[U-Boot] [PATCH v4 1/1] efi_loader: write protocol GUID in OpenProtocol

Heinrich Schuchardt xypron.glpk at gmx.de
Wed Aug 23 21:44:01 UTC 2017


On 08/18/2017 05:45 PM, Heinrich Schuchardt wrote:
> To understand what is happening in OpenProtocol or LocateProtocol
> it is necessary to know the protocol interface GUID.
> Let's write a debug message.
> 
> Cc: Rob Clark <robdclark at gmail.com>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
> v4:
> 	use %pUl format string
> 	correct indention of output
> v3:
> 	commit message changed
> v2:
> 	fix typo in commit message
> ---
>  include/efi_loader.h          |  8 ++++++++
>  lib/efi_loader/efi_boottime.c | 11 +++++++++++
>  2 files changed, 19 insertions(+)
> 
> diff --git a/include/efi_loader.h b/include/efi_loader.h
> index 870854fb61..5b20af808b 100644
> --- a/include/efi_loader.h
> +++ b/include/efi_loader.h
> @@ -17,6 +17,7 @@
>  
>  int __efi_entry_check(void);
>  int __efi_exit_check(void);
> +const char *__efi_nesting(void);
>  const char *__efi_nesting_inc(void);
>  const char *__efi_nesting_dec(void);
>  
> @@ -64,6 +65,13 @@ const char *__efi_nesting_dec(void);
>  	debug("%sEFI: Return From: %s\n", __efi_nesting_dec(), #exp); \
>  	} while(0)
>  
> +/*
> + * Write GUID
> + */
> +#define EFI_PRINT_GUID(txt, guid) ({ \
> +	debug("%sEFI: %s %pUl\n", __efi_nesting(), txt, guid); \
> +	})
> +
>  extern struct efi_runtime_services efi_runtime_services;
>  extern struct efi_system_table systab;
>  
> diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
> index 5aeaeeca75..6af033458b 100644
> --- a/lib/efi_loader/efi_boottime.c
> +++ b/lib/efi_loader/efi_boottime.c
> @@ -112,6 +112,11 @@ static const char *indent_string(int level)
>  	return &indent[max - level];
>  }
>  
> +const char *__efi_nesting(void)
> +{
> +	return indent_string(nesting_level);
> +}
> +
>  const char *__efi_nesting_inc(void)
>  {
>  	return indent_string(nesting_level++);
> @@ -1163,6 +1170,8 @@ static efi_status_t EFIAPI efi_locate_protocol(efi_guid_t *protocol,
>  	if (!protocol || !protocol_interface)
>  		return EFI_EXIT(EFI_INVALID_PARAMETER);
>  
> +	EFI_PRINT_GUID("protocol", protocol);
> +
>  	list_for_each(lhandle, &efi_obj_list) {
>  		struct efi_object *efiobj;
>  
> @@ -1366,6 +1375,8 @@ static efi_status_t EFIAPI efi_open_protocol(
>  		goto out;
>  	}
>  
> +	EFI_PRINT_GUID("protocol", protocol);
> +
>  	switch (attributes) {
>  	case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL:
>  	case EFI_OPEN_PROTOCOL_GET_PROTOCOL:
> 

Hello Rob,

with the patch installed I sometimes got failures on Travis when grub is
loaded.
https://travis-ci.org/xypron2/u-boot/builds/267753128?utm_source=github_status&utm_medium=notification

I added some code for debugging and found that after efi_exit is called
it opens the EFI_LOADED_IMAGE_PROTOCOL.

This leads to an error in __efi_entry_check():

do_bootefi_exec:270 Jumping to 0x9ee22400

previous call
/home/travis/build/xypron2/u-boot/lib/efi_loader/efi_boottime.c(869)
efi_exit, ret = 0

  EFI: protocol 5b1b31a1-9562-11d2-8e3f-00a0c969723b

previous call
/home/travis/build/xypron2/u-boot/lib/efi_loader/efi_boottime.c(1567)
efi_open_protocol, ret = 0

previous call
/home/travis/build/xypron2/u-boot/lib/efi_loader/efi_boottime.c(1365)
efi_locate_protocol, ret = 0

previous call
/home/travis/build/xypron2/u-boot/lib/efi_loader/efi_console.c(54)
efi_cin_get_mode, ret = 0

previous call
/home/travis/build/xypron2/u-boot/lib/efi_loader/efi_boottime.c(1365)
efi_locate_protocol, ret = 0

previous call
/home/travis/build/xypron2/u-boot/lib/efi_loader/efi_console.c(54)
efi_cin_get_mode, ret = 0

/home/travis/build/xypron2/u-boot/lib/efi_loader/efi_boottime.c:227:
efi_allocate_pages_ext: Assertion `__efi_entry_check()' failed.

resetting ...

I will work on a patch to fix it.

Regards

Heinrich


More information about the U-Boot mailing list