public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault
@ 2026-03-05 13:27 Marc Zyngier
  2026-03-05 14:20 ` Quentin Perret
  2026-03-05 15:20 ` Marc Zyngier
  0 siblings, 2 replies; 3+ messages in thread
From: Marc Zyngier @ 2026-03-05 13:27 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel
  Cc: Joey Gouly, Suzuki K Poulose, Oliver Upton, Zenghui Yu,
	Will Deacon, Fuad Tabba, Quentin Perret, stable

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")
Link: https://lore.kernel.org/r/86wlzr77cn.wl-maz@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
Cc: stable@vger.kernel.org
Cc: Quentin Perret <qperret@google.com>
---
 arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
index 38f66a56a7665..d815265bd374f 100644
--- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
+++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
@@ -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;
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault
  2026-03-05 13:27 [PATCH] KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault Marc Zyngier
@ 2026-03-05 14:20 ` Quentin Perret
  2026-03-05 15:20 ` Marc Zyngier
  1 sibling, 0 replies; 3+ messages in thread
From: Quentin Perret @ 2026-03-05 14:20 UTC (permalink / raw)
  To: Marc Zyngier
  Cc: kvmarm, linux-arm-kernel, Joey Gouly, Suzuki K Poulose,
	Oliver Upton, Zenghui Yu, Will Deacon, Fuad Tabba, stable

On Thursday 05 Mar 2026 at 13:27:51 (+0000), Marc Zyngier wrote:
> 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")
> Link: https://lore.kernel.org/r/86wlzr77cn.wl-maz@kernel.org
> Signed-off-by: Marc Zyngier <maz@kernel.org>
> Cc: stable@vger.kernel.org
> Cc: Quentin Perret <qperret@google.com>
> ---
>  arch/arm64/kvm/hyp/nvhe/mem_protect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> index 38f66a56a7665..d815265bd374f 100644
> --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
> @@ -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;
> -- 
> 2.47.3
> 


Reviewed-by: Quentin Perret <qperret@google.com>

Thanks,
Quentin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault
  2026-03-05 13:27 [PATCH] KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault Marc Zyngier
  2026-03-05 14:20 ` Quentin Perret
@ 2026-03-05 15:20 ` Marc Zyngier
  1 sibling, 0 replies; 3+ messages in thread
From: Marc Zyngier @ 2026-03-05 15:20 UTC (permalink / raw)
  To: kvmarm, linux-arm-kernel, Marc Zyngier
  Cc: Joey Gouly, Suzuki K Poulose, Oliver Upton, Zenghui Yu,
	Will Deacon, Fuad Tabba, Quentin Perret, stable

On Thu, 05 Mar 2026 13:27:51 +0000, Marc Zyngier wrote:
> 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.
-- 
Without deviation from the norm, progress is not possible.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-03-05 15:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 13:27 [PATCH] KVM: arm64: pkvm: Fallback to level-3 mapping on host stage-2 fault Marc Zyngier
2026-03-05 14:20 ` Quentin Perret
2026-03-05 15:20 ` Marc Zyngier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox