git: c32b6c742f36 - main - riscv: retire the FPE kernel option
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 02 May 2023 18:04:18 UTC
The branch main has been updated by mhorne: URL: https://cgit.FreeBSD.org/src/commit/?id=c32b6c742f36225ca0a9d2e7a704f959875e37b3 commit c32b6c742f36225ca0a9d2e7a704f959875e37b3 Author: Mitchell Horne <mhorne@FreeBSD.org> AuthorDate: 2023-04-25 17:51:35 +0000 Commit: Mitchell Horne <mhorne@FreeBSD.org> CommitDate: 2023-05-02 18:01:31 +0000 riscv: retire the FPE kernel option We always build the kernel floating point support. Now that the riscv64sf userspace variant has been removed the option is required for correct operation. Reviewed by: jhb Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D39851 --- sys/conf/kern.mk | 7 +++---- sys/conf/options.riscv | 1 - sys/riscv/conf/GENERIC | 1 - sys/riscv/conf/NOTES | 1 - sys/riscv/riscv/exec_machdep.c | 15 +-------------- sys/riscv/riscv/identcpu.c | 2 -- sys/riscv/riscv/machdep.c | 5 +---- sys/riscv/riscv/swtch.S | 14 +------------- sys/riscv/riscv/trap.c | 4 ---- 9 files changed, 6 insertions(+), 44 deletions(-) diff --git a/sys/conf/kern.mk b/sys/conf/kern.mk index 1a1251f670e1..245f81e6ed71 100644 --- a/sys/conf/kern.mk +++ b/sys/conf/kern.mk @@ -153,10 +153,9 @@ INLINE_LIMIT?= 8000 # # For RISC-V we specify the soft-float ABI (lp64) to avoid the use of floating -# point registers within the kernel. However, for kernels supporting hardware -# float (FPE), we have to include that in the march so we can have limited -# floating point support in context switching needed for that. This is different -# than userland where we use a hard-float ABI (lp64d). +# point registers within the kernel. However, we include the F and D extensions +# in -march so we can have limited floating point support in context switching +# code. This is different than userland where we use a hard-float ABI (lp64d). # # We also specify the "medium" code model, which generates code suitable for a # 2GiB addressing range located at any offset, allowing modules to be located diff --git a/sys/conf/options.riscv b/sys/conf/options.riscv index 9e48f73fba33..964a2f07173c 100644 --- a/sys/conf/options.riscv +++ b/sys/conf/options.riscv @@ -1,5 +1,4 @@ # $FreeBSD$ RISCV opt_global.h # For cpu RISCV to work -FPE opt_global.h INTRNG opt_global.h diff --git a/sys/riscv/conf/GENERIC b/sys/riscv/conf/GENERIC index 49e3f07c0f96..04645ec9bf90 100644 --- a/sys/riscv/conf/GENERIC +++ b/sys/riscv/conf/GENERIC @@ -72,7 +72,6 @@ options MAC # TrustedBSD MAC Framework options KDTRACE_FRAME # Ensure frames are compiled in options KDTRACE_HOOKS # Kernel DTrace hooks options DDB_CTF # Kernel ELF linker loads CTF data -options FPE # Floating-point extension support options RACCT # Resource accounting framework options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default options RCTL # Resource limits diff --git a/sys/riscv/conf/NOTES b/sys/riscv/conf/NOTES index f36e6283433d..d3ff441a95d6 100644 --- a/sys/riscv/conf/NOTES +++ b/sys/riscv/conf/NOTES @@ -16,7 +16,6 @@ options PRINTF_BUFR_SIZE=128 # Prevent printf output being interspersed. options KDTRACE_FRAME # Ensure frames are compiled in options KDTRACE_HOOKS # Kernel DTrace hooks options DDB_CTF # Kernel ELF linker loads CTF data -options FPE # Floating-point extension support options RACCT_DEFAULT_TO_DISABLED # Set kern.racct.enable=0 by default # RISC-V SBI console diff --git a/sys/riscv/riscv/exec_machdep.c b/sys/riscv/riscv/exec_machdep.c index ab79c0384eb3..e61bce628602 100644 --- a/sys/riscv/riscv/exec_machdep.c +++ b/sys/riscv/riscv/exec_machdep.c @@ -58,6 +58,7 @@ __FBSDID("$FreeBSD$"); #include <sys/ucontext.h> #include <machine/cpu.h> +#include <machine/fpe.h> #include <machine/kdb.h> #include <machine/pcb.h> #include <machine/pte.h> @@ -70,10 +71,6 @@ __FBSDID("$FreeBSD$"); #include <vm/pmap.h> #include <vm/vm_map.h> -#ifdef FPE -#include <machine/fpe.h> -#endif - static void get_fpcontext(struct thread *td, mcontext_t *mcp); static void set_fpcontext(struct thread *td, mcontext_t *mcp); @@ -123,7 +120,6 @@ set_regs(struct thread *td, struct reg *regs) int fill_fpregs(struct thread *td, struct fpreg *regs) { -#ifdef FPE struct pcb *pcb; pcb = td->td_pcb; @@ -139,7 +135,6 @@ fill_fpregs(struct thread *td, struct fpreg *regs) memcpy(regs->fp_x, pcb->pcb_x, sizeof(regs->fp_x)); regs->fp_fcsr = pcb->pcb_fcsr; } else -#endif memset(regs, 0, sizeof(*regs)); return (0); @@ -148,7 +143,6 @@ fill_fpregs(struct thread *td, struct fpreg *regs) int set_fpregs(struct thread *td, struct fpreg *regs) { -#ifdef FPE struct trapframe *frame; struct pcb *pcb; @@ -160,7 +154,6 @@ set_fpregs(struct thread *td, struct fpreg *regs) pcb->pcb_fpflags |= PCB_FP_STARTED; frame->tf_sstatus &= ~SSTATUS_FS_MASK; frame->tf_sstatus |= SSTATUS_FS_CLEAN; -#endif return (0); } @@ -274,7 +267,6 @@ set_mcontext(struct thread *td, mcontext_t *mcp) static void get_fpcontext(struct thread *td, mcontext_t *mcp) { -#ifdef FPE struct pcb *curpcb; critical_enter(); @@ -300,20 +292,16 @@ get_fpcontext(struct thread *td, mcontext_t *mcp) } critical_exit(); -#endif } static void set_fpcontext(struct thread *td, mcontext_t *mcp) { -#ifdef FPE struct pcb *curpcb; -#endif td->td_frame->tf_sstatus &= ~SSTATUS_FS_MASK; td->td_frame->tf_sstatus |= SSTATUS_FS_OFF; -#ifdef FPE critical_enter(); if ((mcp->mc_flags & _MC_FP_VALID) != 0) { @@ -327,7 +315,6 @@ set_fpcontext(struct thread *td, mcontext_t *mcp) } critical_exit(); -#endif } int diff --git a/sys/riscv/riscv/identcpu.c b/sys/riscv/riscv/identcpu.c index 5f10ec6358ae..c57a22c1b51a 100644 --- a/sys/riscv/riscv/identcpu.c +++ b/sys/riscv/riscv/identcpu.c @@ -203,10 +203,8 @@ parse_riscv_isa(char *isa, int len, u_long *hwcapp) switch(isa[i]) { case 'a': case 'c': -#ifdef FPE case 'd': case 'f': -#endif case 'i': case 'm': hwcap |= HWCAP_ISA_BIT(isa[i]); diff --git a/sys/riscv/riscv/machdep.c b/sys/riscv/riscv/machdep.c index 0821a29d11c1..6b8dcb647162 100644 --- a/sys/riscv/riscv/machdep.c +++ b/sys/riscv/riscv/machdep.c @@ -81,6 +81,7 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_pager.h> #include <machine/cpu.h> +#include <machine/fpe.h> #include <machine/intr.h> #include <machine/kdb.h> #include <machine/machdep.h> @@ -92,10 +93,6 @@ __FBSDID("$FreeBSD$"); #include <machine/trap.h> #include <machine/vmparam.h> -#ifdef FPE -#include <machine/fpe.h> -#endif - #ifdef FDT #include <contrib/libfdt/libfdt.h> #include <dev/fdt/fdt_common.h> diff --git a/sys/riscv/riscv/swtch.S b/sys/riscv/riscv/swtch.S index d2e23784c994..5b878ae2fb30 100644 --- a/sys/riscv/riscv/swtch.S +++ b/sys/riscv/riscv/swtch.S @@ -42,7 +42,6 @@ __FBSDID("$FreeBSD$"); -#ifdef FPE .macro __fpe_state_save p /* * Enable FPE usage in supervisor mode, @@ -204,8 +203,7 @@ ENTRY(fpe_state_clear) ret END(fpe_state_clear) -#endif /* FPE */ - + /* * void cpu_throw(struct thread *old __unused, struct thread *new) */ @@ -240,7 +238,6 @@ ENTRY(cpu_throw) ld s10, (PCB_S + 10 * 8)(x13) ld s11, (PCB_S + 11 * 8)(x13) -#ifdef FPE /* Is FPE enabled for new thread? */ ld t0, TD_FRAME(a0) ld t1, (TF_SSTATUS)(t0) @@ -251,8 +248,6 @@ ENTRY(cpu_throw) /* Restore registers. */ __fpe_state_load x13 1: -#endif - ret END(cpu_throw) @@ -292,7 +287,6 @@ ENTRY(cpu_switch) sd s10, (PCB_S + 10 * 8)(x13) sd s11, (PCB_S + 11 * 8)(x13) -#ifdef FPE /* * Is FPE enabled and is it in dirty state * for the old thread? @@ -313,7 +307,6 @@ ENTRY(cpu_switch) __fpe_state_save x13 1: -#endif /* Activate the new thread's pmap */ mv s0, a0 @@ -355,7 +348,6 @@ ENTRY(cpu_switch) ld s10, (PCB_S + 10 * 8)(x13) ld s11, (PCB_S + 11 * 8)(x13) -#ifdef FPE /* Is FPE enabled for new thread? */ ld t0, TD_FRAME(a1) ld t1, (TF_SSTATUS)(t0) @@ -366,8 +358,6 @@ ENTRY(cpu_switch) /* Restore registers. */ __fpe_state_load x13 1: -#endif - ret END(cpu_switch) @@ -466,8 +456,6 @@ ENTRY(savectx) sd s10, (PCB_S + 10 * 8)(a0) sd s11, (PCB_S + 11 * 8)(a0) -#ifdef FPE __fpe_state_save a0 -#endif ret END(savectx) diff --git a/sys/riscv/riscv/trap.c b/sys/riscv/riscv/trap.c index 39e0fbb1d5bd..11ecfa702054 100644 --- a/sys/riscv/riscv/trap.c +++ b/sys/riscv/riscv/trap.c @@ -57,9 +57,7 @@ __FBSDID("$FreeBSD$"); #include <vm/vm_param.h> #include <vm/vm_extern.h> -#ifdef FPE #include <machine/fpe.h> -#endif #include <machine/frame.h> #include <machine/pcb.h> #include <machine/pcpu.h> @@ -395,7 +393,6 @@ do_trap_user(struct trapframe *frame) ecall_handler(); break; case SCAUSE_ILLEGAL_INSTRUCTION: -#ifdef FPE if ((pcb->pcb_fpflags & PCB_FP_STARTED) == 0) { /* * May be a FPE trap. Enable FPE usage @@ -407,7 +404,6 @@ do_trap_user(struct trapframe *frame) pcb->pcb_fpflags |= PCB_FP_STARTED; break; } -#endif call_trapsignal(td, SIGILL, ILL_ILLTRP, (void *)frame->tf_sepc, exception); userret(td, frame);