]> 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:06:09 +0000 (12:06 -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 412d0829d7a21777c5969ba27293721e9aa3d1c5..a02d7c003475a2cf8152550bc476157d81f1dabc 100644 (file)
@@ -176,5 +176,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 5fd9ff0bfab6baafc10a00c106e0136636bb6651..30c4c833b46132bdacc5487cb27cabb77175d75d 100644 (file)
@@ -849,6 +849,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 5bae3d5ce6eec267e9a5f342714e08723db32513..11662ebdb7f6aa518dccfadbe928ad42482946db 100644 (file)
@@ -6052,17 +6052,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);
@@ -6162,7 +6151,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,