From 16df80ab9cf2b262c32cb6d18c3d1cb2f16d07d5 Mon Sep 17 00:00:00 2001 From: Vincent Donnefort Date: Thu, 13 Mar 2025 17:00:02 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Disable relinquish for p-guest huge-mappings Memory relinquish with huge stage-2 mappings is currently utterly borken as we can't page-fault a half reclaimed huge mapping. Prevent it until it is fixed. Bug: 419548963 Change-Id: I7256042ed8392997dc488199c494cb9984270e24 Signed-off-by: Vincent Donnefort --- arch/arm64/kvm/hyp/nvhe/mem_protect.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/arm64/kvm/hyp/nvhe/mem_protect.c b/arch/arm64/kvm/hyp/nvhe/mem_protect.c index c95a5e896251..1981ce61acd4 100644 --- a/arch/arm64/kvm/hyp/nvhe/mem_protect.c +++ b/arch/arm64/kvm/hyp/nvhe/mem_protect.c @@ -387,6 +387,10 @@ static int relinquish_walker(const struct kvm_pgtable_visit_ctx *ctx, if (!kvm_pte_valid(pte)) return 0; + /* We don't support splitting non-leaf mappings */ + if (ctx->level != (KVM_PGTABLE_MAX_LEVELS - 1)) + return 0; + state = pkvm_getstate(kvm_pgtable_stage2_pte_prot(pte)); if (state != data->expected_state) return -EPERM;