linux/arch/riscv
Sergey Matyukevich f7fc25362c riscv: vector: init vector context with proper vlenb
[ Upstream commit ef3ff40346 ]

The vstate in thread_struct is zeroed when the vector context is
initialized. That includes read-only register vlenb, which holds
the vector register length in bytes. Zeroed state persists until
mstatus.VS becomes 'dirty' and a context switch saves the actual
hardware values.

This can expose the zero vlenb value to the user-space in early
debug scenarios, e.g. when ptrace attaches to a traced process
early, before any vector instruction except the first one was
executed.

Fix this by specifying proper vlenb on vector context init.

Signed-off-by: Sergey Matyukevich <geomatsi@gmail.com>
Reviewed-by: Andy Chiu <andybnac@gmail.com>
Tested-by: Andy Chiu <andybnac@gmail.com>
Link: https://patch.msgid.link/20251214163537.1054292-3-geomatsi@gmail.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-03-04 07:21:20 -05:00
..
boot riscv: dts: sophgo: fix DMA data-width configuration for CV18xx 2025-05-22 14:29:35 +02:00
configs timekeeping: Remove CONFIG_DEBUG_TIMEKEEPING 2024-12-14 20:04:16 +01:00
crypto lib/crypto: riscv/chacha: Avoid s0/fp register 2026-01-08 10:14:55 +01:00
errata RISC-V: errata: Use medany for relocatable builds 2025-04-10 14:39:32 +02:00
include tracing: Add ftrace_partial_regs() for converting ftrace_regs to pt_regs 2026-03-04 07:19:37 -05:00
kernel riscv: vector: init vector context with proper vlenb 2026-03-04 07:21:20 -05:00
kvm RISC-V: KVM: Fix guest page fault within HLV* instructions 2025-12-18 13:55:05 +01:00
lib Merge patch series "riscv: Improve KASAN coverage to fix unit tests" 2024-09-19 01:10:44 -07:00
mm riscv: ptdump: use seq_puts() in pt_dump_seq_puts() macro 2025-11-13 15:34:36 -05:00
net riscv: bpf: Fix uninitialized symbol 'retval_off' 2025-11-13 15:34:07 -05:00
purgatory riscv/purgatory: 4B align purgatory_start 2025-04-10 14:39:33 +02:00
tools riscv: Check relocations at compile time 2023-04-19 07:46:32 -07:00
Kbuild RISC-V: hook new crypto subdir into build-system 2024-01-22 17:55:17 -08:00
Kconfig fgraph: Replace fgraph_ret_regs with ftrace_regs 2026-03-04 07:19:36 -05:00
Kconfig.debug riscv: Add tests for riscv module loading 2023-11-07 14:59:32 -08:00
Kconfig.errata riscv: thead: Rename T-Head PBMT to MAE 2024-04-25 10:22:33 -07:00
Kconfig.socs RISC-V: drop SOC_VIRT for ARCH_VIRT 2024-04-10 11:37:50 +01:00
Kconfig.vendor riscv: Extend cpufeature.c to detect vendor extensions 2024-07-22 15:36:54 -07:00
Makefile riscv: Build loader.bin exclusively for Canaan K210 2025-11-24 10:35:46 +01:00
Makefile.postlink kbuild: remove ARCH_POSTLINK from module builds 2023-10-28 21:10:08 +09:00