aboutsummaryrefslogtreecommitdiff
path: root/sys/riscv/riscv
diff options
context:
space:
mode:
authorJohn Baldwin <jhb@FreeBSD.org>2020-04-27 17:55:40 +0000
committerJohn Baldwin <jhb@FreeBSD.org>2020-04-27 17:55:40 +0000
commit61bbe53c2d4a653d9977e32d3e920a4cbdce77f5 (patch)
treed201f053263e3b0331bdf8b733e01369bf597b3b /sys/riscv/riscv
parent3da4d19be4131b6b6e45d80e5d83e9b508cb064b (diff)
downloadsrc-61bbe53c2d4a653d9977e32d3e920a4cbdce77f5.tar.gz
src-61bbe53c2d4a653d9977e32d3e920a4cbdce77f5.zip
Improve MACHINE_ARCH handling for hard vs soft-float on RISC-V.
For userland, MACHINE_ARCH reflects the current ABI via preprocessor directives. For the kernel, the hw.machine_arch sysctl uses the ELF header flags of the current process to select the correct MACHINE_ARCH value. Reviewed by: imp, kp Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24543
Notes
Notes: svn path=/head/; revision=360387
Diffstat (limited to 'sys/riscv/riscv')
-rw-r--r--sys/riscv/riscv/elf_machdep.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/sys/riscv/riscv/elf_machdep.c b/sys/riscv/riscv/elf_machdep.c
index 3c0852bede68..e2c58928fc9e 100644
--- a/sys/riscv/riscv/elf_machdep.c
+++ b/sys/riscv/riscv/elf_machdep.c
@@ -58,6 +58,8 @@ __FBSDID("$FreeBSD$");
#include <machine/elf.h>
#include <machine/md_var.h>
+static const char *riscv_machine_arch(struct proc *p);
+
u_long elf_hwcap;
struct sysentvec elf64_freebsd_sysvec = {
@@ -94,9 +96,20 @@ struct sysentvec elf64_freebsd_sysvec = {
.sv_thread_detach = NULL,
.sv_trap = NULL,
.sv_hwcap = &elf_hwcap,
+ .sv_machine_arch = riscv_machine_arch,
};
INIT_SYSENTVEC(elf64_sysvec, &elf64_freebsd_sysvec);
+static const char *
+riscv_machine_arch(struct proc *p)
+{
+
+ if ((p->p_elf_flags & EF_RISCV_FLOAT_ABI_MASK) ==
+ EF_RISCV_FLOAT_ABI_SOFT)
+ return (MACHINE_ARCH "sf");
+ return (MACHINE_ARCH);
+}
+
static Elf64_Brandinfo freebsd_brand_info = {
.brand = ELFOSABI_FREEBSD,
.machine = EM_RISCV,