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 B23B9C43334 for ; Thu, 7 Jul 2022 10:38:52 +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=G1Z5KYgIlJRg5I O5LUYoUJKiCIhFHR3kNzJl19O6Ee9jANNE5jCX+Z42VQeGQ5yOxsKm5wt03okzZqccWVp9BDtKvKn KVHRRel9y70N3A5udff6HqqIOvtW2vWsGl/Pg0TyPaA/q6TilwE/l2i3UeY8xjt1UdUd/sdf34YC2 kAHDnLXnlibSEj7DZRsn1ISh2TkootQxunDfQTP0v5LiYo7wLxu9nNWOUApyXz69o71DJp+zJ2u9Q dcz3cj5VecvOlm9CNmsE6mWPQ3QtDsA5UGSwDajz+Up9ujAiBwgycg+yXl3jzT2abSQykZ5wi+OAc tjcLjDIMY5GjpQ42T0eA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9OtQ-00FbNs-OI; Thu, 07 Jul 2022 10:37:56 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1o9Ot9-00FbJ3-Hy for linux-arm-kernel@lists.infradead.org; Thu, 07 Jul 2022 10:37:41 +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 34BA4B82128; Thu, 7 Jul 2022 10:37:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7184AC341CD; Thu, 7 Jul 2022 10:37:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1657190256; bh=ioaKgR6/PaIx8d82WBbtnX2f2PT6EEhU4JgUswr7CiI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oYReGbqwYmgHDzMhDdejZ8L1OKF6FLM7CvGNR0csLqEzqf28NCWtz0MVokFjAR2t2 TXAETXSXDRXfGHvEdKJGzPcF0qukwfn36yT5ck1/u/f188FV+GNxD5pWrQRjHenAsP zChfzKnsQMoxwQcl1Z7DY0lGhEpZU+R2QJt9XIypI7pFZOLo+PUQBQCsiUrKMQDHXh VzXgax6xUdB0MCYFSoA/WMi3uqPUnjNFGWFnZlz5dyaBso88wksC6NWEuBLDx4tX6Z gSP1HQs8hsRX3Dw/77VZeSHDzo4cf+vHFTH00/i8rYPGE6QLI9N+6+32J1fKm/GBs8 +Lfy144NT4JxQ== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: Suzuki K Poulose , Szabolcs Nagy , linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v5 2/3] arm64/cpufeature: Store elf_hwcaps as a bitmap rather than unsigned long Date: Thu, 7 Jul 2022 11:36:31 +0100 Message-Id: <20220707103632.12745-3-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220707103632.12745-1-broonie@kernel.org> References: <20220707103632.12745-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/pANAwAKASTWi3JdVIfQAcsmYgBixrcswTHHbFCDaB7hRD5QSj9JMsCxTKMMp5/WhG+T RRT+zF6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYsa3LAAKCRAk1otyXVSH0AuJB/ 9nX4Wi6W5yZ2cYi8AdsulZ0vl1iPLZ4+ysJsAYZLKdZsUB+z+z+THc4lLN1hOU0VlWJNLV08l6e617 ofQ3zIUPoG5mWiltIzjYy7hQ+L9G5cu1tMoGjKSjc4RBLMi71xyy1Qc2diCRhTjlwsIZg+icrcO9NQ vH4WCcLlkc9QL2i3zd453vY773L47jktQ2LWCDuOFpiEvOsQzU+fOrqC44mTk864YzSaghsx9zAFFZ Vo5qt90TvfTVF10J3oAGyn8OqAt/HtWAuscS7RVDMPNUlydatbmBKXUzq9hjEvlIJxrK2gEg/YKvjM 8DPCIsEbJWXdX6bJCf2mSut2vk0Dam 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-20220707_033739_944917_3C2CD120 X-CRM114-Status: GOOD ( 15.62 ) 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