From nobody Tue Jun 16 01:20:30 2026 Received: from sphereful.davidgow.net (sphereful.davidgow.net [203.29.242.92]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3319337C931 for ; Thu, 16 Apr 2026 07:03:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=203.29.242.92 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776322988; cv=none; b=jYrUXto3Pe78VycszW5DPFi2SJLJRlGfYvk0rrJ00eULvmX0636kuechisrM+DbUtIzCZsbQT2NfJE28i8UpGUYF35RKpNQurkvaVWRGl3arAu11F90AAwCh41o1r5eL7jHQVHkBfXcWbxFKLoDn6dMjNvm3Q9ka+PdHGhRInk4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776322988; c=relaxed/simple; bh=plvoNR5tAg/dTxjKF4oQqUUF+CacD41IL+WQqMYkmM4=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=dJLTTVS78TRBrDlKjJrPFotHU7zftsnju0zlnqekHYnYNMkYmYjyiVKWcgoooqlT7WO6YliEyIXgBGOs6NY1H1qI2B1xr4F6nu9wN+Uf6SiwO44B+DGRQ/3y3ODz8tnMgMuWpaL4xjHwi3JVTwqVXjB2SwXTompPRoiLYBiwvXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=davidgow.net; spf=pass smtp.mailfrom=davidgow.net; dkim=pass (4096-bit key) header.d=davidgow.net header.i=@davidgow.net header.b=fHh+akpd; dkim=pass (4096-bit key) header.d=davidgow.net header.i=@davidgow.net header.b=ZboCyIRK; arc=none smtp.client-ip=203.29.242.92 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=davidgow.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=davidgow.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=davidgow.net header.i=@davidgow.net header.b="fHh+akpd"; dkim=pass (4096-bit key) header.d=davidgow.net header.i=@davidgow.net header.b="ZboCyIRK" DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=davidgow.net; s=201606; t=1776322978; bh=plvoNR5tAg/dTxjKF4oQqUUF+CacD41IL+WQqMYkmM4=; h=From:To:Cc:Subject:Date:From; b=fHh+akpdwGUNOAwSdmZwRdzprcDjDzdBoHObVScaTVXryTPTWG1ch+ibLZXIoIUDo cz8cmQpDP8kcVChIXoxfpv3rh8efkoYYRG0DkOy6ulLEA6wchFwh2/sCTPsS6wzQXw tIgoJy2eNY5EswEXEiciEbL2OtR+QpOfPIg5QKzqxMyqiB+44gicssPiBb/Q2tdddt RQy+l9eVljLF7ZfTze1se1vaq7w0UuJGJOv419kS5u0jU80kdQNrXg4OgJAjM5RVQw YTIxsnaZopJFUO4dHjx7/wbFYORUaUGsv78mN53NMhrrrdLbg+dMyCx1Bmx6TD5kEg hz22bXjvFkN6159ZKZR4PRyqQwVmcY36O6fGavkV3XgL3a3z7TdhJjzv1Lqp7jl6FR XbNGxj/Hkzzr3LE17zjjs0MkzmclHswWHX4aeEdbC9XCUubvgF5rRGiOU09CEsoEWl DhhFajlYtomVj2zV/JW/jF8uBwZKwW0Oyjmg7AQ2F013UpusbJ1DI+24/vUYhTi4ir sySWrN6SVuIL2NRB821kDBUWyQU/gga1cKRhhP40tED4khnUHWNBcCA+j5rn7GOZon gbuTCnaIOyEDU8YMDJ4tL8XL8dUM55rxgFJYjeEAKp90yLDuzCRud1v5LwZ03dQMDY mBGWE/MJ3pJ78JHEEukisJFM= Received: by sphereful.davidgow.net (Postfix, from userid 119) id 511671E68E7; Thu, 16 Apr 2026 15:02:58 +0800 (AWST) X-Spam-Level: DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=davidgow.net; s=201606; t=1776322947; bh=plvoNR5tAg/dTxjKF4oQqUUF+CacD41IL+WQqMYkmM4=; h=From:To:Cc:Subject:Date:From; b=ZboCyIRKTVgGMCzIJmeSbN/XXm4zztL5E2TA5Ks58H0KYmR0461mW+2Dq7Ptpm9mW XpnLmmUSTdvtv0Xi/CqCR3AyZKduVc2cdgLAAWp5gzzfU/gXLxY0nOHZDm6VG3VQ/G JSKNGS5bxiMFIe6Lfgfk0yMyJqWH6Yt6yacFBYnUkSu6mHBDn7dzEc/R4QqYf8YN1p hWHSDHiOOG7Nm3UrT5YjzY02wLL9jW4rSkg6zYDZz3yi1Hiw4/Wft2BIj8/FYT/oWY xlniVJfOMk1qTYuIZSQL78vJZD4VOO/vBrff3C83vZek6UqS5K2BhVEUG/gc91AfUd S7TXz/bAyNZY6IMv29dccmypNF8RI6pt840nGd+GrMpHzBYlsRabenprV2kOxbmkIb RLQzvkKGN14h04cc8SKRRr+ixLCiz3n3Smpgtz4uyRkm792DhTw/fHtt3j2bmuRRn8 xnHDrbPP6YCs9Q3dx6hseN4fbrp+2/+owiKprjpsFyKtFiRrZxXKCumjw3PfVLfXoL X4JLR7b8evivEJruSjQLyGqFkIUJuN8qMsgPFP9dfiNN2243TnoQGoTktIY1fR85Fn OyIgemFS/Qmge5zre8M4akGAGand4yY58JSGX2EEWwf/DrGSqVTvqmV3O4JOXzIZrY ERwZI7Atr7qjEVP4LcOvgj3w= Received: from sparky.lan (unknown [IPv6:2001:8003:8810:ea00:ed87:ca88:5326:e11d]) by sphereful.davidgow.net (Postfix) with ESMTPSA id A25C91E68E3; Thu, 16 Apr 2026 15:02:27 +0800 (AWST) From: David Gow To: Ingo Molnar , Thomas Gleixner Cc: David Gow , Borislav Petkov , Dave Hansen , x86@kernel.org, Andy Shevchenko , Arnd Bergmann , Nikolay Borisov , "H . Peter Anvin" , linux-kernel@vger.kernel.org Subject: [PATCH v2] x86/boot/e820: Re-enable fallback if e820 table is empty Date: Thu, 16 Apr 2026 14:57:43 +0800 Message-ID: <20260416065746.1896647-1-david@davidgow.net> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" In commit 157266edcc56 ("x86/boot/e820: Simplify append_e820_table() and remove restriction on single-entry tables"), 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(). In so doing, we also update the return values to be proper error codes, with -ENOENT for this case (there are no entries), and -EINVAL for the case where an entry appears invalid. Given none of the callers check the actual value -- just whether it's nonzero -- this is largely aesthetic in practice. Tested against linld, and the kernel boots again fine. Fixes: 157266edcc56 ("x86/boot/e820: Simplify append_e820_table() and remov= e restriction on single-entry tables") Signed-off-by: David Gow Reviewed-by: Andy Shevchenko --- Changes since v2: https://lore.kernel.org/lkml/20260415003021.1543723-1-david@davidgow.net/ - Return -ENOENT instead of -1 - Return -EINVAL instead of -1 for the case where an entry looks invalid du= e to an overflow (Thanks, Andy) --- arch/x86/kernel/e820.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c index 2a9992758933..3db9c364b833 100644 --- a/arch/x86/kernel/e820.c +++ b/arch/x86/kernel/e820.c @@ -450,6 +450,10 @@ __init static int append_e820_table(struct boot_e820_e= ntry *entries, u32 nr_entr { struct boot_e820_entry *entry =3D entries; =20 + /* If there aren't any entries, we'll want to fall-back to another source= . */ + if (!nr_entries) + return -ENOENT; + while (nr_entries) { u64 start =3D entry->addr; u64 size =3D entry->size; @@ -458,7 +462,7 @@ __init static int append_e820_table(struct boot_e820_en= try *entries, u32 nr_entr =20 /* Ignore the remaining entries on 64-bit overflow: */ if (start > end && likely(size)) - return -1; + return -EINVAL; =20 e820__range_add(start, size, type); =20 --=20 2.53.0