]> git.hungrycats.org Git - linux/commitdiff
KVM: VMX: Make handle_bus_lock_vmexit() a shared helper
authorXiaoyao Li <xiaoyao.li@intel.com>
Wed, 19 Aug 2026 09:49:01 +0000 (17:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Nov 2026 17:10:48 +0000 (12:10 -0500)
commit 326fa2c9b4d3e6cab58c139eb55aaabd7179192e upstream.

Move handle_bus_lock_vmexit() from vmx.c to main.c to make it a shared
helper so that TDX can use it for Bus Lock VM exit handling as well.
Rename it to add vt_ prefix to reflect that it is a helper for both VMX
and TDX.

Cc: stable@vger.kernel.org
Signed-off-by: Xiaoyao Li <xiaoyao.li@intel.com>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Link: https://patch.msgid.link/20260819094903.3060020-8-xiaoyao.li@intel.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/vmx/common.h
arch/x86/kvm/vmx/main.c
arch/x86/kvm/vmx/vmx.c

index 08005676702c2b5c248ed168f550685249704a29..e97773c0b0ad56f0e88cdc481e5f7772e9545a52 100644 (file)
@@ -184,5 +184,6 @@ static inline void __vmx_deliver_posted_interrupt(struct kvm_vcpu *vcpu,
 }
 
 noinstr void vmx_handle_nmi(struct kvm_vcpu *vcpu);
+int vt_handle_bus_lock_vmexit(struct kvm_vcpu *vcpu);
 
 #endif /* __KVM_X86_VMX_COMMON_H */
index ea0d825e556d298ebad776c30edb36734ecbed5a..835de375e8c8c761a5ff13947aabfbb877ca6166 100644 (file)
@@ -878,6 +878,17 @@ static int vt_gmem_max_mapping_level(struct kvm *kvm, kvm_pfn_t pfn,
 #define vt_op_tdx_only(name) NULL
 #endif /* CONFIG_KVM_INTEL_TDX */
 
+int vt_handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)
+{
+       /*
+        * Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK
+        * VM-Exits. Unconditionally set the flag here and leave the handling
+        * to .handle_exit() callback.
+        */
+       to_vt(vcpu)->exit_reason.bus_lock_detected = true;
+       return 1;
+}
+
 #define VMX_REQUIRED_APICV_INHIBITS                            \
        (BIT(APICV_INHIBIT_REASON_DISABLED) |                   \
         BIT(APICV_INHIBIT_REASON_ABSENT) |                     \
index c897dbf0e954016eddcfa8c5e3b1daba900b7642..b48ae57e262a54c3c1b07d925fc25fbf04396e38 100644 (file)
@@ -6267,17 +6267,6 @@ static int handle_encls(struct kvm_vcpu *vcpu)
 }
 #endif /* CONFIG_X86_SGX_KVM */
 
-static int handle_bus_lock_vmexit(struct kvm_vcpu *vcpu)
-{
-       /*
-        * Hardware may or may not set the BUS_LOCK_DETECTED flag on BUS_LOCK
-        * VM-Exits. Unconditionally set the flag here and leave the handling to
-        * vmx_handle_exit().
-        */
-       to_vt(vcpu)->exit_reason.bus_lock_detected = true;
-       return 1;
-}
-
 static int handle_notify(struct kvm_vcpu *vcpu)
 {
        unsigned long exit_qual = vmx_get_exit_qual(vcpu);
@@ -6377,7 +6366,7 @@ static int (*kvm_vmx_exit_handlers[])(struct kvm_vcpu *vcpu) = {
        [EXIT_REASON_VMFUNC]                  = handle_vmx_instruction,
        [EXIT_REASON_PREEMPTION_TIMER]        = handle_preemption_timer,
        [EXIT_REASON_ENCLS]                   = handle_encls,
-       [EXIT_REASON_BUS_LOCK]                = handle_bus_lock_vmexit,
+       [EXIT_REASON_BUS_LOCK]                = vt_handle_bus_lock_vmexit,
        [EXIT_REASON_NOTIFY]                  = handle_notify,
        [EXIT_REASON_SEAMCALL]                = handle_tdx_instruction,
        [EXIT_REASON_TDCALL]                  = handle_tdx_instruction,