Skip to content

Commit 533925c

Browse files
committed
Merge tag 'riscv-for-linus-6.5-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: - Support for ACPI - Various cleanups to the ISA string parsing, including making them case-insensitive - Support for the vector extension - Support for independent irq/softirq stacks - Our CPU DT binding now has "unevaluatedProperties: false" * tag 'riscv-for-linus-6.5-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (78 commits) riscv: hibernate: remove WARN_ON in save_processor_state dt-bindings: riscv: cpus: switch to unevaluatedProperties: false dt-bindings: riscv: cpus: add a ref the common cpu schema riscv: stack: Add config of thread stack size riscv: stack: Support HAVE_SOFTIRQ_ON_OWN_STACK riscv: stack: Support HAVE_IRQ_EXIT_ON_IRQ_STACK RISC-V: always report presence of extensions formerly part of the base ISA dt-bindings: riscv: explicitly mention assumption of Zicntr & Zihpm support RISC-V: remove decrement/increment dance in ISA string parser RISC-V: rework comments in ISA string parser RISC-V: validate riscv,isa at boot, not during ISA string parsing RISC-V: split early & late of_node to hartid mapping RISC-V: simplify register width check in ISA string parsing perf: RISC-V: Limit the number of counters returned from SBI riscv: replace deprecated scall with ecall riscv: uprobes: Restore thread.bad_cause riscv: mm: try VMA lock-based page fault handling first riscv: mm: Pre-allocate PGD entries for vmalloc/modules area RISC-V: hwprobe: Expose Zba, Zbb, and Zbs RISC-V: Track ISA extensions per hart ...
2 parents d8b0bd5 + 488833c commit 533925c

Some content is hidden

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

78 files changed

+3077
-251
lines changed

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
acpi= [HW,ACPI,X86,ARM64]
1+
acpi= [HW,ACPI,X86,ARM64,RISCV64]
22
Advanced Configuration and Power Interface
33
Format: { force | on | off | strict | noirq | rsdt |
44
copy_dsdt }
55
force -- enable ACPI if default was off
6-
on -- enable ACPI but allow fallback to DT [arm64]
6+
on -- enable ACPI but allow fallback to DT [arm64,riscv64]
77
off -- disable ACPI if default was on
88
noirq -- do not use ACPI for IRQ routing
99
strict -- Be less tolerant of platforms that are not
1010
strictly ACPI specification compliant.
1111
rsdt -- prefer RSDT over (default) XSDT
1212
copy_dsdt -- copy DSDT to memory
13-
For ARM64, ONLY "acpi=off", "acpi=on" or "acpi=force"
14-
are available
13+
For ARM64 and RISCV64, ONLY "acpi=off", "acpi=on" or
14+
"acpi=force" are available
1515

1616
See also Documentation/power/runtime_pm.rst, pci=noacpi
1717

Documentation/devicetree/bindings/riscv/cpus.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ description: |
2323
two cores, each of which has two hyperthreads, could be described as
2424
having four harts.
2525
26+
allOf:
27+
- $ref: /schemas/cpu.yaml#
28+
2629
properties:
2730
compatible:
2831
oneOf:
@@ -61,7 +64,7 @@ properties:
6164
hart. These values originate from the RISC-V Privileged
6265
Specification document, available from
6366
https://riscv.org/specifications/
64-
$ref: "/schemas/types.yaml#/definitions/string"
67+
$ref: /schemas/types.yaml#/definitions/string
6568
enum:
6669
- riscv,sv32
6770
- riscv,sv39
@@ -89,15 +92,18 @@ properties:
8992
Due to revisions of the ISA specification, some deviations
9093
have arisen over time.
9194
Notably, riscv,isa was defined prior to the creation of the
92-
Zicsr and Zifencei extensions and thus "i" implies
93-
"zicsr_zifencei".
95+
Zicntr, Zicsr, Zifencei and Zihpm extensions and thus "i"
96+
implies "zicntr_zicsr_zifencei_zihpm".
9497

9598
While the isa strings in ISA specification are case
9699
insensitive, letters in the riscv,isa string must be all
97-
lowercase to simplify parsing.
98-
$ref: "/schemas/types.yaml#/definitions/string"
100+
lowercase.
101+
$ref: /schemas/types.yaml#/definitions/string
99102
pattern: ^rv(?:64|32)imaf?d?q?c?b?k?j?p?v?h?(?:[hsxz](?:[a-z])+)?(?:_[hsxz](?:[a-z])+)*$
100103

104+
# RISC-V has multiple properties for cache op block sizes as the sizes
105+
# differ between individual CBO extensions
106+
cache-op-block-size: false
101107
# RISC-V requires 'timebase-frequency' in /cpus, so disallow it here
102108
timebase-frequency: false
103109

@@ -120,7 +126,7 @@ properties:
120126
- interrupt-controller
121127

122128
cpu-idle-states:
123-
$ref: '/schemas/types.yaml#/definitions/phandle-array'
129+
$ref: /schemas/types.yaml#/definitions/phandle-array
124130
items:
125131
maxItems: 1
126132
description: |
@@ -137,7 +143,7 @@ required:
137143
- riscv,isa
138144
- interrupt-controller
139145

140-
additionalProperties: true
146+
unevaluatedProperties: false
141147

142148
examples:
143149
- |

Documentation/riscv/hwprobe.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ The following keys are defined:
6464
* :c:macro:`RISCV_HWPROBE_IMA_C`: The C extension is supported, as defined
6565
by version 2.2 of the RISC-V ISA manual.
6666

67+
* :c:macro:`RISCV_HWPROBE_IMA_V`: The V extension is supported, as defined by
68+
version 1.0 of the RISC-V Vector extension manual.
69+
70+
* :c:macro:`RISCV_HWPROBE_EXT_ZBA`: The Zba address generation extension is
71+
supported, as defined in version 1.0 of the Bit-Manipulation ISA
72+
extensions.
73+
74+
* :c:macro:`RISCV_HWPROBE_EXT_ZBB`: The Zbb extension is supported, as defined
75+
in version 1.0 of the Bit-Manipulation ISA extensions.
76+
77+
* :c:macro:`RISCV_HWPROBE_EXT_ZBS`: The Zbs extension is supported, as defined
78+
in version 1.0 of the Bit-Manipulation ISA extensions.
79+
6780
* :c:macro:`RISCV_HWPROBE_KEY_CPUPERF_0`: A bitmask that contains performance
6881
information about the selected set of processors.
6982

Documentation/riscv/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ RISC-V architecture
1010
hwprobe
1111
patch-acceptance
1212
uabi
13+
vector
1314

1415
features
1516

Documentation/riscv/vector.rst

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
=========================================
4+
Vector Extension Support for RISC-V Linux
5+
=========================================
6+
7+
This document briefly outlines the interface provided to userspace by Linux in
8+
order to support the use of the RISC-V Vector Extension.
9+
10+
1. prctl() Interface
11+
---------------------
12+
13+
Two new prctl() calls are added to allow programs to manage the enablement
14+
status for the use of Vector in userspace. The intended usage guideline for
15+
these interfaces is to give init systems a way to modify the availability of V
16+
for processes running under its domain. Calling thess interfaces is not
17+
recommended in libraries routines because libraries should not override policies
18+
configured from the parant process. Also, users must noted that these interfaces
19+
are not portable to non-Linux, nor non-RISC-V environments, so it is discourage
20+
to use in a portable code. To get the availability of V in an ELF program,
21+
please read :c:macro:`COMPAT_HWCAP_ISA_V` bit of :c:macro:`ELF_HWCAP` in the
22+
auxiliary vector.
23+
24+
* prctl(PR_RISCV_V_SET_CONTROL, unsigned long arg)
25+
26+
Sets the Vector enablement status of the calling thread, where the control
27+
argument consists of two 2-bit enablement statuses and a bit for inheritance
28+
mode. Other threads of the calling process are unaffected.
29+
30+
Enablement status is a tri-state value each occupying 2-bit of space in
31+
the control argument:
32+
33+
* :c:macro:`PR_RISCV_V_VSTATE_CTRL_DEFAULT`: Use the system-wide default
34+
enablement status on execve(). The system-wide default setting can be
35+
controlled via sysctl interface (see sysctl section below).
36+
37+
* :c:macro:`PR_RISCV_V_VSTATE_CTRL_ON`: Allow Vector to be run for the
38+
thread.
39+
40+
* :c:macro:`PR_RISCV_V_VSTATE_CTRL_OFF`: Disallow Vector. Executing Vector
41+
instructions under such condition will trap and casuse the termination of the thread.
42+
43+
arg: The control argument is a 5-bit value consisting of 3 parts, and
44+
accessed by 3 masks respectively.
45+
46+
The 3 masks, PR_RISCV_V_VSTATE_CTRL_CUR_MASK,
47+
PR_RISCV_V_VSTATE_CTRL_NEXT_MASK, and PR_RISCV_V_VSTATE_CTRL_INHERIT
48+
represents bit[1:0], bit[3:2], and bit[4]. bit[1:0] accounts for the
49+
enablement status of current thread, and the setting at bit[3:2] takes place
50+
at next execve(). bit[4] defines the inheritance mode of the setting in
51+
bit[3:2].
52+
53+
* :c:macro:`PR_RISCV_V_VSTATE_CTRL_CUR_MASK`: bit[1:0]: Account for the
54+
Vector enablement status for the calling thread. The calling thread is
55+
not able to turn off Vector once it has been enabled. The prctl() call
56+
fails with EPERM if the value in this mask is PR_RISCV_V_VSTATE_CTRL_OFF
57+
but the current enablement status is not off. Setting
58+
PR_RISCV_V_VSTATE_CTRL_DEFAULT here takes no effect but to set back
59+
the original enablement status.
60+
61+
* :c:macro:`PR_RISCV_V_VSTATE_CTRL_NEXT_MASK`: bit[3:2]: Account for the
62+
Vector enablement setting for the calling thread at the next execve()
63+
system call. If PR_RISCV_V_VSTATE_CTRL_DEFAULT is used in this mask,
64+
then the enablement status will be decided by the system-wide
65+
enablement status when execve() happen.
66+
67+
* :c:macro:`PR_RISCV_V_VSTATE_CTRL_INHERIT`: bit[4]: the inheritance
68+
mode for the setting at PR_RISCV_V_VSTATE_CTRL_NEXT_MASK. If the bit
69+
is set then the following execve() will not clear the setting in both
70+
PR_RISCV_V_VSTATE_CTRL_NEXT_MASK and PR_RISCV_V_VSTATE_CTRL_INHERIT.
71+
This setting persists across changes in the system-wide default value.
72+
73+
Return value:
74+
* 0 on success;
75+
* EINVAL: Vector not supported, invalid enablement status for current or
76+
next mask;
77+
* EPERM: Turning off Vector in PR_RISCV_V_VSTATE_CTRL_CUR_MASK if Vector
78+
was enabled for the calling thread.
79+
80+
On success:
81+
* A valid setting for PR_RISCV_V_VSTATE_CTRL_CUR_MASK takes place
82+
immediately. The enablement status specified in
83+
PR_RISCV_V_VSTATE_CTRL_NEXT_MASK happens at the next execve() call, or
84+
all following execve() calls if PR_RISCV_V_VSTATE_CTRL_INHERIT bit is
85+
set.
86+
* Every successful call overwrites a previous setting for the calling
87+
thread.
88+
89+
* prctl(PR_RISCV_V_GET_CONTROL)
90+
91+
Gets the same Vector enablement status for the calling thread. Setting for
92+
next execve() call and the inheritance bit are all OR-ed together.
93+
94+
Note that ELF programs are able to get the availability of V for itself by
95+
reading :c:macro:`COMPAT_HWCAP_ISA_V` bit of :c:macro:`ELF_HWCAP` in the
96+
auxiliary vector.
97+
98+
Return value:
99+
* a nonnegative value on success;
100+
* EINVAL: Vector not supported.
101+
102+
2. System runtime configuration (sysctl)
103+
-----------------------------------------
104+
105+
To mitigate the ABI impact of expansion of the signal stack, a
106+
policy mechanism is provided to the administrators, distro maintainers, and
107+
developers to control the default Vector enablement status for userspace
108+
processes in form of sysctl knob:
109+
110+
* /proc/sys/abi/riscv_v_default_allow
111+
112+
Writing the text representation of 0 or 1 to this file sets the default
113+
system enablement status for new starting userspace programs. Valid values
114+
are:
115+
116+
* 0: Do not allow Vector code to be executed as the default for new processes.
117+
* 1: Allow Vector code to be executed as the default for new processes.
118+
119+
Reading this file returns the current system default enablement status.
120+
121+
At every execve() call, a new enablement status of the new process is set to
122+
the system default, unless:
123+
124+
* PR_RISCV_V_VSTATE_CTRL_INHERIT is set for the calling process, and the
125+
setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not
126+
PR_RISCV_V_VSTATE_CTRL_DEFAULT. Or,
127+
128+
* The setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not
129+
PR_RISCV_V_VSTATE_CTRL_DEFAULT.
130+
131+
Modifying the system default enablement status does not affect the enablement
132+
status of any existing process of thread that do not make an execve() call.

MAINTAINERS

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ L: [email protected] (moderated for non-subscribers)
406406
S: Maintained
407407
F: drivers/acpi/arm64
408408

409+
ACPI FOR RISC-V (ACPI/riscv)
410+
M: Sunil V L <[email protected]>
411+
412+
413+
S: Maintained
414+
F: drivers/acpi/riscv/
415+
409416
ACPI PCC(Platform Communication Channel) MAILBOX DRIVER
410417
M: Sudeep Holla <[email protected]>
411418

arch/riscv/Kconfig

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ config 32BIT
1212

1313
config RISCV
1414
def_bool y
15+
select ACPI_GENERIC_GSI if ACPI
16+
select ACPI_REDUCED_HARDWARE_ONLY if ACPI
1517
select ARCH_DMA_DEFAULT_COHERENT
1618
select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
1719
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
@@ -43,6 +45,7 @@ config RISCV
4345
select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
4446
select ARCH_SUPPORTS_HUGETLBFS if MMU
4547
select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
48+
select ARCH_SUPPORTS_PER_VMA_LOCK if MMU
4649
select ARCH_USE_MEMTEST
4750
select ARCH_USE_QUEUED_RWLOCKS
4851
select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU
@@ -265,6 +268,12 @@ config RISCV_DMA_NONCOHERENT
265268
config AS_HAS_INSN
266269
def_bool $(as-instr,.insn r 51$(comma) 0$(comma) 0$(comma) t0$(comma) t0$(comma) zero)
267270

271+
config AS_HAS_OPTION_ARCH
272+
# https://reviews.llvm.org/D123515
273+
def_bool y
274+
depends on $(as-instr, .option arch$(comma) +m)
275+
depends on !$(as-instr, .option arch$(comma) -i)
276+
268277
source "arch/riscv/Kconfig.socs"
269278
source "arch/riscv/Kconfig.errata"
270279

@@ -463,13 +472,44 @@ config RISCV_ISA_SVPBMT
463472

464473
If you don't know what to do here, say Y.
465474

475+
config TOOLCHAIN_HAS_V
476+
bool
477+
default y
478+
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv)
479+
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv)
480+
depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800
481+
depends on AS_HAS_OPTION_ARCH
482+
483+
config RISCV_ISA_V
484+
bool "VECTOR extension support"
485+
depends on TOOLCHAIN_HAS_V
486+
depends on FPU
487+
select DYNAMIC_SIGFRAME
488+
default y
489+
help
490+
Say N here if you want to disable all vector related procedure
491+
in the kernel.
492+
493+
If you don't know what to do here, say Y.
494+
495+
config RISCV_ISA_V_DEFAULT_ENABLE
496+
bool "Enable userspace Vector by default"
497+
depends on RISCV_ISA_V
498+
default y
499+
help
500+
Say Y here if you want to enable Vector in userspace by default.
501+
Otherwise, userspace has to make explicit prctl() call to enable
502+
Vector, or enable it via the sysctl interface.
503+
504+
If you don't know what to do here, say Y.
505+
466506
config TOOLCHAIN_HAS_ZBB
467507
bool
468508
default y
469509
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbb)
470510
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbb)
471511
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
472-
depends on AS_IS_GNU
512+
depends on AS_HAS_OPTION_ARCH
473513

474514
config RISCV_ISA_ZBB
475515
bool "Zbb extension support for bit manipulation instructions"
@@ -554,6 +594,25 @@ config FPU
554594

555595
If you don't know what to do here, say Y.
556596

597+
config IRQ_STACKS
598+
bool "Independent irq & softirq stacks" if EXPERT
599+
default y
600+
select HAVE_IRQ_EXIT_ON_IRQ_STACK
601+
select HAVE_SOFTIRQ_ON_OWN_STACK
602+
help
603+
Add independent irq & softirq stacks for percpu to prevent kernel stack
604+
overflows. We may save some memory footprint by disabling IRQ_STACKS.
605+
606+
config THREAD_SIZE_ORDER
607+
int "Kernel stack size (in power-of-two numbers of page size)" if VMAP_STACK && EXPERT
608+
range 0 4
609+
default 1 if 32BIT && !KASAN
610+
default 3 if 64BIT && KASAN
611+
default 2
612+
help
613+
Specify the Pages of thread stack size (from 4KB to 64KB), which also
614+
affects irq stack size, which is equal to thread stack size.
615+
557616
endmenu # "Platform type"
558617

559618
menu "Kernel features"
@@ -710,6 +769,7 @@ config EFI
710769
depends on OF && !XIP_KERNEL
711770
depends on MMU
712771
default y
772+
select ARCH_SUPPORTS_ACPI if 64BIT
713773
select EFI_GENERIC_STUB
714774
select EFI_PARAMS_FROM_FDT
715775
select EFI_RUNTIME_WRAPPERS
@@ -822,3 +882,5 @@ source "drivers/cpufreq/Kconfig"
822882
endmenu # "CPU Power Management"
823883

824884
source "arch/riscv/kvm/Kconfig"
885+
886+
source "drivers/acpi/Kconfig"

arch/riscv/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
6060
riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
6161
riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
6262
riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
63+
riscv-march-$(CONFIG_RISCV_ISA_V) := $(riscv-march-y)v
6364

6465
ifdef CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC
6566
KBUILD_CFLAGS += -Wa,-misa-spec=2.2
@@ -71,7 +72,10 @@ endif
7172
# Check if the toolchain supports Zihintpause extension
7273
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause
7374

74-
KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
75+
# Remove F,D,V from isa string for all. Keep extensions between "fd" and "v" by
76+
# matching non-v and non-multi-letter extensions out with the filter ([^v_]*)
77+
KBUILD_CFLAGS += -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)fd([^v_]*)v?/\1\2/')
78+
7579
KBUILD_AFLAGS += -march=$(riscv-march-y)
7680

7781
KBUILD_CFLAGS += -mno-save-restore

0 commit comments

Comments
 (0)