From patchwork Wed Nov 22 09:42:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13464395 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 56345C61D9C for ; Wed, 22 Nov 2023 09:43:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E78726B058C; Wed, 22 Nov 2023 04:43:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E28616B058D; Wed, 22 Nov 2023 04:43:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF19B6B058E; Wed, 22 Nov 2023 04:43:04 -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 C05496B058C for ; Wed, 22 Nov 2023 04:43:04 -0500 (EST) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9B8F7A0492 for ; Wed, 22 Nov 2023 09:43:04 +0000 (UTC) X-FDA: 81485101488.07.25711E8 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf17.hostedemail.com (Postfix) with ESMTP id AC06B4000B for ; Wed, 22 Nov 2023 09:43:02 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q2GNnt1V; spf=pass (imf17.hostedemail.com: domain of broonie@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700646182; 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=0md5lKSrfFF/+d67+dSWGz9Xqa/Mx3egB9cc5ypcmdw=; b=bALhfbDYdUUmBSet15HG4LTn90gRAyEKoflYdyM3sg6DY4qeCsGkOopNH9kROK6anWMEMf E+dfjXRk+RUmLkTOhoy30TLFet4LeGtbwrb+IBuUrAIMW0KLVS05qjnRBwaiEBI3fa7Swq vNTNStueOWjDXAwalhM+T3GAW1IJ1yA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q2GNnt1V; spf=pass (imf17.hostedemail.com: domain of broonie@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700646182; a=rsa-sha256; cv=none; b=SzoiBnXkqBRudGENsuhZ2KFx1fc/Smvvcel+qfCRMEsZ2OVjZA06RZsuQBOzI/A9mGAGV7 BSDiD7miYQakRMmVG7EMB5iqGMJHrNbRSHT9uRcw6m2FjnOdl6mjn8aOiHmYJk8ZEG4tnG buuXu/S2Agu2+0b6xnzb5hrdUqUu40I= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 8085CB8091E; Wed, 22 Nov 2023 09:43:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 141ADC433C7; Wed, 22 Nov 2023 09:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700646179; bh=LBKDiUG7NBwWsYEeStbCS35c5iJdRmlcOY1N9hBogGM=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=q2GNnt1Vg0QJQRjesae4sFYhYpcYrw8xuFx8kU7s+OytKR4wzd1yCHi8+32jxqUC1 AWXRxXmwzXvoYtmicILUtYBc+WxAtCvvhpW99BVlem8s8EkD4oOaigl455Hy4ZYMx3 iZ58lbARbqthj3Fz/zCsx8LDPev0F8etIRFBxbkiJ/7XbkI11XtDhT+FZCdf/Y/fS8 JPsY05zr1HGkfkKAUW1l44mtjfkf1MS4IEFL6TYiUmj3frTdbz5owGw53mqr56wpEY ia86O0YKKUQGxM+0JZoc3SjjbemxCBARirVY0+Wq88KNiqBT29fwGRPlkuuiA9heEW AQSiIbLnkjP/Q== From: Mark Brown Date: Wed, 22 Nov 2023 09:42:11 +0000 Subject: [PATCH v7 01/39] arm64/mm: Restructure arch_validate_flags() for extensibility MIME-Version: 1.0 Message-Id: <20231122-arm64-gcs-v7-1-201c483bd775@kernel.org> References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> In-Reply-To: <20231122-arm64-gcs-v7-0-201c483bd775@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-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1303; i=broonie@kernel.org; h=from:subject:message-id; bh=LBKDiUG7NBwWsYEeStbCS35c5iJdRmlcOY1N9hBogGM=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlXcz3ufb4BdT3G27Wye1QtqLYalH9gsoNYB6OX 7EyWk64VmOJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZV3M9wAKCRAk1otyXVSH 0HxEB/9DTjmmFbNFvHu6r1ymZm8lbbHpqTlnIGPujl+4mFYJWSjhEaVe181wljq4nhtxPsm0u3a dtx7lvzR0Vo0RuGiNEprMGOGHjwlvyFifKfYoG4Hx4DMRzjmHYt9ADFh8JeBcEB7b6VU+8Q54LP choSLtIxGB9bEyLaaFCHrXHn4bsHJebYUBC4hxEk6shMvhPPnKS5YH4sDQVR8xrEqqwA/0e0Nzc 5tg52h+rCta72nz4wUxtrmsCeWCqAeEWxTWayPeXLN4EyGQuAeIcLmLfXs+iQZGDJHimnFgJB+Q IZrJy/B0h5hSoxkO3lXClEw8RP6mm5v2VaonL/9R49GDeD3t X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: AC06B4000B X-Rspam-User: X-Stat-Signature: pxz3pzqg5urrrdkjfmfd3ny8m3tyz6us X-Rspamd-Server: rspam01 X-HE-Tag: 1700646182-988372 X-HE-Meta: U2FsdGVkX1+UWBfhi6/illhGiRaMrWk6uGBnnrWMVw8cV7wcBmptUyweIOFgeeVmgfALmONMSWrL9gV08ayj2D+aUmcyitcRKb0VeEV2riJK7tbewGeocApin/40mfQ066pf8jWskI965fYTp+s0DkeYnWSGfENGl32MsZzP824LLcXyikagV79cwKq+XfCttrFKrLYvJMqBKj/fNeWHPs53Tr2hhOm0f9OCmYr+nIrw1z2e5NazYugW8DOL/p1BOEyPDYoaPcDZcj4aslUF9nocBQTbCMz4LjJH+OmDbqmxPMO6qYLl5RLP/KOZP8krWwExEoGNAkcLEhU7ixqfKEGrdPSRJirB6eBFKyyexcGx4khaNgzocPBd/w4K1ChYJm5VcdUBFbwi8GjdyLjjFwzkINGW6DBRAohpqUViVYddSx1+sVEBImE/qwjdP1SZMyNJB6A5eXg/aT8fxujKkKMSXkZ6VO+4Af389h+Puqyzp79dVyWkIil2MzKe3ihy5R8f3gF1Nx1OK46MH+48GhPKDah47fYWU8VSJz05eDkhW3622PmrCJAB+V/PT5pLxr/vh7O0v8sq7RGEFE8n+l5Lrlb+xEjSIv6xPgTLODAqyoLWjVpsFscn0qUqWmQSqOklzxQ+DY6dOfnlc28/+N/pVLVbY9ZHZ5Nl4wtpDVC3I0rDZ1TJcbdJ7MRo/KSoCt4oZrm5GeojpyVcWbfUz5cw7/E0+nBQI29Wbm9UgizIjOjCQG5q9o1Xeh7KnbaCtvg6xHIkKB2T+qm/PG1PJ1U3vggLZwav6+OVurZS2iU0XUMDhTbqE5AeWRHKF98+xwHpayiXl4dF8WCvi/Qr1gX3Y/eUF5PU/4XhZ2ZJjxavD4aHErI0AIH5Jg9Xm9K/ApkcF6auu0e1qnrmYJYm6cNk17isEfirxegvZJ3+LHAk+8X7WFPlNgouAJ9zCvCtZ3dJPk2vzB1Y/jWenLa M72TAFTP p6gI6xIyupV187A5fWWddaC+PvMblXs/J5nIWJRGBkh1bxrYPCBBX7ODOiuduJebXRb5e5a9ZRvFwzlMRrbWnwDsxwbUT6Itx6hJzOME/3yY3QpmbIh+aPZ9Nl8BCOGyUe/t2o3vj1cD+j/wknhECzsFIUulpt5zWa2Rl5PvOEdqoyanEYQ+4kq4Bteh+CYc06CSyL46W85/NEikFdFUYL/Nd21JH0k7fxlz8IXT9CdGEQgnDs3m65Wjhdw5Kw0Gpn3romZvlZKFXvh1IalkqDaVZpseZ3fHAlwNOxRprqnzvlbKnZJR69GAqZ2wRAG4MwYOrh52o6ivArwkhguyg8LWSjsnh7Mklrzxfek/iSJamNk4= 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)