Re: [BUG] Fault during memory acceptance for TDX VMs with certain memory sizes

From: Kiryl Shutsemau

Date: Fri Feb 13 2026 - 09:24:52 EST


On Fri, Feb 13, 2026 at 01:33:56PM +0100, Moritz Sanft wrote:
> > Could you check it this patch makes a difference:
> >
> > diff --git a/drivers/firmware/efi/unaccepted_memory.c b/drivers/firmware/efi/unaccepted_memory.c
> > index c2c067eff634..f2a00cd429f2 100644
> > --- a/drivers/firmware/efi/unaccepted_memory.c
> > +++ b/drivers/firmware/efi/unaccepted_memory.c
> > @@ -35,7 +35,7 @@ void accept_memory(phys_addr_t start, unsigned long size)
> > struct efi_unaccepted_memory *unaccepted;
> > unsigned long range_start, range_end;
> > struct accept_range range, *entry;
> > - phys_addr_t end = start + size;
> > + phys_addr_t end = start + PAGE_ALIGN(size);
> > unsigned long flags;
> > u64 unit_size;
>
> Thanks, I tried this on the `-m 67000M` VM and the crash still occurs. I
> extended the previously-added logging to also log the values for `start +
> size` and `start + PAGE_ALIGN(size)`. Please find the full patch including
> the logging and your change in [1].

What about the patch below. It seems we under-reserve memory for the
table if it is unaligned.

I still think that we need align start/size/end to the PAGE_SIZE in
accept_memory()/range_contains_unaccepted_memory() before doing anything
else. Otherwise (end % unit_size) check is broken. But it seems to be
unrelated to the problem you see.

diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 111e87a618e5..56e9d73412fa 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -692,13 +692,13 @@ static __init int match_config_table(const efi_guid_t *guid,

static __init void reserve_unaccepted(struct efi_unaccepted_memory *unaccepted)
{
- phys_addr_t start, size;
+ phys_addr_t start, end;

start = PAGE_ALIGN_DOWN(efi.unaccepted);
- size = PAGE_ALIGN(sizeof(*unaccepted) + unaccepted->size);
+ end = PAGE_ALIGN(efi.unaccepted + sizeof(*unaccepted) + unaccepted->size);

- memblock_add(start, size);
- memblock_reserve(start, size);
+ memblock_add(start, end - start);
+ memblock_reserve(start, end - start);
}

int __init efi_config_parse_tables(const efi_config_table_t *config_tables,
--
Kiryl Shutsemau / Kirill A. Shutemov