Skip to content

Commit 119b1e6

Browse files
committed
Merge tag 'riscv-for-linus-6.16-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: - Support for the FWFT SBI extension, which is part of SBI 3.0 and a dependency for many new SBI and ISA extensions - Support for getrandom() in the VDSO - Support for mseal - Optimized routines for raid6 syndrome and recovery calculations - kexec_file() supports loading Image-formatted kernel binaries - Improvements to the instruction patching framework to allow for atomic instruction patching, along with rules as to how systems need to behave in order to function correctly - Support for a handful of new ISA extensions: Svinval, Zicbop, Zabha, some SiFive vendor extensions - Various fixes and cleanups, including: misaligned access handling, perf symbol mangling, module loading, PUD THPs, and improved uaccess routines * tag 'riscv-for-linus-6.16-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (69 commits) riscv: uaccess: Only restore the CSR_STATUS SUM bit RISC-V: vDSO: Wire up getrandom() vDSO implementation riscv: enable mseal sysmap for RV64 raid6: Add RISC-V SIMD syndrome and recovery calculations riscv: mm: Add support for Svinval extension RISC-V: Documentation: Add enough title underlines to CMODX riscv: Improve Kconfig help for RISCV_ISA_V_PREEMPTIVE MAINTAINERS: Update Atish's email address riscv: uaccess: do not do misaligned accesses in get/put_user() riscv: process: use unsigned int instead of unsigned long for put_user() riscv: make unsafe user copy routines use existing assembly routines riscv: hwprobe: export Zabha extension riscv: Make regs_irqs_disabled() more clear perf symbols: Ignore mapping symbols on riscv RISC-V: Kconfig: Fix help text of CMDLINE_EXTEND riscv: module: Optimize PLT/GOT entry counting riscv: Add support for PUD THP riscv: xchg: Prefetch the destination word for sc.w riscv: Add ARCH_HAS_PREFETCH[W] support with Zicbop riscv: Add support for Zicbop ...
2 parents d94467a + 51f1b16 commit 119b1e6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+3787
-855
lines changed

.mailmap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ Asahi Lina <[email protected]> <[email protected]>
107107
Ashok Raj Nagarajan <[email protected]> <[email protected]>
108108
109109
110-
110+
111+
111112
Avaneesh Kumar Dwivedi <[email protected]> <[email protected]>
112113
Axel Dyks <[email protected]>
113114

Documentation/arch/riscv/cmodx.rst

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,45 @@ modified by the program itself. Instruction storage and the instruction cache
1010
program must enforce its own synchronization with the unprivileged fence.i
1111
instruction.
1212

13-
However, the default Linux ABI prohibits the use of fence.i in userspace
14-
applications. At any point the scheduler may migrate a task onto a new hart. If
15-
migration occurs after the userspace synchronized the icache and instruction
16-
storage with fence.i, the icache on the new hart will no longer be clean. This
17-
is due to the behavior of fence.i only affecting the hart that it is called on.
18-
Thus, the hart that the task has been migrated to may not have synchronized
19-
instruction storage and icache.
13+
CMODX in the Kernel Space
14+
-------------------------
15+
16+
Dynamic ftrace
17+
---------------------
18+
19+
Essentially, dynamic ftrace directs the control flow by inserting a function
20+
call at each patchable function entry, and patches it dynamically at runtime to
21+
enable or disable the redirection. In the case of RISC-V, 2 instructions,
22+
AUIPC + JALR, are required to compose a function call. However, it is impossible
23+
to patch 2 instructions and expect that a concurrent read-side executes them
24+
without a race condition. This series makes atmoic code patching possible in
25+
RISC-V ftrace. Kernel preemption makes things even worse as it allows the old
26+
state to persist across the patching process with stop_machine().
27+
28+
In order to get rid of stop_machine() and run dynamic ftrace with full kernel
29+
preemption, we partially initialize each patchable function entry at boot-time,
30+
setting the first instruction to AUIPC, and the second to NOP. Now, atmoic
31+
patching is possible because the kernel only has to update one instruction.
32+
According to Ziccif, as long as an instruction is naturally aligned, the ISA
33+
guarantee an atomic update.
34+
35+
By fixing down the first instruction, AUIPC, the range of the ftrace trampoline
36+
is limited to +-2K from the predetermined target, ftrace_caller, due to the lack
37+
of immediate encoding space in RISC-V. To address the issue, we introduce
38+
CALL_OPS, where an 8B naturally align metadata is added in front of each
39+
pacthable function. The metadata is resolved at the first trampoline, then the
40+
execution can be derect to another custom trampoline.
41+
42+
CMODX in the User Space
43+
-----------------------
44+
45+
Though fence.i is an unprivileged instruction, the default Linux ABI prohibits
46+
the use of fence.i in userspace applications. At any point the scheduler may
47+
migrate a task onto a new hart. If migration occurs after the userspace
48+
synchronized the icache and instruction storage with fence.i, the icache on the
49+
new hart will no longer be clean. This is due to the behavior of fence.i only
50+
affecting the hart that it is called on. Thus, the hart that the task has been
51+
migrated to may not have synchronized instruction storage and icache.
2052

2153
There are two ways to solve this problem: use the riscv_flush_icache() syscall,
2254
or use the ``PR_RISCV_SET_ICACHE_FLUSH_CTX`` prctl() and emit fence.i in

Documentation/arch/riscv/hwprobe.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,10 @@ The following keys are defined:
271271
* :c:macro:`RISCV_HWPROBE_EXT_ZICBOM`: The Zicbom extension is supported, as
272272
ratified in commit 3dd606f ("Create cmobase-v1.0.pdf") of riscv-CMOs.
273273

274+
* :c:macro:`RISCV_HWPROBE_EXT_ZABHA`: The Zabha extension is supported as
275+
ratified in commit 49f49c842ff9 ("Update to Rafified state") of
276+
riscv-zabha.
277+
274278
* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: Deprecated. Returns similar values to
275279
:c:macro:`RISCV_HWPROBE_KEY_MISALIGNED_SCALAR_PERF`, but the key was
276280
mistakenly classified as a bitmask rather than a value.
@@ -335,3 +339,25 @@ The following keys are defined:
335339

336340
* :c:macro:`RISCV_HWPROBE_KEY_ZICBOM_BLOCK_SIZE`: An unsigned int which
337341
represents the size of the Zicbom block in bytes.
342+
343+
* :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0`: A bitmask containing the
344+
sifive vendor extensions that are compatible with the
345+
:c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
346+
347+
* SIFIVE
348+
349+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCDOD`: The Xsfqmaccdod vendor
350+
extension is supported in version 1.1 of SiFive Int8 Matrix Multiplication
351+
Extensions Specification.
352+
353+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVQMACCQOQ`: The Xsfqmaccqoq vendor
354+
extension is supported in version 1.1 of SiFive Int8 Matrix Multiplication
355+
Instruction Extensions Specification.
356+
357+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVFNRCLIPXFQF`: The Xsfvfnrclipxfqf
358+
vendor extension is supported in version 1.0 of SiFive FP32-to-int8 Ranged
359+
Clip Instructions Extensions Specification.
360+
361+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XSFVFWMACCQQQ`: The Xsfvfwmaccqqq
362+
vendor extension is supported in version 1.0 of Matrix Multiply Accumulate
363+
Instruction Extensions Specification.

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,31 @@ properties:
662662
Registers in the AX45MP datasheet.
663663
https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
664664

665+
# SiFive
666+
- const: xsfvqmaccdod
667+
description:
668+
SiFive Int8 Matrix Multiplication Extensions Specification.
669+
See more details in
670+
https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
671+
672+
- const: xsfvqmaccqoq
673+
description:
674+
SiFive Int8 Matrix Multiplication Extensions Specification.
675+
See more details in
676+
https://www.sifive.com/document-file/sifive-int8-matrix-multiplication-extensions-specification
677+
678+
- const: xsfvfnrclipxfqf
679+
description:
680+
SiFive FP32-to-int8 Ranged Clip Instructions Extensions Specification.
681+
See more details in
682+
https://www.sifive.com/document-file/fp32-to-int8-ranged-clip-instructions
683+
684+
- const: xsfvfwmaccqqq
685+
description:
686+
SiFive Matrix Multiply Accumulate Instruction Extensions Specification.
687+
See more details in
688+
https://www.sifive.com/document-file/matrix-multiply-accumulate-instruction
689+
665690
# T-HEAD
666691
- const: xtheadvector
667692
description:

MAINTAINERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13270,7 +13270,7 @@ F: arch/powerpc/kvm/
1327013270

1327113271
KERNEL VIRTUAL MACHINE FOR RISC-V (KVM/riscv)
1327213272
M: Anup Patel <[email protected]>
13273-
R: Atish Patra <[email protected]>
13273+
R: Atish Patra <[email protected]>
1327413274
1327513275
1327613276
@@ -21332,7 +21332,7 @@ F: arch/riscv/boot/dts/sifive/
2133221332
F: arch/riscv/boot/dts/starfive/
2133321333

2133421334
RISC-V PMU DRIVERS
21335-
M: Atish Patra <[email protected]>
21335+
M: Atish Patra <[email protected]>
2133621336
R: Anup Patel <[email protected]>
2133721337
2133821338
S: Supported

arch/riscv/Kconfig

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ config RISCV
7070
# LLD >= 14: https://github.com/llvm/llvm-project/issues/50505
7171
select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000
7272
select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000
73+
select ARCH_SUPPORTS_MSEAL_SYSTEM_MAPPINGS if 64BIT && MMU
7374
select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
7475
select ARCH_SUPPORTS_PER_VMA_LOCK if MMU
7576
select ARCH_SUPPORTS_RT
@@ -99,6 +100,7 @@ config RISCV
99100
select EDAC_SUPPORT
100101
select FRAME_POINTER if PERF_EVENTS || (FUNCTION_TRACER && !DYNAMIC_FTRACE)
101102
select FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY if DYNAMIC_FTRACE
103+
select FUNCTION_ALIGNMENT_8B if DYNAMIC_FTRACE_WITH_CALL_OPS
102104
select GENERIC_ARCH_TOPOLOGY
103105
select GENERIC_ATOMIC64 if !64BIT
104106
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
@@ -143,20 +145,23 @@ config RISCV
143145
select HAVE_ARCH_THREAD_STRUCT_WHITELIST
144146
select HAVE_ARCH_TRACEHOOK
145147
select HAVE_ARCH_TRANSPARENT_HUGEPAGE if 64BIT && MMU
148+
select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if 64BIT && MMU
146149
select HAVE_ARCH_USERFAULTFD_MINOR if 64BIT && USERFAULTFD
147150
select HAVE_ARCH_VMAP_STACK if MMU && 64BIT
148151
select HAVE_ASM_MODVERSIONS
149152
select HAVE_CONTEXT_TRACKING_USER
150153
select HAVE_DEBUG_KMEMLEAK
151154
select HAVE_DMA_CONTIGUOUS if MMU
152155
select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && (CLANG_SUPPORTS_DYNAMIC_FTRACE || GCC_SUPPORTS_DYNAMIC_FTRACE)
153-
select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
156+
select FUNCTION_ALIGNMENT_4B if HAVE_DYNAMIC_FTRACE && RISCV_ISA_C
157+
select HAVE_DYNAMIC_FTRACE_WITH_DIRECT_CALLS if HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS
158+
select HAVE_DYNAMIC_FTRACE_WITH_CALL_OPS if (DYNAMIC_FTRACE_WITH_ARGS && !CFI_CLANG)
154159
select HAVE_DYNAMIC_FTRACE_WITH_ARGS if HAVE_DYNAMIC_FTRACE
155160
select HAVE_FTRACE_GRAPH_FUNC
156161
select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL
157162
select HAVE_FUNCTION_GRAPH_TRACER if HAVE_DYNAMIC_FTRACE_WITH_ARGS
158163
select HAVE_FUNCTION_GRAPH_FREGS
159-
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION
164+
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
160165
select HAVE_EBPF_JIT if MMU
161166
select HAVE_GUP_FAST if MMU
162167
select HAVE_FUNCTION_ARG_ACCESS_API
@@ -218,6 +223,7 @@ config RISCV
218223
select THREAD_INFO_IN_TASK
219224
select TRACE_IRQFLAGS_SUPPORT
220225
select UACCESS_MEMCPY if !MMU
226+
select VDSO_GETRANDOM if HAVE_GENERIC_VDSO
221227
select USER_STACKTRACE_SUPPORT
222228
select ZONE_DMA32 if 64BIT
223229

@@ -236,6 +242,7 @@ config CLANG_SUPPORTS_DYNAMIC_FTRACE
236242
config GCC_SUPPORTS_DYNAMIC_FTRACE
237243
def_bool CC_IS_GCC
238244
depends on $(cc-option,-fpatchable-function-entry=8)
245+
depends on CC_HAS_MIN_FUNCTION_ALIGNMENT || !RISCV_ISA_C
239246

240247
config HAVE_SHADOW_CALL_STACK
241248
def_bool $(cc-option,-fsanitize=shadow-call-stack)
@@ -664,12 +671,12 @@ config RISCV_ISA_V_PREEMPTIVE
664671
default y
665672
help
666673
Usually, in-kernel SIMD routines are run with preemption disabled.
667-
Functions which envoke long running SIMD thus must yield core's
674+
Functions which invoke long running SIMD thus must yield the core's
668675
vector unit to prevent blocking other tasks for too long.
669676

670-
This config allows kernel to run SIMD without explicitly disable
671-
preemption. Enabling this config will result in higher memory
672-
consumption due to the allocation of per-task's kernel Vector context.
677+
This config allows the kernel to run SIMD without explicitly disabling
678+
preemption. Enabling this config will result in higher memory consumption
679+
due to the allocation of per-task's kernel Vector context.
673680

674681
config RISCV_ISA_ZAWRS
675682
bool "Zawrs extension support for more efficient busy waiting"
@@ -842,6 +849,21 @@ config RISCV_ISA_ZICBOZ
842849

843850
If you don't know what to do here, say Y.
844851

852+
config RISCV_ISA_ZICBOP
853+
bool "Zicbop extension support for cache block prefetch"
854+
depends on MMU
855+
depends on RISCV_ALTERNATIVE
856+
default y
857+
help
858+
Adds support to dynamically detect the presence of the ZICBOP
859+
extension (Cache Block Prefetch Operations) and enable its
860+
usage.
861+
862+
The Zicbop extension can be used to prefetch cache blocks for
863+
read/write fetch.
864+
865+
If you don't know what to do here, say Y.
866+
845867
config TOOLCHAIN_NEEDS_EXPLICIT_ZICSR_ZIFENCEI
846868
def_bool y
847869
# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=aed44286efa8ae8717a77d94b51ac3614e2ca6dc
@@ -1171,8 +1193,8 @@ config CMDLINE_FALLBACK
11711193
config CMDLINE_EXTEND
11721194
bool "Extend bootloader kernel arguments"
11731195
help
1174-
The command-line arguments provided during boot will be
1175-
appended to the built-in command line. This is useful in
1196+
The built-in command line will be appended to the command-
1197+
line arguments provided during boot. This is useful in
11761198
cases where the provided arguments are insufficient and
11771199
you don't want to or cannot modify them.
11781200

arch/riscv/Kconfig.vendor

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,19 @@ config RISCV_ISA_VENDOR_EXT_ANDES
1616
If you don't know what to do here, say Y.
1717
endmenu
1818

19+
menu "SiFive"
20+
config RISCV_ISA_VENDOR_EXT_SIFIVE
21+
bool "SiFive vendor extension support"
22+
select RISCV_ISA_VENDOR_EXT
23+
default y
24+
help
25+
Say N here if you want to disable all SiFive vendor extension
26+
support. This will cause any SiFive vendor extensions that are
27+
requested by hardware probing to be ignored.
28+
29+
If you don't know what to do here, say Y.
30+
endmenu
31+
1932
menu "T-Head"
2033
config RISCV_ISA_VENDOR_EXT_THEAD
2134
bool "T-Head vendor extension support"

arch/riscv/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
1515
LDFLAGS_vmlinux += --no-relax
1616
KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
1717
ifeq ($(CONFIG_RISCV_ISA_C),y)
18-
CC_FLAGS_FTRACE := -fpatchable-function-entry=4
18+
CC_FLAGS_FTRACE := -fpatchable-function-entry=8,4
1919
else
20-
CC_FLAGS_FTRACE := -fpatchable-function-entry=2
20+
CC_FLAGS_FTRACE := -fpatchable-function-entry=4,2
2121
endif
2222
endif
2323

arch/riscv/configs/defconfig

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ CONFIG_CGROUP_DEVICE=y
1818
CONFIG_CGROUP_CPUACCT=y
1919
CONFIG_CGROUP_PERF=y
2020
CONFIG_CGROUP_BPF=y
21-
CONFIG_NAMESPACES=y
2221
CONFIG_USER_NS=y
2322
CONFIG_CHECKPOINT_RESTORE=y
2423
CONFIG_BLK_DEV_INITRD=y
25-
CONFIG_EXPERT=y
26-
# CONFIG_SYSFS_SYSCALL is not set
2724
CONFIG_PROFILING=y
2825
CONFIG_ARCH_MICROCHIP=y
2926
CONFIG_ARCH_SIFIVE=y
@@ -182,6 +179,7 @@ CONFIG_REGULATOR_FIXED_VOLTAGE=y
182179
CONFIG_REGULATOR_AXP20X=y
183180
CONFIG_REGULATOR_GPIO=y
184181
CONFIG_MEDIA_SUPPORT=m
182+
CONFIG_MEDIA_PLATFORM_SUPPORT=y
185183
CONFIG_VIDEO_CADENCE_CSI2RX=m
186184
CONFIG_DRM=m
187185
CONFIG_DRM_RADEON=m
@@ -297,25 +295,7 @@ CONFIG_DEFAULT_SECURITY_DAC=y
297295
CONFIG_CRYPTO_USER_API_HASH=y
298296
CONFIG_CRYPTO_DEV_VIRTIO=y
299297
CONFIG_PRINTK_TIME=y
298+
CONFIG_DEBUG_KERNEL=y
300299
CONFIG_DEBUG_FS=y
301-
CONFIG_DEBUG_PAGEALLOC=y
302-
CONFIG_SCHED_STACK_END_CHECK=y
303-
CONFIG_DEBUG_VM=y
304-
CONFIG_DEBUG_VM_PGFLAGS=y
305-
CONFIG_DEBUG_MEMORY_INIT=y
306-
CONFIG_DEBUG_PER_CPU_MAPS=y
307-
CONFIG_SOFTLOCKUP_DETECTOR=y
308-
CONFIG_WQ_WATCHDOG=y
309-
CONFIG_DEBUG_RT_MUTEXES=y
310-
CONFIG_DEBUG_SPINLOCK=y
311-
CONFIG_DEBUG_MUTEXES=y
312-
CONFIG_DEBUG_RWSEMS=y
313-
CONFIG_DEBUG_ATOMIC_SLEEP=y
314-
CONFIG_DEBUG_LIST=y
315-
CONFIG_DEBUG_PLIST=y
316-
CONFIG_DEBUG_SG=y
317-
# CONFIG_RCU_TRACE is not set
318-
CONFIG_RCU_EQS_DEBUG=y
319-
# CONFIG_FTRACE is not set
320300
# CONFIG_RUNTIME_TESTING_MENU is not set
321301
CONFIG_MEMTEST=y

arch/riscv/include/asm/asm-prototypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ long long __ashlti3(long long a, int b);
1212
#ifdef CONFIG_RISCV_ISA_V
1313

1414
#ifdef CONFIG_MMU
15-
asmlinkage int enter_vector_usercopy(void *dst, void *src, size_t n);
15+
asmlinkage int enter_vector_usercopy(void *dst, void *src, size_t n, bool enable_sum);
1616
#endif /* CONFIG_MMU */
1717

1818
void xor_regs_2_(unsigned long bytes, unsigned long *__restrict p1,

0 commit comments

Comments
 (0)