aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/riscv/Kconfig9
-rw-r--r--arch/riscv/Makefile2
-rw-r--r--arch/riscv/include/asm/switch_to.h10
-rw-r--r--arch/riscv/kernel/Makefile2
-rw-r--r--arch/riscv/kernel/process.c4
-rw-r--r--arch/riscv/kernel/signal.c5
6 files changed, 29 insertions, 3 deletions
diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig
index a344980287a5..a63f9dbb4706 100644
--- a/arch/riscv/Kconfig
+++ b/arch/riscv/Kconfig
@@ -208,6 +208,15 @@ config RISCV_BASE_PMU
208 208
209endmenu 209endmenu
210 210
211config FPU
212 bool "FPU support"
213 default y
214 help
215 Say N here if you want to disable all floating-point related procedure
216 in the kernel.
217
218 If you don't know what to do here, say Y.
219
211endmenu 220endmenu
212 221
213menu "Kernel type" 222menu "Kernel type"
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 01393e1b2921..901770fc9bd2 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -44,7 +44,7 @@ KBUILD_CFLAGS += -Wall
44riscv-march-$(CONFIG_ARCH_RV32I) := rv32im 44riscv-march-$(CONFIG_ARCH_RV32I) := rv32im
45riscv-march-$(CONFIG_ARCH_RV64I) := rv64im 45riscv-march-$(CONFIG_ARCH_RV64I) := rv64im
46riscv-march-$(CONFIG_RISCV_ISA_A) := $(riscv-march-y)a 46riscv-march-$(CONFIG_RISCV_ISA_A) := $(riscv-march-y)a
47riscv-march-y := $(riscv-march-y)fd 47riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
48riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c 48riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
49KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) 49KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
50KBUILD_AFLAGS += -march=$(riscv-march-y) 50KBUILD_AFLAGS += -march=$(riscv-march-y)
diff --git a/arch/riscv/include/asm/switch_to.h b/arch/riscv/include/asm/switch_to.h
index dd6b05bff75b..093050b03543 100644
--- a/arch/riscv/include/asm/switch_to.h
+++ b/arch/riscv/include/asm/switch_to.h
@@ -18,6 +18,7 @@
18#include <asm/ptrace.h> 18#include <asm/ptrace.h>
19#include <asm/csr.h> 19#include <asm/csr.h>
20 20
21#ifdef CONFIG_FPU
21extern void __fstate_save(struct task_struct *save_to); 22extern void __fstate_save(struct task_struct *save_to);
22extern void __fstate_restore(struct task_struct *restore_from); 23extern void __fstate_restore(struct task_struct *restore_from);
23 24
@@ -55,6 +56,15 @@ static inline void __switch_to_aux(struct task_struct *prev,
55 fstate_restore(next, task_pt_regs(next)); 56 fstate_restore(next, task_pt_regs(next));
56} 57}
57 58
59#define DEFAULT_SSTATUS (SR_SPIE | SR_FS_INITIAL)
60
61#else
62#define fstate_save(task, regs) do { } while (0)
63#define fstate_restore(task, regs) do { } while (0)
64#define __switch_to_aux(__prev, __next) do { } while (0)
65#define DEFAULT_SSTATUS (SR_SPIE | SR_FS_OFF)
66#endif
67
58extern struct task_struct *__switch_to(struct task_struct *, 68extern struct task_struct *__switch_to(struct task_struct *,
59 struct task_struct *); 69 struct task_struct *);
60 70
diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile
index bd433efd915e..f13f7f276639 100644
--- a/arch/riscv/kernel/Makefile
+++ b/arch/riscv/kernel/Makefile
@@ -13,7 +13,6 @@ extra-y += vmlinux.lds
13obj-y += cpu.o 13obj-y += cpu.o
14obj-y += cpufeature.o 14obj-y += cpufeature.o
15obj-y += entry.o 15obj-y += entry.o
16obj-y += fpu.o
17obj-y += irq.o 16obj-y += irq.o
18obj-y += process.o 17obj-y += process.o
19obj-y += ptrace.o 18obj-y += ptrace.o
@@ -32,6 +31,7 @@ obj-y += vdso/
32 31
33CFLAGS_setup.o := -mcmodel=medany 32CFLAGS_setup.o := -mcmodel=medany
34 33
34obj-$(CONFIG_FPU) += fpu.o
35obj-$(CONFIG_SMP) += smpboot.o 35obj-$(CONFIG_SMP) += smpboot.o
36obj-$(CONFIG_SMP) += smp.o 36obj-$(CONFIG_SMP) += smp.o
37obj-$(CONFIG_MODULES) += module.o 37obj-$(CONFIG_MODULES) += module.o
diff --git a/arch/riscv/kernel/process.c b/arch/riscv/kernel/process.c
index d7c6ca7c95ae..07d515655aa9 100644
--- a/arch/riscv/kernel/process.c
+++ b/arch/riscv/kernel/process.c
@@ -76,7 +76,7 @@ void show_regs(struct pt_regs *regs)
76void start_thread(struct pt_regs *regs, unsigned long pc, 76void start_thread(struct pt_regs *regs, unsigned long pc,
77 unsigned long sp) 77 unsigned long sp)
78{ 78{
79 regs->sstatus = SR_SPIE /* User mode, irqs on */ | SR_FS_INITIAL; 79 regs->sstatus = DEFAULT_SSTATUS;
80 regs->sepc = pc; 80 regs->sepc = pc;
81 regs->sp = sp; 81 regs->sp = sp;
82 set_fs(USER_DS); 82 set_fs(USER_DS);
@@ -84,12 +84,14 @@ void start_thread(struct pt_regs *regs, unsigned long pc,
84 84
85void flush_thread(void) 85void flush_thread(void)
86{ 86{
87#ifdef CONFIG_FPU
87 /* 88 /*
88 * Reset FPU context 89 * Reset FPU context
89 * frm: round to nearest, ties to even (IEEE default) 90 * frm: round to nearest, ties to even (IEEE default)
90 * fflags: accrued exceptions cleared 91 * fflags: accrued exceptions cleared
91 */ 92 */
92 memset(&current->thread.fstate, 0, sizeof(current->thread.fstate)); 93 memset(&current->thread.fstate, 0, sizeof(current->thread.fstate));
94#endif
93} 95}
94 96
95int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) 97int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src)
diff --git a/arch/riscv/kernel/signal.c b/arch/riscv/kernel/signal.c
index 6a18b9819ead..2450b824d799 100644
--- a/arch/riscv/kernel/signal.c
+++ b/arch/riscv/kernel/signal.c
@@ -37,6 +37,7 @@ struct rt_sigframe {
37 struct ucontext uc; 37 struct ucontext uc;
38}; 38};
39 39
40#ifdef CONFIG_FPU
40static long restore_fp_state(struct pt_regs *regs, 41static long restore_fp_state(struct pt_regs *regs,
41 union __riscv_fp_state *sc_fpregs) 42 union __riscv_fp_state *sc_fpregs)
42{ 43{
@@ -85,6 +86,10 @@ static long save_fp_state(struct pt_regs *regs,
85 86
86 return err; 87 return err;
87} 88}
89#else
90#define save_fp_state(task, regs) (0)
91#define restore_fp_state(task, regs) (0)
92#endif
88 93
89static long restore_sigcontext(struct pt_regs *regs, 94static long restore_sigcontext(struct pt_regs *regs,
90 struct sigcontext __user *sc) 95 struct sigcontext __user *sc)