All of lore.kernel.org
 help / color / mirror / Atom feed
From: Patrick Daly <pdaly@codeaurora.org>
To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com
Cc: Patrick Daly <pdaly@codeaurora.org>
Subject: [PATCH] arm64: mte: Use PAGE_KERNEL_TAGGED in arch_add_memory
Date: Tue,  2 Mar 2021 20:21:03 -0800	[thread overview]
Message-ID: <1614745263-27827-1-git-send-email-pdaly@codeaurora.org> (raw)

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

             reply	other threads:[~2021-03-03 14:32 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-03  4:21 Patrick Daly [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1614745263-27827-1-git-send-email-pdaly@codeaurora.org \
    --to=pdaly@codeaurora.org \
    --cc=catalin.marinas@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --subject='Re: [PATCH] arm64: mte: Use PAGE_KERNEL_TAGGED in arch_add_memory' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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.