Skip to content

[PW_SID:1069088] [RFC] riscv: clarify vector state semantics on syscall and context switch#1643

Open
linux-riscv-bot wants to merge 1 commit intoworkflow__riscv__fixesfrom
pw1069088
Open

[PW_SID:1069088] [RFC] riscv: clarify vector state semantics on syscall and context switch#1643
linux-riscv-bot wants to merge 1 commit intoworkflow__riscv__fixesfrom
pw1069088

Conversation

@linux-riscv-bot
Copy link

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

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>
@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 136.94 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1145.70 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1658.97 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 26.40 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 27.54 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 0.75 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 83.94 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
kdoc
Desc: Detects for kdoc errors
Duration: 0.88 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
module-param
Desc: Detect module_param changes
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.23 seconds
Result: PASS

@linux-riscv-bot
Copy link
Author

Patch 1: "[RFC] riscv: clarify vector state semantics on syscall and context switch"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant