[PATCH v2 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 - 18:00:12 EST
Three changes for issues we found in pKVM as part of our research
project.
Patch 1 fixes 32-bit size computations in hyp_early_alloc_contig()
and hyp_pool_init(). The hyp page-table and host stage-2 regions reach
4 GiB on machines with about 2 TiB of RAM; the early allocator then
carves them too small, so the two pools overlap and can hand out the
same page twice.
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>
---
Changes in v2:
- Patch 1: also fix the same overflow in hyp_early_alloc_contig(), which
makes hpool and host_s2_pool overlap (reported by the Sashiko review of
v1); describe that in the commit message and add its Fixes: tag.
- Link to v1: https://lore.kernel.org/r/20261105-hyp-pool-and-map-v1-0-756bb5d8e067@xxxxxxxxxxxxxxx
---
Xuheng Li (3):
KVM: arm64: Compute hyp early-allocation and pool sizes 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/early_alloc.c | 2 +-
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 +++++++
4 files changed, 14 insertions(+), 4 deletions(-)
---
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
change-id: 20261105-hyp-pool-and-map-b5e7be9a1191
Best regards,
--
Xuheng Li <xuheng@xxxxxxxxxxxxxxx>