From patchwork Thu Sep 5 23:05:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13793080 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 53A3CCE7AA1 for ; Thu, 5 Sep 2024 23:09:59 +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=RzJmVHoxTOkqVv2oPM0AZ9Ba2lKqM75VQ4Cr65YXulE=; b=fTly5ONL03w03M+rZmQhCsaYmB +nd8KJ0pKAT7QQZ/TukRZ1SbCgmfzB1AqmhvqN1tRIQqV+s0/735TYdcT2kUXBZ1Bh4JE7BeQpzT7 eiNz6OFUzDRNDcWBePwrdtqUlCD0JWVDG9KiL2VkhVB8jZJ3GpSxgqT247jQXm5F+lGXzOuQVpQmD Xwg34VJmUiO6qbilpCzKphGRNc+jmTzOB9CpfFvS0eZht77llFasS5721aiyrGoWCq6WHNs1IST2Q jQQ3F957U5HutPjNT+3WzJ2lfzd/rOVoYXxJEWCiQX5OSZOEKdfWUfGb1DNMhKc9fs4bMWzuLuCNs 4nV1jg8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1smLbr-0000000A5TB-00t8; Thu, 05 Sep 2024 23:09:51 +0000 Received: from nyc.source.kernel.org ([2604:1380:45d1:ec00::3]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1smLZ6-0000000A4wP-33V8 for linux-arm-kernel@lists.infradead.org; Thu, 05 Sep 2024 23:07:02 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 8BFBCA4372A; Thu, 5 Sep 2024 23:06:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9469AC4CEC4; Thu, 5 Sep 2024 23:06:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1725577619; bh=A1MsCyDJgEsRX6kQKLK9eRLTDyJrgk7l7bzvGIADznQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=GhPgpfKb5XecmsryPGqjtx250G+lHVlFC4InO3RdPZcoD042V6UNbwQvKhp8HWjDL 405lCJ2+pKEhgEgHItQ1CzvzdJHWrF9CsVVLAFVNP85qSJIYbACUW7jzLlhipJfysf hOJhCzJVdm+YbUquMIwd54Q8dksbeZAzTajmvRbnEEfks54KIRg8aV//0dhV9U5ia2 0nRkbWhpSK0+pxVRqYvd6EDYK5UzMuJ7tI4JNElz7RIC3Tce4hcohkbBd+7y8ptcQ7 EQs6XiZCAbU4I9xSlfvO1v7RN35XZkI4hW6zafmkZ7pImt6ET/WcsmYUcG61emsXd4 hwop67+Fc4LBw== From: Mark Brown Date: Fri, 06 Sep 2024 00:05:25 +0100 Subject: [PATCH RFC 2/2] arm64: Support AT_HWCAP3 MIME-Version: 1.0 Message-Id: <20240906-arm64-elf-hwcap3-v1-2-8df1a5e63508@kernel.org> References: <20240906-arm64-elf-hwcap3-v1-0-8df1a5e63508@kernel.org> In-Reply-To: <20240906-arm64-elf-hwcap3-v1-0-8df1a5e63508@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-99b12 X-Developer-Signature: v=1; a=openpgp-sha256; l=4418; i=broonie@kernel.org; h=from:subject:message-id; bh=A1MsCyDJgEsRX6kQKLK9eRLTDyJrgk7l7bzvGIADznQ=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBm2jmIf3KlTF3HuICSRK2swFAoI5TkoKodbSQSwtH2 eOden2uJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZto5iAAKCRAk1otyXVSH0JhuB/ 42nAbDepwuWS2bMb3uWSgS9OHa4Ly3xMqGKhQKJqXvqevtltxck+8dXjok7eAUJ+8xSKRPw72njBZq KA4OUWQragIfeidoQKApKZpih0twdUPs/d+yVmUHUHedClUN/jbIgyd/HUgUGr8pt34UT+KTaK/LYs d/bbD655MWElOWiowvYs/iXX8GOPWs0NnTa30pP9NvOp2SzkyqfPcbSk3d7q5ONRaZKjhZZUK4LmEY Ug2VjEvJ9l7KkbevX4lts5DLJsFwZqVLUnn/EN+mwW3hUvaCjqgOVM4xUKiR1uNjM4cv+tmBkP+G+J 7l4k82NXS0/cr/as7YI3eLuqmQfYuq 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-20240905_160700_933333_07F4076D X-CRM114-Status: GOOD ( 15.54 ) 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 --- 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 448c1664879b..36530d613adb 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 558434267271..0a999a45ce02 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 4edd3b61df11..c1107456cb81 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -158,17 +158,21 @@ #define KERNEL_HWCAP_SME_SF8DP4 __khwcap2_feature(SME_SF8DP4) #define KERNEL_HWCAP_SME_SF8DP2 __khwcap2_feature(SME_SF8DP2) +#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 285610e626f5..170eac371991 100644 --- a/arch/arm64/include/uapi/asm/hwcap.h +++ b/arch/arm64/include/uapi/asm/hwcap.h @@ -123,4 +123,8 @@ #define HWCAP2_SME_SF8DP4 (1UL << 61) #define HWCAP2_SME_SF8DP2 (1UL << 62) +/* + * 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 646ecd3069fd..77d6a84e27e5 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); @@ -3476,6 +3477,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) { /*