From a2a4bc3b09fc956ae58572430a019781425baf9c Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Tue, 16 Apr 2019 13:24:20 +0900 Subject: efi_loader: export root node handle This is a preparatory patch. The root node handle will be used as a dummy parent handle when invoking an EFI image from bootefi/bootmgr command. Signed-off-by: AKASHI Takahiro Rebased. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index f7bf732827..93f7672aec 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -25,6 +25,9 @@ EFI_GUID(0xe61d73b9, 0xa384, 0x4acc, \ 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3, 0x62, 0x8b) +/* Root node */ +extern efi_handle_t efi_root; + int __efi_entry_check(void); int __efi_exit_check(void); const char *__efi_nesting(void); -- cgit From dec88e41e022ac06c0054ca48807db0d95f917f6 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 20 Apr 2019 07:39:11 +0200 Subject: efi_loader: consistent naming of protocol GUIDs We should consistently use the same name for protocol GUIDs as defined in the UEFI specification. Not adhering to this rule has led to duplicate definitions for the EFI_LOADED_IMAGE_PROTOCOL_GUID. Adjust misnamed protocol GUIDs. Adjust the text for the graphics output protocol in the output of the `efidebug dh` command. Signed-off-by: Heinrich Schuchardt --- include/efi_api.h | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/efi_api.h b/include/efi_api.h index 5b0a100635..472160cb30 100644 --- a/include/efi_api.h +++ b/include/efi_api.h @@ -290,10 +290,6 @@ struct efi_runtime_services { EFI_GUID(0x8be4df61, 0x93ca, 0x11d2, 0xaa, 0x0d, \ 0x00, 0xe0, 0x98, 0x03, 0x2b, 0x8c) -#define LOADED_IMAGE_PROTOCOL_GUID \ - EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, 0x8e, 0x3f, \ - 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) - #define EFI_FDT_GUID \ EFI_GUID(0xb1b621d5, 0xf19c, 0x41a5, \ 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0) @@ -329,11 +325,11 @@ struct efi_system_table { struct efi_configuration_table *tables; }; -#define LOADED_IMAGE_GUID \ +#define EFI_LOADED_IMAGE_PROTOCOL_GUID \ EFI_GUID(0x5b1b31a1, 0x9562, 0x11d2, \ 0x8e, 0x3f, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) -#define LOADED_IMAGE_DEVICE_PATH_GUID \ +#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \ EFI_GUID(0xbc62157e, 0x3e33, 0x4fec, \ 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf) @@ -355,7 +351,7 @@ struct efi_loaded_image { unsigned long unload; }; -#define DEVICE_PATH_GUID \ +#define EFI_DEVICE_PATH_PROTOCOL_GUID \ EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) @@ -478,7 +474,7 @@ struct efi_device_path_file_path { u16 str[]; } __packed; -#define BLOCK_IO_GUID \ +#define EFI_BLOCK_IO_PROTOCOL_GUID \ EFI_GUID(0x964e5b21, 0x6459, 0x11d2, \ 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b) @@ -1123,7 +1119,7 @@ struct efi_hii_config_access_protocol { efi_browser_action_request_t *action_request); }; -#define EFI_GOP_GUID \ +#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \ EFI_GUID(0x9042a9de, 0x23dc, 0x4a38, \ 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a) @@ -1175,7 +1171,7 @@ struct efi_gop { struct efi_gop_mode *mode; }; -#define EFI_SIMPLE_NETWORK_GUID \ +#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \ EFI_GUID(0xa19832b9, 0xac25, 0x11d3, \ 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) @@ -1268,7 +1264,7 @@ struct efi_simple_network { struct efi_simple_network_mode *mode; }; -#define EFI_PXE_GUID \ +#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \ EFI_GUID(0x03c4e603, 0xac28, 0x11d3, \ 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d) -- cgit From 6b95b38c41a6a56d48b51b192dac7365ce0a8024 Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Fri, 19 Apr 2019 12:22:35 +0900 Subject: efi_loader: rework bootmgr/bootefi using load_image API In the current implementation, bootefi command and EFI boot manager don't use load_image API, instead, use more primitive and internal functions. This will introduce duplicated code and potentially unknown bugs as well as inconsistent behaviours. With this patch, do_efibootmgr() and do_boot_efi() are completely overhauled and re-implemented using load_image API. Signed-off-by: AKASHI Takahiro Use efi_root as parent handle for the loaded image. LoadImage() should be called with BootPolicy = true by the boot manager. Avoid duplicate free_pool(). Eliminate variable memdp which is not needed after anymore due to "efi_loader: correctly split device path of loaded image". Reviewed-by: Heinrich Schuchardt Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'include') diff --git a/include/efi_loader.h b/include/efi_loader.h index 93f7672aec..39ed8a6fa5 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -412,8 +412,6 @@ efi_status_t efi_setup_loaded_image(struct efi_device_path *device_path, struct efi_device_path *file_path, struct efi_loaded_image_obj **handle_ptr, struct efi_loaded_image **info_ptr); -efi_status_t efi_load_image_from_path(struct efi_device_path *file_path, - void **buffer, efi_uintn_t *size); /* Print information about all loaded images */ void efi_print_image_infos(void *pc); @@ -567,8 +565,7 @@ struct efi_load_option { void efi_deserialize_load_option(struct efi_load_option *lo, u8 *data); unsigned long efi_serialize_load_option(struct efi_load_option *lo, u8 **data); -void *efi_bootmgr_load(struct efi_device_path **device_path, - struct efi_device_path **file_path); +efi_status_t efi_bootmgr_load(efi_handle_t *handle); #else /* CONFIG_IS_ENABLED(EFI_LOADER) */ -- cgit From f12bcc9149c32a01dac687718ad126d4d3ba29ba Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 23 Apr 2019 00:30:53 +0200 Subject: efi_loader: check memory type in AllocatePages() The UEFI specification prescribes that AllocatePages() checks the memory type. Signed-off-by: Heinrich Schuchardt --- include/efi.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/efi.h b/include/efi.h index 3c9d20f8c0..5f415a99cc 100644 --- a/include/efi.h +++ b/include/efi.h @@ -168,6 +168,10 @@ enum efi_mem_type { * part of the processor. */ EFI_PAL_CODE, + /* + * Non-volatile memory. + */ + EFI_PERSISTENT_MEMORY_TYPE, EFI_MAX_MEMORY_TYPE, EFI_TABLE_END, /* For efi_build_mem_table() */ -- cgit