All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: SVM: handle wraparound of asid_generation
@ 2026-06-25  9:40 suryasaimadhu
  2026-06-25  9:58 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: suryasaimadhu @ 2026-06-25  9:40 UTC (permalink / raw)
  To: seanjc, pbonzini
  Cc: tglx, mingo, bp, dave.hansen, x86, hpa, kvm, linux-kernel,
	suryasaimadhu

If asid_generation wraps around to 0, it matches the initial
value of svm->current_vmcb->asid_generation (0), causing KVM
to skip calling new_asid() and potentially reuse stale ASIDs.

Fix this by skipping 0 when incrementing asid_generation.

Signed-off-by: suryasaimadhu <suryasaimadhu369@gmail.com>
---
 arch/x86/kvm/svm/svm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c
index 9658ce4e0..fafd0af5d 100644
--- a/arch/x86/kvm/svm/svm.c
+++ b/arch/x86/kvm/svm/svm.c
@@ -1900,7 +1900,8 @@ static void svm_update_exception_bitmap(struct kvm_vcpu *vcpu)
 static void new_asid(struct vcpu_svm *svm, struct svm_cpu_data *sd)
 {
 	if (sd->next_asid > sd->max_asid) {
-		++sd->asid_generation;
+		if (!++sd->asid_generation)
+			sd->asid_generation = 1;
 		sd->next_asid = sd->min_asid;
 		svm->vmcb->control.tlb_ctl = TLB_CONTROL_FLUSH_ALL_ASID;
 		vmcb_mark_dirty(svm->vmcb, VMCB_ASID);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-06-25 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-25  9:40 [PATCH] KVM: SVM: handle wraparound of asid_generation suryasaimadhu
2026-06-25  9:58 ` sashiko-bot
2026-06-25 14:47   ` Sean Christopherson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.