Skip to content

Commit 1b5f3c5

Browse files
committed
Merge tag 'riscv-for-linus-6.14-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux
Pull RISC-V updates from Palmer Dabbelt: - The PH1520 pinctrl and dwmac drivers are enabeled in defconfig - A redundant AQRL barrier has been removed from the futex cmpxchg implementation - Support for the T-Head vector extensions, which includes exposing these extensions to userspace on systems that implement them - Some more page table information is now printed on die() and systems that cause PA overflows * tag 'riscv-for-linus-6.14-mw1' of git://git.kernel.org/pub/scm/linux/kernel/git/riscv/linux: riscv: add a warning when physical memory address overflows riscv/mm/fault: add show_pte() before die() riscv: Add ghostwrite vulnerability selftests: riscv: Support xtheadvector in vector tests selftests: riscv: Fix vector tests riscv: hwprobe: Document thead vendor extensions and xtheadvector extension riscv: hwprobe: Add thead vendor extension probing riscv: vector: Support xtheadvector save/restore riscv: Add xtheadvector instruction definitions riscv: csr: Add CSR encodings for CSR_VXRM/CSR_VXSAT RISC-V: define the elements of the VCSR vector CSR riscv: vector: Use vlenb from DT for thead riscv: Add thead and xtheadvector as a vendor extension riscv: dts: allwinner: Add xtheadvector to the D1/D1s devicetree dt-bindings: cpus: add a thead vlen register length property dt-bindings: riscv: Add xtheadvector ISA extension description RISC-V: Mark riscv_v_init() as __init riscv: defconfig: drop RT_GROUP_SCHED=y riscv/futex: Optimize atomic cmpxchg riscv: defconfig: enable pinctrl and dwmac support for TH1520
2 parents fd8c09a + 1019712 commit 1b5f3c5

File tree

47 files changed

+1111
-282
lines changed

Some content is hidden

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

47 files changed

+1111
-282
lines changed

Documentation/arch/riscv/hwprobe.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,3 +293,13 @@ The following keys are defined:
293293

294294
* :c:macro:`RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED`: Misaligned vector accesses are
295295
not supported at all and will generate a misaligned address fault.
296+
297+
* :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0`: A bitmask containing the
298+
thead vendor extensions that are compatible with the
299+
:c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
300+
301+
* T-HEAD
302+
303+
* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR`: The xtheadvector vendor
304+
extension is supported in the T-Head ISA extensions spec starting from
305+
commit a18c801634 ("Add T-Head VECTOR vendor extension. ").

Documentation/devicetree/bindings/riscv/cpus.yaml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ description: |
2626
allOf:
2727
- $ref: /schemas/cpu.yaml#
2828
- $ref: extensions.yaml
29+
- if:
30+
not:
31+
properties:
32+
compatible:
33+
contains:
34+
enum:
35+
- thead,c906
36+
- thead,c910
37+
- thead,c920
38+
then:
39+
properties:
40+
thead,vlenb: false
2941

3042
properties:
3143
compatible:
@@ -96,6 +108,13 @@ properties:
96108
description:
97109
The blocksize in bytes for the Zicboz cache operations.
98110

111+
thead,vlenb:
112+
$ref: /schemas/types.yaml#/definitions/uint32
113+
description:
114+
VLEN/8, the vector register length in bytes. This property is required on
115+
thead systems where the vector register length is not identical on all harts, or
116+
the vlenb CSR is not available.
117+
99118
# RISC-V has multiple properties for cache op block sizes as the sizes
100119
# differ between individual CBO extensions
101120
cache-op-block-size: false

Documentation/devicetree/bindings/riscv/extensions.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,13 +621,23 @@ properties:
621621
latency, as ratified in commit 56ed795 ("Update
622622
riscv-crypto-spec-vector.adoc") of riscv-crypto.
623623

624+
# vendor extensions, each extension sorted alphanumerically under the
625+
# vendor they belong to. Vendors are sorted alphanumerically as well.
626+
627+
# Andes
624628
- const: xandespmu
625629
description:
626630
The Andes Technology performance monitor extension for counter overflow
627631
and privilege mode filtering. For more details, see Counter Related
628632
Registers in the AX45MP datasheet.
629633
https://www.andestech.com/wp-content/uploads/AX45MP-1C-Rev.-5.0.0-Datasheet.pdf
630634

635+
# T-HEAD
636+
- const: xtheadvector
637+
description:
638+
The T-HEAD specific 0.7.1 vector implementation as written in
639+
https://github.com/T-head-Semi/thead-extension-spec/blob/95358cb2cca9489361c61d335e03d3134b14133f/xtheadvector.adoc.
640+
631641
allOf:
632642
# Zcb depends on Zca
633643
- if:

arch/riscv/Kconfig.errata

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,15 @@ config ERRATA_THEAD_PMU
119119

120120
If you don't know what to do here, say "Y".
121121

122+
config ERRATA_THEAD_GHOSTWRITE
123+
bool "Apply T-Head Ghostwrite errata"
124+
depends on ERRATA_THEAD && RISCV_ISA_XTHEADVECTOR
125+
default y
126+
help
127+
The T-Head C9xx cores have a vulnerability in the xtheadvector
128+
instruction set. When this errata is enabled, the CPUs will be probed
129+
to determine if they are vulnerable and disable xtheadvector.
130+
131+
If you don't know what to do here, say "Y".
132+
122133
endmenu # "CPU errata selection"

arch/riscv/Kconfig.vendor

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

19+
menu "T-Head"
20+
config RISCV_ISA_VENDOR_EXT_THEAD
21+
bool "T-Head vendor extension support"
22+
select RISCV_ISA_VENDOR_EXT
23+
default y
24+
help
25+
Say N here to disable detection of and support for all T-Head vendor
26+
extensions. Without this option enabled, T-Head vendor extensions will
27+
not be detected at boot and their presence not reported to userspace.
28+
29+
If you don't know what to do here, say Y.
30+
31+
config RISCV_ISA_XTHEADVECTOR
32+
bool "xtheadvector extension support"
33+
depends on RISCV_ISA_VENDOR_EXT_THEAD
34+
depends on RISCV_ISA_V
35+
depends on FPU
36+
default y
37+
help
38+
Say N here if you want to disable all xtheadvector related procedures
39+
in the kernel. This will disable vector for any T-Head board that
40+
contains xtheadvector rather than the standard vector.
41+
42+
If you don't know what to do here, say Y.
43+
endmenu
44+
1945
endmenu

arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
riscv,isa = "rv64imafdc";
2828
riscv,isa-base = "rv64i";
2929
riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
30-
"zifencei", "zihpm";
30+
"zifencei", "zihpm", "xtheadvector";
31+
thead,vlenb = <128>;
3132
#cooling-cells = <2>;
3233

3334
cpu0_intc: interrupt-controller {

arch/riscv/configs/defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ CONFIG_MEMCG=y
1010
CONFIG_BLK_CGROUP=y
1111
CONFIG_CGROUP_SCHED=y
1212
CONFIG_CFS_BANDWIDTH=y
13-
CONFIG_RT_GROUP_SCHED=y
1413
CONFIG_CGROUP_PIDS=y
1514
CONFIG_CGROUP_FREEZER=y
1615
CONFIG_CGROUP_HUGETLB=y

arch/riscv/errata/thead/errata.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/string.h>
1111
#include <linux/uaccess.h>
1212
#include <asm/alternative.h>
13+
#include <asm/bugs.h>
1314
#include <asm/cacheflush.h>
1415
#include <asm/cpufeature.h>
1516
#include <asm/dma-noncoherent.h>
@@ -142,6 +143,31 @@ static bool errata_probe_pmu(unsigned int stage,
142143
return true;
143144
}
144145

146+
static bool errata_probe_ghostwrite(unsigned int stage,
147+
unsigned long arch_id, unsigned long impid)
148+
{
149+
if (!IS_ENABLED(CONFIG_ERRATA_THEAD_GHOSTWRITE))
150+
return false;
151+
152+
/*
153+
* target-c9xx cores report arch_id and impid as 0
154+
*
155+
* While ghostwrite may not affect all c9xx cores that implement
156+
* xtheadvector, there is no futher granularity than c9xx. Assume
157+
* vulnerable for this entire class of processors when xtheadvector is
158+
* enabled.
159+
*/
160+
if (arch_id != 0 || impid != 0)
161+
return false;
162+
163+
if (stage != RISCV_ALTERNATIVES_EARLY_BOOT)
164+
return false;
165+
166+
ghostwrite_set_vulnerable();
167+
168+
return true;
169+
}
170+
145171
static u32 thead_errata_probe(unsigned int stage,
146172
unsigned long archid, unsigned long impid)
147173
{
@@ -155,6 +181,8 @@ static u32 thead_errata_probe(unsigned int stage,
155181
if (errata_probe_pmu(stage, archid, impid))
156182
cpu_req_errata |= BIT(ERRATA_THEAD_PMU);
157183

184+
errata_probe_ghostwrite(stage, archid, impid);
185+
158186
return cpu_req_errata;
159187
}
160188

arch/riscv/include/asm/bugs.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/* SPDX-License-Identifier: GPL-2.0-only */
2+
/*
3+
* Interface for managing mitigations for riscv vulnerabilities.
4+
*
5+
* Copyright (C) 2024 Rivos Inc.
6+
*/
7+
8+
#ifndef __ASM_BUGS_H
9+
#define __ASM_BUGS_H
10+
11+
/* Watch out, ordering is important here. */
12+
enum mitigation_state {
13+
UNAFFECTED,
14+
MITIGATED,
15+
VULNERABLE,
16+
};
17+
18+
void ghostwrite_set_vulnerable(void);
19+
bool ghostwrite_enable_mitigation(void);
20+
enum mitigation_state ghostwrite_get_state(void);
21+
22+
#endif /* __ASM_BUGS_H */

arch/riscv/include/asm/cpufeature.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ DECLARE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo);
3434
/* Per-cpu ISA extensions. */
3535
extern struct riscv_isainfo hart_isa[NR_CPUS];
3636

37+
extern u32 thead_vlenb_of;
38+
3739
void __init riscv_user_isa_enable(void);
3840

3941
#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _validate) { \

0 commit comments

Comments
 (0)