[PW_SID:1069088] [RFC] riscv: clarify vector state semantics on syscall and context switch#1643
[PW_SID:1069088] [RFC] riscv: clarify vector state semantics on syscall and context switch#1643linux-riscv-bot wants to merge 1 commit intoworkflow__riscv__fixesfrom
Conversation
The RISC-V vector specification states that executing a system call
causes all caller-saved vector registers (v0-v31, vl, vtype) and vstart
to become unspecified.
Currently, after calling riscv_v_vstate_discard(), the vector state
may still be marked as DIRTY, which can mislead the context switch
logic into treating the registers as containing valid user data.
This patch clarifies and tightens the kernel-side semantics:
1. On syscall entry, the kernel checks the vector state via mstatus
and discards it if necessary. After discard, the state is explicitly
set to INIT instead of DIRTY, indicating that the vector registers
no longer contain meaningful user data.
2. During context switch, the vector state is interpreted as follows:
- INIT: no valid user data is present, so vector register data does
not need to be saved.
- non-INIT (e.g. DIRTY): vector register data must be saved.
3. On restore, if the state is INIT, the vector registers are treated
as invalid and are not restored from memory. Instead, they are
overwritten with a known initial value to avoid potential data
leakage from a previous task.
This aligns the kernel's vector state tracking with the architectural
"unspecified" semantics while ensuring correct lazy context switching
and preventing cross-task data leakage.
Signed-off-by: daichengrong <daichengrong@iscas.ac.cn>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
|
Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch" |
PR for series 1069088 applied to workflow__riscv__fixes
Name: [RFC] riscv: clarify vector state semantics on syscall and context switch
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1069088
Version: 1