From abfeafa87629ff91e7d9d5a9ed32ebd7848ed5be Mon Sep 17 00:00:00 2001 From: zhangyuan21 Date: Thu, 12 Oct 2023 19:14:22 +0800 Subject: [PATCH] arm64: XN should only be set when the attribute MT_EXECUTE_NEVER is set Only when SCTLR_ELn.WXN is set to 1, regions that are writable at ELn are treated as non-executable. Therefore, when SCTLR_ELn.WXN is set to 0, regions that are writable at ELn can be executed, so the writable attribute cannot be used to restrict the executable attribute. Signed-off-by: zhangyuan21 --- arch/arm64/src/common/arm64_mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/src/common/arm64_mmu.c b/arch/arm64/src/common/arm64_mmu.c index 18476049fe..294845d860 100644 --- a/arch/arm64/src/common/arm64_mmu.c +++ b/arch/arm64/src/common/arm64_mmu.c @@ -336,7 +336,7 @@ static void set_pte_block_desc(uint64_t *pte, uint64_t addr_pa, { /* Make Normal RW memory as execute never */ - if ((attrs & MT_RW) || (attrs & MT_EXECUTE_NEVER)) + if (attrs & MT_EXECUTE_NEVER) { desc |= PTE_BLOCK_DESC_PXN; }