[PATCH v3 0/4] riscv: optimize Vector context restore on syscall

Andy Chiu tchiu at tenstorrent.com
Thu May 21 09:25:16 PDT 2026


This patch series optimizes riscv vector state handling across syscall
boundaries and context switches. The kernel now keeps track of the
INITIAL state in sstatus.vs to optimize unnecessary context management
operations.

This version merges daichengrong's RFC patch [1] for the state tracking
code as it looks cleaner than my v2/v1.

[1]: https://lore.kernel.org/linux-riscv/7ba2f4b7-8475-4ec3-ab31-58b332bda47e@iscas.ac.cn/#r
Link to v2: https://lore.kernel.org/linux-riscv/20260402043414.2421916-1-andybnac@gmail.com/

Patch summary:
 - Updated patches: 2
 - New patches: 1, 3, 4

Changelog v3:
 - Refactor function names. (1, 2)
 - Merge daichengrong's patch, with a fix and optimzation. (2)
 - Fix ptrace GETREGSET failure. (3)
 - Strengthen ptrace SETREGSET semantics and add a test to cover it. (3,
   4)
 - Fix a potential ABI break in signal and add a test to prevent future
   breaks. (3, 4)

Changelog v2: rebase on top of for-next

Andy Chiu (3):
  riscv: vector: refactor vector context operations
  riscv: vector: adjust ptrace and signal behavior for INITIAL state
  selftests: riscv: Extend vector tests for sigreturn and ptrace

daichengrong (1):
  riscv: clarify vector state semantics on syscall and context switch

 arch/riscv/include/asm/kvm_vcpu_vector.h      |   8 +-
 arch/riscv/include/asm/vector.h               |  45 ++++----
 arch/riscv/kernel/kernel_mode_vector.c        |  27 ++++-
 arch/riscv/kernel/ptrace.c                    |  13 +--
 arch/riscv/kernel/signal.c                    |  11 +-
 arch/riscv/kernel/vector.c                    |  38 ++++++-
 arch/riscv/kvm/vcpu_vector.c                  |   8 +-
 .../selftests/riscv/sigreturn/sigreturn.c     |  75 +++++++++++++
 .../selftests/riscv/vector/vstate_ptrace.c    | 100 +++++++++++++++++-
 9 files changed, 281 insertions(+), 44 deletions(-)

-- 
2.43.0




More information about the linux-riscv mailing list