From 9e4f6e1ef8ce7be966c7e7925f0699535871c490 Mon Sep 17 00:00:00 2001 From: Will Deacon Date: Mon, 30 Oct 2023 11:11:20 +0000 Subject: [PATCH] ANDROID: KVM: arm64: Fix KVM_HOST_S2_DEFAULT_MMIO_PTE encoding Commit b489c5300127 ("ANDROID: KVM: arm64: Allow setting {P,U}XN in stage-2 PTEs") changed KVM_PTE_LEAF_ATTR_HI_S2_XN to refer to the XN field of the pte (i.e. bits 54:53) instead of just bit 54 and forgot to update KVM_HOST_S2_DEFAULT_MMIO_PTE in the process. Consequently, coalescing will fail to apply to default MMIO ptes and may inadvertently trigger for ptes marked as UXN. Fix the mask. Cc: Quentin Perret Cc: Sebastian Ene Bug: 308395502 Signed-off-by: Will Deacon Change-Id: I4f85eae7ccee008a1161e09739c1fd4f3e1b6e2b --- arch/arm64/include/asm/kvm_pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index ce85d55fb981..56e5edcc5aee 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -234,7 +234,7 @@ enum kvm_pgtable_prot { #define KVM_HOST_S2_DEFAULT_MMIO_PTE \ (KVM_HOST_S2_DEFAULT_MEM_PTE | \ - KVM_PTE_LEAF_ATTR_HI_S2_XN) + FIELD_PREP(KVM_PTE_LEAF_ATTR_HI_S2_XN, KVM_PTE_LEAF_ATTR_HI_S2_XN_XN)) #define PAGE_HYP KVM_PGTABLE_PROT_RW #define PAGE_HYP_EXEC (KVM_PGTABLE_PROT_R | KVM_PGTABLE_PROT_X)