x86/mce: Report unavailable MCE support at informational level
Subsystems (3)
PATCH v2 1/1 x86/mce: Report unavailable MCE support at informational level
mcheck_init_device() reports an error and returns -EIO when mce_available() is false. However, MCE support being unavailable does not necessarily indicate an initialization failure.
For example, a TDX guest with TD_CTLS.REDUCE_VE set and FEATURE_PARAVIRT_CTLS.MCA clear does not enumerate the MCE and MCA CPUID capabilities. This is an expected configuration, but it causes the kernel to print:
mce: Unable to init MCE device (rc: -5)
MCE can also be unavailable because it was explicitly disabled with mce=off or nomce. When it was disabled due to an earlier initialization problem, the relevant path already reports the reason.
Report MCE unavailability at informational level and return -ENODEV directly instead of routing it through the common error path.
---
Changes since v1:
v1: https://lore.kernel.org/all/[email protected]/
Added Reviewed-by's of Naman and Yazen.
No other change.
arch/x86/kernel/cpu/mce/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mce/core.c +2 -2
@@ -2815,8 +2815,8 @@ static __init int mcheck_init_device(void)MAYBE_BUILD_BUG_ON (__VIRTUAL_MASK_SHIFT >=63 );if (!mce_available (&boot_cpu_data)) { - err = -EIO ; - goto err_out; +pr_info ("MCE is unavailable\n" ); +return -ENODEV ; }if (!zalloc_cpumask_var (&mce_device_initialized,GFP_KERNEL )) {
Signature · 1 line
2.55.0
Borislav Petkov
maintainerQuoted 37 lines · Dexuan Cui
mcheck_init_device()reports an error and returns-EIOwhenmce_available()is false. However, MCE support being unavailable does not necessarily indicate an initialization failure.For example, a TDX guest with TD_CTLS.REDUCE_VE set and FEATURE_PARAVIRT_CTLS.MCA clear does not enumerate the MCE and MCA CPUID capabilities. This is an expected configuration, but it causes the kernel to print:
mce: Unable to init MCE device (rc: -5)
MCE can also be unavailable because it was explicitly disabled with mce=off or nomce. When it was disabled due to an earlier initialization problem, the relevant path already reports the reason.
Report MCE unavailability at informational level and return
-ENODEVdirectly instead of routing it through the common error path.Reviewed-by Naman Jain <[email protected]>Reviewed-by Yazen Ghannam <[email protected]>Signed-off-by Dexuan Cui <[email protected]>---
Changes since v1:
v1: https://lore.kernel.org/all/[email protected]/Added Reviewed-by's of Naman and Yazen.
No other change.arch/x86/kernel/cpu/mce/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/x86/kernel/cpu/mce/core.c +0
-0
arch/x86/kernel/cpu/mce/core.c static __init int mcheck_init_device(void) · line 2819
Quoted 7 lines
arch/x86/kernel/cpu/mce/core.c +2
-2@@ -2815,8 +2815,8 @@ static __init int mcheck_init_device(void)MAYBE_BUILD_BUG_ON (__VIRTUAL_MASK_SHIFT >=63 );if (!mce_available (&boot_cpu_data)) { - err = -EIO ; - goto err_out; +pr_info ("MCE is unavailable\n" ); +return -ENODEV ;
What's the difference between:
"MCE is unavailable\n"
and
"Unable to init MCE device (rc: %d)\n", err
?
And changing the routing path breaks the readability in this function.
What's the point of this patch at all?
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 3 lines
From: Borislav Petkov <[email protected]>
Sent: Monday, November 23, 2026 6:18 PM
...
Hi Boris, sorry for my late reply!
Quoted 16 lines
Review
Quoted 1 line
(quoted diff) +0
-0
b/arch/x86/kernel/cpu/mce/core.carch/x86/kernel/cpu/mce/core.c static __init int mcheck_init_device(void) · line 2819
Quoted 11 lines
index
50b1614968be6..ca7b729b74126100644arch/x86/kernel/cpu/mce/core.c +2
-2@@ -2815,8 +2815,8 @@ static __init int mcheck_init_device(void)MAYBE_BUILD_BUG_ON (__VIRTUAL_MASK_SHIFT >=63 );if (!mce_available (&boot_cpu_data)) { - err = -EIO ; - goto err_out; +pr_info ("MCE is unavailable\n" ); +return -ENODEV ;What's the difference between:
Quoted 7 lines
"MCE is unavailable\n"
and
"Unable to init MCE device (rc: %d)\n", err
?
My intention with this patch is to distinguish between two different cases:
* MCE is unavailable in expected scenarios (e.g., certain TDX guests or disabled via boot parameters), where pr_info() is more appropriate.
* MCE is available, but an actual error occurs during initialization, where pr_err() should be used.
Quoted 1 line
And changing the routing path breaks the readability in this function.
Since if (!mce_available(&boot_cpu_data)) is the very first check at the beginning of mcheck_init_device(), I thought an early "return -ENODEV;" wouldn't hurt readability.
Quoted 5 lines
What's the point of this patch at all?
--
Regards/Gruss,
Boris.
Some internal monitoring tool flags all pr_err() messages in dmesg as failures. When I looked into "mce: Unable to init MCE device (rc: -5)", I felt using pr_info() for the unavailable case made sense. However, if you don't think this change is worth the effort, I can ask our internal tool to ignore this message and we can drop the patch.
Thanks,
Dexuan
Borislav Petkov
maintainerQuoted 3 lines · Dexuan Cui
Some internal monitoring tool flags all
pr_err()messages in dmesg as failures. When I looked into "mce: Unable to init MCE device (rc: -5)", I felt usingpr_info()for the unavailable case made sense.
Put that in your commit message. Because I have no clue why your patch exists.
And drop the
pr_info("MCE is unavailable\n");print.
No need to say anything there - either the user knows she disabled MCE or machines without X86_FEATURE_MCA are outdated junk which no one uses. Then your tool won't have anything to ignore and everyone's happy.
But srsly, to go to that effort to patch the kernel instead of teaching your internal tool to ignore prints, that does sound like your tool needs to be taught to ignore prints faster.
Because you've probably found yourself in a whack'a'mole game already and will soon realize that wagging the dog simply doesn't cut it.
But ok, we can do it this one time. :)
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteQuoted 8 lines
From: Borislav Petkov <[email protected]>
Sent: Thursday, December 3, 2026 4:38 PM
...
Put that in your commit message. Because I have no clue why your patch exists.And drop the
Quoted 8 lines
pr_info("MCE is unavailable\n");print.
No need to say anything there - either the user knows she disabled MCE or machines without
X86_FEATURE_MCAare outdated junk which no one uses. Then
your tool won't have anything to ignore and everyone's happy.
Ok, I just posted v3 here:
https://lore.kernel.org/all/[email protected]/
Quoted 7 lines
But srsly, to go to that effort to patch the kernel instead of teaching your internal tool to ignore prints, that does sound like your tool needs to be taught to ignore prints faster.
Because you've probably found yourself in a whack'a'mole game already and will
soon realize that wagging the dog simply doesn't cut it.
Agreed.
Quoted 7 lines
But ok, we can do it this one time. :)
Thx.
--
Regards/Gruss,
Boris.
Thanks for making the exception! Please take a look at v3.
Thanks,
Dexuan