ia64/xen-unstable

changeset 8932:012e133941fc

Eliminate hard coded items from x86_64 __xen_guest section
to avoid problems when the position of the hypercall page changes.
Further, clean up many things to avoid needless differences to native
code, while also adding a couple of adjustments that only will be
submitted for native code inclusion, that simplify code, or that
remove unused elements.

From: Jan Beulich <JBeulich@novell.com>
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Mon Feb 20 16:42:54 2006 +0000 (2006-02-20)
parents c93c6b392ce5
children bea58b594c4a
files linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S linux-2.6-xen-sparse/arch/x86_64/kernel/head64-xen.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Mon Feb 20 16:08:27 2006 +0000
     1.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head-xen.S	Mon Feb 20 16:42:54 2006 +0000
     1.3 @@ -14,15 +14,6 @@
     1.4  
     1.5  
     1.6  #include <linux/linkage.h>
     1.7 -
     1.8 -.section __xen_guest
     1.9 -	.ascii	"GUEST_OS=linux,GUEST_VER=2.6"
    1.10 -	.ascii	",XEN_VER=xen-3.0"
    1.11 -	.ascii	",VIRT_BASE=0xffffffff80000000"
    1.12 -	.ascii	",HYPERCALL_PAGE=0x10a" /* __pa(hypercall_page) >> 12 */
    1.13 -	.ascii	",LOADER=generic"
    1.14 -	.byte	0
    1.15 -      
    1.16  #include <linux/threads.h>
    1.17  #include <linux/init.h>
    1.18  #include <asm/desc.h>
    1.19 @@ -30,64 +21,21 @@
    1.20  #include <asm/page.h>
    1.21  #include <asm/msr.h>
    1.22  #include <asm/cache.h>
    1.23 -	
    1.24 -/* we are not able to switch in one step to the final KERNEL ADRESS SPACE
    1.25 - * because we need identity-mapped pages on setup so define __START_KERNEL to
    1.26 - * 0x100000 for this stage
    1.27 - * 
    1.28 - */
    1.29  
    1.30  	.text
    1.31  	.code64
    1.32  	.globl startup_64
    1.33  startup_64:
    1.34  ENTRY(_start)
    1.35 -	movq %rsi,xen_start_info(%rip)
    1.36 -
    1.37 -#ifdef CONFIG_SMP
    1.38 -ENTRY(startup_64_smp)
    1.39 -#endif /* CONFIG_SMP */
    1.40 -
    1.41 -	cld
    1.42 -
    1.43 -	movq init_rsp(%rip),%rsp
    1.44 +	movq $(init_thread_union+THREAD_SIZE-8),%rsp
    1.45  	/* zero EFLAGS after setting rsp */
    1.46  	pushq $0
    1.47  	popfq
    1.48 -	movq	initial_code(%rip),%rax
    1.49 -	jmp	*%rax
    1.50  
    1.51 -	/* SMP bootup changes these two */	
    1.52 -	.globl	initial_code
    1.53 -initial_code:
    1.54 -	.quad	x86_64_start_kernel
    1.55 -	.globl init_rsp
    1.56 -init_rsp:
    1.57 -	.quad  init_thread_union+THREAD_SIZE-8
    1.58 -
    1.59 -ENTRY(early_idt_handler)
    1.60 -	xorl %eax,%eax
    1.61 -	movq 8(%rsp),%rsi	# get rip
    1.62 -	movq (%rsp),%rdx
    1.63 -	leaq early_idt_msg(%rip),%rdi
    1.64 -1:	hlt                     # generate #GP
    1.65 -	jmp 1b
    1.66 -
    1.67 -early_idt_msg:
    1.68 -	.asciz "PANIC: early exception rip %lx error %lx cr2 %lx\n"
    1.69 -
    1.70 -#if 0
    1.71 -ENTRY(lgdt_finish)
    1.72 -        movl $(__USER_DS),%eax          # DS/ES contains default USER segment
    1.73 -        movw %ax,%ds
    1.74 -        movw %ax,%es
    1.75 -        movl $(__KERNEL_DS),%eax        
    1.76 -        movw %ax,%ss                    # after changing gdt.
    1.77 -        popq %rax                       # get the retrun address
    1.78 -        pushq $(__KERNEL_CS)
    1.79 -        pushq %rax
    1.80 -        lretq
    1.81 -#endif 
    1.82 +	/* rsi is pointer to startup info structure.
    1.83 +	   pass it to C */
    1.84 +	movq %rsi,%rdi
    1.85 +	jmp x86_64_start_kernel
    1.86  
    1.87  ENTRY(stext)
    1.88  ENTRY(_stext)
    1.89 @@ -113,39 +61,9 @@ NEXT_PAGE(init_level4_pgt)
    1.90  NEXT_PAGE(init_level4_user_pgt)
    1.91  	.fill	512,8,0
    1.92  
    1.93 -	/*
    1.94 -	 * In Xen the following pre-initialized pgt entries are re-initialized.
    1.95 -	 */
    1.96  NEXT_PAGE(level3_kernel_pgt)
    1.97 -	.fill	510,8,0
    1.98 -	/* (2^48-(2*1024*1024*1024)-((2^39)*511))/(2^30) = 510 */
    1.99 -	.quad	phys_level2_kernel_pgt | 0x007
   1.100 -	.fill	1,8,0
   1.101 +	.fill	512,8,0
   1.102  
   1.103 -NEXT_PAGE(level2_ident_pgt)
   1.104 -	/* 40MB for bootup. 	*/
   1.105 -	i = 0
   1.106 -	.rept 20
   1.107 -	.quad	i << 21 | 0x083
   1.108 -	i = i + 1
   1.109 -	.endr
   1.110 -	/* Temporary mappings for the super early allocator in arch/x86_64/mm/init.c */
   1.111 -	.globl temp_boot_pmds
   1.112 -temp_boot_pmds:
   1.113 -	.fill	492,8,0
   1.114 -
   1.115 -NEXT_PAGE(level2_kernel_pgt)
   1.116 -	/* 40MB kernel mapping. The kernel code cannot be bigger than that.
   1.117 -	   When you change this change KERNEL_TEXT_SIZE in page.h too. */
   1.118 -	/* (2^48-(2*1024*1024*1024)-((2^39)*511)-((2^30)*510)) = 0 */
   1.119 -	i = 0
   1.120 -	.rept 20
   1.121 -	.quad	i << 21 | 0x183
   1.122 -	i = i + 1
   1.123 -	.endr
   1.124 -	/* Module mapping starts here */
   1.125 -	.fill	492,8,0
   1.126 -	
   1.127          /*
   1.128           * This is used for vsyscall area mapping as we have a different
   1.129           * level4 page table for user.
   1.130 @@ -153,81 +71,19 @@ NEXT_PAGE(level2_kernel_pgt)
   1.131  NEXT_PAGE(level3_user_pgt)
   1.132          .fill	512,8,0
   1.133  
   1.134 -NEXT_PAGE(cpu_gdt_table)
   1.135 -/* The TLS descriptors are currently at a different place compared to i386.
   1.136 -   Hopefully nobody expects them at a fixed place (Wine?) */
   1.137 -	.quad	0x0000000000000000	/* NULL descriptor */
   1.138 -	.quad	0x0			/* unused */
   1.139 -	.quad	0x00affa000000ffff	/* __KERNEL_CS */
   1.140 -	.quad	0x00cff2000000ffff	/* __KERNEL_DS */
   1.141 -       	.quad	0x00cffa000000ffff	/* __USER32_CS */
   1.142 -	.quad	0x00cff2000000ffff	/* __USER_DS, __USER32_DS  */		
   1.143 -	.quad	0x00affa000000ffff	/* __USER_CS */
   1.144 -	.quad	0x00cffa000000ffff	/* __KERNEL32_CS */        
   1.145 -	.quad	0,0			/* TSS */
   1.146 -	.quad	0,0			/* LDT */
   1.147 -	.quad   0,0,0			/* three TLS descriptors */ 
   1.148 -	.quad	0			/* unused */
   1.149 -gdt_end:
   1.150 -#if 0
   1.151 -	/* asm/segment.h:GDT_ENTRIES must match this */	
   1.152 -	/* This should be a multiple of the cache line size */
   1.153 -	/* GDTs of other CPUs are now dynamically allocated */
   1.154 -
   1.155 -	/* zero the remaining page */
   1.156 -	.fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
   1.157 -#endif
   1.158 +NEXT_PAGE(level2_kernel_pgt)
   1.159 +	.fill	512,8,0
   1.160  
   1.161  NEXT_PAGE(empty_zero_page)
   1.162 -
   1.163 -NEXT_PAGE(level3_physmem_pgt)
   1.164 -	.quad	phys_level2_kernel_pgt | 0x007	/* so that __va works even before pagetable_init */
   1.165 +	.skip PAGE_SIZE
   1.166  
   1.167  NEXT_PAGE(hypercall_page)
   1.168 -.if (phys_hypercall_page - 0x10a000)
   1.169 -	/* cause compiler error if the hypercall_page is at a
   1.170 -	 * different address than expected. */
   1.171 -	.quad	__adjust_hypercall_page_in_header
   1.172 -.endif
   1.173  	.fill	512,8,0
   1.174  
   1.175  #undef NEXT_PAGE
   1.176  
   1.177  	.data
   1.178  
   1.179 -#ifndef CONFIG_XEN
   1.180 -#ifdef CONFIG_ACPI_SLEEP
   1.181 -	.align PAGE_SIZE
   1.182 -ENTRY(wakeup_level4_pgt)
   1.183 -	.quad	phys_level3_ident_pgt | 0x007
   1.184 -	.fill	255,8,0
   1.185 -	.quad	phys_level3_physmem_pgt | 0x007
   1.186 -	.fill	254,8,0
   1.187 -	/* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
   1.188 -	.quad	phys_level3_kernel_pgt | 0x007
   1.189 -#endif
   1.190 -
   1.191 -#ifndef CONFIG_HOTPLUG_CPU
   1.192 -	__INITDATA
   1.193 -#endif
   1.194 -	/*
   1.195 -	 * This default setting generates an ident mapping at address 0x100000
   1.196 -	 * and a mapping for the kernel that precisely maps virtual address
   1.197 -	 * 0xffffffff80000000 to physical address 0x000000. (always using
   1.198 -	 * 2Mbyte large pages provided by PAE mode)
   1.199 -	 */
   1.200 -	.align PAGE_SIZE
   1.201 -ENTRY(boot_level4_pgt)
   1.202 -	.quad	phys_level3_ident_pgt | 0x007
   1.203 -	.fill	255,8,0
   1.204 -	.quad	phys_level3_physmem_pgt | 0x007
   1.205 -	.fill	254,8,0
   1.206 -	/* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
   1.207 -	.quad	phys_level3_kernel_pgt | 0x007
   1.208 -#endif
   1.209 -
   1.210 -	.data
   1.211 -
   1.212  	.align 16
   1.213  	.globl cpu_gdt_descr
   1.214  cpu_gdt_descr:
   1.215 @@ -246,11 +102,59 @@ gdt:
   1.216   * Also sysret mandates a special GDT layout 
   1.217   */
   1.218  		 		
   1.219 -.align PAGE_SIZE
   1.220 +	.section .data.page_aligned, "aw"
   1.221 +	.align PAGE_SIZE
   1.222 +
   1.223 +/* The TLS descriptors are currently at a different place compared to i386.
   1.224 +   Hopefully nobody expects them at a fixed place (Wine?) */
   1.225  
   1.226 +ENTRY(cpu_gdt_table)
   1.227 +	.quad	0x0000000000000000	/* NULL descriptor */
   1.228 +	.quad	0x0			/* unused */
   1.229 +	.quad	0x00affa000000ffff	/* __KERNEL_CS */
   1.230 +	.quad	0x00cff2000000ffff	/* __KERNEL_DS */
   1.231 +	.quad	0x00cffa000000ffff	/* __USER32_CS */
   1.232 +	.quad	0x00cff2000000ffff	/* __USER_DS, __USER32_DS  */
   1.233 +	.quad	0x00affa000000ffff	/* __USER_CS */
   1.234 +	.quad	0x00cffa000000ffff	/* __KERNEL32_CS */
   1.235 +	.quad	0,0			/* TSS */
   1.236 +	.quad	0,0			/* LDT */
   1.237 +	.quad   0,0,0			/* three TLS descriptors */
   1.238 +	.quad	0			/* unused */
   1.239 +gdt_end:
   1.240 +	/* asm/segment.h:GDT_ENTRIES must match this */
   1.241 +	/* This should be a multiple of the cache line size */
   1.242 +	/* GDTs of other CPUs are now dynamically allocated */
   1.243 +
   1.244 +	/* zero the remaining page */
   1.245 +	.fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
   1.246 +
   1.247 +	.section .bss, "aw", @nobits
   1.248 +	.align L1_CACHE_BYTES
   1.249  ENTRY(idt_table)	
   1.250  	.rept   256
   1.251  	.quad   0
   1.252  	.quad 	0
   1.253  	.endr
   1.254  
   1.255 +/*
   1.256 + * __xen_guest information
   1.257 + */
   1.258 +.macro utoh value
   1.259 + .if (\value) < 0 || (\value) >= 0x10
   1.260 +	utoh (((\value)>>4)&0x0fffffffffffffff)
   1.261 + .endif
   1.262 + .if ((\value) & 0xf) < 10
   1.263 +  .byte '0' + ((\value) & 0xf)
   1.264 + .else
   1.265 +  .byte 'A' + ((\value) & 0xf) - 10
   1.266 + .endif
   1.267 +.endm
   1.268 +
   1.269 +.section __xen_guest
   1.270 +	.ascii	"GUEST_OS=linux,GUEST_VER=2.6"
   1.271 +	.ascii	",XEN_VER=xen-3.0"
   1.272 +	.ascii	",VIRT_BASE=0x"; utoh __START_KERNEL_map
   1.273 +	.ascii	",HYPERCALL_PAGE=0x"; utoh (phys_hypercall_page >> PAGE_SHIFT)
   1.274 +	.ascii	",LOADER=generic"
   1.275 +	.byte	0
     2.1 --- a/linux-2.6-xen-sparse/arch/x86_64/kernel/head64-xen.c	Mon Feb 20 16:08:27 2006 +0000
     2.2 +++ b/linux-2.6-xen-sparse/arch/x86_64/kernel/head64-xen.c	Mon Feb 20 16:42:54 2006 +0000
     2.3 @@ -47,7 +47,7 @@ extern char saved_command_line[];
     2.4  
     2.5  static void __init copy_bootdata(char *real_mode_data)
     2.6  {
     2.7 -#if 0
     2.8 +#ifndef CONFIG_XEN
     2.9  	int new_data;
    2.10  	char * command_line;
    2.11  
    2.12 @@ -63,7 +63,6 @@ static void __init copy_bootdata(char *r
    2.13  	}
    2.14  	command_line = (char *) ((u64)(new_data));
    2.15  	memcpy(saved_command_line, command_line, COMMAND_LINE_SIZE);
    2.16 -	printk("Bootdata ok (command line is %s)\n", saved_command_line);
    2.17  #else
    2.18  	int max_cmdline;
    2.19  	
    2.20 @@ -71,8 +70,8 @@ static void __init copy_bootdata(char *r
    2.21  		max_cmdline = COMMAND_LINE_SIZE;
    2.22  	memcpy(saved_command_line, xen_start_info->cmd_line, max_cmdline);
    2.23  	saved_command_line[max_cmdline-1] = '\0';
    2.24 +#endif
    2.25  	printk("Bootdata ok (command line is %s)\n", saved_command_line);
    2.26 -#endif
    2.27  }
    2.28  
    2.29  static void __init setup_boot_cpu_data(void)
    2.30 @@ -98,6 +97,7 @@ void __init x86_64_start_kernel(char * r
    2.31  	char *s;
    2.32  	int i;
    2.33  
    2.34 +	xen_start_info = (struct start_info *)real_mode_data;
    2.35  	if (!xen_feature(XENFEAT_auto_translated_physmap)) {
    2.36  		phys_to_machine_mapping =
    2.37  			(unsigned long *)xen_start_info->mfn_list;
    2.38 @@ -105,9 +105,9 @@ void __init x86_64_start_kernel(char * r
    2.39  			xen_start_info->nr_pt_frames;
    2.40  	}
    2.41  
    2.42 +#if 0
    2.43  	for (i = 0; i < 256; i++)
    2.44  		set_intr_gate(i, early_idt_handler);
    2.45 -#if 0
    2.46  	asm volatile("lidt %0" :: "m" (idt_descr));
    2.47  #endif
    2.48