diff --git a/arch/riscv/kernel/usercfi.c b/arch/riscv/kernel/usercfi.c index 23c4d6d9d8cb..86141e5bab82 100644 --- a/arch/riscv/kernel/usercfi.c +++ b/arch/riscv/kernel/usercfi.c @@ -15,6 +15,7 @@ #include #include #include +#include #include unsigned long riscv_nousercfi __read_mostly; @@ -66,12 +67,7 @@ void set_shstk_status(struct task_struct *task, bool enable) task->thread_info.user_cfi_state.ubcfi_en = enable ? 1 : 0; - if (enable) - task->thread.envcfg |= ENVCFG_SSE; - else - task->thread.envcfg &= ~ENVCFG_SSE; - - csr_write(CSR_ENVCFG, task->thread.envcfg); + envcfg_update_bits(task, ENVCFG_SSE, enable ? ENVCFG_SSE : 0); } void set_shstk_lock(struct task_struct *task, bool lock) @@ -96,12 +92,7 @@ void set_indir_lp_status(struct task_struct *task, bool enable) task->thread_info.user_cfi_state.ufcfi_en = enable ? 1 : 0; - if (enable) - task->thread.envcfg |= ENVCFG_LPE; - else - task->thread.envcfg &= ~ENVCFG_LPE; - - csr_write(CSR_ENVCFG, task->thread.envcfg); + envcfg_update_bits(task, ENVCFG_LPE, enable ? ENVCFG_LPE : 0); } void set_indir_lp_lock(struct task_struct *task, bool lock)