[PATCH v4 4/5] KVM: arm64: nv: Check ->last_vcpu_ran in __kvm_at_s1e01_fast()

Dan Carpenter dan at pereq.eu
Wed Dec 2 02:08:59 PST 2026


If we have a guest hypervisor (L1) and it's running a VM (L2) and the
VM has two vcpus, then when we run AT, KVM has to ensure that no other
vcpu used the same MMU on this physical CPU since this vcpu last ran
there.  Otherwise we could hit the other vcpu's stale TLB entries and
get a wrong answer.

Use the slow path in this case.  The slow path is obviously slower but
this is the simpler solution and this path is very rare.

Reported-by: Sashiko <sashiko-bot at kernel.org>
Closes: https://lore.kernel.org/all/sashiko-outbox-237810@kernel.org/
Fixes: 477e89cabb14 ("KVM: arm64: nv: Add basic emulation of AT S1E{0,1}{R,W}")
Signed-off-by: Dan Carpenter <dan at pereq.eu>
---
 arch/arm64/kvm/at.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/arm64/kvm/at.c b/arch/arm64/kvm/at.c
index 4a1767704d22..164fee4f0b3e 100644
--- a/arch/arm64/kvm/at.c
+++ b/arch/arm64/kvm/at.c
@@ -1457,6 +1457,9 @@ static u64 __kvm_at_s1e01_fast(struct kvm_vcpu *vcpu, u32 op, u64 vaddr)
 	if (!mmu)
 		return par;
 
+	if (*this_cpu_ptr(mmu->last_vcpu_ran) != vcpu->vcpu_idx)
+		return par;
+
 	__mmu_config_save(&config);
 
 	write_sysreg_el1(vcpu_read_sys_reg(vcpu, TTBR0_EL1),	SYS_TTBR0);

-- 
2.53.0




More information about the linux-arm-kernel mailing list