KVM: x86: Kill off __ex() and __kvm_handle_fault_on_reboot()
authorSean Christopherson <seanjc@google.com>
Mon, 9 Aug 2021 17:39:54 +0000 (10:39 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 13 Aug 2021 07:35:16 +0000 (03:35 -0400)
Remove the __kvm_handle_fault_on_reboot() and __ex() macros now that all
VMX and SVM instructions use asm goto to handle the fault (or in the
case of VMREAD, completely custom logic).  Drop kvm_spurious_fault()'s
asmlinkage annotation as __kvm_handle_fault_on_reboot() was the only
flow that invoked it from assembly code.

Cc: Uros Bizjak <ubizjak@gmail.com>
Cc: Like Xu <like.xu.linux@gmail.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210809173955.1710866-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/vmx/vmx_ops.h
arch/x86/kvm/x86.c

index 5e35334980a6e7828aaf88025e8bbdf84f4b41cc..8c8aa8ab5f0bf155a771ceac8dd12eecbd7ded4c 100644 (file)
@@ -1811,30 +1811,7 @@ enum {
 #define kvm_arch_vcpu_memslots_id(vcpu) ((vcpu)->arch.hflags & HF_SMM_MASK ? 1 : 0)
 #define kvm_memslots_for_spte_role(kvm, role) __kvm_memslots(kvm, (role).smm)
 
-asmlinkage void kvm_spurious_fault(void);
-
-/*
- * Hardware virtualization extension instructions may fault if a
- * reboot turns off virtualization while processes are running.
- * Usually after catching the fault we just panic; during reboot
- * instead the instruction is ignored.
- */
-#define __kvm_handle_fault_on_reboot(insn)                             \
-       "666: \n\t"                                                     \
-       insn "\n\t"                                                     \
-       "jmp    668f \n\t"                                              \
-       "667: \n\t"                                                     \
-       "1: \n\t"                                                       \
-       ".pushsection .discard.instr_begin \n\t"                        \
-       ".long 1b - . \n\t"                                             \
-       ".popsection \n\t"                                              \
-       "call   kvm_spurious_fault \n\t"                                \
-       "1: \n\t"                                                       \
-       ".pushsection .discard.instr_end \n\t"                          \
-       ".long 1b - . \n\t"                                             \
-       ".popsection \n\t"                                              \
-       "668: \n\t"                                                     \
-       _ASM_EXTABLE(666b, 667b)
+void kvm_spurious_fault(void);
 
 #define KVM_ARCH_WANT_MMU_NOTIFIER
 
index 81601c31f549caf941fb605fe37888e4ed0c6bde..75e0b21ad07c9e89a54131be45bdcca3fa88af4e 100644 (file)
@@ -28,8 +28,6 @@
 #include "cpuid.h"
 #include "trace.h"
 
-#define __ex(x) __kvm_handle_fault_on_reboot(x)
-
 #ifndef CONFIG_KVM_AMD_SEV
 /*
  * When this config is not defined, SEV feature is not supported and APIs in
index 9d72b1df426e64c7cd1b67dd693c0b69c722285f..2b6632d4c76f732b9d066cb179805597db33326c 100644 (file)
@@ -46,8 +46,6 @@
 #include "kvm_onhyperv.h"
 #include "svm_onhyperv.h"
 
-#define __ex(x) __kvm_handle_fault_on_reboot(x)
-
 MODULE_AUTHOR("Qumranet");
 MODULE_LICENSE("GPL");
 
index 164b64f65a8f3466cdcedf654145ca45cfe4cdea..c0d74b994b56e7c031474bab051f57890900d7c7 100644 (file)
@@ -10,8 +10,6 @@
 #include "evmcs.h"
 #include "vmcs.h"
 
-#define __ex(x) __kvm_handle_fault_on_reboot(x)
-
 asmlinkage void vmread_error(unsigned long field, bool fault);
 __attribute__((regparm(0))) void vmread_error_trampoline(unsigned long field,
                                                         bool fault);
index 70d42b50199afbefaef6cf24bd21472035d8e688..58a72c7d3330328fb0d4ffddc44568ea59f09152 100644 (file)
@@ -486,7 +486,14 @@ int kvm_set_apic_base(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
 }
 EXPORT_SYMBOL_GPL(kvm_set_apic_base);
 
-asmlinkage __visible noinstr void kvm_spurious_fault(void)
+/*
+ * Handle a fault on a hardware virtualization (VMX or SVM) instruction.
+ *
+ * Hardware virtualization extension instructions may fault if a reboot turns
+ * off virtualization while processes are running.  Usually after catching the
+ * fault we just panic; during reboot instead the instruction is ignored.
+ */
+noinstr void kvm_spurious_fault(void)
 {
        /* Fault while not rebooting.  We want the trace. */
        BUG_ON(!kvm_rebooting);