ia64/xen-unstable

changeset 18717:164985e3a46e

x86: Dom0 builder must run on a valid GDT at all times.
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Oct 23 15:34:27 2008 +0100 (2008-10-23)
parents 6d45bf101d57
children d1ecee02cced
files xen/arch/x86/domain_build.c
line diff
     1.1 --- a/xen/arch/x86/domain_build.c	Thu Oct 23 15:23:15 2008 +0100
     1.2 +++ b/xen/arch/x86/domain_build.c	Thu Oct 23 15:34:27 2008 +0100
     1.3 @@ -194,6 +194,32 @@ static void __init process_dom0_ioports_
     1.4      }
     1.5  }
     1.6  
     1.7 +/* We run on dom0's page tables for the final part of the build process. */
     1.8 +static void dom0_pt_enter(struct vcpu *v)
     1.9 +{
    1.10 +    struct desc_ptr gdt_desc = {
    1.11 +        .limit = LAST_RESERVED_GDT_BYTE,
    1.12 +        .base = (unsigned long)(this_cpu(gdt_table) - FIRST_RESERVED_GDT_ENTRY)
    1.13 +    };
    1.14 +
    1.15 +    asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
    1.16 +    local_irq_disable();
    1.17 +    write_ptbase(v);
    1.18 +}
    1.19 +
    1.20 +/* Return to idle domain's page tables. */
    1.21 +static void dom0_pt_exit(void)
    1.22 +{
    1.23 +    struct desc_ptr gdt_desc = {
    1.24 +        .limit = LAST_RESERVED_GDT_BYTE,
    1.25 +        .base = GDT_VIRT_START(current)
    1.26 +    };
    1.27 +
    1.28 +    write_ptbase(current);
    1.29 +    local_irq_enable();
    1.30 +    asm volatile ( "lgdt %0" : : "m" (gdt_desc) );
    1.31 +}
    1.32 +
    1.33  int __init construct_dom0(
    1.34      struct domain *d,
    1.35      unsigned long _image_start, unsigned long image_len, 
    1.36 @@ -700,14 +726,12 @@ int __init construct_dom0(
    1.37          (void)alloc_vcpu(d, i, i % num_online_cpus());
    1.38  
    1.39      /* Set up CR3 value for write_ptbase */
    1.40 -    if ( paging_mode_enabled(v->domain) )
    1.41 +    if ( paging_mode_enabled(d) )
    1.42          paging_update_paging_modes(v);
    1.43      else
    1.44          update_cr3(v);
    1.45  
    1.46 -    /* Install the new page tables. */
    1.47 -    local_irq_disable();
    1.48 -    write_ptbase(v);
    1.49 +    dom0_pt_enter(v);
    1.50  
    1.51      /* Copy the OS image and free temporary buffer. */
    1.52      elf.dest = (void*)vkern_start;
    1.53 @@ -804,9 +828,7 @@ int __init construct_dom0(
    1.54          xlat_start_info(si, XLAT_start_info_console_dom0);
    1.55  #endif
    1.56  
    1.57 -    /* Reinstate the caller's page tables. */
    1.58 -    write_ptbase(current);
    1.59 -    local_irq_enable();
    1.60 +    dom0_pt_exit();
    1.61  
    1.62  #if defined(__i386__)
    1.63      /* Destroy low mappings - they were only for our convenience. */