From patchwork Mon Jul 31 13:43:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13334668 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 2D184C001DF for ; Mon, 31 Jul 2023 13:51:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DEA7280045; Mon, 31 Jul 2023 09:51:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 98EEB280023; Mon, 31 Jul 2023 09:51:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85730280045; Mon, 31 Jul 2023 09:51:25 -0400 (EDT) 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 73A10280023 for ; Mon, 31 Jul 2023 09:51:25 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 3E5E51C97A1 for ; Mon, 31 Jul 2023 13:51:25 +0000 (UTC) X-FDA: 81072044130.11.978F0EC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id 2E276160029 for ; Mon, 31 Jul 2023 13:51:22 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lsLOZTpH; spf=pass (imf08.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 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=1690811483; 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=f1Fjfwmv9c20XNlM3MrDH4yBU8vPb3KKbDiNXIhVRLM=; b=iF4cSgbjUy9re61CDjqRZQY2pzsx08ubVK0TqmFOZJK0AAvWPsJCXbmHvIxXRDp1ggo8Oo ap2t/QcMesrmriI2+S6UPB91NkO/fiAOAdfPfHIJA9/hmpOerA+WgkwDrmNy8pntDF200E uId2NpFHOBY7Vx8ScOoIqvDxtL6r7po= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690811483; a=rsa-sha256; cv=none; b=SNZ+/wjOCpQ8BO6LUF6fQIzmijzQ7LVumtkCPHzyp3hkdemkN2S1jTqStG1Px6fpy6wAYo UaGKF/0kUcColB54vPOS3fAI84nCvc01/9EukO2larrVVc1ZWbZw4Gt7Y9Uf+tY/GbTw/m /HWXVXKksbwzFdms9XcZK1/kq7wfG90= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lsLOZTpH; spf=pass (imf08.hostedemail.com: domain of broonie@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=broonie@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 16B1661161; Mon, 31 Jul 2023 13:51:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 840A0C433AD; Mon, 31 Jul 2023 13:51:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690811481; bh=k6DV13RSkbr/e436II0jx5LmEFZf9bksk2EmOe6Nllo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=lsLOZTpH+8SBzUiTw8HV48Qa5qh/ezBf0ELFVjs56JxaXGKdr28bJDtnWAX9B6Rvi 43U2G8PKboTs+GpKVHPPT/xl5ps1RR0DK4QNrokPeFaLkdB7LhOETYnUDBdVSUjWhf FZs+Z42/+MfsQpFy8B6gKx2wIBq8a7kZrZ2SnMiHQrzrRlxPR+CeA8Qc/BsG9+Q2Qg sS7D7wUVktidOErGrA5ZXAArW8pFw13I1ckiFdbYuJQmY7mUGxom54J7+UpZacVIQn xVQ0V/kkjKlxMd++2UhxCCU4SngpxJXMFuSKr0EjY9cApGzjwW6bY96nFxmk4hklvz 3Lh+i0j/k4tIg== From: Mark Brown Date: Mon, 31 Jul 2023 14:43:14 +0100 Subject: [PATCH v3 05/36] arm64/sysreg: Add definitions for architected GCS caps MIME-Version: 1.0 Message-Id: <20230731-arm64-gcs-v3-5-cddf9f980d98@kernel.org> References: <20230731-arm64-gcs-v3-0-cddf9f980d98@kernel.org> In-Reply-To: <20230731-arm64-gcs-v3-0-cddf9f980d98@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 , 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-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1361; i=broonie@kernel.org; h=from:subject:message-id; bh=k6DV13RSkbr/e436II0jx5LmEFZf9bksk2EmOe6Nllo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBkx7wYerkhf4DlFAJ/h/2aEAXpsdOEqzt5SXJT0kfw k6t2uxmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZMe8GAAKCRAk1otyXVSH0H3eB/ 9FmcAX8XCOxGc6hnHhT+sSmRPLoo1VTaogIvPtvK109vuA3Mi4J7e8OR+wew7LNQZCFspKHyuNLS1R rTq1rCgZ8dABBitJKtqFOHBtIdqxYmLBkOOqiY8nwYU3Frl93OmnVpWlrGeaOv6l6UbgvC4MPs6JjT syfR9EcDbaezL43OCpXQoboq9SS9f3RhuETCMJ9NfdoSCJFFBxaQPHlGqissKqyIRYb5MpxBFQ24RV LH0PuwjDxl9bn0v9vRJi2DQuQYHV3uIbB+A87DHUWiYxp8MaJ4N+MMzcsHPfCm9ui5QQ6g/6hnGnN+ 23e2StffnVm67pHbOPI0IL4pC+i5+v X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: 2E276160029 X-Rspam-User: X-Stat-Signature: 3wbtc33944ps5gym4dh1o1eeo7nyeobt X-Rspamd-Server: rspam03 X-HE-Tag: 1690811482-241001 X-HE-Meta: U2FsdGVkX1/tSnPDg1gouxZgF9GhMQxf34Z9UCY5xJrmpwurUVb4Ve5OC4Pi1EhT8Lr7g932jXh5lSDer2u8TkU1wENHk6jJwuu5VoZHaV+nUTxxcQxC5t6VxGuyCN+Tm3Fb1nWFC7QJ6JFROY7pzOUtzLw2urVG89cO0o4tlA76YXaajnYcmBA6W4rNiXIPgdh2KmyBuBBnbu/kELZZLDLeDc1cHZi4hg/xqaTL7I9skI6wCqgcFvMDm9Bp5/CI07MtahUH5AaEIdVgkDiiSOJ/zNF4Tk/n4ctlSOY2msh1wfk1MmBhlgcIqC6XIEs2KWqxd8IW/DzKGlc7txU+18XPzeadxKkmMOhMb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amicity=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 b481935e9314..3d7f9b25b8fb 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -730,6 +730,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. */