...like it's already done when exiting a trap. This is required, since handing a syscall can result in an AST; in particular this happens when the current thread is being terminated, which sets AST_TERMINATE and expects the thread to never return to userspace.
Fixes a kernel crash upon calling exit () or pthread_exit () in glibc. --- x86_64/locore.S | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/x86_64/locore.S b/x86_64/locore.S index 366ef292..577a9096 100644 --- a/x86_64/locore.S +++ b/x86_64/locore.S @@ -1428,10 +1428,17 @@ _syscall64_args_stack: _syscall64_call: call *EXT(mach_trap_table)+8(%rax) /* call procedure */ - // XXX: check ast on exit? - /* Restore thread state and return to user using sysret. */ +_syscall64_check_for_ast: + /* Check for ast. */ CPU_NUMBER(%r11) + cmpl $0,CX(EXT(need_ast),%r11) + jz _syscall64_restore_state + call EXT(i386_astintr) + jmp _syscall64_check_for_ast /* check again */ + +_syscall64_restore_state: + /* Restore thread state and return to user using sysret. */ movq CX(EXT(active_threads),%r11),%r11 /* point to current thread */ movq TH_PCB(%r11),%r11 /* point to pcb */ addq $ PCB_ISS,%r11 /* point to saved state */ -- 2.40.1