From patchwork Fri May 3 13:01:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joey Gouly X-Patchwork-Id: 13652795 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 26BC9C4345F for ; Fri, 3 May 2024 13:02:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6007A6B00AC; Fri, 3 May 2024 09:02:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 589B46B00AD; Fri, 3 May 2024 09:02:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3B42C6B00AE; Fri, 3 May 2024 09:02:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 157C36B00AC for ; Fri, 3 May 2024 09:02:51 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C1FCDA10B4 for ; Fri, 3 May 2024 13:02:50 +0000 (UTC) X-FDA: 82077099300.24.8248220 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf16.hostedemail.com (Postfix) with ESMTP id 1966C18001A for ; Fri, 3 May 2024 13:02:48 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=none; spf=pass (imf16.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=1714741369; 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=UHZii1WwyPiQbM25MJuHnPX8X8jSD4FoCigkDlugWZU=; b=14u3DfU8scv0ZMXRv4CyeIfRJ3SEBoCCnctw3f/PEnFUHKtoq9itK13vAYyhYQ1Z5wVXun TlwofIDeRuj9rDPLq5t219xj3tgafcd6b2MLe29oLu/JAsOoKcv5vQn6gdaYiLcdS8BsTv /yv7OX4IIaLaszkOROp8Yd/poIHc7zw= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=none; spf=pass (imf16.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=1714741369; a=rsa-sha256; cv=none; b=b2sTDyLBRVrqPqaUVXzt6FsJW3yj9cBWlEJggvS4iosXKtuPDXCR2h5lJxoJwn1cQcYoBi oI3jckCvBhc576NVXbfWsYvinTYS7sRFaGF2JKsiPREztIkTeF38pFTey7yRwI3coCIvUn CNJbLyQHBLJttufHk3z1Fw3CREtynp4= 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 BE51016F3; Fri, 3 May 2024 06:03:13 -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 69B1E3F73F; Fri, 3 May 2024 06:02:45 -0700 (PDT) From: Joey Gouly To: linux-arm-kernel@lists.infradead.org Cc: akpm@linux-foundation.org, aneesh.kumar@kernel.org, aneesh.kumar@linux.ibm.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, szabolcs.nagy@arm.com, tglx@linutronix.de, will@kernel.org, x86@kernel.org, kvmarm@lists.linux.dev Subject: [PATCH v4 16/29] arm64: add pte_access_permitted_no_overlay() Date: Fri, 3 May 2024 14:01:34 +0100 Message-Id: <20240503130147.1154804-17-joey.gouly@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503130147.1154804-1-joey.gouly@arm.com> References: <20240503130147.1154804-1-joey.gouly@arm.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1966C18001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: r8pcczikomdh73aqezh3rakinkbpcjp4 X-HE-Tag: 1714741368-54459 X-HE-Meta: U2FsdGVkX1+iE5wVeb3FER3Hu/xUOKwXO7Gi2j3BrBsPSgc5647neJhbyHJFVf0EsWCMXkwRQfuFTwfN5vhB7ozOKKWhNsbisHPwfAkbNfIJl0R6foJXG+D9fhlpfWU9yPQd8vvLIkjcugsnl67KDKgHDLqilATBD2Zjbj2y0smzeHdSNfJ1f33uCNg5MWgIVtnfNK+zKKyFqlDHGOWMLyK2MZNcKX4dhCC4Mern0dvtPCMwKYgPOpmnPvMKQFno6aDi7WHK2SKMsVCYA0EOkc8wLjfcxduFr2Eg1F4iE46K/CiZlaR7GvmH+wzfrWw/FkwTl+NdOvzXBCbp/WQBRNlIyqNp1YtbWPmAZmNd2kmAGvKo9IxDw24rjcvtFwe4AMBTUiddHqnqZv1XZ4RhAqGhqjhArw5RGKgkSUIiY8dnr5iN0goMONju2dvN7ud9fcDRh1j50gLVoBl0wvkQ/si06P0/zB0y/ky/1YOWErSma++vaWUaBp//pb1JUz8HfIPkvejwfXkP0jhDLrGvTKWnhJSpdzxUDXNdhoHN5URuuW8QVj7DaL9AzwJYn4Ga3upzuJa9JDfUTbYTm9qVHBL5MuHPBXbZCv+ls5Oq4xWmsuXBJZyk31qXqVGAmhp7gsNAjmTvB5Dv2A5pLqUS3ffw2HqOX0FJeJi/Bc0l04Fim/YN++AUYVwXfGd7+xJgoiBhrM+qIgrwecdkxJFDVDysh++1Nf9gVlegxIWpnJF1y3RMBreyZKKG5HWAjILsgyvZMaJGZEPYicLL4oppU7x0YfeQquUBUI8/IxZhdykLLweodQTB/uBTboPPnSfpWD13/z2po3MGPTDw3UFVYkZ9w9Fr760RhtI2BjE/fvNWX3o3DYlBAM3CjSB6cyRNZjAXkxdV048254Euddk2BfUVR8yQy36DGNzW6IPSb8e8DMZNU5lG200D4WLKdr4ustbEwQC4E6dxQFJeFUg oo+Q/XaJ 4eVZRPM/GueHwK7CDR6eL5LxPhCUG6JzAEfhrr+dqwvPM8kV+R8vBoMxlfcYHrwGLjGscMUlmw1cnpHUqwjNvNIvXBjbcd4aNEEWZ+p/gQ2OW0AX5orlDLbicS/n8anHGn/8xzO0HTG5uwM+IGZVpKNoyr30X7g2H9Rb9TDs+2fdmBx9K0vMFs2fuFD6ynvu2WhVYhEeDKgwYbbJOUdDqn73ussKJ8yRVruCPgPIlVbqW/zpW8EyjRoVutdPVKdZhiZHhMKU8F255eE0= 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 a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h index 5c970a9cca67..2449e4e27ea6 100644 --- a/arch/arm64/include/asm/pgtable.h +++ b/arch/arm64/include/asm/pgtable.h @@ -160,8 +160,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) \ @@ -348,10 +350,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); }