From: Sean Christopherson <seanjc@google.com>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
Yosry Ahmed <yosry.ahmed@linux.dev>
Subject: [PATCH v2 7/8] KVM: nSVM: Move vmcb_ctrl_area_cached.bus_lock_rip to svm_nested_state
Date: Wed, 18 Feb 2026 15:09:57 -0800 [thread overview]
Message-ID: <20260218230958.2877682-8-seanjc@google.com> (raw)
In-Reply-To: <20260218230958.2877682-1-seanjc@google.com>
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.
Signed-off-by: Sean Christopherson <seanjc@google.com>
---
arch/x86/kvm/svm/nested.c | 8 ++++----
arch/x86/kvm/svm/svm.c | 2 +-
arch/x86/kvm/svm/svm.h | 2 +-
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/svm/nested.c b/arch/x86/kvm/svm/nested.c
index bbb8dfc9979b..bcd6304f3c0c 100644
--- a/arch/x86/kvm/svm/nested.c
+++ b/arch/x86/kvm/svm/nested.c
@@ -806,7 +806,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;
@@ -1191,11 +1191,11 @@ int 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);
diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 9e76bf1671da..7c832a0decc2 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -3223,7 +3223,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;
}
diff --git a/arch/x86/kvm/svm/svm.h b/arch/x86/kvm/svm/svm.h
index 92a1691dc7be..c4ed1be38ceb 100644
--- a/arch/x86/kvm/svm/svm.h
+++ b/arch/x86/kvm/svm/svm.h
@@ -173,7 +173,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;
@@ -188,6 +187,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
--
2.53.0.345.g96ddfc5eaa-goog
next prev parent reply other threads:[~2026-02-18 23:10 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-18 23:09 [PATCH v2 0/8] KVM: SVM: A fix and cleanups for VMCB intercepts Sean Christopherson
2026-02-18 23:09 ` [PATCH v2 1/8] KVM: SVM: Explicitly mark vmcb01 dirty after modifying " Sean Christopherson
2026-02-18 23:15 ` Yosry Ahmed
2026-02-18 23:09 ` [PATCH v2 2/8] KVM: SVM: Separate recalc_intercepts() into nested vs. non-nested parts Sean Christopherson
2026-02-18 23:19 ` Yosry Ahmed
2026-02-18 23:09 ` [PATCH v2 3/8] KVM: nSVM: WARN and abort vmcb02 intercepts recalc if vmcb02 isn't active Sean Christopherson
2026-02-18 23:09 ` [PATCH v2 4/8] KVM: nSVM: Directly (re)calc vmcb02 intercepts from nested_vmcb02_prepare_control() Sean Christopherson
2026-02-18 23:20 ` Yosry Ahmed
2026-02-18 23:09 ` [PATCH v2 5/8] KVM: nSVM: Use intuitive local variables in nested_vmcb02_recalc_intercepts() Sean Christopherson
2026-02-18 23:09 ` [PATCH v2 6/8] KVM: nSVM: Use vmcb12_is_intercept() in nested_sync_control_from_vmcb02() Sean Christopherson
2026-02-18 23:09 ` Sean Christopherson [this message]
2026-02-18 23:21 ` [PATCH v2 7/8] KVM: nSVM: Move vmcb_ctrl_area_cached.bus_lock_rip to svm_nested_state Yosry Ahmed
2026-02-18 23:09 ` [PATCH v2 8/8] KVM: nSVM: Capture svm->nested.ctl as vmcb12_ctrl when preparing vmcb02 Sean Christopherson
2026-02-18 23:23 ` Yosry Ahmed
2026-03-05 17:08 ` [PATCH v2 0/8] KVM: SVM: A fix and cleanups for VMCB intercepts Sean Christopherson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260218230958.2877682-8-seanjc@google.com \
--to=seanjc@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=yosry.ahmed@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®