ia64/xen-unstable

changeset 11542:f90ac959db92

[XEN][X86_64] Remove hardcoded addresses in x86/64 boot assembly.
Signed-off-by: Jan Beulich <jbeulich@novell.com>
author kfraser@localhost.localdomain
date Wed Sep 20 09:48:41 2006 +0100 (2006-09-20)
parents f07cf18343f1
children 9deecd4f9cf9
files xen/arch/x86/boot/x86_64.S
line diff
     1.1 --- a/xen/arch/x86/boot/x86_64.S	Tue Sep 19 16:33:01 2006 +0100
     1.2 +++ b/xen/arch/x86/boot/x86_64.S	Wed Sep 20 09:48:41 2006 +0100
     1.3 @@ -10,6 +10,8 @@
     1.4          .text
     1.5          .code32
     1.6  
     1.7 +#define SYM_PHYS(sym) (sym - __PAGE_OFFSET)
     1.8 +
     1.9  ENTRY(start)
    1.10  ENTRY(stext)
    1.11  ENTRY(_stext)
    1.12 @@ -24,15 +26,14 @@ ENTRY(_stext)
    1.13          /* Checksum: must be the negated sum of the first two fields. */
    1.14          .long   -0x1BADB005
    1.15  
    1.16 -        .org    0x010
    1.17 -        .asciz "ERR: Not a 64-bit CPU!"
    1.18 -        .org    0x028
    1.19 -        .asciz "ERR: Not a Multiboot bootloader!"
    1.20 +.Lbad_cpu_msg: .asciz "ERR: Not a 64-bit CPU!"
    1.21 +.Lbad_ldr_msg: .asciz "ERR: Not a Multiboot bootloader!"
    1.22 +
    1.23  bad_cpu:
    1.24 -        mov     $0x100010,%esi # Error message
    1.25 +        mov     $(SYM_PHYS(.Lbad_cpu_msg)),%esi # Error message
    1.26          jmp     print_err
    1.27  not_multiboot:
    1.28 -        mov     $0x100028,%esi # Error message
    1.29 +        mov     $(SYM_PHYS(.Lbad_ldr_msg)),%esi # Error message
    1.30  print_err:
    1.31          mov     $0xB8000,%edi  # VGA framebuffer
    1.32  1:      mov     (%esi),%bl
    1.33 @@ -55,7 +56,7 @@ 3:      in      %dx,%al
    1.34          cli
    1.35  
    1.36          /* Set up a few descriptors: on entry only CS is guaranteed good. */
    1.37 -        lgdt    %cs:0x100306        # nopaging_gdt_descr
    1.38 +        lgdt    %cs:SYM_PHYS(nopaging_gdt_descr)
    1.39          mov     $(__HYPERVISOR_DS32),%ecx
    1.40          mov     %ecx,%ds
    1.41          mov     %ecx,%es
    1.42 @@ -68,7 +69,7 @@ 3:      in      %dx,%al
    1.43          jne     not_multiboot
    1.44  
    1.45          /* Save the Multiboot info structure for later use. */
    1.46 -        mov     %ebx,0x100300       # multiboot_ptr
    1.47 +        mov     %ebx,SYM_PHYS(multiboot_ptr)
    1.48  
    1.49          /* We begin by interrogating the CPU for the presence of long mode. */
    1.50          mov     $0x80000000,%eax
    1.51 @@ -79,7 +80,7 @@ 3:      in      %dx,%al
    1.52          cpuid
    1.53          bt      $29,%edx            # Long mode feature?
    1.54          jnc     bad_cpu
    1.55 -        mov     %edx,0x100310       # cpuid_ext_features
    1.56 +        mov     %edx,SYM_PHYS(cpuid_ext_features)
    1.57  skip_boot_checks:
    1.58  
    1.59          /* Set up FPU. */
    1.60 @@ -90,7 +91,7 @@ skip_boot_checks:
    1.61          mov     %ecx,%cr4
    1.62  
    1.63          /* Load pagetable base register. */
    1.64 -        mov     $0x102000,%eax   /* idle_pg_table */
    1.65 +        mov     $SYM_PHYS(idle_pg_table),%eax
    1.66          mov     %eax,%cr3
    1.67  
    1.68          /* Set up EFER (Extended Feature Enable Register). */
    1.69 @@ -98,7 +99,7 @@ skip_boot_checks:
    1.70          rdmsr
    1.71          btsl    $_EFER_LME,%eax /* Long Mode      */
    1.72          btsl    $_EFER_SCE,%eax /* SYSCALL/SYSRET */
    1.73 -        mov     0x100310,%edi
    1.74 +        mov     SYM_PHYS(cpuid_ext_features),%edi
    1.75          btl     $20,%edi        /* CPUID 0x80000001, EDX[20] */
    1.76          jnc     1f
    1.77          btsl    $_EFER_NX,%eax  /* No-Execute     */
    1.78 @@ -109,11 +110,10 @@ 1:      wrmsr
    1.79          jmp     1f
    1.80  
    1.81  1:      /* Now in compatibility mode. Long-jump into 64-bit mode. */
    1.82 -        ljmp    $(__HYPERVISOR_CS64),$0x100200
    1.83 +        ljmp    $(__HYPERVISOR_CS64),$SYM_PHYS(start64)
    1.84          
    1.85          .code64
    1.86 -        .org    0x0200
    1.87 -
    1.88 +start64:
    1.89          /* Install relocated selectors (FS/GS unused). */
    1.90          lgdt    gdt_descr(%rip)
    1.91  
    1.92 @@ -195,18 +195,16 @@ 1:      jmp     1b
    1.93  .globl idt
    1.94  .globl gdt        
    1.95  
    1.96 -        .org    0x300
    1.97 -        .code32
    1.98 -
    1.99 -multiboot_ptr:        /* 0x300 */
   1.100 +        .align 8, 0xCC
   1.101 +multiboot_ptr:
   1.102          .long   0
   1.103  
   1.104          .word   0
   1.105 -nopaging_gdt_descr:   /* 0x306 */
   1.106 +nopaging_gdt_descr:
   1.107          .word   LAST_RESERVED_GDT_BYTE
   1.108          .quad   gdt_table - FIRST_RESERVED_GDT_BYTE - __PAGE_OFFSET
   1.109  
   1.110 -cpuid_ext_features:   /* 0x310 */
   1.111 +cpuid_ext_features:
   1.112          .long   0
   1.113          
   1.114          .word   0
   1.115 @@ -227,7 +225,7 @@ ENTRY(stack_start)
   1.116  high_start:
   1.117          .quad   __high_start
   1.118  
   1.119 -        .org    0x1000
   1.120 +        .align PAGE_SIZE, 0
   1.121  ENTRY(gdt_table)
   1.122          .quad 0x0000000000000000     /* unused */
   1.123          .quad 0x00cf9a000000ffff     /* 0xe008 ring 0 code, compatibility */
   1.124 @@ -240,7 +238,7 @@ ENTRY(gdt_table)
   1.125          .fill 4*NR_CPUS,8,0          /* space for TSS and LDT per CPU     */
   1.126  
   1.127  /* Initial PML4 -- level-4 page table. */
   1.128 -        .org 0x2000
   1.129 +        .align PAGE_SIZE, 0
   1.130  ENTRY(idle_pg_table)
   1.131  ENTRY(idle_pg_table_4)
   1.132          .quad idle_pg_table_l3 - __PAGE_OFFSET + 7 # PML4[0]
   1.133 @@ -248,12 +246,12 @@ ENTRY(idle_pg_table_4)
   1.134          .quad idle_pg_table_l3 - __PAGE_OFFSET + 7 # PML4[262]
   1.135  
   1.136  /* Initial PDP -- level-3 page table. */
   1.137 -        .org 0x3000
   1.138 +        .align PAGE_SIZE, 0
   1.139  ENTRY(idle_pg_table_l3)
   1.140          .quad idle_pg_table_l2 - __PAGE_OFFSET + 7
   1.141  
   1.142  /* Initial PDE -- level-2 page table. Maps first 1GB physical memory. */
   1.143 -        .org 0x4000
   1.144 +        .align PAGE_SIZE, 0
   1.145  ENTRY(idle_pg_table_l2)
   1.146          .macro identmap from=0, count=512
   1.147          .if \count-1
   1.148 @@ -265,8 +263,7 @@ ENTRY(idle_pg_table_l2)
   1.149          .endm
   1.150          identmap
   1.151  
   1.152 -        .org 0x4000 + PAGE_SIZE
   1.153 -        .code64
   1.154 +        .align PAGE_SIZE, 0
   1.155  
   1.156  .section ".bss.stack_aligned","w"
   1.157  ENTRY(cpu0_stack)