All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: mte: Use PAGE_KERNEL_TAGGED in arch_add_memory
@ 2021-03-03  4:21 Patrick Daly
  2021-03-05 11:19 ` Catalin Marinas
  0 siblings, 1 reply; 13+ messages in thread
From: Patrick Daly @ 2021-03-03  4:21 UTC (permalink / raw)
  To: linux-arm-kernel, catalin.marinas; +Cc: Patrick Daly

In a system which supports MTE, the linear kernel region must allow
reading/writing allocation tags. For memory present at boot this
is already being done in map_mem(). Add the same in arch_add_memory().

Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
---
 arch/arm64/mm/mmu.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c
index 9b25d60b..0fcfe90 100644
--- a/arch/arm64/mm/mmu.c
+++ b/arch/arm64/mm/mmu.c
@@ -1463,6 +1463,7 @@ int arch_add_memory(int nid, u64 start, u64 size,
 		    struct mhp_params *params)
 {
 	int ret, flags = 0;
+	pgprot_t pgprot;
 
 	if (!inside_linear_region(start, size)) {
 		pr_err("[%llx %llx] is outside linear mapping region\n", start, start + size);
@@ -1477,8 +1478,17 @@ int arch_add_memory(int nid, u64 start, u64 size,
 	    IS_ENABLED(CONFIG_KFENCE))
 		flags = NO_BLOCK_MAPPINGS | NO_CONT_MAPPINGS;
 
+	/*
+	 * The linear map must allow allocation tags reading/writing
+	 * if MTE is present. Otherwise, it has the same attributes as
+	 * PAGE_KERNEL.
+	 */
+	pgprot = params->pgprot;
+	if (pgprot_val(pgprot) == pgprot_val(PAGE_KERNEL))
+		pgprot = PAGE_KERNEL_TAGGED;
+
 	__create_pgd_mapping(swapper_pg_dir, start, __phys_to_virt(start),
-			     size, params->pgprot, __pgd_pgtable_alloc,
+			     size, pgprot, __pgd_pgtable_alloc,
 			     flags);
 
 	memblock_clear_nomap(start, size);
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2021-03-08 23:45 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03  4:21 [PATCH] arm64: mte: Use PAGE_KERNEL_TAGGED in arch_add_memory Patrick Daly
2021-03-05 11:19 ` Catalin Marinas
2021-03-05 15:43   ` Catalin Marinas
2021-03-05 15:43     ` Catalin Marinas
2021-03-05 15:55     ` David Hildenbrand
2021-03-05 15:55       ` David Hildenbrand
2021-03-05 17:44       ` Catalin Marinas
2021-03-05 17:44         ` Catalin Marinas
2021-03-08 11:00         ` David Hildenbrand
2021-03-08 11:00           ` David Hildenbrand
2021-03-08 11:18           ` Catalin Marinas
2021-03-08 11:18             ` Catalin Marinas
2021-03-08 23:44             ` Patrick Daly

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.