Skip to content

Commit 91af684

Browse files
yghannambp3tk0v
authored andcommitted
x86/mce: Move machine_check_poll() status checks to helper functions
There are a number of generic and vendor-specific status checks in machine_check_poll(). These are used to determine if an error should be skipped. Move these into helper functions. Future vendor-specific checks will be added to the helpers. Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com> Reviewed-by: Tony Luck <tony.luck@intel.com> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com> Tested-by: Tony Luck <tony.luck@intel.com> Link: https://lore.kernel.org/20250908-wip-mca-updates-v6-0-eef5d6c74b9c@amd.com
1 parent 7eee1e9 commit 91af684

1 file changed

Lines changed: 48 additions & 40 deletions

File tree

arch/x86/kernel/cpu/mce/core.c

Lines changed: 48 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,52 @@ static noinstr void mce_read_aux(struct mce_hw_err *err, int i)
714714

715715
DEFINE_PER_CPU(unsigned, mce_poll_count);
716716

717+
/*
718+
* Newer Intel systems that support software error
719+
* recovery need to make additional checks. Other
720+
* CPUs should skip over uncorrected errors, but log
721+
* everything else.
722+
*/
723+
static bool ser_should_log_poll_error(struct mce *m)
724+
{
725+
/* Log "not enabled" (speculative) errors */
726+
if (!(m->status & MCI_STATUS_EN))
727+
return true;
728+
729+
/*
730+
* Log UCNA (SDM: 15.6.3 "UCR Error Classification")
731+
* UC == 1 && PCC == 0 && S == 0
732+
*/
733+
if (!(m->status & MCI_STATUS_PCC) && !(m->status & MCI_STATUS_S))
734+
return true;
735+
736+
return false;
737+
}
738+
739+
static bool should_log_poll_error(enum mcp_flags flags, struct mce_hw_err *err)
740+
{
741+
struct mce *m = &err->m;
742+
743+
/* If this entry is not valid, ignore it. */
744+
if (!(m->status & MCI_STATUS_VAL))
745+
return false;
746+
747+
/*
748+
* If we are logging everything (at CPU online) or this
749+
* is a corrected error, then we must log it.
750+
*/
751+
if ((flags & MCP_UC) || !(m->status & MCI_STATUS_UC))
752+
return true;
753+
754+
if (mca_cfg.ser)
755+
return ser_should_log_poll_error(m);
756+
757+
if (m->status & MCI_STATUS_UC)
758+
return false;
759+
760+
return true;
761+
}
762+
717763
/*
718764
* Poll for corrected events or events that happened before reset.
719765
* Those are just logged through /dev/mcelog.
@@ -765,48 +811,10 @@ void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
765811
if (!mca_cfg.cmci_disabled)
766812
mce_track_storm(m);
767813

768-
/* If this entry is not valid, ignore it */
769-
if (!(m->status & MCI_STATUS_VAL))
814+
/* Verify that the error should be logged based on hardware conditions. */
815+
if (!should_log_poll_error(flags, &err))
770816
continue;
771817

772-
/*
773-
* If we are logging everything (at CPU online) or this
774-
* is a corrected error, then we must log it.
775-
*/
776-
if ((flags & MCP_UC) || !(m->status & MCI_STATUS_UC))
777-
goto log_it;
778-
779-
/*
780-
* Newer Intel systems that support software error
781-
* recovery need to make additional checks. Other
782-
* CPUs should skip over uncorrected errors, but log
783-
* everything else.
784-
*/
785-
if (!mca_cfg.ser) {
786-
if (m->status & MCI_STATUS_UC)
787-
continue;
788-
goto log_it;
789-
}
790-
791-
/* Log "not enabled" (speculative) errors */
792-
if (!(m->status & MCI_STATUS_EN))
793-
goto log_it;
794-
795-
/*
796-
* Log UCNA (SDM: 15.6.3 "UCR Error Classification")
797-
* UC == 1 && PCC == 0 && S == 0
798-
*/
799-
if (!(m->status & MCI_STATUS_PCC) && !(m->status & MCI_STATUS_S))
800-
goto log_it;
801-
802-
/*
803-
* Skip anything else. Presumption is that our read of this
804-
* bank is racing with a machine check. Leave the log alone
805-
* for do_machine_check() to deal with it.
806-
*/
807-
continue;
808-
809-
log_it:
810818
mce_read_aux(&err, i);
811819
m->severity = mce_severity(m, NULL, NULL, false);
812820
/*

0 commit comments

Comments
 (0)