From patchwork Wed Nov 22 09:42:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13464401 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 5BEE2C61D9C for ; Wed, 22 Nov 2023 09:43:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA14B6B0598; Wed, 22 Nov 2023 04:43:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E50606B0599; Wed, 22 Nov 2023 04:43:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF1F26B059A; Wed, 22 Nov 2023 04:43:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BCCF16B0598 for ; Wed, 22 Nov 2023 04:43:48 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 96129805C0 for ; Wed, 22 Nov 2023 09:43:48 +0000 (UTC) X-FDA: 81485103336.15.AA332A5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id C4C5DC0021 for ; Wed, 22 Nov 2023 09:43:46 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qs5YB6BE; spf=pass (imf10.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=1700646226; 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=TZ0ZwEmlv4C4jxhX8WtZ7aOr+nW8SCVOLuCCiD9LGas=; b=VbzS7p2fYcDijDwvRoEL5vIEDwAgiRrEeTiMD2gkI/XauayV9cEIYjgRicKwbzPWZVQZn0 w0Xjy/XQZ0R42hd1Fh52wMgDdrDRgCLKH6upHlHgRVXtZIjFy2wmaO4P/C3mFtoHK6lgUq QM7md8FPa42xY8rH9pJ93wELuGaBWfs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700646226; a=rsa-sha256; cv=none; b=M4HaAgQHf9TPKzjEP39zVCy3Ixmcff14FmXe1VKpqZF64741JgkFx7cKLFIImQ+sk19bdC nUMl5ee9Ngks+PEnot8nvR3h53b5sMgXSBra677jbvton8OBJl+jAuRdpjJKUe2nADL2CT LLDZImp0Z7RaUP9PUryrBhB26obBdpM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qs5YB6BE; spf=pass (imf10.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 (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D868161CD1; Wed, 22 Nov 2023 09:43:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77F1AC433C9; Wed, 22 Nov 2023 09:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1700646225; bh=AdenxNKaKLfO1zzZHzslCIJebdi1YPs1wuXZd9U1dO4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qs5YB6BECnMAmghk+5k7QLjQ4iTf/O6w9uwKHheCTbxYsU4dCielXXbKpJWvVJbOO eHvstQrw3PY/tc2Itmd0DGJ7a9XLXgveUYEreP0NdC2bZwRKN8Csxmok8dA98yK6jJ pc/VhN++Iddv1n65+uxrwhQVBNX4wTnb4RntXV6p1LG9HjaGajgFeuYEg7d8W2vnS6 DsVLe11iXrOgM+nfF8hv0a4E3fBTkDuQgmYeEb5x+merErzYBI1UBOYtqum9DhkAEu iz1H6w7wU93+McmzZK2pTguofmFSA0eW8JcDbFbW+BkqVIf9s/MphpA8RcRNk9/QCg +DKBkAjfQe8QQ== From: Mark Brown Date: Wed, 22 Nov 2023 09:42:17 +0000 Subject: [PATCH v7 07/39] arm64/sysreg: Add definitions for architected GCS caps MIME-Version: 1.0 Message-Id: <20231122-arm64-gcs-v7-7-201c483bd775@kernel.org> References: <20231122-arm64-gcs-v7-0-201c483bd775@kernel.org> In-Reply-To: <20231122-arm64-gcs-v7-0-201c483bd775@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-0438c X-Developer-Signature: v=1; a=openpgp-sha256; l=1363; i=broonie@kernel.org; h=from:subject:message-id; bh=AdenxNKaKLfO1zzZHzslCIJebdi1YPs1wuXZd9U1dO4=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlXcz8bmHxgHWCFRqVN8uz2M3iReNk3BZizcael fYUhMZ5DoWJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZV3M/AAKCRAk1otyXVSH 0F7RB/4ql9JuD5+zDZkKa3IqDccJ/whQ1MzEyDazvd5D9iSOO2uFVWKf/mgBe42Co9F7iJXvawY fnM4HLJ+2I6Jpps5E2t0pRb5MPSbFPYrmiDpnpwyH+gCNdD/ISBWGGKi19hQLMzotC2usKxe7n/ ZPPgZlodquDSXAvzd6yBK/QAT+KqARuuUYjttCxdlJOeU0BHNEbhz8/owbin6JfrC1GTlcGGFai aASFR2cqBA+/sxYNdN9NjVEQv2zxSBdFJ+zVZ1qt29sVNQq4+UVEYWYK5MXwadGBn1rZoKRfQA/ I2UNt33vEzbJko8U/aAkwKFHIOuyMBeaY7xivvSZlmH0QBVz X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspamd-Queue-Id: C4C5DC0021 X-Rspam-User: X-Stat-Signature: abzpx7cdz9i1x11uxr7po14q3z71h3y1 X-Rspamd-Server: rspam03 X-HE-Tag: 1700646226-732047 X-HE-Meta: U2FsdGVkX19RnM82PjYFzlpGNBKVTHXCTCHy3it13owcnEdW/KHB5BFRzPqO+mnd9AG04IUqdLjsesOV1rxm8jesgAcTA9X3B9VKEWuYxtmA3X1RM7Ku5fbSKx1AFxGJ8XFGJITx12JutQAiHcbAaxSMvltTmTLrYJXrpLevfYrDCFBq77KvMv12CDsIKGcK5eTpLlbI27D0aCq75yVp0aBrtJ6td1kPdMsTCn/jFbDOeBxA5ATmYZE1oy2qUx35ljpf7tlZjGt/smZ9qdMe7Va7B/56m3J4Fo6ZSL8rzduPaFV7yf24dZVEDDs++jBlkewNA1hw7+JOkRIN5pdWhW/hfJj2LHirvY6NSqZfrf1/PjXJnC3kS2nRvTJ4mxccCi91D8OjtZD0tnwSnVebpLPpzGsEkSl4T/wQujz859ff+6eG8Ek9GhqUUiUyrk0uQf4J5y4ehO3nMTFfqnPqX3RgbbMtqnzkZQTxoLKo3klYYECkoPgiU9MZ3LMEjb3xL7y0zcKmurt6rqFSp4xivwpSnAnI3Af8LNP5gvWDXuwZ6KGf3MhuzgAcQYC+ZX+fqp6OupzBZzrtY4p3PkFGQpWdFrUV/Z7bOug1FgI8eQEGtv1j8Kys4U669OR9xvDjdei3wgTXrWeHHV/W1Lc1sTy9mMXIv5aemBFpQ5qrU8EDJr7rh1mtX5bD9RrCphqlGzlAH60s4dwrJdXfEMfiKJG360WWiq11uXABbbYR2BouzdKZAAYAsATlw0QEaylTZAw+SXDJ07rl8qEkX/yJi/ZQqi5TNYKEmzsNiVkE5RDOFzzd2tY2ACK3LpmIZfwl7qhTyrSjGom30LADajQIDgxK0jBq4c3UAcvHxiPrOFSawxlqv3652D0auXh3CH5HOOoNwl6Ut5yzeg5ZUPcB3tEdGw9uFRwwzft4fopnhErhb8EOQFOqMVZzQ3D14mqUBmRnVVJLpOfbZx+1pxl RPB742sl 5LVcJJNCHDCcgHB33/etrHJopck8FnpZo35v01WfwTNtm8zlODWmbJN2dLhmbYgX4oP1UP4y8OpBnrQfvXQ3bGqQFGXF0PK6fs/TC1LulQxlY02SJM7ezhvKRStd5F6DxKKuKOETfZ1C2eoVbINdGw7Ytg2FQFXmjaw6j6uX7Po2KDalozcCCkQ6NNb0vfzR0KJnyB5NnkvVtt9cSQqxSDWQxb09DrloKYzQkE1bWPWatVuYLXvuPyPqawn2fOAkNIMfIKBjeZ7I+ddMlvmjCwAqGfLWPOlN/L5wL/4IGwz70+w4X0JI3+guUPytpSmIkx+J6 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. 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 5e65f51c10d2..75a49b41fa93 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -1039,6 +1039,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. */