Skip to content

Commit 2f40c46

Browse files
Gavin ShanMarc Zyngier
authored andcommitted
KVM: arm64: Use fallback mapping sizes for contiguous huge page sizes
Although huge pages can be created out of multiple contiguous PMDs or PTEs, the corresponding sizes are not supported at Stage-2 yet. Instead of failing the mapping, fall back to the nearer supported mapping size (CONT_PMD to PMD and CONT_PTE to PTE respectively). Suggested-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Gavin Shan <gshan@redhat.com> [maz: rewritten commit message] Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20201025230626.18501-1-gshan@redhat.com
1 parent e2fc6a9 commit 2f40c46

1 file changed

Lines changed: 19 additions & 7 deletions

File tree

arch/arm64/kvm/mmu.c

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -787,14 +787,26 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
787787
vma_shift = PAGE_SHIFT;
788788
}
789789

790-
if (vma_shift == PUD_SHIFT &&
791-
!fault_supports_stage2_huge_mapping(memslot, hva, PUD_SIZE))
792-
vma_shift = PMD_SHIFT;
793-
794-
if (vma_shift == PMD_SHIFT &&
795-
!fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE)) {
796-
force_pte = true;
790+
switch (vma_shift) {
791+
case PUD_SHIFT:
792+
if (fault_supports_stage2_huge_mapping(memslot, hva, PUD_SIZE))
793+
break;
794+
fallthrough;
795+
case CONT_PMD_SHIFT:
796+
vma_shift = PMD_SHIFT;
797+
fallthrough;
798+
case PMD_SHIFT:
799+
if (fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE))
800+
break;
801+
fallthrough;
802+
case CONT_PTE_SHIFT:
797803
vma_shift = PAGE_SHIFT;
804+
force_pte = true;
805+
fallthrough;
806+
case PAGE_SHIFT:
807+
break;
808+
default:
809+
WARN_ONCE(1, "Unknown vma_shift %d", vma_shift);
798810
}
799811

800812
vma_pagesize = 1UL << vma_shift;

0 commit comments

Comments
 (0)