* [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3
@ 2024-09-05 23:05 Mark Brown
2024-09-05 23:05 ` [PATCH RFC 1/2] binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4 Mark Brown
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Mark Brown @ 2024-09-05 23:05 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman,
Kees Cook, Catalin Marinas, Will Deacon, Jonathan Corbet
Cc: linux-fsdevel, linux-mm, linux-kernel, Yury Khrustalev,
Wilco Dijkstra, linux-arm-kernel, linux-doc, Mark Brown
Since arm64 has now used all of AT_HWCAP2 it needs to either start using
AT_HWCAP3 (which was recently added for PowerPC) or start allocating
bits 32..61 of AT_HWCAP first. Those are documented in elf_hwcaps.rst
as unused and in uapi/asm/hwcap.h as unallocated for potential use by
libc, glibc does currently use bits 62 and 63. This series has the code
for enabling AT_HWCAP3 as a reference.
We will at some point need to bite this bullet but we need to decide if
it's now or later. Given that we used the high bits of AT_HWCAP2 first
and AT_HWCAP3 is already defined it feels like that might be people's
preference, in order to minimise churn in serieses adding new HWCAPs
it'd be good to get consensus if that's the case or not.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
Mark Brown (2):
binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4
arm64: Support AT_HWCAP3
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 ++++++
fs/binfmt_elf.c | 6 ++++++
fs/binfmt_elf_fdpic.c | 6 ++++++
fs/compat_binfmt_elf.c | 15 +++++++++++++++
8 files changed, 47 insertions(+), 5 deletions(-)
---
base-commit: 7c626ce4bae1ac14f60076d00eafe71af30450ba
change-id: 20240905-arm64-elf-hwcap3-7709c5593d34
Best regards,
--
Mark Brown <broonie@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH RFC 1/2] binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4
2024-09-05 23:05 [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Mark Brown
@ 2024-09-05 23:05 ` Mark Brown
2024-09-12 16:28 ` Catalin Marinas
2024-09-05 23:05 ` [PATCH RFC 2/2] arm64: Support AT_HWCAP3 Mark Brown
2024-09-12 16:45 ` [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Catalin Marinas
2 siblings, 1 reply; 6+ messages in thread
From: Mark Brown @ 2024-09-05 23:05 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman,
Kees Cook, Catalin Marinas, Will Deacon, Jonathan Corbet
Cc: linux-fsdevel, linux-mm, linux-kernel, Yury Khrustalev,
Wilco Dijkstra, linux-arm-kernel, linux-doc, Mark Brown
AT_HWCAP3 and AT_HWCAP4 were recently defined for use on PowerPC in commit
3281366a8e79 ("uapi/auxvec: Define AT_HWCAP3 and AT_HWCAP4 aux vector,
entries"). Since we want to start using AT_HWCAP3 on arm64 add support for
exposing both these new hwcaps via binfmt_elf.
Signed-off-by: Mark Brown <broonie@kernel.org>
---
fs/binfmt_elf.c | 6 ++++++
fs/binfmt_elf_fdpic.c | 6 ++++++
fs/compat_binfmt_elf.c | 15 +++++++++++++++
3 files changed, 27 insertions(+)
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index 19fa49cd9907..32e45e65de8f 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -257,6 +257,12 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec,
NEW_AUX_ENT(AT_RANDOM, (elf_addr_t)(unsigned long)u_rand_bytes);
#ifdef ELF_HWCAP2
NEW_AUX_ENT(AT_HWCAP2, ELF_HWCAP2);
+#endif
+#ifdef ELF_HWCAP3
+ NEW_AUX_ENT(AT_HWCAP3, ELF_HWCAP3);
+#endif
+#ifdef ELF_HWCAP4
+ NEW_AUX_ENT(AT_HWCAP3, ELF_HWCAP4);
#endif
NEW_AUX_ENT(AT_EXECFN, bprm->exec);
if (k_platform) {
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
index 28a3439f163a..9365f48598a1 100644
--- a/fs/binfmt_elf_fdpic.c
+++ b/fs/binfmt_elf_fdpic.c
@@ -620,6 +620,12 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
NEW_AUX_ENT(AT_HWCAP, ELF_HWCAP);
#ifdef ELF_HWCAP2
NEW_AUX_ENT(AT_HWCAP2, ELF_HWCAP2);
+#endif
+#ifdef ELF_HWCAP3
+ NEW_AUX_ENT(AT_HWCAP3, ELF_HWCAP3);
+#endif
+#ifdef ELF_HWCAP3
+ NEW_AUX_ENT(AT_HWCAP4, ELF_HWCAP4);
#endif
NEW_AUX_ENT(AT_PAGESZ, PAGE_SIZE);
NEW_AUX_ENT(AT_CLKTCK, CLOCKS_PER_SEC);
diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
index 8f0af4f62631..0a219e26692a 100644
--- a/fs/compat_binfmt_elf.c
+++ b/fs/compat_binfmt_elf.c
@@ -80,6 +80,21 @@
#define ELF_HWCAP2 COMPAT_ELF_HWCAP2
#endif
+#ifdef COMPAT_ELF_HWCAP3
+#undef ELF_HWCAP3
+#define ELF_HWCAP3 COMPAT_ELF_HWCAP3
+#endif
+
+#ifdef COMPAT_ELF_HWCAP3
+#undef ELF_HWCAP3
+#define ELF_HWCAP3 COMPAT_ELF_HWCAP3
+#endif
+
+#ifdef COMPAT_ELF_HWCAP4
+#undef ELF_HWCAP4
+#define ELF_HWCAP4 COMPAT_ELF_HWCAP4
+#endif
+
#ifdef COMPAT_ARCH_DLINFO
#undef ARCH_DLINFO
#define ARCH_DLINFO COMPAT_ARCH_DLINFO
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH RFC 2/2] arm64: Support AT_HWCAP3
2024-09-05 23:05 [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Mark Brown
2024-09-05 23:05 ` [PATCH RFC 1/2] binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4 Mark Brown
@ 2024-09-05 23:05 ` Mark Brown
2024-09-12 16:45 ` [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Catalin Marinas
2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2024-09-05 23:05 UTC (permalink / raw)
To: Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman,
Kees Cook, Catalin Marinas, Will Deacon, Jonathan Corbet
Cc: linux-fsdevel, linux-mm, linux-kernel, Yury Khrustalev,
Wilco Dijkstra, linux-arm-kernel, linux-doc, Mark Brown
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 <broonie@kernel.org>
---
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 <asm/hwcap.h>
#include <asm/sysreg.h>
-#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)
{
/*
--
2.39.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH RFC 1/2] binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4
2024-09-05 23:05 ` [PATCH RFC 1/2] binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4 Mark Brown
@ 2024-09-12 16:28 ` Catalin Marinas
0 siblings, 0 replies; 6+ messages in thread
From: Catalin Marinas @ 2024-09-12 16:28 UTC (permalink / raw)
To: Mark Brown
Cc: Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman,
Kees Cook, Will Deacon, Jonathan Corbet, linux-fsdevel, linux-mm,
linux-kernel, Yury Khrustalev, Wilco Dijkstra, linux-arm-kernel,
linux-doc
On Fri, Sep 06, 2024 at 12:05:24AM +0100, Mark Brown wrote:
> diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
> index 19fa49cd9907..32e45e65de8f 100644
> --- a/fs/binfmt_elf.c
> +++ b/fs/binfmt_elf.c
> @@ -257,6 +257,12 @@ create_elf_tables(struct linux_binprm *bprm, const struct elfhdr *exec,
> NEW_AUX_ENT(AT_RANDOM, (elf_addr_t)(unsigned long)u_rand_bytes);
> #ifdef ELF_HWCAP2
> NEW_AUX_ENT(AT_HWCAP2, ELF_HWCAP2);
> +#endif
> +#ifdef ELF_HWCAP3
> + NEW_AUX_ENT(AT_HWCAP3, ELF_HWCAP3);
> +#endif
> +#ifdef ELF_HWCAP4
> + NEW_AUX_ENT(AT_HWCAP3, ELF_HWCAP4);
s/HWCAP3/HWCAP4/ for the last line.
> #endif
> NEW_AUX_ENT(AT_EXECFN, bprm->exec);
> if (k_platform) {
> diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c
> index 28a3439f163a..9365f48598a1 100644
> --- a/fs/binfmt_elf_fdpic.c
> +++ b/fs/binfmt_elf_fdpic.c
> @@ -620,6 +620,12 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm,
> NEW_AUX_ENT(AT_HWCAP, ELF_HWCAP);
> #ifdef ELF_HWCAP2
> NEW_AUX_ENT(AT_HWCAP2, ELF_HWCAP2);
> +#endif
> +#ifdef ELF_HWCAP3
> + NEW_AUX_ENT(AT_HWCAP3, ELF_HWCAP3);
> +#endif
> +#ifdef ELF_HWCAP3
> + NEW_AUX_ENT(AT_HWCAP4, ELF_HWCAP4);
Same here with the ifdef.
> #endif
> NEW_AUX_ENT(AT_PAGESZ, PAGE_SIZE);
> NEW_AUX_ENT(AT_CLKTCK, CLOCKS_PER_SEC);
> diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
> index 8f0af4f62631..0a219e26692a 100644
> --- a/fs/compat_binfmt_elf.c
> +++ b/fs/compat_binfmt_elf.c
> @@ -80,6 +80,21 @@
> #define ELF_HWCAP2 COMPAT_ELF_HWCAP2
> #endif
>
> +#ifdef COMPAT_ELF_HWCAP3
> +#undef ELF_HWCAP3
> +#define ELF_HWCAP3 COMPAT_ELF_HWCAP3
> +#endif
> +
> +#ifdef COMPAT_ELF_HWCAP3
> +#undef ELF_HWCAP3
> +#define ELF_HWCAP3 COMPAT_ELF_HWCAP3
> +#endif
Duplicate hunk.
--
Catalin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3
2024-09-05 23:05 [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Mark Brown
2024-09-05 23:05 ` [PATCH RFC 1/2] binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4 Mark Brown
2024-09-05 23:05 ` [PATCH RFC 2/2] arm64: Support AT_HWCAP3 Mark Brown
@ 2024-09-12 16:45 ` Catalin Marinas
2024-09-12 17:29 ` Mark Brown
2 siblings, 1 reply; 6+ messages in thread
From: Catalin Marinas @ 2024-09-12 16:45 UTC (permalink / raw)
To: Mark Brown
Cc: Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman,
Kees Cook, Will Deacon, Jonathan Corbet, linux-fsdevel, linux-mm,
linux-kernel, Yury Khrustalev, Wilco Dijkstra, linux-arm-kernel,
linux-doc
On Fri, Sep 06, 2024 at 12:05:23AM +0100, Mark Brown wrote:
> Since arm64 has now used all of AT_HWCAP2 it needs to either start using
> AT_HWCAP3 (which was recently added for PowerPC) or start allocating
> bits 32..61 of AT_HWCAP first. Those are documented in elf_hwcaps.rst
> as unused and in uapi/asm/hwcap.h as unallocated for potential use by
> libc, glibc does currently use bits 62 and 63. This series has the code
> for enabling AT_HWCAP3 as a reference.
>
> We will at some point need to bite this bullet but we need to decide if
> it's now or later. Given that we used the high bits of AT_HWCAP2 first
> and AT_HWCAP3 is already defined it feels like that might be people's
> preference, in order to minimise churn in serieses adding new HWCAPs
> it'd be good to get consensus if that's the case or not.
Since the arm64 ABI documents that only bits 62 and 63 from AT_HWCAP are
reserved for glibc, I think we should start using the remaining 30 bits
of AT_HWCAP first before going for AT_HWCAP3. I'm sure we'll go through
them quickly enough, so these two patches will have to be merged at some
point.
We'll need an Ack from the (arm64) glibc people on the GCS patch series
if we are going for bits 32+ in AT_HWCAP.
--
Catalin
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3
2024-09-12 16:45 ` [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Catalin Marinas
@ 2024-09-12 17:29 ` Mark Brown
0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2024-09-12 17:29 UTC (permalink / raw)
To: Catalin Marinas
Cc: Alexander Viro, Christian Brauner, Jan Kara, Eric Biederman,
Kees Cook, Will Deacon, Jonathan Corbet, linux-fsdevel, linux-mm,
linux-kernel, Yury Khrustalev, Wilco Dijkstra, linux-arm-kernel,
linux-doc
[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]
On Thu, Sep 12, 2024 at 05:45:45PM +0100, Catalin Marinas wrote:
> On Fri, Sep 06, 2024 at 12:05:23AM +0100, Mark Brown wrote:
> > We will at some point need to bite this bullet but we need to decide if
> > it's now or later. Given that we used the high bits of AT_HWCAP2 first
> > and AT_HWCAP3 is already defined it feels like that might be people's
> > preference, in order to minimise churn in serieses adding new HWCAPs
> > it'd be good to get consensus if that's the case or not.
> Since the arm64 ABI documents that only bits 62 and 63 from AT_HWCAP are
> reserved for glibc, I think we should start using the remaining 30 bits
> of AT_HWCAP first before going for AT_HWCAP3. I'm sure we'll go through
> them quickly enough, so these two patches will have to be merged at some
> point.
That does seem like the easiest path for everyone, assuming that there
hasn't been any usage of the remaining spare bits we weren't aware of.
> We'll need an Ack from the (arm64) glibc people on the GCS patch series
> if we are going for bits 32+ in AT_HWCAP.
Yup, hopefully Yuri or Wilco can confirm prior to reposting. It does
seem like it'd be good for glibc to add whatever support is needed for
HWCAP3/4 now anyway so that whenever we do burn through the remaining
bits on AT_HWCAP there's less friction as we start using them.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-09-12 17:29 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-05 23:05 [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Mark Brown
2024-09-05 23:05 ` [PATCH RFC 1/2] binfmt_elf: Wire up AT_HWCAP3 at AT_HWCAP4 Mark Brown
2024-09-12 16:28 ` Catalin Marinas
2024-09-05 23:05 ` [PATCH RFC 2/2] arm64: Support AT_HWCAP3 Mark Brown
2024-09-12 16:45 ` [PATCH RFC 0/2] arm64: Add infrastructure for use of AT_HWCAP3 Catalin Marinas
2024-09-12 17:29 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).