Skip to contentSkip to conversation

efi: Add EFI Debug Support Table feature

PATCH Superseded Ying-Chun Liu (PaulLiu) 3 participants 12 messages Apr 24, 2025 – Apr 25, 2025

v2 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v2 cover efi: 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.

Ying-Chun Liu (PaulLiu) (3):
efi: add EFI_SYSTEM_TABLE_POINTER for debug
efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug
efi: add EFI_DEBUG_IMAGE_INFO for debug

 include/efi_api.h             |  32 ++++++
 include/efi_loader.h          |   7 ++
 lib/efi_loader/Kconfig        |   7 ++
 lib/efi_loader/efi_boottime.c | 200 ++++++++++++++++++++++++++++++++++
 lib/efi_loader/efi_setup.c    |   9 ++
 5 files changed, 255 insertions(+)
Signature · 1 line
2.39.5
#1 lore raw

PATCH v2 1/3 efi: add EFI_SYSTEM_TABLE_POINTER for debug

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

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

This feature is described in UEFI SPEC version 2.10. Section 18.4.2.

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

---
V2: add Kconfig options to turn on/off this feature.

---
 include/efi_api.h             |  6 +++++
 include/efi_loader.h          |  2 ++
 lib/efi_loader/Kconfig        |  7 ++++++
 lib/efi_loader/efi_boottime.c | 44 +++++++++++++++++++++++++++++++++++
 lib/efi_loader/efi_setup.c    |  9 +++++++
 5 files changed, 68 insertions(+)
include/efi_api.h +6 -0
index eb61eafa028..5017d9037cd 100644
@@ -259,6 +259,12 @@ struct efi_capsule_result_variable_header {
 	efi_status_t capsule_status;
 } __packed;
 
+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 1d75d97ebbc..370bc042f70 100644
@@ -615,6 +615,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 d4f6b56afaa..94a75981389 100644
@@ -70,6 +70,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 +44 -0

53 lines not on this page · raw message

lib/efi_loader/efi_setup.c +9 -0
index aa59bc7779d..6be23ca43bf 100644
@@ -259,6 +259,15 @@ efi_status_t efi_init_obj_list(void)
 	if (ret != EFI_SUCCESS)
 		goto out;
 
+	/* Initialize system table */
+	if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+		ret = efi_initialize_system_table_pointer();
+		if (ret != EFI_SUCCESS) {
+			printf("EFI init system table pointer fail\n");
+			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 v2 1/3] efi: add EFI_SYSTEM_TABLE_POINTER for debug

Quoted 6 lines · Ying-Chun Liu (PaulLiu)

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

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

This feature is described in UEFI SPEC version 2.10. Section 18.4.2.

Hello Ying-Chun,

Thank you for your contribution.

Unfortunately it is not clear what your use case is. The reason for implementing a feature should be mentioned in the commit message. Cover-letters for a patch series are the right place to describe overarching topics.

The relevant information needed to debug U-Boot is the u-boot.map file and the relocation address. On arm64 the relocation address can be found via the global data structure pointed to by register x18.

Once you have the relocation offset, you can determine the system table address via the u-boot.map file.

If you need information about loaded EFI images, you could enable debug messages using U-Boot's log command.

Quoted 76 lines
Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>

---
V2: add Kconfig options to turn on/off this feature.

---
  include/efi_api.h             |  6 +++++
  include/efi_loader.h          |  2 ++
  lib/efi_loader/Kconfig        |  7 ++++++
  lib/efi_loader/efi_boottime.c | 44 +++++++++++++++++++++++++++++++++++
  lib/efi_loader/efi_setup.c    |  9 +++++++
  5 files changed, 68 insertions(+)
include/efi_api.h +6 -0
index eb61eafa028..5017d9037cd 100644
@@ -259,6 +259,12 @@ struct efi_capsule_result_variable_header {
  	efi_status_t capsule_status;
  } __packed;
 
+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 1d75d97ebbc..370bc042f70 100644
@@ -615,6 +615,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 d4f6b56afaa..94a75981389 100644
@@ -70,6 +70,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 +2 -0
index 5164cb15986..366bc0d2b1d 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
   *

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

Quoted 10 lines
lib/efi_loader/efi_boottime.c +7 -0
@@ -4035,3 +4037,45 @@ efi_status_t efi_initialize_system_table(void)
 
  	return ret;
  }
+
+/**
+ * efi_initialize_system_table() - Initialize system table
+ *
+ * Return:	status code
+ */
+efi_status_t efi_initialize_system_table_pointer(void)

This function name seems to be a misnomer as you are setting up much more with the next patches.

Quoted 16 lines
lib/efi_loader/efi_boottime.c +16 -0
+{
+	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,
+				 real_pages,
+				 &addr);
+

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

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+	/* 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));
+
+	/*
+	 * These entries will be set to NULL in ExitBootServices(). To avoid
+	 * relocation in SetVirtualAddressMap(), set them dynamically.
+	 */

This comment does not match the submitted code.

Quoted 14 lines
lib/efi_loader/efi_boottime.c +9 -0
+	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 +0 -0
index aa59bc7779d..6be23ca43bf 100644

lib/efi_loader/efi_setup.c efi_status_t efi_init_obj_list(void) · line 266

Quoted 8 lines
lib/efi_loader/efi_setup.c +5 -0
@@ -259,6 +259,15 @@ efi_status_t efi_init_obj_list(void)
  	if (ret != EFI_SUCCESS)
  		goto out;
 
+	/* Initialize system table */
+	if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+		ret = efi_initialize_system_table_pointer();
+		if (ret != EFI_SUCCESS) {
+			printf("EFI init system table pointer fail\n");

Maybe: "Installing EFI system table pointer failed\n".

Please, use log_error() and move the output to the appropriate place in the efi_initialize_system_table_pointer() function.

Best regards

Heinrich

Quoted 7 lines
lib/efi_loader/efi_setup.c +4 -0
+			goto out;
+		}
+	}
+
  	if (IS_ENABLED(CONFIG_EFI_ECPT)) {
  		ret = efi_ecpt_register();
  		if (ret != EFI_SUCCESS)
#3 lore raw

Re: [PATCH v2 1/3] efi: add EFI_SYSTEM_TABLE_POINTER for debug

Hi Heinrich,

Thanks for the review.

Quoted 8 lines · Heinrich Schuchardt
Quoted 6 lines · Ying-Chun Liu (PaulLiu)

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

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

This feature is described in UEFI SPEC version 2.10. Section 18.4.2.

Quoted 9 lines

Hello Ying-Chun,

Thank you for your contribution.

Unfortunately it is not clear what your use case is. The reason for implementing a feature should be mentioned in the commit message. Cover-letters for a patch series are the right place to describe overarching topics.

I'll enhance the commit message in next version.

Quoted 6 lines

The relevant information needed to debug U-Boot is the u-boot.map file and the relocation address. On arm64 the relocation address can be found via the global data structure pointed to by register x18.

Yes. Previously we use
p/x (*(struct global_data*)\$x18)->relocaddr
add-symbol-file <Symbols.deug> $1
For loading the debug symbols for U-boot.

Quoted 7 lines

Once you have the relocation offset, you can determine the system table address via the u-boot.map file.

If you need information about loaded EFI images, you could enable debug messages using U-Boot's log command.

The idea here is to provide another way to get the information about the loaded EFI images.
So that we can have an easier way to start debugging the EFI applications.

I think for both EDK2 and U-boot, we can get the information through debug messages.
EDK2 also outputs debug messages through IO port 0x402 on X86. So the developers can get information there.

But let's assume that our environment is just an ARM board. With hardware JTAG connects to it.
So through the JTAG, gdb can read the memory. And can stop program running at a place.
And through this implementation, we can use some python extensions to directly get the information of the EFI applications for debug. First, the extension will look for this SystemTablePointer structure through the memory address.
And then we can get information about the EFI applications. There is already a python gdb extension in EDK2.
1.
https://github.com/tianocore/edk2/blob/master/BaseTools/Scripts/efi_debugging.py
2.
https://github.com/tianocore/edk2/blob/master/BaseTools/Scripts/efi_gdb.py
And we implemented the missing parts through this PR.
https://github.com/tianocore/edk2/pull/10980

I've also implemented a gdb python extension by reusing the efi_debugging.py in EDK2.
https://paste.debian.net/hidden/c3122c5b/

By this way it makes things a bit easier. So that we don't need to load U-boot debug symbols. Don't need debug logs.
Just the EFI application and its debug symbols are needed. And then we can start debugging on the real hardware.

Quoted 80 lines

Review

Quoted 63 lines
Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>

---
V2: add Kconfig options to turn on/off this feature.

---
  include/efi_api.h             |  6 +++++
  include/efi_loader.h          |  2 ++
  lib/efi_loader/Kconfig        |  7 ++++++
  lib/efi_loader/efi_boottime.c | 44 +++++++++++++++++++++++++++++++++++
  lib/efi_loader/efi_setup.c    |  9 +++++++
  5 files changed, 68 insertions(+)
include/efi_api.h +6 -0
index eb61eafa028..5017d9037cd 100644
@@ -259,6 +259,12 @@ struct efi_capsule_result_variable_header {
      efi_status_t capsule_status;
  } __packed;
 
+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 1d75d97ebbc..370bc042f70 100644
@@ -615,6 +615,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 d4f6b56afaa..94a75981389 100644
@@ -70,6 +70,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
(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 5164cb15986..366bc0d2b1d 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 6 lines
lib/efi_loader/efi_boottime.c +1 -0
+
  /**
   * efi_initialize_system_table() - Initialize system table
   *
@@ -4035,3 +4037,45 @@ efi_status_t efi_initialize_system_table(void)
 
Quoted 13 lines

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

Quoted 9 lines
lib/efi_loader/efi_boottime.c +7 -0
      return ret;
  }
+
+/**
+ * efi_initialize_system_table() - Initialize system table
+ *
+ * Return:   status code
+ */
+efi_status_t efi_initialize_system_table_pointer(void)

This function name seems to be a misnomer as you are setting up much more with the next patches.

I will fix this in the next version.
Plan to separate it into two functions. One for the system_table_pointer. Another for the configuration table.

Quoted 27 lines

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

Quoted 5 lines
lib/efi_loader/efi_boottime.c +4 -0
+{
+     efi_status_t ret;
+     const int size_4MB = 0x00400000;
+     int pages = efi_size_in_pages(sizeof(struct

efi_system_table_pointer));

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -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,

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

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+                              &addr);
+
+     /* 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));
+
+     /*
+      * These entries will be set to NULL in ExitBootServices(). To

avoid

Quoted 6 lines

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

Quoted 2 lines
lib/efi_loader/efi_boottime.c +2 -0
+      * relocation in SetVirtualAddressMap(), set them dynamically.
+      */

This comment does not match the submitted code.

Will fix this in the next version.

Quoted 26 lines

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

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

(efi_physical_addr_t)&systab;

Quoted 12 lines
lib/efi_loader/efi_boottime.c +7 -0
+     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 +0 -0
index aa59bc7779d..6be23ca43bf 100644

lib/efi_loader/efi_setup.c efi_status_t efi_init_obj_list(void) · line 266

Quoted 8 lines
lib/efi_loader/efi_setup.c +5 -0
@@ -259,6 +259,15 @@ efi_status_t efi_init_obj_list(void)
      if (ret != EFI_SUCCESS)
              goto out;
 
+     /* Initialize system table */
+     if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+             ret = efi_initialize_system_table_pointer();
+             if (ret != EFI_SUCCESS) {
+                     printf("EFI init system table pointer fail\n");

Maybe: "Installing EFI system table pointer failed\n".

Quoted 4 lines

Please, use log_error() and move the output to the appropriate place in the efi_initialize_system_table_pointer() function.

Will fix it in the next version.

Quoted 13 lines

Best regards

Heinrich

Quoted 7 lines
lib/efi_loader/efi_setup.c +4 -0
+                     goto out;
+             }
+     }
+
      if (IS_ENABLED(CONFIG_EFI_ECPT)) {
              ret = efi_ecpt_register();
              if (ret != EFI_SUCCESS)

Thanks a lot.

Yours,
Paul

#4 lore raw

PATCH v2 2/3 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.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
---
 include/efi_api.h             | 24 ++++++++++++++++++++++++
 lib/efi_loader/efi_boottime.c | 16 ++++++++++++++++
 2 files changed, 40 insertions(+)
include/efi_api.h +24 -0
index 5017d9037cd..0f4245091f1 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;
@@ -564,6 +568,26 @@ 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 {
+	u32 image_info_type;
+	struct efi_loaded_image *loaded_image_protocol_instance;
+	efi_handle_t image_handle;
+};
+
+union efi_debug_image_info {
+	u32 *image_info_type;
+	struct efi_debug_image_info_normal *normal_image;
+};
+
+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)
lib/efi_loader/efi_boottime.c +16 -0
index 366bc0d2b1d..e2665459e44 100644
@@ -4038,6 +4038,16 @@ efi_status_t efi_initialize_system_table(void)
 	return ret;
 }
 
+struct efi_debug_image_info_table_header __efi_runtime_data
+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;
+
 /**
  * efi_initialize_system_table() - Initialize system table
  *
@@ -4053,6 +4063,8 @@ efi_status_t efi_initialize_system_table_pointer(void)
 	u64 addr;
 	u64 aligned_addr;
 	u32 crc32_value;
+	efi_guid_t debug_image_info_table_guid =
+		efi_debug_image_info_table_guid;
 
 	/* Allocate configuration table array */
 	ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
@@ -4077,5 +4089,9 @@ efi_status_t efi_initialize_system_table_pointer(void)
 			    (const unsigned char *)systab_pointer,
 			    sizeof(struct efi_system_table_pointer));
 	systab_pointer->crc32 = crc32_value;
+
+	ret = efi_install_configuration_table(&debug_image_info_table_guid,
+					      &efi_m_debug_info_table_header);
+
 	return ret;
 }
Signature · 1 line
2.39.5
#5 lore raw

Re: [PATCH v2 2/3] efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug

Quoted 31 lines · 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.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
---
  include/efi_api.h             | 24 ++++++++++++++++++++++++
  lib/efi_loader/efi_boottime.c | 16 ++++++++++++++++
  2 files changed, 40 insertions(+)
include/efi_api.h +4 -0
index 5017d9037cd..0f4245091f1 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;

include/efi_api.h struct efi_loaded_image { · line 573

Quoted 6 lines
include/efi_api.h +3 -0
@@ -564,6 +568,26 @@ 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
+

All structures and unions and their elements should be describe according to
https://docs.kernel.org/doc-guide/kernel-doc.html#structure-union-and-enumeration-documentation

include/efi_api.h struct efi_loaded_image { · line 578

Quoted 5 lines
include/efi_api.h +5 -0
+struct efi_debug_image_info_normal {
+	u32 image_info_type;
+	struct efi_loaded_image *loaded_image_protocol_instance;
+	efi_handle_t image_handle;
+};

What are the assumptions about alignment?
Should this structure be marked as packed like most UEFI structures?

include/efi_api.h struct efi_loaded_image { · line 580

Quoted 2 lines
include/efi_api.h +2 -0
+
+union efi_debug_image_info {

Why do we need the union? The first field of struct efi_debug_image_info_normal is image_info_type.

include/efi_api.h struct efi_loaded_image { · line 586

Quoted 6 lines
include/efi_api.h +6 -0
+	u32 *image_info_type;
+	struct efi_debug_image_info_normal *normal_image;
+};
+
+struct efi_debug_image_info_table_header {
+	volatile u32 update_status;

Why is volatile needed here?

Best regards

Heinrich

Quoted 53 lines
include/efi_api.h +4 -0
+	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)
lib/efi_loader/efi_boottime.c +16 -0
index 366bc0d2b1d..e2665459e44 100644
@@ -4038,6 +4038,16 @@ efi_status_t efi_initialize_system_table(void)
  	return ret;
  }
 
 
 
 
+struct efi_debug_image_info_table_header __efi_runtime_data
 
 
 
+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;
+
  /**
   * efi_initialize_system_table() - Initialize system table
   *
@@ -4053,6 +4063,8 @@ efi_status_t efi_initialize_system_table_pointer(void)
  	u64 addr;
  	u64 aligned_addr;
  	u32 crc32_value;
+	efi_guid_t debug_image_info_table_guid =
+		efi_debug_image_info_table_guid;
 
  	/* Allocate configuration table array */
  	ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
@@ -4077,5 +4089,9 @@ efi_status_t efi_initialize_system_table_pointer(void)
  			    (const unsigned char *)systab_pointer,
  			    sizeof(struct efi_system_table_pointer));
  	systab_pointer->crc32 = crc32_value;
+
+	ret = efi_install_configuration_table(&debug_image_info_table_guid,
+					      &efi_m_debug_info_table_header);
+
  	return ret;
  }
#6 lore raw

Re: [PATCH v2 2/3] efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug

Quoted 44 lines · Heinrich Schuchardt
Quoted 31 lines · 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.

Cc Heinrich Schuchardt <[email protected]>
Cc Ilias Apalodimas <[email protected]>
---
  include/efi_api.h             | 24 ++++++++++++++++++++++++
  lib/efi_loader/efi_boottime.c | 16 ++++++++++++++++
  2 files changed, 40 insertions(+)
include/efi_api.h +4 -0
index 5017d9037cd..0f4245091f1 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;

include/efi_api.h struct efi_loaded_image { · line 573

Quoted 6 lines
include/efi_api.h +3 -0
@@ -564,6 +568,26 @@ 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
+

All structures and unions and their elements should be describe according to

https://docs.kernel.org/doc-guide/kernel-doc.html#structure-union-and-enumeration-documentation

Quoted 10 lines

include/efi_api.h struct efi_loaded_image { · line 578

Quoted 5 lines
include/efi_api.h +5 -0
+struct efi_debug_image_info_normal {
+     u32 image_info_type;
+     struct efi_loaded_image *loaded_image_protocol_instance;
+     efi_handle_t image_handle;
+};

What are the assumptions about alignment?
Should this structure be marked as packed like most UEFI structures?

Not aligned. This structure in EDK2 is not aligned, not packed. And it is really not packed because the size of this structure is larger. 4 bytes are padded in the 64-bit environment I think.

Quoted 7 lines

include/efi_api.h struct efi_loaded_image { · line 580

Quoted 2 lines
include/efi_api.h +2 -0
+
+union efi_debug_image_info {

Why do we need the union? The first field of struct efi_debug_image_info_normal is image_info_type.

I just copied it from the EDK2. But we can remove it. I think edk2 wants to support not only normal images. However, currently there is only a normal image.
So it looks redundant.
I will remove this union in the next version.

Quoted 10 lines

include/efi_api.h struct efi_loaded_image { · line 586

Quoted 6 lines
include/efi_api.h +6 -0
+     u32 *image_info_type;
+     struct efi_debug_image_info_normal *normal_image;
+};
+
+struct efi_debug_image_info_table_header {
+     volatile u32 update_status;

Why is volatile needed here?

The volatile is needed because we like the status to be updated immediately to the memory.
If we are using a hardware jtag. And it stops the code at random places at the beginning. It might have paused just inside these logics. So this update_status is to tell the gdb python extensions to not referencing EFI tables because it is not ready yet.
Thus this value cannot be optimized for updating later. And thus the volatile is needed.

Quoted 63 lines

Best regards

Heinrich

Review

Quoted 8 lines
include/efi_api.h +4 -0
+     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)
(quoted diff) +0 -0

b/lib/efi_loader/efi_boottime.c

lib/efi_loader/efi_boottime.c efi_status_t

Quoted 27 lines

index 366bc0d2b1d..e2665459e44 100644

lib/efi_loader/efi_boottime.c +10 -0
@@ -4038,6 +4038,16 @@ efi_status_t efi_initialize_system_table(void)
      return ret;
  }
 
 
 
 
+struct efi_debug_image_info_table_header __efi_runtime_data
 
 
 
+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;
+
  /**
   * efi_initialize_system_table() - Initialize system table
   *
@@ -4053,6 +4063,8 @@ efi_status_t

efi_initialize_system_table_pointer(void)

lib/efi_loader/efi_boottime.c efi_status_t

Quoted 9 lines
lib/efi_loader/efi_boottime.c +2 -0
      u64 addr;
      u64 aligned_addr;
      u32 crc32_value;
+     efi_guid_t debug_image_info_table_guid =
+             efi_debug_image_info_table_guid;
 
      /* Allocate configuration table array */
      ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
@@ -4077,5 +4089,9 @@ efi_status_t

efi_initialize_system_table_pointer(void)

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4095

Quoted 6 lines
lib/efi_loader/efi_boottime.c +3 -0
                          (const unsigned char *)systab_pointer,
                          sizeof(struct efi_system_table_pointer));
      systab_pointer->crc32 = crc32_value;
+
+     ret = efi_install_configuration_table(&debug_image_info_table_guid,
+

&efi_m_debug_info_table_header);

Quoted 3 lines
lib/efi_loader/efi_boottime.c +1 -0
+
      return ret;
  }
#7 lore raw

Re: [PATCH v2 2/3] efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug

Quoted 64 lines · Paul Liu

On Thu, 24 Apr 2025 at 23:02, Heinrich Schuchardt <[email protected] <mailto:[email protected]>> wrote:

    On 24.04.25 22:19, Ying-Chun Liu (PaulLiu) wrote:
     > From: "Ying-Chun Liu (PaulLiu)" <[email protected]
    <mailto:[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.
     >
     > Signed-off-by: Ying-Chun Liu (PaulLiu) <[email protected]
    <mailto:[email protected]>>
     > Cc: Heinrich Schuchardt <[email protected]
    <mailto:[email protected]>>
     > Cc: Ilias Apalodimas <[email protected]
    <mailto:[email protected]>>
     > ---
     >   include/efi_api.h             | 24 ++++++++++++++++++++++++
     >   lib/efi_loader/efi_boottime.c | 16 ++++++++++++++++
     >   2 files changed, 40 insertions(+)
     >
     > diff --git a/include/efi_api.h b/include/efi_api.h
     > index 5017d9037cd..0f4245091f1 100644
     > --- a/include/efi_api.h
     > +++ b/include/efi_api.h
     > @@ -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;
     > @@ -564,6 +568,26 @@ 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
     > +

    All structures and unions and their elements should be describe
    according to
    https://docs.kernel.org/doc-guide/kernel-doc.html#structure-union-
    and-enumeration-documentation <https://docs.kernel.org/doc-guide/
    kernel-doc.html#structure-union-and-enumeration-documentation>

     > +struct efi_debug_image_info_normal {
     > +     u32 image_info_type;
     > +     struct efi_loaded_image *loaded_image_protocol_instance;
     > +     efi_handle_t image_handle;
     > +};

    What are the assumptions about alignment?
    Should this structure be marked as packed like most UEFI structures?
Quoted 1 line

Not aligned. This structure in EDK2 is not aligned, not packed. And it is really not packed because the size of this structure is larger. 4 bytes are padded in the 64-bit environment I think.

All other structures in EDK II are packed. Did you look at the structure in a debugger?

The compiler will assume that a pointer to "struct efi_debug_image_info_normal *" points to a sizeof(uintptr_t) aligned structure if no other indication is made.

Best regards

Heinrich

Quoted 90 lines

> +
> +union efi_debug_image_info {

Why do we need the union? The first field of struct efi_debug_image_info_normal is image_info_type.

I just copied it from the EDK2. But we can remove it. I think edk2 wants to support not only normal images. However, currently there is only a normal image. So it looks redundant.
I will remove this union in the next version.

     > +     u32 *image_info_type;
     > +     struct efi_debug_image_info_normal *normal_image;
     > +};
     > +
     > +struct efi_debug_image_info_table_header {
     > +     volatile u32 update_status;

    Why is volatile needed here?

The volatile is needed because we like the status to be updated immediately to the memory.
If we are using a hardware jtag. And it stops the code at random places at the beginning. It might have paused just inside these logics. So this update_status is to tell the gdb python extensions to not referencing EFI tables because it is not ready yet. Thus this value cannot be optimized for updating later. And thus the volatile is needed.

    Best regards

    Heinrich

     > +     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)
     > diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/
    efi_boottime.c
     > index 366bc0d2b1d..e2665459e44 100644
     > --- a/lib/efi_loader/efi_boottime.c
     > +++ b/lib/efi_loader/efi_boottime.c
     > @@ -4038,6 +4038,16 @@ efi_status_t efi_initialize_system_table(void)
     >       return ret;
     >   }
     >



     > +struct efi_debug_image_info_table_header __efi_runtime_data



     > +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;
     > +
     >   /**
     >    * efi_initialize_system_table() - Initialize system table
     >    *
     > @@ -4053,6 +4063,8 @@ efi_status_t
    efi_initialize_system_table_pointer(void)
     >       u64 addr;
     >       u64 aligned_addr;
     >       u32 crc32_value;
     > +     efi_guid_t debug_image_info_table_guid =
     > +             efi_debug_image_info_table_guid;
     >
     >       /* Allocate configuration table array */
     >       ret = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES,
     > @@ -4077,5 +4089,9 @@ efi_status_t
    efi_initialize_system_table_pointer(void)
     >                           (const unsigned char *)systab_pointer,
     >                           sizeof(struct efi_system_table_pointer));
     >       systab_pointer->crc32 = crc32_value;
     > +
     > +     ret =
    efi_install_configuration_table(&debug_image_info_table_guid,
     > +                                         
      &efi_m_debug_info_table_header);
     > +
     >       return ret;
     >   }
#8 lore raw

Re: [PATCH v2 2/3] efi: add EFI_DEBUG_IMAGE_INFO_TABLE for debug

Quoted 77 lines · Heinrich Schuchardt
Quoted 65 lines · Paul Liu

On Thu, 24 Apr 2025 at 23:02, Heinrich Schuchardt <[email protected] <mailto:[email protected]>> wrote:

    On 24.04.25 22:19, Ying-Chun Liu (PaulLiu) wrote:
     > From: "Ying-Chun Liu (PaulLiu)" <[email protected]
    <mailto:[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.
     >
     > Signed-off-by: Ying-Chun Liu (PaulLiu) <[email protected]
    <mailto:[email protected]>>
     > Cc: Heinrich Schuchardt <[email protected]
    <mailto:[email protected]>>
     > Cc: Ilias Apalodimas <[email protected]
    <mailto:[email protected]>>
     > ---
     >   include/efi_api.h             | 24 ++++++++++++++++++++++++
     >   lib/efi_loader/efi_boottime.c | 16 ++++++++++++++++
     >   2 files changed, 40 insertions(+)
     >
     > diff --git a/include/efi_api.h b/include/efi_api.h
     > index 5017d9037cd..0f4245091f1 100644
     > --- a/include/efi_api.h
     > +++ b/include/efi_api.h
     > @@ -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;
     > @@ -564,6 +568,26 @@ 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
     > +

    All structures and unions and their elements should be describe
    according to
    https://docs.kernel.org/doc-guide/kernel-doc.html#structure-union-
    and-enumeration-documentation <https://docs.kernel.org/doc-guide/
    kernel-doc.html#structure-union-and-enumeration-documentation>

     > +struct efi_debug_image_info_normal {
     > +     u32 image_info_type;
     > +     struct efi_loaded_image *loaded_image_protocol_instance;
     > +     efi_handle_t image_handle;
     > +};

    What are the assumptions about alignment?
    Should this structure be marked as packed like most UEFI structures?
Quoted 3 lines

Not aligned. This structure in EDK2 is not aligned, not packed. And it is really not packed because the size of this structure is larger. 4 bytes are padded in the 64-bit environment I think.

All other structures in EDK II are packed. Did you look at the structure in a debugger?

The compiler will assume that a pointer to "struct efi_debug_image_info_normal *" points to a sizeof(uintptr_t) aligned structure if no other indication is made.

Quoted 6 lines

Best regards

Heinrich

Hi Heinrich,

Yes. All other structures in EDK II are packed. But this one is not packed.

And yes, seems it is aligned to sizeof(uintptr_t) in edk2. How do we implement this if we want the alignment? I plan to just remove that union and use "struct efi_debug_image_info_normal" directly.
But maybe the alignment is not important here? I'll do a bit of research on this.
Because we are not searching for this structure in the debugger. We just read it from EFI_DEBUG_IMAGE_INFO_TABLE. Which will be in the Configuration Table with specific GUID.
The only search in the debugger is for the SYSTEM_TABLE_POINTER structure.

Yours,
Paul

#9 lore raw

PATCH v2 3/3 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.

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

---
V2: use Kconfig options to turn on/off this feature.

---
 include/efi_api.h             |   2 +
 include/efi_loader.h          |   5 ++
 lib/efi_loader/efi_boottime.c | 140 ++++++++++++++++++++++++++++++++++
 3 files changed, 147 insertions(+)
include/efi_api.h +2 -0
index 0f4245091f1..ba87af17c1f 100644
@@ -571,6 +571,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 {
 	u32 image_info_type;
 	struct efi_loaded_image *loaded_image_protocol_instance;
include/efi_loader.h +5 -0
index 370bc042f70..babe23a8a83 100644
@@ -617,6 +617,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 */
+void 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 +140 -0

161 lines not on this page · raw message

Signature · 1 line
2.39.5
#10 lore raw

Re: [PATCH v2 3/3] efi: add EFI_DEBUG_IMAGE_INFO for debug

Quoted 77 lines · 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.

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

---
V2: use Kconfig options to turn on/off this feature.

---
  include/efi_api.h             |   2 +
  include/efi_loader.h          |   5 ++
  lib/efi_loader/efi_boottime.c | 140 ++++++++++++++++++++++++++++++++++
  3 files changed, 147 insertions(+)
include/efi_api.h +2 -0
index 0f4245091f1..ba87af17c1f 100644
@@ -571,6 +571,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 {
  	u32 image_info_type;
  	struct efi_loaded_image *loaded_image_protocol_instance;
include/efi_loader.h +5 -0
index 370bc042f70..babe23a8a83 100644
@@ -617,6 +617,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 */
+void 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 +11 -0
index e2665459e44..0d4df5ee6ae 100644
@@ -2130,6 +2130,14 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy,
  		*image_handle = NULL;
  		free(info);
  	}
+
+	if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+		if (*image_handle) {
+			efi_core_new_debug_image_info_entry(EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
+							    info,
+							    *image_handle);
+		}
+	}
  error:
  	return EFI_EXIT(ret);
  }
@@ -3359,6 +3367,9 @@ efi_status_t EFIAPI efi_unload_image(efi_handle_t image_handle)
  		ret = EFI_INVALID_PARAMETER;
  		goto out;
  	}
+	if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+		efi_core_remove_debug_image_info_entry(image_handle);
+	}
  	switch (efiobj->type) {
  	case EFI_OBJECT_TYPE_STARTED_IMAGE:
  		/* Call the unload function */

lib/efi_loader/efi_boottime.c efi_m_debug_info_table_header = { · line 4058

Quoted 3 lines
lib/efi_loader/efi_boottime.c +0 -0
@@ -4045,6 +4056,10 @@ efi_m_debug_info_table_header = {
  	NULL
  };
 

Please, describe this field.

lib/efi_loader/efi_boottime.c efi_m_debug_info_table_header = {

Quoted 4 lines
lib/efi_loader/efi_boottime.c +3 -0
+static u32 efi_m_max_table_entries;
+
 
+#define EFI_DEBUG_TABLE_ENTRY_SIZE  (sizeof(void *))

Wouldn't it be more readable to use sizeof(union efi_debug_image_info *) instead of this constant?

Quoted 12 lines
lib/efi_loader/efi_boottime.c +5 -0
+
  const efi_guid_t efi_debug_image_info_table_guid =
  	EFI_DEBUG_IMAGE_INFO_TABLE_GUID;
@@ -4095,3 +4110,128 @@ efi_status_t efi_initialize_system_table_pointer(void)
 
  	return ret;
  }
+
+/**
+ * Add a new efi_loaded_image structure to the efi_debug_image_info Table.
+ * Re-Allocates the table if it's not large enough to accomidate another

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4126

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+ * entry.
+ *
+ * @param image_info_type  type of debug image information
+ * @param loaded_image     pointer to the loaded image protocol for the image
+ *                         being loaded
+ * @param image_handle     image handle for the image being loaded
+ **/
+void efi_core_new_debug_image_info_entry(u32 image_info_type,
+					 struct efi_loaded_image *loaded_image,
+					 efi_handle_t image_handle)

Reallocation can fail. The return value type void seems not to be adequate.

Quoted 13 lines
lib/efi_loader/efi_boottime.c +13 -0
+{
+	union efi_debug_image_info *table;
+	union efi_debug_image_info *new_table;
+	u32 index;
+	u32 table_size;
+
+	/* Set the flag indicating that we're in the process of updating
+	 * the table.
+	 */
+	efi_m_debug_info_table_header.update_status |=
+		EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+
+	table = efi_m_debug_info_table_header.efi_debug_image_info_table;

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4149

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+
+	if (efi_m_debug_info_table_header.table_size < efi_m_max_table_entries) {
+		/* We still have empty entries in the Table, find the first
+		 * empty entry.
+		 */
+		index = 0;
+		while (table[index].normal_image)
+			index++;
+	} else {
+		/* table is full, re-allocate another page for a larger

"Re-allocate the buffer increasing the size by 4 KiB" would be clearer.

Quoted 4 lines
lib/efi_loader/efi_boottime.c +4 -0
+		 * table.
+		 */
+		table_size = efi_m_max_table_entries * EFI_DEBUG_TABLE_ENTRY_SIZE;
+		efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA,

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4163

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+				  table_size + EFI_PAGE_SIZE,
+				  (void **)&new_table);
+
+		if (!new_table) {
+			efi_m_debug_info_table_header.update_status &=
+				~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+			return;
+		}
+
+		memset(new_table, 0, table_size + EFI_PAGE_SIZE);

Please, carve out an efi_realloc() function and place it in lib/efi_loader/efi_memory.c beside efi_alloc().

Quoted 12 lines
lib/efi_loader/efi_boottime.c +12 -0
+
+		/* Copy the old table into the new one. */
+		memcpy(new_table, table, table_size);
+		/* Free the old table. */
+		efi_free_pool(table);
+		/* Update the table header. */
+		table = new_table;
+		efi_m_debug_info_table_header.efi_debug_image_info_table =
+			new_table;
+
+		/* Enlarge the max table entries and set the first empty
+		 * entry index to be the original max table entries.

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4185

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+		 */
+		index = efi_m_max_table_entries;
+		efi_m_max_table_entries +=
+			EFI_PAGE_SIZE / EFI_DEBUG_TABLE_ENTRY_SIZE;
+	}
+
+	/* Allocate data for new entry. */
+	efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA,
+			  sizeof(struct efi_debug_image_info_normal),
+			  (void **)(&table[index].normal_image));

efi_allocate_pool() will consume a whole page. Shouldn't we have an array of consecutive structures and use realloc_pool() to enlarge it if we load too many images?

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4190

Quoted 5 lines
lib/efi_loader/efi_boottime.c +5 -0
+	if (table[index].normal_image) {
+		/* Update the entry. */
+		table[index].normal_image->image_info_type = image_info_type;
+		table[index].normal_image->loaded_image_protocol_instance =
+			loaded_image;

All protocols become invalid after ExitBootServices(). Why would you use EFI_RUNTIME_SERVICES_DATA to store references to something that does not exist at runtime?

EDK II uses AllocateZeroPool() which does not use EfiRuntimeServicesData.

Best regards

Heinrich

Quoted 47 lines
lib/efi_loader/efi_boottime.c +47 -0
+		table[index].normal_image->image_handle = image_handle;
+
+		/* Increase the number of EFI_DEBUG_IMAGE_INFO elements and
+		 * set the efi_m_debug_info_table_header in modified status.
+		 */
+		efi_m_debug_info_table_header.table_size++;
+		efi_m_debug_info_table_header.update_status |=
+			EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
+	}
+
+	efi_m_debug_info_table_header.update_status &=
+		~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+}
+
+void efi_core_remove_debug_image_info_entry(efi_handle_t image_handle)
+{
+	union efi_debug_image_info *table;
+	u32 index;
+
+	efi_m_debug_info_table_header.update_status |=
+		EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+
+	table = efi_m_debug_info_table_header.efi_debug_image_info_table;
+
+	for (index = 0; index < efi_m_max_table_entries; index++) {
+		if (table[index].normal_image &&
+		    table[index].normal_image->image_handle == image_handle) {
+			/* Found a match. Free up the record, then NULL the
+			 * pointer to indicate the slot is free.
+			 */
+			efi_free_pool(table[index].normal_image);
+			table[index].normal_image = NULL;
+
+			/* Decrease the number of EFI_DEBUG_IMAGE_INFO
+			 * elements and set the efi_m_debug_info_table_header
+			 * in modified status.
+			 */
+			efi_m_debug_info_table_header.table_size--;
+			efi_m_debug_info_table_header.update_status |=
+				EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
+			break;
+		}
+	}
+
+	efi_m_debug_info_table_header.update_status &=
+		~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+}
#11 lore raw

Re: [PATCH v2 3/3] efi: add EFI_DEBUG_IMAGE_INFO for debug

Hi Heinrich,

Thanks for the review.
All of the issues in this commit will be fixed in the next version.

Thanks a lot.

Yours,
Paul

Quoted 268 lines · Heinrich Schuchardt
Quoted 36 lines · 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.

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

---
V2: use Kconfig options to turn on/off this feature.

---
  include/efi_api.h             |   2 +
  include/efi_loader.h          |   5 ++
  lib/efi_loader/efi_boottime.c | 140 ++++++++++++++++++++++++++++++++++
  3 files changed, 147 insertions(+)
include/efi_api.h +2 -0
index 0f4245091f1..ba87af17c1f 100644
@@ -571,6 +571,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 {
      u32 image_info_type;
      struct efi_loaded_image *loaded_image_protocol_instance;
include/efi_loader.h +0 -0
index 370bc042f70..babe23a8a83 100644

include/efi_loader.h efi_status_t efi_root_node_register(void); · line 622

Quoted 6 lines
include/efi_loader.h +3 -0
@@ -617,6 +617,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 */
+void efi_core_new_debug_image_info_entry(u32 image_info_type,
+                                      struct efi_loaded_image

*loaded_image,

Review

Quoted 6 lines
include/efi_loader.h +2 -0
+                                      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 */
(quoted diff) +0 -0

b/lib/efi_loader/efi_boottime.c

lib/efi_loader/efi_boottime.c efi_status_t EFIAPI efi_load_image(bool

Quoted 4 lines

index e2665459e44..0d4df5ee6ae 100644

lib/efi_loader/efi_boottime.c +0 -0
@@ -2130,6 +2130,14 @@ efi_status_t EFIAPI efi_load_image(bool

boot_policy,

lib/efi_loader/efi_boottime.c efi_status_t EFIAPI efi_load_image(bool boot_policy,

Quoted 7 lines
lib/efi_loader/efi_boottime.c +4 -0
              *image_handle = NULL;
              free(info);
      }
+
+     if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+             if (*image_handle) {
+

efi_core_new_debug_image_info_entry(EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,

lib/efi_loader/efi_boottime.c efi_status_t EFIAPI efi_unload_image(efi_handle_t

Quoted 8 lines
lib/efi_loader/efi_boottime.c +4 -0
+                                                         info,
+                                                         *image_handle);
+             }
+     }
  error:
      return EFI_EXIT(ret);
  }
@@ -3359,6 +3367,9 @@ efi_status_t EFIAPI efi_unload_image(efi_handle_t

image_handle)

lib/efi_loader/efi_boottime.c efi_m_debug_info_table_header = { · line 4058

Quoted 13 lines
lib/efi_loader/efi_boottime.c +3 -0
              ret = EFI_INVALID_PARAMETER;
              goto out;
      }
+     if (IS_ENABLED(CONFIG_EFI_DEBUG_SUPPORT_TABLE)) {
+             efi_core_remove_debug_image_info_entry(image_handle);
+     }
      switch (efiobj->type) {
      case EFI_OBJECT_TYPE_STARTED_IMAGE:
              /* Call the unload function */
@@ -4045,6 +4056,10 @@ efi_m_debug_info_table_header = {
      NULL
  };
 

Please, describe this field.

lib/efi_loader/efi_boottime.c efi_m_debug_info_table_header = {

Quoted 4 lines
lib/efi_loader/efi_boottime.c +3 -0
+static u32 efi_m_max_table_entries;
+
 
+#define EFI_DEBUG_TABLE_ENTRY_SIZE  (sizeof(void *))

Wouldn't it be more readable to use sizeof(union efi_debug_image_info *) instead of this constant?

lib/efi_loader/efi_boottime.c efi_status_t

Quoted 5 lines
lib/efi_loader/efi_boottime.c +1 -0
+
  const efi_guid_t efi_debug_image_info_table_guid =
      EFI_DEBUG_IMAGE_INFO_TABLE_GUID;
@@ -4095,3 +4110,128 @@ efi_status_t

efi_initialize_system_table_pointer(void)

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

Quoted 6 lines
lib/efi_loader/efi_boottime.c +3 -0
      return ret;
  }
+
+/**
+ * Add a new efi_loaded_image structure to the efi_debug_image_info

Table.

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

Quoted 5 lines
lib/efi_loader/efi_boottime.c +5 -0
+ * Re-Allocates the table if it's not large enough to accomidate another
+ * entry.
+ *
+ * @param image_info_type  type of debug image information
+ * @param loaded_image     pointer to the loaded image protocol for the

image

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

Quoted 5 lines
lib/efi_loader/efi_boottime.c +5 -0
+ *                         being loaded
+ * @param image_handle     image handle for the image being loaded
+ **/
+void efi_core_new_debug_image_info_entry(u32 image_info_type,
+                                      struct efi_loaded_image

*loaded_image,

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4126

Quoted 1 line
lib/efi_loader/efi_boottime.c +1 -0
+                                      efi_handle_t image_handle)

Reallocation can fail. The return value type void seems not to be adequate.

Quoted 5 lines
lib/efi_loader/efi_boottime.c +5 -0
+{
+     union efi_debug_image_info *table;
+     union efi_debug_image_info *new_table;
+     u32 index;
+     u32 table_size;

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

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+
+     /* Set the flag indicating that we're in the process of updating
+      * the table.
+      */
+     efi_m_debug_info_table_header.update_status |=
+             EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+
+     table = efi_m_debug_info_table_header.efi_debug_image_info_table;
+
+     if (efi_m_debug_info_table_header.table_size <

efi_m_max_table_entries) {

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4149

Quoted 8 lines
lib/efi_loader/efi_boottime.c +8 -0
+             /* We still have empty entries in the Table, find the first
+              * empty entry.
+              */
+             index = 0;
+             while (table[index].normal_image)
+                     index++;
+     } else {
+             /* table is full, re-allocate another page for a larger

"Re-allocate the buffer increasing the size by 4 KiB" would be clearer.

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

Quoted 3 lines
lib/efi_loader/efi_boottime.c +3 -0
+              * table.
+              */
+             table_size = efi_m_max_table_entries *

EFI_DEBUG_TABLE_ENTRY_SIZE;

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4163

Quoted 11 lines
lib/efi_loader/efi_boottime.c +11 -0
+             efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA,
+                               table_size + EFI_PAGE_SIZE,
+                               (void **)&new_table);
+
+             if (!new_table) {
+                     efi_m_debug_info_table_header.update_status &=
+                             ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+                     return;
+             }
+
+             memset(new_table, 0, table_size + EFI_PAGE_SIZE);

Please, carve out an efi_realloc() function and place it in lib/efi_loader/efi_memory.c beside efi_alloc().

Quoted 12 lines
lib/efi_loader/efi_boottime.c +12 -0
+
+             /* Copy the old table into the new one. */
+             memcpy(new_table, table, table_size);
+             /* Free the old table. */
+             efi_free_pool(table);
+             /* Update the table header. */
+             table = new_table;
+             efi_m_debug_info_table_header.efi_debug_image_info_table =
+                     new_table;
+
+             /* Enlarge the max table entries and set the first empty
+              * entry index to be the original max table entries.

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4185

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+              */
+             index = efi_m_max_table_entries;
+             efi_m_max_table_entries +=
+                     EFI_PAGE_SIZE / EFI_DEBUG_TABLE_ENTRY_SIZE;
+     }
+
+     /* Allocate data for new entry. */
+     efi_allocate_pool(EFI_RUNTIME_SERVICES_DATA,
+                       sizeof(struct efi_debug_image_info_normal),
+                       (void **)(&table[index].normal_image));

efi_allocate_pool() will consume a whole page. Shouldn't we have an array of consecutive structures and use realloc_pool() to enlarge it if we load too many images?

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

Quoted 3 lines
lib/efi_loader/efi_boottime.c +3 -0
+     if (table[index].normal_image) {
+             /* Update the entry. */
+             table[index].normal_image->image_info_type =

image_info_type;

lib/efi_loader/efi_boottime.c efi_status_t efi_initialize_system_table_pointer(void) · line 4190

Quoted 2 lines
lib/efi_loader/efi_boottime.c +2 -0
+             table[index].normal_image->loaded_image_protocol_instance =
+                     loaded_image;

All protocols become invalid after ExitBootServices(). Why would you use EFI_RUNTIME_SERVICES_DATA to store references to something that does not exist at runtime?

EDK II uses AllocateZeroPool() which does not use EfiRuntimeServicesData.

Best regards

Heinrich

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

Quoted 4 lines
lib/efi_loader/efi_boottime.c +4 -0
+             table[index].normal_image->image_handle = image_handle;
+
+             /* Increase the number of EFI_DEBUG_IMAGE_INFO elements and
+              * set the efi_m_debug_info_table_header in modified

status.

Quoted 13 lines
lib/efi_loader/efi_boottime.c +13 -0
+              */
+             efi_m_debug_info_table_header.table_size++;
+             efi_m_debug_info_table_header.update_status |=
+                     EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
+     }
+
+     efi_m_debug_info_table_header.update_status &=
+             ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+}
+
+void efi_core_remove_debug_image_info_entry(efi_handle_t image_handle)
+{
+     union efi_debug_image_info *table;

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

Quoted 10 lines
lib/efi_loader/efi_boottime.c +10 -0
+     u32 index;
+
+     efi_m_debug_info_table_header.update_status |=
+             EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+
+     table = efi_m_debug_info_table_header.efi_debug_image_info_table;
+
+     for (index = 0; index < efi_m_max_table_entries; index++) {
+             if (table[index].normal_image &&
+                 table[index].normal_image->image_handle ==

image_handle) {

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

Quoted 8 lines
lib/efi_loader/efi_boottime.c +8 -0
+                     /* Found a match. Free up the record, then NULL the
+                      * pointer to indicate the slot is free.
+                      */
+                     efi_free_pool(table[index].normal_image);
+                     table[index].normal_image = NULL;
+
+                     /* Decrease the number of EFI_DEBUG_IMAGE_INFO
+                      * elements and set the

efi_m_debug_info_table_header

Quoted 12 lines
lib/efi_loader/efi_boottime.c +12 -0
+                      * in modified status.
+                      */
+                     efi_m_debug_info_table_header.table_size--;
+                     efi_m_debug_info_table_header.update_status |=
+                             EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED;
+                     break;
+             }
+     }
+
+     efi_m_debug_info_table_header.update_status &=
+             ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+}