Skip to content

Commit 244acf1

Browse files
Fuad TabbaMarc Zyngier
authored andcommitted
KVM: arm64: Fix vma_shift staleness on nested hwpoison path
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: fd276e7 ("KVM: arm64: nv: Handle shadow stage 2 page faults") Signed-off-by: Fuad Tabba <[email protected]> Link: https://patch.msgid.link/[email protected] [maz: simplified vma_shift assignment from the original patch] Signed-off-by: Marc Zyngier <[email protected]>
1 parent e07fc9e commit 244acf1

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

arch/arm64/kvm/mmu.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
17511751

17521752
force_pte = (max_map_size == PAGE_SIZE);
17531753
vma_pagesize = min_t(long, vma_pagesize, max_map_size);
1754+
vma_shift = __ffs(vma_pagesize);
17541755
}
17551756

17561757
/*

0 commit comments

Comments
 (0)