riscv: stop preserving the tp register needlessly
The tp (x4) register is neither caller nor callee saved according to the RISC-V standard calling convention. It only has to be set on thread context switching and is otherwise read-only. To protect the kernel against a possible rogue user thread, the tp is also re-set on exception entry from u-mode. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
95b18c7f9f
commit
3f8e326d1a
7 changed files with 11 additions and 17 deletions
|
@ -16,7 +16,6 @@
|
|||
|
||||
#define DO_CALLEE_SAVED(op, reg) \
|
||||
RV_E( op ra, _thread_offset_to_ra(reg) );\
|
||||
RV_E( op tp, _thread_offset_to_tp(reg) );\
|
||||
RV_E( op s0, _thread_offset_to_s0(reg) );\
|
||||
RV_E( op s1, _thread_offset_to_s1(reg) );\
|
||||
RV_I( op s2, _thread_offset_to_s2(reg) );\
|
||||
|
@ -75,6 +74,11 @@ skip_store_fp_callee_saved:
|
|||
/* Get the new thread's stack pointer */
|
||||
lr sp, _thread_offset_to_sp(a0)
|
||||
|
||||
#if defined(CONFIG_THREAD_LOCAL_STORAGE)
|
||||
/* Get the new thread's tls pointer */
|
||||
lr tp, _thread_offset_to_tls(a0)
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_PMP_STACK_GUARD)
|
||||
/*
|
||||
* Stack guard has priority over user space for PMP usage.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue