diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index 08423b6182c4..2dda8f41b719 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -1068,25 +1068,32 @@ flush_l1d_hw(void) wrmsr(MSR_IA32_FLUSH_CMD, IA32_FLUSH_CMD_L1D); } -static void __inline -amd64_syscall_ret_flush_l1d_inline(int error) +static void __noinline +amd64_syscall_ret_flush_l1d_check(int error) { void (*p)(void); - if (error != 0 && error != EEXIST && error != EAGAIN && - error != EXDEV && error != ENOENT && error != ENOTCONN && - error != EINPROGRESS) { - p = syscall_ret_l1d_flush; + if (error != EEXIST && error != EAGAIN && error != EXDEV && + error != ENOENT && error != ENOTCONN && error != EINPROGRESS) { + p = (void *)atomic_load_ptr(&syscall_ret_l1d_flush); if (p != NULL) p(); } } +static void __inline +amd64_syscall_ret_flush_l1d_check_inline(int error) +{ + + if (__predict_false(error != 0)) + amd64_syscall_ret_flush_l1d_check(error); +} + void amd64_syscall_ret_flush_l1d(int error) { - amd64_syscall_ret_flush_l1d_inline(error); + amd64_syscall_ret_flush_l1d_check_inline(error); } void @@ -1190,5 +1197,5 @@ amd64_syscall(struct thread *td, int traced) if (__predict_false(td->td_frame->tf_rip >= VM_MAXUSER_ADDRESS)) set_pcb_flags(td->td_pcb, PCB_FULL_IRET); - amd64_syscall_ret_flush_l1d_inline(td->td_errno); + amd64_syscall_ret_flush_l1d_check_inline(td->td_errno); }