Skip to contentSkip to conversation

x86/mce: Report unavailable MCE support at informational level

PATCH Superseded Dexuan Cui 3 participants 3 messages Sep 23 – Oct 19

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Dexuan Cui

author
#0 lore raw

PATCH 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.

---
 arch/x86/kernel/cpu/mce/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mce/core.c +2 -2
index f3a793e3a6c8..24ac10075263 100644
@@ -2825,8 +2825,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.52.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 26 lines · Dexuan Cui

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.

---
 arch/x86/kernel/cpu/mce/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mce/core.c +0 -0
index f3a793e3a6c8..24ac10075263 100644

arch/x86/kernel/cpu/mce/core.c static __init int mcheck_init_device(void) · line 2832

Quoted 10 lines
arch/x86/kernel/cpu/mce/core.c +2 -2
@@ -2825,8 +2825,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)) {

LGTM.

Regards,
Naman Jain

Reviewed-by on v1 1/1
#2 lore raw
In reply to Dexuan Cui
Quoted 29 lines · Dexuan Cui

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.

---
 arch/x86/kernel/cpu/mce/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/mce/core.c +0 -0
index f3a793e3a6c8..24ac10075263 100644

arch/x86/kernel/cpu/mce/core.c static __init int mcheck_init_device(void) · line 2832

Quoted 10 lines
arch/x86/kernel/cpu/mce/core.c +2 -2
@@ -2825,8 +2825,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)) {

I like this idea. I've seen cases where 'mce=off' is used for test cases. It'd be nice to have an explicit message like this to distinguish from true init failures.

Thanks,
Yazen