Skip to contentSkip to conversation

KVM: arm64: Failback on unsupported huge page sizes

PATCH Applied Gavin Shan 2 participants 2 messages Oct 25, 2020 – Oct 29, 2020

Subsystems (2)
lore
Share & tools
lore

Gavin Shan

author
#0 lore raw

PATCH v2 1/1 KVM: arm64: Failback on unsupported huge page sizes

The huge page could be mapped through multiple contiguous PMDs or PTEs. The corresponding huge page sizes aren't supported by the page table walker currently.

This fails the unsupported huge page sizes to the near one. Otherwise, the guest can't boot successfully: CONT_PMD_SHIFT and CONT_PTE_SHIFT fail back to PMD_SHIFT and PAGE_SHIFT separately.

---
v2: Reorganize the code as Marc suggested

---
 arch/arm64/kvm/mmu.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)
arch/arm64/kvm/mmu.c +19 -7
index a816cb8e619b..e431d2d8e368 100644
@@ -787,14 +787,26 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
 		vma_shift = PAGE_SHIFT;
 	}
 
-	if (vma_shift == PUD_SHIFT &&
-	    !fault_supports_stage2_huge_mapping(memslot, hva, PUD_SIZE))
-	       vma_shift = PMD_SHIFT;
-
-	if (vma_shift == PMD_SHIFT &&
-	    !fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE)) {
-		force_pte = true;
+	switch (vma_shift) {
+	case PUD_SHIFT:
+		if (fault_supports_stage2_huge_mapping(memslot, hva, PUD_SIZE))
+			break;
+		fallthrough;
+	case CONT_PMD_SHIFT:
+		vma_shift = PMD_SHIFT;
+		fallthrough;
+	case PMD_SHIFT:
+		if (fault_supports_stage2_huge_mapping(memslot, hva, PMD_SIZE))
+			break;
+		fallthrough;
+	case CONT_PTE_SHIFT:
 		vma_shift = PAGE_SHIFT;
+		force_pte = true;
+		fallthrough;
+	case PAGE_SHIFT:
+		break;
+	default:
+		WARN_ONCE(1, "Unknown vma_shift %d", vma_shift);
 	}
 
 	vma_pagesize = 1UL << vma_shift;
Signature · 1 line
2.23.0
maintainer Applied
#1 lore raw
Quoted 7 lines · Gavin Shan

The huge page could be mapped through multiple contiguous PMDs or PTEs. The corresponding huge page sizes aren't supported by the page table walker currently.

This fails the unsupported huge page sizes to the near one. Otherwise, the guest can't boot successfully: CONT_PMD_SHIFT and CONT_PTE_SHIFT fail back to PMD_SHIFT and PAGE_SHIFT separately.

Applied to next, thanks!

[1/1] KVM: arm64: Use fallback mapping sizes for contiguous huge page sizes

      commit: 2f40c46021bbb3ecd5c5f05764ecccbc276bc690

Cheers,

	M.
Signature · 7 lines
Without deviation from the norm, progress is not possible.


_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm