Re: [PATCH v5 5/7] KVM: arm64: Don't WARN on pKVM stage-2 map failures

From: Bradley Morgan

Date: Tue Jul 21 2026 - 07:10:10 EST


On July 17, 2026 2:03:15 PM GMT+01:00, Fuad Tabba <fuad.tabba@xxxxxxxxx>
wrote:
>pkvm_pgtable_stage2_map() wraps the __pkvm_host_share_guest() and
>__pkvm_host_donate_guest() return in WARN_ON(), but those hypercalls
>fail for reasons that are not EL1 invariant violations: -EINVAL for a
>pfn that is not memblock RAM (check_range_allowed_memory() rejects a
>device page mapped into a non-protected guest) and -ENOMEM under
>memcache pressure. Both are reachable from a guest fault, so the WARN
>splats on host input.
>
>Return the error without warning. The unshare and write-protect WARNs
>stay, since a failure there does signal a broken EL1 invariant.
>
>Fixes: 3669ddd8fa8b5 ("KVM: arm64: Add a range to pkvm_mappings")
>Signed-off-by: Fuad Tabba <fuad.tabba@xxxxxxxxx>

LGTM,

Reviewed-by: Bradley Morgan <include@xxxxxxxxx>


>---
> arch/arm64/kvm/pkvm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/arch/arm64/kvm/pkvm.c b/arch/arm64/kvm/pkvm.c
>index ba6570e37545..1212a2c5613d 100644
>--- a/arch/arm64/kvm/pkvm.c
>+++ b/arch/arm64/kvm/pkvm.c
>@@ -466,7 +466,7 @@ int pkvm_pgtable_stage2_map(struct kvm_pgtable *pgt, u64 addr, u64 size,
> size / PAGE_SIZE, prot);
> }
>
>- if (WARN_ON(ret))
>+ if (ret)
> return ret;
>
> swap(mapping, cache->mapping);
>

Thanks!