From patchwork Fri Oct 4 20:26:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13822984 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B22E6CF885A for ; Fri, 4 Oct 2024 20:31:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References :Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=QGrbr+9fd07ji0wETl8H+7l9HeI4HM8dzkTBIS3jCoE=; b=DLRtVqe0obWZxjzzQmR+gJ6e2G sJM2gE0cZybu8Bgv2OcUTS855AGkeeAbdl8h7Ui+SEgoMqgLI3JejH9e53MNz1I12KjB7WKJLKZyN hLxmEjSab3TGG3notfMk4wtyVgls3/Q+bEdRdoJS3JhBsxWuJLzP/hwZt1Vn+BNBAw5BGjdMf38EE JWiahCTNVUE1dhjuFhohjduuEBHJaAs64H7mY8U9N0Vgi6IBCxJFUXLD1GkHOCxsM1v2Mlzr1o4zp Pe0xPVb+dpNPsSjfXqlB0ONXDMfy+WTh/jjH5Rm6nUyQItFI8Z6bfJM3OTW3NlJl5wLvSwoGcRO2W s2yyp0Lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1swowx-0000000E9Yi-083T; Fri, 04 Oct 2024 20:30:55 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swovh-0000000E9L8-0eln for linux-arm-kernel@bombadil.infradead.org; Fri, 04 Oct 2024 20:29:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Sender:Reply-To:Content-ID:Content-Description; bh=QGrbr+9fd07ji0wETl8H+7l9HeI4HM8dzkTBIS3jCoE=; b=cOAevXOV50vl9Maeh9lHzrtQ3f V97u1zfDEFRHZ3GYx5Vu/ufhIZkeoif3fULz+QNkrN24ipUcV286fl2PChw/dOwXGE5QPRCYcy0ps js0PBwkIZ6010mjE1VdwRvQN9/qSkThCBef3sHTAnUimKksjaYrefT59E3Bl6wAfW5CZ0UEtQQUEZ wWbzWGewPJB88k3vGlNNvEVFHgfYFN4C0HJEHGJmfIB0YuF6c0oRobzP6vC565uM+ZuMMwBMoiC2x 4sMTF+tudajDM532xIiGh2nNgg2CaUBRz4hiRZTGoZsGEyRMDAGc9t7zD9QsGOoyNbahBdimnDeLW okdnsoAA==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1swovd-00000003wr5-3uTp for linux-arm-kernel@lists.infradead.org; Fri, 04 Oct 2024 20:29:36 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BE33C5C5946; Fri, 4 Oct 2024 20:29:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B9738C4CECD; Fri, 4 Oct 2024 20:29:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728073770; bh=Q29JrkLZxdArYwY+rVpKpTkNxIyN30A+TtF5u4a+d1w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=kPfnVwr8SWBws2rU3nHv5pCJNfCkH6R5u4eQ6sEHY7b59UXTp/29XlR7QsZn9vLeY WxIgMlZAJkzfbjX23C1S0RchYA9z7k4Mx1MP0RNEhoqER0TOP5/zXDAd70UkVyVxHV BpmsVOnqD0ZsgItThc4CVUsNMAssHg/YGdBqsGcvUSkYp5Y1d5Hitf4F2Tx1QXnLFx oV3YoL7FLZOHQECi6q89+XiFzeErqfXK7h5pHa9lSLUNSps7JTqqC10yOUrBRM0Uno 88hn/JpoqAeAZVNZulJ1piBT6ushRc5l8Crzi//csirZiLsV5XtSVEXa6Wy6Ld1Hqt V3bUp2d9d7Vfg== From: Mark Brown Date: Fri, 04 Oct 2024 21:26:30 +0100 Subject: [PATCH RFC v2 2/2] arm64: Support AT_HWCAP3 MIME-Version: 1.0 Message-Id: <20241004-arm64-elf-hwcap3-v2-2-799d1daad8b0@kernel.org> References: <20241004-arm64-elf-hwcap3-v2-0-799d1daad8b0@kernel.org> In-Reply-To: <20241004-arm64-elf-hwcap3-v2-0-799d1daad8b0@kernel.org> To: Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Kees Cook , Catalin Marinas , Will Deacon , Jonathan Corbet Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Yury Khrustalev , Wilco Dijkstra , linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, Mark Brown X-Mailer: b4 0.15-dev-9b746 X-Developer-Signature: v=1; a=openpgp-sha256; l=4678; i=broonie@kernel.org; h=from:subject:message-id; bh=Q29JrkLZxdArYwY+rVpKpTkNxIyN30A+TtF5u4a+d1w=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBnAFAfn7BPFjo4XljvMQXJ1vgo1LJghNjRRFv/EHRJ dSaDGdWJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZwBQHwAKCRAk1otyXVSH0HXCB/ sHPZyH0C3p8kpDx3xx/v8pAStV7iXI+CDLK+jDe+taJ/8wYG3EaQtVb3UfwJFVBhine4yNr8GKd5td NnTguPxISjp9da3eMg+/Ev+VRxbfRCzTlCboqTDAIF602zHJu0z516cRbb7gcrKXWQkyZNk9jWj+NY JKt7w8bnejgF0i8MEbTOyvq8JpW2FCdeGqzLs60Lm15nNnHnUzno0S05Yi5fhQAfJv7ia0XTf8iSim 7FWdQhvTkjNAHa5BU2ro3B2dKdcr/Z3wKkaj4wlkWXdCuJIqCXpATbAiPSYX1GhNYCGtZA4QftstDo pX9bsUtoq7432pKjQDX0iVx2mJaUBA X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241004_212934_451332_8C1AB4C5 X-CRM114-Status: GOOD ( 15.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have filled all 64 bits of AT_HWCAP2 so in order to support discovery of further features provide the framework to use the already defined AT_HWCAP3 for further CPU features. Signed-off-by: Mark Brown Reviewed-by: Anshuman Khandual --- Documentation/arch/arm64/elf_hwcaps.rst | 6 +++--- arch/arm64/include/asm/cpufeature.h | 3 ++- arch/arm64/include/asm/hwcap.h | 6 +++++- arch/arm64/include/uapi/asm/hwcap.h | 4 ++++ arch/arm64/kernel/cpufeature.c | 6 ++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Documentation/arch/arm64/elf_hwcaps.rst b/Documentation/arch/arm64/elf_hwcaps.rst index 694f67fa07d196816b1292e896ebe6a1b599c125..dc1b11d6d1122bba928b054cd1874aad5073e05c 100644 --- a/Documentation/arch/arm64/elf_hwcaps.rst +++ b/Documentation/arch/arm64/elf_hwcaps.rst @@ -16,9 +16,9 @@ architected discovery mechanism available to userspace code at EL0. The kernel exposes the presence of these features to userspace through a set of flags called hwcaps, exposed in the auxiliary vector. -Userspace software can test for features by acquiring the AT_HWCAP or -AT_HWCAP2 entry of the auxiliary vector, and testing whether the relevant -flags are set, e.g.:: +Userspace software can test for features by acquiring the AT_HWCAP, +AT_HWCAP2 or AT_HWCAP3 entry of the auxiliary vector, and testing +whether the relevant flags are set, e.g.:: bool floating_point_is_present(void) { diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 3d261cc123c1e22ac7bc9cfcde463624c76b2084..38e7d1a44ea38ab0a06a6f22824ae023b128721b 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -12,7 +12,7 @@ #include #include -#define MAX_CPU_FEATURES 128 +#define MAX_CPU_FEATURES 192 #define cpu_feature(x) KERNEL_HWCAP_ ## x #define ARM64_SW_FEATURE_OVERRIDE_NOKASLR 0 @@ -438,6 +438,7 @@ void cpu_set_feature(unsigned int num); bool cpu_have_feature(unsigned int num); unsigned long cpu_get_elf_hwcap(void); unsigned long cpu_get_elf_hwcap2(void); +unsigned long cpu_get_elf_hwcap3(void); #define cpu_set_named_feature(name) cpu_set_feature(cpu_feature(name)) #define cpu_have_named_feature(name) cpu_have_feature(cpu_feature(name)) diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h index a775adddecf25633e87d58fb9ac9e6293beac1b3..3b5c50df419ee94193a4d9e3a47516eb0739e89a 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -159,17 +159,21 @@ #define KERNEL_HWCAP_SME_SF8DP2 __khwcap2_feature(SME_SF8DP2) #define KERNEL_HWCAP_POE __khwcap2_feature(POE) +#define __khwcap3_feature(x) (const_ilog2(HWCAP3_ ## x) + 128) + /* * This yields a mask that user programs can use to figure out what * instruction set this cpu supports. */ #define ELF_HWCAP cpu_get_elf_hwcap() #define ELF_HWCAP2 cpu_get_elf_hwcap2() +#define ELF_HWCAP3 cpu_get_elf_hwcap3() #ifdef CONFIG_COMPAT #define COMPAT_ELF_HWCAP (compat_elf_hwcap) #define COMPAT_ELF_HWCAP2 (compat_elf_hwcap2) -extern unsigned int compat_elf_hwcap, compat_elf_hwcap2; +#define COMPAT_ELF_HWCAP3 (compat_elf_hwcap3) +extern unsigned int compat_elf_hwcap, compat_elf_hwcap2, compat_elf_hwcap3; #endif enum { diff --git a/arch/arm64/include/uapi/asm/hwcap.h b/arch/arm64/include/uapi/asm/hwcap.h index 055381b2c61595361c2d57d38be936c2dfeaa195..3dd4a53a438a14bfb41882b2ab15bdd7ce617475 100644 --- a/arch/arm64/include/uapi/asm/hwcap.h +++ b/arch/arm64/include/uapi/asm/hwcap.h @@ -124,4 +124,8 @@ #define HWCAP2_SME_SF8DP2 (1UL << 62) #define HWCAP2_POE (1UL << 63) +/* + * HWCAP3 flags - for AT_HWCAP3 + */ + #endif /* _UAPI__ASM_HWCAP_H */ diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 718728a85430fad5151b73fa213a510efac3f834..7221636b790709b153b49126e00246cc3032a7bc 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -103,6 +103,7 @@ static DECLARE_BITMAP(elf_hwcap, MAX_CPU_FEATURES) __read_mostly; COMPAT_HWCAP_LPAE) unsigned int compat_elf_hwcap __read_mostly = COMPAT_ELF_HWCAP_DEFAULT; unsigned int compat_elf_hwcap2 __read_mostly; +unsigned int compat_elf_hwcap3 __read_mostly; #endif DECLARE_BITMAP(system_cpucaps, ARM64_NCAPS); @@ -3499,6 +3500,11 @@ unsigned long cpu_get_elf_hwcap2(void) return elf_hwcap[1]; } +unsigned long cpu_get_elf_hwcap3(void) +{ + return elf_hwcap[2]; +} + static void __init setup_boot_cpu_capabilities(void) { /*