Re: [PATCH 2/3] efi: Pass EFI boot memmap struct address to core kernel
Leif Lindholm <[email protected]>
| Newsgroups | dev.linux.lists.loongarch,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-efi |
|---|---|
| Message-ID | <aoMV3TX0hgTsj3_m@leviathan> |
On Mon, Aug 17, 2026 at 14:00:16 +0300, Ard Biesheuvel wrote:
> >> > 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.
> >
>
> But not an external ABI. It documents specifically how the EFI stub
> interfaces with the kernel proper. This might change at any point,
> without any obligation whatsoever to remain compatible with the
> previous method.
So you're saying if the kernel proper decides to use x1 for something
else, we'll move to x2?
I agree that in the context of how the stub calls the kernel proper,
this is not ABI, but x1 is one of the registers currently marked as
"reserved for future use" in booting.rst. So it feels weird for me to
allocate one of those registers for this internal use then not mention
it.
In that case, couldn't we instead pick a register outside of the
reserved ones?
> ...
> >> > 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?
> >
>
> Not disagreeing but I think it is fine to leave it as I suggested at this
> point.
>
> Some additional work is needed to get rid of linux,uefi-boot-memmap
> entirely, and until that happens, passing the EFI system table via
> X1 and linux,uefi-boot-memmap via DT is not a huge improvement.
>
> linux,uefi-boot-memmap is needed when SetVirtualAddressMap() is called
> [with a non-1:1 mapping], as the EFI system table contains a remapped
> address of the config table array in that case.
Of course, the devil on my shoulder suggests the stub could always
add an address fixup handler for the config table too...
> There are currently two remaining reasons why calling
> SetVirtualAddressMap() is required:
> - some Ampere boxes crash otherwise (but these systems tolerate SVAM
> being called with a 1:1 mapping)
> - kernel configs with a VA space < 48 bits are not guaranteed to be
> able to map the EFI runtime services 1:1, so there, SVAM is still
> needed as well.
>
> Both can be fixed, and I have been meaning to address the latter by
> always making the EFI runtime map (which is essentially a 1:1 map)
> use 48 bits of VA in all configs. (The ID map already does the same)
>
> Then, the former can be addressed by installing a 1:1 mapping when
> calling SVAM.
>
> That would remove the need entirely to ever call SVAM() on arm64,
> and therefore the need to pass the address of the EFI memory map
> separately.
Makes sense.
/
Leif