Make fastpath_restore match restore_user_context

Mostly call c_exit_hook() with global lock held.

Signed-off-by: Indan Zupancic <indan@nul.nu>
This commit is contained in:
Indan Zupancic 2025-08-20 15:26:16 +01:00
parent 09e6c3f5e2
commit a117712c19
5 changed files with 11 additions and 10 deletions

View file

@ -118,14 +118,14 @@ static inline int fastpath_reply_cap_check(cap_t cap)
/** DONT_TRANSLATE */
static inline void NORETURN FORCE_INLINE fastpath_restore(word_t badge, word_t msgInfo, tcb_t *cur_thread)
{
NODE_UNLOCK;
c_exit_hook();
#ifdef ARM_CP14_SAVE_AND_RESTORE_NATIVE_THREADS
restore_user_debug_context(cur_thread);
#endif
NODE_UNLOCK;
register word_t badge_reg asm("r0") = badge;
register word_t msgInfo_reg asm("r1") = msgInfo;
register word_t cur_thread_reg asm("r2") = (word_t)cur_thread->tcbArch.tcbContext.registers;

View file

@ -139,14 +139,14 @@ static inline int fastpath_reply_cap_check(cap_t cap)
/** DONT_TRANSLATE */
static inline void NORETURN FORCE_INLINE fastpath_restore(word_t badge, word_t msgInfo, tcb_t *cur_thread)
{
NODE_UNLOCK;
c_exit_hook();
#ifdef ARM_CP14_SAVE_AND_RESTORE_NATIVE_THREADS
restore_user_debug_context(cur_thread);
#endif
NODE_UNLOCK;
register word_t badge_reg asm("x0") = badge;
register word_t msgInfo_reg asm("x1") = msgInfo;
register word_t cur_thread_reg asm("x2") = (word_t)cur_thread->tcbArch.tcbContext.registers;

View file

@ -100,7 +100,7 @@ static inline int fastpath_reply_cap_check(cap_t cap)
/** DONT_TRANSLATE */
static inline void NORETURN FORCE_INLINE fastpath_restore(word_t badge, word_t msgInfo, tcb_t *cur_thread)
{
NODE_UNLOCK_IF_HELD;
c_exit_hook();
word_t cur_thread_regs = (word_t)cur_thread->tcbArch.tcbContext.registers;
@ -110,12 +110,12 @@ static inline void NORETURN FORCE_INLINE fastpath_restore(word_t badge, word_t m
*((word_t *)sp) = cur_thread_regs;
#endif
c_exit_hook();
#ifdef CONFIG_HAVE_FPU
set_tcb_fs_state(cur_thread, isFpuEnable());
#endif
NODE_UNLOCK_IF_HELD;
register word_t badge_reg asm("a0") = badge;
register word_t msgInfo_reg asm("a1") = msgInfo;
register word_t cur_thread_reg asm("t0") = cur_thread_regs;

View file

@ -99,13 +99,13 @@ static inline void NORETURN FORCE_INLINE fastpath_restore(word_t badge, word_t m
NODE_UNLOCK;
setKernelEntryStackPointer(cur_thread);
#ifdef CONFIG_HARDWARE_DEBUG_API
restore_user_debug_context(cur_thread);
assert(!cur_thread->tcbArch.tcbContext.breakpointState.single_step_enabled);
#endif
setKernelEntryStackPointer(cur_thread);
if (config_set(CONFIG_KERNEL_X86_IBRS_BASIC)) {
x86_disable_ibrs();
}

View file

@ -131,9 +131,10 @@ static inline void NORETURN FORCE_INLINE fastpath_restore(word_t badge, word_t m
*/
restore_user_context();
}
NODE_UNLOCK;
c_exit_hook();
NODE_UNLOCK;
if (config_set(CONFIG_KERNEL_SKIM_WINDOW)) {
/* see restore_user_context for a full explanation of why we do this */
word_t *irqstack = x64KSIRQStack[CURRENT_CPU_INDEX()];