From mboxrd@z Thu Jan 1 00:00:00 1970 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 41D3FC433EF for ; Mon, 20 Jun 2022 13:22:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=i5O9pFV2jbxWqt7d3z2pmmrLr7vIqg3GmQ3L2yejVhY=; b=KFSCpJrQq6SwiK i/PtHoTahKixV9z7WuEUwTcAqpnfvbsOgyVnXSzDi43xa/TkUsCAheAIzXuE615dANhf/GI4ZNRP4 +/wKzIUocLGj8SQ9zxybVtDmFdG1Bc6if6D/rswclAfEfHWCDjZjAJDXBlyLMFETtmBUm0NhF3M5f JsO3q+UFNcNvA3He3v3Abf4/4g7WwkziZr5aQsEyORTupIk1nDbYJiVXQ77j40gpmy1OGJEIXDt6C IbDOxkhjkJGcJkD2qp8I3PW+EIQZatCC8gouZ+RW4gpa9lYpMX6YCufuRGtIDk5ajSWNge6+iyHx7 kj7yddXGry/cxeDlbwow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3HL6-000mpq-Pm; Mon, 20 Jun 2022 13:21:13 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o3Gvo-000aYC-8m for linux-arm-kernel@lists.infradead.org; Mon, 20 Jun 2022 12:55:05 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id CA6BF614CE; Mon, 20 Jun 2022 12:55:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5D75C3411B; Mon, 20 Jun 2022 12:55:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655729703; bh=T5EjbHAjhM0OSWcUmIu6t7wobHfDG7ghrcRYLVcAKRA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eBR12uTrORb2oCTt7C91s7wUUTD4OFBu6rh4T5arVSZcqo+rL+UTx2cH5rlbSZD2c yw/0ajpKW4mzVf7bi69yMngbcI/x8s6T0D1GlCuYFtvz2GXMfYyoRbjmOmN8izZSmX d+bQB9CwR1mTMLlPcnON48XF1y8FKuozpWOHejBZSa8KeXJDGl5uERZEcfvcROowLl xHHmkiberfs8XWOu0AIhUGiUOs+H9MDg3m00paQMC6L55knSeXIhehyMoMg6CGuPLL l5pjU0yMTDVbbemUM/sCqkJpqmW/64sUufFZq0Da7wwb5vmsLD5oAScxwZJ/SEBkbf HuKRoZ7/mPUkw== From: Mark Brown To: Catalin Marinas , Will Deacon , Eric Biederman , Kees Cook Cc: Suzuki K Poulose , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v2 3/4] arm64/cpufeature: Support AT_HWCAP3 Date: Mon, 20 Jun 2022 13:54:50 +0100 Message-Id: <20220620125451.653507-4-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220620125451.653507-1-broonie@kernel.org> References: <20220620125451.653507-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4920; h=from:subject; bh=T5EjbHAjhM0OSWcUmIu6t7wobHfDG7ghrcRYLVcAKRA=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBisG4ZiFkZG/1svW4fiP+xGNVvuAWa2MZMwhJbxEl0 SmSwlQeJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYrBuGQAKCRAk1otyXVSH0A8VB/ 47QuZHMD5hP6BGLBJvDTshrq2ynCLOp9QymmVlmHsyLPlZ0SG0cQofKcMT3stFhjWaCZ15B47xMWbL PJJboWL5eyvmcZE6lICA8R5e052gcXXv+4vJybDblxeQ57msOq1q1w3bu68stX8qFHNTeSAX2q1xg1 H0xL3Oj8lIQ3+Jj9SA3Az5OyD6mJwmlFXjW2RCKf1oiyRPCGgKtjMZmz7GzkBjkVxNPLwjy/Go8rHL RWyon09hkVqjOqf72j/4cWJsBNDZzo31aWYzk0nnKqpzGcpcQCAw2eMtpvTA1gBXD/NRKAs4k4ixnN w/HE9Hb0zH9aVKLcmVfxDRJmVBm6rU 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-20220620_055504_471409_6A59FB29 X-CRM114-Status: GOOD ( 21.12 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We have filled the low 32 bits of both AT_HWCAP and AT_HWCAP2 so in order to support further architecture features we must either start allocating from the upper 32 bits or add a new AT_HWCAP3. Feedback from the glibc developers was that AT_HWCAP3 would be cleaner so go with that. This patch merely adds the glue required for AT_HWCAP3, meaning that we start providing AT_HWCAP3 for ELF executables but no bits will be set in it. Signed-off-by: Mark Brown --- Documentation/arm64/elf_hwcaps.rst | 6 +++--- arch/arm64/include/asm/cpufeature.h | 3 ++- arch/arm64/include/asm/hwcap.h | 12 ++++++++---- arch/arm64/include/uapi/asm/hwcap.h | 4 ++++ arch/arm64/kernel/cpufeature.c | 5 +++++ 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/Documentation/arm64/elf_hwcaps.rst b/Documentation/arm64/elf_hwcaps.rst index 3d116fb536c5..5f4d89c4afe2 100644 --- a/Documentation/arm64/elf_hwcaps.rst +++ b/Documentation/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 auxilliary 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 84756c660b5e..901cf318a556 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -13,7 +13,7 @@ /* Note that bits 62 and 63 of each AT_HWCAP are reserved */ #define CPU_FEATURES_PER_HWCAP 32 -#define MAX_CPU_FEATURES 64 +#define MAX_CPU_FEATURES 96 #define cpu_feature(x) KERNEL_HWCAP_ ## x #ifndef __ASSEMBLY__ @@ -436,6 +436,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 e0054c7b3a98..1ef208ab6895 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -44,10 +44,11 @@ #define KHWCAP_OFFSET(n) ((n - 1) * CPU_FEATURES_PER_HWCAP) /* - * For userspace we represent hwcaps as a collection of HWCAP{,2}_x bitfields - * as described in uapi/asm/hwcap.h. For the kernel we represent hwcaps as - * natural numbers (in a single range of size MAX_CPU_FEATURES) defined here - * with prefix KERNEL_HWCAP_ mapped to their HWCAP{,2}_x counterpart. + * For userspace we represent hwcaps as a collection of HWCAP{,[23]}_x + * bitfields as described in uapi/asm/hwcap.h. For the kernel we + * represent hwcaps as natural numbers (in a single range of size + * MAX_CPU_FEATURES) defined here with prefix KERNEL_HWCAP_ mapped to + * their HWCAP{,2}_x counterpart. * * Hwcaps should be set and tested within the kernel via the * cpu_{set,have}_named_feature(feature) where feature is the unique suffix @@ -121,12 +122,15 @@ #define KERNEL_HWCAP_SME_FA64 __khwcap2_feature(SME_FA64) #define KERNEL_HWCAP_WFXT __khwcap2_feature(WFXT) +#define __khwcap3_feature(x) (const_ilog2(HWCAP3_ ## x) + KHWCAP_OFFSET(3)) + /* * 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) diff --git a/arch/arm64/include/uapi/asm/hwcap.h b/arch/arm64/include/uapi/asm/hwcap.h index 4bb2cc8ac446..7b818f8fc01b 100644 --- a/arch/arm64/include/uapi/asm/hwcap.h +++ b/arch/arm64/include/uapi/asm/hwcap.h @@ -89,4 +89,8 @@ #define HWCAP2_SME_FA64 (1 << 30) #define HWCAP2_WFXT (1UL << 31) +/* + * 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 1a8f60a6661e..7605b213d9db 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -3132,6 +3132,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_system_capabilities(void) { /* -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel