From patchwork Tue Aug 22 13:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13360856 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 7828BEE4993 for ; Tue, 22 Aug 2023 14:03:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 14402280015; Tue, 22 Aug 2023 10:03:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F562900011; Tue, 22 Aug 2023 10:03:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ED85F280015; Tue, 22 Aug 2023 10:03:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D8F40900011 for ; Tue, 22 Aug 2023 10:03:43 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B602D160376 for ; Tue, 22 Aug 2023 14:03:43 +0000 (UTC) X-FDA: 81151908726.21.E07812B Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf30.hostedemail.com (Postfix) with ESMTP id BDD368001E for ; Tue, 22 Aug 2023 14:03:41 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="MmfJzI/a"; spf=pass (imf30.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=1692713021; 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=vxDDpW7ZAMXtRujil1XxAhj8V5DwidAGLtVi6NTEOoOgYt4JFiT7azBVqNGhrvf0a18GKi zXj7bQEuvowQxL6fNczSYp/sbNr9PruEz+a6P2MUdI8WXswfKrxHsZ8HAHQHLUdxa4OsDZ kzuhuWOjpcJ6aGuvKkubmaT5/jQN+6M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1692713021; a=rsa-sha256; cv=none; b=bWFVYE8OMrO3Cwx4aTVTrswy4IiuxOA1BhCIsWOMlanZhNK4+deNVO9g2zrToMD7cK5aMu Vfx8y39nVhKVgxTX0gwS/MXPfUmw0zDjppnpfQc2DzkQCQXOpNNB3boFp/oBJiZLcs31BI qso41deoTg5ttjFamtw6eAVzxI3ra5M= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="MmfJzI/a"; spf=pass (imf30.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 001AA65772; Tue, 22 Aug 2023 14:03:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 62D45C433C9; Tue, 22 Aug 2023 14:03:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1692713020; bh=k6DV13RSkbr/e436II0jx5LmEFZf9bksk2EmOe6Nllo=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=MmfJzI/at4bw9DCmBSmMuMKkWI2tgIZTavr5wz82wQsjtwr7Jt5jpyTX/Y2SFcQFW cQqkm1lkDJL3ZyPAfRt17vTwmyIlgyi1yKrzkp71EYfjh3KTAqqsQf20c+ZpXsWJb+ SUUeKOKPs8IQzC+88PTilBvGcRGj9H5MmjeGMRZ3UzVL2bsupFq13Bc6d10mTfwwIC IfE04Rpc8O9FJczByP4+UwG77QTRebifYUe0Tkv3GHq5Lg8DCt/KHS0dZC3bXbNotY 7SBBi2E3x2COT0pH8V1YehvEpmIfECZXHGSgkVq9HoPh5Qxwfb+h3wYN84+D590msR oeA3wUJE31uDw== From: Mark Brown Date: Tue, 22 Aug 2023 14:56:39 +0100 Subject: [PATCH v5 06/37] arm64/sysreg: Add definitions for architected GCS caps MIME-Version: 1.0 Message-Id: <20230822-arm64-gcs-v5-6-9ef181dd6324@kernel.org> References: <20230822-arm64-gcs-v5-0-9ef181dd6324@kernel.org> In-Reply-To: <20230822-arm64-gcs-v5-0-9ef181dd6324@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-034f2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1361; i=broonie@kernel.org; h=from:subject:message-id; bh=k6DV13RSkbr/e436II0jx5LmEFZf9bksk2EmOe6Nllo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBk5L/0emVUssYxVMpdvy4Gd5xaJ0NcqmBuGJeaPcsx 6408fA2JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZOS/9AAKCRAk1otyXVSH0Ju7B/ 9yc31MAumewhFe2jlP2O/W+ECI5wcdNXu0y8MHvZXGM8kWN+h2n6gGh3tNwVdexQE2d2mWGrW/TmoS V2ca0cbs92ACfcj/N4nIZPVJ2hgoAY1oltXeqMqrfkIQz7BHkUNfiu+Gb9Ewq6o/mnjtmPsNXN2Wpg Pfn7Cj12s9ABBTZaiqy6RiV1K2ws+xnlY/kW5jiGAVV6CT10msAZmo9vKNDFKuzTX7GWvE9loyR4p6 28SwnUPqAsFv+HM5wHZddwmrN6d8d7oQksQO9DVhrKbo1x6AFd8sKvhqE/eE3jttsdeyhvCKzx4Cor FuiiAAdLO4oBKTfG6ZfuhEoT0h14Ro X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Stat-Signature: ha1i8y761hswa9jds97dewotc3m9ifdi X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BDD368001E X-Rspam-User: X-HE-Tag: 1692713021-170718 X-HE-Meta: U2FsdGVkX19lKLZwHx03Kryxh0Ghz0hxMIDhdwYy1UD4KujI9mG67+Kd2TjxD+UDYXEVJ4Vwx0HwguthjxDYkjY+GeAHJhwc7qol1JTwaxDPKbgTdJ1aiAL4OQcZxQqI9jPlOtRJ2uXC4RHKfDQIfnP2G8OcyISeWdFoNxj7b+O9xBoibcy+k//88GIw7fiSIt1GacCIC5hMjaS532kYyGreAaE33/qgAAxCDTsdI2qK9T6AzTEkydWUXYAGUQRr8/vf+X3IJ0SFW783zeqi1Y3aEasHZ73TTc4qrNem6wfPOBW7W8IPPa0n//utV+UifJanXxig5+jXr8yIHpY/EpkGZEmyxbEA7722vpGkkKktExVzgiXqpKjV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ofilter, 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 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. */