[PATCH 14/20] KVM: arm64: pkvm: Warn on guest stage-2 block collapse
Vincent Donnefort
vdonnefort at google.com
Mon Aug 3 03:08:58 PDT 2026
When pKVM is enabled, the host relies on a pkvm_mapping tree that
mirrors the actual hypervisor-owned stage-2. The hypervisor is not
allowed to silently split blocks or collapse page-tables. This should be
treated as a bug.
Therefore, WARN on guest stage-2 page-table collapse which would
otherwise be fatal anyway.
Signed-off-by: Vincent Donnefort <vdonnefort at google.com>
diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
index 2340706e41d3..e16dde4c5f4b 100644
--- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c
+++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c
@@ -226,6 +226,12 @@ static void guest_s2_put_page(void *addr)
hyp_put_page(¤t_vm->pool, addr);
}
+static void guest_s2_free_unlinked_table(void *addr, s8 level)
+{
+ /* We should never collapse guest stage-2 tables into blocks */
+ WARN_ON(1);
+}
+
static void __apply_guest_page(void *va, size_t size,
void (*func)(void *addr, size_t size))
{
@@ -287,6 +293,7 @@ int kvm_guest_prepare_stage2(struct pkvm_hyp_vm *vm, void *pgd)
.put_page = guest_s2_put_page,
.dcache_clean_inval_poc = clean_dcache_guest_page,
.icache_inval_pou = invalidate_icache_guest_page,
+ .free_unlinked_table = guest_s2_free_unlinked_table,
};
guest_lock_component(vm);
--
2.55.0.508.g3f0d502094-goog
More information about the linux-arm-kernel
mailing list