diff options
author | Avi Kivity <avi@redhat.com> | 2011-05-15 10:13:12 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2011-07-12 04:45:00 -0400 |
commit | 5e520e62787afd8fc28626fd8d4f77491135119d (patch) | |
tree | 44641116820afb0b14f05ce643889c60ed024dab | |
parent | 7b105ca2903b84f023c49965d9a511c5e55256dc (diff) |
KVM: VMX: Move VMREAD cleanup to exception handler
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>
-rw-r--r-- | arch/x86/include/asm/kvm_host.h | 6 | ||||
-rw-r--r-- | arch/x86/kvm/vmx.c | 8 |
2 files changed, 10 insertions, 4 deletions
diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index d2ac8e2ee897..db4b6543b830 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h | |||
@@ -830,11 +830,12 @@ enum { | |||
830 | asmlinkage void kvm_spurious_fault(void); | 830 | asmlinkage void kvm_spurious_fault(void); |
831 | extern bool kvm_rebooting; | 831 | extern bool kvm_rebooting; |
832 | 832 | ||
833 | #define __kvm_handle_fault_on_reboot(insn) \ | 833 | #define ____kvm_handle_fault_on_reboot(insn, cleanup_insn) \ |
834 | "666: " insn "\n\t" \ | 834 | "666: " insn "\n\t" \ |
835 | "668: \n\t" \ | 835 | "668: \n\t" \ |
836 | ".pushsection .fixup, \"ax\" \n" \ | 836 | ".pushsection .fixup, \"ax\" \n" \ |
837 | "667: \n\t" \ | 837 | "667: \n\t" \ |
838 | cleanup_insn "\n\t" \ | ||
838 | "cmpb $0, kvm_rebooting \n\t" \ | 839 | "cmpb $0, kvm_rebooting \n\t" \ |
839 | "jne 668b \n\t" \ | 840 | "jne 668b \n\t" \ |
840 | __ASM_SIZE(push) " $666b \n\t" \ | 841 | __ASM_SIZE(push) " $666b \n\t" \ |
@@ -844,6 +845,9 @@ extern bool kvm_rebooting; | |||
844 | _ASM_PTR " 666b, 667b \n\t" \ | 845 | _ASM_PTR " 666b, 667b \n\t" \ |
845 | ".popsection" | 846 | ".popsection" |
846 | 847 | ||
848 | #define __kvm_handle_fault_on_reboot(insn) \ | ||
849 | ____kvm_handle_fault_on_reboot(insn, "") | ||
850 | |||
847 | #define KVM_ARCH_WANT_MMU_NOTIFIER | 851 | #define KVM_ARCH_WANT_MMU_NOTIFIER |
848 | int kvm_unmap_hva(struct kvm *kvm, unsigned long hva); | 852 | int kvm_unmap_hva(struct kvm *kvm, unsigned long hva); |
849 | int kvm_age_hva(struct kvm *kvm, unsigned long hva); | 853 | int kvm_age_hva(struct kvm *kvm, unsigned long hva); |
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index d48ec60ea421..7d22d6c6734d 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -43,6 +43,8 @@ | |||
43 | #include "trace.h" | 43 | #include "trace.h" |
44 | 44 | ||
45 | #define __ex(x) __kvm_handle_fault_on_reboot(x) | 45 | #define __ex(x) __kvm_handle_fault_on_reboot(x) |
46 | #define __ex_clear(x, reg) \ | ||
47 | ____kvm_handle_fault_on_reboot(x, "xor " reg " , " reg) | ||
46 | 48 | ||
47 | MODULE_AUTHOR("Qumranet"); | 49 | MODULE_AUTHOR("Qumranet"); |
48 | MODULE_LICENSE("GPL"); | 50 | MODULE_LICENSE("GPL"); |
@@ -587,10 +589,10 @@ static inline void ept_sync_individual_addr(u64 eptp, gpa_t gpa) | |||
587 | 589 | ||
588 | static unsigned long vmcs_readl(unsigned long field) | 590 | static unsigned long vmcs_readl(unsigned long field) |
589 | { | 591 | { |
590 | unsigned long value = 0; | 592 | unsigned long value; |
591 | 593 | ||
592 | asm volatile (__ex(ASM_VMX_VMREAD_RDX_RAX) | 594 | asm volatile (__ex_clear(ASM_VMX_VMREAD_RDX_RAX, "%0") |
593 | : "+a"(value) : "d"(field) : "cc"); | 595 | : "=a"(value) : "d"(field) : "cc"); |
594 | return value; | 596 | return value; |
595 | } | 597 | } |
596 | 598 | ||