diff options
| -rw-r--r-- | arch/riscv/Kconfig | 9 | ||||
| -rw-r--r-- | arch/riscv/Makefile | 2 | ||||
| -rw-r--r-- | arch/riscv/include/asm/switch_to.h | 10 | ||||
| -rw-r--r-- | arch/riscv/kernel/Makefile | 2 | ||||
| -rw-r--r-- | arch/riscv/kernel/process.c | 4 | ||||
| -rw-r--r-- | arch/riscv/kernel/signal.c | 5 |
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 | ||
| 209 | endmenu | 209 | endmenu |
| 210 | 210 | ||
| 211 | config 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 | |||
| 211 | endmenu | 220 | endmenu |
| 212 | 221 | ||
| 213 | menu "Kernel type" | 222 | menu "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 | |||
| 44 | riscv-march-$(CONFIG_ARCH_RV32I) := rv32im | 44 | riscv-march-$(CONFIG_ARCH_RV32I) := rv32im |
| 45 | riscv-march-$(CONFIG_ARCH_RV64I) := rv64im | 45 | riscv-march-$(CONFIG_ARCH_RV64I) := rv64im |
| 46 | riscv-march-$(CONFIG_RISCV_ISA_A) := $(riscv-march-y)a | 46 | riscv-march-$(CONFIG_RISCV_ISA_A) := $(riscv-march-y)a |
| 47 | riscv-march-y := $(riscv-march-y)fd | 47 | riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd |
| 48 | riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c | 48 | riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c |
| 49 | KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) | 49 | KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) |
| 50 | KBUILD_AFLAGS += -march=$(riscv-march-y) | 50 | KBUILD_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 | ||
| 21 | extern void __fstate_save(struct task_struct *save_to); | 22 | extern void __fstate_save(struct task_struct *save_to); |
| 22 | extern void __fstate_restore(struct task_struct *restore_from); | 23 | extern 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 | |||
| 58 | extern struct task_struct *__switch_to(struct task_struct *, | 68 | extern 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 | |||
| 13 | obj-y += cpu.o | 13 | obj-y += cpu.o |
| 14 | obj-y += cpufeature.o | 14 | obj-y += cpufeature.o |
| 15 | obj-y += entry.o | 15 | obj-y += entry.o |
| 16 | obj-y += fpu.o | ||
| 17 | obj-y += irq.o | 16 | obj-y += irq.o |
| 18 | obj-y += process.o | 17 | obj-y += process.o |
| 19 | obj-y += ptrace.o | 18 | obj-y += ptrace.o |
| @@ -32,6 +31,7 @@ obj-y += vdso/ | |||
| 32 | 31 | ||
| 33 | CFLAGS_setup.o := -mcmodel=medany | 32 | CFLAGS_setup.o := -mcmodel=medany |
| 34 | 33 | ||
| 34 | obj-$(CONFIG_FPU) += fpu.o | ||
| 35 | obj-$(CONFIG_SMP) += smpboot.o | 35 | obj-$(CONFIG_SMP) += smpboot.o |
| 36 | obj-$(CONFIG_SMP) += smp.o | 36 | obj-$(CONFIG_SMP) += smp.o |
| 37 | obj-$(CONFIG_MODULES) += module.o | 37 | obj-$(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) | |||
| 76 | void start_thread(struct pt_regs *regs, unsigned long pc, | 76 | void 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 | ||
| 85 | void flush_thread(void) | 85 | void 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(¤t->thread.fstate, 0, sizeof(current->thread.fstate)); | 93 | memset(¤t->thread.fstate, 0, sizeof(current->thread.fstate)); |
| 94 | #endif | ||
| 93 | } | 95 | } |
| 94 | 96 | ||
| 95 | int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src) | 97 | int 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 | ||
| 40 | static long restore_fp_state(struct pt_regs *regs, | 41 | static 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 | ||
| 89 | static long restore_sigcontext(struct pt_regs *regs, | 94 | static long restore_sigcontext(struct pt_regs *regs, |
| 90 | struct sigcontext __user *sc) | 95 | struct sigcontext __user *sc) |
