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: 196258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp992447dyc; Sat, 3 Feb 2024 04:32:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXhkS7XqJrP7h0mD74lvru53YgnsolRw5JJlYRteaNpWYU807BpJ3suxtiBi35MGV6xraj X-Received: by 2002:a17:90a:8a88:b0:290:4b14:3638 with SMTP id x8-20020a17090a8a8800b002904b143638mr1832094pjn.12.1706963559525; Sat, 03 Feb 2024 04:32:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706963559; cv=pass; d=google.com; s=arc-20160816; b=UiWw6IPi3ust4PLTnBCP5SAyPiQ43wkwqjh/mr9mv3WWaDfqLvwUWTbjCpu6U5gmSI +xAVXWkELtMmNoy8kBN1vJpaqr0g4/WI/24AGkLi1OSUppY30YWYOEsh2oaVHEUvxFA3 KjSeyi7M0/DNAcKAOOnrbcQdZJ6wcGm+lmrgsTw7PVPKWP5+rTLVOUP2CxV0b0LtTbFl DleAAkN9kCsbzGtsKptcNgKMeAWXmwRmDbGeQJjpz/3g972RkUfdkG/2uq6vdoPreEWm 1iW6kFnwugWxkw1/4Ot8ERVtFWLy8IOy2g7oNo0ioWeDBoHHIUIH8VJl0TvsRsgwRTWz c6ig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=DbuZEnfEz8N4esDWlO+EFArbZ8jBkVnMQyeK4BYbEVk=; fh=envw4cykSSWeOjxec0KiC3qsqE6mtH/iCTXTISDMkWM=; b=TiRCBG8JorXon3EhHfjQ9zmsOYq2mk84LWdwETjjorbeih7e18/3jKCTx0mnmBCbPJ cW21Yp3h1U8eQGdYIpKd6XKgIDXiuvYrNsWaUw74v0bS+l0cZ/YEY3pNGvjWMUURINxx q3xz4TYZvfM4BbyRtU7wPMfNZFcHhSz9xdpYtXUsA83yjS+ApzbMms+XGE7EeWImLd9W Vpn6EOYrfXxkDEPLKtzZuHqfMCyhSZ9b7QLrfomIiRzN53813Nb/ft3TQVc3MqoJkAE+ LezyvkEw/dqBiyrkPGX570UgzqHR7s8QYbHVJY12em2cIvg1xc6it1xWa3GNPBe8xxdU p58Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="C/gZ15/I"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51043-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51043-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org X-Forwarded-Encrypted: i=1; AJvYcCV+NQYHXO7vGzPVfko2ibncBDdc/8uIPjH6O+oPfIH4HF8kkbr8tF9NGMVlO0tJy4Lt/rm33FXmzsXokNEn8JlmPZkffw== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id r15-20020a17090a4dcf00b00295dc06ddb6si1489693pjl.129.2024.02.03.04.32.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Feb 2024 04:32:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51043-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="C/gZ15/I"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-51043-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51043-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 96FA8B2533C for ; Sat, 3 Feb 2024 12:31:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 268055EE81; Sat, 3 Feb 2024 12:27:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="C/gZ15/I" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B94C65D914; Sat, 3 Feb 2024 12:27:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706963227; cv=none; b=K+UgSfiMt8X6kmuEKt1AFYjjNQhw8/m9Mq7OXml0wx9ZTB0WwJe4Xog0ho+/0hVdQYg1iGqOmX6X1ikvcRNsYYqZIu0/kofly9ZoAIexT+8mYbFDUuKtEH7qukID6eFF7A1uXcL8zeJulTswtok8v+LlUJeLrFr0iOpEu+T0lzE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706963227; c=relaxed/simple; bh=pFAvrTvTUMO0xGKH/cMXrv1R9nlyUOOKoHgSKri2XFo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=PbyW/igHm6z7HoCHykrduUZOfxKbnG2ZlBmcIUK4awz5zAE8exDPAzuLoyxn5kwt0/6fJQQf3ed6qqHDvtN3nLGIrPaXOrUitT5sustCihQe6HHiSl2KxFEhCRwYDmWk4GZ45wxR+0/qUifcNZRsbXswXfhMGD6gybZkTODO+JU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=C/gZ15/I; arc=none smtp.client-ip=10.30.226.201 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789881021748186924 X-GMAIL-MSGID: 1789881021748186924 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)