From patchwork Mon Oct 9 12:08:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13413508 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 53215E95A91 for ; Mon, 9 Oct 2023 12:11:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E15358D0062; Mon, 9 Oct 2023 08:11:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DC3E28D0031; Mon, 9 Oct 2023 08:11:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CD9DC8D0062; Mon, 9 Oct 2023 08:11:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id BDDD78D0031 for ; Mon, 9 Oct 2023 08:11:33 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 876E6140235 for ; Mon, 9 Oct 2023 12:11:33 +0000 (UTC) X-FDA: 81325808466.06.FF556A8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf06.hostedemail.com (Postfix) with ESMTP id F3B28180009 for ; Mon, 9 Oct 2023 12:11:30 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uW2YvwkT; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1696853491; 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=vC2JPAVWIYLn4Gtm6DpcKM6hN4sCG/C7Tc4DVCUhKHk=; b=zDx+IupneDq4+EVU86ufshhrtlSaKWEqmmzbkVuM1KFwT/mY6B6Tz3BVPjDxdzu1WaiMIf YA+NKmbmqDJ4+JjOOrF3vyQs3MfHwM4AjZaSGxlOiftiZik4X9M++LCqCxvXwLFnDUHGu/ 0Fjr32jz2RpXB3w7EK0dMnv+zpRaLRY= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uW2YvwkT; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1696853491; a=rsa-sha256; cv=none; b=hVi9JajOWvi6odVgedQE2ybJ0CZTHmPt4LQXr6cnLlGttZOUubotD5LYzp9O3SLZ0DDFTg /J0yjIS53mBNfcHTJOa7JVobVKxGJ1ekHMqJJztKpGAFp5CaOvyib1cB8Rna9u86plNI/G N2L/hucNCq7qQ/avycxwTP2GNnDgHPE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id E19A5CE1391; Mon, 9 Oct 2023 12:11:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC675C433CB; Mon, 9 Oct 2023 12:11:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696853485; bh=dnQiLWCQEIWy/Xq7xUVmoEvPZ7/L9XTfsPiddNnhH8A=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=uW2YvwkTEs3ksNnBeyCkmHvcg7Hg45MTQOrvX344Mz095Y2nBmnaK61KvKyW5feOb f+HQRctmZfEFAzdsuUP4ETQaCQOOmd0zQw8Z4ksCz6K9hEhCwCPfvutNq6j2WD6vmj 4pZr9m/47nVQFEVwotHX0Esp6jxSPTzu8BCaa0T9mYgV7uNgC2U8xiw1lhPXIW7knn ELoN/tObaoGVa+rdJP5Z5qYUZYF3VtUWJEpFVOSJFOS6A9HGzHFORbRPu9ErGrSjQC 8zpmiTl07f7AolAPvTFvKuOG/xJLeHqxbUiM5buTP5J+4fA3i09lEyQKTacVUD5oPS grZRCB+QM3npg== From: Mark Brown Date: Mon, 09 Oct 2023 13:08:41 +0100 Subject: [PATCH v6 07/38] arm64/sysreg: Add definitions for architected GCS caps MIME-Version: 1.0 Message-Id: <20231009-arm64-gcs-v6-7-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=1361; i=broonie@kernel.org; h=from:subject:message-id; bh=dnQiLWCQEIWy/Xq7xUVmoEvPZ7/L9XTfsPiddNnhH8A=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlI+2WHMOtW7oALvhLQJzuMUteJm/EdFfby1ez8IFL vZyYW8OJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZSPtlgAKCRAk1otyXVSH0CRDB/ 44i2mEo1C6AV0kBavJlNrHUoe01OCdzz/4EZVGIvfLNMche/CoZDy2oB/+y3rrHCMkeSEwFG4KcFyC VnY88Rj9OOm0uZVKN9lUzQ9Aboh+Bi3RgzyK8XcLr9nza0lytLsRy9LRhol8LKzq3qVAiv/79KB5mQ 6qpMbIMPk0FLn6qsC/iAjW/tbSgEmSfH00+X8llt831T8OpphOjxb8HdOOpRpV34JrA44UIyFWAtxX dkrGQX6Gpxd4DhjR16V1xYXaJiITXqvrJ1xhJf43u7igOOFiEW7N5vuix/L6mtmFwahxXcJFwM7/XT FmiKMyTaKx8MiwzpDMZjLMwG5iuqwL X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: F3B28180009 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: efjqos9z9yrkqz6ixi3keo5uyzwe9whq X-HE-Tag: 1696853490-419181 X-HE-Meta: U2FsdGVkX1/bLvAnqA8xLXCMgN3UARFQO3vcztZAfmBeZIbBwfHIKPacl/kaKa1S+c1vekLRKJawjsJswuYRPFFBH/ow5Dw6jmUuir3GNBToy+dRDBgCWwxB3Z4JqkfDWppp0EUZmEA9OCwNXHe83Fch6XXOg3S7x8BLPvmn6VodKMb44gkh3oUXKLBWcqNItY9Zgy++dVzWwAzsv+rzPGEZTIs1L1Gko67gQnOYkkYQGn3VM4iXkCGrYRapDd14EFyUKKl+03E4GMwbJRUn9+dGD5y5wivMUxZ1psmnyqpm2h96ekW03RHADKUu9AnFVPSgNZze2ZtpHxGzf7w0+44B26h3oiQEdOAoVd8tc/kombCHQSrM9EXQcFrt3aLhCup8xZiWWuPy5Sq7ZM4tDtW3WqaXnylnHWK20fLRFwW30q6t67CWnvKTtcUVD949LSyf3m+PCGhqpdCTNGE36LlQHqeNr2JFPJHwp6SKqJRmO17jG64rgZjqJUlMI4FqasrXhpYTdbNwmCtVkVzIAmvPEoNElIgWb95KXrc/OkDT+kmfRFaDB4V4deQVhfaaT4tgVz37u4hQwvZ/1buUscHLoU0P37zwhdFKTYb00C9vU+fd9geTetmE3I+COFjfA2Tmjkj0JFaoDD1vEsDGjzMpK4W0bs55F8CRmp3YXlpt6z/jwi2FllFW9LOkHnwP1bOOOWXOwbLZEzR3OPwm+AzVPhPePJL5rKno80N0ahBLxplvHj2qh0f89fj2p6+yzKrZQ8TS8Ob3Ra5hVN+WciRHxt6Dy3Gy2K+tTMINRa3B/NwkkXB1HqHVqfX+s6mcjhbVUJ2vHhjBX7VIwFb/3JlLDs2X/Dos1M1F3xt3lcbVI2PHwKeCX+cK/g2s2dRT0j7fOlLP/CRmvguEtbZIoRQanQrx6C4Tzz+rUt/TipV3fizKkRUQE08lva+KUMw5b4AqgYEeR7IroooQ+88 puMOq1f2 tTv73dCc0wbE2oA3ItFqkQSE5g6Hc6Hgs6ntrO+UyP7vGo+jIm7azYiFjmXCMfZCgxjoz960Z0AKR0W/IBH/dz29T0GU1uv4U3hNqtuQNOvvGzJwA3jX+kv3m58lj90rijAR/2MpoCjTnxJcUBcHsKOkjptTxhOG/PeOsGCUQfW6XIobe62VJyns6dgsd7aBtSlE1oL3juqRQugK0ZCtR/DbT554xMcLsPWKwNtk7brpaU0BQcV0Ah3njue5c5NRTknomqVqua3GFY9lCp8UOHbDeMjtGYin6tMc0zQrCsOVyaT6Gk2JwJD2B1I5U47IytOJ/dnt5GLFEWtE= 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: The architecture defines a format for guarded control stack caps, used to mark the top of an unused GCS in order to limit the potential for exploitation via stack switching. Add definitions associated with these. Signed-off-by: Mark Brown --- arch/arm64/include/asm/sysreg.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 38296579a4fd..6a550781d71e 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -994,6 +994,26 @@ #define PIRx_ELx_PERM(idx, perm) ((perm) << ((idx) * 4)) +/* + * Definitions for Guarded Control Stack + */ + +#define GCS_CAP_ADDR_MASK GENMASK(63, 12) +#define GCS_CAP_ADDR_SHIFT 12 +#define GCS_CAP_ADDR_WIDTH 52 +#define GCS_CAP_ADDR(x) FIELD_GET(GCS_CAP_ADDR_MASK, x) + +#define GCS_CAP_TOKEN_MASK GENMASK(11, 0) +#define GCS_CAP_TOKEN_SHIFT 0 +#define GCS_CAP_TOKEN_WIDTH 12 +#define GCS_CAP_TOKEN(x) FIELD_GET(GCS_CAP_TOKEN_MASK, x) + +#define GCS_CAP_VALID_TOKEN 0x1 +#define GCS_CAP_IN_PROGRESS_TOKEN 0x5 + +#define GCS_CAP(x) ((((unsigned long)x) & GCS_CAP_ADDR_MASK) | \ + GCS_CAP_VALID_TOKEN) + #define ARM64_FEATURE_FIELD_BITS 4 /* Defined for compatibility only, do not add new users. */