File tree Expand file tree Collapse file tree 5 files changed +49
-0
lines changed Expand file tree Collapse file tree 5 files changed +49
-0
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ config RISCV
27
27
select ARCH_HAS_GCOV_PROFILE_ALL
28
28
select ARCH_HAS_GIGANTIC_PAGE
29
29
select ARCH_HAS_KCOV
30
+ select ARCH_HAS_KERNEL_FPU_SUPPORT if 64BIT && FPU
30
31
select ARCH_HAS_MEMBARRIER_CALLBACKS
31
32
select ARCH_HAS_MEMBARRIER_SYNC_CORE
32
33
select ARCH_HAS_MMIOWB
Original file line number Diff line number Diff line change @@ -84,6 +84,9 @@ KBUILD_CFLAGS += -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64i
84
84
85
85
KBUILD_AFLAGS += -march=$(riscv-march-y )
86
86
87
+ # For C code built with floating-point support, exclude V but keep F and D.
88
+ CC_FLAGS_FPU := -march=$(shell echo $(riscv-march-y ) | sed -E 's/(rv32ima|rv64ima) ([^v_]*)v?/\1\2/')
89
+
87
90
KBUILD_CFLAGS += -mno-save-restore
88
91
KBUILD_CFLAGS += -DCONFIG_PAGE_OFFSET=$(CONFIG_PAGE_OFFSET )
89
92
Original file line number Diff line number Diff line change
1
+ /* SPDX-License-Identifier: GPL-2.0-only */
2
+ /*
3
+ * Copyright (C) 2023 SiFive
4
+ */
5
+
6
+ #ifndef _ASM_RISCV_FPU_H
7
+ #define _ASM_RISCV_FPU_H
8
+
9
+ #include <asm/switch_to.h>
10
+
11
+ #define kernel_fpu_available () has_fpu()
12
+
13
+ void kernel_fpu_begin (void );
14
+ void kernel_fpu_end (void );
15
+
16
+ #endif /* ! _ASM_RISCV_FPU_H */
Original file line number Diff line number Diff line change @@ -67,6 +67,7 @@ obj-$(CONFIG_RISCV_MISALIGNED) += unaligned_access_speed.o
67
67
obj-$(CONFIG_RISCV_PROBE_UNALIGNED_ACCESS) += copy-unaligned.o
68
68
69
69
obj-$(CONFIG_FPU) += fpu.o
70
+ obj-$(CONFIG_FPU) += kernel_mode_fpu.o
70
71
obj-$(CONFIG_RISCV_ISA_V) += vector.o
71
72
obj-$(CONFIG_RISCV_ISA_V) += kernel_mode_vector.o
72
73
obj-$(CONFIG_SMP) += smpboot.o
Original file line number Diff line number Diff line change
1
+ // SPDX-License-Identifier: GPL-2.0-only
2
+ /*
3
+ * Copyright (C) 2023 SiFive
4
+ */
5
+
6
+ #include <linux/export.h>
7
+ #include <linux/preempt.h>
8
+
9
+ #include <asm/csr.h>
10
+ #include <asm/fpu.h>
11
+ #include <asm/processor.h>
12
+ #include <asm/switch_to.h>
13
+
14
+ void kernel_fpu_begin (void )
15
+ {
16
+ preempt_disable ();
17
+ fstate_save (current , task_pt_regs (current ));
18
+ csr_set (CSR_SSTATUS , SR_FS );
19
+ }
20
+ EXPORT_SYMBOL_GPL (kernel_fpu_begin );
21
+
22
+ void kernel_fpu_end (void )
23
+ {
24
+ csr_clear (CSR_SSTATUS , SR_FS );
25
+ fstate_restore (current , task_pt_regs (current ));
26
+ preempt_enable ();
27
+ }
28
+ EXPORT_SYMBOL_GPL (kernel_fpu_end );
You can’t perform that action at this time.
0 commit comments