From patchwork Tue Oct 1 22:58:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13818918 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 D27A4CF318A for ; Tue, 1 Oct 2024 23:03:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 661FD44015C; Tue, 1 Oct 2024 19:03:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5EA3068002B; Tue, 1 Oct 2024 19:03:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 464A244015C; Tue, 1 Oct 2024 19:03:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1EE5868002B for ; Tue, 1 Oct 2024 19:03:18 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id DA596A0667 for ; Tue, 1 Oct 2024 23:03:17 +0000 (UTC) X-FDA: 82626561234.19.68653E9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 0CBC420002 for ; Tue, 1 Oct 2024 23:03:15 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qN0KFUJ+; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.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=1727823775; a=rsa-sha256; cv=none; b=JL/GhhcwR3MHoUMz/goqNfKSEJ469WWdTo3KsRSWcvQPZ24HKxO0rvCIrZ1dHdINNAeU/1 +i6h740GD3PRF5uDA6wn/owzFLtRIodeR1WeTlxplqHZtEJaIsPIbV4jsH5A2heGoI3Kkj j5Di7RRwmoc7CKpBLeM0s3eDl2QjhGg= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=qN0KFUJ+; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf03.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=1727823775; 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=ZaSzZ1EERtenLj4LKOi2XUQcr6CbcgyVZvgUx3t3Hlg=; b=ir0xjNfZBhrbDKYi/9HB1jRSsi39VrvdStesvhCWBVwuAmLBmxetQS28BMg0JzPMEHl10r kZGXYyZPIAtlgAtSRm+ccKK3gAlobzXt93YY1xr08Cq1YwWi/bPmBCm/6RMLl18zNmFhO7 B25eMuPzRXk0hp3Y0oEvKQFdIFp2x3A= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 19EFD5C4354; Tue, 1 Oct 2024 23:03:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B4015C4CEC6; Tue, 1 Oct 2024 23:03:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727823794; bh=2WIrz1ABczNTTuelqfWzt+ZpKm8ek9K3V5zq/uM97Fk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=qN0KFUJ+vti96yhBFnZJAl07br92mY0LG2AqB/XU+lMCE9arSoc22Aihn57FzTPpD jKKAVLnRC9gZ+jxwJjsmG+liJwo8cYrrojAb2rw7ocfy49cIqq+/HQJ2k+wHQ3azmZ u3St2TVXL1sZjxGG5DyK1BGF285LX4FW+9/vCWli5B9IDC/htY/ksU3oVbD5fNcrSZ a1TY6yxP+8vK/arjhFPYY/r10Hn3joDG3THXNeO20pmSm37VOv9GnTCtQ0Fs10weUJ L+JfGNKPR7XepAB1gZxNt/mU2ePMdt3EoQib1jcflSlJ0/7U8bue3Y1rO4mX5fjIIM m+gHnS7WPEZoQ== From: Mark Brown Date: Tue, 01 Oct 2024 23:58:57 +0100 Subject: [PATCH v13 18/40] arm64/hwcap: Add hwcap for GCS MIME-Version: 1.0 Message-Id: <20241001-arm64-gcs-v13-18-222b78d87eee@kernel.org> References: <20241001-arm64-gcs-v13-0-222b78d87eee@kernel.org> In-Reply-To: <20241001-arm64-gcs-v13-0-222b78d87eee@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 , David Spickett , Yury Khrustalev , Wilco Dijkstra , 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.15-dev-99b12 X-Developer-Signature: v=1; a=openpgp-sha256; l=3474; i=broonie@kernel.org; h=from:subject:message-id; bh=2WIrz1ABczNTTuelqfWzt+ZpKm8ek9K3V5zq/uM97Fk=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBm/H7ScE1JawkHCykL372K9ucQN3HG0LoTpJcod4re tJ+zIjyJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZvx+0gAKCRAk1otyXVSH0JQvB/ oDt7sqH+5NY4WIhDaXR/5vdnxL7JiatcdiiFuj+HShLpNnbvssP8ZvQSkwVv2/FomFWveqRBW43bJG P9/eHhKLyOKtyVQL4JAFUypJsyrK1luF9UU6gl9ztYvjWlBwjyVgH2te8uhEl4P5pP+WATtKiIC/Wo eul9cxeK7IgMXvQ3/hOCQpTVAHAi71PRnUczqs1r9slmr10NSrFKQiGJ9nq6AzMp/S+cIz4mJeVnEg OIUD1mRHZ8TPssXOn4jR4Y54I3iYwHRRUkvIOT/Tr7jH+Vs3/3yPmLGdBY7SEMaLgniP0PYxT8pSec FSLL7PSosg+g3RZfNrkb5A1gygvicw X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-Rspam-User: X-Stat-Signature: ozxyfquaat9ri3k5648br357cn8jw6df X-Rspamd-Queue-Id: 0CBC420002 X-Rspamd-Server: rspam02 X-HE-Tag: 1727823795-578891 X-HE-Meta: U2FsdGVkX1+qqBZKB5BBJstfpwZJ3NR33NoBaYbXYD7h+HeQKrOQi/jThioW2UXeJm6CFHa4pMWHlzb4a11vwyfTZpIz19EqCsVe68iXflmKGH/ibdUkHelkF2qjnltbkUhglgwsy9/GH++hw2BXOf39anLFbNmwXH4ybtNeCL55aWEk8jAnbX2+L1IEtj/7NqC0PiEiADSWPMkZb8cNyko+a9U7q2vokuSBYYnikG97hbsjtmpB8yk90NASxHNVG0Vh8hvZqwHjxXQkWFcV5smSeW2euFvaoLxKZzf2qEuVzdH0IrPzYOyqJUMPIUCE8IMI0ngObzG7P9Jvp1MAe7iuJ9zkEYeij4wgdw7Oqha2KurEfjZzcTLwAoTYkNc2VYRtJFsRBHkSgOiVoowWHWIThxI/duBWZgxFt0Q2n4kD6TrCLMk2PT2aUz6ZbOEz+5yjE7oMtxhG8wjo06bqYemx+2NDMv26Gao8D3LBVlz/zXdkOhtl0ihY5n+zvNzy8qSS8GYxaD3CBFoX+ljs6g/m5TpyL728lnv5o1Qfu1olkiNLtjXCxHnTIz3c6IoUjUyXraHZZa7jj3AUNlgZZh3jXeq/cU810tsbxRdWykW3QH3f0Rw7OpWVpnWT4bQYXCp9VSiIY9HtyJXDTeRFFZzqdQP3/+jGx6/xs7E1wScaoT5dK735r4alsqCoDDtIl2eVN1Qq9m7lr3Kh0wiaTCZdM8RiJd4LUKazzbm8VYe0pz+aqn4nt6NrALQ2Irj6tTPPjZq90p9U1+c3U3HlHwrlaXmLC4KkCHYEZPq8ot8+eMj+1aPa8JT4jfe2dGgjA0afbIYEmq75iwmWwU3T951t+Kttm0vWGPddq2SO/xOBm6j8DFq4Oe767hJzQNHht4zZwZ8TGg3rtO3fdM0z5r6Ym96GScu0iZM/wHt0oaux2Bea8NYg5XKE6Yg6aiMNXPb9n4BKePtKmV3R5+B Y7hDKLKn 7pFxiOx6x23iN3U9eUApzndiOv/zl9tMnFRkNw2mUnm9okZikYiPxeXF/vtyI2c2qzkyHfz5kYBLCWrQFeJDsYpxbUHD+Y4rn+8SYOuBQp+IkZd1Dno+XEVJKeglFJsrEGyXK3Mem11dHzPGeXRUtuAAsMuFmvISgoJmTMcLM9+ORyxlS1Cr5uf/Rc1yPGtd1PmOmHXIpGg7ua6LvnD1H1KyKtkHD51ui18aaDL47uJ7Clbo8oflWhvX+shlxNQJ4roER0f+wSi9sFYPqm54DBUHcOAsl1CirLDxepMB/n3pleV7E+Okmx2GaSLnYyPLHfMmt 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: Provide a hwcap to enable userspace to detect support for GCS. Signed-off-by: Mark Brown Acked-by: Yury Khrustalev --- Documentation/arch/arm64/elf_hwcaps.rst | 4 ++++ arch/arm64/include/asm/hwcap.h | 1 + arch/arm64/include/uapi/asm/hwcap.h | 3 ++- arch/arm64/kernel/cpufeature.c | 3 +++ arch/arm64/kernel/cpuinfo.c | 1 + 5 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst index 694f67fa07d1..25b41ff74fa0 100644 --- a/Documentation/arch/arm64/elf_hwcaps.rst +++ b/Documentation/arch/arm64/elf_hwcaps.rst @@ -170,6 +170,10 @@ HWCAP_PACG ID_AA64ISAR1_EL1.GPI == 0b0001, as described by Documentation/arch/arm64/pointer-authentication.rst. +HWCAP_GCS + Functionality implied by ID_AA64PFR1_EL1.GCS == 0b1, as + described by Documentation/arch/arm64/gcs.rst. + HWCAP2_DCPODP Functionality implied by ID_AA64ISAR1_EL1.DPB == 0b0010. diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h index a775adddecf2..7bcf1347ca0b 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -92,6 +92,7 @@ #define KERNEL_HWCAP_SB __khwcap_feature(SB) #define KERNEL_HWCAP_PACA __khwcap_feature(PACA) #define KERNEL_HWCAP_PACG __khwcap_feature(PACG) +#define KERNEL_HWCAP_GCS __khwcap_feature(GCS) #define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 64) #define KERNEL_HWCAP_DCPODP __khwcap2_feature(DCPODP) diff --git a/arch/arm64/include/uapi/asm/hwcap.h b/arch/arm64/include/uapi/asm/hwcap.h index 055381b2c615..675642ec4d91 100644 --- a/arch/arm64/include/uapi/asm/hwcap.h +++ b/arch/arm64/include/uapi/asm/hwcap.h @@ -21,7 +21,7 @@ * HWCAP flags - for AT_HWCAP * * Bits 62 and 63 are reserved for use by libc. - * Bits 32-61 are unallocated for potential use by libc. + * Bits 33-61 are unallocated for potential use by libc. */ #define HWCAP_FP (1 << 0) #define HWCAP_ASIMD (1 << 1) @@ -55,6 +55,7 @@ #define HWCAP_SB (1 << 29) #define HWCAP_PACA (1 << 30) #define HWCAP_PACG (1UL << 31) +#define HWCAP_GCS (1UL << 32) /* * HWCAP2 flags - for AT_HWCAP2 diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index d1e758e99e0a..b8655d55f318 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -3025,6 +3025,9 @@ static const struct arm64_cpu_capabilities arm64_elf_hwcaps[] = { HWCAP_CAP(ID_AA64ZFR0_EL1, I8MM, IMP, CAP_HWCAP, KERNEL_HWCAP_SVEI8MM), HWCAP_CAP(ID_AA64ZFR0_EL1, F32MM, IMP, CAP_HWCAP, KERNEL_HWCAP_SVEF32MM), HWCAP_CAP(ID_AA64ZFR0_EL1, F64MM, IMP, CAP_HWCAP, KERNEL_HWCAP_SVEF64MM), +#endif +#ifdef CONFIG_ARM64_GCS + HWCAP_CAP(ID_AA64PFR1_EL1, GCS, IMP, CAP_HWCAP, KERNEL_HWCAP_GCS), #endif HWCAP_CAP(ID_AA64PFR1_EL1, SSBS, SSBS2, CAP_HWCAP, KERNEL_HWCAP_SSBS), #ifdef CONFIG_ARM64_BTI diff --git a/arch/arm64/kernel/cpuinfo.c b/arch/arm64/kernel/cpuinfo.c index 44718d0482b3..f2f92c6b1c85 100644 --- a/arch/arm64/kernel/cpuinfo.c +++ b/arch/arm64/kernel/cpuinfo.c @@ -80,6 +80,7 @@ static const char *const hwcap_str[] = { [KERNEL_HWCAP_SB] = "sb", [KERNEL_HWCAP_PACA] = "paca", [KERNEL_HWCAP_PACG] = "pacg", + [KERNEL_HWCAP_GCS] = "gcs", [KERNEL_HWCAP_DCPODP] = "dcpodp", [KERNEL_HWCAP_SVE2] = "sve2", [KERNEL_HWCAP_SVEAES] = "sveaes",