Skip to content

Commit

Permalink
riscv: vector: Check SR_SD before saving vstate
Browse files Browse the repository at this point in the history
The SD bit summarizes the dirty states of FS, VS, or XS fields,
providing a "fast check" before saving fstate or vstate.

Let __switch_to_vector() check SD bit as __switch_to_fpu() does.

Fixes: 3a2df63 ("riscv: Add task switch support for vector")
Signed-off-by: Song Shuai <songshuaishuai@tinylab.org>
Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
  • Loading branch information
Song Shuai authored and Björn Töpel committed Jan 5, 2024
1 parent 67e0de6 commit e7b56b1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/riscv/include/asm/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ static inline void __switch_to_vector(struct task_struct *prev,
struct pt_regs *regs;

regs = task_pt_regs(prev);
riscv_v_vstate_save(prev, regs);
if (unlikely(regs->status & SR_SD))
riscv_v_vstate_save(prev, regs);
riscv_v_vstate_restore(next, task_pt_regs(next));
}

Expand Down

0 comments on commit e7b56b1

Please sign in to comment.