Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b76563d
Revert "xtheadvector: fix it used as v-ext when hwprobe is used"
Jul 29, 2026
d81c3b1
Revert "riscv: xtheadvector: enable vector function"
Jul 29, 2026
7dc044f
riscv: dts: allwinner: convert isa detection to new properties
ConchuOD Oct 9, 2023
1a1d1c3
dt-bindings: cpus: add a thead vlen register length property
charlie-rivos Nov 14, 2024
c6e2559
riscv: dts: allwinner: Add xtheadvector to the D1/D1s devicetree
charlie-rivos Nov 14, 2024
afb5503
riscv: Add thead and xtheadvector as a vendor extension
charlie-rivos Nov 14, 2024
2032a6a
riscv: vector: Use vlenb from DT for thead
charlie-rivos Nov 14, 2024
19ca02e
RISC-V: define the elements of the VCSR vector CSR
mmind Nov 14, 2024
6660012
riscv: csr: Add CSR encodings for CSR_VXRM/CSR_VXSAT
charlie-rivos Nov 14, 2024
01d696f
riscv: Add xtheadvector instruction definitions
charlie-rivos Nov 14, 2024
7d796aa
riscv: vector: Support xtheadvector save/restore
charlie-rivos Nov 14, 2024
963c9da
riscv: hwprobe: Document thead vendor extensions and xtheadvector ext…
charlie-rivos Nov 14, 2024
0992bf2
selftests: riscv: Fix vector tests
charlie-rivos Nov 14, 2024
75b3f62
selftests: riscv: Support xtheadvector in vector tests
charlie-rivos Nov 14, 2024
d3d0334
riscv: vector: Fix context save/restore with xtheadvector
RevySR May 23, 2025
3d54575
riscv: cpufeature: avoid uninitialized variable in has_thead_homogene…
Oct 18, 2025
2fda4c0
riscv: dts: allwinner: d1: fix vlenb property
geomatsi Nov 19, 2025
7d94c2c
riscv: dts: thead: add xtheadvector to the th1520 devicetree
RevySR Sep 18, 2025
b557c93
riscv: vector: adjust minimum Vector requirement to ZVE32X
AndybnACT May 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Documentation/arch/riscv/hwprobe.rst
Original file line number Diff line number Diff line change
Expand Up @@ -354,3 +354,13 @@ The following keys are defined:

* :c:macro:`RISCV_HWPROBE_MISALIGNED_VECTOR_UNSUPPORTED`: Misaligned vector accesses are
not supported at all and will generate a misaligned address fault.

* :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0`: A bitmask containing the
thead vendor extensions that are compatible with the
:c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.

* T-HEAD

* :c:macro:`RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR`: The xtheadvector vendor
extension is supported in the T-Head ISA extensions spec starting from
commit a18c801634 ("Add T-Head VECTOR vendor extension. ").
19 changes: 19 additions & 0 deletions Documentation/devicetree/bindings/riscv/cpus.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ description: |
allOf:
- $ref: /schemas/cpu.yaml#
- $ref: extensions.yaml
- if:
not:
properties:
compatible:
contains:
enum:
- thead,c906
- thead,c910
- thead,c920
then:
properties:
thead,vlenb: false

properties:
compatible:
Expand Down Expand Up @@ -83,6 +95,13 @@ properties:
description:
The blocksize in bytes for the Zicboz cache operations.

thead,vlenb:
$ref: /schemas/types.yaml#/definitions/uint32
description:
VLEN/8, the vector register length in bytes. This property is required on
thead systems where the vector register length is not identical on all harts, or
the vlenb CSR is not available.

# RISC-V has multiple properties for cache op block sizes as the sizes
# differ between individual CBO extensions
cache-op-block-size: false
Expand Down
26 changes: 26 additions & 0 deletions arch/riscv/Kconfig.vendor
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,30 @@ config RISCV_ISA_VENDOR_EXT_ANDES
If you don't know what to do here, say Y.
endmenu

menu "T-Head"
config RISCV_ISA_VENDOR_EXT_THEAD
bool "T-Head vendor extension support"
select RISCV_ISA_VENDOR_EXT
default y
help
Say N here to disable detection of and support for all T-Head vendor
extensions. Without this option enabled, T-Head vendor extensions will
not be detected at boot and their presence not reported to userspace.

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

config RISCV_ISA_XTHEADVECTOR
bool "xtheadvector extension support"
depends on RISCV_ISA_VENDOR_EXT_THEAD
depends on RISCV_ISA_V
depends on FPU
default y
help
Say N here if you want to disable all xtheadvector related procedures
in the kernel. This will disable vector for any T-Head board that
contains xtheadvector rather than the standard vector.

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

endmenu
4 changes: 4 additions & 0 deletions arch/riscv/boot/dts/allwinner/sun20i-d1s.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
mmu-type = "riscv,sv39";
operating-points-v2 = <&opp_table_cpu>;
riscv,isa = "rv64imafdc";
riscv,isa-base = "rv64i";
riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
"zifencei", "zihpm", "xtheadvector";
thead,vlenb = <16>;
#cooling-cells = <2>;

cpu0_intc: interrupt-controller {
Expand Down
24 changes: 20 additions & 4 deletions arch/riscv/boot/dts/thead/th1520.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@
c910_0: cpu@0 {
compatible = "thead,c910", "riscv";
device_type = "cpu";
riscv,isa = "rv64imafdc";
riscv,isa = "rv64imafdc_xtheadvector";
riscv,isa-base = "rv64i";
riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
"zifencei", "zihpm", "xtheadvector";
thead,vlenb = <16>;
reg = <0>;
i-cache-block-size = <64>;
i-cache-size = <65536>;
Expand Down Expand Up @@ -99,7 +103,11 @@
c910_1: cpu@1 {
compatible = "thead,c910", "riscv";
device_type = "cpu";
riscv,isa = "rv64imafdc";
riscv,isa = "rv64imafdc_xtheadvector";
riscv,isa-base = "rv64i";
riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
"zifencei", "zihpm", "xtheadvector";
thead,vlenb = <16>;
reg = <1>;
i-cache-block-size = <64>;
i-cache-size = <65536>;
Expand Down Expand Up @@ -130,7 +138,11 @@
c910_2: cpu@2 {
compatible = "thead,c910", "riscv";
device_type = "cpu";
riscv,isa = "rv64imafdc";
riscv,isa = "rv64imafdc_xtheadvector";
riscv,isa-base = "rv64i";
riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
"zifencei", "zihpm", "xtheadvector";
thead,vlenb = <16>;
reg = <2>;
i-cache-block-size = <64>;
i-cache-size = <65536>;
Expand Down Expand Up @@ -161,7 +173,11 @@
c910_3: cpu@3 {
compatible = "thead,c910", "riscv";
device_type = "cpu";
riscv,isa = "rv64imafdc";
riscv,isa = "rv64imafdc_xtheadvector";
riscv,isa-base = "rv64i";
riscv,isa-extensions = "i", "m", "a", "f", "d", "c", "zicntr", "zicsr",
"zifencei", "zihpm", "xtheadvector";
thead,vlenb = <16>;
reg = <3>;
i-cache-block-size = <64>;
i-cache-size = <65536>;
Expand Down
2 changes: 2 additions & 0 deletions arch/riscv/include/asm/cpufeature.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ DECLARE_PER_CPU(struct riscv_cpuinfo, riscv_cpuinfo);
/* Per-cpu ISA extensions. */
extern struct riscv_isainfo hart_isa[NR_CPUS];

extern u32 thead_vlenb_of;

void __init riscv_user_isa_enable(void);

#define _RISCV_ISA_EXT_DATA(_name, _id, _subset_exts, _subset_exts_size, _validate) { \
Expand Down
18 changes: 18 additions & 0 deletions arch/riscv/include/asm/csr.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
#define SR_VS_CLEAN _AC(0x00000400, UL)
#define SR_VS_DIRTY _AC(0x00000600, UL)

#define SR_VS_THEAD _AC(0x01800000, UL) /* xtheadvector Status */
#define SR_VS_OFF_THEAD _AC(0x00000000, UL)
#define SR_VS_INITIAL_THEAD _AC(0x00800000, UL)
#define SR_VS_CLEAN_THEAD _AC(0x01000000, UL)
#define SR_VS_DIRTY_THEAD _AC(0x01800000, UL)

#define SR_XS _AC(0x00018000, UL) /* Extension Status */
#define SR_XS_OFF _AC(0x00000000, UL)
#define SR_XS_INITIAL _AC(0x00008000, UL)
Expand Down Expand Up @@ -301,6 +307,18 @@
#define CSR_STIMECMP 0x14D
#define CSR_STIMECMPH 0x15D

/* zicfiss user mode csr. CSR_SSP holds current shadow stack pointer */
#define CSR_SSP 0x011

/* xtheadvector symbolic CSR names */
#define CSR_VXSAT 0x9
#define CSR_VXRM 0xa

/* xtheadvector CSR masks */
#define CSR_VXRM_MASK 3
#define CSR_VXRM_SHIFT 1
#define CSR_VXSAT_MASK 1

/* Supervisor-Level Window to Indirectly Accessed Registers (AIA) */
#define CSR_SISELECT 0x150
#define CSR_SIREG 0x151
Expand Down
1 change: 0 additions & 1 deletion arch/riscv/include/asm/hwcap.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#define RISCV_ISA_EXT_ZICSR 40
#define RISCV_ISA_EXT_ZIFENCEI 41
#define RISCV_ISA_EXT_ZIHPM 42
#define RISCV_ISA_EXT_XTHEADVECTOR 43
#define RISCV_ISA_EXT_SMSTATEEN 44
#define RISCV_ISA_EXT_ZICOND 45
#define RISCV_ISA_EXT_ZBC 46
Expand Down
2 changes: 1 addition & 1 deletion arch/riscv/include/asm/switch_to.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ do { \
struct task_struct *__next = (next); \
if (has_fpu()) \
__switch_to_fpu(__prev, __next); \
if (has_vector()) \
if (has_vector() || has_xtheadvector()) \
__switch_to_vector(__prev, __next); \
__switch_to_envcfg(__next); \
__switch_sse_entry_task(__next); \
Expand Down
Loading
Loading