All of lore.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus@valinux.co.jp>
To: xen-devel@lists.xensource.com
Cc: Magnus Damm <magnus@valinux.co.jp>, magnus.damm@gmail.com
Subject: [PATCH] hvm: clear vmxe if vmxoff
Date: Fri, 29 Sep 2006 15:44:25 +0900	[thread overview]
Message-ID: <20060929064425.24864.5149.sendpatchset@localhost> (raw)

hvm: clear vmxe if vmxoff

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>

--- 0001/xen/arch/x86/hvm/vmx/vmx.c
+++ work/xen/arch/x86/hvm/vmx/vmx.c	2006-09-29 14:49:55.000000000 +0900
@@ -485,8 +485,10 @@ static void vmx_ctxt_switch_to(struct vc
 
 static void stop_vmx(void)
 {
-    if (read_cr4() & X86_CR4_VMXE)
+    if (read_cr4() & X86_CR4_VMXE) {
         __vmxoff();
+        clear_in_cr4(X86_CR4_VMXE);
+    }
 }
 
 void vmx_migrate_timers(struct vcpu *v)
@@ -806,12 +808,14 @@ int start_vmx(void)
 
     if ( (vmcs = vmx_alloc_host_vmcs()) == NULL )
     {
+        clear_in_cr4(X86_CR4_VMXE);
         printk("Failed to allocate host VMCS\n");
         return 0;
     }
 
     if ( __vmxon(virt_to_maddr(vmcs)) )
     {
+        clear_in_cr4(X86_CR4_VMXE);
         printk("VMXON failed\n");
         vmx_free_host_vmcs(vmcs);
         return 0;

             reply	other threads:[~2006-09-29  6:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-29  6:44 Magnus Damm [this message]
2006-09-29  6:44 ` [PATCH] hvm: disable on smp Magnus Damm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060929064425.24864.5149.sendpatchset@localhost \
    --to=magnus@valinux.co.jp \
    --cc=magnus.damm@gmail.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.