[PATCH v2 0/2] riscv: Add support for vector misaligned load/store

Nylon Chen nylon.chen at sifive.com
Tue Nov 17 19:13:43 PST 2026


This series adds emulation support for misaligned RISC-V vector
load/store instructions, which may currently fault/trap without being
handled on hardware that does not provide misaligned vector memory
access support.

Patch 1 implements the trap handler, with emulators for vector
load/store covering unit-stride, strided, indexed (ordered and
unordered), segment, whole-register, and fault-only-first forms, for
both user and kernel mode traps.

Patch 2 adds a kselftest exercising these code paths across the
various vector instruction forms and element widths.

Signed-off-by: Nylon Chen <nylon.chen at sifive.com>
---
Changes in v2:
- Fix riscv-allnoconfig build failure reported by the kernel test
  robot: build traps_v_misaligned.o under CONFIG_RISCV_VECTOR_MISALIGNED
  instead of CONFIG_RISCV_MISALIGNED, since the former already depends
  on CONFIG_RISCV_ISA_V, which declares the kernel_vector_begin()/
  kernel_vector_end()/riscv_v_enable()/riscv_v_disable() helpers the
  file uses.
- Link to v1: https://patch.msgid.link/20261116-riscv-vector-misaligned-v1-0-6c4d0ca905b7@sifive.com

---
Nylon Chen (2):
      riscv: traps: Add support for vector misalignment handler
      selftests/riscv: Add vector misaligned load/store tests

 arch/riscv/include/asm/vector.h                    |   4 +
 arch/riscv/kernel/Makefile                         |   1 +
 arch/riscv/kernel/traps_misaligned.c               |  39 +-
 arch/riscv/kernel/traps_v_misaligned.c             | 902 +++++++++++++++++++++
 tools/testing/selftests/riscv/vector/Makefile      |   5 +-
 .../testing/selftests/riscv/vector/v_misaligned.c  | 169 ++++
 .../testing/selftests/riscv/vector/v_misaligned.h  | 530 ++++++++++++
 7 files changed, 1647 insertions(+), 3 deletions(-)
---
base-commit: 05441d697f7f9a927264f4058cbbc6a03dfcac9d
change-id: 20261109-riscv-vector-misaligned-54773f80ca6b

Best regards,
--  
Nylon Chen <nylon.chen at sifive.com>




More information about the linux-riscv mailing list