RISC-V: export the ISA string of the running machine in

A patch from »Expose the isa-string via the AT_BASE_PLATFORM aux vector« in state Obsolete for linux-kernel

From: Heiko Stuebner <heiko.stuebner@...> Date: Wed, 12 Apr 2023 17:17:30 +0200

Commit-Message

Already defined aux-vectors regarding the machine type are AT_PLATFORM and AT_BASE_PLATFORM. PPC already uses AT_BASE_PLATFORM to identify the real platform the system is running on, so do a similar thing on RISC-V and export the ISA string of the running machine via this aux-vector element. This way userspace can possibly adapt to extensions that allow it to run certain loads more performantly. Signed-off-by: Heiko Stuebner <heiko.stuebner@...>

Patch-Comment

arch/riscv/include/asm/elf.h | 10 ++++++++++ arch/riscv/kernel/cpu.c | 12 ++++++++++++ 2 files changed, 22 insertions(+)

Statistics

  • 22 lines added
  • 0 lines removed

Changes

------------------------- arch/riscv/include/asm/elf.h -------------------------
index 30e7d2455960..820ef627e83d 100644
@@ -78,6 +78,16 @@ extern unsigned long elf_hwcap;
#define COMPAT_ELF_PLATFORM (NULL)
+/*
+ * ELF_PLATFORM indicates the ISA supported by the platform, but has
+ * special meaning to ld.so .
+ * Expose the ISA string including all usable extensions via
+ * ELF_BASE_PLATFORM instead and allow userspace to adapt to them
+ * if needed.
+ */
+#define ELF_BASE_PLATFORM (riscv_base_platform)
+extern const char *riscv_base_platform;
+
#ifdef CONFIG_MMU
#define ARCH_DLINFO \
do { \
--------------------------- arch/riscv/kernel/cpu.c ----------------------------
index 06c2f587a176..71770563199f 100644
@@ -118,8 +118,12 @@ static int riscv_cpuinfo_starting(unsigned int cpu)
return 0;
}
+const char *riscv_base_platform = NULL;
+static char *riscv_create_isa_string(void);
+
static int __init riscv_cpuinfo_init(void)
{
+ char *isa_str;
int ret;
ret = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "riscv/cpuinfo:starting",
@@ -129,6 +133,14 @@ static int __init riscv_cpuinfo_init(void)
return ret;
}
+ /*
+ * Create the isa-string with the common set of extensions over
+ * all harts, to expose as AT_BASE_PLATFORM in the aux vector.
+ */
+ isa_str = riscv_create_isa_string();
+ if (!IS_ERR(isa_str))
+ riscv_base_platform = isa_str;
+
return 0;
}
arch_initcall(riscv_cpuinfo_init);
 
 

Recent Patches

About Us

Sed lacus. Donec lectus. Nullam pretium nibh ut turpis. Nam bibendum. In nulla tortor, elementum vel, tempor at, varius non, purus. Mauris vitae nisl nec metus placerat consectetuer.

Read More...