public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [RFC v2 01/11] efi_loader: boottime: add loaded image device path protocol to image handle
Date: Thu, 28 Mar 2019 10:13:09 +0900	[thread overview]
Message-ID: <20190328011308.GU9937@linaro.org> (raw)
In-Reply-To: <451c4b47-192f-7dab-b132-819bd39a59c0@gmx.de>

On Wed, Mar 27, 2019 at 06:58:31AM +0100, Heinrich Schuchardt wrote:
> On 3/27/19 5:40 AM, AKASHI Takahiro wrote:
> > To meet UEFI spec v2.7a section 9.2, we should add
> > EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL to image handle,
> > instead of EFI_DEVICE_PATH_PROTOCOL.
> >
> > Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
> > ---
> >  include/efi_api.h                 |  4 ++++
> >  include/efi_loader.h              |  1 +
> >  lib/efi_loader/efi_boottime.c     | 19 ++++++++++++-------
> >  lib/efi_loader/efi_image_loader.c |  2 ++
> >  4 files changed, 19 insertions(+), 7 deletions(-)
> >
> > diff --git a/include/efi_api.h b/include/efi_api.h
> > index ccf608653d4a..63b703c951a7 100644
> > --- a/include/efi_api.h
> > +++ b/include/efi_api.h
> > @@ -333,6 +333,10 @@ struct efi_system_table {
> >  	EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \
> >  		 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
> >
> > +#define LOADED_IMAGE_DEVICE_PATH_GUID \
> > +	EFI_GUID(0xbc62157e, 0x3e33, 0x4fec, \
> > +		 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf)
> > +
> >  #define EFI_LOADED_IMAGE_PROTOCOL_REVISION 0x1000
> >
> >  struct efi_loaded_image {
> > diff --git a/include/efi_loader.h b/include/efi_loader.h
> > index 512880ab8fbf..3f54e354bdcd 100644
> > --- a/include/efi_loader.h
> > +++ b/include/efi_loader.h
> > @@ -135,6 +135,7 @@ extern const efi_guid_t efi_guid_event_group_reset_system;
> >  /* GUID of the device tree table */
> >  extern const efi_guid_t efi_guid_fdt;
> >  extern const efi_guid_t efi_guid_loaded_image;
> > +extern const efi_guid_t efi_guid_loaded_image_device_path;
> >  extern const efi_guid_t efi_guid_device_path_to_text_protocol;
> >  extern const efi_guid_t efi_simple_file_system_protocol_guid;
> >  extern const efi_guid_t efi_file_info_guid;
> > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> > index 391681260c27..578b32a05ffd 100644
> > --- a/lib/efi_loader/efi_boottime.c
> > +++ b/lib/efi_loader/efi_boottime.c
> > @@ -1519,6 +1519,7 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
> >  	efi_status_t ret;
> >  	struct efi_loaded_image *info = NULL;
> >  	struct efi_loaded_image_obj *obj = NULL;
> > +	struct efi_device_path *dp;
> >
> >  	/* In case of EFI_OUT_OF_RESOURCES avoid illegal free by caller. */
> >  	*handle_ptr = NULL;
> > @@ -1542,15 +1543,19 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path,
> >
> >  	if (device_path) {
> >  		info->device_handle = efi_dp_find_obj(device_path, NULL);
> > -		/*
> > -		 * When asking for the device path interface, return
> > -		 * bootefi_device_path
> > -		 */
> > -		ret = efi_add_protocol(&obj->header,
> > -				       &efi_guid_device_path, device_path);
> > -		if (ret != EFI_SUCCESS)
> > +
> > +		dp = efi_dp_append(device_path, file_path);
> 
> I think we should pass the original device_path as a parameter to
> efi_setup_loaded_image instead of first splitting and then recombining
> devicepath elements.

Agree, but I didn't modify the code because efi_setup_loaded_image()
is still used to load "efi_selftest" in bootefi.

I hope that you will work on do_efi_selftest().

> But let's leave this as a TODO after the rest of the refactoring.
> 
> > +		if (!dp) {
> > +			ret = EFI_OUT_OF_RESOURCES;
> >  			goto failure;
> > +		}
> > +	} else {
> > +		dp = NULL;
> >  	}
> > +	ret = efi_add_protocol(&obj->header,
> > +			       &efi_guid_loaded_image_device_path, dp);
> 
> I wondered about the loaded imaged device path protocol possibly being
> NULL. But the spec explicitely states:
> 
> It is legal to call LoadImage() for a buffer in memory with a NULL
> DevicePath parameter. In this case, the Loaded Image Device Path
> Protocol is installed with a NULL interface pointer.

Right, I have also found this statement.

-Takahiro Akashi

> Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> 
> > +	if (ret != EFI_SUCCESS)
> > +		goto failure;
> >
> >  	/*
> >  	 * When asking for the loaded_image interface, just
> > diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
> > index fe66e7b9ffe1..c6177b9ff832 100644
> > --- a/lib/efi_loader/efi_image_loader.c
> > +++ b/lib/efi_loader/efi_image_loader.c
> > @@ -14,6 +14,8 @@
> >  const efi_guid_t efi_global_variable_guid = EFI_GLOBAL_VARIABLE_GUID;
> >  const efi_guid_t efi_guid_device_path = DEVICE_PATH_GUID;
> >  const efi_guid_t efi_guid_loaded_image = LOADED_IMAGE_GUID;
> > +const efi_guid_t efi_guid_loaded_image_device_path
> > +		= LOADED_IMAGE_DEVICE_PATH_GUID;
> >  const efi_guid_t efi_simple_file_system_protocol_guid =
> >  		EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
> >  const efi_guid_t efi_file_info_guid = EFI_FILE_INFO_GUID;
> >
> 

  parent reply	other threads:[~2019-03-28  1:13 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27  4:40 [U-Boot] [RFC v2 00/11] efi_loader: rework bootefi/bootmgr AKASHI Takahiro
2019-03-27  4:40 ` [U-Boot] [RFC v2 01/11] efi_loader: boottime: add loaded image device path protocol to image handle AKASHI Takahiro
2019-03-27  5:58   ` Heinrich Schuchardt
2019-03-27 21:25     ` Heinrich Schuchardt
2019-03-28  1:13     ` AKASHI Takahiro [this message]
2019-03-27  4:40 ` [U-Boot] [RFC v2 02/11] efi_loader: boottime: export efi_[un]load_image() AKASHI Takahiro
2019-03-27 21:26   ` Heinrich Schuchardt
2019-03-27  4:40 ` [U-Boot] [RFC v2 03/11] efi_loader: device_path: handle special case of loading AKASHI Takahiro
2019-03-27  6:17   ` Heinrich Schuchardt
2019-03-28  1:17     ` AKASHI Takahiro
2019-03-27  4:40 ` [U-Boot] [RFC v2 04/11] cmd: bootefi: carve out fdt handling from do_bootefi() AKASHI Takahiro
2019-03-27  6:29   ` Heinrich Schuchardt
2019-03-28  1:26     ` AKASHI Takahiro
2019-03-27  4:40 ` [U-Boot] [RFC v2 05/11] cmd: bootefi: merge efi_install_fdt() and efi_process_fdt() AKASHI Takahiro
2019-03-27  6:33   ` Heinrich Schuchardt
2019-03-28  1:31     ` AKASHI Takahiro
2019-03-27  4:40 ` [U-Boot] [RFC v2 06/11] cmd: bootefi: carve out efi_selftest code from do_bootefi() AKASHI Takahiro
2019-03-27  6:45   ` Heinrich Schuchardt
2019-03-28  2:00     ` AKASHI Takahiro
2019-03-27  4:40 ` [U-Boot] [RFC v2 07/11] cmd: bootefi: move do_bootefi_bootmgr_exec() forward AKASHI Takahiro
2019-03-27  6:50   ` Heinrich Schuchardt
2019-03-28  2:13     ` AKASHI Takahiro
2019-03-27  4:40 ` [U-Boot] [RFC v2 08/11] cmd: bootefi: carve out bootmgr code from do_bootefi() AKASHI Takahiro
2019-04-12  5:55   ` Heinrich Schuchardt
2019-04-12  7:06     ` AKASHI Takahiro
2019-04-12  8:58       ` Heinrich Schuchardt
2019-04-12 14:19         ` AKASHI Takahiro
2019-04-12 20:28           ` Heinrich Schuchardt
2019-04-16  4:20             ` AKASHI Takahiro
2019-03-27  4:40 ` [U-Boot] [RFC v2 09/11] cmd: bootefi: carve out do_boot_efi() " AKASHI Takahiro
2019-04-12  5:59   ` Heinrich Schuchardt
2019-04-12  7:22     ` AKASHI Takahiro
2019-04-12  9:01       ` Heinrich Schuchardt
2019-03-27  4:40 ` [U-Boot] [RFC v2 10/11] efi_loader: rework bootmgr/bootefi using load_image API AKASHI Takahiro
2019-04-12  5:53   ` Heinrich Schuchardt
2019-04-12  8:38     ` AKASHI Takahiro
2019-04-12  8:55       ` Heinrich Schuchardt
2019-03-27  4:40 ` [U-Boot] [RFC v2 11/11] cmd: add efibootmgr command AKASHI Takahiro
2019-03-27  7:10   ` Heinrich Schuchardt
2019-03-31 18:27     ` Alexander Graf
2019-04-12  1:18 ` [U-Boot] [RFC v2 00/11] efi_loader: rework bootefi/bootmgr AKASHI Takahiro
2019-04-12  6:11   ` Heinrich Schuchardt
2019-04-12  6:25     ` AKASHI Takahiro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190328011308.GU9937@linaro.org \
    --to=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox