Re: [PATCH] x86/boot/e820: Re-enable fallback if e820 table is empty

From: David Gow

Date: Wed Apr 15 2026 - 09:51:26 EST


Le 15/04/2026 à 4:51 PM, Andy Shevchenko a écrit :
On Wed, Apr 15, 2026 at 08:30:18AM +0800, David Gow wrote:
In commit 157266edcc56 ("x86/boot/e820: Simplify append_e820_table() and remove restriction on single-entry tables"),

Note, it's fine to wrap this line in the commit message, it's only requirement
to tags to be "1 tag — 1 line".


Thanks -- I vaguely recall checkpatch complaining about this at some point, though I could've been imagining it...

the check that the number of entries in the e820 table was removed. The
intention was to support single-entry maps, but by removing the check
entirely, we also skip the fallback (to, e.g., the BIOS 88h function).

This means that if no E820 map is passed in from the bootloader (which is
the case on some bootloaders, like linld), we end up with an empty memory
map, and the kernel fails to boot (either by deadlocking on OOM, or by
failing to allocate the real mode trampoline, or similar).

Re-instate the check in append_e820_table(), but only check nr_entries is
non-zero. This allows e820__memory_setup_default() to fall back to other
memory size sources, and doesn't affect e820__memory_setup_extended(), as
the latter ignores the return value from append_e820_table().

Tested against linld, and the kernel boots again fine.

Fixes: 157266edcc56 ("x86/boot/e820: Simplify append_e820_table() and remove restriction on single-entry tables")

...

struct boot_e820_entry *entry = entries;
+ /* If there aren't any entries, we'll want to fall-back to another source. */
+ if (!nr_entries)
+ return -1;

Can we return -ENODATA or -ENOENT here?


Sounds like a good idea. The previous code (like this) used -1 for both "there are no entires" and "there are entries which look bogus". Maybe we should replace the latter with -EINVAL, too.

-- David