From patchwork Tue Jun 25 14:57:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13711328 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 23A53C3064D for ; Tue, 25 Jun 2024 15:01:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A3B456B009A; Tue, 25 Jun 2024 11:01:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9EC4F6B009B; Tue, 25 Jun 2024 11:01:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 83E0C6B009C; Tue, 25 Jun 2024 11:01:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 654536B009A for ; Tue, 25 Jun 2024 11:01:39 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0D1F1C01B2 for ; Tue, 25 Jun 2024 15:01:38 +0000 (UTC) X-FDA: 82269725118.03.D091B7F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id ACAB11000E6 for ; Tue, 25 Jun 2024 15:01:25 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tBApK9Cr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719327675; a=rsa-sha256; cv=none; b=wL8i9p5OTR1lBqszCS+ossCc3BVE56wiXi3IdaBHcDWv/WOCMv0nWcPoEHUkBEqjfnt0RP pMh68QLCb760SRmvIPVm3iAjfIeTBelMwFW5QXxs2AYye1ZpandumqVJVAnVqYFRizzHqS TP6oVjpMOjfHSiZR4dhePdvoVKprUe8= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=tBApK9Cr; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf05.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 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=1719327675; 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=e/fF6j+GFZ/B1J+sTD7FTRUr5nN0gJgvjv0gndMoJSM=; b=iGaxz85ElzMPJxD9eVeze8pPZAtlAZZVKavCYziJLcwC/NG4fNIhNyfk7UXuiVsUXLYTja 1tA5u5KJ9LVxWbqUBkxYnrq85zcnL3JcDrXw71fT4D6LrPhvnJjY9gD6JTEyukaXdok/kq i/03+poUbkjw7CHeu3dJxkLTxnSQYUE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6708661463; Tue, 25 Jun 2024 15:01:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9A0C7C4AF0C; Tue, 25 Jun 2024 15:01:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1719327684; bh=OtVuYnhHZ3Ff9iifqi0z8zMYVHFXjow5mOcREWek5jw=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tBApK9CrubSeAIcZz7A44caQcV2AMjXOrBWKOAQ3YTROjS6A3B4P8v4DYUloTh3iu L2JunxfQe6hZaIBlEPk9nSW/4o4pQZmJ/DFcV3ws0UAQ2v71qgRnh8O5ROxwbkVS2u Od4fFEhLHznvAgb0qV5QQr4wYTOrgQxeo8iT/UyiHXH2mwQ2Gv2eBlAo0sUKyHa2/H EpnCO7nOAwCEH3PE/YoT1josQRX1DA+TcpWW/DUzAO+2gk4RVwbzuTXJNrK+uZkuae 1NtJZFXhf4RCRNResyygODc36rxxsXvch8b78J0So8bQnWcrBWUvDry124M1g2R/jY 7LKsbul7AtnxA== From: Mark Brown Date: Tue, 25 Jun 2024 15:57:34 +0100 Subject: [PATCH v9 06/39] arm64/sysreg: Add definitions for architected GCS caps MIME-Version: 1.0 Message-Id: <20240625-arm64-gcs-v9-6-0f634469b8f0@kernel.org> References: <20240625-arm64-gcs-v9-0-0f634469b8f0@kernel.org> In-Reply-To: <20240625-arm64-gcs-v9-0-0f634469b8f0@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 , Shuah Khan , "Rick P. Edgecombe" , Deepak Gupta , Ard Biesheuvel , Szabolcs Nagy , Kees Cook Cc: "H.J. Lu" , Paul Walmsley , Palmer Dabbelt , Albert Ou , Florian Weimer , Christian Brauner , Thiago Jung Bauermann , Ross Burton , 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.14-dev-d4707 X-Developer-Signature: v=1; a=openpgp-sha256; l=1421; i=broonie@kernel.org; h=from:subject:message-id; bh=OtVuYnhHZ3Ff9iifqi0z8zMYVHFXjow5mOcREWek5jw=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmett2xSPtaVh5MhskCkWC9d+Vs/ZeudvczR6T8fnM pi3EiCKJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZnrbdgAKCRAk1otyXVSH0A6RB/ 9c9lgKwWs8KNFn8y602zbLtUWWDwRky5DJm0wa9ndVkr99Np3G6Sgp0kjHCrAME1Jhs3loF7ZRybJP cE8qjsWIDeZ5xnO1Xyk9fkQnHnEnm+mx6iD3x4MjqpDs+Llqis9IJMXZUXdHhR+S5XUJHaNOUmE9d4 OVBHUXg7rMVfhK+/LBd9eQgwyt+T37LYbSEJE4mDUJL25MGhqGZ/C7KVwXwFLuAD9Ego1WlN6c1Jux E69W8dgNbYY5tptjL9vw8zgrp+QLEHvMwCxgPYkTzlK49PHBow+u8sN1eOjKFNvIYEKwHwcmDTHJWI ofycDRnMbkf8lWLsyocl3/o+4LmsPY X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: ACAB11000E6 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: t54hm6z7mxxis6rsco6pn6zzggyuer7g X-HE-Tag: 1719327684-452035 X-HE-Meta: U2FsdGVkX18NY676vkQNvgoBfJJNK80nHIfT4mhoqKtJboA1u6s6GwTo1xR4ivskB6exOGEO4UOtmoOE93mHSL7SQOcnMp1d7IwFsfBCS1NWEaowOmWCK/gMqW10Ap1WZKQ2q9CHyw9HoJA0PSC/zvpHEzXKKH79elbYIyxqsfq6XNbmImcRieUDz3Dm1gFcMFUFdVXsKdsUQUZTJz9F/RniYJbCOwitCTPaYt11fOriCoJuvtV5H7GJudtJSD6du8lw4svqsI/rfYlochabmpX7gu8rRvicZljm6xLVL05KuSalP4rWbpSBRJLMijB8RUzg9ut7f24/efntT9I+eGRQMxn+alkLozaY+f8AExnvImDil/jnl+OT4xsadMucakciHBPvvD0t5BQuhUpCznJeB25P29zMToqW53NP1HTNIUBpYjvcn/2leyYysc4Z9OVkJwGoRBcBc5xcXXNaKvBRqEohpJ3UUzfh3H84G+q9AvkW1RwGvT5S40S0FNOq8GmN6am7l1l6/woOSGQhwuwRCUmPXgrySNJEcts/9PU0d5Z5Rch2VjbufEkIhj5F/UGCkWnX8qbe8cJyvPLLQhH3YyVHOdbBlzOySif4sZikP6xpNU8buHpFIFMYGWR1/KR2KwNVpfrdo/aK8q7vEkxnjw2+zwQ7YXoiYS92mMM2pat1NPg/y77gDaBH8ZL6SayKpK4MnzxjImYqgTS6PhdDJ7/DmLKhS68+4FgPemJYPjYBBUADjs+Glf7wIcYRselq4d30Hmh3vSC5vaH80ZwpzRO8jQ/7X+tn5hWj/OPUZiOr9qHcbBBdqK9N1LNmDseAi2RquJdlxQWAfQLqBAUCvF89XvALy9zfUAfDDGe0b8TspNr5YwUlDTWNFNwp+6RuHq2Zu91hksEAigvXmKJu+uv3ZAFIctaBuTxOe3qt94OpvvNzKtHQuDLtUomzlgASDGDhvpQolnQj02V I0lDBDmJ xwjzaWDhFQ0XWFmUjDMQ/lxZaH25JbETgTG0nqJSJvICFH+YwZzZGnyIJsfGb4HwNz6exsWswM4pqKkWD+W790dTbn1eyM6R/FR2lv1inup7bHXv86baleDpkPJpdpNVnODgXeRLVbjN3O7jCG1Ccrei1mKk4OcDBVkgcpp663jz5POS0lyIv42NgnoSg8izSSSox3K7Kc66DhmT608hBFdDIlD7L0Bze11RVJL6EJGPo7bb3fhhTxTGRNW3YHcg0VGdaU0GFwrHHtWsja3hnmqMHdwTzoYLv9QM2olAIZUo8TtNcnHi8bkOjOBhK9P9RSl0kj6iV2Xjte0OZYGCdtfX6y78OuiCLLWbFD7ZNBam2ucAU/JP6vgN1zZMaw1Sfxu7o 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: 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. Reviewed-by: Thiago Jung Bauermann 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 af3b206fa423..325a1daa98ed 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -1064,6 +1064,26 @@ #define POE_RXW UL(0x7) #define POE_MASK UL(0xf) +/* + * 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. */