Re: [PATCH 2/3] efi: Pass EFI boot memmap struct address to core kernel

Leif Lindholm <[email protected]>
Newsgroups org.kernel.vger.linux-efi,dev.linux.lists.loongarch,org.infradead.lists.linux-arm-kernel
Message-ID <aoLR9BPGt4Kzbr3y@leviathan>
On Mon, Aug 17, 2026 at 11:41:51 +0300, Ard Biesheuvel wrote:
> On Fri, 14 Aug 2026, at 18:16, Leif Lindholm wrote:
> > On Thu, Aug 13, 2026 at 09:45:09 +0200, Ard Biesheuvel wrote:
> >> The EFI stub already passes a struct efi_boot_memmap populated with the
> >> information of the EFI memory map as a configuration table, and so
> >> passing the physical address, size, descriptor size and descriptor
> >> version via 4 different DT properties is kind of redundant.
> >> 
> >> Instead, pass the physical address of this struct in memory so that the
> >> kernel can just retrieve the values directly.
> >> 
> >> Unfortunately, the scheme with four separate properties is boot ABI for
> >> Xen, and so this needs to remain supported.
> >
> > To clarify, you mean boot ABI when running under Xen?
> >
> 
> Yes. We've allowed Xen dom0 to omit the EFI stub entirely, and boot the
> kernel proper in EFI mode, passing the EFI system table and memory map
> addresses via these special DT properties.
> 
> >> But for the EFI stub itself,
> >> this is just an internal ABI that can be modified.
> >
> > Hmm...
> >
> > So this leaves only three properties that cannot be derived from the
> > System Table:
> > - The System Table address itself
> > - kaslr-seed
> > - bootargs
> >
> > The latter two could also be given the config table treatment.
> >
> 
> The latter two are generic boot ABI for the arm64 kernel, and there
> is no need to treat them differently for EFI boot. Note that we also
> support passing the initrd directly via DT when doing EFI boot, rather
> than via the EFI specific device path.

Ah, yes, noted.

> > Is it time to update the boot ABI to say x0 will hold the physical
> > address of "device tree blob (dtb) or EFI System Table in system RAM"?
> > They can be distinguished by 0xd00dfeed / "IBI SYST".
> 
> Let's avoid 'boot ABI' here, given that we are talking about an internal
> interface between the EFI stub and the kernel proper.

It's an internal business in the topic under discussion, but if we
were to change it, that would mean updating booting.rst, which I
consider an ABI.

> This internal interface uses DT under the hood, even on ACPI platforms,
> because it simplifies the early boot code. I don't think we should change
> this.
> 
> Also, the DT provided by the bootloader (if any) may differ from the one
> passed by the EFI stub, and so discovering the DT from the EFI system
> table is not straight-forward - they are not the same, and making them
> the same may have unintended side effects.

Right, but this confusion exists precisely because of the two ways the
device tree can be accessed with the curreent design.

> > The use of a generated DT when none was provided by firmware has led
> > to both confusion and shenanigans, and might be nice to get rid of?
> >
> 
> I don't disagree with that. But that would imply adding new code to the
> early startup code doing command line parsing and KASLR randomization to
> reason about whether these assets are passed via DT or via some other means.

I take your point about the invasiveness, so won't pursue that further
at this time. But I can't promise I won't bring it up again eventually :)

> What would make sense imo is to pass the EFI system table address via X1
> when doing EFI boot, so we don't have to get anything at all from the DT.

That certainly sounds like a clear improvement.

> > Either way, it would be nice to get rid of all four of the
> > linux,uefi-mmap nodes if they're now completely redundant.
> >
> 
> Indeed.
> 
> > Minor bikeshedding below.
> >
> >> @@ -123,8 +134,24 @@ u64 __init efi_get_fdt_params(struct efi_memory_map_data *mm)
> >>  			pr_err("Can't find property '%s' in DT!\n", pname);
> >>  			return 0;
> >>  		}
> >> -		if (dt_params[i].paravirt)
> >> +		if (IS_ENABLED(CONFIG_XEN) && dt_params[i].paravirt) {
> >>  			set_bit(EFI_PARAVIRT, &efi.flags);
> >> +		} else {
> >
> > This condition branch doesn't in fact have anything to do with the fdt.
> > Should it still live in fdtparams.c?
> >
> 
> I don't follow. The EFI_PARAVIRT flag is set based on whether we are 
> using the generic or the Xen-specific set of DT properties. What would
> be a better place to decide this?

Apologies, I may have commented confusingly - my comment was about the
else branch:

+
+                       bm = early_memremap_ro(memmap, sizeof(*bm));
+                       if (!bm) {
+                               pr_err("Cannot remap EFI boot memory map\n");
+                               return 0;
+                       }
+
+                       mm->phys_map            = memmap + sizeof(*bm);
+                       mm->size                = bm->map_size;
+                       mm->desc_size           = bm->desc_size;
+                       mm->desc_version        = bm->desc_ver;
+
+                       early_memunmap(bm, sizeof(*bm));

So to restate - this function is called from efi_init():
---
        /* Grab UEFI information placed in FDT by stub */
        efi_system_table = efi_get_fdt_params(&data);
        if (!efi_system_table)
                return;
---

Before this set, this function called get_fdt_params() indeed gets
"params" from a device tree. After this set, this function gets params
from a device tree in some instances, and not in others.
Which feels suboptimal.

We could rename the function, but then there's still DT-unrelated
code held in fdtparams.c.

If we go down the route of passing the system table in x1 on boot,
then I guess the effect of assigning efi_system_table will already be
broken out. But should we then split the mm struct initialisation into
separate DT and config table helper functions?

/
    Leif
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.