pussuw commented on a change in pull request #5782: URL: https://github.com/apache/incubator-nuttx/pull/5782#discussion_r838152965
########## File path: arch/risc-v/src/common/riscv_swint.c ########## @@ -179,6 +187,31 @@ int riscv_swint(int irq, void *context, void *arg) riscv_registerdump(regs); #endif + /* Handle the syscall */ + + regs = riscv_handle_syscall(regs); + + /* Report what happened. That might difficult in the case of a context + * switch + */ + +#ifdef CONFIG_DEBUG_SYSCALL_INFO + if (regs != CURRENT_REGS) + { + svcinfo("SWInt Return: Context switch!\n"); + riscv_registerdump((const uintptr_t *)CURRENT_REGS); + } + else + { + svcinfo("SWInt Return: %d\n", regs[REG_A0]); + } +#endif + + return OK; +} + +void *riscv_handle_syscall(uintptr_t *regs) Review comment: Good morning, I took a look at riscv_swint.c and the context switch routines are all dependend on the CURRENT_REGS variable, which is defined as: `#define CURRENT_REGS (g_current_regs[up_cpu_index()])` It is a global variable that is dependent on the CPU index too. So no, the function is not truly re-entrant. I guess what CURRENT_REGS is needed for is to pass a reference to the modified context to the interrupt return logic, which is not used when using the trampoline to dispatch a syscall. As riscv_swint can be entered both from the trampoline as well as interrupt, the value of CURRENT_REGS really needs to be set and cleared. -- 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: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org