Skip to content

riscv: backport mainline xtheadvector support - #355

Open
zhuzhenxxx-collab wants to merge 22 commits into
RVCK-Project:rvck-6.6from
zhuzhenxxx-collab:rvck-6.6-xtheadvector-backport
Open

riscv: backport mainline xtheadvector support #355
zhuzhenxxx-collab wants to merge 22 commits into
RVCK-Project:rvck-6.6from
zhuzhenxxx-collab:rvck-6.6-xtheadvector-backport

Conversation

@zhuzhenxxx-collab

@zhuzhenxxx-collab zhuzhenxxx-collab commented Jul 31, 2026

Copy link
Copy Markdown

将上游 xtheadvector 主线支持 backport 到 rvck-6.6。先 revert 基线 4 个旧改 commit,再合入 18 个上游 commit。共 22 commits。

Reverts (4)

  • Revert "fix: riscv: xtheadvector: fix setup_v_vsize"
  • Revert "xtheadvector: fix it used as v-ext when hwprobe is used"
  • Revert "riscv: xtheadvector: enable vector function"
  • Revert "T-Head C9xx cores implement an older version (0.7.1) of the vector specification."

Series 1: riscv: Add support for xtheadvector (v11, Charlie Jenkins)

Cover: https://lore.kernel.org/r/20241113-xtheadvector-v11-0-236c22791ef9@rivosinc.com

13 patches 合入 12 个,patch 10 (21e49e64f307) 基线已有,跳过。

  • [01/13] e576b7cb8183 dt-bindings: riscv: Add xtheadvector ISA extension description
  • [02/13] bf6279b38a4b dt-bindings: cpus: add a thead vlen register length property
  • [03/13] ce1daeeba600 riscv: dts: allwinner: Add xtheadvector to the D1/D1s devicetree
  • [04/13] cddd63869f92 riscv: Add thead and xtheadvector as a vendor extension
  • [05/13] 377be47f90e4 riscv: vector: Use vlenb from DT for thead
  • [06/13] 66f197785d51 RISC-V: define the elements of the VCSR vector CSR
  • [07/13] b9a931442451 riscv: csr: Add CSR encodings for CSR_VXRM/CSR_VXSAT (有差异,基线 csr.h 已有部分定义)
  • [08/13] 01e3313e34d0 riscv: Add xtheadvector instruction definitions
  • [09/13] d863910eabaf riscv: vector: Support xtheadvector save/restore (有差异,仅需 vector.h hunks)
  • [10/13] 21e49e64f307 riscv: hwprobe: Add thead vendor extension probing — 基线已有,跳过
  • [11/13] 7fa00fd6ff53 riscv: hwprobe: Document thead vendor extensions and xtheadvector extension
  • [12/13] 57d7713af93e selftests: riscv: Fix vector tests
  • [13/13] c384c5d4a2ae selftests: riscv: Support xtheadvector in vector tests

Series 2: D1 dts isa-extensions 转换 (依赖补丁)

Link: https://lore.kernel.org/r/20231009-moonlight-gray-92debdc89f30@wendy

  • c3f7c14856eb riscv: dts: allwinner: convert isa detection to new properties

Series 3: zve-detection v5 (仅 patch 7)

Link: https://lore.kernel.org/r/20240510-zve-detection-v5-7-0711bdd26c12@sifive.com

  • [07/11] ac295b67422d riscv: vector: adjust minimum Vector requirement to ZVE32X (有差异,部分 backport,仅 sys_hwprobe.c + uaccess.S)

fixes (4)

测试

root@light-a-val:/root/selftest# ./v_initval
TAP version 13
1..1
# Starting 1 tests from 1 test cases.
#  RUN           global.v_initval ...
#            OK  global.v_initval
ok 1 global.v_initval
# PASSED: 1 / 1 tests passed.
# Totals: pass:1 fail:0 xfail:0 xpass:0 skip:0 error:0
root@light-a-val:/root/selftest# ./vstate_prctl
TAP version 13
1..13
# Starting 13 tests from 1 test cases.
#  RUN           global.get_control_no_v ...
#      SKIP      Test expects vector to be not supp[ 2247.157782] vstate_exec_nol[1496]: unhandled signal 4 code 0x1 at 0x0000000000013ca8 in vstate_exec_nolibc[10000+7000]
[ 2247.169836] CPU: 0 PID: 1496 Comm: vstate_exec_nol Not tainted 6.6.143+ #99
[ 2247.176819] Hardware name: Sipeed Lichee Pi 4A (DT)
[ 2247.181710] epc : 0000000000013ca8 ra : 0000000000013c40 sp : 0000003fd0688d00
[ 2247.188947]  gp : 0000000000016800 tp : 00000000212df7a0 t0 : 00000000003dd1fb
[ 2247.196182]  t1 : 0000003fd97ff838 t2 : 0000000000000000 s0 : 0000003fd0688d70
[ 2247.203413]  s1 : 0000000000000000 a0 : 0000000000000001 a1 : 0000000000000000
[ 2247.210643]  a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000001
[ 2247.217874]  a5 : 0000000000000000 a6 : 7efefefefefefeff a7 : 00000000000000a7
[ 2247.225107]  s2 : 0000000000013abe s3 : 0000000000013a36 s4 : 0000000000010248
[ 2247.232339]  s5 : 0000000000084018 s6 : 000000002fcfc490 s7 : 000000002fcdf300
[ 2247.239569]  s8 : 0000000000000000 s9 : 000000002fd1a9e0 s10: 000000002fd1aa40
[ 2247.246800]  s11: 000000002fd1aa00 t3 : 0000000000028d18 t4 : 0000000000000000
[ 2247.254032]  t5 : ffffffffffffffff t6 : 00000000212e05ca ssp : 0000000000000000
[ 2247.261354] status: 0000000200004020 badaddr: 000000000d307057 cause: 0000000000000002
orted
#        [ 2247.269592] audit: type=1701 audit(1659952044.404:23): auid=4294967295 uid=0 gid=0 ses=4294967295 subj=unconfined pid=1496 comm="vstate_exec_nol" exe="/root/selftest/vstate_exec_nolibc" sig=4 res=1
    OK  global.get_control_no_v
ok 1 # SKIP Test expects vector to be not supported
#  RUN           global.set_control_no_v ...
#      SKIP      Test expects vector to be n[ 2247.302064] vstate_exec_nol[1508]: unhandled signal 4 code 0x1 at 0x0000000000013ca8 in vstate_exec_nolibc[10000+7000]
ot supported
# [ 2247.314212] CPU: 1 PID: 1508 Comm: vstate_exec_nol Not tainted 6.6.143+ #99
           OK  g[ 2247.322558] Hardware name: Sipeed Lichee Pi 4A (DT)
lobal.set_contro[ 2247.328825] epc : 0000000000013ca8 ra : 0000000000013c40 sp : 0000003fec1efd10
l_no_v
ok 2 # S[ 2247.337430]  gp : 0000000000016800 tp : 00000000212df7a0 t0 : 00000000003dd1fb
KIP Test expects[ 2247.346038]  t1 : 0000003fd97ff838 t2 : 0000000000000000 s0 : 0000003fec1efd80
 vector to be no[ 2247.354644]  s1 : 0000000000000000 a0 : 0000000000000015 a1 : 0000000000000000
t supported
#  [ 2247.363253]  a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000015
RUN           gl[ 2247.371858]  a5 : 0000000000000000 a6 : 7efefefefefefeff a7 : 00000000000000a7
obal.vstate_on_c[ 2247.380464]  s2 : 0000000000013abe s3 : 0000000000013a36 s4 : 0000000000010248
urrent ...
#   [ 2247.389072]  s5 : 0000000000084018 s6 : 000000002fcfc490 s7 : 000000002fcdf300
         OK  glo[ 2247.397678]  s8 : 0000000000000000 s9 : 000000002fd1a9e0 s10: 000000002fd1aa40
bal.vstate_on_cu[ 2247.406284]  s11: 000000002fd1aa00 t3 : 0000000000028d18 t4 : 0000000000000001
rrent
ok 3 glob[ 2247.414893]  t5 : ffffffffffffffff t6 : 00000000212e05d5 ssp : 0000000000000000
al.vstate_on_cur[ 2247.423585] status: 0000000200004020 badaddr: 000000000d307057 cause: 0000000000000002
rent
#  RUN    [ 2247.433216] audit: type=1701 audit(1659952044.568:24): auid=4294967295 uid=0 gid=0 ses=4294967295 subj=unconfined pid=1508 comm="vstate_exec_nol" exe="/root/selftest/vstate_exec_nolibc" sig=4 res=1
       global.vstate_off_eperm ...
#            OK  global.vstate_off_eperm
ok[ 2247.457998] vstate_exec_nol[1511]: unhandled signal 4 code 0x1 at 0x0000000000013ca8 in vstate_exec_nolibc[10000+7000]
[ 2247.469467] CPU: 0 PID: 1511 Comm: vstate_exec_nol Not tainted 6.6.143+ #99
[ 2247.476451] Hardware name: Sipeed Lichee Pi 4A (DT)
[ 2247.481341] epc : 0000000000013ca8 ra : 0000000000013c40 sp : 0000003fd61ffd00
[ 2247.488576]  gp : 0000000000016800 tp : 00000000212df7a0 t0 : 00000000003dd1fb
[ 2247.495812]  t1 : 0000003fd97ff838 t2 : 0000000000000000 s0 : 0000003fd61ffd70
[ 2247.503046]  s1 : 0000000000000000 a0 : 0000000000000015 a1 : 0000000000000000
[ 2247.510277]  a2 : 0000000000000000 a3 : 0000000000000000 a4 : 0000000000000015
[ 2247.517509]  a5 : 0000000000000000 a6 : 7efefefefefefeff a7 : 00000000000000a7
[ 2247.524741]  s2 : 0000000000013abe s3 : 0000000000013a36 s4 : 0000000000010248
[ 2247.531974]  s5 : 0000000000084018 s6 : 000000002fcfc490 s7 : 000000002fcdf300
[ 2247.539206]  s8 : 0000000000000000 s9 : 000000002fd1a9e0 s10: 000000002fd1aa40
[ 2247.546437]  s11: 000000002fd1aa00 t3 : 0000000000028d18 t4 : 0000000000000000
 4 global.vstate_off_eperm
#  RUN           glo[ 2247.553682]  t5 : ffffffffffffffff t6 : 00000000212e05ca ssp : 0000000000000000
bal.vstate_on_no[ 2247.553695] status: 0000000200004020 badaddr: 000000000d307057 cause: 0000000000000002
_nesting ...
# [ 2247.553995] audit: type=1701 audit(1659952044.688:25): auid=4294967295 uid=0 gid=0 ses=4294967295 subj=unconfined pid=1511 comm="vstate_exec_nol" exe="/root/selftest/vstate_exec_nolibc" sig=4 res=1
           OK  global.vstate_on_no_nesting
ok 5 global.vstate_on_no_nesting
#  RUN           global.vstate_off_nesting ...
#            OK  global.vstate_off_nesting
ok 6 global.vstate_off_nesting
#  RUN           global.vstate_on_inherit_no_nesting ...
#            OK  global.vstate_on_inherit_no_nesting
ok 7 global.vstate_on_inherit_no_nesting
#  RUN           global.vstate_on_inherit ...
#            OK  global.vstate_on_inherit
ok 8 global.vstate_on_inherit
#  RUN           global.vstate_off_inherit_no_nesting ...
#            OK  global.vstate_off_inherit_no_nesting
ok 9 global.vstate_off_inherit_no_nesting
#  RUN           global.vstate_off_inherit ...
#            OK  global.vstate_off_inherit
ok 10 global.vstate_off_inherit
#  RUN           global.inval_set_control_1 ...
#            OK  global.inval_set_control_1
ok 11 global.inval_set_control_1
#  RUN           global.inval_set_control_2 ...
#            OK  global.inval_set_control_2
ok 12 global.inval_set_control_2
#  RUN           global.inval_set_control_3 ...
#            OK  global.inval_set_control_3
ok 13 global.inval_set_control_3
# PASSED: 13 / 13 tests passed.
# Totals: pass:11 fail:0 xfail:0 xpass:0 skip:2 error:0
root@light-a-val:/root/selftest#

fixed: #354

ZhenXing Zhu and others added 22 commits July 29, 2026 09:48
dist inclusion
category: cleanup
Link: RVCK-Project#354

--------------------------------

This reverts commit 30843df.

Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
dist inclusion
category: cleanup
Link: RVCK-Project#354

--------------------------------

This reverts commit 4a43937.

Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
dist inclusion
category: cleanup
Link: RVCK-Project#354

--------------------------------

This reverts commit 3401b2a.

Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
…ector specification."

dist inclusion
category: cleanup
Link: RVCK-Project#354

--------------------------------

This reverts commit d701970.

Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.10
commit c3f7c14 ("riscv: dts: allwinner: convert isa detection to new properties")
category: feature
Link: RVCK-Project#354

--------------------------------

Convert the D1 devicetrees to use the new properties
"riscv,isa-base" & "riscv,isa-extensions".
For compatibility with other projects, "riscv,isa" remains.

Acked-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20231009-moonlight-gray-92debdc89f30@wendy
Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit e576b7c ("dt-bindings: riscv: Add xtheadvector ISA extension description")
category: feature
Link: RVCK-Project#354

--------------------------------

The xtheadvector ISA extension is described on the T-Head extension spec
Github page [1] at commit 95358cb2cca9.

Link: https://github.com/T-head-Semi/thead-extension-spec/blob/95358cb2cca9489361c61d335e03d3134b14133f/xtheadvector.adoc [1]

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-1-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit bf6279b ("dt-bindings: cpus: add a thead vlen register length property")
category: feature
Link: RVCK-Project#354

--------------------------------

Add a property analogous to the vlenb CSR so that software can detect
the vector length of each CPU prior to it being brought online.
Currently software has to assume that the vector length read from the
boot CPU applies to all possible CPUs. On T-Head CPUs implementing
pre-ratification vector, reading the th.vlenb CSR may produce an illegal
instruction trap, so this property is required on such systems.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-2-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit ce1daee ("riscv: dts: allwinner: Add xtheadvector to the D1/D1s devicetree")
category: feature
Link: RVCK-Project#354

--------------------------------

The D1/D1s SoCs support xtheadvector so it can be included in the
devicetree. Also include vlenb for the cpu.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-3-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit cddd638 ("riscv: Add thead and xtheadvector as a vendor extension")
category: feature
Link: RVCK-Project#354

--------------------------------

Add support to the kernel for THead vendor extensions with the target of
the new extension xtheadvector.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-4-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit 377be47 ("riscv: vector: Use vlenb from DT for thead")
category: feature
Link: RVCK-Project#354

--------------------------------

If thead,vlenb is provided in the device tree, prefer that over reading
the vlenb csr.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-5-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit 66f1977 ("RISC-V: define the elements of the VCSR vector CSR")
category: feature
Link: RVCK-Project#354

--------------------------------

The VCSR CSR contains two elements VXRM[2:1] and VXSAT[0].

Define constants for those to access the elements in a readable way.

Acked-by: Guo Ren <guoren@kernel.org>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Heiko Stuebner <heiko.stuebner@vrull.eu>
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-6-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit b9a9314 ("riscv: csr: Add CSR encodings for CSR_VXRM/CSR_VXSAT")
category: feature
Link: RVCK-Project#354

--------------------------------

The VXRM vector csr for xtheadvector has an encoding of 0xa and VXSAT
has an encoding of 0x9.

Co-developed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-7-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
[zhenxing.zhu@linux.alibaba.com: adapted to rvck-6.6 baseline csr.h which already has partial CSR definitions]
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit 01e3313 ("riscv: Add xtheadvector instruction definitions")
category: feature
Link: RVCK-Project#354

--------------------------------

xtheadvector uses different encodings than standard vector for
vsetvli and vector loads/stores. Write the instruction formats to be
used in assembly code.

Co-developed-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-8-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit d863910 ("riscv: vector: Support xtheadvector save/restore")
category: feature
Link: RVCK-Project#354

--------------------------------

Use alternatives to add support for xtheadvector vector save/restore
routines.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-9-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
[zhenxing.zhu@linux.alibaba.com: only vector.h hunks needed, other files already in rvck-6.6 baseline]
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
…ension

mainline inclusion
from mainline-6.14
commit 7fa00fd ("riscv: hwprobe: Document thead vendor extensions and xtheadvector extension")
category: feature
Link: RVCK-Project#354

--------------------------------

Document support for thead vendor extensions using the key
RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0 and xtheadvector extension using
the key RISCV_HWPROBE_VENDOR_EXT_XTHEADVECTOR.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Evan Green <evan@rivosinc.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-11-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit 57d7713 ("selftests: riscv: Fix vector tests")
category: feature
Link: RVCK-Project#354

--------------------------------

Overhaul the riscv vector tests to use kselftest_harness to help the
test cases correctly report the results and decouple the individual test
cases from each other. With this refactoring, only run the test cases if
vector is reported and properly report the test case as skipped
otherwise. The v_initval_nolibc test was previously not checking if
vector was supported and used a function (malloc) which invalidates
the state of the vector registers.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-12-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.14
commit c384c5d ("selftests: riscv: Support xtheadvector in vector tests")
category: feature
Link: RVCK-Project#354

--------------------------------

Extend existing vector tests to be compatible with the xtheadvector
instructions.

Signed-off-by: Charlie Jenkins <charlie@rivosinc.com>
Tested-by: Yangyu Chen <cyy@cyyself.name>
Link: https://lore.kernel.org/r/20241113-xtheadvector-v11-13-236c22791ef9@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.16
commit 4262bd0 ("riscv: vector: Fix context save/restore with xtheadvector")
category: feature
Link: RVCK-Project#354

--------------------------------

Previously only v0-v7 were correctly saved/restored,
and the context of v8-v31 are damanged.
Correctly save/restore v8-v31 to avoid breaking userspace.

Fixes: d863910 ("riscv: vector: Support xtheadvector save/restore")
Cc: stable@vger.kernel.org
Signed-off-by: Han Gao <rabenda.cn@gmail.com>
Tested-by: Xiongchuan Tan <tanxiongchuan@isrc.iscas.ac.cn>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Reviewed-by: Andy Chiu <andybnac@gmail.com>
Link: https://lore.kernel.org/r/9b9eb2337f3d5336ce813721f8ebea51e0b2b553.1747994822.git.rabenda.cn@gmail.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
…ous_vlenb()

mainline inclusion
from mainline-6.18
commit 2dc99ea ("riscv: cpufeature: avoid uninitialized variable in has_thead_homogeneous_vlenb()")
category: feature
Link: RVCK-Project#354

--------------------------------

In has_thead_homogeneous_vlenb(), smatch detected that the vlenb variable
could be used while uninitialized.  It appears that this could happen if
no CPUs described in DT have the "thead,vlenb" property.

Fix by initializing vlenb to 0, which will keep thead_vlenb_of set to 0
(as it was statically initialized).  This in turn will cause
riscv_v_setup_vsize() to fall back to CSR probing - the desired result if
thead,vlenb isn't provided in the DT data.

While here, fix a nearby comment typo.

Cc: stable@vger.kernel.org
Cc: Charlie Jenkins <charlie@rivosinc.com>
Fixes: 377be47 ("riscv: vector: Use vlenb from DT for thead")
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Link: https://lore.kernel.org/r/22674afb-2fe8-2a83-1818-4c37bd554579@kernel.org
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.18
commit 9f393d8 ("riscv: dts: allwinner: d1: fix vlenb property")
category: feature
Link: RVCK-Project#354

--------------------------------

According to [1], the C906 vector registers are 128 bits wide.
The 'thead,vlenb' property specifies the vector register length
in bytes, so its value must be set to 16.

[1] https://dl.linux-sunxi.org/D1/Xuantie_C906_R1S0_User_Manual.pdf

Fixes: ce1daee ("riscv: dts: allwinner: Add xtheadvector to the D1/D1s devicetree")
Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
Link: https://patch.msgid.link/20251119203508.1032716-1-geomatsi@gmail.com
Signed-off-by: Chen-Yu Tsai <wens@kernel.org>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.19
commit aef6dc0 ("riscv: dts: thead: add xtheadvector to the th1520 devicetree")
category: feature
Link: RVCK-Project#354

--------------------------------

The th1520 support xtheadvector [1] so it can be included in the
devicetree. Also include vlenb for the cpu. And set vlenb=16 [2].

This can be tested by passing the "mitigations=off" kernel parameter.

Link: https://lore.kernel.org/linux-riscv/20241113-xtheadvector-v11-4-236c22791ef9@rivosinc.com/ [1]
Link: https://lore.kernel.org/linux-riscv/aCO44SAoS2kIP61r@ghost/ [2]

Signed-off-by: Han Gao <rabenda.cn@gmail.com>
Reviewed-by: Drew Fustini <fustini@kernel.org>
Signed-off-by: Drew Fustini <fustini@kernel.org>
[zhenxing.zhu@linux.alibaba.com: xtheadvector already in isa, only added thead,vlenb property]
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
mainline inclusion
from mainline-6.11
commit ac295b6 ("riscv: vector: adjust minimum Vector requirement to ZVE32X")
category: feature
Link: RVCK-Project#354

--------------------------------

Make has_vector() to check for ZVE32X. Every in-kernel usage of V that
requires a more complicate version of V must then call out explicitly.

Also, change riscv_v_first_use_handler(), and boot code that calls
riscv_v_setup_vsize() to accept ZVE32X.

Most kernel/user interfaces requires minimum of ZVE32X. Thus, programs
compiled and run with ZVE32X should be supported by the kernel on most
aspects. This includes context-switch, signal, ptrace, prctl, and
hwprobe.

One exception is that ELF_HWCAP returns 'V' only if full V is supported
on the platform. This means that the system without a full V must not
rely on ELF_HWCAP to tell whether it is allowable to execute Vector
without first invoking a prctl() check.

Signed-off-by: Andy Chiu <andy.chiu@sifive.com>
Acked-by: Joel Granados <j.granados@samsung.com>
Link: https://lore.kernel.org/r/20240510-zve-detection-v5-7-0711bdd26c12@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
[zhenxing.zhu@linux.alibaba.com: partial backport, vector.h/cpufeature.c/vector.c already applied via baseline, only sys_hwprobe.c and uaccess.S hunks added]
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
@github-actions

github-actions Bot commented Jul 31, 2026

Copy link
Copy Markdown

开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/30614654906

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/355/head
base ref rvck-6.6
LAVA repo RVCK-Project/lavaci
LAVA hardware ['qemu']
LAVA Testcase path lava-testcases/common-test/ltp/ltp.yaml
need run job kunit-test,kernel-build,check-patch,lava-trigger

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch failure
lava-trigger-qemu failure
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[08:59:26] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 1
Total Warnings 22

LAVA Check (qemu)


lava 执行失败.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TH1520 kernel crash when enabling vector (xtheadvector)

8 participants