Skip to contentSkip to conversation

KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault

PATCH Applied Marc Zyngier 2 participants 3 messages Mar 5

Subsystems (3)
lore
Share & tools
lore

Marc Zyngier

author maintainer
#0 lore raw

PATCH 1/1 KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault

If, for any odd reason, we cannot converge to mapping size that is completely contained in a memblock region, we fail to install a S2 mapping and go back to the faulting instruction. Rince, repeat.

This happens when faulting in regions that are smaller than a page or that do not have PAGE_SIZE-aligned boundaries (as witnessed on an O6 board that refuses to boot in protected mode).

In this situation, fallback to using a PAGE_SIZE mapping anyway -- it isn't like we can go any lower.

Fixes e728e705802fe ("KVM: arm64: Adjust range correctly during host stage-2 faults")
Cc Quentin Perret <[email protected]>
---
 arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/mem_protect.c +1 -1
index 38f66a56a7665..d815265bd374f 100644
@@ -518,7 +518,7 @@ static int host_stage2_adjust_range(u64 addr, struct kvm_mem_range *range)
 		granule = kvm_granule_size(level);
 		cur.start = ALIGN_DOWN(addr, granule);
 		cur.end = cur.start + granule;
-		if (!range_included(&cur, range))
+		if (!range_included(&cur, range) && level < KVM_PGTABLE_LAST_LEVEL)
 			continue;
 		*range = cur;
 		return 0;
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 36 lines · Marc Zyngier

If, for any odd reason, we cannot converge to mapping size that is completely contained in a memblock region, we fail to install a S2 mapping and go back to the faulting instruction. Rince, repeat.

This happens when faulting in regions that are smaller than a page or that do not have PAGE_SIZE-aligned boundaries (as witnessed on an O6 board that refuses to boot in protected mode).

In this situation, fallback to using a PAGE_SIZE mapping anyway -- it isn't like we can go any lower.

Fixes e728e705802fe ("KVM: arm64: Adjust range correctly during host stage-2 faults")
Cc Quentin Perret <[email protected]>
---
 arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/kvm/hyp/nvhe/mem_protect.c +1 -1
index 38f66a56a7665..d815265bd374f 100644
@@ -518,7 +518,7 @@ static int host_stage2_adjust_range(u64 addr, struct kvm_mem_range *range)
 		granule = kvm_granule_size(level);
 		cur.start = ALIGN_DOWN(addr, granule);
 		cur.end = cur.start + granule;
-		if (!range_included(&cur, range))
+		if (!range_included(&cur, range) && level < KVM_PGTABLE_LAST_LEVEL)
 			continue;
 		*range = cur;
 		return 0;
Signature · 1 line
2.47.3

Thanks,
Quentin

author maintainer Applied
#2 lore raw
In reply to Marc Zyngier
Quoted 9 lines · Marc Zyngier

If, for any odd reason, we cannot converge to mapping size that is completely contained in a memblock region, we fail to install a S2 mapping and go back to the faulting instruction. Rince, repeat.

This happens when faulting in regions that are smaller than a page or that do not have PAGE_SIZE-aligned boundaries (as witnessed on an O6 board that refuses to boot in protected mode).

[...]

Applied to fixes, thanks!

[1/1] KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault

      commit: 8531d5a83d8eb8affb5c0249b466c28d94192603

Cheers,

	M.
Signature · 1 line
Without deviation from the norm, progress is not possible.