From 992b1731e6afc9ae4507e3ae22b6bcd1f2cb4ffc Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sun, 21 Feb 2021 10:16:58 +0100 Subject: efi_loader: ACPI tables must be in EfiACPIReclaimMemory The UEFI spec does not allow ACPI tables to be in runtime services memory. It recommends EfiACPIReclaimMemory. Remove a superfluous check that the allocated pages are 16 byte aligned. EFI pages are 4 KiB aligned. Fixes: 86df34d42b05 ("efi_loader: Install ACPI configuration tables") Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_acpi.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_acpi.c b/lib/efi_loader/efi_acpi.c index 585b2d2b63..a62c34009c 100644 --- a/lib/efi_loader/efi_acpi.c +++ b/lib/efi_loader/efi_acpi.c @@ -25,7 +25,7 @@ efi_status_t efi_acpi_register(void) /* Reserve 64kiB page for ACPI */ ret = efi_allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, - EFI_RUNTIME_SERVICES_DATA, 16, &acpi); + EFI_ACPI_RECLAIM_MEMORY, 16, &acpi); if (ret != EFI_SUCCESS) return ret; @@ -34,7 +34,6 @@ efi_status_t efi_acpi_register(void) * a 4k-aligned address, so it is safe to assume that * write_acpi_tables() will write the table at that address. */ - assert(!(acpi & 0xf)); write_acpi_tables(acpi); /* And expose them to our EFI payload */ -- cgit v1.2.3 From 77cae565bde9a9fa98e191006c0672d57d862a48 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Mon, 22 Feb 2021 20:26:34 +0100 Subject: MAINTAINERS: assign tools/mkeficapsule.c to EFI PAYLOAD tools/mkeficapsule.c is used to prepare test files for testing the UEFI sub-system. Signed-off-by: Heinrich Schuchardt --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index b82b7adbeb..a832abc765 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -708,6 +708,7 @@ F: cmd/efidebug.c F: cmd/nvedit_efi.c F: tools/efivar.py F: tools/file2include.c +F: tools/mkeficapsule.c EFI VARIABLES VIA OP-TEE M: Ilias Apalodimas -- cgit v1.2.3 From 95cacc86f2f4baa2d86f68a63baa9e8e797e4e46 Mon Sep 17 00:00:00 2001 From: Klaus Heinrich Kiwi Date: Sat, 20 Feb 2021 17:40:45 -0300 Subject: tools/mkeficapsule.c: fix DEBUG build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a missing comma sign (,) from a printf(), that is only reachable if DEBUG is defined, in which case the build fails with: tools/mkeficapsule.c:266:36: error: expected β€˜)’ before β€˜bin’ 266 | printf("\tbin: %s\n\ttype: %pUl\n" bin, guid); | ^~~~ | ) Signed-off-by: Klaus Heinrich Kiwi Reviewed-by: Heinrich Schuchardt --- tools/mkeficapsule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/mkeficapsule.c b/tools/mkeficapsule.c index 162494907a..1613e74ca7 100644 --- a/tools/mkeficapsule.c +++ b/tools/mkeficapsule.c @@ -263,7 +263,7 @@ static int create_fwbin(char *path, char *bin, efi_guid_t *guid, #ifdef DEBUG printf("For output: %s\n", path); - printf("\tbin: %s\n\ttype: %pUl\n" bin, guid); + printf("\tbin: %s\n\ttype: %pUl\n", bin, guid); printf("\tindex: %ld\n\tinstance: %ld\n", index, instance); #endif -- cgit v1.2.3 From 9c081a7eabd4e5f54bd692df722705bc5ec57891 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Tue, 23 Feb 2021 21:15:35 +0100 Subject: efi_loader: limit output length for VenHw, VenMedia VenHw and VenMedia device path nodes may carry vendor defined data of arbitrary length. When converting a device path node to text ensure that we do not overrun our internal buffer. In our implementation of EFI_DEVICE_PATH_TO_TEXT_PROTOCOL.ConvertDevicePathToText() we could first determine the output length and then allocate buffers but that would nearly double the code size. Therefore keep the preallocated buffers and truncate excessive device paths instead. Signed-off-by: Heinrich Schuchardt --- lib/efi_loader/efi_device_path_to_text.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/efi_loader/efi_device_path_to_text.c b/lib/efi_loader/efi_device_path_to_text.c index 81b8ac23ba..edc9fdc387 100644 --- a/lib/efi_loader/efi_device_path_to_text.c +++ b/lib/efi_loader/efi_device_path_to_text.c @@ -67,7 +67,8 @@ static char *dp_hardware(char *s, struct efi_device_path *dp) s += sprintf(s, "VenHw(%pUl", &vdp->guid); n = (int)vdp->dp.length - sizeof(struct efi_device_path_vendor); - if (n > 0) { + /* Node must fit into MAX_NODE_LEN) */ + if (n > 0 && n < MAX_NODE_LEN / 2 - 22) { s += sprintf(s, ","); for (i = 0; i < n; ++i) s += sprintf(s, "%02x", vdp->vendor_data[i]); @@ -251,7 +252,8 @@ static char *dp_media(char *s, struct efi_device_path *dp) s += sprintf(s, "VenMedia(%pUl", &vdp->guid); n = (int)vdp->dp.length - sizeof(struct efi_device_path_vendor); - if (n > 0) { + /* Node must fit into MAX_NODE_LEN) */ + if (n > 0 && n < MAX_NODE_LEN / 2 - 24) { s += sprintf(s, ","); for (i = 0; i < n; ++i) s += sprintf(s, "%02x", vdp->vendor_data[i]); -- cgit v1.2.3 From c6f077a207921df8259170916ae9a2952b1fcd71 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 25 Feb 2021 08:02:37 +0100 Subject: efi_loader: fix documentation in efi_loader.h Correct missing descriptions and typos in efi_loader.h. Signed-off-by: Heinrich Schuchardt --- include/efi_loader.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/include/efi_loader.h b/include/efi_loader.h index f470bbd636..68daa1a4a9 100644 --- a/include/efi_loader.h +++ b/include/efi_loader.h @@ -242,7 +242,7 @@ struct efi_open_protocol_info_item { * @link: link to the list of protocols of a handle * @guid: GUID of the protocol * @protocol_interface: protocol interface - * @open_infos link to the list of open protocol info items + * @open_infos: link to the list of open protocol info items */ struct efi_handler { struct list_head link; @@ -258,9 +258,13 @@ struct efi_handler { * started image. */ enum efi_object_type { + /** @EFI_OBJECT_TYPE_UNDEFINED: undefined image type */ EFI_OBJECT_TYPE_UNDEFINED = 0, + /** @EFI_OBJECT_TYPE_U_BOOT_FIRMWARE: U-Boot firmware */ EFI_OBJECT_TYPE_U_BOOT_FIRMWARE, + /** @EFI_OBJECT_TYPE_LOADED_IMAGE: loaded image (not started) */ EFI_OBJECT_TYPE_LOADED_IMAGE, + /** @EFI_OBJECT_TYPE_STARTED_IMAGE: started image */ EFI_OBJECT_TYPE_STARTED_IMAGE, }; @@ -270,6 +274,7 @@ enum efi_object_type { * @link: pointers to put the handle into a linked list * @protocols: linked list with the protocol interfaces installed on this * handle + * @type: image type if the handle relates to an image * * UEFI offers a flexible and expandable object model. The objects in the UEFI * API are devices, drivers, and loaded images. struct efi_object is our storage @@ -325,7 +330,7 @@ struct efi_loaded_image_obj { * @queue_link: Link to the list of queued events * @type: Type of event, see efi_create_event * @notify_tpl: Task priority level of notifications - * @nofify_function: Function to call when the event is triggered + * @notify_function: Function to call when the event is triggered * @notify_context: Data to be passed to the notify function * @group: Event group * @trigger_time: Period of the timer @@ -368,7 +373,8 @@ struct efi_protocol_notification { }; /** - * efi_register_notify_event - event registered by RegisterProtocolNotify() + * struct efi_register_notify_event - event registered by + * RegisterProtocolNotify() * * The address of this structure serves as registration value. * @@ -747,7 +753,7 @@ efi_status_t efi_set_load_options(efi_handle_t handle, efi_status_t efi_bootmgr_load(efi_handle_t *handle, void **load_options); /** - * efi_image_regions - A list of memory regions + * struct efi_image_regions - A list of memory regions * * @max: Maximum number of regions * @num: Number of regions @@ -760,13 +766,13 @@ struct efi_image_regions { }; /** - * efi_sig_data - A decoded data of struct efi_signature_data + * struct efi_sig_data - A decoded data of struct efi_signature_data * * This structure represents an internal form of signature in * signature database. A listed list may represent a signature list. * * @next: Pointer to next entry - * @onwer: Signature owner + * @owner: Signature owner * @data: Pointer to signature data * @size: Size of signature data */ @@ -778,7 +784,7 @@ struct efi_sig_data { }; /** - * efi_signature_store - A decoded data of signature database + * struct efi_signature_store - A decoded data of signature database * * This structure represents an internal form of signature database. * -- cgit v1.2.3 From a2c3f1bca4bf21371d041d1de589039aa3459e91 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 26 Feb 2021 17:57:47 +0100 Subject: cmd/efidebug: add firmware management protocol GUID Add missing GUID short text used in the efidebug tables and efidebug dh sub-commands. Signed-off-by: Heinrich Schuchardt --- cmd/efidebug.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmd/efidebug.c b/cmd/efidebug.c index bbbcb0a546..e4030f514a 100644 --- a/cmd/efidebug.c +++ b/cmd/efidebug.c @@ -507,6 +507,10 @@ static const struct { "System Partition", PARTITION_SYSTEM_GUID }, + { + "Firmware Management", + EFI_FIRMWARE_MANAGEMENT_PROTOCOL_GUID + }, /* Configuration table GUIDs */ { "ACPI table", -- cgit v1.2.3