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 5FE95C43334 for ; Thu, 16 Jun 2022 11:29:38 +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=SdcWjRgFTYtm0BnckGavoVK5w9dFrBiK9B5/gIeGQck=; b=1S4cadp9TOBsvZ 5XZd6WzuB9Vaqoxdb19ilZmy21hduXI3ea/ssOGdcYkEA9KBnueGER9haEYxzTgARlBeluDwiiVbD 4FAmxWteoSNZfn4y+sHjz86RhQWfiyzJgejdlUxGu71ULirROSH6gthStteD+xQVkFfaaYd6+I7MK vD8MagnYaiJxT/VZdGEe7jbhFJ8mPfHNPay9e3ka/TWL3TuVNv3+uYBPL1rHubSB+YIYuRlnBm8hh qxYvOw6gQVWIVLDzRHPhhHtPThYzmCGT0+Lr1uGbA+GXIE8ofPnf+gBN72kHc7/ysA4ZIFHX7Sq9P Lw4J0KEm/rBkn4c/08tA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1ng0-0024om-6g; Thu, 16 Jun 2022 11:28:40 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o1nfc-0024iP-4K for linux-arm-kernel@lists.infradead.org; Thu, 16 Jun 2022 11:28:20 +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 sin.source.kernel.org (Postfix) with ESMTPS id DA6CACE2490; Thu, 16 Jun 2022 11:28:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 80705C34114; Thu, 16 Jun 2022 11:28:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655378892; bh=dB/RmUjK/U4GObwVBMTSKTNssGSMKdJHhK+hf2FVH+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vJDJ8Jrq2rNjx6yB2U/OK8lecoLsZByxKiNxkieZPdgIHWkAs7DXrGHWVLXcy8xNz K53jsiDkuv37q9f4mHvlSrgXvbYAZ4K/8U5Hf+bHhcLo3n7//M4j2KypKweH4+9nXz KphkJPowoz9n4q14XrWmM/LaCKbisfsh09Mv/qJ2MdabqrDVACU8EjcKvqulXE58NS 9Vlidf2IG8g9wDQiHchfvrIhkvVOt1oj+PzXgOG9HbTE6ihbDHmm6/7S9nGE0dTpmy T3L28dBnnzlYvJYTnd3arvIamgP+/RNh6UpOCd7Ft4DxQwc7Whhe6aGHp88Ua3nlZo fQ0gMDXFWhplg== 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 v1 3/4] arm64/cpufeature: Support AT_HWCAP3 Date: Thu, 16 Jun 2022 12:18:17 +0100 Message-Id: <20220616111818.724230-4-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220616111818.724230-1-broonie@kernel.org> References: <20220616111818.724230-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4920; h=from:subject; bh=dB/RmUjK/U4GObwVBMTSKTNssGSMKdJHhK+hf2FVH+c=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBiqxF2entQbrffTWfUn73F61y+4vij14fecr0ijE45 4aFCqZ2JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYqsRdgAKCRAk1otyXVSH0LOoB/ 0WNaT9WrDS4I3IeOhfvtUpDlz0n8BhKleLqZLcTY+bFI5qa3QVEL2dKRdRWGdz5w7ok3T+jViQMeWw 9kyRmj3aMFDWi4cZLmWL9C2+8ZBnb5rVCKL3sisevM4fscXoIjBSHEJbM1RWAihngvJCt/qFqeSZB0 yHf7sifeo7zwHZ2cTd6PpJZW/SbSiAxDVaBkU8LOEy/u2zwNBGgm0zH/l9qzJdEL27GafhehgZCRzr I2OwNd+tww2fAk5k7pyA4FGZ40SCPowOb+M46AK6lRB5MSwqnCZZwREVmVCodxmEvBn7TBr4RnjvI7 znF8KRn211Z9jv2xaQY47HrjZfSjLz 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-20220616_042816_598196_8BA229E3 X-CRM114-Status: GOOD ( 21.31 ) 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 3ae8eb4a9446..1b1ef0178e7e 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -3141,6 +3141,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