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 AC4C3C433EF for ; Wed, 6 Jul 2022 17:56:18 +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=ViIsU/Yo3PbyBz4eJhKj2aIWwTG0cjanaDYvn9S836w=; b=GzRgN9q7lCRoUc XIj55V/55XHan5UIY0V0Xr9vW4gkLW1bd5VdMHSynLqdT94v/rRmqneSYvPp3FlcKwEK9BrIcJ4Cb /0wzYfH55J5qRDGcNI4fGoOGmNatQ9ZXwF8MYwn/s0vvhoq3yOjWpWNgzzXGgmcYMXMAOuprOLvK1 1bw4KzLIzdA98QSviJLqX880tibSnIArJPVTs1/jiBqd5/klq/tgRN5y1ar4j0DRzItkTgRUi7AjD xz8whJn/wK3R2Efchdp0Nm9sTL2GXXcqYrHWeJSSTfTFtsoLppt5+iTmq4qccr24IzXbtNRTEQ0hh TiW/BeZKQGg9clfiVAFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o99F7-00Bqyv-V3; Wed, 06 Jul 2022 17:55:18 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o99Dw-00BqbO-Vo for linux-arm-kernel@lists.infradead.org; Wed, 06 Jul 2022 17:54:07 +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 ams.source.kernel.org (Postfix) with ESMTPS id 399FFB81E69; Wed, 6 Jul 2022 17:54:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0871AC341CE; Wed, 6 Jul 2022 17:53:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657130042; bh=ioaKgR6/PaIx8d82WBbtnX2f2PT6EEhU4JgUswr7CiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OsrHI+61nw6bY6KkeOw8+ofqqLS/aiQ2qHl0dQ5Yxek43t4OImRdAXAaI01dzz3E9 gB1TF6/VMgdAPZ7DHkIY57z4irfSJROoKB3KgPMTCLosmsGvw2JX32SxTpzQ4bVxkD fOqltb1PyJcFM+Jdl0Tq0Fb8F/+PFTwhyDAG0Xj9MtjFOOEo1Hna0cfSAQM2Sdy+do v6R7D9eW/QU39tyxZjqJT7u4G3kSE7QbxH+lUnjMqQSKuCODQHU0EkiFHUiJhAxhT9 ezQPo3IWBlXGO3eY6Ufg/RzHNVOqmxhW4+xPtV/m5dzatwv440xEK7YHO/3zZthckL fERPkcrno7UVw== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Suzuki K Poulose , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v4 2/3] arm64/cpufeature: Store elf_hwcaps as a bitmap rather than unsigned long Date: Wed, 6 Jul 2022 18:52:55 +0100 Message-Id: <20220706175256.847703-3-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220706175256.847703-1-broonie@kernel.org> References: <20220706175256.847703-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3117; h=from:subject; bh=ioaKgR6/PaIx8d82WBbtnX2f2PT6EEhU4JgUswr7CiI=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBixcv2wTHHbFCDaB7hRD5QSj9JMsCxTKMMp5/WhG+T RRT+zF6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYsXL9gAKCRAk1otyXVSH0H5rB/ 9y7JiIe9tfXfInOJ7ybSOwS8xw19myR3sqqlZPHid2j5yqLAyn6KzZMUAsLwtBNIDaSkHBMe7h7WUl VAnIK8cv1r+u85I6s9tbSbvNyvFHoXX3tt8srwsoGA3644/sKWBguzGtXPraOrUyo1+yIyv6i9TKGI Nr+jVUpWTRhojhTOhHBoGPifgF3QT/Q80/va+OF83ZdBwTFj/F4qCfURA3Y5ygfaSBB3qS4yPelG6i 7JOYRAOJk821pB8aJqDtGtJ/3m0msZwN8cp3SbbZoD7cZ+dwjmA70Hc0C4BiZcNRVlrScTXcWthD6+ UWRUqtoZthx+ME7ezLJZKppv6mzq0n 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-20220706_105405_437694_F8A2DAAE X-CRM114-Status: GOOD ( 15.34 ) 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 When we added support for AT_HWCAP2 we took advantage of the fact that we have limited hwcaps to the low 32 bits and stored it along with AT_HWCAP in a single unsigned integer. Thanks to the ever expanding capabilities of the architecture we have now allocated all 64 of the bits in an unsigned long so in preparation for adding more hwcaps convert elf_hwcap to be a bitmap instead, with 64 bits allocated to each AT_HWCAP. There should be no functional change from this patch. Signed-off-by: Mark Brown --- arch/arm64/include/asm/cpufeature.h | 2 +- arch/arm64/include/asm/hwcap.h | 2 +- arch/arm64/kernel/cpufeature.c | 12 +++++------- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h index 14a8f3d93add..7abd6c0fa53d 100644 --- a/arch/arm64/include/asm/cpufeature.h +++ b/arch/arm64/include/asm/cpufeature.h @@ -11,7 +11,7 @@ #include #include -#define MAX_CPU_FEATURES 64 +#define MAX_CPU_FEATURES 128 #define cpu_feature(x) KERNEL_HWCAP_ ## x #ifndef __ASSEMBLY__ diff --git a/arch/arm64/include/asm/hwcap.h b/arch/arm64/include/asm/hwcap.h index aa443d8f8cfb..9b5fdc114f8c 100644 --- a/arch/arm64/include/asm/hwcap.h +++ b/arch/arm64/include/asm/hwcap.h @@ -85,7 +85,7 @@ #define KERNEL_HWCAP_PACA __khwcap_feature(PACA) #define KERNEL_HWCAP_PACG __khwcap_feature(PACG) -#define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 32) +#define __khwcap2_feature(x) (const_ilog2(HWCAP2_ ## x) + 64) #define KERNEL_HWCAP_DCPODP __khwcap2_feature(DCPODP) #define KERNEL_HWCAP_SVE2 __khwcap2_feature(SVE2) #define KERNEL_HWCAP_SVEAES __khwcap2_feature(SVEAES) diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c index 8d88433de81d..5ba226f3721c 100644 --- a/arch/arm64/kernel/cpufeature.c +++ b/arch/arm64/kernel/cpufeature.c @@ -91,7 +91,7 @@ #include /* Kernel representation of AT_HWCAP and AT_HWCAP2 */ -static unsigned long elf_hwcap __read_mostly; +static DECLARE_BITMAP(elf_hwcap, MAX_CPU_FEATURES) __read_mostly; #ifdef CONFIG_COMPAT #define COMPAT_ELF_HWCAP_DEFAULT \ @@ -3098,14 +3098,12 @@ static bool __maybe_unused __system_matches_cap(unsigned int n) void cpu_set_feature(unsigned int num) { - WARN_ON(num >= MAX_CPU_FEATURES); - elf_hwcap |= BIT(num); + set_bit(num, elf_hwcap); } bool cpu_have_feature(unsigned int num) { - WARN_ON(num >= MAX_CPU_FEATURES); - return elf_hwcap & BIT(num); + return test_bit(num, elf_hwcap); } EXPORT_SYMBOL_GPL(cpu_have_feature); @@ -3116,12 +3114,12 @@ unsigned long cpu_get_elf_hwcap(void) * note that for userspace compatibility we guarantee that bits 62 * and 63 will always be returned as 0. */ - return lower_32_bits(elf_hwcap); + return elf_hwcap[0]; } unsigned long cpu_get_elf_hwcap2(void) { - return upper_32_bits(elf_hwcap); + return elf_hwcap[1]; } 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