https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-8/-/blob/ccf40dfacd314ab0fea16cfc6f4eded1a08e2710/arch/x86/kernel/cpu/mce/core.c#L1331
preempt_enable()
before nmi_exit()
, is this a OK code?
if ((m.cs & 3) == 3) {
/* If this triggers there is no way to recover. Die hard. */
BUG_ON(!on_thread_stack() || !user_mode(regs));
local_irq_enable();
preempt_enable();
current->task_struct_rh->mce_ripv = !!(m.mcgstatus & MCG_STATUS_RIPV);
current->task_struct_rh->mce_whole_page = whole_page(&m);
if (kill_it || do_memory_failure(&m))
force_sig(SIGBUS, current);
preempt_disable();
local_irq_disable();
} else {
if (!fixup_exception(regs, X86_TRAP_MC))
mce_panic("Failed kernel mode recovery", &m, NULL);
}
out_ist:
nmi_exit();
}
In my understanding, the kernel can't preempt if preempt_count > 0
, in this case, it is inside NMI, so preempt_count > 0
.
It is sending SIGBUS:
force_sig(SIGBUS, current);
seems unnecessary to do local_irq_enable
and preempt_enable
?
Asked by Mark K
(955 rep)
Sep 5, 2022, 06:22 AM
Last activity: Sep 5, 2022, 06:29 AM
Last activity: Sep 5, 2022, 06:29 AM