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
This commit is contained in:
Mitchell Horne 2023-04-25 14:51:35 -03:00
parent f5d39047b0
commit c32b6c742f
9 changed files with 6 additions and 44 deletions

View File

@ -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

View File

@ -1,5 +1,4 @@
# $FreeBSD$
RISCV opt_global.h # For cpu RISCV to work
FPE opt_global.h
INTRNG opt_global.h

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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]);

View File

@ -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>

View File

@ -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)

View File

@ -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);