Re: [PATCH RESEND V2 1/2] x86/mce: Fix missing address mask in recovery for errors in TDX/SEAM non-root mode

From: Borislav Petkov
Date: Wed Aug 27 2025 - 04:30:21 EST


On Wed, Aug 27, 2025 at 11:22:07AM +0300, Adrian Hunter wrote:
> +#ifdef CONFIG_X86_MCE_INTEL
> +static __always_inline void tdx_extract_err_addr(struct mce *m)
> +{
> + if (boot_cpu_has(X86_FEATURE_TDX_HOST_PLATFORM))
> + m->addr &= GENMASK_ULL(boot_cpu_data.x86_phys_bits - 1, 0);

Right, you can stick that thing straight into mce_read_aux() since it is
simple enough and drop the ifdeffery and use cpu_feature_enabled():

mce_read_aux:

...

/* Remove TDX KeyID from the address */
if (cpu_feature_enabled(X86_FEATURE_TDX_HOST_PLATFORM))
m->addr &= GENMASK_ULL(boot_cpu_data.x86_phys_bits - 1, 0);

Something like that...

Thx.

--
Regards/Gruss,
Boris.

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