]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: nSVM: Move vmcb_ctrl_area_cached.bus_lock_rip to svm_nested_state
authorSean Christopherson <seanjc@google.com>
Wed, 18 Feb 2026 23:09:57 +0000 (15:09 -0800)
committerSean Christopherson <seanjc@google.com>
Thu, 5 Mar 2026 00:09:01 +0000 (16:09 -0800)
Move "bus_lock_rip" from "vmcb_ctrl_area_cached" to "svm_nested_state" as
"last_bus_lock_rip" to more accurately reflect what it tracks, and because
it is NOT a cached vmcb12 control field.  The misplaced field isn't all
that apparent in the current code base, as KVM uses "svm->nested.ctl"
broadly, but the bad placement becomes glaringly obvious if
"svm->nested.ctl" is captured as a local "vmcb12_ctrl" variable.

No functional change intended.

Reviewed-by: Yosry Ahmed <yosry.ahmed@linux.dev>
Link: https://patch.msgid.link/20260218230958.2877682-8-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/nested.c
arch/x86/kvm/svm/svm.c
arch/x86/kvm/svm/svm.h

index c965d10f31875d7842890441d77b428232f442e2..dc4cca7df47ecf89d2f0c21732378fe9e43afc72 100644 (file)
@@ -850,7 +850,7 @@ static void nested_vmcb02_prepare_control(struct vcpu_svm *svm)
         * L1 re-enters L2, the same instruction will trigger a VM-Exit and the
         * entire cycle start over.
         */
-       if (vmcb02->save.rip && (svm->nested.ctl.bus_lock_rip == vmcb02->save.rip))
+       if (vmcb02->save.rip && (svm->nested.last_bus_lock_rip == vmcb02->save.rip))
                vmcb02->control.bus_lock_counter = 1;
        else
                vmcb02->control.bus_lock_counter = 0;
@@ -1255,11 +1255,11 @@ void nested_svm_vmexit(struct vcpu_svm *svm)
        }
 
        /*
-        * Invalidate bus_lock_rip unless KVM is still waiting for the guest
-        * to make forward progress before re-enabling bus lock detection.
+        * Invalidate last_bus_lock_rip unless KVM is still waiting for the
+        * guest to make forward progress before re-enabling bus lock detection.
         */
        if (!vmcb02->control.bus_lock_counter)
-               svm->nested.ctl.bus_lock_rip = INVALID_GPA;
+               svm->nested.last_bus_lock_rip = INVALID_GPA;
 
        nested_svm_copy_common_state(svm->nested.vmcb02.ptr, svm->vmcb01.ptr);
 
index 1901e9feff51a9e8f596de64d2af62f9f900c488..62501c12011248c802923ae4e901e811c19cd0fa 100644 (file)
@@ -3271,7 +3271,7 @@ static int bus_lock_exit(struct kvm_vcpu *vcpu)
        vcpu->arch.complete_userspace_io = complete_userspace_buslock;
 
        if (is_guest_mode(vcpu))
-               svm->nested.ctl.bus_lock_rip = vcpu->arch.cui_linear_rip;
+               svm->nested.last_bus_lock_rip = vcpu->arch.cui_linear_rip;
 
        return 0;
 }
index 267ef8a3359b48e7b1bb608abe1bb23307c4c6b6..6c3b3fae91ec14920a55ec44207cb9c220ead90c 100644 (file)
@@ -174,7 +174,6 @@ struct vmcb_ctrl_area_cached {
        u64 nested_cr3;
        u64 virt_ext;
        u32 clean;
-       u64 bus_lock_rip;
        union {
 #if IS_ENABLED(CONFIG_HYPERV) || IS_ENABLED(CONFIG_KVM_HYPERV)
                struct hv_vmcb_enlightenments hv_enlightenments;
@@ -189,6 +188,7 @@ struct svm_nested_state {
        u64 vm_cr_msr;
        u64 vmcb12_gpa;
        u64 last_vmcb12_gpa;
+       u64 last_bus_lock_rip;
 
        /*
         * The MSR permissions map used for vmcb02, which is the merge result