From patchwork Thu Aug 22 15:11:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13773687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B95DC3DA4A for ; Thu, 22 Aug 2024 15:12:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9E4BD6B0255; Thu, 22 Aug 2024 11:12:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 995496B025C; Thu, 22 Aug 2024 11:12:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 80EA56B0255; Thu, 22 Aug 2024 11:12:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 5BCF46B0250 for ; Thu, 22 Aug 2024 11:12:40 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 08B1C8177C for ; Thu, 22 Aug 2024 15:12:39 +0000 (UTC) X-FDA: 82480223280.26.FE41AB9 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP id 5DD9A140021 for ; Thu, 22 Aug 2024 15:12:38 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724339518; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hcli0Td5f2QXcIZuDvn/8dKsjYNziEJ78ahe7tKTuic=; b=yFIX5oLA6mKGdCC1MNsP+iFFIh62w3XYeU+SYG/ZtBQSLApN2wecDXUN8kfK2I6A4xsUN/ fNFAnmToBh75eM+oYKE8dErvYmtg1prfu7fSU3phMD85tTZ+Kwy6nL1k4ln8P3WbaeDxlF a4O+4dDZZo3q3ZcVSa8RQK8gKNpmMM4= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=none; spf=pass (imf09.hostedemail.com: domain of joey.gouly@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=joey.gouly@arm.com; dmarc=pass (policy=none) header.from=arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724339518; a=rsa-sha256; cv=none; b=lkmVutmp1EgcJ1P8uW4ziu3WvLEwS+Rfo3Rxo/c7pobRxRWBDSSynFqpknn2km+J0EBscy qMPTcTzMcwskxYKZpBFW/2MmLDxmjBf73+QDlQr3/QPJ265YB2hiHiCqvQ2oqZ1eSsmKbY ET5sVCMhbdUf8QEQ2sL/zfujS7qtZHQ= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C8794DA7; Thu, 22 Aug 2024 08:13:03 -0700 (PDT) Received: from e124191.cambridge.arm.com (e124191.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A9C703F58B; Thu, 22 Aug 2024 08:12:33 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: nd@arm.com, akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.com, anshuman.khandual@arm.com, bp@alien8.de, broonie@kernel.org, catalin.marinas@arm.com, christophe.leroy@csgroup.eu, dave.hansen@linux.intel.com, hpa@zytor.com, joey.gouly@arm.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, maz@kernel.org, mingo@redhat.com, mpe@ellerman.id.au, naveen.n.rao@linux.ibm.com, npiggin@gmail.com, oliver.upton@linux.dev, shuah@kernel.org, skhan@linuxfoundation.org, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev, linux-kselftest@vger.kernel.org Subject: [PATCH v5 17/30] arm64: add pte_access_permitted_no_overlay() Date: Thu, 22 Aug 2024 16:11:00 +0100 Message-Id: <20240822151113.1479789-18-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240822151113.1479789-1-joey.gouly@arm.com> References: <20240822151113.1479789-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 5DD9A140021 X-Stat-Signature: zjo51wa9g5s3g9wowx8jkhuxe6oy3ex3 X-HE-Tag: 1724339558-964828 X-HE-Meta: U2FsdGVkX1+1zXuSLnSogBXCPZI3rmG7+k21ccR6BvKX2ZOeOS9aokzmEsdoL2faCHeuraL8+SNVgNOFb2Kj6VxypFdGPgEA5tWJ0gdC8SRVmcHhLCZw2AeLEFJD/2m5OKdOPluuObDM/4K+N96NYOnj8CyPIXSk5f2OsKawXfOQmzkLny6wZQxuLFLf3IprdfFbtIu5OLYs//6J6mTAb3LPO4fAnyZecOD/x9tuGOjvAa2dw69tQHykd9c4X/5fjenXN7iwx/G2/WZEaRj1d4eUsZ+URD+yZW1QN0n0sF5OWVgsS25DX38ng8zsdxtH11BJffrrMt123bJPYiXCYOYzhWRr7RR1XfFhNW8W2PN2+PJA++h2a75u7sybFp4JpQoch5W/Cws7xWRoZH9J3+1JjZiqMeDfYW0aZn0bFUlU8M1lpZjrl/tZYtp38Y4zdVsloaD14tiCe/lJ9y1PjkiztZo/dGjkd7XiCKe62Hh/lRfQEjWTvKNZUXD1YmLUJ+Ors3nqhChzHoX1Xbk90xcvnvzkgT1xKzO53kyGwLqSIWZe5k9s/EOAFvsD9R7ZhTFidtTGPfj5UG8NXCSAteKcbjRy2sHl7sNXFnqc805a9/W0D5Sle6GBmOQhZLd7Yt1Uu77RizHntCwM8NGFP+5OeMNq+aEC5M8T0prhQcVF2+gJPTwLo951zWqsSxCNswTs5dmw1j9EtircQTikzhXE9jXEF6i8jRs7W4iYpeK9TgzzDNKvPxUGmUpG65QPGlH6ru8XVA54nrCMORJ0iBBiXsyzqYe/cH8KC/5bpootDByfstc3OAs6JbF2QMzpAnGo3+Tc+LG+O4tDk+UAxic9eGNxESnYhstJRe5aP9FSQfU2/pX/ucVPyPOGD8st9NKXOxtF2R8I5m4hbBVRVhKpEWHpsa4R5J6ndocQDy2I8HiuKXOFdfp7Uv80O5jLdw0/FsXlQHKzuIE/zTK Zg9iZ+3Y Bx5t7COOXtpt5mzLOWkgGN+ieJPtAi1A6HH/FDoefd/Thr4gRh0p1dTTSlTmWXCiO5gzr9P+EzhUqD2TeXSXTwk3iFCW5fFfmx8Vbn0yYEUWNoP0vSwZp/9UgTN6qa4nSNcNu2KKt0UPEeYM12FPPv5GJkcz55avzzZ6gaYMVqRTEyaMvRFFyTa4bh2mW/j5lRCfzj0ntlBrmFcPogetxrSgfsPTlPok6CwjGtoHvTub2LDhvl5Ztt5utUoXhGH/KUnxKlCihTw7Jqzg= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We do not want take POE into account when clearing the MTE tags. Signed-off-by: Joey Gouly Cc: Catalin Marinas Cc: Will Deacon Reviewed-by: Catalin Marinas Reviewed-by: Anshuman Khandual --- arch/arm64/include/asm/pgtable.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git arch/arm64/include/asm/pgtable.h arch/arm64/include/asm/pgtable.h index 1d0f18d30e1e..61a674942a6b 100644 --- arch/arm64/include/asm/pgtable.h +++ arch/arm64/include/asm/pgtable.h @@ -156,8 +156,10 @@ static inline pteval_t __phys_to_pte_val(phys_addr_t phys) * not set) must return false. PROT_NONE mappings do not have the * PTE_VALID bit set. */ -#define pte_access_permitted(pte, write) \ +#define pte_access_permitted_no_overlay(pte, write) \ (((pte_val(pte) & (PTE_VALID | PTE_USER)) == (PTE_VALID | PTE_USER)) && (!(write) || pte_write(pte))) +#define pte_access_permitted(pte, write) \ + pte_access_permitted_no_overlay(pte, write) #define pmd_access_permitted(pmd, write) \ (pte_access_permitted(pmd_pte(pmd), (write))) #define pud_access_permitted(pud, write) \ @@ -373,10 +375,11 @@ static inline void __sync_cache_and_tags(pte_t pte, unsigned int nr_pages) /* * If the PTE would provide user space access to the tags associated * with it then ensure that the MTE tags are synchronised. Although - * pte_access_permitted() returns false for exec only mappings, they - * don't expose tags (instruction fetches don't check tags). + * pte_access_permitted_no_overlay() returns false for exec only + * mappings, they don't expose tags (instruction fetches don't check + * tags). */ - if (system_supports_mte() && pte_access_permitted(pte, false) && + if (system_supports_mte() && pte_access_permitted_no_overlay(pte, false) && !pte_special(pte) && pte_tagged(pte)) mte_sync_tags(pte, nr_pages); }