ia64/xen-unstable

changeset 18932:c3df4b8ea2fc

vmx: Do not disable real EFER.NXE even when disabled by guest.

We must not disable EFER.NXE in host mode since shadow code relies on
accessing shadow mappings with NX set.

We do not want to write EFER on every vmentry/vmexit if we can avoid
it, since it will be somewhat slow.

Finally, we don't believe that any guest relies on NX really being
disabled when EFER.NXE is cleared.

This given, it makes sense to ignore the guest's setting of EFER.NXE.

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Dec 16 11:54:11 2008 +0000 (2008-12-16)
parents 5b73fa1b9562
children ea0ad7b3ae41
files xen/arch/x86/hvm/vmx/vmx.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Tue Dec 16 11:49:20 2008 +0000
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Tue Dec 16 11:54:11 2008 +0000
     1.3 @@ -306,9 +306,6 @@ static void vmx_restore_host_msrs(void)
     1.4          wrmsrl(msr_index[i], host_msr_state->msrs[i]);
     1.5          clear_bit(i, &host_msr_state->flags);
     1.6      }
     1.7 -
     1.8 -    if ( cpu_has_nx && !(read_efer() & EFER_NX) )
     1.9 -        write_efer(read_efer() | EFER_NX);
    1.10  }
    1.11  
    1.12  static void vmx_save_guest_msrs(struct vcpu *v)
    1.13 @@ -342,39 +339,23 @@ static void vmx_restore_guest_msrs(struc
    1.14          clear_bit(i, &guest_flags);
    1.15      }
    1.16  
    1.17 -    if ( (v->arch.hvm_vcpu.guest_efer ^ read_efer()) & (EFER_NX | EFER_SCE) )
    1.18 +    if ( (v->arch.hvm_vcpu.guest_efer ^ read_efer()) & EFER_SCE )
    1.19      {
    1.20          HVM_DBG_LOG(DBG_LEVEL_2,
    1.21                      "restore guest's EFER with value %lx",
    1.22                      v->arch.hvm_vcpu.guest_efer);
    1.23 -        write_efer((read_efer() & ~(EFER_NX | EFER_SCE)) |
    1.24 -                   (v->arch.hvm_vcpu.guest_efer & (EFER_NX | EFER_SCE)));
    1.25 +        write_efer((read_efer() & ~EFER_SCE) |
    1.26 +                   (v->arch.hvm_vcpu.guest_efer & EFER_SCE));
    1.27      }
    1.28  }
    1.29  
    1.30  #else  /* __i386__ */
    1.31  
    1.32  #define vmx_save_host_msrs()        ((void)0)
    1.33 -
    1.34 -static void vmx_restore_host_msrs(void)
    1.35 -{
    1.36 -    if ( cpu_has_nx && !(read_efer() & EFER_NX) )
    1.37 -        write_efer(read_efer() | EFER_NX);
    1.38 -}
    1.39 +#define vmx_restore_host_msrs()     ((void)0)
    1.40  
    1.41  #define vmx_save_guest_msrs(v)      ((void)0)
    1.42 -
    1.43 -static void vmx_restore_guest_msrs(struct vcpu *v)
    1.44 -{
    1.45 -    if ( (v->arch.hvm_vcpu.guest_efer ^ read_efer()) & EFER_NX )
    1.46 -    {
    1.47 -        HVM_DBG_LOG(DBG_LEVEL_2,
    1.48 -                    "restore guest's EFER with value %lx",
    1.49 -                    v->arch.hvm_vcpu.guest_efer);
    1.50 -        write_efer((read_efer() & ~EFER_NX) |
    1.51 -                   (v->arch.hvm_vcpu.guest_efer & EFER_NX));
    1.52 -    }
    1.53 -}
    1.54 +#define vmx_restore_guest_msrs(v)   ((void)0)
    1.55  
    1.56  static enum handler_return long_mode_do_msr_read(struct cpu_user_regs *regs)
    1.57  {
    1.58 @@ -1190,8 +1171,8 @@ static void vmx_update_guest_efer(struct
    1.59  #endif
    1.60  
    1.61      if ( v == current )
    1.62 -        write_efer((read_efer() & ~(EFER_NX|EFER_SCE)) |
    1.63 -                   (v->arch.hvm_vcpu.guest_efer & (EFER_NX|EFER_SCE)));
    1.64 +        write_efer((read_efer() & ~EFER_SCE) |
    1.65 +                   (v->arch.hvm_vcpu.guest_efer & EFER_SCE));
    1.66  }
    1.67  
    1.68  static void vmx_flush_guest_tlbs(void)