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

From: Dave Hansen
Date: Wed Jun 18 2025 - 11:00:20 EST


On 6/18/25 05:08, Adrian Hunter wrote:
> --- a/arch/x86/kernel/cpu/mce/core.c
> +++ b/arch/x86/kernel/cpu/mce/core.c
> @@ -1665,7 +1665,8 @@ noinstr void do_machine_check(struct pt_regs *regs)
> * be added to free list when the guest is terminated.
> */
> if (mce_usable_address(m)) {
> - struct page *p = pfn_to_online_page(m->addr >> PAGE_SHIFT);
> + unsigned long pfn = (m->addr & MCI_ADDR_PHYSADDR) >> PAGE_SHIFT;
> + struct page *p = pfn_to_online_page(pfn);

If ->addr isn't really an address that software can do much with,
shouldn't we mask MCI_ADDR_PHYSADDR off up front, like in mce_read_aux()?

Maybe we should break it up into address and KeyID _there_.