[PATCH v3] x86/mce: Don't report an error when MCE is unavailable
From: Dexuan Cui
Date: Thu Dec 03 2026 - 21:12:54 EST
A TDX guest with TD_CTLS.REDUCE_VE set and FEATURE_PARAVIRT_CTLS.MCA
clear does not enumerate the MCE or MCA CPUID bits. This is expected,
but mcheck_init_device() logs:
mce: Unable to init MCE device (rc: -5)
An internal monitor treats every pr_err() in dmesg as a failure, so it
flags a healthy guest. Booting with mce=off or nomce takes the same
error path.
Return -ENODEV without logging when mce_available() is false. Keep the
existing diagnostic for failures during device initialization.
Signed-off-by: Dexuan Cui <decui@xxxxxxxxxxxxx>
---
Changes in v3:
- Explain the motivation in the commit message (Boris).
- Drop the v2 pr_info("MCE is unavailable\n") and return silently
(Boris).
- Not carrying the v2 Reviewed-by tags, since the logging behavior
they reviewed has changed.
v2: https://lore.kernel.org/all/20261119185811.565606-1-decui@xxxxxxxxxxxxx/
v2 review: https://lore.kernel.org/all/20261204003753.GJaxILYWe-nBosYtkh@fat_crate.local/
arch/x86/kernel/cpu/mce/core.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -2814,10 +2814,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;
- }
+ if (!mce_available(&boot_cpu_data))
+ return -ENODEV;
if (!zalloc_cpumask_var(&mce_device_initialized, GFP_KERNEL)) {
err = -ENOMEM;