Skip to content

Commit c150b80

Browse files
committed
Merge tag 'riscv-for-linus-6.9-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: - Support for various vector-accelerated crypto routines - Hibernation is now enabled for portable kernel builds - mmap_rnd_bits_max is larger on systems with larger VAs - Support for fast GUP - Support for membarrier-based instruction cache synchronization - Support for the Andes hart-level interrupt controller and PMU - Some cleanups around unaligned access speed probing and Kconfig settings - Support for ACPI LPI and CPPC - Various cleanus related to barriers - A handful of fixes * tag 'riscv-for-linus-6.9-mw2' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: (66 commits) riscv: Fix syscall wrapper for >word-size arguments crypto: riscv - add vector crypto accelerated AES-CBC-CTS crypto: riscv - parallelize AES-CBC decryption riscv: Only flush the mm icache when setting an exec pte riscv: Use kcalloc() instead of kzalloc() riscv/barrier: Add missing space after ',' riscv/barrier: Consolidate fence definitions riscv/barrier: Define RISCV_FULL_BARRIER riscv/barrier: Define __{mb,rmb,wmb} RISC-V: defconfig: Enable CONFIG_ACPI_CPPC_CPUFREQ cpufreq: Move CPPC configs to common Kconfig and add RISC-V ACPI: RISC-V: Add CPPC driver ACPI: Enable ACPI_PROCESSOR for RISC-V ACPI: RISC-V: Add LPI driver cpuidle: RISC-V: Move few functions to arch/riscv riscv: Introduce set_compat_task() in asm/compat.h riscv: Introduce is_compat_thread() into compat.h riscv: add compile-time test into is_compat_task() riscv: Replace direct thread flag check with is_compat_task() riscv: Improve arch_get_mmap_end() macro ...
2 parents 1e3cd03 + a9ad732 commit c150b80

File tree

105 files changed

+5183
-747
lines changed

Some content is hidden

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

105 files changed

+5183
-747
lines changed

Documentation/arch/riscv/vm-layout.rst

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,8 @@ passing 0 into the hint address parameter of mmap. On CPUs with an address space
144144
smaller than sv48, the CPU maximum supported address space will be the default.
145145

146146
Software can "opt-in" to receiving VAs from another VA space by providing
147-
a hint address to mmap. A hint address passed to mmap will cause the largest
148-
address space that fits entirely into the hint to be used, unless there is no
149-
space left in the address space. If there is no space available in the requested
150-
address space, an address in the next smallest available address space will be
151-
returned.
152-
153-
For example, in order to obtain 48-bit VA space, a hint address greater than
154-
:code:`1 << 47` must be provided. Note that this is 47 due to sv48 userspace
155-
ending at :code:`1 << 47` and the addresses beyond this are reserved for the
156-
kernel. Similarly, to obtain 57-bit VA space addresses, a hint address greater
157-
than or equal to :code:`1 << 56` must be provided.
147+
a hint address to mmap. When a hint address is passed to mmap, the returned
148+
address will never use more bits than the hint address. For example, if a hint
149+
address of `1 << 40` is passed to mmap, a valid returned address will never use
150+
bits 41 through 63. If no mappable addresses are available in that range, mmap
151+
will return `MAP_FAILED`.

Documentation/devicetree/bindings/riscv/cpus.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ properties:
110110
const: 1
111111

112112
compatible:
113-
const: riscv,cpu-intc
113+
oneOf:
114+
- items:
115+
- const: andestech,cpu-intc
116+
- const: riscv,cpu-intc
117+
- const: riscv,cpu-intc
114118

115119
interrupt-controller: true
116120

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -477,5 +477,12 @@ properties:
477477
latency, as ratified in commit 56ed795 ("Update
478478
riscv-crypto-spec-vector.adoc") of riscv-crypto.
479479

480+
- const: xandespmu
481+
description:
482+
The Andes Technology performance monitor extension for counter overflow
483+
and privilege mode filtering. For more details, see Counter Related
484+
Registers in the AX45MP datasheet.
485+
https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
486+
480487
additionalProperties: true
481488
...

Documentation/features/sched/membarrier-sync-core/arch-support.txt

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,22 @@
1010
# Rely on implicit context synchronization as a result of exception return
1111
# when returning from IPI handler, and when returning to user-space.
1212
#
13+
# * riscv
14+
#
15+
# riscv uses xRET as return from interrupt and to return to user-space.
16+
#
17+
# Given that xRET is not core serializing, we rely on FENCE.I for providing
18+
# core serialization:
19+
#
20+
# - by calling sync_core_before_usermode() on return from interrupt (cf.
21+
# ipi_sync_core()),
22+
#
23+
# - via switch_mm() and sync_core_before_usermode() (respectively, for
24+
# uthread->uthread and kthread->uthread transitions) before returning
25+
# to user-space.
26+
#
27+
# The serialization in switch_mm() is activated by prepare_sync_core_cmd().
28+
#
1329
# * x86
1430
#
1531
# x86-32 uses IRET as return from interrupt, which takes care of the IPI.
@@ -43,7 +59,7 @@
4359
| openrisc: | TODO |
4460
| parisc: | TODO |
4561
| powerpc: | ok |
46-
| riscv: | TODO |
62+
| riscv: | ok |
4763
| s390: | ok |
4864
| sh: | TODO |
4965
| sparc: | TODO |

Documentation/scheduler/index.rst

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

88

99
completion
10+
membarrier
1011
sched-arch
1112
sched-bwc
1213
sched-deadline
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
.. SPDX-License-Identifier: GPL-2.0
2+
3+
========================
4+
membarrier() System Call
5+
========================
6+
7+
MEMBARRIER_CMD_{PRIVATE,GLOBAL}_EXPEDITED - Architecture requirements
8+
=====================================================================
9+
10+
Memory barriers before updating rq->curr
11+
----------------------------------------
12+
13+
The commands MEMBARRIER_CMD_PRIVATE_EXPEDITED and MEMBARRIER_CMD_GLOBAL_EXPEDITED
14+
require each architecture to have a full memory barrier after coming from
15+
user-space, before updating rq->curr. This barrier is implied by the sequence
16+
rq_lock(); smp_mb__after_spinlock() in __schedule(). The barrier matches a full
17+
barrier in the proximity of the membarrier system call exit, cf.
18+
membarrier_{private,global}_expedited().
19+
20+
Memory barriers after updating rq->curr
21+
---------------------------------------
22+
23+
The commands MEMBARRIER_CMD_PRIVATE_EXPEDITED and MEMBARRIER_CMD_GLOBAL_EXPEDITED
24+
require each architecture to have a full memory barrier after updating rq->curr,
25+
before returning to user-space. The schemes providing this barrier on the various
26+
architectures are as follows.
27+
28+
- alpha, arc, arm, hexagon, mips rely on the full barrier implied by
29+
spin_unlock() in finish_lock_switch().
30+
31+
- arm64 relies on the full barrier implied by switch_to().
32+
33+
- powerpc, riscv, s390, sparc, x86 rely on the full barrier implied by
34+
switch_mm(), if mm is not NULL; they rely on the full barrier implied
35+
by mmdrop(), otherwise. On powerpc and riscv, switch_mm() relies on
36+
membarrier_arch_switch_mm().
37+
38+
The barrier matches a full barrier in the proximity of the membarrier system call
39+
entry, cf. membarrier_{private,global}_expedited().

MAINTAINERS

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14134,7 +14134,9 @@ M: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
1413414134
M: "Paul E. McKenney" <paulmck@kernel.org>
1413514135
L: linux-kernel@vger.kernel.org
1413614136
S: Supported
14137-
F: arch/powerpc/include/asm/membarrier.h
14137+
F: Documentation/scheduler/membarrier.rst
14138+
F: arch/*/include/asm/membarrier.h
14139+
F: arch/*/include/asm/sync_core.h
1413814140
F: include/uapi/linux/membarrier.h
1413914141
F: kernel/sched/membarrier.c
1414014142

arch/riscv/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
obj-y += kernel/ mm/ net/
44
obj-$(CONFIG_BUILTIN_DTB) += boot/dts/
5+
obj-$(CONFIG_CRYPTO) += crypto/
56
obj-y += errata/
67
obj-$(CONFIG_KVM) += kvm/
78

arch/riscv/Kconfig

Lines changed: 64 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,18 @@ config RISCV
2727
select ARCH_HAS_GCOV_PROFILE_ALL
2828
select ARCH_HAS_GIGANTIC_PAGE
2929
select ARCH_HAS_KCOV
30+
select ARCH_HAS_MEMBARRIER_CALLBACKS
31+
select ARCH_HAS_MEMBARRIER_SYNC_CORE
3032
select ARCH_HAS_MMIOWB
3133
select ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
3234
select ARCH_HAS_PMEM_API
35+
select ARCH_HAS_PREPARE_SYNC_CORE_CMD
3336
select ARCH_HAS_PTE_SPECIAL
3437
select ARCH_HAS_SET_DIRECT_MAP if MMU
3538
select ARCH_HAS_SET_MEMORY if MMU
3639
select ARCH_HAS_STRICT_KERNEL_RWX if MMU && !XIP_KERNEL
3740
select ARCH_HAS_STRICT_MODULE_RWX if MMU && !XIP_KERNEL
41+
select ARCH_HAS_SYNC_CORE_BEFORE_USERMODE
3842
select ARCH_HAS_SYSCALL_WRAPPER
3943
select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST
4044
select ARCH_HAS_UBSAN
@@ -47,6 +51,9 @@ config RISCV
4751
select ARCH_SUPPORTS_CFI_CLANG
4852
select ARCH_SUPPORTS_DEBUG_PAGEALLOC if MMU
4953
select ARCH_SUPPORTS_HUGETLBFS if MMU
54+
# LLD >= 14: https://github.com/llvm/llvm-project/issues/50505
55+
select ARCH_SUPPORTS_LTO_CLANG if LLD_VERSION >= 140000
56+
select ARCH_SUPPORTS_LTO_CLANG_THIN if LLD_VERSION >= 140000
5057
select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
5158
select ARCH_SUPPORTS_PER_VMA_LOCK if MMU
5259
select ARCH_SUPPORTS_SHADOW_CALL_STACK if HAVE_SHADOW_CALL_STACK
@@ -106,6 +113,7 @@ config RISCV
106113
select HAVE_ARCH_KGDB_QXFER_PKT
107114
select HAVE_ARCH_MMAP_RND_BITS if MMU
108115
select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT
116+
select HAVE_ARCH_RANDOMIZE_KSTACK_OFFSET
109117
select HAVE_ARCH_SECCOMP_FILTER
110118
select HAVE_ARCH_THREAD_STRUCT_WHITELIST
111119
select HAVE_ARCH_TRACEHOOK
@@ -124,6 +132,7 @@ config RISCV
124132
select HAVE_FUNCTION_GRAPH_RETVAL if HAVE_FUNCTION_GRAPH_TRACER
125133
select HAVE_FUNCTION_TRACER if !XIP_KERNEL && !PREEMPTION
126134
select HAVE_EBPF_JIT if MMU
135+
select HAVE_FAST_GUP if MMU
127136
select HAVE_FUNCTION_ARG_ACCESS_API
128137
select HAVE_FUNCTION_ERROR_INJECTION
129138
select HAVE_GCC_PLUGINS
@@ -155,6 +164,7 @@ config RISCV
155164
select IRQ_FORCED_THREADING
156165
select KASAN_VMALLOC if KASAN
157166
select LOCK_MM_AND_FIND_VMA
167+
select MMU_GATHER_RCU_TABLE_FREE if SMP && MMU
158168
select MODULES_USE_ELF_RELA if MODULES
159169
select MODULE_SECTIONS if MODULES
160170
select OF
@@ -576,6 +586,13 @@ config TOOLCHAIN_HAS_ZBB
576586
depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
577587
depends on AS_HAS_OPTION_ARCH
578588

589+
# This symbol indicates that the toolchain supports all v1.0 vector crypto
590+
# extensions, including Zvk*, Zvbb, and Zvbc. LLVM added all of these at once.
591+
# binutils added all except Zvkb, then added Zvkb. So we just check for Zvkb.
592+
config TOOLCHAIN_HAS_VECTOR_CRYPTO
593+
def_bool $(as-instr, .option arch$(comma) +v$(comma) +zvkb)
594+
depends on AS_HAS_OPTION_ARCH
595+
579596
config RISCV_ISA_ZBB
580597
bool "Zbb extension support for bit manipulation instructions"
581598
depends on TOOLCHAIN_HAS_ZBB
@@ -686,27 +703,61 @@ config THREAD_SIZE_ORDER
686703
affects irq stack size, which is equal to thread stack size.
687704

688705
config RISCV_MISALIGNED
689-
bool "Support misaligned load/store traps for kernel and userspace"
706+
bool
690707
select SYSCTL_ARCH_UNALIGN_ALLOW
691-
default y
692708
help
693-
Say Y here if you want the kernel to embed support for misaligned
694-
load/store for both kernel and userspace. When disable, misaligned
695-
accesses will generate SIGBUS in userspace and panic in kernel.
709+
Embed support for emulating misaligned loads and stores.
710+
711+
choice
712+
prompt "Unaligned Accesses Support"
713+
default RISCV_PROBE_UNALIGNED_ACCESS
714+
help
715+
This determines the level of support for unaligned accesses. This
716+
information is used by the kernel to perform optimizations. It is also
717+
exposed to user space via the hwprobe syscall. The hardware will be
718+
probed at boot by default.
719+
720+
config RISCV_PROBE_UNALIGNED_ACCESS
721+
bool "Probe for hardware unaligned access support"
722+
select RISCV_MISALIGNED
723+
help
724+
During boot, the kernel will run a series of tests to determine the
725+
speed of unaligned accesses. This probing will dynamically determine
726+
the speed of unaligned accesses on the underlying system. If unaligned
727+
memory accesses trap into the kernel as they are not supported by the
728+
system, the kernel will emulate the unaligned accesses to preserve the
729+
UABI.
730+
731+
config RISCV_EMULATED_UNALIGNED_ACCESS
732+
bool "Emulate unaligned access where system support is missing"
733+
select RISCV_MISALIGNED
734+
help
735+
If unaligned memory accesses trap into the kernel as they are not
736+
supported by the system, the kernel will emulate the unaligned
737+
accesses to preserve the UABI. When the underlying system does support
738+
unaligned accesses, the unaligned accesses are assumed to be slow.
739+
740+
config RISCV_SLOW_UNALIGNED_ACCESS
741+
bool "Assume the system supports slow unaligned memory accesses"
742+
depends on NONPORTABLE
743+
help
744+
Assume that the system supports slow unaligned memory accesses. The
745+
kernel and userspace programs may not be able to run at all on systems
746+
that do not support unaligned memory accesses.
696747

697748
config RISCV_EFFICIENT_UNALIGNED_ACCESS
698-
bool "Assume the CPU supports fast unaligned memory accesses"
749+
bool "Assume the system supports fast unaligned memory accesses"
699750
depends on NONPORTABLE
700751
select DCACHE_WORD_ACCESS if MMU
701752
select HAVE_EFFICIENT_UNALIGNED_ACCESS
702753
help
703-
Say Y here if you want the kernel to assume that the CPU supports
704-
efficient unaligned memory accesses. When enabled, this option
705-
improves the performance of the kernel on such CPUs. However, the
706-
kernel will run much more slowly, or will not be able to run at all,
707-
on CPUs that do not support efficient unaligned memory accesses.
754+
Assume that the system supports fast unaligned memory accesses. When
755+
enabled, this option improves the performance of the kernel on such
756+
systems. However, the kernel and userspace programs will run much more
757+
slowly, or will not be able to run at all, on systems that do not
758+
support efficient unaligned memory accesses.
708759

709-
If unsure what to do here, say N.
760+
endchoice
710761

711762
endmenu # "Platform type"
712763

@@ -1011,11 +1062,8 @@ menu "Power management options"
10111062

10121063
source "kernel/power/Kconfig"
10131064

1014-
# Hibernation is only possible on systems where the SBI implementation has
1015-
# marked its reserved memory as not accessible from, or does not run
1016-
# from the same memory as, Linux
10171065
config ARCH_HIBERNATION_POSSIBLE
1018-
def_bool NONPORTABLE
1066+
def_bool y
10191067

10201068
config ARCH_HIBERNATION_HEADER
10211069
def_bool HIBERNATION

arch/riscv/Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ ifndef CONFIG_AS_IS_LLVM
5050
KBUILD_CFLAGS += -Wa,-mno-relax
5151
KBUILD_AFLAGS += -Wa,-mno-relax
5252
endif
53+
# LLVM has an issue with target-features and LTO: https://github.com/llvm/llvm-project/issues/59350
54+
# Ensure it is aware of linker relaxation with LTO, otherwise relocations may
55+
# be incorrect: https://github.com/llvm/llvm-project/issues/65090
56+
else ifeq ($(CONFIG_LTO_CLANG),y)
57+
KBUILD_LDFLAGS += -mllvm -mattr=+c -mllvm -mattr=+relax
5358
endif
5459

5560
ifeq ($(CONFIG_SHADOW_CALL_STACK),y)

0 commit comments

Comments
 (0)