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

From: Adrian Hunter
Date: Thu Jun 19 2025 - 07:59:39 EST


On 18/06/2025 17:55, Dave Hansen wrote:
> 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()?

Would that mean no one would know if the mce addr had KeyID bits or not?

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

Could we deal with any tidy-ups in separate patches?