From patchwork Sat Feb 3 12:25:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13544148 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 AF2ECC4828D for ; Sat, 3 Feb 2024 12:32:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B66256B00AD; Sat, 3 Feb 2024 07:32:13 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AFBEA6B00AE; Sat, 3 Feb 2024 07:32:13 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 82D106B00B0; Sat, 3 Feb 2024 07:32:13 -0500 (EST) 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 6828D6B00AE for ; Sat, 3 Feb 2024 07:32:13 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 394971407E3 for ; Sat, 3 Feb 2024 12:32:13 +0000 (UTC) X-FDA: 81750430146.24.51EFD37 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id E9A85160015 for ; Sat, 3 Feb 2024 12:32:10 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="C/gZ15/I"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1706963531; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DbuZEnfEz8N4esDWlO+EFArbZ8jBkVnMQyeK4BYbEVk=; b=dI2YRv3OD2w8neLnqGpMr9pCWIDZD7fJwOoQWmRKIBAahNKtSc79Xm9Ic/5pr76ijgXLWw 6QeQ0Aca9hOfeRR7/kffFe7komAW8KpYsyXXAQ1aE/YZHFpbvNc/rNYpeo6378H6E8fY+E pBgmmLt+onLNZh0/wAexfatok+dL4K0= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="C/gZ15/I"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of broonie@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1706963531; a=rsa-sha256; cv=none; b=aAPAhc5bu50YRM2ShOJnazbr0WBzv7nEfBnCaZJ2RMNoFdWLUcB/KjMvQsjhij18WFLpsB +eFMEQL1jFGpTGYw3VkEJcjgh/5zkz6owBoyboGausA8YlXQ6x6z/uAsVTSlynhk/LasCC xHmuBMJhxnC7OT4/CELuVWinc+fbOA8= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B4EB5CE1F10; Sat, 3 Feb 2024 12:27:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 06800C433F1; Sat, 3 Feb 2024 12:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706963225; bh=pFAvrTvTUMO0xGKH/cMXrv1R9nlyUOOKoHgSKri2XFo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=C/gZ15/Ih7YAjtmLdHR/TtvRO+E/8UJIq9lmPTUvseNjdRw+s/0VC3c8URiH6Nbmx 5VUZhGl3pA1i6VI+ObcmVcAwxp/GorH94ALCXaIJHgg3PGT/wLzihdncGDlOR5tJak 4M9B7NVXSmdX/cqc/hLdE43xQ2poQNoEbnSy5k2IDMDbZx6jtvF224lDFrHpZo9nla 2tCEW1yrzfYUs0pUcW5taI+xnzeUZMGnvQ1IZIN//VN+Nnha+a9WZc8fa+0FwlKh1x l9htZ7I8HwV9mWsnCWI/GhhzsAoNusqgcHBVJOzXa7+vmdeoI98LlvML84DcXXcrKs HJQXs31uFwAAQ== From: Mark Brown Date: Sat, 03 Feb 2024 12:25:27 +0000 Subject: [PATCH v8 01/38] arm64/mm: Restructure arch_validate_flags() for extensibility MIME-Version: 1.0 Message-Id: <20240203-arm64-gcs-v8-1-c9fec77673ef@kernel.org> References: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> In-Reply-To: <20240203-arm64-gcs-v8-0-c9fec77673ef@kernel.org> To: Catalin Marinas , Will Deacon , Jonathan Corbet , Andrew Morton , Marc Zyngier , Oliver Upton , James Morse , Suzuki K Poulose , Arnd Bergmann , Oleg Nesterov , Eric Biederman , Kees Cook , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, kvmarm@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Brown X-Mailer: b4 0.13-dev-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=1303; i=broonie@kernel.org; h=from:subject:message-id; bh=pFAvrTvTUMO0xGKH/cMXrv1R9nlyUOOKoHgSKri2XFo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlvjDRUU8pHKDrpqmD8Z5/cQPWcT2fxI/PTb43xILE 3klUGLuJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZb4w0QAKCRAk1otyXVSH0ILuCA CCaSAWHZ2GgIQmRN8CmYFqqP3TAAMCqBy0U8CCN9L9hh2nWPnKUBPuzE6mZMeadLSL/HQ1G4LHuG0x 6OMIPqSfSx2wXoguzb8jtTGGQoLKWUT7dsVMq5iVJxUx1BB4yL1EYKRR9o3XdciRZaC7oU3y4jQuQl wI4JBRvGqQAIVk6X4V19TKXJBDc+acfsTQK2r4Bc4dtVrYqEyijuhBVKUvyEpec9c97DRYA+gyOdda ELM5NGe4shdaggm7TEMjjzbSsUBBc5c5bx2wu+SouBMKV/1Jiq4WYAdo8eW469DQ0awge1JhDylMyX jVKn98vbXMa7Xs3VGJ4pR7EQH6Tu24 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: E9A85160015 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: uxieb3wjgbdtodcnn5gzbijrig7yitbc X-HE-Tag: 1706963530-311660 X-HE-Meta: U2FsdGVkX18lv2IjdjourGQ53YuWsGlq31qX7wwqXAvwrqZYAis9QbOLTM/XLDFt7NaAqgCnU/0Qu5jqKhyCPBu0Gj8TRGKs4NkjSHNAUomiWohRC1QR9W8eZqwXtnoE6irFNAT9rrGL/61l5SGpBCVGyLhsPPPeYLNA4d2+rbXoMsPIebNGVEuM25gPR+roCLJzgKeVI4II6FArvF7brIyzuIZpPaNgiFsFgkVLIxWFkt0uozvimbL+vwQgEK9EcwQWopigVLjHkZooI8HbOntbl/7dma3J4pgRsQCE04bYcMgzQ9XouabqgeaAHckTG/iUvBfjbAucxUGxySfuH1YeZE5GtWS5XMPdw/uu5sUz3eeMBlNNApZP6SbGtGvjWkdmdVN8hI139CMC9bzt8lm8iWuPQ+gfqcvDWeNFdAq47Vnnn6MD5osAUKYtb2AVneL2r6oL7JzYjVpJaLdvzha6kplVr+1xSJGn9awwYn4V19waBWG/6XNF2g6qIsftnhS34nXkGEnIxD+SNa5AbmBMpTtRrK3T4xYAToHn13z1cKa29cg/L7rvvIjQpUn6zCAL2WKj39A4Y3sFZIHRo4pAdhpLPRbFyPYX+RTz3MjlfQ67wkVg2NiyAl1k6WY9j2lXur3MuJFroit5JJXbXme8YGCEvvvrfCOtrPGIaOYgJNunl4LNGuo/xwEW8p9gAXB94vDBbgOtERSWMCNQW2zrRssybz8HzMuwMW89+2DGfcdcrUsft3AUaGIJu6TtmEj/zaaqlHdu5qMIbbhwg9LRke5/XKOwxYxMGmcXVKWx1O4blorrpCdLKlzn69HxleUDyCvdyynOq6tOOh1mjJcKBgJcx9zAXVnkOgrafBZGwhmAy5ZKcOgqhOaxwGNrRsHGuFxrtP2gcSbOoLFhyZMvnjnc8mJW3EuSEQegluia6DJ294QHkLmvoqSv2RjN60wI5cT4LrvwSof9/mG MuSq80a+ FvTZTe3pjaiRTFwehTa/du6csKrIUPfGfAqtj 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: Currently arch_validate_flags() is written in a very non-extensible fashion, returning immediately if MTE is not supported and writing the MTE check as a direct return. Since we will want to add more checks for GCS refactor the existing code to be more extensible, no functional change intended. Signed-off-by: Mark Brown --- arch/arm64/include/asm/mman.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/mman.h b/arch/arm64/include/asm/mman.h index 5966ee4a6154..c21849ffdd88 100644 --- a/arch/arm64/include/asm/mman.h +++ b/arch/arm64/include/asm/mman.h @@ -52,11 +52,17 @@ static inline bool arch_validate_prot(unsigned long prot, static inline bool arch_validate_flags(unsigned long vm_flags) { - if (!system_supports_mte()) - return true; + if (system_supports_mte()) { + /* + * only allow VM_MTE if VM_MTE_ALLOWED has been set + * previously + */ + if ((vm_flags & VM_MTE) && !(vm_flags & VM_MTE_ALLOWED)) + return false; + } + + return true; - /* only allow VM_MTE if VM_MTE_ALLOWED has been set previously */ - return !(vm_flags & VM_MTE) || (vm_flags & VM_MTE_ALLOWED); } #define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags)