KVM: VMX: Move VMREAD cleanup to exception handler
authorAvi Kivity <avi@redhat.com>
Sun, 15 May 2011 14:13:12 +0000 (10:13 -0400)
committerAvi Kivity <avi@redhat.com>
Tue, 12 Jul 2011 08:45:00 +0000 (11:45 +0300)
We clean up a failed VMREAD by clearing the output register.  Do
it in the exception handler instead of unconditionally.  This is
worthwhile since there are more than a hundred call sites.

Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/vmx.c

index d2ac8e2..db4b654 100644 (file)
@@ -830,11 +830,12 @@ enum {
 asmlinkage void kvm_spurious_fault(void);
 extern bool kvm_rebooting;
 
-#define __kvm_handle_fault_on_reboot(insn) \
+#define ____kvm_handle_fault_on_reboot(insn, cleanup_insn)     \
        "666: " insn "\n\t" \
        "668: \n\t"                           \
        ".pushsection .fixup, \"ax\" \n" \
        "667: \n\t" \
+       cleanup_insn "\n\t"                   \
        "cmpb $0, kvm_rebooting \n\t"         \
        "jne 668b \n\t"                       \
        __ASM_SIZE(push) " $666b \n\t"        \
@@ -844,6 +845,9 @@ extern bool kvm_rebooting;
        _ASM_PTR " 666b, 667b \n\t" \
        ".popsection"
 
+#define __kvm_handle_fault_on_reboot(insn)             \
+       ____kvm_handle_fault_on_reboot(insn, "")
+
 #define KVM_ARCH_WANT_MMU_NOTIFIER
 int kvm_unmap_hva(struct kvm *kvm, unsigned long hva);
 int kvm_age_hva(struct kvm *kvm, unsigned long hva);
index d48ec60..7d22d6c 100644 (file)
@@ -43,6 +43,8 @@
 #include "trace.h"
 
 #define __ex(x) __kvm_handle_fault_on_reboot(x)
+#define __ex_clear(x, reg) \
+       ____kvm_handle_fault_on_reboot(x, "xor " reg " , " reg)
 
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
@@ -587,10 +589,10 @@ static inline void ept_sync_individual_addr(u64 eptp, gpa_t gpa)
 
 static unsigned long vmcs_readl(unsigned long field)
 {
-       unsigned long value = 0;
+       unsigned long value;
 
-       asm volatile (__ex(ASM_VMX_VMREAD_RDX_RAX)
-                     : "+a"(value) : "d"(field) : "cc");
+       asm volatile (__ex_clear(ASM_VMX_VMREAD_RDX_RAX, "%0")
+                     : "=a"(value) : "d"(field) : "cc");
        return value;
 }