From ebbd2aaf821a69a3b11883002abed08304079533 Mon Sep 17 00:00:00 2001 From: leoliu-oc Date: Tue, 25 Jun 2024 18:58:02 +0800 Subject: [PATCH] anolis: x86/mce: Add NMIs setup in machine_check func ANBZ: #9424 This will lead to console_owner_lock issue and HPET dead loop issue. For example, The HPET dead loop issue: CPU x CPU x ---- ---- read_hpet() arch_spin_trylock(&hpet.lock) [CPU x got the hpet.lock] #MCE happened do_machine_check() mce_panic() panic() kmsg_dump() pstore_dump() pstore_record_init() ktime_get_real_fast_ns() read_hpet() [dead loops] This may lead to read_hpet dead loops. The console_owner_lock issue is similar. To avoid these issues, add NMIs setup When Handling #MC Exceptions. Signed-off-by: leoliu-oc --- arch/x86/kernel/cpu/mce/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c index 821a2a84fc86..24ee4f17b151 100644 --- a/arch/x86/kernel/cpu/mce/core.c +++ b/arch/x86/kernel/cpu/mce/core.c @@ -2068,10 +2068,14 @@ static __always_inline void exc_machine_check_kernel(struct pt_regs *regs) static __always_inline void exc_machine_check_user(struct pt_regs *regs) { + irqentry_state_t irq_state; + irqentry_enter_from_user_mode(regs); + irq_state = irqentry_nmi_enter(regs); instrumentation_begin(); machine_check_vector(regs); instrumentation_end(); + irqentry_nmi_exit(regs, irq_state); irqentry_exit_to_user_mode(regs); } -- Gitee