[PW_SID:1141715] riscv: vector: preserve state when scheduling at nonzero depth - #2424
[PW_SID:1141715] riscv: vector: preserve state when scheduling at nonzero depth#2424linux-riscv-bot wants to merge 2 commits into
Conversation
The IN_SCHEDULE shortcut lets __switch_to_vector() discard Vector state at a voluntary schedule point, where Vector registers are caller-saved. Switch-in can then enable Vector without restoring state. An interrupt or fault can also schedule at nonzero Vector nesting depth. This triggers: WARNING: arch/riscv/include/asm/vector.h:376 at __schedule+0xfbc/0x10b4 The shortcut is then also taken on switch-in, so it skips NEED_RESTORE and riscv_v_context_nesting_end() resumes with stale Vector registers. In the vector usercopy loop, an interrupt between vsetvli and vle8.v/vse8.v can therefore resume with another task's vl, vtype and vector registers. The scalar loop state survives, so the copy can use the wrong vector length and silently corrupt user data. A sleeping page fault in vectorized usercopy can reach the same switch without CONFIG_PREEMPTION. Use the shortcut only at depth zero. Nonzero-depth switches retain the existing save and NEED_RESTORE protocol. Fixes: d1049fc ("riscv: vector: Support calling schedule() for preemptible Vector") Cc: stable@vger.kernel.org Assisted-by: Codex:gpt-5.6-luna Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com> Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
|
Patch 1: "riscv: vector: preserve state when scheduling at nonzero depth" |
abf8962 to
9fa746d
Compare
PR for series 1141715 applied to workflow__riscv__fixes
Name: riscv: vector: preserve state when scheduling at nonzero depth
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=1141715
Version: 1