Skip to contentSkip to conversation

Add EFI Debug Support Table feature

PATCH Superseded Ying-Chun Liu (PaulLiu) 5 participants 13 messages May 22, 2025 – May 28, 2025

v3 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v3 cover Add EFI Debug Support Table feature

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

I implemented the UEFI Specification version 2.10, specifically focusing on the functionality described in Section 18.4, which details the EFI Debug Support Table feature. This implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover and interact with system-level debug resources.

V2: add Kconfig options to turn on/off this feature.
V3: Fix the way of removing debug_image_info.

Ying-Chun Liu (PaulLiu) (4):
efi: add EFI_SYSTEM_TABLE_POINTER for debug
efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug
lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory
efi: add EFI_DEBUG_IMAGE_INFO for debug

 include/efi_api.h             |  71 +++++++++++++
 include/efi_loader.h          |  11 ++
 lib/efi_loader/Kconfig        |   7 ++
 lib/efi_loader/efi_boottime.c | 188 ++++++++++++++++++++++++++++++++++
 lib/efi_loader/efi_memory.c   |  52 ++++++++++
 lib/efi_loader/efi_setup.c    |  25 +++++
 6 files changed, 354 insertions(+)
Signature · 1 line
2.39.5
#1 lore raw

PATCH v3 1/4 efi: add EFI_SYSTEM_TABLE_POINTER for debug

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

Add EFI_SYSTEM_TABLE_POINTER structure for remote debugger to locate the address of EFI_SYSTEM_TABLE.

This feature is described in UEFI SPEC version 2.10. Section 18.4.2. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover the EFI system table.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>

---
V2: add Kconfig options to turn on/off this feature.
V3: make efi_initialize_system_table_pointer() do the job as described.

---
 include/efi_api.h             | 16 ++++++++++++
 include/efi_loader.h          |  2 ++
 lib/efi_loader/Kconfig        |  7 ++++++
 lib/efi_loader/efi_boottime.c | 46 +++++++++++++++++++++++++++++++++++
 lib/efi_loader/efi_setup.c    |  8 ++++++
 5 files changed, 79 insertions(+)
include/efi_api.h +16 -0
index eb61eafa028..6c4c1a0cc7b 100644
@@ -259,6 +259,22 @@ struct efi_capsule_result_variable_header {
 	efi_status_t capsule_status;
 } __packed;
 
+/**
+ * struct efi_system_table_pointer - struct to store the pointer of system
+ * table.
+ * @signature: The signature of this struct.
+ * @efi_system_table_base: The physical address of System Table.
+ * @crc32: CRC32 checksum
+ *
+ * This struct is design for hardware debugger to search through memory to
+ * get the address of EFI System Table.
+ */
+struct efi_system_table_pointer {
+	u64 signature;
+	efi_physical_addr_t efi_system_table_base;
+	u32 crc32;
+};
+
 struct efi_memory_range {
 	efi_physical_addr_t	address;
 	u64			length;
include/efi_loader.h +2 -0
index 8f9f2bcf1cb..8f065244d8e 100644
@@ -646,6 +646,8 @@ efi_status_t efi_tcg2_measure_dtb(void *dtb);
 efi_status_t efi_root_node_register(void);
 /* Called by bootefi to initialize runtime */
 efi_status_t efi_initialize_system_table(void);
+/* Called by bootefi to initialize debug */
+efi_status_t efi_initialize_system_table_pointer(void);
 /* efi_runtime_detach() - detach unimplemented runtime functions */
 void efi_runtime_detach(void);
 /* efi_convert_pointer() - convert pointer to virtual address */
lib/efi_loader/Kconfig +7 -0
index 7f02a83e2a2..d878fc9021d 100644
@@ -71,6 +71,13 @@ config EFI_SECURE_BOOT
 config EFI_SIGNATURE_SUPPORT
 	bool
 
+config EFI_DEBUG_SUPPORT_TABLE
+	bool "EFI Debug Support Table"
+	help
+	  Select this option if you want to setup the EFI Debug Support
+	  Table which is used by the debug agent or an external debugger to
+	  determine loaded image information in a quiescent manner.
+
 menu "UEFI services"
 
 config EFI_GET_TIME
lib/efi_loader/efi_boottime.c +46 -0

55 lines not on this page · raw message

lib/efi_loader/efi_setup.c +8 -0
index 48f91da5df7..a6b37d994f6 100644
@@ -278,6 +278,14 @@ efi_status_t efi_init_obj_list(void)
 	if (ret != EFI_SUCCESS)
 		goto out;
 
+	/* Initialize system table pointer */
+	if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+		ret = efi_initialize_system_table_pointer();
+		if (ret != EFI_SUCCESS) {
+			goto out;
+		}
+	}
+
 	if (IS_ENABLED(CONFIG_EFI_ECPT)) {
 		ret = efi_ecpt_register();
 		if (ret != EFI_SUCCESS)
Signature · 1 line
2.39.5
#2 lore raw

Re: [PATCH v3 1/4] efi: add EFI_SYSTEM_TABLE_POINTER for debug

Am 22. Mai 2025 03:17:45 MESZ schrieb "Ying-Chun Liu (PaulLiu)" <[email protected]>:

Quoted 112 lines

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

Add EFI_SYSTEM_TABLE_POINTER structure for remote debugger to locate the address of EFI_SYSTEM_TABLE.

This feature is described in UEFI SPEC version 2.10. Section 18.4.2. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover the EFI system table.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>

---
V2: add Kconfig options to turn on/off this feature.
V3: make efi_initialize_system_table_pointer() do the job as described.
---

include/efi_api.h             | 16 ++++++++++++
include/efi_loader.h          |  2 ++
lib/efi_loader/Kconfig        |  7 ++++++
lib/efi_loader/efi_boottime.c | 46 +++++++++++++++++++++++++++++++++++
lib/efi_loader/efi_setup.c    |  8 ++++++
5 files changed, 79 insertions(+)
include/efi_api.h +16 -0
index eb61eafa028..6c4c1a0cc7b 100644
@@ -259,6 +259,22 @@ struct efi_capsule_result_variable_header {
 	efi_status_t capsule_status;
 } __packed;
 
+/**
+ * struct efi_system_table_pointer - struct to store the pointer of system
+ * table.
+ * @signature: The signature of this struct.
+ * @efi_system_table_base: The physical address of System Table.
+ * @crc32: CRC32 checksum
+ *
+ * This struct is design for hardware debugger to search through memory to
+ * get the address of EFI System Table.
+ */
+struct efi_system_table_pointer {
+	u64 signature;
+	efi_physical_addr_t efi_system_table_base;
+	u32 crc32;
+};
+
 struct efi_memory_range {
 	efi_physical_addr_t	address;
 	u64			length;
include/efi_loader.h +2 -0
index 8f9f2bcf1cb..8f065244d8e 100644
@@ -646,6 +646,8 @@ efi_status_t efi_tcg2_measure_dtb(void *dtb);
 efi_status_t efi_root_node_register(void);
 /* Called by bootefi to initialize runtime */
 efi_status_t efi_initialize_system_table(void);
+/* Called by bootefi to initialize debug */
+efi_status_t efi_initialize_system_table_pointer(void);
 /* efi_runtime_detach() - detach unimplemented runtime functions */
 void efi_runtime_detach(void);
 /* efi_convert_pointer() - convert pointer to virtual address */
lib/efi_loader/Kconfig +0 -0
index 7f02a83e2a2..d878fc9021d 100644
@@ -71,6 +71,13 @@ config EFI_SECURE_BOOT

config EFI_SIGNATURE_SUPPORT
bool

lib/efi_loader/Kconfig +7 -0
+config EFI_DEBUG_SUPPORT_TABLE
+	bool "EFI Debug Support Table"
+	help
+	  Select this option if you want to setup the EFI Debug Support
+	  Table which is used by the debug agent or an external debugger to
+	  determine loaded image information in a quiescent manner.
+

menu "UEFI services"

config EFI_GET_TIME

lib/efi_loader/efi_boottime.c +14 -0
index dbebb37dc04..5a4349f8679 100644
@@ -4001,6 +4001,8 @@ struct efi_system_table __efi_runtime_data systab = {
 	.tables = NULL,
 };
 
+struct efi_system_table_pointer __efi_runtime_data * systab_pointer = NULL;
+
 /**
 * efi_initialize_system_table() - Initialize system table
 *
@@ -4035,3 +4037,47 @@ efi_status_t efi_initialize_system_table(void)
 
 	return ret;
 }
+
+/**
+ * efi_initialize_system_table() - Initialize system table pointer
+ *
+ * Return:	status code
+ */
+efi_status_t efi_initialize_system_table_pointer(void)
+{
+	efi_status_t ret;
+	const int size_4MB = 0x00400000;
+	int pages = efi_size_in_pages(sizeof(struct efi_system_table_pointer));
+	int alignment_mask = size_4MB - 1;

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void) · line 4061

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+	int real_pages = pages + efi_size_in_pages(size_4MB);
+	u64 addr;
+	u64 aligned_addr;
+	u32 crc32_value;
+
+	/* Allocate configuration table array */
+	ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+				 EFI_RUNTIME_SERVICES_DATA,
+				 real_pages,
+				 &addr);

You are allocating 8 MiB for a table that isn't even 1 KiB in size.

Can't we use an LMB allocation function instead and add the page to the EFI memory table afterwards?

Only for the EFI app and the sandbox physical and virtual addresses differ.

Best regards

Heinrich

Quoted 41 lines
lib/efi_loader/efi_boottime.c +22 -0
+
+	if (ret != EFI_SUCCESS) {
+		log_err("Installing EFI system table pointer failed\n");
+		return ret;
+	}
+
+	/* alignment to 4MB boundary */
+	aligned_addr = (addr + alignment_mask) & ~alignment_mask;
+
+	systab_pointer = (struct efi_system_table_pointer *)aligned_addr;
+	memset(systab_pointer, 0, sizeof(struct efi_system_table_pointer));
+
+	systab_pointer->signature = EFI_SYSTEM_TABLE_SIGNATURE;
+	systab_pointer->efi_system_table_base = (efi_physical_addr_t)&systab;
+	systab_pointer->crc32 = 0;
+	crc32_value = crc32(0,
+			    (const unsigned char *)systab_pointer,
+			    sizeof(struct efi_system_table_pointer));
+	systab_pointer->crc32 = crc32_value;
+
+	return ret;
+}
lib/efi_loader/efi_setup.c +8 -0
index 48f91da5df7..a6b37d994f6 100644
@@ -278,6 +278,14 @@ efi_status_t efi_init_obj_list(void)
 	if (ret != EFI_SUCCESS)
 		goto out;
 
+	/* Initialize system table pointer */
+	if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+		ret = efi_initialize_system_table_pointer();
+		if (ret != EFI_SUCCESS) {
+			goto out;
+		}
+	}
+
 	if (IS_ENABLED(CONFIG_EFI_ECPT)) {
 		ret = efi_ecpt_register();
 		if (ret != EFI_SUCCESS)
#3 lore raw

Re: [PATCH v3 1/4] efi: add EFI_SYSTEM_TABLE_POINTER for debug

In reply to Ying-Chun Liu (PaulLiu)

Hi Paul,

[...]

Quoted 49 lines

bool

lib/efi_loader/Kconfig +7 -0
+config EFI_DEBUG_SUPPORT_TABLE
+       bool "EFI Debug Support Table"
+       help
+         Select this option if you want to setup the EFI Debug Support
+         Table which is used by the debug agent or an external debugger to
+         determine loaded image information in a quiescent manner.
+
 menu "UEFI services"
 
 config EFI_GET_TIME
lib/efi_loader/efi_boottime.c +22 -0
index dbebb37dc04..5a4349f8679 100644
@@ -4001,6 +4001,8 @@ struct efi_system_table __efi_runtime_data systab = {
        .tables = NULL,
 };
 
+struct efi_system_table_pointer __efi_runtime_data * systab_pointer = NULL;
+
 /**
  * efi_initialize_system_table() - Initialize system table
  *
@@ -4035,3 +4037,47 @@ efi_status_t efi_initialize_system_table(void)
 
        return ret;
 }
+
+/**
+ * efi_initialize_system_table() - Initialize system table pointer
+ *
+ * Return:     status code
+ */
+efi_status_t efi_initialize_system_table_pointer(void)
+{
+       efi_status_t ret;
+       const int size_4MB = 0x00400000;
+       int pages = efi_size_in_pages(sizeof(struct efi_system_table_pointer));
+       int alignment_mask = size_4MB - 1;
+       int real_pages = pages + efi_size_in_pages(size_4MB);
+       u64 addr;
+       u64 aligned_addr;
+       u32 crc32_value;
+
+       /* Allocate configuration table array */
+       ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                EFI_RUNTIME_SERVICES_DATA,

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void) · line 4069

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+                                real_pages,
+                                &addr);
+
+       if (ret != EFI_SUCCESS) {
+               log_err("Installing EFI system table pointer failed\n");
+               return ret;
+       }
+
+       /* alignment to 4MB boundary */
+       aligned_addr = (addr + alignment_mask) & ~alignment_mask;

efi_alloc_aligned_pages() does that for you.
But I have similar questions to Heinrich here. Why do you need 4MB?

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void) · line 4076

Quoted 7 lines
lib/efi_loader/efi_boottime.c +7 -0
+
+       systab_pointer = (struct efi_system_table_pointer *)aligned_addr;
+       memset(systab_pointer, 0, sizeof(struct efi_system_table_pointer));
+
+       systab_pointer->signature = EFI_SYSTEM_TABLE_SIGNATURE;
+       systab_pointer->efi_system_table_base = (efi_physical_addr_t)&systab;
+       systab_pointer->crc32 = 0;

You are assigning this at the end regardless, so I guess you can skip it here.

Quoted 27 lines
lib/efi_loader/efi_boottime.c +7 -0
+       crc32_value = crc32(0,
+                           (const unsigned char *)systab_pointer,
+                           sizeof(struct efi_system_table_pointer));
+       systab_pointer->crc32 = crc32_value;
+
+       return ret;
+}
lib/efi_loader/efi_setup.c +8 -1
index 48f91da5df7..a6b37d994f6 100644
@@ -278,6 +278,14 @@ efi_status_t efi_init_obj_list(void)
        if (ret != EFI_SUCCESS)
                goto out;
 
+       /* Initialize system table pointer */
+       if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+               ret = efi_initialize_system_table_pointer();
+               if (ret != EFI_SUCCESS) {
+                       goto out;
+               }
+       }
+
        if (IS_ENABLED(CONFIG_EFI_ECPT)) {
                ret = efi_ecpt_register();
                if (ret != EFI_SUCCESS)
--
Quoted 2 lines

2.39.5

Thanks
/Ilias

#4 lore raw

Re: [PATCH v3 1/4] efi: add EFI_SYSTEM_TABLE_POINTER for debug

Hi Ilias,

Quoted 64 lines · Ilias Apalodimas

Hi Paul,

[...]

lib/efi_loader/Kconfig config EFI_SECURE_BOOT

Quoted 7 lines

bool

lib/efi_loader/Kconfig +5 -0
+config EFI_DEBUG_SUPPORT_TABLE
+       bool "EFI Debug Support Table"
+       help
+         Select this option if you want to setup the EFI Debug Support
+         Table which is used by the debug agent or an external debugger

to

Review

Quoted 6 lines
lib/efi_loader/Kconfig +2 -0
+         determine loaded image information in a quiescent manner.
+
 menu "UEFI services"
 
 config EFI_GET_TIME
(quoted diff) +0 -0

b/lib/efi_loader/efi_boottime.c

lib/efi_loader/efi_boottime.c struct efi_system_table __efi_runtime_data systab

Quoted 4 lines

index dbebb37dc04..5a4349f8679 100644

lib/efi_loader/efi_boottime.c +0 -0
@@ -4001,6 +4001,8 @@ struct efi_system_table __efi_runtime_data systab

= {

lib/efi_loader/efi_boottime.c struct efi_system_table __efi_runtime_data systab = {

Quoted 4 lines
lib/efi_loader/efi_boottime.c +1 -0
        .tables = NULL,
 };
 
+struct efi_system_table_pointer __efi_runtime_data * systab_pointer =

NULL;

Quoted 9 lines
lib/efi_loader/efi_boottime.c +2 -0
+
 /**
  * efi_initialize_system_table() - Initialize system table
  *
@@ -4035,3 +4037,47 @@ efi_status_t efi_initialize_system_table(void)
 
        return ret;
 }
+

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void) · line 4050

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+/**
+ * efi_initialize_system_table() - Initialize system table pointer
+ *
+ * Return:     status code
+ */
+efi_status_t efi_initialize_system_table_pointer(void)
+{
+       efi_status_t ret;
+       const int size_4MB = 0x00400000;
+       int pages = efi_size_in_pages(sizeof(struct

efi_system_table_pointer));

Quoted 14 lines
lib/efi_loader/efi_boottime.c +14 -0
+       int alignment_mask = size_4MB - 1;
+       int real_pages = pages + efi_size_in_pages(size_4MB);
+       u64 addr;
+       u64 aligned_addr;
+       u32 crc32_value;
+
+       /* Allocate configuration table array */
+       ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+                                EFI_RUNTIME_SERVICES_DATA,
+                                real_pages,
+                                &addr);
+
+       if (ret != EFI_SUCCESS) {
+               log_err("Installing EFI system table pointer failed\n");
Quoted 8 lines

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void) · line 4069

Quoted 5 lines
lib/efi_loader/efi_boottime.c +5 -0
+               return ret;
+       }
+
+       /* alignment to 4MB boundary */
+       aligned_addr = (addr + alignment_mask) & ~alignment_mask;

efi_alloc_aligned_pages() does that for you.
But I have similar questions to Heinrich here. Why do you need 4MB?

The alignment of this structure is 4MB. Is there a way not to allocate a full page but still fulfill this?
The spec said. "A check-summed structure containing the physical address of the EFI system table is created and located on a
4M aligned memory address. A hardware debugger can search memory for this structure to determine the location of the EFI system table."

So that's why I need a page aligned with 4MB. This code is actually copied from edk2. So I should replace it with efi_alloc_aligned_pages() right?

Quoted 6 lines

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void)

Quoted 5 lines
lib/efi_loader/efi_boottime.c +3 -0
+
+       systab_pointer = (struct efi_system_table_pointer *)aligned_addr;
+       memset(systab_pointer, 0, sizeof(struct

efi_system_table_pointer));

Quoted 10 lines

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void)

Quoted 3 lines
lib/efi_loader/efi_boottime.c +3 -0
+
+       systab_pointer->signature = EFI_SYSTEM_TABLE_SIGNATURE;
+       systab_pointer->efi_system_table_base =

(efi_physical_addr_t)&systab;

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table(void) · line 4076

Quoted 1 line
lib/efi_loader/efi_boottime.c +1 -0
+       systab_pointer->crc32 = 0;

You are assigning this at the end regardless, so I guess you can skip it here.

Will remove.

Quoted 33 lines
Quoted 27 lines
lib/efi_loader/efi_boottime.c +7 -0
+       crc32_value = crc32(0,
+                           (const unsigned char *)systab_pointer,
+                           sizeof(struct efi_system_table_pointer));
+       systab_pointer->crc32 = crc32_value;
+
+       return ret;
+}
lib/efi_loader/efi_setup.c +8 -1
index 48f91da5df7..a6b37d994f6 100644
@@ -278,6 +278,14 @@ efi_status_t efi_init_obj_list(void)
        if (ret != EFI_SUCCESS)
                goto out;
 
+       /* Initialize system table pointer */
+       if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+               ret = efi_initialize_system_table_pointer();
+               if (ret != EFI_SUCCESS) {
+                       goto out;
+               }
+       }
+
        if (IS_ENABLED(CONFIG_EFI_ECPT)) {
                ret = efi_ecpt_register();
                if (ret != EFI_SUCCESS)
--
Quoted 2 lines

2.39.5

Thanks
/Ilias

#5 lore raw

PATCH v3 2/4 efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug

In reply to Ying-Chun Liu (PaulLiu)

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

EFI_DEBUG_IMAGE_INFO_TABLE is used to store EFI_LOADED_IMAGE for debug purpose. This commit adds the table to the EFI_CONFIGURATION_TABLE.

This feature is described in UEFI Spec version 2.10. Section 18.4. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover and interact with system-level debug resources.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>

---
V3: Fix the way of installation of configuration table.

---
 include/efi_api.h          | 53 ++++++++++++++++++++++++++++++++++++++
 include/efi_loader.h       |  2 ++
 lib/efi_loader/efi_setup.c | 17 ++++++++++++
 3 files changed, 72 insertions(+)
include/efi_api.h +53 -0
index 6c4c1a0cc7b..8da0a350ce3 100644
@@ -238,6 +238,10 @@ enum efi_reset_type {
 	EFI_GUID(0xcce33c35, 0x74ac, 0x4087, 0xbc, 0xe7, \
 		 0x8b, 0x29, 0xb0, 0x2e, 0xeb, 0x27)
 
+#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
+	EFI_GUID(0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, \
+		 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b)
+
 struct efi_conformance_profiles_table {
 	u16 version;
 	u16 number_of_profiles;
@@ -574,6 +578,55 @@ struct efi_loaded_image {
 	efi_status_t (EFIAPI *unload)(efi_handle_t image_handle);
 };
 
+#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01
+#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED     0x02
+
+/**
+ * struct efi_debug_image_info_normal - Store Debug Information for normal
+ * image.
+ * @image_info_type: the type of image info.
+ * @loaded_image_protocol_instance: the pointer to struct efi_loaded_image.
+ * @image_handle: the EFI handle of the image.
+ *
+ * This struct is created by efi_load_image() and store the information
+ * for debugging an normal image.
+ */
+struct efi_debug_image_info_normal {
+	u32 image_info_type;
+	struct efi_loaded_image *loaded_image_protocol_instance;
+	efi_handle_t image_handle;
+};
+
+/**
+ * union efi_debug_image_info - The union to store a pointer for EFI
+ * DEBUG IMAGE INFO.
+ * @image_info_type: the type of the image_info if it is not a normal image.
+ * @normal_image: The pointer to a normal image.
+ *
+ * This union is for a pointer that can point to the struct of normal_image.
+ * Or it points to an image_info_type.
+ */
+union efi_debug_image_info {
+	u32 *image_info_type;
+	struct efi_debug_image_info_normal *normal_image;
+};
+
+/**
+ * struct efi_debug_image_info_table_header - store the array of
+ * struct efi_debug_image_info.
+ * @update_status: Status to notify this struct is ready to use or not.
+ * @table_size: The number of elements of efi_debug_image_info_table.
+ * @efi_debug_image_info_table: The array of efi_debug_image_info.
+ *
+ * This struct stores the array of efi_debug_image_info. The
+ * number of elements is table_size.
+ */
+struct efi_debug_image_info_table_header {
+	volatile u32 update_status;
+	u32 table_size;
+	union efi_debug_image_info *efi_debug_image_info_table;
+};
+
 #define EFI_DEVICE_PATH_PROTOCOL_GUID \
 	EFI_GUID(0x09576e91, 0x6d3f, 0x11d2, \
 		 0x8e, 0x39, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b)
include/efi_loader.h +2 -0
index 8f065244d8e..d0c72d0bc58 100644
@@ -315,6 +315,8 @@ extern const struct efi_hii_config_routing_protocol efi_hii_config_routing;
 extern const struct efi_hii_config_access_protocol efi_hii_config_access;
 extern const struct efi_hii_database_protocol efi_hii_database;
 extern const struct efi_hii_string_protocol efi_hii_string;
+/* structure for EFI_DEBUG_SUPPORT_PROTOCOL */
+extern struct efi_debug_image_info_table_header efi_m_debug_info_table_header;
 
 uint16_t *efi_dp_str(struct efi_device_path *dp);
 
lib/efi_loader/efi_setup.c +17 -0
index a6b37d994f6..e949100593f 100644
@@ -18,6 +18,15 @@
 
 efi_status_t efi_obj_list_initialized = OBJ_LIST_NOT_INITIALIZED;
 
+struct efi_debug_image_info_table_header efi_m_debug_info_table_header = {
+	0,
+	0,
+	NULL
+};
+
+const efi_guid_t efi_debug_image_info_table_guid =
+	EFI_DEBUG_IMAGE_INFO_TABLE_GUID;
+
 /*
  * Allow unaligned memory access.
  *
@@ -280,10 +289,18 @@ efi_status_t efi_init_obj_list(void)
 
 	/* Initialize system table pointer */
 	if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+		efi_guid_t debug_image_info_table_guid =
+			efi_debug_image_info_table_guid;
 		ret = efi_initialize_system_table_pointer();
 		if (ret != EFI_SUCCESS) {
 			goto out;
 		}
+
+		ret = efi_install_configuration_table(&debug_image_info_table_guid,
+						      &efi_m_debug_info_table_header);
+		if (ret != EFI_SUCCESS) {
+			goto out;
+		}
 	}
 
 	if (IS_ENABLED(CONFIG_EFI_ECPT)) {
Signature · 1 line
2.39.5
#6 lore raw

PATCH v3 3/4 lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory

In reply to Ying-Chun Liu (PaulLiu)

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

Add efi_realloc() for realloc memory that previously alloc by efi_alloc().

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>
---
 include/efi_loader.h        |  2 ++
 lib/efi_loader/efi_memory.c | 52 +++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
include/efi_loader.h +2 -0
index d0c72d0bc58..ff7ca5a0480 100644
@@ -878,6 +878,8 @@ efi_status_t efi_next_variable_name(efi_uintn_t *size, u16 **buf,
 #define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT)
 /* Allocate boot service data pool memory */
 void *efi_alloc(size_t len);
+/* Reallocate boot service data pool memory */
+void *efi_realloc(void *ptr, size_t len);
 /* Allocate pages on the specified alignment */
 void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align);
 /* More specific EFI memory allocator, called by EFI payloads */
lib/efi_loader/efi_memory.c +52 -0

58 lines not on this page · raw message

Signature · 1 line
2.39.5
#7 lore raw

Re: [PATCH v3 3/4] lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory

Hi,

Quoted 34 lines · Ying-Chun Liu (PaulLiu)

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

Add efi_realloc() for realloc memory that previously alloc by efi_alloc().

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>
---
 include/efi_loader.h        |  2 ++
 lib/efi_loader/efi_memory.c | 52 +++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
include/efi_loader.h +2 -0
index d0c72d0bc58..ff7ca5a0480 100644
@@ -878,6 +878,8 @@ efi_status_t efi_next_variable_name(efi_uintn_t *size, u16 **buf,
 #define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT)
 /* Allocate boot service data pool memory */
 void *efi_alloc(size_t len);
+/* Reallocate boot service data pool memory */
+void *efi_realloc(void *ptr, size_t len);
 /* Allocate pages on the specified alignment */
 void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align);
 /* More specific EFI memory allocator, called by EFI payloads */
lib/efi_loader/efi_memory.c +0 -0
index 0abb1f6159a..4c76df642dc 100644
@@ -666,6 +666,58 @@ void *efi_alloc(size_t size)
        return buf;
 }

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size) · line 677

Quoted 10 lines
lib/efi_loader/efi_memory.c +9 -0
 
+/**
+ * efi_realloc() - reallocate boot services data pool memory
+ *
+ * Reallocate memory from pool for a new size and copy the data from old one.
+ *
+ * @ptr:       pointer to old buffer
+ * @size:      number of bytes to allocate
+ * Return:     pointer to allocated memory or NULL
+ */

Should go in header file

Quoted 47 lines
lib/efi_loader/efi_memory.c +43 -1
+void *efi_realloc(void *ptr, size_t size)
+{
+       efi_status_t ret;
+       void *new_ptr;
+       struct efi_pool_allocation *alloc;
+       u64 num_pages = efi_size_in_pages(size +
+                                         sizeof(struct efi_pool_allocation));
+       size_t old_size;
+
+       if (!ptr)
+               return efi_alloc(size);
+
+       ret = efi_check_allocated((uintptr_t)ptr, true);
+       if (ret != EFI_SUCCESS)
+               return ptr;
+
+       alloc = container_of(ptr, struct efi_pool_allocation, data);
+
+       /* Check that this memory was allocated by efi_allocate_pool() */
+       if (((uintptr_t)alloc & EFI_PAGE_MASK) ||
+           alloc->checksum != checksum(alloc)) {
+               printf("%s: illegal realloc 0x%p\n", __func__, ptr);
+               return ptr;
+       }
+
+       /* Don't realloc. The actual size in pages is the same. */
+       if (alloc->num_pages == num_pages)
+               return ptr;
+
+       old_size = alloc->num_pages * EFI_PAGE_SIZE -
+               sizeof(struct efi_pool_allocation);
+
+       new_ptr = efi_alloc(size);
+
+       /* copy old data to new alloced buffer */
+       memcpy(new_ptr, ptr, min(size, old_size));
+
+       /* free the old buffer */
+       efi_free_pool(ptr);
+
+       return new_ptr;
+}
+
 /**
  * efi_free_pool() - free memory from pool
  *
--
Quoted 2 lines

2.39.5

Could you add a bit of detail as to why this patch is needed? It is hard to tell which code will actually use it. So long as it cannot be used outside lib/efi_loader then it should be OK.

I would like to remove most/all use of efi_alloc() so that the EFI app can use the standard U-Boot malloc(). I am not 100% sure about this, but so far it seems like the best way to support EFI booting from the EFI app.

So if this patch is accepted, it may make it harder to reconcile memory allocation in U-Boot across EFI loader and app.

Regards,
Simon

#8 lore raw

Re: [PATCH v3 3/4] lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory

Hi Simon,

Quoted 47 lines · Simon Glass

Hi,

Quoted 4 lines · Ying-Chun Liu (PaulLiu)

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

Add efi_realloc() for realloc memory that previously alloc by

efi_alloc().

include/efi_loader.h efi_status_t efi_next_variable_name(efi_uintn_t

Quoted 15 lines
Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>
---
 include/efi_loader.h        |  2 ++
 lib/efi_loader/efi_memory.c | 52 +++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
include/efi_loader.h +0 -0
index d0c72d0bc58..ff7ca5a0480 100644
@@ -878,6 +878,8 @@ efi_status_t efi_next_variable_name(efi_uintn_t

*size, u16 **buf,

include/efi_loader.h efi_status_t efi_next_variable_name(efi_uintn_t · line 878

Quoted 1 line
include/efi_loader.h +0 -0
 #define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >>

EFI_PAGE_SHIFT)

Quoted 12 lines
include/efi_loader.h +2 -0
 /* Allocate boot service data pool memory */
 void *efi_alloc(size_t len);
+/* Reallocate boot service data pool memory */
+void *efi_realloc(void *ptr, size_t len);
 /* Allocate pages on the specified alignment */
 void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align);
 /* More specific EFI memory allocator, called by EFI payloads */
lib/efi_loader/efi_memory.c +0 -0
index 0abb1f6159a..4c76df642dc 100644

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size) · line 672

Quoted 7 lines
lib/efi_loader/efi_memory.c +4 -0
@@ -666,6 +666,58 @@ void *efi_alloc(size_t size)
        return buf;
 }
 
+/**
+ * efi_realloc() - reallocate boot services data pool memory
+ *
+ * Reallocate memory from pool for a new size and copy the data from

old one.

Quoted 9 lines

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size) · line 677

Quoted 5 lines
lib/efi_loader/efi_memory.c +5 -0
+ *
+ * @ptr:       pointer to old buffer
+ * @size:      number of bytes to allocate
+ * Return:     pointer to allocated memory or NULL
+ */

Should go in header file

I'll move it to the header file.

Quoted 55 lines

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size)

Quoted 7 lines
lib/efi_loader/efi_memory.c +7 -0
+void *efi_realloc(void *ptr, size_t size)
+{
+       efi_status_t ret;
+       void *new_ptr;
+       struct efi_pool_allocation *alloc;
+       u64 num_pages = efi_size_in_pages(size +
+                                         sizeof(struct

efi_pool_allocation));

Quoted 40 lines
lib/efi_loader/efi_memory.c +36 -1
+       size_t old_size;
+
+       if (!ptr)
+               return efi_alloc(size);
+
+       ret = efi_check_allocated((uintptr_t)ptr, true);
+       if (ret != EFI_SUCCESS)
+               return ptr;
+
+       alloc = container_of(ptr, struct efi_pool_allocation, data);
+
+       /* Check that this memory was allocated by efi_allocate_pool() */
+       if (((uintptr_t)alloc & EFI_PAGE_MASK) ||
+           alloc->checksum != checksum(alloc)) {
+               printf("%s: illegal realloc 0x%p\n", __func__, ptr);
+               return ptr;
+       }
+
+       /* Don't realloc. The actual size in pages is the same. */
+       if (alloc->num_pages == num_pages)
+               return ptr;
+
+       old_size = alloc->num_pages * EFI_PAGE_SIZE -
+               sizeof(struct efi_pool_allocation);
+
+       new_ptr = efi_alloc(size);
+
+       /* copy old data to new alloced buffer */
+       memcpy(new_ptr, ptr, min(size, old_size));
+
+       /* free the old buffer */
+       efi_free_pool(ptr);
+
+       return new_ptr;
+}
+
 /**
  * efi_free_pool() - free memory from pool
  *
--
Quoted 2 lines

2.39.5

Could you add a bit of detail as to why this patch is needed? It is hard to tell which code will actually use it. So long as it cannot be used outside lib/efi_loader then it should be OK.

Quoted 9 lines

I would like to remove most/all use of efi_alloc() so that the EFI app can use the standard U-Boot malloc(). I am not 100% sure about this, but so far it seems like the best way to support EFI booting from the EFI app.

So if this patch is accepted, it may make it harder to reconcile memory allocation in U-Boot across EFI loader and app.

This function is just like calloc(). Currently we can only use efi_alloc() and manually memcpy the data to the new place if we want to enlarge an allocation.
So if we want to remove efi_alloc and replace it by malloc(). I think we can also just replace efi_calloc() with calloc().

Yours,
Paul

Quoted 3 lines

Regards,
Simon

#9 lore raw

Re: [PATCH v3 3/4] lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory

In reply to Simon Glass
Quoted 47 lines · Simon Glass

Hi,

Quoted 4 lines · Ying-Chun Liu (PaulLiu)

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

Add efi_realloc() for realloc memory that previously alloc by

efi_alloc().

include/efi_loader.h efi_status_t efi_next_variable_name(efi_uintn_t

Quoted 15 lines
Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>
---
 include/efi_loader.h        |  2 ++
 lib/efi_loader/efi_memory.c | 52 +++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
include/efi_loader.h +0 -0
index d0c72d0bc58..ff7ca5a0480 100644
@@ -878,6 +878,8 @@ efi_status_t efi_next_variable_name(efi_uintn_t

*size, u16 **buf,

include/efi_loader.h efi_status_t efi_next_variable_name(efi_uintn_t · line 878

Quoted 1 line
include/efi_loader.h +0 -0
 #define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >>

EFI_PAGE_SHIFT)

Quoted 12 lines
include/efi_loader.h +2 -0
 /* Allocate boot service data pool memory */
 void *efi_alloc(size_t len);
+/* Reallocate boot service data pool memory */
+void *efi_realloc(void *ptr, size_t len);
 /* Allocate pages on the specified alignment */
 void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align);
 /* More specific EFI memory allocator, called by EFI payloads */
lib/efi_loader/efi_memory.c +0 -0
index 0abb1f6159a..4c76df642dc 100644

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size) · line 672

Quoted 7 lines
lib/efi_loader/efi_memory.c +4 -0
@@ -666,6 +666,58 @@ void *efi_alloc(size_t size)
        return buf;
 }
 
+/**
+ * efi_realloc() - reallocate boot services data pool memory
+ *
+ * Reallocate memory from pool for a new size and copy the data from

old one.

Quoted 8 lines

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size) · line 677

Quoted 5 lines
lib/efi_loader/efi_memory.c +5 -0
+ *
+ * @ptr:       pointer to old buffer
+ * @size:      number of bytes to allocate
+ * Return:     pointer to allocated memory or NULL
+ */

Should go in header file

Hi Simon,

I look into the code. It seems other functions in the same .c file put the comments in the .c file instead of the header file.
Should I move the comments to the header file? I'm a bit confused.

Yours,
Paul

Quoted 67 lines

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size)

Quoted 8 lines
lib/efi_loader/efi_memory.c +7 -0
+void *efi_realloc(void *ptr, size_t size)
+{
+       efi_status_t ret;
+       void *new_ptr;
+       struct efi_pool_allocation *alloc;
+       u64 num_pages = efi_size_in_pages(size +
+                                         sizeof(struct

efi_pool_allocation));

Quoted 40 lines
lib/efi_loader/efi_memory.c +36 -1
+       size_t old_size;
+
+       if (!ptr)
+               return efi_alloc(size);
+
+       ret = efi_check_allocated((uintptr_t)ptr, true);
+       if (ret != EFI_SUCCESS)
+               return ptr;
+
+       alloc = container_of(ptr, struct efi_pool_allocation, data);
+
+       /* Check that this memory was allocated by efi_allocate_pool() */
+       if (((uintptr_t)alloc & EFI_PAGE_MASK) ||
+           alloc->checksum != checksum(alloc)) {
+               printf("%s: illegal realloc 0x%p\n", __func__, ptr);
+               return ptr;
+       }
+
+       /* Don't realloc. The actual size in pages is the same. */
+       if (alloc->num_pages == num_pages)
+               return ptr;
+
+       old_size = alloc->num_pages * EFI_PAGE_SIZE -
+               sizeof(struct efi_pool_allocation);
+
+       new_ptr = efi_alloc(size);
+
+       /* copy old data to new alloced buffer */
+       memcpy(new_ptr, ptr, min(size, old_size));
+
+       /* free the old buffer */
+       efi_free_pool(ptr);
+
+       return new_ptr;
+}
+
 /**
  * efi_free_pool() - free memory from pool
  *
--
Quoted 2 lines

2.39.5

Could you add a bit of detail as to why this patch is needed? It is hard to tell which code will actually use it. So long as it cannot be used outside lib/efi_loader then it should be OK.

I would like to remove most/all use of efi_alloc() so that the EFI app can use the standard U-Boot malloc(). I am not 100% sure about this, but so far it seems like the best way to support EFI booting from the EFI app.

So if this patch is accepted, it may make it harder to reconcile memory allocation in U-Boot across EFI loader and app.

Regards,
Simon

#10 lore raw

Re: [PATCH v3 3/4] lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory

Hi Paul,

Quoted 57 lines · Paul Liu
Quoted 40 lines · Simon Glass

Hi,

Quoted 35 lines · Ying-Chun Liu (PaulLiu)

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

Add efi_realloc() for realloc memory that previously alloc by efi_alloc().

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>
---
 include/efi_loader.h        |  2 ++
 lib/efi_loader/efi_memory.c | 52 +++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
include/efi_loader.h +2 -0
index d0c72d0bc58..ff7ca5a0480 100644
@@ -878,6 +878,8 @@ efi_status_t efi_next_variable_name(efi_uintn_t *size, u16 **buf,
 #define efi_size_in_pages(size) (((size) + EFI_PAGE_MASK) >> EFI_PAGE_SHIFT)
 /* Allocate boot service data pool memory */
 void *efi_alloc(size_t len);
+/* Reallocate boot service data pool memory */
+void *efi_realloc(void *ptr, size_t len);
 /* Allocate pages on the specified alignment */
 void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align);
 /* More specific EFI memory allocator, called by EFI payloads */
lib/efi_loader/efi_memory.c +0 -0
index 0abb1f6159a..4c76df642dc 100644
@@ -666,6 +666,58 @@ void *efi_alloc(size_t size)
        return buf;
 }
 
Quoted 11 lines

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size) · line 677

Quoted 9 lines
lib/efi_loader/efi_memory.c +9 -0
+/**
+ * efi_realloc() - reallocate boot services data pool memory
+ *
+ * Reallocate memory from pool for a new size and copy the data from old one.
+ *
+ * @ptr:       pointer to old buffer
+ * @size:      number of bytes to allocate
+ * Return:     pointer to allocated memory or NULL
+ */

Should go in header file

Quoted 4 lines

Hi Simon,

I look into the code. It seems other functions in the same .c file put the comments in the .c file instead of the header file. Should I move the comments to the header file? I'm a bit confused.

Normally we use the header file for exported functions and comments. Sometimes people don't like to convert everything, as I did with [1], for example. So a middle path is to just make sure you add new exported functions in the header file.

Regards,
SImon

[1] https://patchwork.ozlabs.org/project/uboot/patch/[email protected]/

#11 lore raw

Re: [PATCH v3 3/4] lib: efi_loader: efi_memory.c: add efi_realloc() for realloc memory

In reply to Ying-Chun Liu (PaulLiu)

Hi Paul,

[...]

Quoted 13 lines

+ * efi_realloc() - reallocate boot services data pool memory
+ *
+ * Reallocate memory from pool for a new size and copy the data from old one.
+ *

+ * @ptr:       pointer to old buffer
+ * @size:      number of bytes to allocate
+ * Return:     pointer to allocated memory or NULL

+ */

lib/efi_loader/efi_memory.c +5 -0
+void *efi_realloc(void *ptr, size_t size)
+{
+       efi_status_t ret;
+       void *new_ptr;
+       struct efi_pool_allocation *alloc;

lib/efi_loader/efi_memory.c void *efi_alloc(size_t size) · line 692

Quoted 10 lines
lib/efi_loader/efi_memory.c +10 -0
+       u64 num_pages = efi_size_in_pages(size +
+                                         sizeof(struct efi_pool_allocation));
+       size_t old_size;
+
+       if (!ptr)
+               return efi_alloc(size);
+
+       ret = efi_check_allocated((uintptr_t)ptr, true);
+       if (ret != EFI_SUCCESS)
+               return ptr;

This is a bit weird here. If we return a pointer how can we tell success vs failure?
I think we should return EFI/SUCCESS fail and just pass a **ptr as an argument?

Thanks
/Ilias

Quoted 34 lines
lib/efi_loader/efi_memory.c +28 -1
+
+       alloc = container_of(ptr, struct efi_pool_allocation, data);
+
+       /* Check that this memory was allocated by efi_allocate_pool() */
+       if (((uintptr_t)alloc & EFI_PAGE_MASK) ||
+           alloc->checksum != checksum(alloc)) {
+               printf("%s: illegal realloc 0x%p\n", __func__, ptr);
+               return ptr;
+       }
+
+       /* Don't realloc. The actual size in pages is the same. */
+       if (alloc->num_pages == num_pages)
+               return ptr;
+
+       old_size = alloc->num_pages * EFI_PAGE_SIZE -
+               sizeof(struct efi_pool_allocation);
+
+       new_ptr = efi_alloc(size);
+
+       /* copy old data to new alloced buffer */
+       memcpy(new_ptr, ptr, min(size, old_size));
+
+       /* free the old buffer */
+       efi_free_pool(ptr);
+
+       return new_ptr;
+}
+
 /**
  * efi_free_pool() - free memory from pool
  *
--

2.39.5

#12 lore raw

PATCH v3 4/4 efi: add EFI_DEBUG_IMAGE_INFO for debug

In reply to Ying-Chun Liu (PaulLiu)

From: "Ying-Chun Liu (PaulLiu)" <[email protected]>

This commit adds the functionality of generate EFI_DEBUG_IMAGE_INFO while loading the image.

This feature is described in UEFI Spec 2.10. Section 18.4.3. The implementation ensures support for hardware-assisted debugging and provides a standardized mechanism for debuggers to discover the load address of an EFI application.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
Cc Peter Robinson <[email protected]>

---
V2: use Kconfig options to turn on/off this feature.
V3: Use efi_realloc to realloc the tables. Move tables to boot time.

---
 include/efi_api.h             |   2 +
 include/efi_loader.h          |   5 ++
 lib/efi_loader/efi_boottime.c | 142 ++++++++++++++++++++++++++++++++++
 3 files changed, 149 insertions(+)
include/efi_api.h +2 -0
index 8da0a350ce3..77a05f752e5 100644
@@ -581,6 +581,8 @@ struct efi_loaded_image {
 #define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01
 #define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED     0x02
 
+#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL  0x01
+
 /**
  * struct efi_debug_image_info_normal - Store Debug Information for normal
  * image.
include/efi_loader.h +5 -0
index ff7ca5a0480..649bfc36f22 100644
@@ -650,6 +650,11 @@ efi_status_t efi_root_node_register(void);
 efi_status_t efi_initialize_system_table(void);
 /* Called by bootefi to initialize debug */
 efi_status_t efi_initialize_system_table_pointer(void);
+/* Called by efi_load_image for register debug info */
+efi_status_t efi_core_new_debug_image_info_entry(u32 image_info_type,
+						 struct efi_loaded_image *loaded_image,
+						 efi_handle_t image_handle);
+void efi_core_remove_debug_image_info_entry(efi_handle_t image_handle);
 /* efi_runtime_detach() - detach unimplemented runtime functions */
 void efi_runtime_detach(void);
 /* efi_convert_pointer() - convert pointer to virtual address */
lib/efi_loader/efi_boottime.c +142 -0

163 lines not on this page · raw message

Signature · 1 line
2.39.5