From patchwork Wed Mar 3 04:21:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Daly X-Patchwork-Id: 12113637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66FA5C433E0 for ; Wed, 3 Mar 2021 14:32:13 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2926C64EE4 for ; Wed, 3 Mar 2021 14:32:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2926C64EE4 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:MIME-Version:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To:From:Reply-To: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=hk+05qixtubnfHwUhUsN0xumPWnLJIMqPknYAtxLqAU=; b=Rtc0OCooJYbrYF8SmonAmfR3nk /ckZLD9yG/O6ruMamQTqsfdtJFjR202SihQwzGhu3QR2yuqpFowmgJ41K621Q7pBGlx5BbQyieMlm ti4JeptTThWrnMJc/Xm6lUxTWl9Ojw8cBkU0YH039NWAuZmjJka8lcls1nU25Rekah7R+nPi8Lm0F u65Q84E3dixFYQlaM17rfmhWlrJhVFv9W9TJ8MWDNVEm6gBepflfujBXGu0P7jbqlHoKA9CquvNLT YLWFuIovAyYQMgMVk40GM0LTEig+a7R4XNT1y74jAn9z4pBzJGtFmcoVG1haJS7gYnDQNnDI/uUHg 59WGnnrQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lHSVJ-0058YC-Aq; Wed, 03 Mar 2021 14:29:33 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHS8S-0053CW-7K for linux-arm-kernel@desiato.infradead.org; Wed, 03 Mar 2021 14:05:56 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To:References; bh=ldfxjLFHtXKsltZ7DpqkrY7N8nvUCvOrPhPB9LgRfEE=; b=Je5UoXipOK4D9XBWxop3QXdgoz 6ZSvQFroW/J52Sar3Mw5yXlsV+IkcL7UEY2vMzsap5d4MShhvM/+h9gWAfIFXbabXrnFkmSA8lbhb GQ31JNtr3/n94z1WneCHMyb4n/2psM4LTtC/jRwdS1fvIXj2RIsWKmFfhQOPSaqlC2jOPMGD2QtRs bNbGt5cJkY6BJN1cESxgRbzI4ejtg+gOEmxU43L3f0l+J6mZS7JrpABF34q/i1HMWh6Fw35urOJb9 QFH6DB5gu1udVQ37kQUFDXeVzjt34plz4Sd7we9f8MqM8XstdCEehO6c8K5m1B/RyHcFzwfASUsR3 qaxgrVng==; Received: from labrats.qualcomm.com ([199.106.110.90]) by casper.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lHJ2p-001FZm-1k for linux-arm-kernel@lists.infradead.org; Wed, 03 Mar 2021 04:23:31 +0000 IronPort-SDR: PewXvtshzulzjSuvaQZy2Y59jlx4TTp5FFurTdb+nc5I+hHpjw1xb1yieSGdeXbHXumV/m+OZ5 aEWgPBBFbp9pjAGb7TRwnYcaCrS0AWZRQOPZT+wRpgg/XO30dTXLfYbP4u7rZFQ0tXT5Tsq2GQ jQkbPFbbqs+0Gp/wXXGwsvWYIBDzujOafR1PkxIcALJCEQYz1uRMfWcy7uW2M/pgyqAHXY3Ura celjfjAE0QzoqG1f7ubar7EftZgRvmiI5K/A1Frgdd7ew6VIJEWGKTve2zQ3pe/TrvRy7yIPsF fFU= X-IronPort-AV: E=Sophos;i="5.81,218,1610438400"; d="scan'208";a="47799779" Received: from unknown (HELO ironmsg02-sd.qualcomm.com) ([10.53.140.142]) by labrats.qualcomm.com with ESMTP; 02 Mar 2021 20:22:23 -0800 X-QCInternal: smtphost Received: from linux-kernel-memory-lab-01.qualcomm.com ([10.63.172.21]) by ironmsg02-sd.qualcomm.com with ESMTP; 02 Mar 2021 20:22:19 -0800 Received: by linux-kernel-memory-lab-01.qualcomm.com (Postfix, from userid 98314) id E8A6022539; Tue, 2 Mar 2021 20:22:15 -0800 (PST) From: Patrick Daly To: linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com Cc: Patrick Daly Subject: [PATCH] arm64: mte: Use PAGE_KERNEL_TAGGED in arch_add_memory Date: Tue, 2 Mar 2021 20:21:03 -0800 Message-Id: <1614745263-27827-1-git-send-email-pdaly@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210303_042331_584085_D508C261 X-CRM114-Status: UNSURE ( 9.83 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 --- 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);