Skip to content

Commit 265d6ab

Browse files
riscv: uaccess: Only restore the CSR_STATUS SUM bit
During switch to csrs will OR the value of the register into the corresponding csr. In this case we're only interested in restoring the SUM bit not the entire register. Signed-off-by: Cyril Bur <[email protected]> Link: https://lore.kernel.org/r/[email protected] Co-developed-by: Alexandre Ghiti <[email protected]> Signed-off-by: Alexandre Ghiti <[email protected]> Fixes: 788aa64 ("riscv: save the SR_SUM status over switches") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 2670a39 commit 265d6ab

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

arch/riscv/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ struct thread_struct {
110110
struct __riscv_d_ext_state fstate;
111111
unsigned long bad_cause;
112112
unsigned long envcfg;
113-
unsigned long status;
113+
unsigned long sum;
114114
u32 riscv_v_flags;
115115
u32 vstate_ctrl;
116116
struct __riscv_v_ext_state vstate;

arch/riscv/kernel/asm-offsets.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void asm_offsets(void)
3434
OFFSET(TASK_THREAD_S9, task_struct, thread.s[9]);
3535
OFFSET(TASK_THREAD_S10, task_struct, thread.s[10]);
3636
OFFSET(TASK_THREAD_S11, task_struct, thread.s[11]);
37-
OFFSET(TASK_THREAD_STATUS, task_struct, thread.status);
37+
OFFSET(TASK_THREAD_SUM, task_struct, thread.sum);
3838

3939
OFFSET(TASK_TI_CPU, task_struct, thread_info.cpu);
4040
OFFSET(TASK_TI_PREEMPT_COUNT, task_struct, thread_info.preempt_count);
@@ -347,8 +347,8 @@ void asm_offsets(void)
347347
offsetof(struct task_struct, thread.s[11])
348348
- offsetof(struct task_struct, thread.ra)
349349
);
350-
DEFINE(TASK_THREAD_STATUS_RA,
351-
offsetof(struct task_struct, thread.status)
350+
DEFINE(TASK_THREAD_SUM_RA,
351+
offsetof(struct task_struct, thread.sum)
352352
- offsetof(struct task_struct, thread.ra)
353353
);
354354

arch/riscv/kernel/entry.S

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,15 @@ SYM_FUNC_START(__switch_to)
399399
REG_S s11, TASK_THREAD_S11_RA(a3)
400400

401401
/* save the user space access flag */
402-
li s0, SR_SUM
403-
csrr s1, CSR_STATUS
404-
REG_S s1, TASK_THREAD_STATUS_RA(a3)
402+
csrr s0, CSR_STATUS
403+
REG_S s0, TASK_THREAD_SUM_RA(a3)
405404

406405
/* Save the kernel shadow call stack pointer */
407406
scs_save_current
408407
/* Restore context from next->thread */
409-
REG_L s0, TASK_THREAD_STATUS_RA(a4)
408+
REG_L s0, TASK_THREAD_SUM_RA(a4)
409+
li s1, SR_SUM
410+
and s0, s0, s1
410411
csrs CSR_STATUS, s0
411412
REG_L ra, TASK_THREAD_RA_RA(a4)
412413
REG_L sp, TASK_THREAD_SP_RA(a4)

0 commit comments

Comments
 (0)