riscv/syscall: Add dependency to RISCV_PERCPU_SCRATCH when LIB_SYSCALL=y

The per CPU scratch register is needed by system calls -> enable it by
default.
This commit is contained in:
Ville Juven 2024-07-30 15:16:03 +03:00 committed by Xiang Xiao
parent 75c65c7ce9
commit fa71bc3d74
3 changed files with 11 additions and 3 deletions

View File

@ -520,7 +520,7 @@ config RISCV_MISALIGNED_HANDLER
config RISCV_PERCPU_SCRATCH
bool "Enable Scratch-based Per-CPU storage"
default n
default y if LIB_SYSCALL
---help---
In some special chipsets, multiple CPUs may be bundled in one hardware
thread cluster, which results in hartid and cpuindex not being exactly

View File

@ -55,6 +55,14 @@
# endif
#endif
/* System calls require the per CPU scratch area */
#ifdef CONFIG_LIB_SYSCALL
# ifndef CONFIG_RISCV_PERCPU_SCRATCH
# error "CONFIG_RISCV_PERCPU_SCRATCH is needed for handling system calls"
# endif
#endif
/* Provide a default section for the exeception handler. */
#ifndef EXCEPTION_SECTION

View File

@ -246,9 +246,9 @@ pid_t riscv_fork(const struct fork_s *context)
fregs[REG_FS11] = context->fs11; /* Saved register fs11 */
#endif
#ifdef CONFIG_BUILD_PROTECTED
#ifdef CONFIG_LIB_SYSCALL
/* Forked task starts at `dispatch_syscall()`, which requires TP holding
* TCB pointer as per e6973c764c, so we please it here to support vfork.
* TCB, in this case the child's TCB is needed.
*/
child->cmn.xcp.regs[REG_TP] = (uintptr_t)child;