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: 13793077 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91951CE7AA1 for ; Thu, 5 Sep 2024 23:07:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FFB36B0089; Thu, 5 Sep 2024 19:07:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1B2566B0092; Thu, 5 Sep 2024 19:07:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 006B26B0093; Thu, 5 Sep 2024 19:07:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id D1AFF6B0089 for ; Thu, 5 Sep 2024 19:07:02 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6495780CCC for ; Thu, 5 Sep 2024 23:07:02 +0000 (UTC) X-FDA: 82532221884.27.645970A Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf19.hostedemail.com (Postfix) with ESMTP id A14BD1A000D for ; Thu, 5 Sep 2024 23:07:00 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GhPgpfKb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725577595; a=rsa-sha256; cv=none; b=7JNQk9NFywehMs9yBguBqTORVGQhbdrAqHFhe1sa8y+QfBfKaYRXQEXTjaK5vuvYodSTzr mCkLt7qgBAb4xHYQFRflLcrm8ka5DDSw4BecgNwfKGQKKTSfK3l767cZtFfdjs+bb+iW9M XYhAdlGTpLneJDasht+odlUZT9T7p2E= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=GhPgpfKb; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of broonie@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=broonie@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725577595; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=RzJmVHoxTOkqVv2oPM0AZ9Ba2lKqM75VQ4Cr65YXulE=; b=mTmgTuONMto1JSUEKeRto3VlzLPqXXT7FI/zki9HFq5tr9lJRzn+8p19SdmeS+bBtFgJLL XiyDHIdboFOaoB6v+Zsen6wbhEcgi2hU025fuuuqr9SsP0QCA2q6+yQmmXNNBhA7UdSePY eoog7dLZa1zReA1hFgubDcEguSv17og= 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-Rspam-User: X-Rspamd-Queue-Id: A14BD1A000D X-Rspamd-Server: rspam01 X-Stat-Signature: 83q37wpdcg15mbga1d3oiapgxszjoqbj X-HE-Tag: 1725577620-471494 X-HE-Meta: U2FsdGVkX1/JVOhQgmKRE+69S9Jc920N3a9m+crrzwmvn2QRvu9l8xgpOKK9a516LdrFXdIjD58v/tVnQg3//6SmKSWqKKSyMqeVRK4gDa73dJrOCU8F3AoFYHAuwopm5D0kcjseWHtdpqJyIIYdsafl5OHx18Mupgk6d/BmZ3rnejz+DsjWXbtkwH7IlZMIlgwREAnu/uKNnhTyfWJoiOa0YHGP8lHPrtMX0BHA8g0sVGXXDK6ox9b4WQERwj4KdZY/bW4psYz+CFSuI8gQH9ABmmP89R5U5uqgywqhyyMhCY+KkQuVL98o9Wis4ZmEPUuVJp/a/uCmv2saC/mzTVVhg3YoiUtAkSIGYZRl+dEGZxW08LpRRqd1K2j0/uAIl1pmJJuupAjDGygY+JfzsURUUA1q1jKWfcY5R66ciX29RFmNHPGheAzrsnrJjzhNBc5lh6EVIGy3Qi35bwoJ2RKt6nSwyfvQt0TSyX5hNSGi4e8gQGijFa5sz4fUDfXavYp+LhNdrzdhccl0JdF351vwn4xNiF8J60UnrhNADwMiRmgUUHPHcGrKNPUzSx6Kf6evO6YAbNhXSzjkQ+LDM9xb0yMvaZ+hx8LgBlO1pntAdLjvQYApZMXxGG1Tjm9T0MiDU61tBa12d9hKt7zjVUyi20g7HabHaxBwyfchS0BAop6JcZ2g51UXtrXlrxQlYx6N4erZfP2azwaO3vUrq9HG1zPrTDCtZCveNbsDjmE9ztT7kJ08egI1rQNa1SdIbnoIxulK9udxCPhmuhHe76Sg8Q/6SIfb6448ik9XT3fErxmz9CUoMmT/onGXd9UjV7BPshMTd7dflH/8t4wJ0XsSKmUXVYARsP/AvVpqiU7gFuBvgSsvxiy6IQor8hokBtBvZ2IQX5DuNxBG9XJ9AojYWEeUgONcR5R3eKUh6yiYCGgwULJa3u1UbEt9se99gKmAbeSwsKmFg5O4Wau z9k6GMpC QdYHVxpH+wGZWbr6OtNuzd3bhReMdewl+cL/SWQMy+Ne4KWA6TvhGiRpjgIZc7u5iWnWSkndghgQOFFoq4/OHRO4MGFsbKzcqEwMAU2N047VZnNHKFX6CxCxrP9BQ+IQ//ni8/cIUzivildblIx2TLcZ3PQ71m8HAH50W9KSU+p7rGy6VZD0lddaILChUcom76Yil8ZwPIH3h6z8zpTqgrB1EyaSMJ3GV4u5oHtfmNpkzk+78WOdArCwApL53t7aPSeYKku3+5OIz0iE9EmTPFsCGcd/t8775k1yG X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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) { /*