[PATCH 0/2] KVM: arm64: Fix stage-2 THP mapping on hosts with 2-level page tables

From: Fuad Tabba

Date: Mon Nov 23 2026 - 05:35:24 EST


Hi folks,

A fix for how KVM maps a THP at stage-2 on a host with 2-level page
tables (64K pages with a 42-bit VA, or 16K pages with a 36-bit VA).
There, KVM also maps the host memory that follows a THP into the guest
if the guest's first access to the THP isn't to its first page.

transparent_hugepage_adjust() is meant to round the faulting pfn down to
the start of the THP, but its mask is a no-op when the PMD level is
folded, and has been since THP support was added. Before 6f745f1bb5bf2
("KVM: arm64: Convert user_mem_abort() to generic page-table API"), KVM
mapped only the THP anyway, which is why the Fixes: tag is on that
commit. Kernels before f583a53c2b8a ("KVM: arm64: Make fault_ipa
immutable") round the IPA with PMD_MASK, so only the pfn line of the fix
applies there.

Tested on QEMU with a 64K, 42-bit VA host kernel, where the new
selftest scenario fails without the fix and passes with it.

Based on Linux 7.4-rc3 (aebb727447640).

Cheers,
/fuad

Fuad Tabba (2):
KVM: arm64: Fix THP block mapping when the PMD level is folded
KVM: arm64: selftests: Test a THP whose first fault is on a tail page

arch/arm64/kvm/mmu.c | 4 +-
.../kvm/arm64/stage2_block_transitions.c | 56 ++++++++++++++++++-
2 files changed, 55 insertions(+), 5 deletions(-)


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
--
2.47.3