ia64/xen-unstable
changeset 1656:c6692e37c11f
bitkeeper revision 1.1041.1.8 (40e42bdbxRgFLnyaLAVXrbfK0RQrgg)
Cleanups.
Cleanups.
author | kaf24@scramble.cl.cam.ac.uk |
---|---|
date | Thu Jul 01 15:20:59 2004 +0000 (2004-07-01) |
parents | aa6d5eac6275 |
children | 720ab2010246 006c505fe15f |
files | .rootkeys xen/arch/x86/Makefile xen/arch/x86/boot/boot.S xen/arch/x86/boot/x86_32.S xen/arch/x86/boot/x86_64.S xen/arch/x86/setup.c xen/common/kernel.c xen/include/asm-x86/config.h |
line diff
1.1 --- a/.rootkeys Thu Jul 01 11:04:02 2004 +0000 1.2 +++ b/.rootkeys Thu Jul 01 15:20:59 2004 +0000 1.3 @@ -281,7 +281,8 @@ 3ddb79bcZbRBzT3elFWSX7u6NtMagQ xen/arch/ 1.4 3ddb79bcBQF85CfLS4i1WGZ4oLLaCA xen/arch/x86/Rules.mk 1.5 3e5636e5FAYZ5_vQnmgwFJfSdmO5Mw xen/arch/x86/acpi.c 1.6 3ddb79bcsjinG9k1KcvbVBuas1R2dA xen/arch/x86/apic.c 1.7 -3ddb79bcSC_LvnmFlX-T5iTgaR0SKg xen/arch/x86/boot/boot.S 1.8 +3ddb79bcSC_LvnmFlX-T5iTgaR0SKg xen/arch/x86/boot/x86_32.S 1.9 +40e42bdbNu4MjI750THP_8J1S-Sa0g xen/arch/x86/boot/x86_64.S 1.10 3ddb79bcUrk2EIaM5VsT6wUudH1kkg xen/arch/x86/delay.c 1.11 3e32af9aRnYGl4GMOaDKp7JdfhOGhg xen/arch/x86/domain_page.c 1.12 3ddb79bcecupHj56ZbTa3B0FxDowMg xen/arch/x86/entry.S
2.1 --- a/xen/arch/x86/Makefile Thu Jul 01 11:04:02 2004 +0000 2.2 +++ b/xen/arch/x86/Makefile Thu Jul 01 15:20:59 2004 +0000 2.3 @@ -15,9 +15,9 @@ LOAD_BASE := 0x00100000 # Xen is loaded 2.4 # segment offsets from LINK_BASE-relative to LOAD_BASE-relative. 2.5 # (NB. Linux gets round this by turning its image into raw binary, then 2.6 # wrapping that with a low-memory bootstrapper.) 2.7 -default: boot/boot.o $(OBJS) 2.8 +default: boot/$(TARGET_SUBARCH).o $(OBJS) 2.9 $(LD) -r -o arch.o $(OBJS) 2.10 - $(LD) $(LDFLAGS) boot/boot.o $(ALL_OBJS) -o $(TARGET)-syms 2.11 + $(LD) $(LDFLAGS) boot/$(TARGET_SUBARCH).o $(ALL_OBJS) -o $(TARGET)-syms 2.12 objcopy -R .note -R .comment -S $(TARGET)-syms $(TARGET) 2.13 $(BASEDIR)/tools/elf-reloc $(LINK_BASE) $(LOAD_BASE) $(TARGET) 2.14
3.1 --- a/xen/arch/x86/boot/boot.S Thu Jul 01 11:04:02 2004 +0000 3.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 3.3 @@ -1,249 +0,0 @@ 3.4 -#include <xen/config.h> 3.5 -#include <hypervisor-ifs/hypervisor-if.h> 3.6 -#include <asm/page.h> 3.7 - 3.8 -#define SECONDARY_CPU_FLAG 0xA5A5A5A5 3.9 - 3.10 - .text 3.11 - 3.12 -ENTRY(start) 3.13 - jmp hal_entry 3.14 - 3.15 - .align 4 3.16 - 3.17 -/*** MULTIBOOT HEADER ****/ 3.18 - /* Magic number indicating a Multiboot header. */ 3.19 - .long 0x1BADB002 3.20 - /* Flags to bootloader (see Multiboot spec). */ 3.21 - .long 0x00000002 3.22 - /* Checksum: must be the negated sum of the first two fields. */ 3.23 - .long -0x1BADB004 3.24 - 3.25 -hal_entry: 3.26 - /* Set up a few descriptors: on entry only CS is guaranteed good. */ 3.27 - lgdt %cs:nopaging_gdt_descr-__PAGE_OFFSET 3.28 - mov $(__HYPERVISOR_DS),%ecx 3.29 - mov %ecx,%ds 3.30 - mov %ecx,%es 3.31 - mov %ecx,%fs 3.32 - mov %ecx,%gs 3.33 - ljmp $(__HYPERVISOR_CS),$(1f)-__PAGE_OFFSET 3.34 -1: lss stack_start-__PAGE_OFFSET,%esp 3.35 - 3.36 - /* Reset EFLAGS (subsumes CLI and CLD). */ 3.37 - pushl $0 3.38 - popf 3.39 - 3.40 - /* CPU type checks. We need P6+. */ 3.41 - mov $0x200000,%edx 3.42 - pushfl 3.43 - pop %ecx 3.44 - and %edx,%ecx 3.45 - jne bad_cpu # ID bit should be clear 3.46 - pushl %edx 3.47 - popfl 3.48 - pushfl 3.49 - pop %ecx 3.50 - and %edx,%ecx 3.51 - je bad_cpu # ID bit should be set 3.52 - 3.53 - /* Set up CR0. */ 3.54 - mov %cr0,%ecx 3.55 - and $0x00000011,%ecx # save ET and PE 3.56 - or $0x00050022,%ecx # set AM, WP, NE and MP 3.57 - mov %ecx,%cr0 3.58 - 3.59 - /* Set up FPU. */ 3.60 - fninit 3.61 - 3.62 - /* Set up CR4, except global flag which Intel requires should be */ 3.63 - /* left until after paging is enabled (IA32 Manual Vol. 3, Sec. 2.5) */ 3.64 - mov %cr4,%ecx 3.65 - or mmu_cr4_features-__PAGE_OFFSET,%ecx 3.66 - mov %ecx,mmu_cr4_features-__PAGE_OFFSET 3.67 - and $0x7f,%ecx /* disable GLOBAL bit */ 3.68 - mov %ecx,%cr4 3.69 - 3.70 -#ifdef CONFIG_SMP 3.71 - /* Is this a non-boot processor? */ 3.72 - cmp $(SECONDARY_CPU_FLAG),%ebx 3.73 - jne continue_boot_cpu 3.74 - 3.75 - call start_paging 3.76 - lidt idt_descr 3.77 - jmp start_secondary 3.78 -#endif 3.79 - 3.80 -continue_boot_cpu: 3.81 - add $__PAGE_OFFSET,%ebx 3.82 - push %ebx /* Multiboot info struct */ 3.83 - push %eax /* Multiboot magic value */ 3.84 - 3.85 - /* Initialize BSS (no nasty surprises!) */ 3.86 - mov $__bss_start-__PAGE_OFFSET,%edi 3.87 - mov $_end-__PAGE_OFFSET,%ecx 3.88 - sub %edi,%ecx 3.89 - xor %eax,%eax 3.90 - rep stosb 3.91 - 3.92 - /* Copy all modules (dom0 + initrd if present) out of the Xen heap */ 3.93 - mov (%esp),%eax 3.94 - cmp $0x2BADB002,%eax 3.95 - jne skip_dom0_copy 3.96 - sub $__PAGE_OFFSET,%ebx /* turn back into a phys addr */ 3.97 - mov 0x14(%ebx),%edi /* mbi->mods_count */ 3.98 - dec %edi /* mbi->mods_count-- */ 3.99 - jb skip_dom0_copy /* skip if no modules */ 3.100 - mov 0x18(%ebx),%eax /* mbi->mods_addr */ 3.101 - mov (%eax),%ebx /* %ebx = mod[0]->mod_start */ 3.102 - shl $4,%edi 3.103 - add %edi,%eax 3.104 - mov 0x4(%eax),%eax /* %eax = mod[mod_count-1]->end */ 3.105 - mov %eax,%ecx 3.106 - sub %ebx,%ecx /* %ecx = byte len of all mods */ 3.107 - mov $(DIRECTMAP_PHYS_END), %edi 3.108 - add %ecx, %edi /* %edi = src + length */ 3.109 - shr $2,%ecx /* %ecx = length/4 */ 3.110 -1: sub $4,%eax /* %eax = src, %edi = dst */ 3.111 - sub $4,%edi 3.112 - mov (%eax),%ebx 3.113 - mov %ebx,(%edi) 3.114 - loop 1b 3.115 -skip_dom0_copy: 3.116 - 3.117 - /* Initialize low and high mappings of all memory with 4MB pages */ 3.118 - mov $idle_pg_table-__PAGE_OFFSET,%edi 3.119 - mov $0x1e3,%eax /* PRESENT+RW+A+D+4MB+GLOBAL */ 3.120 -1: mov %eax,__PAGE_OFFSET>>20(%edi) /* high mapping */ 3.121 - stosl /* low mapping */ 3.122 - add $(1<<L2_PAGETABLE_SHIFT),%eax 3.123 - cmp $DIRECTMAP_PHYS_END+0x1e3,%eax 3.124 - jne 1b 3.125 - 3.126 - call start_paging 3.127 - call setup_idt 3.128 - lidt idt_descr 3.129 - 3.130 - /* Call into main C routine. This should never return.*/ 3.131 - call cmain 3.132 - ud2 /* Force a panic (invalid opcode). */ 3.133 - 3.134 -start_paging: 3.135 - mov $idle_pg_table-__PAGE_OFFSET,%eax 3.136 - mov %eax,%cr3 3.137 - mov %cr0,%eax 3.138 - or $0x80010000,%eax /* set PG and WP bits */ 3.139 - mov %eax,%cr0 3.140 - jmp 1f 3.141 -1: /* Install relocated selectors (FS/GS unused). */ 3.142 - lgdt gdt_descr 3.143 - mov $(__HYPERVISOR_DS),%ecx 3.144 - mov %ecx,%ds 3.145 - mov %ecx,%es 3.146 - mov %ecx,%ss 3.147 - ljmp $(__HYPERVISOR_CS),$1f 3.148 -1: /* Paging enabled, so we can now enable GLOBAL mappings in CR4. */ 3.149 - movl mmu_cr4_features,%ecx 3.150 - movl %ecx,%cr4 3.151 - /* Relocate ESP */ 3.152 - add $__PAGE_OFFSET,%esp 3.153 - /* Relocate EIP via return jump */ 3.154 - pop %ecx 3.155 - add $__PAGE_OFFSET,%ecx 3.156 - jmp *%ecx 3.157 - 3.158 - 3.159 -/*** INTERRUPT INITIALISATION ***/ 3.160 - 3.161 -setup_idt: 3.162 - lea ignore_int,%edx 3.163 - mov $(__HYPERVISOR_CS << 16),%eax 3.164 - mov %dx,%ax /* selector = 0x0010 = cs */ 3.165 - mov $0x8E00,%dx /* interrupt gate - dpl=0, present */ 3.166 - 3.167 - lea SYMBOL_NAME(idt_table),%edi 3.168 - mov $256,%ecx 3.169 -1: mov %eax,(%edi) 3.170 - mov %edx,4(%edi) 3.171 - add $8,%edi 3.172 - loop 1b 3.173 - ret 3.174 - 3.175 -/* This is the default interrupt handler. */ 3.176 -int_msg: 3.177 - .asciz "Unknown interrupt\n" 3.178 - ALIGN 3.179 -ignore_int: 3.180 - cld 3.181 - push %eax 3.182 - push %ecx 3.183 - push %edx 3.184 - pushl %es 3.185 - pushl %ds 3.186 - mov $(__HYPERVISOR_DS),%eax 3.187 - mov %eax,%ds 3.188 - mov %eax,%es 3.189 - pushl $int_msg 3.190 - call SYMBOL_NAME(printf) 3.191 -1: jmp 1b 3.192 - 3.193 -bad_cpu_msg: 3.194 - .asciz "Bad CPU type. Need P6+." 3.195 - ALIGN 3.196 -bad_cpu: 3.197 - pushl $bad_cpu_msg 3.198 - call SYMBOL_NAME(printf) 3.199 -1: jmp 1b 3.200 - 3.201 -/*** STACK LOCATION ***/ 3.202 - 3.203 -ENTRY(stack_start) 3.204 - .long SYMBOL_NAME(cpu0_stack) + 8100 - __PAGE_OFFSET 3.205 - .long __HYPERVISOR_DS 3.206 - 3.207 -/*** DESCRIPTOR TABLES ***/ 3.208 - 3.209 -.globl SYMBOL_NAME(idt) 3.210 -.globl SYMBOL_NAME(gdt) 3.211 - 3.212 - ALIGN 3.213 - 3.214 - .word 0 3.215 -idt_descr: 3.216 - .word 256*8-1 3.217 -SYMBOL_NAME(idt): 3.218 - .long SYMBOL_NAME(idt_table) 3.219 - 3.220 - .word 0 3.221 -gdt_descr: 3.222 - .word (LAST_RESERVED_GDT_ENTRY*8)+7 3.223 -SYMBOL_NAME(gdt): 3.224 - .long SYMBOL_NAME(gdt_table) /* gdt base */ 3.225 - 3.226 - .word 0 3.227 -nopaging_gdt_descr: 3.228 - .word (LAST_RESERVED_GDT_ENTRY*8)+7 3.229 - .long SYMBOL_NAME(gdt_table)-__PAGE_OFFSET 3.230 - 3.231 - ALIGN 3.232 -/* NB. Rings != 0 get access up to 0xFC400000. This allows access to the */ 3.233 -/* machine->physical mapping table. Ring 0 can access all memory. */ 3.234 -ENTRY(gdt_table) 3.235 - .fill FIRST_RESERVED_GDT_ENTRY,8,0 3.236 - .quad 0x0000000000000000 /* unused */ 3.237 - .quad 0x00cf9a000000ffff /* 0x0808 ring 0 4.00GB code at 0x0 */ 3.238 - .quad 0x00cf92000000ffff /* 0x0810 ring 0 4.00GB data at 0x0 */ 3.239 - .quad 0x00cfba000000c3ff /* 0x0819 ring 1 3.95GB code at 0x0 */ 3.240 - .quad 0x00cfb2000000c3ff /* 0x0821 ring 1 3.95GB data at 0x0 */ 3.241 - .quad 0x00cffa000000c3ff /* 0x082b ring 3 3.95GB code at 0x0 */ 3.242 - .quad 0x00cff2000000c3ff /* 0x0833 ring 3 3.95GB data at 0x0 */ 3.243 - .quad 0x0000000000000000 /* unused */ 3.244 - .fill 2*NR_CPUS,8,0 /* space for TSS and LDT per CPU */ 3.245 - 3.246 - .org 0x1000 3.247 -ENTRY(idle_pg_table) # Initial page directory is 4kB 3.248 - .org 0x2000 3.249 -ENTRY(cpu0_stack) # Initial stack is 8kB 3.250 - .org 0x4000 3.251 -ENTRY(stext) 3.252 -ENTRY(_stext)
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/xen/arch/x86/boot/x86_32.S Thu Jul 01 15:20:59 2004 +0000 4.3 @@ -0,0 +1,193 @@ 4.4 +#include <xen/config.h> 4.5 +#include <hypervisor-ifs/hypervisor-if.h> 4.6 +#include <asm/page.h> 4.7 + 4.8 +#define SECONDARY_CPU_FLAG 0xA5A5A5A5 4.9 + 4.10 + .text 4.11 + 4.12 +ENTRY(start) 4.13 + jmp __start 4.14 + 4.15 + .align 4 4.16 + 4.17 +/*** MULTIBOOT HEADER ****/ 4.18 + /* Magic number indicating a Multiboot header. */ 4.19 + .long 0x1BADB002 4.20 + /* Flags to bootloader (see Multiboot spec). */ 4.21 + .long 0x00000002 4.22 + /* Checksum: must be the negated sum of the first two fields. */ 4.23 + .long -0x1BADB004 4.24 + 4.25 +bad_cpu: 4.26 + jmp bad_cpu 4.27 + 4.28 +__start: 4.29 + /* Set up a few descriptors: on entry only CS is guaranteed good. */ 4.30 + lgdt %cs:nopaging_gdt_descr-__PAGE_OFFSET 4.31 + mov $(__HYPERVISOR_DS),%ecx 4.32 + mov %ecx,%ds 4.33 + mov %ecx,%es 4.34 + mov %ecx,%fs 4.35 + mov %ecx,%gs 4.36 + ljmp $(__HYPERVISOR_CS),$(1f)-__PAGE_OFFSET 4.37 +1: lss stack_start-__PAGE_OFFSET,%esp 4.38 + 4.39 + /* Reset EFLAGS (subsumes CLI and CLD). */ 4.40 + pushl $0 4.41 + popf 4.42 + 4.43 + /* CPU type checks. We need P6+. */ 4.44 + mov $0x200000,%edx 4.45 + pushfl 4.46 + pop %ecx 4.47 + and %edx,%ecx 4.48 + jne bad_cpu # ID bit should be clear 4.49 + pushl %edx 4.50 + popfl 4.51 + pushfl 4.52 + pop %ecx 4.53 + and %edx,%ecx 4.54 + je bad_cpu # ID bit should be set 4.55 + 4.56 + /* Set up FPU. */ 4.57 + fninit 4.58 + 4.59 + /* Set up CR4, except global flag which Intel requires should be */ 4.60 + /* left until after paging is enabled (IA32 Manual Vol. 3, Sec. 2.5) */ 4.61 + mov mmu_cr4_features-__PAGE_OFFSET,%ecx 4.62 + and $0x7f,%cl # CR4.PGE (global enable) 4.63 + mov %ecx,%cr4 4.64 + 4.65 + cmp $(SECONDARY_CPU_FLAG),%ebx 4.66 + je start_paging 4.67 + 4.68 + add $__PAGE_OFFSET,%ebx 4.69 + push %ebx /* Multiboot info struct */ 4.70 + push %eax /* Multiboot magic value */ 4.71 + 4.72 + /* Initialize BSS (no nasty surprises!) */ 4.73 + mov $__bss_start-__PAGE_OFFSET,%edi 4.74 + mov $_end-__PAGE_OFFSET,%ecx 4.75 + sub %edi,%ecx 4.76 + xor %eax,%eax 4.77 + rep stosb 4.78 + 4.79 + /* Initialize low and high mappings of all memory with 4MB pages */ 4.80 + mov $idle_pg_table-__PAGE_OFFSET,%edi 4.81 + mov $0x1e3,%eax /* PRESENT+RW+A+D+4MB+GLOBAL */ 4.82 +1: mov %eax,__PAGE_OFFSET>>20(%edi) /* high mapping */ 4.83 + stosl /* low mapping */ 4.84 + add $(1<<L2_PAGETABLE_SHIFT),%eax 4.85 + cmp $DIRECTMAP_PHYS_END+0x1e3,%eax 4.86 + jne 1b 4.87 +1: stosl /* low mappings cover as much physmem as possible */ 4.88 + add $(1<<L2_PAGETABLE_SHIFT),%eax 4.89 + cmp $__HYPERVISOR_VIRT_START+0x1e3,%eax 4.90 + jne 1b 4.91 + 4.92 + /* Initialise IDT with simple error defaults. */ 4.93 + lea ignore_int,%edx 4.94 + mov $(__HYPERVISOR_CS << 16),%eax 4.95 + mov %dx,%ax /* selector = 0x0010 = cs */ 4.96 + mov $0x8E00,%dx /* interrupt gate - dpl=0, present */ 4.97 + lea SYMBOL_NAME(idt_table)-__PAGE_OFFSET,%edi 4.98 + mov $256,%ecx 4.99 +1: mov %eax,(%edi) 4.100 + mov %edx,4(%edi) 4.101 + add $8,%edi 4.102 + loop 1b 4.103 + 4.104 +start_paging: 4.105 + mov $idle_pg_table-__PAGE_OFFSET,%eax 4.106 + mov %eax,%cr3 4.107 + mov $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */ 4.108 + mov %eax,%cr0 4.109 + jmp 1f 4.110 +1: /* Install relocated selectors (FS/GS unused). */ 4.111 + lgdt gdt_descr 4.112 + mov $(__HYPERVISOR_DS),%ecx 4.113 + mov %ecx,%ds 4.114 + mov %ecx,%es 4.115 + mov %ecx,%ss 4.116 + ljmp $(__HYPERVISOR_CS),$1f 4.117 +1: /* Paging enabled, so we can now enable GLOBAL mappings in CR4. */ 4.118 + mov mmu_cr4_features,%ecx 4.119 + mov %ecx,%cr4 4.120 + /* Relocate ESP */ 4.121 + add $__PAGE_OFFSET,%esp 4.122 + 4.123 + lidt idt_descr 4.124 + 4.125 + cmp $(SECONDARY_CPU_FLAG),%ebx 4.126 + je start_secondary 4.127 + 4.128 + /* Call into main C routine. This should never return.*/ 4.129 + call cmain 4.130 + ud2 /* Force a panic (invalid opcode). */ 4.131 + 4.132 +/* This is the default interrupt handler. */ 4.133 +int_msg: 4.134 + .asciz "Unknown interrupt\n" 4.135 + ALIGN 4.136 +ignore_int: 4.137 + cld 4.138 + mov $(__HYPERVISOR_DS),%eax 4.139 + mov %eax,%ds 4.140 + mov %eax,%es 4.141 + pushl $int_msg 4.142 + call SYMBOL_NAME(printf) 4.143 +1: jmp 1b 4.144 + 4.145 +/*** STACK LOCATION ***/ 4.146 + 4.147 +ENTRY(stack_start) 4.148 + .long SYMBOL_NAME(cpu0_stack) + 8100 - __PAGE_OFFSET 4.149 + .long __HYPERVISOR_DS 4.150 + 4.151 +/*** DESCRIPTOR TABLES ***/ 4.152 + 4.153 +.globl SYMBOL_NAME(idt) 4.154 +.globl SYMBOL_NAME(gdt) 4.155 + 4.156 + ALIGN 4.157 + 4.158 + .word 0 4.159 +idt_descr: 4.160 + .word 256*8-1 4.161 +SYMBOL_NAME(idt): 4.162 + .long SYMBOL_NAME(idt_table) 4.163 + 4.164 + .word 0 4.165 +gdt_descr: 4.166 + .word (LAST_RESERVED_GDT_ENTRY*8)+7 4.167 +SYMBOL_NAME(gdt): 4.168 + .long SYMBOL_NAME(gdt_table) /* gdt base */ 4.169 + 4.170 + .word 0 4.171 +nopaging_gdt_descr: 4.172 + .word (LAST_RESERVED_GDT_ENTRY*8)+7 4.173 + .long SYMBOL_NAME(gdt_table)-__PAGE_OFFSET 4.174 + 4.175 + ALIGN 4.176 +/* NB. Rings != 0 get access up to 0xFC400000. This allows access to the */ 4.177 +/* machine->physical mapping table. Ring 0 can access all memory. */ 4.178 +ENTRY(gdt_table) 4.179 + .fill FIRST_RESERVED_GDT_ENTRY,8,0 4.180 + .quad 0x0000000000000000 /* unused */ 4.181 + .quad 0x00cf9a000000ffff /* 0x0808 ring 0 4.00GB code at 0x0 */ 4.182 + .quad 0x00cf92000000ffff /* 0x0810 ring 0 4.00GB data at 0x0 */ 4.183 + .quad 0x00cfba000000c3ff /* 0x0819 ring 1 3.95GB code at 0x0 */ 4.184 + .quad 0x00cfb2000000c3ff /* 0x0821 ring 1 3.95GB data at 0x0 */ 4.185 + .quad 0x00cffa000000c3ff /* 0x082b ring 3 3.95GB code at 0x0 */ 4.186 + .quad 0x00cff2000000c3ff /* 0x0833 ring 3 3.95GB data at 0x0 */ 4.187 + .quad 0x0000000000000000 /* unused */ 4.188 + .fill 2*NR_CPUS,8,0 /* space for TSS and LDT per CPU */ 4.189 + 4.190 + .org 0x1000 4.191 +ENTRY(idle_pg_table) # Initial page directory is 4kB 4.192 + .org 0x2000 4.193 +ENTRY(cpu0_stack) # Initial stack is 8kB 4.194 + .org 0x4000 4.195 +ENTRY(stext) 4.196 +ENTRY(_stext)
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 5.2 +++ b/xen/arch/x86/boot/x86_64.S Thu Jul 01 15:20:59 2004 +0000 5.3 @@ -0,0 +1,185 @@ 5.4 +#include <xen/config.h> 5.5 +#include <hypervisor-ifs/hypervisor-if.h> 5.6 +#include <asm/page.h> 5.7 + 5.8 +#define SECONDARY_CPU_FLAG 0xA5A5A5A5 5.9 + 5.10 + .text 5.11 + .code32 5.12 + 5.13 +ENTRY(start) 5.14 + jmp __start 5.15 + 5.16 + .align 4 5.17 + 5.18 +/*** MULTIBOOT HEADER ****/ 5.19 + /* Magic number indicating a Multiboot header. */ 5.20 + .long 0x1BADB002 5.21 + /* Flags to bootloader (see Multiboot spec). */ 5.22 + .long 0x00000002 5.23 + /* Checksum: must be the negated sum of the first two fields. */ 5.24 + .long -0x1BADB004 5.25 + 5.26 +bad_cpu: 5.27 + jmp bad_cpu 5.28 + 5.29 +__start: 5.30 + /* We begin by interrogating the CPU for the presence of long mode. */ 5.31 + mov $0x80000000,%eax 5.32 + cpuid 5.33 + cmp $0x80000000,%eax # any function > 0x80000000? 5.34 + jbe bad_cpu 5.35 + mov $0x80000001,%eax 5.36 + cpuid 5.37 + bt $29,%edx # Long mode feature? 5.38 + jnc bad_cpu 5.39 + 5.40 + /* Set up a few descriptors: on entry only CS is guaranteed good. */ 5.41 + lgdt %cs:nopaging_gdt_descr-__PAGE_OFFSET 5.42 + mov $(__HYPERVISOR_DS),%ecx 5.43 + mov %ecx,%ds 5.44 + mov %ecx,%es 5.45 + mov %ecx,%fs 5.46 + mov %ecx,%gs 5.47 + ljmp $(__HYPERVISOR_CS32),$(1f)-__PAGE_OFFSET 5.48 +1: lss stack_start-__PAGE_OFFSET,%esp 5.49 + 5.50 + /* Reset EFLAGS (subsumes CLI and CLD). */ 5.51 + pushl $0 5.52 + popf 5.53 + 5.54 + /* Set up FPU. */ 5.55 + fninit 5.56 + 5.57 + /* Set up CR4, except global flag which Intel requires should be */ 5.58 + /* left until after paging is enabled (IA32 Manual Vol. 3, Sec. 2.5) */ 5.59 + mov mmu_cr4_features-__PAGE_OFFSET,%ecx 5.60 + and $0x7f,%cl # CR4.PGE (global enable) 5.61 + mov %ecx,%cr4 5.62 + 5.63 + cmp $(SECONDARY_CPU_FLAG),%ebx 5.64 + je start_paging 5.65 + 5.66 + add $__PAGE_OFFSET,%ebx 5.67 + push %ebx /* Multiboot info struct */ 5.68 + push %eax /* Multiboot magic value */ 5.69 + 5.70 + /* Initialize BSS (no nasty surprises!) */ 5.71 + mov $__bss_start-__PAGE_OFFSET,%edi 5.72 + mov $_end-__PAGE_OFFSET,%ecx 5.73 + sub %edi,%ecx 5.74 + xor %eax,%eax 5.75 + rep stosb 5.76 + 5.77 + /* Initialize low and high mappings of all memory with 4MB pages */ 5.78 + mov $idle_pg_table-__PAGE_OFFSET,%edi 5.79 + mov $0x1e3,%eax /* PRESENT+RW+A+D+4MB+GLOBAL */ 5.80 +1: mov %eax,__PAGE_OFFSET>>20(%edi) /* high mapping */ 5.81 + stosl /* low mapping */ 5.82 + add $(1<<L2_PAGETABLE_SHIFT),%eax 5.83 + cmp $DIRECTMAP_PHYS_END+0x1e3,%eax 5.84 + jne 1b 5.85 + 5.86 + /* Initialise IDT with simple error defaults. */ 5.87 + lea ignore_int,%edx 5.88 + mov $(__HYPERVISOR_CS << 16),%eax 5.89 + mov %dx,%ax /* selector = 0x0010 = cs */ 5.90 + mov $0x8E00,%dx /* interrupt gate - dpl=0, present */ 5.91 + lea SYMBOL_NAME(idt_table)-__PAGE_OFFSET,%edi 5.92 + mov $256,%ecx 5.93 +1: mov %eax,(%edi) 5.94 + mov %edx,4(%edi) 5.95 + add $8,%edi 5.96 + loop 1b 5.97 + 5.98 +start_paging: 5.99 + mov $idle_pg_table-__PAGE_OFFSET,%eax 5.100 + mov %eax,%cr3 5.101 + mov $0x80050033,%eax /* hi-to-lo: PG,AM,WP,NE,ET,MP,PE */ 5.102 + mov %eax,%cr0 5.103 + jmp 1f 5.104 +1: /* Install relocated selectors (FS/GS unused). */ 5.105 + lgdt gdt_descr 5.106 + mov $(__HYPERVISOR_DS),%ecx 5.107 + mov %ecx,%ds 5.108 + mov %ecx,%es 5.109 + mov %ecx,%ss 5.110 + ljmp $(__HYPERVISOR_CS),$1f 5.111 +1: /* Paging enabled, so we can now enable GLOBAL mappings in CR4. */ 5.112 + mov mmu_cr4_features,%ecx 5.113 + mov %ecx,%cr4 5.114 + /* Relocate ESP */ 5.115 + add $__PAGE_OFFSET,%esp 5.116 + 5.117 + lidt idt_descr 5.118 + 5.119 + cmp $(SECONDARY_CPU_FLAG),%ebx 5.120 + je start_secondary 5.121 + 5.122 + /* Call into main C routine. This should never return.*/ 5.123 + call cmain 5.124 + ud2 /* Force a panic (invalid opcode). */ 5.125 + 5.126 +/* This is the default interrupt handler. */ 5.127 +int_msg: 5.128 + .asciz "Unknown interrupt\n" 5.129 + ALIGN 5.130 +ignore_int: 5.131 + cld 5.132 + mov $(__HYPERVISOR_DS),%eax 5.133 + mov %eax,%ds 5.134 + mov %eax,%es 5.135 + pushl $int_msg 5.136 + call SYMBOL_NAME(printf) 5.137 +1: jmp 1b 5.138 + 5.139 +/*** STACK LOCATION ***/ 5.140 + 5.141 +ENTRY(stack_start) 5.142 + .long SYMBOL_NAME(cpu0_stack) + 8100 - __PAGE_OFFSET 5.143 + .long __HYPERVISOR_DS 5.144 + 5.145 +/*** DESCRIPTOR TABLES ***/ 5.146 + 5.147 +.globl SYMBOL_NAME(idt) 5.148 +.globl SYMBOL_NAME(gdt) 5.149 + 5.150 + ALIGN 5.151 + 5.152 + .word 0 5.153 +idt_descr: 5.154 + .word 256*8-1 5.155 +SYMBOL_NAME(idt): 5.156 + .long SYMBOL_NAME(idt_table) 5.157 + 5.158 + .word 0 5.159 +gdt_descr: 5.160 + .word (LAST_RESERVED_GDT_ENTRY*8)+7 5.161 +SYMBOL_NAME(gdt): 5.162 + .long SYMBOL_NAME(gdt_table) /* gdt base */ 5.163 + 5.164 + .word 0 5.165 +nopaging_gdt_descr: 5.166 + .word (LAST_RESERVED_GDT_ENTRY*8)+7 5.167 + .long SYMBOL_NAME(gdt_table)-__PAGE_OFFSET 5.168 + 5.169 + .align 64 5.170 +ENTRY(gdt_table) 5.171 + .fill FIRST_RESERVED_GDT_ENTRY,8,0 5.172 + .quad 0x0000000000000000 /* unused */ 5.173 + .quad 0x00cf9a000000ffff /* 0x0808 ring 0 code, compatability */ 5.174 + .quad 0x00af9a000000ffff /* 0x0810 ring 0 code, 64-bit mode */ 5.175 + .quad 0x00cf92000000ffff /* 0x0818 ring 0 data */ 5.176 + .quad 0x00cffa000000ffff /* 0x0823 ring 3 code, compatibility */ 5.177 + .quad 0x00affa000000ffff /* 0x082b ring 3 code, 64-bit mode */ 5.178 + .quad 0x00cff2000000ffff /* 0x0833 ring 3 data */ 5.179 + .quad 0x0000000000000000 /* unused */ 5.180 + .fill 2*NR_CPUS,8,0 /* space for TSS and LDT per CPU */ 5.181 + 5.182 + .org 0x1000 5.183 +ENTRY(idle_pg_table) # Initial page directory is 4kB 5.184 + .org 0x2000 5.185 +ENTRY(cpu0_stack) # Initial stack is 8kB 5.186 + .org 0x4000 5.187 +ENTRY(stext) 5.188 +ENTRY(_stext)
6.1 --- a/xen/arch/x86/setup.c Thu Jul 01 11:04:02 2004 +0000 6.2 +++ b/xen/arch/x86/setup.c Thu Jul 01 15:20:59 2004 +0000 6.3 @@ -28,7 +28,6 @@ extern int do_timer_lists_from_pit; 6.4 char ignore_irq13; /* set if exception 16 works */ 6.5 struct cpuinfo_x86 boot_cpu_data = { 0, 0, 0, 0, -1 }; 6.6 6.7 -/* Lots of nice things, since we only target PPro+. */ 6.8 unsigned long mmu_cr4_features = X86_CR4_PSE | X86_CR4_PGE; 6.9 EXPORT_SYMBOL(mmu_cr4_features); 6.10
7.1 --- a/xen/common/kernel.c Thu Jul 01 11:04:02 2004 +0000 7.2 +++ b/xen/common/kernel.c Thu Jul 01 15:20:59 2004 +0000 7.3 @@ -202,6 +202,18 @@ void cmain(unsigned long magic, multiboo 7.4 7.5 #if defined(__i386__) 7.6 7.7 + initial_images_start = DIRECTMAP_PHYS_END; 7.8 + initial_images_end = initial_images_start + 7.9 + (mod[mbi->mods_count-1].mod_end - mod[0].mod_start); 7.10 + if ( initial_images_end > (max_page << PAGE_SHIFT) ) 7.11 + { 7.12 + printk("Not enough memory to stash the DOM0 kernel image.\n"); 7.13 + for ( ; ; ) ; 7.14 + } 7.15 + memmove((void *)initial_images_start, /* use low mapping */ 7.16 + (void *)mod[0].mod_start, /* use low mapping */ 7.17 + mod[mbi->mods_count-1].mod_end - mod[0].mod_start); 7.18 + 7.19 if ( opt_xenheap_megabytes > XENHEAP_DEFAULT_MB ) 7.20 { 7.21 printk("Xen heap size is limited to %dMB - you specified %dMB.\n", 7.22 @@ -214,10 +226,6 @@ void cmain(unsigned long magic, multiboo 7.23 7.24 init_frametable((void *)FRAMETABLE_VIRT_START, max_page); 7.25 7.26 - /* Initial images stashed away above DIRECTMAP area in boot.S. */ 7.27 - initial_images_start = DIRECTMAP_PHYS_END; 7.28 - initial_images_end = initial_images_start + 7.29 - (mod[mbi->mods_count-1].mod_end - mod[0].mod_start); 7.30 7.31 #elif defined(__x86_64__) 7.32
8.1 --- a/xen/include/asm-x86/config.h Thu Jul 01 11:04:02 2004 +0000 8.2 +++ b/xen/include/asm-x86/config.h Thu Jul 01 15:20:59 2004 +0000 8.3 @@ -164,7 +164,8 @@ extern void __out_of_line_bug(int line) 8.4 #define DIRECTMAP_PHYS_END (40*1024*1024) 8.5 8.6 /* Hypervisor owns top 64MB of virtual address space. */ 8.7 -#define HYPERVISOR_VIRT_START (0xFC000000UL) 8.8 +#define __HYPERVISOR_VIRT_START 0xFC000000 8.9 +#define HYPERVISOR_VIRT_START (0xFC000000UL) 8.10 8.11 /* 8.12 * First 4MB are mapped read-only for all. It's for the machine->physical