Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/mce/inject: Remove call to mce_notify_irq()

The call to mce_notify_irq() has been there since the initial version of
the soft inject mce machinery, introduced in

ea149b36c7f5 ("x86, mce: add basic error injection infrastructure").

At that time it was functional since injecting an MCE resulted in the
following call chain:

raise_mce()
->machine_check_poll()
->mce_log() - sets notfiy_user_bit
->mce_notify_user() (current mce_notify_irq) consumed the bit and called the
usermode helper.

However, with the introduction of

011d82611172 ("RAS: Add a Corrected Errors Collector")

the code got moved around and the usermode helper began to be called via the
early notifier mce_first_notifier() rendering the call in raise_local()
defunct as the mce_need_notify bit (ex notify_user) is only being set from the
early notifier.

Remove the noop call and make mce_notify_irq() static.

No functional changes.

Signed-off-by: Nikolay Borisov <nik.borisov@suse.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20250225143348.268469-1-nik.borisov@suse.com

authored by

Nikolay Borisov and committed by
Borislav Petkov (AMD)
64478288 d082ecbc

+22 -25
-2
arch/x86/include/asm/mce.h
··· 296 296 297 297 void machine_check_poll(enum mcp_flags flags, mce_banks_t *b); 298 298 299 - bool mce_notify_irq(void); 300 - 301 299 DECLARE_PER_CPU(struct mce, injectm); 302 300 303 301 /* Disable CMCI/polling for MCA bank claimed by firmware */
+22 -22
arch/x86/kernel/cpu/mce/core.c
··· 584 584 } 585 585 EXPORT_SYMBOL_GPL(mce_is_correctable); 586 586 587 + /* 588 + * Notify the user(s) about new machine check events. 589 + * Can be called from interrupt context, but not from machine check/NMI 590 + * context. 591 + */ 592 + static bool mce_notify_irq(void) 593 + { 594 + /* Not more than two messages every minute */ 595 + static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2); 596 + 597 + if (test_and_clear_bit(0, &mce_need_notify)) { 598 + mce_work_trigger(); 599 + 600 + if (__ratelimit(&ratelimit)) 601 + pr_info(HW_ERR "Machine check events logged\n"); 602 + 603 + return true; 604 + } 605 + 606 + return false; 607 + } 608 + 587 609 static int mce_early_notifier(struct notifier_block *nb, unsigned long val, 588 610 void *data) 589 611 { ··· 1794 1772 for_each_online_cpu(cpu) 1795 1773 del_timer_sync(&per_cpu(mce_timer, cpu)); 1796 1774 } 1797 - 1798 - /* 1799 - * Notify the user(s) about new machine check events. 1800 - * Can be called from interrupt context, but not from machine check/NMI 1801 - * context. 1802 - */ 1803 - bool mce_notify_irq(void) 1804 - { 1805 - /* Not more than two messages every minute */ 1806 - static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2); 1807 - 1808 - if (test_and_clear_bit(0, &mce_need_notify)) { 1809 - mce_work_trigger(); 1810 - 1811 - if (__ratelimit(&ratelimit)) 1812 - pr_info(HW_ERR "Machine check events logged\n"); 1813 - 1814 - return true; 1815 - } 1816 - return false; 1817 - } 1818 - EXPORT_SYMBOL_GPL(mce_notify_irq); 1819 1775 1820 1776 static void __mcheck_cpu_mce_banks_init(void) 1821 1777 {
-1
arch/x86/kernel/cpu/mce/inject.c
··· 229 229 } else if (m->status) { 230 230 pr_info("Starting machine check poll CPU %d\n", cpu); 231 231 raise_poll(m); 232 - mce_notify_irq(); 233 232 pr_info("Machine check poll done on CPU %d\n", cpu); 234 233 } else 235 234 m->finished = 0;