[PATCH v4 0/5] KVM: arm64: nv: Fix AT emulation for nested virtualization
Dan Carpenter
dan at pereq.eu
Wed Dec 2 02:08:55 PST 2026
This series fixes 3 issues found by our formal analysis at Pereq and
two extra bugs that were found during the review process.
* VMs were potentially using the TCR2 bits which weren't intended for
them.
* It turns out that guests could write to the TCR2 bits even when those
bits are "hidden".
* The VMID wasn't handled correctly. Roll over could happen before or
during the AT execution leading to invalid results.
* Sashiko pointed out that we need to test ->last_vcpu_ran
* Also ensure that ->pending_unmap isn't set
I'm not totally sure the rules of when to CC stable. I included it on
the first three but I didn't include it on the last two. Commit
94d0e5980d67 ("arm/arm64: KVM: Perform local TLB invalidation when
multiplexing vcpus on a single CPU") is basically the same as patch 4
and didn't Cc stable.
NOTE: My AI review process says that AT is still not safe under
PREEMPT_RT but I'm really trying to focus on Pereq bugs and I'm spending
a lot of time fixing other bugs. So I'm going to leave that for later.
Changes in v4:
Version 4 adds two new patches at the end. The rest are unchanged.
Changes in v3:
In v2 patches 2 and 3 added traps to prevent writes to hidden TCR2
bits. Marc didn't like this approach and to be honest, the patch
had other issues as well. Marc suggested that we load load
PIR/PIRE0/POR unconditionally instead and that's the approach here
in patch 2.
The other thing is that I have been trying to improve my review
process so I ended up fixing a bug handling POR_EL0 in __kvm_at_s1e01_fast().
That fix is now merged into patch 1 since it feels very related and
it gets backported to the same kernel.
Changes in v2:
1) Sashiko pointed out that we need to restore the original TCR2
bits at the end of the AT command.
2) Clean up based on Marc's feedback.
3) Trap the writes to the TCR2 registers (normal and nested)
Signed-off-by: Dan Carpenter <dan at pereq.eu>
---
Dan Carpenter (5):
KVM: arm64: nv: Fix AT emulation for TCR2_EL1
KVM: arm64: Load no-access permissions when S1PIE or S1POE is hidden
KVM: arm64: nv: Update the shadow MMU's VMID for AT emulation
KVM: arm64: nv: Check ->last_vcpu_ran in __kvm_at_s1e01_fast()
KVM: arm64: nv: Check for pending unmaps in AT fast path
arch/arm64/kvm/at.c | 66 +++++++++++++++++++++++++++---
arch/arm64/kvm/hyp/include/hyp/sysreg-sr.h | 40 +++++++++++++-----
arch/arm64/kvm/hyp/vhe/sysreg-sr.c | 15 ++++---
3 files changed, 101 insertions(+), 20 deletions(-)
---
base-commit: 5a7235e9adff42aa043ac9473dbeb0354dca0967
change-id: 20261202-nv-tcr2-v4_send-cf75e257705d
Best regards,
--
Dan Carpenter <dan at pereq.eu>
More information about the linux-arm-kernel
mailing list