[PATCH 0/3] KVM: arm64: Fix the hyp pool size on large machines, plus two hardening patches

From: Xuheng Li via B4 Relay

Date: Thu Nov 05 2026 - 17:29:34 EST


Three changes for issues we found in pKVM as part of our research
project.

Patch 1 fixes a 32-bit size computation in hyp_pool_init(): a pool of
4 GiB or more gets a truncated range and maximum order. hpool and
host_s2_pool reach that size on machines with about 2 TiB of RAM.

Patch 2 checks the host stage-2 PGD allocation for NULL before using
it. With patch 1 applied that allocation cannot fail, so this only
turns a mis-sized pool into a clean -ENOMEM instead of a hyp panic.

Patch 3 makes hyp_map_walker() refuse to replace a valid block mapping
with a table, which would skip break-before-make and unmap the rest of
the block. Nothing in mainline maps into an existing hyp block, so this
is hardening; Android's interface for EL2 modules to map pages can reach
it.

Signed-off-by: Xuheng Li <xuheng@xxxxxxxxxxxxxxx>
---
Xuheng Li (3):
KVM: arm64: Compute the hyp pool size in 64 bits
KVM: arm64: Check the host stage-2 PGD allocation for NULL
KVM: arm64: Don't replace a valid hyp block mapping with a table

arch/arm64/kvm/hyp/nvhe/mem_protect.c | 3 +++
arch/arm64/kvm/hyp/nvhe/page_alloc.c | 6 +++---
arch/arm64/kvm/hyp/pgtable.c | 7 +++++++
3 files changed, 13 insertions(+), 3 deletions(-)
---
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
change-id: 20261105-hyp-pool-and-map-b5e7be9a1191

Best regards,
--
Xuheng Li <xuheng@xxxxxxxxxxxxxxx>