aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDongha Lee <[email protected]>2025-09-06 04:07:24 +0000
committerOliver Upton <[email protected]>2025-09-10 09:56:20 +0000
commitebb2d8fd81b82c8a57f88add118108b1c4408670 (patch)
tree91d87075a549375d8f666a7a88e8c9250da65446
parentKVM: arm64: vgic-v3: Indicate vgic_put_irq() may take LPI xarray lock (diff)
downloadkernel-ebb2d8fd81b82c8a57f88add118108b1c4408670.tar.gz
kernel-ebb2d8fd81b82c8a57f88add118108b1c4408670.zip
KVM: arm64: nv: Fix incorrect VNCR invalidation range calculation
The code for invalidating VNCR entries in both kvm_invalidate_vncr_ipa() and invalidate_vncr_va() incorrectly uses a bitwise AND with `(size - 1)` instead of `~(size - 1)` to align the start address. This results in masking the address bits instead of aligning them down to the start of the block. This bug may cause stale VNCR TLB entries to remain valid even after a TLBI or MMU notifier, leading to incorrect memory translation and unexpected guest behavior. Credit to Team 0xB6 in bob14: DongHa Lee, Gyujeong Jin, Daehyeon Ko, Geonha Lee, Hyungyu Oh, and Jaewon Yang. Reviewed-by: Marc Zyngier <[email protected]> Signed-off-by: Dongha Lee <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
-rw-r--r--arch/arm64/kvm/nested.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/arch/arm64/kvm/nested.c b/arch/arm64/kvm/nested.c
index 24eab94d7d7f..50d559248a1f 100644
--- a/arch/arm64/kvm/nested.c
+++ b/arch/arm64/kvm/nested.c
@@ -847,7 +847,7 @@ static void kvm_invalidate_vncr_ipa(struct kvm *kvm, u64 start, u64 end)
ipa_size = ttl_to_size(pgshift_level_to_ttl(vt->wi.pgshift,
vt->wr.level));
- ipa_start = vt->wr.pa & (ipa_size - 1);
+ ipa_start = vt->wr.pa & ~(ipa_size - 1);
ipa_end = ipa_start + ipa_size;
if (ipa_end <= start || ipa_start >= end)
@@ -887,7 +887,7 @@ static void invalidate_vncr_va(struct kvm *kvm,
va_size = ttl_to_size(pgshift_level_to_ttl(vt->wi.pgshift,
vt->wr.level));
- va_start = vt->gva & (va_size - 1);
+ va_start = vt->gva & ~(va_size - 1);
va_end = va_start + va_size;
switch (scope->type) {