pussuw commented on PR #12435: URL: https://github.com/apache/nuttx/pull/12435#issuecomment-2244841345
> @pussuw does this support PROTECTED build where `ARCH_KERNEL_STACK` nor `RISCV_PERCPU_SCRATCH` is defined? I forgot about fork altogether, as it does not work in kernel mode. Sorry about the regression in protected mode. Initially, I think enabling system calls should enforce RISCV_PERCPU_SCRATCH. Enforcing ARCH_KERNEL_STACK is not necessary though, it should work without. Why is the scratch area needed ? Because TP has dual meaning depending on which privilege mode we are running; When in usermode: TP holds the user thread pointer (__thread / TLS) (When CONFIG_SCHED_THREAD_LOCAL=y) When in kernelmode: TP holds the current TCB Thus, We need the scratch area to atomically swap between user TLS / kernel TCB upon trap entry! The fix in 12717 works if CONFIG_SCHED_THREAD_LOCAL=n but (I think it) destroys the user __thread / TLS pointer otherwise. Thanks for doing this patch, however in order to restore CONFIG_SCHED_THREAD_LOCAL=y functionality we need to do more. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
