ia64/xen-unstable

changeset 5774:71d000e59b13

Cleanup mov to CR4 handling.

Signed-off-by: Arun Sharma <arun.sharma@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Jul 14 08:00:35 2005 +0000 (2005-07-14)
parents 637127cded4e
children 9b77ba29108d
files xen/arch/x86/vmx.c xen/include/asm-x86/vmx.h
line diff
     1.1 --- a/xen/arch/x86/vmx.c	Thu Jul 14 08:00:23 2005 +0000
     1.2 +++ b/xen/arch/x86/vmx.c	Thu Jul 14 08:00:35 2005 +0000
     1.3 @@ -801,11 +801,7 @@ vmx_world_restore(struct vcpu *d, struct
     1.4  skip_cr3:
     1.5  
     1.6      error |= __vmread(CR4_READ_SHADOW, &old_cr4);
     1.7 -#if defined (__i386__)
     1.8 -    error |= __vmwrite(GUEST_CR4, (c->cr4 | X86_CR4_VMXE));
     1.9 -#else
    1.10 -    error |= __vmwrite(GUEST_CR4, (c->cr4 | X86_CR4_VMXE | X86_CR4_PAE));
    1.11 -#endif
    1.12 +    error |= __vmwrite(GUEST_CR4, (c->cr4 | VMX_CR4_HOST_MASK));
    1.13      error |= __vmwrite(CR4_READ_SHADOW, c->cr4);
    1.14  
    1.15      error |= __vmwrite(GUEST_IDTR_LIMIT, c->idtr_limit);
    1.16 @@ -1178,13 +1174,10 @@ static int mov_to_cr(int gp, int cr, str
    1.17      {
    1.18          /* CR4 */
    1.19          unsigned long old_guest_cr;
    1.20 -        unsigned long pae_disabled = 0;
    1.21  
    1.22          __vmread(GUEST_CR4, &old_guest_cr);
    1.23          if (value & X86_CR4_PAE){
    1.24              set_bit(VMX_CPU_STATE_PAE_ENABLED, &d->arch.arch_vmx.cpu_state);
    1.25 -            if(!vmx_paging_enabled(d))
    1.26 -                pae_disabled = 1;
    1.27          } else {
    1.28              if (test_bit(VMX_CPU_STATE_LMA_ENABLED,
    1.29                           &d->arch.arch_vmx.cpu_state)){
    1.30 @@ -1194,11 +1187,8 @@ static int mov_to_cr(int gp, int cr, str
    1.31          }
    1.32  
    1.33          __vmread(CR4_READ_SHADOW, &old_cr);
    1.34 -        if (pae_disabled)
    1.35 -            __vmwrite(GUEST_CR4, value| X86_CR4_VMXE);
    1.36 -        else
    1.37 -            __vmwrite(GUEST_CR4, value| X86_CR4_VMXE);
    1.38  
    1.39 +        __vmwrite(GUEST_CR4, value| VMX_CR4_HOST_MASK);
    1.40          __vmwrite(CR4_READ_SHADOW, value);
    1.41  
    1.42          /*
     2.1 --- a/xen/include/asm-x86/vmx.h	Thu Jul 14 08:00:23 2005 +0000
     2.2 +++ b/xen/include/asm-x86/vmx.h	Thu Jul 14 08:00:35 2005 +0000
     2.3 @@ -183,6 +183,13 @@ extern unsigned int cpu_rev;
     2.4        EXCEPTION_BITMAP_GP )
     2.5  #endif
     2.6  
     2.7 +/* These bits in the CR4 are owned by the host */
     2.8 +#ifdef __i386__
     2.9 +#define VMX_CR4_HOST_MASK (X86_CR4_VMXE)
    2.10 +#else
    2.11 +#define VMX_CR4_HOST_MASK (X86_CR4_VMXE | X86_CR4_PAE)
    2.12 +#endif
    2.13 +
    2.14  #define VMCALL_OPCODE   ".byte 0x0f,0x01,0xc1\n"
    2.15  #define VMCLEAR_OPCODE  ".byte 0x66,0x0f,0xc7\n"        /* reg/opcode: /6 */
    2.16  #define VMLAUNCH_OPCODE ".byte 0x0f,0x01,0xc2\n"