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
|
@ -41,10 +41,6 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
|||
stack_init->a2 = (ulong_t)p2;
|
||||
stack_init->a3 = (ulong_t)p3;
|
||||
|
||||
#ifdef CONFIG_THREAD_LOCAL_STORAGE
|
||||
thread->callee_saved.tp = (ulong_t)thread->tls;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Following the RISC-V architecture,
|
||||
* the MSTATUS register (used to globally enable/disable interrupt),
|
||||
|
@ -90,11 +86,6 @@ void arch_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
|
|||
stack_init->sp = (ulong_t)(stack_init + 1);
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
#if defined(CONFIG_THREAD_LOCAL_STORAGE)
|
||||
stack_init->tp = thread->tls;
|
||||
thread->callee_saved.tp = thread->tls;
|
||||
#endif
|
||||
|
||||
/* Assign thread entry point and mstatus.MPRV mode. */
|
||||
if (IS_ENABLED(CONFIG_USERSPACE)
|
||||
&& (thread->base.user_options & K_USER)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue