From 66251331379fcfadfea33cb48b7051ad83cce511 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Wed, 20 Sep 2023 14:08:41 +0100 Subject: [PATCH] ANDROID: KVM: arm64: Don't force pte mappings in [n]VHE guest stage-2 Commit d096d35445d7 ("ANDROID: KVM: arm64: Have different callbacks for PTE manipulation") accidentally forces the use of pte-level mappings for the guest stage-2 page-table when not using pKVM. This confuses user_mem_abort() when the guest takes a permission fault trying to execute from a huge page. Since the fault is reported at the pte-level, we end up handling it as a translation fault by calling kvm_pgtable_stage2_map() which dutifully returns -EAGAIN when it finds the RW PTE. Consequently, the guest appears to hang randomly during boot. Fix the issue by inverting stage2_force_pte_cb() so that the host is in complete control of the mapping granularity of the guest when pKVM is not being used. Cc: Fuad Tabba Cc: Mostafa Saleh Fixes: d096d35445d7 ("ANDROID: KVM: arm64: Have different callbacks for PTE manipulation") Signed-off-by: Will Deacon Bug: 222044487 Change-Id: Ideab281ae6d1d5c0fd29fba03ad8ed1cae521a1e --- arch/arm64/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c index 6259a72812e9..8d4d1374012a 100644 --- a/arch/arm64/kvm/mmu.c +++ b/arch/arm64/kvm/mmu.c @@ -701,7 +701,7 @@ static int get_user_mapping_size(struct kvm *kvm, u64 addr) static bool stage2_force_pte_cb(u64 addr, u64 end, enum kvm_pgtable_prot prot) { - return true; + return false; } static bool stage2_pte_is_counted(kvm_pte_t pte, u32 level)