Skip to content

Commit 50724ef

Browse files
AndybnACTpalmer-dabbelt
authored andcommitted
riscv: hwcap: change ELF_HWCAP to a function
Using a function is flexible to represent ELF_HWCAP. So the kernel may encode hwcap reflecting supported hardware features just at the moment of the start of each program. This will be helpful when we introduce prctl/sysctl interface to control per-process availability of Vector extension in following patches. Programs started with V disabled should see V masked off in theirs ELF_HWCAP. Signed-off-by: Andy Chiu <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 0f4b825 commit 50724ef

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

arch/riscv/include/asm/elf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extern bool compat_elf_check_arch(Elf32_Ehdr *hdr);
6666
* via a bitmap that coorespends to each single-letter ISA extension. This is
6767
* essentially defunct, but will remain for compatibility with userspace.
6868
*/
69-
#define ELF_HWCAP (elf_hwcap & ((1UL << RISCV_ISA_EXT_BASE) - 1))
69+
#define ELF_HWCAP riscv_get_elf_hwcap()
7070
extern unsigned long elf_hwcap;
7171

7272
/*

arch/riscv/include/asm/hwcap.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161

6262
#include <linux/jump_label.h>
6363

64+
unsigned long riscv_get_elf_hwcap(void);
65+
6466
struct riscv_isa_ext_data {
6567
/* Name of the extension displayed to userspace via /proc/cpuinfo */
6668
char uprop[RISCV_ISA_EXT_NAME_LEN_MAX];

arch/riscv/kernel/cpufeature.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ void __init riscv_fill_hwcap(void)
293293
pr_info("riscv: ELF capabilities %s\n", print_str);
294294
}
295295

296+
unsigned long riscv_get_elf_hwcap(void)
297+
{
298+
return (elf_hwcap & ((1UL << RISCV_ISA_EXT_BASE) - 1));
299+
}
300+
296301
#ifdef CONFIG_RISCV_ALTERNATIVE
297302
/*
298303
* Alternative patch sites consider 48 bits when determining when to patch

0 commit comments

Comments
 (0)