Skip to content

Commit 89d77f7

Browse files
committed
Merge tag 'riscv-for-linus-6.4-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: - Support for runtime detection of the Svnapot extension - Support for Zicboz when clearing pages - We've moved to GENERIC_ENTRY - Support for !MMU on rv32 systems - The linear region is now mapped via huge pages - Support for building relocatable kernels - Support for the hwprobe interface - Various fixes and cleanups throughout the tree * tag 'riscv-for-linus-6.4-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (57 commits) RISC-V: hwprobe: Explicity check for -1 in vdso init RISC-V: hwprobe: There can only be one first riscv: Allow to downgrade paging mode from the command line dt-bindings: riscv: add sv57 mmu-type RISC-V: hwprobe: Remove __init on probe_vendor_features() riscv: Use --emit-relocs in order to move .rela.dyn in init riscv: Check relocations at compile time powerpc: Move script to check relocations at compile time in scripts/ riscv: Introduce CONFIG_RELOCATABLE riscv: Move .rela.dyn outside of init to avoid empty relocations riscv: Prepare EFI header for relocatable kernels riscv: Unconditionnally select KASAN_VMALLOC if KASAN riscv: Fix ptdump when KASAN is enabled riscv: Fix EFI stub usage of KASAN instrumented strcmp function riscv: Move DTB_EARLY_BASE_VA to the kernel address space riscv: Rework kasan population functions riscv: Split early and final KASAN population functions riscv: Use PUD/P4D/PGD pages for the linear mapping riscv: Move the linear mapping creation in its own function riscv: Get rid of riscv_pfn_base variable ...
2 parents b23c137 + b09313d commit 89d77f7

91 files changed

Lines changed: 2595 additions & 993 deletions

Some content is hidden

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

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3612,7 +3612,10 @@
36123612
emulation library even if a 387 maths coprocessor
36133613
is present.
36143614

3615-
no5lvl [X86-64] Disable 5-level paging mode. Forces
3615+
no4lvl [RISCV] Disable 4-level and 5-level paging modes. Forces
3616+
kernel to use 3-level paging instead.
3617+
3618+
no5lvl [X86-64,RISCV] Disable 5-level paging mode. Forces
36163619
kernel to use 4-level paging instead.
36173620

36183621
noaliencache [MM, NUMA, SLAB] Disables the allocation of alien

Documentation/devicetree/bindings/riscv/cpus.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,19 @@ properties:
6666
- riscv,sv32
6767
- riscv,sv39
6868
- riscv,sv48
69+
- riscv,sv57
6970
- riscv,none
7071

7172
riscv,cbom-block-size:
7273
$ref: /schemas/types.yaml#/definitions/uint32
7374
description:
7475
The blocksize in bytes for the Zicbom cache operations.
7576

77+
riscv,cboz-block-size:
78+
$ref: /schemas/types.yaml#/definitions/uint32
79+
description:
80+
The blocksize in bytes for the Zicboz cache operations.
81+
7682
riscv,isa:
7783
description:
7884
Identifies the specific RISC-V instruction set architecture

Documentation/riscv/hwprobe.rst

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
RISC-V Hardware Probing Interface
4+
---------------------------------
5+
6+
The RISC-V hardware probing interface is based around a single syscall, which
7+
is defined in <asm/hwprobe.h>::
8+
9+
struct riscv_hwprobe {
10+
__s64 key;
11+
__u64 value;
12+
};
13+
14+
long sys_riscv_hwprobe(struct riscv_hwprobe *pairs, size_t pair_count,
15+
size_t cpu_count, cpu_set_t *cpus,
16+
unsigned int flags);
17+
18+
The arguments are split into three groups: an array of key-value pairs, a CPU
19+
set, and some flags. The key-value pairs are supplied with a count. Userspace
20+
must prepopulate the key field for each element, and the kernel will fill in the
21+
value if the key is recognized. If a key is unknown to the kernel, its key field
22+
will be cleared to -1, and its value set to 0. The CPU set is defined by
23+
CPU_SET(3). For value-like keys (eg. vendor/arch/impl), the returned value will
24+
be only be valid if all CPUs in the given set have the same value. Otherwise -1
25+
will be returned. For boolean-like keys, the value returned will be a logical
26+
AND of the values for the specified CPUs. Usermode can supply NULL for cpus and
27+
0 for cpu_count as a shortcut for all online CPUs. There are currently no flags,
28+
this value must be zero for future compatibility.
29+
30+
On success 0 is returned, on failure a negative error code is returned.
31+
32+
The following keys are defined:
33+
34+
* :c:macro:`RISCV_HWPROBE_KEY_MVENDORID`: Contains the value of ``mvendorid``,
35+
as defined by the RISC-V privileged architecture specification.
36+
37+
* :c:macro:`RISCV_HWPROBE_KEY_MARCHID`: Contains the value of ``marchid``, as
38+
defined by the RISC-V privileged architecture specification.
39+
40+
* :c:macro:`RISCV_HWPROBE_KEY_MIMPLID`: Contains the value of ``mimplid``, as
41+
defined by the RISC-V privileged architecture specification.
42+
43+
* :c:macro:`RISCV_HWPROBE_KEY_BASE_BEHAVIOR`: A bitmask containing the base
44+
user-visible behavior that this kernel supports. The following base user ABIs
45+
are defined:
46+
47+
* :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: Support for rv32ima or
48+
rv64ima, as defined by version 2.2 of the user ISA and version 1.10 of the
49+
privileged ISA, with the following known exceptions (more exceptions may be
50+
added, but only if it can be demonstrated that the user ABI is not broken):
51+
52+
* The :fence.i: instruction cannot be directly executed by userspace
53+
programs (it may still be executed in userspace via a
54+
kernel-controlled mechanism such as the vDSO).
55+
56+
* :c:macro:`RISCV_HWPROBE_KEY_IMA_EXT_0`: A bitmask containing the extensions
57+
that are compatible with the :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`:
58+
base system behavior.
59+
60+
* :c:macro:`RISCV_HWPROBE_IMA_FD`: The F and D extensions are supported, as
61+
defined by commit cd20cee ("FMIN/FMAX now implement
62+
minimumNumber/maximumNumber, not minNum/maxNum") of the RISC-V ISA manual.
63+
64+
* :c:macro:`RISCV_HWPROBE_IMA_C`: The C extension is supported, as defined
65+
by version 2.2 of the RISC-V ISA manual.
66+
67+
* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
68+
information about the selected set of processors.
69+
70+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_UNKNOWN`: The performance of misaligned
71+
accesses is unknown.
72+
73+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_EMULATED`: Misaligned accesses are
74+
emulated via software, either in or below the kernel. These accesses are
75+
always extremely slow.
76+
77+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_SLOW`: Misaligned accesses are supported
78+
in hardware, but are slower than the cooresponding aligned accesses
79+
sequences.
80+
81+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_FAST`: Misaligned accesses are supported
82+
in hardware and are faster than the cooresponding aligned accesses
83+
sequences.
84+
85+
* :c:macro:`RISCV_HWPROBE_MISALIGNED_UNSUPPORTED`: Misaligned accesses are
86+
not supported at all and will generate a misaligned address fault.

Documentation/riscv/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RISC-V architecture
77

88
boot-image-header
99
vm-layout
10+
hwprobe
1011
patch-acceptance
1112
uabi
1213

arch/powerpc/tools/relocs_check.sh

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,8 @@ if [ $# -lt 3 ]; then
1515
exit 1
1616
fi
1717

18-
# Have Kbuild supply the path to objdump and nm so we handle cross compilation.
19-
objdump="$1"
20-
nm="$2"
21-
vmlinux="$3"
22-
23-
# Remove from the bad relocations those that match an undefined weak symbol
24-
# which will result in an absolute relocation to 0.
25-
# Weak unresolved symbols are of that form in nm output:
26-
# " w _binary__btf_vmlinux_bin_end"
27-
undef_weak_symbols=$($nm "$vmlinux" | awk '$1 ~ /w/ { print $2 }')
28-
2918
bad_relocs=$(
30-
$objdump -R "$vmlinux" |
31-
# Only look at relocation lines.
32-
grep -E '\<R_' |
19+
${srctree}/scripts/relocs_check.sh "$@" |
3320
# These relocations are okay
3421
# On PPC64:
3522
# R_PPC64_RELATIVE, R_PPC64_NONE
@@ -44,8 +31,7 @@ R_PPC_ADDR16_LO
4431
R_PPC_ADDR16_HI
4532
R_PPC_ADDR16_HA
4633
R_PPC_RELATIVE
47-
R_PPC_NONE' |
48-
([ "$undef_weak_symbols" ] && grep -F -w -v "$undef_weak_symbols" || cat)
34+
R_PPC_NONE'
4935
)
5036

5137
if [ -z "$bad_relocs" ]; then

arch/riscv/Kconfig

Lines changed: 67 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ config RISCV
3333
select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
3434
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
3535
select ARCH_HAS_UBSAN_SANITIZE_ALL
36+
select ARCH_HAS_VDSO_DATA
3637
select ARCH_OPTIONAL_KERNEL_RWX if ARCH_HAS_STRICT_KERNEL_RWX
3738
select ARCH_OPTIONAL_KERNEL_RWX_DEFAULT
3839
select ARCH_STACKWALK
@@ -44,7 +45,7 @@ config RISCV
4445
select ARCH_USE_QUEUED_RWLOCKS
4546
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
4647
select ARCH_WANT_FRAME_POINTERS
47-
select ARCH_WANT_GENERAL_HUGETLB
48+
select ARCH_WANT_GENERAL_HUGETLB if !RISCV_ISA_SVNAPOT
4849
select ARCH_WANT_HUGETLB_PAGE_OPTIMIZE_VMEMMAP
4950
select ARCH_WANT_HUGE_PMD_SHARE if 64BIT
5051
select ARCH_WANT_LD_ORPHAN_WARN if !XIP_KERNEL
@@ -60,6 +61,7 @@ config RISCV
6061
select GENERIC_ATOMIC64 if !64BIT
6162
select GENERIC_CLOCKEVENTS_BROADCAST if SMP
6263
select GENERIC_EARLY_IOREMAP
64+
select GENERIC_ENTRY
6365
select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
6466
select GENERIC_IDLE_POLL_SETUP
6567
select GENERIC_IOREMAP if MMU
@@ -121,6 +123,7 @@ config RISCV
121123
select HAVE_SYSCALL_TRACEPOINTS
122124
select IRQ_DOMAIN
123125
select IRQ_FORCED_THREADING
126+
select KASAN_VMALLOC if KASAN
124127
select MODULES_USE_ELF_RELA if MODULES
125128
select MODULE_SECTIONS if MODULES
126129
select OF
@@ -181,8 +184,8 @@ config MMU
181184

182185
config PAGE_OFFSET
183186
hex
184-
default 0xC0000000 if 32BIT
185-
default 0x80000000 if 64BIT && !MMU
187+
default 0xC0000000 if 32BIT && MMU
188+
default 0x80000000 if !MMU
186189
default 0xff60000000000000 if 64BIT
187190

188191
config KASAN_SHADOW_OFFSET
@@ -249,7 +252,7 @@ config AS_HAS_INSN
249252
def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero)
250253

251254
source "arch/riscv/Kconfig.socs"
252-
source "arch/riscv/Kconfig.erratas"
255+
source "arch/riscv/Kconfig.errata"
253256

254257
menu "Platform type"
255258

@@ -283,7 +286,6 @@ config ARCH_RV32I
283286
select GENERIC_LIB_ASHRDI3
284287
select GENERIC_LIB_LSHRDI3
285288
select GENERIC_LIB_UCMPDI2
286-
select MMU
287289

288290
config ARCH_RV64I
289291
bool "RV64I"
@@ -324,6 +326,14 @@ config SMP
324326

325327
If you don't know what to do here, say N.
326328

329+
config SCHED_MC
330+
bool "Multi-core scheduler support"
331+
depends on SMP
332+
help
333+
Multi-core scheduler support improves the CPU scheduler's decision
334+
making when dealing with multi-core CPU chips at a cost of slightly
335+
increased overhead in some places. If unsure say N here.
336+
327337
config NR_CPUS
328338
int "Maximum number of CPUs (2-512)"
329339
depends on SMP
@@ -382,9 +392,9 @@ config RISCV_ALTERNATIVE
382392
depends on !XIP_KERNEL
383393
help
384394
This Kconfig allows the kernel to automatically patch the
385-
errata required by the execution platform at run time. The
386-
code patching is performed once in the boot stages. It means
387-
that the overhead from this mechanism is just taken once.
395+
erratum or cpufeature required by the execution platform at run
396+
time. The code patching overhead is minimal, as it's only done
397+
once at boot and once on each module load.
388398

389399
config RISCV_ALTERNATIVE_EARLY
390400
bool
@@ -402,21 +412,40 @@ config RISCV_ISA_C
402412

403413
If you don't know what to do here, say Y.
404414

415+
config RISCV_ISA_SVNAPOT
416+
bool "Svnapot extension support for supervisor mode NAPOT pages"
417+
depends on 64BIT && MMU
418+
depends on RISCV_ALTERNATIVE
419+
default y
420+
help
421+
Allow kernel to detect the Svnapot ISA-extension dynamically at boot
422+
time and enable its usage.
423+
424+
The Svnapot extension is used to mark contiguous PTEs as a range
425+
of contiguous virtual-to-physical translations for a naturally
426+
aligned power-of-2 (NAPOT) granularity larger than the base 4KB page
427+
size. When HUGETLBFS is also selected this option unconditionally
428+
allocates some memory for each NAPOT page size supported by the kernel.
429+
When optimizing for low memory consumption and for platforms without
430+
the Svnapot extension, it may be better to say N here.
431+
432+
If you don't know what to do here, say Y.
433+
405434
config RISCV_ISA_SVPBMT
406-
bool "SVPBMT extension support"
435+
bool "Svpbmt extension support for supervisor mode page-based memory types"
407436
depends on 64BIT && MMU
408437
depends on RISCV_ALTERNATIVE
409438
default y
410439
help
411-
Adds support to dynamically detect the presence of the SVPBMT
440+
Adds support to dynamically detect the presence of the Svpbmt
412441
ISA-extension (Supervisor-mode: page-based memory types) and
413442
enable its usage.
414443

415444
The memory type for a page contains a combination of attributes
416445
that indicate the cacheability, idempotency, and ordering
417446
properties for access to that page.
418447

419-
The SVPBMT extension is only available on 64Bit cpus.
448+
The Svpbmt extension is only available on 64-bit cpus.
420449

421450
If you don't know what to do here, say Y.
422451

@@ -460,6 +489,19 @@ config RISCV_ISA_ZICBOM
460489

461490
If you don't know what to do here, say Y.
462491

492+
config RISCV_ISA_ZICBOZ
493+
bool "Zicboz extension support for faster zeroing of memory"
494+
depends on MMU
495+
depends on RISCV_ALTERNATIVE
496+
default y
497+
help
498+
Enable the use of the Zicboz extension (cbo.zero instruction)
499+
when available.
500+
501+
The Zicboz extension is used for faster zeroing of memory.
502+
503+
If you don't know what to do here, say Y.
504+
463505
config TOOLCHAIN_HAS_ZIHINTPAUSE
464506
bool
465507
default y
@@ -586,6 +628,20 @@ config COMPAT
586628

587629
If you want to execute 32-bit userspace applications, say Y.
588630

631+
config RELOCATABLE
632+
bool "Build a relocatable kernel"
633+
depends on MMU && 64BIT && !XIP_KERNEL
634+
help
635+
This builds a kernel as a Position Independent Executable (PIE),
636+
which retains all relocation metadata required to relocate the
637+
kernel binary at runtime to a different virtual address than the
638+
address it was linked at.
639+
Since RISCV uses the RELA relocation format, this requires a
640+
relocation pass at runtime even if the kernel is loaded at the
641+
same address it was linked at.
642+
643+
If unsure, say N.
644+
589645
endmenu # "Kernel features"
590646

591647
menu "Boot options"

arch/riscv/Makefile

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77
#
88

99
OBJCOPYFLAGS := -O binary
10-
LDFLAGS_vmlinux :=
10+
LDFLAGS_vmlinux := -z norelro
11+
ifeq ($(CONFIG_RELOCATABLE),y)
12+
LDFLAGS_vmlinux += -shared -Bsymbolic -z notext --emit-relocs
13+
KBUILD_CFLAGS += -fPIE
14+
endif
1115
ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
12-
LDFLAGS_vmlinux := --no-relax
16+
LDFLAGS_vmlinux += --no-relax
1317
KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY
1418
ifeq ($(CONFIG_RISCV_ISA_C),y)
1519
CC_FLAGS_FTRACE := -fpatchable-function-entry=4
@@ -183,3 +187,7 @@ rv64_randconfig:
183187
PHONY += rv32_defconfig
184188
rv32_defconfig:
185189
$(Q)$(MAKE) -f $(srctree)/Makefile defconfig 32-bit.config
190+
191+
PHONY += rv32_nommu_virt_defconfig
192+
rv32_nommu_virt_defconfig:
193+
$(Q)$(MAKE) -f $(srctree)/Makefile nommu_virt_defconfig 32-bit.config

0 commit comments

Comments
 (0)