Skip to content

Commit 1d8c3c2

Browse files
committed
KVM: arm64: Ensure canonical IPA is hugepage-aligned when handling fault
Zenghui reports that VMs backed by hugetlb pages are no longer booting after commit fd276e7 ("KVM: arm64: nv: Handle shadow stage 2 page faults"). Support for shadow stage-2 MMUs introduced the concept of a fault IPA and canonical IPA to stage-2 fault handling. These are identical in the non-nested case, as the hardware stage-2 context is always that of the canonical IPA space. Both addresses need to be hugepage-aligned when preparing to install a hugepage mapping to ensure that KVM uses the correct GFN->PFN translation and installs that at the correct IPA for the current stage-2. And now I'm feeling thirsty after all this talk of IPAs... Fixes: fd276e7 ("KVM: arm64: nv: Handle shadow stage 2 page faults") Reported-by: Zenghui Yu <[email protected]> Reviewed-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Oliver Upton <[email protected]>
1 parent f616506 commit 1d8c3c2

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

arch/arm64/kvm/mmu.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1540,8 +1540,15 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
15401540
vma_pagesize = min(vma_pagesize, (long)max_map_size);
15411541
}
15421542

1543-
if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE)
1543+
/*
1544+
* Both the canonical IPA and fault IPA must be hugepage-aligned to
1545+
* ensure we find the right PFN and lay down the mapping in the right
1546+
* place.
1547+
*/
1548+
if (vma_pagesize == PMD_SIZE || vma_pagesize == PUD_SIZE) {
15441549
fault_ipa &= ~(vma_pagesize - 1);
1550+
ipa &= ~(vma_pagesize - 1);
1551+
}
15451552

15461553
gfn = ipa >> PAGE_SHIFT;
15471554
mte_allowed = kvm_vma_mte_allowed(vma);

0 commit comments

Comments
 (0)