]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: arm64: Fix vma_shift staleness on nested hwpoison path
authorFuad Tabba <tabba@google.com>
Wed, 4 Mar 2026 16:22:22 +0000 (16:22 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 6 Mar 2026 10:42:02 +0000 (10:42 +0000)
When user_mem_abort() handles a nested stage-2 fault, it truncates
vma_pagesize to respect the guest's mapping size. However, the local
variable vma_shift is never updated to match this new size.

If the underlying host page turns out to be hardware poisoned,
kvm_send_hwpoison_signal() is called with the original, larger
vma_shift instead of the actual mapping size. This signals incorrect
poison boundaries to userspace and breaks hugepage memory poison
containment for nested VMs.

Update vma_shift to match the truncated vma_pagesize when operating
on behalf of a nested hypervisor.

Fixes: fd276e71d1e7 ("KVM: arm64: nv: Handle shadow stage 2 page faults")
Signed-off-by: Fuad Tabba <tabba@google.com>
Link: https://patch.msgid.link/20260304162222.836152-3-tabba@google.com
[maz: simplified vma_shift assignment from the original patch]
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/mmu.c

index e1d6a4f591a964dcbbaf171e8b2781e983dc1843..17d64a1e11e5c00906fcc93c3948cbab69009040 100644 (file)
@@ -1751,6 +1751,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
 
                force_pte = (max_map_size == PAGE_SIZE);
                vma_pagesize = min_t(long, vma_pagesize, max_map_size);
+               vma_shift = __ffs(vma_pagesize);
        }
 
        /*