ia64/xen-unstable

changeset 11684:bcd0e18f7881

[HVM][VMX] Clear vmxe when VMX is not enabled.

The current Xen code keeps X86_CR4_VMXE set even if VMXON has not been
executed. The stop_vmx() code assumes that it is possible to call
VMXOFF if X86_CR4_VMXE is set which is not always true. Calling VMXOFF
without VMXON results in an illegal opcode trap, and to avoid this condition
this patch makes sure that X86_CR4_VMXE is only set when VMXON has
been called.

Tested using x86_32 on a Pentium D 930.

Signed-Off-By: Magnus Damm <magnus@valinux.co.jp>
author kfraser@localhost.localdomain
date Fri Sep 29 11:26:33 2006 +0100 (2006-09-29)
parents be78be7009c5
children 9eb80d41c724
files xen/arch/x86/hvm/vmx/vmx.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Fri Sep 29 11:22:24 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Fri Sep 29 11:26:33 2006 +0100
     1.3 @@ -485,8 +485,10 @@ static void vmx_ctxt_switch_to(struct vc
     1.4  
     1.5  static void stop_vmx(void)
     1.6  {
     1.7 -    if (read_cr4() & X86_CR4_VMXE)
     1.8 -        __vmxoff();
     1.9 +    if ( !(read_cr4() & X86_CR4_VMXE) )
    1.10 +        return;
    1.11 +    __vmxoff();
    1.12 +    clear_in_cr4(X86_CR4_VMXE);
    1.13  }
    1.14  
    1.15  void vmx_migrate_timers(struct vcpu *v)
    1.16 @@ -806,12 +808,14 @@ int start_vmx(void)
    1.17  
    1.18      if ( (vmcs = vmx_alloc_host_vmcs()) == NULL )
    1.19      {
    1.20 +        clear_in_cr4(X86_CR4_VMXE);
    1.21          printk("Failed to allocate host VMCS\n");
    1.22          return 0;
    1.23      }
    1.24  
    1.25      if ( __vmxon(virt_to_maddr(vmcs)) )
    1.26      {
    1.27 +        clear_in_cr4(X86_CR4_VMXE);
    1.28          printk("VMXON failed\n");
    1.29          vmx_free_host_vmcs(vmcs);
    1.30          return 0;