From patchwork Mon Oct 9 12:08:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13413483 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A1563E95A9A for ; Mon, 9 Oct 2023 12:11:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346524AbjJIMLA (ORCPT ); Mon, 9 Oct 2023 08:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346496AbjJIMK6 (ORCPT ); Mon, 9 Oct 2023 08:10:58 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A0A1F7; Mon, 9 Oct 2023 05:10:45 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E26B1C43395; Mon, 9 Oct 2023 12:10:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696853445; bh=pFAvrTvTUMO0xGKH/cMXrv1R9nlyUOOKoHgSKri2XFo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Wvv+8fQiJLsDyPC0NnM1Q8ZyuLIaTwYxmV4/n6iYyTSFm2c3s/lXYiIujtfqegWR5 i+6r97yeEFEr4SuiSg43kWLmH09n7ZR/ZCXoWJasjIzJx+djDmQqsidBxXjLgKIpdW USEzih2i0SA+mKWoVY+bWCbYYsuCJH+HUplm5UojKv0lL6UF4DGA5SDT+CacuA1WA4 oSm8tkPSZp0qife0Ths/W9nGm12sWcn2q+T/WK1q5JrOai/DPDX9Umpa7nqzfrVypG J6NVP/nkQzGEuN9PqjtaHLmak3br43uZpGnq2WynrJw6MMDSVcTWuk4mRX6DuUaqiF +7pCIfTCF7+SA== From: Mark Brown Date: Mon, 09 Oct 2023 13:08:35 +0100 Subject: [PATCH v6 01/38] arm64/mm: Restructure arch_validate_flags() for extensibility MIME-Version: 1.0 Message-Id: <20231009-arm64-gcs-v6-1-78e55deaa4dd@kernel.org> References: <20231009-arm64-gcs-v6-0-78e55deaa4dd@kernel.org> In-Reply-To: <20231009-arm64-gcs-v6-0-78e55deaa4dd@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 , 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=pFAvrTvTUMO0xGKH/cMXrv1R9nlyUOOKoHgSKri2XFo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlI+2RRGngkj18F3uCpZZfRd1ocU0q8HRquWAvC/i8 MLyCK6+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZSPtkQAKCRAk1otyXVSH0IgWB/ 9nEEL548GJxcwR1LGdSjepOH5kHepxay1tzf82bn7l9zh6fQGxR6ix+aOPOcIC0mVUG3uBo/OqUafc JHsz6EEkKKkT+8LEz51beTFl4qVhh1Ow5Rk0OEWXlvnnu8ZQObqqFwMY0PNRfSmOtzpFrAOF+7cpg3 Sj0Yycn8U5ODSu3bIWtjprRbW0HeaYkWpU1J/rMGOVpT+VVlXY/Tac108UyzCQmmIro7sCHuaLNBpW UxSMVsEAelZ5K94QPG020QQcQvtmVVBOG1zhZOUIWPgeZ9WuB8xrR237xwNy7kMbaxY9AWSb7Jaazz bt/kuflV6ao5nlq/P4VKE/AulNOgZm X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org 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)