From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>,
Vasileios Almpanis <vasileios.almpanis@virtuozzo.com>
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 1/7] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure
Date: Thu, 26 Nov 2026 22:52:59 +0100 [thread overview]
Message-ID: <20261126-khorenko-vstor-157390-kvm-fixes-v1-1-ea4024e03c63@virtuozzo.com> (raw)
In-Reply-To: <20261126-khorenko-vstor-157390-kvm-fixes-v1-0-ea4024e03c63@virtuozzo.com>
From: Sean Christopherson <seanjc@google.com>
[ Upstream commit b2691b3a6cd230209736c89684dab90d939aa56b ]
Conditionally reschedule when retrying a guest PTE walk because the CMPXCHG
to update A/D bits failed, e.g. because a different task/vCPU modified the
relevant gPTEs. On kernels without involuntary preemption of some kind, a
misbehaving guest can "capture" a pCPU effectively indefinitely and trigger
soft lockups by continuously modifying its gPTEs such that the result of
the walk is remains valid.
Fixes: b3e4e63fd9ee ("KVM: MMU: Use cmpxchg for pte updates on walk_addr()")
Cc: stable@vger.kernel.org
Reported-by: Stefan Teodorescu <fane@google.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-ID: <20261022015903.282261-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit 399c8c1e2ea42018960a31ef3a2e93554e50f606)
https://virtuozzo.atlassian.net/browse/VSTOR-157287
Feature: fix ms/kvm
Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
arch/x86/kvm/mmu/paging_tmpl.h | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h
index af220c9c8ab8d..1727399b6899f 100644
--- a/arch/x86/kvm/mmu/paging_tmpl.h
+++ b/arch/x86/kvm/mmu/paging_tmpl.h
@@ -321,6 +321,13 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
gpa_t real_gpa;
gfn_t gfn;
+ /*
+ * KVM might sleep/resched when retrying the walk if the updating A/D
+ * fails because the gPTE changed between reading the gPTE and trying
+ * the CMPXHG to set A/D bits.
+ */
+ might_sleep();
+
trace_kvm_mmu_pagetable_walk(addr, access);
retry_walk:
walker->level = mmu->cpu_role.base.level;
@@ -467,8 +474,10 @@ static int FNAME(walk_addr_generic)(struct guest_walker *walker,
addr, write_fault);
if (unlikely(ret < 0))
goto error;
- else if (ret)
+ else if (ret) {
+ cond_resched();
goto retry_walk;
+ }
}
return 1;
--
2.43.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-26 21:54 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:52 [Devel] [PATCH hci-8.2 0/7] KVM fixes for the 8.2 kernel Konstantin Khorenko
2026-11-26 21:52 ` Konstantin Khorenko [this message]
2026-12-01 0:44 ` [Devel] [PATCH hci-8.2 1/7] ms/KVM: x86/mmu: Conditionally resched when retrying gPTE walk on A/D update failure no-reply
2026-11-26 21:53 ` [Devel] [PATCH hci-8.2 2/7] ms/KVM: x86: Conditionally resched when restarting REP string emulation Konstantin Khorenko
2026-12-01 0:45 ` no-reply
2026-11-26 21:53 ` [Devel] [PATCH hci-8.2 3/7] ms/KVM: nVMX: Process each host MSR entry at most once when unwinding failed VM-Entry Konstantin Khorenko
2026-12-01 0:45 ` no-reply
2026-11-26 21:53 ` [Devel] [PATCH hci-8.2 4/7] ms/KVM: x86/mmu: Cap number of parent PTEs per SP at 1000 (the arbitrary rmap limit) Konstantin Khorenko
2026-12-01 0:46 ` no-reply
2026-11-26 21:53 ` [Devel] [PATCH hci-8.2 5/7] ms/KVM: x86: Unconditionally reset MMU context when emulating INIT Konstantin Khorenko
2026-12-01 0:47 ` no-reply
2026-11-26 21:53 ` [Devel] [PATCH hci-8.2 6/7] ms/KVM: SVM: Triple fault L1 on unintercepted EFER.SVME clear by L2 Konstantin Khorenko
2026-12-01 0:49 ` no-reply
2026-11-26 21:53 ` [Devel] [PATCH hci-8.2 7/7] ms/KVM: selftests: Add a test for L2 clearing EFER.SVME without intercept Konstantin Khorenko
2026-12-01 0:50 ` no-reply
2026-11-27 14:43 ` [Devel] [PATCH hci-8.2 0/7] KVM fixes for the 8.2 kernel Konstantin Khorenko
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=20261126-khorenko-vstor-157390-kvm-fixes-v1-1-ea4024e03c63@virtuozzo.com \
--to=khorenko@virtuozzo.com \
--cc=devel@openvz.org \
--cc=ptikhomirov@virtuozzo.com \
--cc=vasileios.almpanis@virtuozzo.com \
/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 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.