mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] x86/mce: Report unavailable MCE support at informational level
@ 2026-11-19 18:58 Dexuan Cui
  2026-11-24  2:18 ` Borislav Petkov
  0 siblings, 1 reply; 2+ messages in thread
From: Dexuan Cui @ 2026-11-19 18:58 UTC (permalink / raw)
  To: tony.luck, bp, tglx, mingo, dave.hansen, x86, hpa, linux-edac,
	linux-kernel
  Cc: kameroncarr, Dexuan Cui, Naman Jain, Yazen Ghannam

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.

Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: Dexuan Cui <decui@microsoft.com>
---

Changes since v1:
    v1: https://lore.kernel.org/all/20260923173033.4104944-1-decui@microsoft.com/

    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(-)

diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
index 50b1614968be6..ca7b729b74126 100644
--- a/arch/x86/kernel/cpu/mce/core.c
+++ b/arch/x86/kernel/cpu/mce/core.c
@@ -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)) {
-- 
2.55.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] x86/mce: Report unavailable MCE support at informational level
  2026-11-19 18:58 [PATCH v2] x86/mce: Report unavailable MCE support at informational level Dexuan Cui
@ 2026-11-24  2:18 ` Borislav Petkov
  0 siblings, 0 replies; 2+ messages in thread
From: Borislav Petkov @ 2026-11-24  2:18 UTC (permalink / raw)
  To: Dexuan Cui
  Cc: tony.luck, tglx, mingo, dave.hansen, x86, hpa, linux-edac,
	linux-kernel, kameroncarr, Naman Jain, Yazen Ghannam

On Thu, Nov 19, 2026 at 10:58:11AM -0800, Dexuan Cui wrote:
> 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.
> 
> Reviewed-by: Naman Jain <namjain@linux.microsoft.com>
> Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
> Signed-off-by: Dexuan Cui <decui@microsoft.com>
> ---
> 
> Changes since v1:
>     v1: https://lore.kernel.org/all/20260923173033.4104944-1-decui@microsoft.com/
> 
>     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(-)
> 
> diff --git a/arch/x86/kernel/cpu/mce/core.c b/arch/x86/kernel/cpu/mce/core.c
> index 50b1614968be6..ca7b729b74126 100644
> --- a/arch/x86/kernel/cpu/mce/core.c
> +++ b/arch/x86/kernel/cpu/mce/core.c
> @@ -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?

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-24  2:18 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-19 18:58 [PATCH v2] x86/mce: Report unavailable MCE support at informational level Dexuan Cui
2026-11-24  2:18 ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®