Message ID | 20240528144252.179247-7-heinrich.schuchardt@canonical.com |
---|---|
State | Superseded |
Delegated to: | Heinrich Schuchardt |
Headers | show |
Series | efi_loader: improve device-tree loading | expand |
On Tue, 28 May 2024 at 17:43, Heinrich Schuchardt <heinrich.schuchardt@canonical.com> wrote: > > For finding distro supplied device-trees we need to know from which device > we are booting. This can be identified via the device-path of the binary. > > Up to now efi_dp_from_lo() only could return the initrd or fdt device-path. > Allow returning the binary device-path, too. > > Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> > --- > v2: > no change > --- > lib/efi_loader/efi_device_path.c | 20 ++++++++++++-------- > 1 file changed, 12 insertions(+), 8 deletions(-) > > diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c > index c8c8d54f733..52e3313c23a 100644 > --- a/lib/efi_loader/efi_device_path.c > +++ b/lib/efi_loader/efi_device_path.c > @@ -1133,17 +1133,18 @@ ssize_t efi_dp_check_length(const struct efi_device_path *dp, > } > > /** > - * efi_dp_from_lo() - Get the instance of a VenMedia node in a > - * multi-instance device path that matches > - * a specific GUID. This kind of device paths > - * is found in Boot#### options describing an > - * initrd location > + * efi_dp_from_lo() - get device-path from load option > * > - * @lo: EFI_LOAD_OPTION containing a valid device path > - * @guid: guid to search for > + * The load options in U-Boot may contain multiple concatenated device-paths. > + * The first device-path indicates the EFI binary to execute. Subsequent > + * device-paths start with a VenMedia node where the GUID identifies the > + * function (initrd or fdt). > + * > + * @lo: EFI load option containing a valid device path > + * @guid: GUID identifying device-path or NULL for the EFI binary > * > * Return: > - * device path including the VenMedia node or NULL. > + * device path excluding the matched VenMedia node or NULL. thanks for catching the typo as well > * Caller must free the returned value. > */ > struct > @@ -1154,6 +1155,9 @@ efi_device_path *efi_dp_from_lo(struct efi_load_option *lo, > struct efi_device_path_vendor *vendor; > int lo_len = lo->file_path_length; > > + if (!guid) > + return efi_dp_dup(fp); > + > for (; lo_len >= sizeof(struct efi_device_path); > lo_len -= fp->length, fp = (void *)fp + fp->length) { > if (lo_len < 0 || efi_dp_check_length(fp, lo_len) < 0) > -- > 2.43.0 > Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c index c8c8d54f733..52e3313c23a 100644 --- a/lib/efi_loader/efi_device_path.c +++ b/lib/efi_loader/efi_device_path.c @@ -1133,17 +1133,18 @@ ssize_t efi_dp_check_length(const struct efi_device_path *dp, } /** - * efi_dp_from_lo() - Get the instance of a VenMedia node in a - * multi-instance device path that matches - * a specific GUID. This kind of device paths - * is found in Boot#### options describing an - * initrd location + * efi_dp_from_lo() - get device-path from load option * - * @lo: EFI_LOAD_OPTION containing a valid device path - * @guid: guid to search for + * The load options in U-Boot may contain multiple concatenated device-paths. + * The first device-path indicates the EFI binary to execute. Subsequent + * device-paths start with a VenMedia node where the GUID identifies the + * function (initrd or fdt). + * + * @lo: EFI load option containing a valid device path + * @guid: GUID identifying device-path or NULL for the EFI binary * * Return: - * device path including the VenMedia node or NULL. + * device path excluding the matched VenMedia node or NULL. * Caller must free the returned value. */ struct @@ -1154,6 +1155,9 @@ efi_device_path *efi_dp_from_lo(struct efi_load_option *lo, struct efi_device_path_vendor *vendor; int lo_len = lo->file_path_length; + if (!guid) + return efi_dp_dup(fp); + for (; lo_len >= sizeof(struct efi_device_path); lo_len -= fp->length, fp = (void *)fp + fp->length) { if (lo_len < 0 || efi_dp_check_length(fp, lo_len) < 0)
For finding distro supplied device-trees we need to know from which device we are booting. This can be identified via the device-path of the binary. Up to now efi_dp_from_lo() only could return the initrd or fdt device-path. Allow returning the binary device-path, too. Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com> --- v2: no change --- lib/efi_loader/efi_device_path.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-)