Skip to contentSkip to conversation

efi: Improvements to booting and debugging

PATCH Superseded Simon Glass 3 participants 16 messages Feb 26, 2023 – Mar 11, 2023

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

cover efi: Improvements to booting and debugging

This series provides support for booting a kernel from the EFI app. So far this is pretty basic, since it only supports the actual booting, not providing ACPI tables, etc. But it is a start.

It also includes an enhancement to the 'efi' command and a few other clean-ups.

Simon Glass (10):
efi: Set RUN_64BIT correctly for the EFI app
x86: Adjust bootparam.h to be more like linux
x86: Add return-value comment to cpu_jump_to_64bit()
x86: Support booting a 64-bit kernel from 64-bit U-Boot
x86: Exit EFI boot services before starting kernel
x86: Support zboot and bootm in the EFI app
efi: Add another tranch of GUIDs
doc: Add help for the efi command
efi: Support showing tables
efI: Allow packaging a kernel in the debugging script

 arch/x86/Kconfig                 |   4 +-
 arch/x86/include/asm/bootm.h     |  12 +-
 arch/x86/include/asm/bootparam.h |  70 ++++++----
 arch/x86/include/asm/cpu.h       |   1 +
 arch/x86/lib/bootm.c             |  43 ++++--
 arch/x86/lib/zimage.c            |  17 ++-
 cmd/efi.c                        |  40 +++++-
 configs/efi-x86_app32_defconfig  |   2 +-
 configs/efi-x86_app64_defconfig  |   3 +-
 doc/usage/cmd/efi.rst            | 219 +++++++++++++++++++++++++++++++
 doc/usage/index.rst              |   1 +
 include/efi_api.h                |  28 ++++
 lib/uuid.c                       |  12 ++
 scripts/build-efi.sh             |  14 +-
 14 files changed, 419 insertions(+), 47 deletions(-)
 create mode 100644 doc/usage/cmd/efi.rst
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#1 lore raw

PATCH 1/10 efi: Set RUN_64BIT correctly for the EFI app

The U-Boot EFI app can run as a 64-bit program, so set the Kconfig correctly in that case. Make sure it doesn't build SPL, since there is no need to switch from 32 to 64 bit when running.

---

 arch/x86/Kconfig                | 4 ++--
 configs/efi-x86_app64_defconfig | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
arch/x86/Kconfig +2 -2
index 07be5cd05ec..99e59d94c60 100644
@@ -32,8 +32,8 @@ config X86_RUN_32BIT
 config X86_RUN_64BIT
 	bool "64-bit"
 	select X86_64
-	select SPL
-	select SPL_SEPARATE_BSS
+	select SPL if !EFI_APP
+	select SPL_SEPARATE_BSS if !EFI_APP
 	help
 	  Build U-Boot as a 64-bit binary with a 32-bit SPL. This is
 	  experimental and many features are missing. U-Boot SPL starts up,
configs/efi-x86_app64_defconfig +1 -0
index dae48840493..f1cf43c1ef6 100644
@@ -4,6 +4,7 @@ CONFIG_ENV_SIZE=0x1000
 CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app"
 CONFIG_DEBUG_UART_BASE=0
 CONFIG_DEBUG_UART_CLOCK=0
+CONFIG_X86_RUN_64BIT=y
 CONFIG_VENDOR_EFI=y
 CONFIG_TARGET_EFI_APP64=y
 CONFIG_DEBUG_UART=y
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#2 lore raw

PATCH 2/10 x86: Adjust bootparam.h to be more like linux

In reply to Simon Glass

This likely came from Linux originally, so update it to match v6.2 more. This has no functional change.

---

 arch/x86/include/asm/bootparam.h | 70 +++++++++++++++++++++-----------
 arch/x86/lib/zimage.c            |  2 +-
 2 files changed, 47 insertions(+), 25 deletions(-)
arch/x86/include/asm/bootparam.h +46 -24
index 7a3c1f51554..ea816ca7469 100644
@@ -9,19 +9,54 @@
 #include <asm/ist.h>
 #include <asm/video/edid.h>
 
-/* setup data types */
-enum {
-	SETUP_NONE = 0,
-	SETUP_E820_EXT,
-	SETUP_DTB,
-};
+/* setup_data/setup_indirect types */
+#define SETUP_NONE			0
+#define SETUP_E820_EXT			1
+#define SETUP_DTB			2
+#define SETUP_PCI			3
+#define SETUP_EFI			4
+#define SETUP_APPLE_PROPERTIES		5
+#define SETUP_JAILHOUSE			6
+#define SETUP_CC_BLOB			7
+#define SETUP_IMA			8
+#define SETUP_RNG_SEED			9
+#define SETUP_ENUM_MAX			SETUP_RNG_SEED
+
+#define SETUP_INDIRECT			BIT(31)
+#define SETUP_TYPE_MAX			(SETUP_ENUM_MAX | SETUP_INDIRECT)
+
+/* ram_size flags */
+#define RAMDISK_IMAGE_START_MASK	0x07FF
+#define RAMDISK_PROMPT_FLAG		0x8000
+#define RAMDISK_LOAD_FLAG		0x4000
+
+/* loadflags */
+#define LOADED_HIGH	BIT(0)
+#define KASLR_FLAG	BIT(1)
+#define QUIET_FLAG	BIT(5)
+#define KEEP_SEGMENTS	BIT(6)
+#define CAN_USE_HEAP	BIT(7)
+
+#define XLF_KERNEL_64			BIT(0)
+#define XLF_CAN_BE_LOADED_ABOVE_4G	BIT(1)
+#define XLF_EFI_HANDOVER_32		BIT(2)
+#define XLF_EFI_HANDOVER_64		BIT(3)
+#define XLF_EFI_KEXEC			BIT(4)
 
 /* extensible setup data list node */
 struct setup_data {
 	__u64 next;
 	__u32 type;
 	__u32 len;
-	__u8 data[0];
+	__u8 data[];
+};
+
+/* extensible setup indirect data node */
+struct setup_indirect {
+	__u32 type;
+	__u32 reserved;  /* Reserved, must be set to zero. */
+	__u64 len;
+	__u64 addr;
 };
 
 /**
@@ -34,9 +69,6 @@ struct setup_header {
 	__u16	root_flags;
 	__u32	syssize;
 	__u16	ram_size;
-#define RAMDISK_IMAGE_START_MASK	0x07FF
-#define RAMDISK_PROMPT_FLAG		0x8000
-#define RAMDISK_LOAD_FLAG		0x4000
 	__u16	vid_mode;
 	__u16	root_dev;
 	__u16	boot_flag;
@@ -44,15 +76,10 @@ struct setup_header {
 	__u32	header;
 	__u16	version;
 	__u32	realmode_swtch;
-	__u16	start_sys;
+	__u16	start_sys_seg;
 	__u16	kernel_version;
 	__u8	type_of_loader;
 	__u8	loadflags;
-#define LOADED_HIGH	BIT(0)
-#define KASLR_FLAG	BIT(1)
-#define QUIET_FLAG	BIT(5)
-#define KEEP_SEGMENTS	BIT(6)		/* Obsolete */
-#define CAN_USE_HEAP	BIT(7)
 	__u16	setup_move_size;
 	__u32	code32_start;
 	__u32	ramdisk_image;
@@ -65,13 +92,8 @@ struct setup_header {
 	__u32	initrd_addr_max;
 	__u32	kernel_alignment;
 	__u8	relocatable_kernel;
-	u8	min_alignment;
-#define XLF_KERNEL_64			BIT(0)
-#define XLF_CAN_BE_LOADED_ABOVE_4G	BIT(1)
-#define XLF_EFI_HANDOVER_32		BIT(2)
-#define XLF_EFI_HANDOVER_64		BIT(3)
-#define XLF_EFI_KEXEC			BIT(4)
-	u16	xloadflags;
+	__u8	min_alignment;
+	__u16	xloadflags;
 	__u32	cmdline_size;
 	__u32	hardware_subarch;
 	__u64	hardware_subarch_data;
@@ -81,7 +103,7 @@ struct setup_header {
 	__u64	pref_address;
 	__u32	init_size;
 	__u32	handover_offset;
-	u32	kernel_info_offset;
+	__u32	kernel_info_offset;
 } __attribute__((packed));
 
 struct sys_desc_table {
arch/x86/lib/zimage.c +1 -1
index 9cc04490307..a6d9151c324 100644
@@ -655,7 +655,7 @@ void zimage_dump(struct boot_params *base_ptr)
 		printf("%-20s  %s\n", "", "Ancient kernel, using version 100");
 	print_num("Version", hdr->version);
 	print_num("Real mode switch", hdr->realmode_swtch);
-	print_num("Start sys", hdr->start_sys);
+	print_num("Start sys seg", hdr->start_sys_seg);
 	print_num("Kernel version", hdr->kernel_version);
 	version = get_kernel_version(base_ptr, (void *)state.bzimage_addr);
 	if (version)
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#3 lore raw

PATCH 3/10 x86: Add return-value comment to cpu_jump_to_64bit()

In reply to Simon Glass

This does not mention what it returns. Add the missing documentation.

---

 arch/x86/include/asm/cpu.h | 1 +
 1 file changed, 1 insertion(+)
arch/x86/include/asm/cpu.h +1 -0
index 3346012d335..aa03ef598e1 100644
@@ -262,6 +262,7 @@ void cpu_call32(ulong code_seg32, ulong target, ulong table);
  *
  * @setup_base:	Pointer to the setup.bin information for the kernel
  * @target:	Pointer to the start of the kernel image
+ * Returns: -EFAULT if the kernel returned; otherwise does not return
  */
 int cpu_jump_to_64bit(ulong setup_base, ulong target);
 
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#4 lore raw

PATCH 4/10 x86: Support booting a 64-bit kernel from 64-bit U-Boot

In reply to Simon Glass

Add the missing code to handle this. For a 64-bit kernel the entry address is 0x200 bytes after the normal entry.

Rename the parameter to boot_linux_kernel() accordingly. Update the comments to indicate that these are addresses, not pointers.

---

 arch/x86/include/asm/bootm.h | 12 ++++++------
 arch/x86/lib/bootm.c         | 25 +++++++++++++++++--------
 arch/x86/lib/zimage.c        | 15 +++++++++++++--
 3 files changed, 36 insertions(+), 16 deletions(-)
arch/x86/include/asm/bootm.h +6 -6
index 109f686f740..3b641783b9c 100644
@@ -14,14 +14,14 @@ void bootm_announce_and_cleanup(void);
  * This boots a kernel image, either 32-bit or 64-bit. It will also work with
  * a self-extracting kernel, if you set @image_64bit to false.
  *
- * @setup_base:		Pointer to the setup.bin information for the kernel
- * @load_address:	Pointer to the start of the kernel image
- * @image_64bit:	true if the image is a raw 64-bit kernel, false if it
- *			is raw 32-bit or any type of self-extracting kernel
- *			such as a bzImage.
+ * @setup_base:		Address of the setup.bin information for the kernel
+ * @entry:		Address of the kernel entry point
+ * @image_64bit:	true if the image is a raw 64-bit kernel, or a kernel
+ * which supports booting in 64-bit mode; false if it is raw 32-bit or any type
+ * of self-extracting kernel such as a bzImage.
  * Return: -ve error code. This function does not return if the kernel was
  * booted successfully.
  */
-int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit);
+int boot_linux_kernel(ulong setup_base, ulong entry, bool image_64bit);
 
 #endif
arch/x86/lib/bootm.c +17 -8
index 873e2bc176f..9beb376bb9c 100644
@@ -149,7 +149,7 @@ error:
 	return 1;
 }
 
-int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
+int boot_linux_kernel(ulong setup_base, ulong entry, bool image_64bit)
 {
 	bootm_announce_and_cleanup();
 
@@ -161,14 +161,23 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
 			puts("Cannot boot 64-bit kernel on 32-bit machine\n");
 			return -EFAULT;
 		}
-		/* At present 64-bit U-Boot does not support booting a
+		/*
+		 * At present 64-bit U-Boot only supports booting a 64-bit
 		 * kernel.
-		 * TODO([email protected]): Support booting both 32-bit and
-		 * 64-bit kernels from 64-bit U-Boot.
+		 *
+		 * TODO([email protected]): Support booting 32-bit kernels from
+		 * 64-bit U-Boot
 		 */
-#if !CONFIG_IS_ENABLED(X86_64)
-		return cpu_jump_to_64bit(setup_base, load_address);
-#endif
+		if (CONFIG_IS_ENABLED(X86_64)) {
+			typedef void (*h_func)(ulong zero, ulong setup);
+			h_func func;
+
+			/* jump to Linux with rdi=0, rsi=setup_base */
+			func = (h_func)entry;
+			func(0, setup_base);
+		} else {
+			return cpu_jump_to_64bit(setup_base, entry);
+		}
 	} else {
 		/*
 		* Set %ebx, %ebp, and %edi to 0, %esi to point to the
@@ -190,7 +199,7 @@ int boot_linux_kernel(ulong setup_base, ulong load_address, bool image_64bit)
 		"movl $0, %%ebp\n"
 		"cli\n"
 		"jmp *%[kernel_entry]\n"
-		:: [kernel_entry]"a"(load_address),
+		:: [kernel_entry]"a"(entry),
 		[boot_params] "S"(setup_base),
 		"b"(0), "D"(0)
 		);
arch/x86/lib/zimage.c +13 -2
index a6d9151c324..e5ea5129c1e 100644
@@ -504,13 +504,24 @@ static int do_zboot_info(struct cmd_tbl *cmdtp, int flag, int argc,
 static int do_zboot_go(struct cmd_tbl *cmdtp, int flag, int argc,
 		       char *const argv[])
 {
+	struct boot_params *params = state.base_ptr;
+	struct setup_header *hdr = &params->hdr;
+	bool image_64bit;
+	ulong entry;
 	int ret;
 
 	disable_interrupts();
 
+	entry = state.load_address;
+	image_64bit = false;
+	if (IS_ENABLED(CONFIG_X86_RUN_64BIT) &&
+	    (hdr->xloadflags & XLF_KERNEL_64)) {
+		entry += 0x200;
+		image_64bit = true;
+	}
+
 	/* we assume that the kernel is in place */
-	ret = boot_linux_kernel((ulong)state.base_ptr, state.load_address,
-				false);
+	ret = boot_linux_kernel((ulong)state.base_ptr, entry, image_64bit);
 	printf("Kernel returned! (err=%d)\n", ret);
 
 	return CMD_RET_FAILURE;
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#5 lore raw

PATCH 5/10 x86: Exit EFI boot services before starting kernel

In reply to Simon Glass

When running the EFI app, we need to exit boot services before jumping to Linux.

At some point it may be possible to jump to Linux and pass on the boot services, so that the Linux efistub can be used. For now, this is not implemented.

---

 arch/x86/lib/bootm.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
arch/x86/lib/bootm.c +18 -0
index 9beb376bb9c..61cb7bc6116 100644
@@ -10,6 +10,7 @@
 #include <common.h>
 #include <bootstage.h>
 #include <command.h>
+#include <efi.h>
 #include <hang.h>
 #include <log.h>
 #include <asm/global_data.h>
@@ -156,6 +157,23 @@ int boot_linux_kernel(ulong setup_base, ulong entry, bool image_64bit)
 #ifdef CONFIG_SYS_COREBOOT
 	timestamp_add_now(TS_U_BOOT_START_KERNEL);
 #endif
+
+	/*
+	 * Exit EFI boot services just before jumping, after all console
+	 * output, since the console won't be available afterwards.
+	 */
+	if (IS_ENABLED(CONFIG_EFI_APP)) {
+		int ret;
+
+		ret = efi_store_memory_map(efi_get_priv());
+		if (ret)
+			return ret;
+		printf("Exiting EFI boot services\n");
+		ret = efi_call_exit_boot_services();
+		if (ret)
+			return ret;
+	}
+
 	if (image_64bit) {
 		if (!cpu_has_64bit()) {
 			puts("Cannot boot 64-bit kernel on 32-bit machine\n");
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#6 lore raw

PATCH 6/10 x86: Support zboot and bootm in the EFI app

In reply to Simon Glass

These have been disabled due to the rudimentary support available. It is a little better now, so enable these options.

---

 configs/efi-x86_app32_defconfig | 2 +-
 configs/efi-x86_app64_defconfig | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
configs/efi-x86_app32_defconfig +1 -1
index 905f375a3ef..50975dbfaaf 100644
@@ -19,7 +19,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PBSIZE=532
-# CONFIG_CMD_BOOTM is not set
+CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_PART=y
 # CONFIG_CMD_NET is not set
 CONFIG_CMD_TIME=y
configs/efi-x86_app64_defconfig +1 -1
index f1cf43c1ef6..0fc358ddcdf 100644
@@ -20,7 +20,7 @@ CONFIG_DISPLAY_BOARDINFO_LATE=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_HUSH_PARSER=y
 CONFIG_SYS_PBSIZE=532
-# CONFIG_CMD_BOOTM is not set
+CONFIG_CMD_BOOTZ=y
 CONFIG_CMD_PART=y
 # CONFIG_CMD_NET is not set
 CONFIG_CMD_CACHE=y
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#7 lore raw

PATCH 7/10 efi: Add another tranch of GUIDs

In reply to Simon Glass

Provide information about the GUIDs supplied by QEMU, so far as it is known.

---

 include/efi_api.h | 28 ++++++++++++++++++++++++++++
 lib/uuid.c        | 12 ++++++++++++
 2 files changed, 40 insertions(+)
include/efi_api.h +28 -0
index 2d18d25a713..90caee4038c 100644
@@ -1909,6 +1909,34 @@ struct efi_system_resource_table {
 	EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \
 		 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
 
+#define EFI_LZMA_COMPRESSED \
+	EFI_GUID(0xee4e5898, 0x3914, 0x4259, 0x9d, 0x6e, \
+		 0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf)
+#define EFI_DXE_SERVICES \
+	EFI_GUID(0x05ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, \
+		 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9)
+#define EFI_HOB_LIST \
+	EFI_GUID(0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a,  \
+		 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_MEMORY_TYPE \
+	EFI_GUID(0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, \
+		 0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa)
+#define EFI_SMBIOS \
+	EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16,  \
+		 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_MEM_STATUS_CODE_REC \
+	EFI_GUID(0x060cc026, 0x4c0d, 0x4dda, 0x8f, 0x41, \
+		 0x59, 0x5f, 0xef, 0x00, 0xa5, 0x02)
+#define EFI_GUID_SNBIOS \
+	EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, \
+		 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_GUID_EFI_ACPI1 \
+	EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3,  0x9a, 0x16, \
+		 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_GUID_EFI_ACPI2 \
+	EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, \
+		 0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)
+
 /**
  * struct win_certificate_uefi_guid - A certificate that encapsulates
  * a GUID-specific signature
lib/uuid.c +12 -0
index 465e1ac38f5..77aef746a2e 100644
@@ -255,6 +255,18 @@ static const struct {
 		EFI_CERT_TYPE_PKCS7_GUID,
 	},
 #endif
+#ifdef CONFIG_EFI_APP
+#endif
+	{ "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
+	{ "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
+	{ "EFI_HOB_LIST", EFI_HOB_LIST },
+	{ "EFI_MEMORY_TYPE", EFI_MEMORY_TYPE },
+	{ "EFI_SMBIOS", EFI_SMBIOS },
+	{ "EFI_MEM_STATUS_CODE_REC", EFI_MEM_STATUS_CODE_REC },
+	{ "EFI_GUID_SNBIOS", EFI_GUID_SNBIOS },
+	{ "EFI_GUID_EFI_ACPI1", EFI_GUID_EFI_ACPI1 },
+	{ "EFI_GUID_EFI_ACPI2", EFI_GUID_EFI_ACPI2 },
+
 };
 
 /*
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#8 lore raw

Re: [PATCH 07/10] efi: Add another tranch of GUIDs

Hi Simon

Quoted 3 lines · Simon Glass

Provide information about the GUIDs supplied by QEMU, so far as it is known.

What the patch does is obvious. Can you explain why this is needed though?

Quoted 21 lines

---

 include/efi_api.h | 28 ++++++++++++++++++++++++++++
 lib/uuid.c        | 12 ++++++++++++
 2 files changed, 40 insertions(+)
include/efi_api.h +5 -0
index 2d18d25a713..90caee4038c 100644
@@ -1909,6 +1909,34 @@ struct efi_system_resource_table {
        EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \
                 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
 
+#define EFI_LZMA_COMPRESSED \
+       EFI_GUID(0xee4e5898, 0x3914, 0x4259, 0x9d, 0x6e, \
+                0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf)
+#define EFI_DXE_SERVICES \
+       EFI_GUID(0x05ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, \

include/efi_api.h struct efi_system_resource_table { · line 1926

Quoted 10 lines
include/efi_api.h +10 -0
+                0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9)
+#define EFI_HOB_LIST \
+       EFI_GUID(0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a,  \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_MEMORY_TYPE \
+       EFI_GUID(0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, \
+                0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa)
+#define EFI_SMBIOS \
+       EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16,  \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)

This already exists as SMBIOS_TABLE_GUID

include/efi_api.h struct efi_system_resource_table { · line 1932

Quoted 6 lines
include/efi_api.h +6 -0
+#define EFI_MEM_STATUS_CODE_REC \
+       EFI_GUID(0x060cc026, 0x4c0d, 0x4dda, 0x8f, 0x41, \
+                0x59, 0x5f, 0xef, 0x00, 0xa5, 0x02)
+#define EFI_GUID_SNBIOS \
+       EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)

what is SNBIOS? I assume it's a typos since it matches the existing SMBIOS_TABLE_GUID?

include/efi_api.h struct efi_system_resource_table { · line 1938

Quoted 6 lines
include/efi_api.h +6 -0
+#define EFI_GUID_EFI_ACPI1 \
+       EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3,  0x9a, 0x16, \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_GUID_EFI_ACPI2 \
+       EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, \
+                0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)

Already exists as EFI_ACPI_TABLE_GUID

Quoted 28 lines
include/efi_api.h +1 -0
+
 /**
  * struct win_certificate_uefi_guid - A certificate that encapsulates
  * a GUID-specific signature
lib/uuid.c +12 -1
index 465e1ac38f5..77aef746a2e 100644
@@ -255,6 +255,18 @@ static const struct {
                EFI_CERT_TYPE_PKCS7_GUID,
        },
 #endif
+#ifdef CONFIG_EFI_APP
+#endif
+       { "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
+       { "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
+       { "EFI_HOB_LIST", EFI_HOB_LIST },
+       { "EFI_MEMORY_TYPE", EFI_MEMORY_TYPE },
+       { "EFI_SMBIOS", EFI_SMBIOS },
+       { "EFI_MEM_STATUS_CODE_REC", EFI_MEM_STATUS_CODE_REC },
+       { "EFI_GUID_SNBIOS", EFI_GUID_SNBIOS },
+       { "EFI_GUID_EFI_ACPI1", EFI_GUID_EFI_ACPI1 },
+       { "EFI_GUID_EFI_ACPI2", EFI_GUID_EFI_ACPI2 },
+
 };
 
 /*
--
Quoted 2 lines

2.39.2.637.g21b0678d19-goog

Thanks
/Ilias

#9 lore raw

Re: [PATCH 07/10] efi: Add another tranch of GUIDs

Hi Ilias,

Quoted 9 lines · Ilias Apalodimas

Hi Simon

Quoted 3 lines · Simon Glass

Provide information about the GUIDs supplied by QEMU, so far as it is known.

What the patch does is obvious. Can you explain why this is needed though?

Yes. It allows seeing what the tables actually are, since the GUIDs are impenetrable for that. See for example the 'efi table' command in this series.

I think %sU uses it too.

Quoted 26 lines
Quoted 26 lines

---

 include/efi_api.h | 28 ++++++++++++++++++++++++++++
 lib/uuid.c        | 12 ++++++++++++
 2 files changed, 40 insertions(+)
include/efi_api.h +9 -0
index 2d18d25a713..90caee4038c 100644
@@ -1909,6 +1909,34 @@ struct efi_system_resource_table {
        EFI_GUID(0x4aafd29d, 0x68df, 0x49ee, 0x8a, 0xa9, \
                 0x34, 0x7d, 0x37, 0x56, 0x65, 0xa7)
 
+#define EFI_LZMA_COMPRESSED \
+       EFI_GUID(0xee4e5898, 0x3914, 0x4259, 0x9d, 0x6e, \
+                0xdc, 0x7b, 0xd7, 0x94, 0x03, 0xcf)
+#define EFI_DXE_SERVICES \
+       EFI_GUID(0x05ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, \
+                0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9)
+#define EFI_HOB_LIST \
+       EFI_GUID(0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a,  \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
Quoted 8 lines

include/efi_api.h struct efi_system_resource_table { · line 1926

Quoted 6 lines
include/efi_api.h +6 -0
+#define EFI_MEMORY_TYPE \
+       EFI_GUID(0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, \
+                0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa)
+#define EFI_SMBIOS \
+       EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16,  \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)

This already exists as SMBIOS_TABLE_GUID

Oh dear, OK. Would you mind if I rename it? It is hard to find things if the naming is inconsistent.

Quoted 10 lines

include/efi_api.h struct efi_system_resource_table { · line 1932

Quoted 7 lines
include/efi_api.h +6 -0
+#define EFI_MEM_STATUS_CODE_REC \
+       EFI_GUID(0x060cc026, 0x4c0d, 0x4dda, 0x8f, 0x41, \
+                0x59, 0x5f, 0xef, 0x00, 0xa5, 0x02)
+#define EFI_GUID_SNBIOS \
+       EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)

what is SNBIOS? I assume it's a typos since it matches the existing SMBIOS_TABLE_GUID?

Yes, a typo

Quoted 9 lines

include/efi_api.h struct efi_system_resource_table { · line 1938

Quoted 7 lines
include/efi_api.h +6 -0
+#define EFI_GUID_EFI_ACPI1 \
+       EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3,  0x9a, 0x16, \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_GUID_EFI_ACPI2 \
+       EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, \
+                0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)

Already exists as EFI_ACPI_TABLE_GUID

OK, bind if I rename it so we have these consistent?

Quoted 27 lines
Quoted 27 lines
include/efi_api.h +1 -0
+
 /**
  * struct win_certificate_uefi_guid - A certificate that encapsulates
  * a GUID-specific signature
lib/uuid.c +12 -0
index 465e1ac38f5..77aef746a2e 100644
@@ -255,6 +255,18 @@ static const struct {
                EFI_CERT_TYPE_PKCS7_GUID,
        },
 #endif
+#ifdef CONFIG_EFI_APP
+#endif
+       { "EFI_LZMA_COMPRESSED", EFI_LZMA_COMPRESSED },
+       { "EFI_DXE_SERVICES", EFI_DXE_SERVICES },
+       { "EFI_HOB_LIST", EFI_HOB_LIST },
+       { "EFI_MEMORY_TYPE", EFI_MEMORY_TYPE },
+       { "EFI_SMBIOS", EFI_SMBIOS },
+       { "EFI_MEM_STATUS_CODE_REC", EFI_MEM_STATUS_CODE_REC },
+       { "EFI_GUID_SNBIOS", EFI_GUID_SNBIOS },
+       { "EFI_GUID_EFI_ACPI1", EFI_GUID_EFI_ACPI1 },
+       { "EFI_GUID_EFI_ACPI2", EFI_GUID_EFI_ACPI2 },
+
 };
 
Quoted 4 lines
Quoted 4 lines
lib/uuid.c +0 -1
 /*
--

2.39.2.637.g21b0678d19-goog

Regards,
Simon

#10 lore raw

Re: [PATCH 07/10] efi: Add another tranch of GUIDs

Hi Simon,

Quoted 13 lines · Simon Glass

Hi Ilias,

Quoted 8 lines · Ilias Apalodimas

Hi Simon

Quoted 3 lines · Simon Glass

Provide information about the GUIDs supplied by QEMU, so far as it is known.

Quoted 7 lines
Quoted 1 line

What the patch does is obvious. Can you explain why this is needed though?

Yes. It allows seeing what the tables actually are, since the GUIDs are impenetrable for that. See for example the 'efi table' command in this series.

I think %sU uses it too.

Yes, but please put that in the commit message in the next version.

[...]

Quoted 10 lines
Quoted 7 lines

include/efi_api.h struct efi_system_resource_table { · line 1926

Quoted 5 lines
include/efi_api.h +5 -0
+       EFI_GUID(0x4c19049f, 0x4137, 0x4dd3, 0x9c, 0x10, \
+                0x8b, 0x97, 0xa8, 0x3f, 0xfd, 0xfa)
+#define EFI_SMBIOS \
+       EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16,  \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)

This already exists as SMBIOS_TABLE_GUID

Oh dear, OK. Would you mind if I rename it? It is hard to find things if the naming is inconsistent.

I think the naming is already quite consistent here. We are trying to follow what's in the EFI specification, so it's easy to search and find things in there (§4.6.1.1 Industry Standard Configuration Tables). I'd rather leave it as is

Quoted 24 lines
Quoted 11 lines

include/efi_api.h struct efi_system_resource_table { · line 1932

Quoted 8 lines
include/efi_api.h +6 -0
+#define EFI_MEM_STATUS_CODE_REC \
+       EFI_GUID(0x060cc026, 0x4c0d, 0x4dda, 0x8f, 0x41, \
+                0x59, 0x5f, 0xef, 0x00, 0xa5, 0x02)
+#define EFI_GUID_SNBIOS \
+       EFI_GUID(0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)

what is SNBIOS? I assume it's a typos since it matches the existing SMBIOS_TABLE_GUID?

Yes, a typo

Quoted 9 lines

include/efi_api.h struct efi_system_resource_table { · line 1938

Quoted 7 lines
include/efi_api.h +6 -0
+#define EFI_GUID_EFI_ACPI1 \
+       EFI_GUID(0xeb9d2d30, 0x2d88, 0x11d3,  0x9a, 0x16, \
+                0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d)
+#define EFI_GUID_EFI_ACPI2 \
+       EFI_GUID(0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, \
+                0x00, 0x80, 0xc7, 0x3c, 0x88, 0x81)

Already exists as EFI_ACPI_TABLE_GUID

Quoted 1 line

OK, bind if I rename it so we have these consistent?

The same thing applies to this one, it's described as-is in the EFI spec.

[...]

Thanks
/Ilias

#11 lore raw

PATCH 8/10 doc: Add help for the efi command

In reply to Simon Glass

This command currently has no help. Add some.

---

 doc/usage/cmd/efi.rst | 197 ++++++++++++++++++++++++++++++++++++++++++
 doc/usage/index.rst   |   1 +
 2 files changed, 198 insertions(+)
 create mode 100644 doc/usage/cmd/efi.rst
doc/usage/cmd/efi.rst new file +197 -0
new file mode 100644
index 00000000000..c029c423879
@@ -0,0 +1,197 @@
+.. SPDX-License-Identifier: GPL-2.0+
+.. Copyright 2020, Heinrich Schuchardt <[email protected]>
+
+efi command
+===========
+
+Synopsis
+--------
+
+::
+
+    efi mem [all]
+
+Description
+-----------
+
+The *efi* command provides information about the EFI environment U-Boot is
+running in, when it is started from EFI.
+
+When running as an EFI app, this command queries EFI boot services for the
+information. When running as an EFI payload, EFI boot services have been
+stopped, so it uses the information collected by the boot stub before that
+happened.
+
+efi mem
+~~~~~~~
+
+This shows the EFI memory map, sorted in order of physical address.
+
+This is normally a very large table. To help reduce the amount of detritus,
+boot-time memory is normally merged with conventional memory. Use the 'all'
+argument to show everything.
+
+The fields are as follows:
+
+#
+    Entry number (sequentially from 0)
+
+Type
+    Memory type. EFI has a large number of memory types. The type is shown in
+    the format <n>:<name> where in is the format number in hex and <name> is the
+    name.
+
+Physical
+    Physical address
+
+Virtual
+    Virtual address
+
+Size
+    Size of memory area in bytes
+
+Attributes
+    Shows a code for memory attributes. The key for this is shown below the
+    table.
+
+Example
+-------
+
+::
+
+    => efi mem
+    EFI table at 0, memory map 000000001ad38b60, size 1260, key a79, version 1, descr. size 0x30
+     #  Type              Physical     Virtual        Size  Attributes
+     0  7:conv          0000000000  0000000000  00000a0000  f
+        <gap>           00000a0000              0000060000
+     1  7:conv          0000100000  0000000000  0000700000  f
+     2  a:acpi_nvs      0000800000  0000000000  0000008000  f
+     3  7:conv          0000808000  0000000000  0000008000  f
+     4  a:acpi_nvs      0000810000  0000000000  00000f0000  f
+     5  7:conv          0000900000  0000000000  001efef000  f
+     6  6:rt_data       001f8ef000  0000000000  0000100000  rf
+     7  5:rt_code       001f9ef000  0000000000  0000100000  rf
+     8  0:reserved      001faef000  0000000000  0000080000  f
+     9  9:acpi_reclaim  001fb6f000  0000000000  0000010000  f
+    10  a:acpi_nvs      001fb7f000  0000000000  0000080000  f
+    11  7:conv          001fbff000  0000000000  0000359000  f
+    12  6:rt_data       001ff58000  0000000000  0000020000  rf
+    13  a:acpi_nvs      001ff78000  0000000000  0000088000  f
+        <gap>           0020000000              0090000000
+    14  0:reserved      00b0000000  0000000000  0010000000  1
+
+    Attributes key:
+     f: uncached, write-coalescing, write-through, write-back
+    rf: uncached, write-coalescing, write-through, write-back, needs runtime mapping
+     1: uncached
+    *Some areas are merged (use 'all' to see)
+
+
+    => efi mem  all
+    EFI table at 0, memory map 000000001ad38bb0, size 1260, key a79, version 1, descr. size 0x30
+     #  Type              Physical     Virtual        Size  Attributes
+     0  3:bs_code       0000000000  0000000000  0000001000  f
+     1  7:conv          0000001000  0000000000  000009f000  f
+        <gap>           00000a0000              0000060000
+     2  7:conv          0000100000  0000000000  0000700000  f
+     3  a:acpi_nvs      0000800000  0000000000  0000008000  f
+     4  7:conv          0000808000  0000000000  0000008000  f
+     5  a:acpi_nvs      0000810000  0000000000  00000f0000  f
+     6  4:bs_data       0000900000  0000000000  0000c00000  f
+     7  7:conv          0001500000  0000000000  000aa36000  f
+     8  2:loader_data   000bf36000  0000000000  0010000000  f
+     9  4:bs_data       001bf36000  0000000000  0000020000  f
+    10  7:conv          001bf56000  0000000000  00021e1000  f
+    11  1:loader_code   001e137000  0000000000  00000c4000  f
+    12  7:conv          001e1fb000  0000000000  000009b000  f
+    13  1:loader_code   001e296000  0000000000  00000e2000  f
+    14  7:conv          001e378000  0000000000  000005b000  f
+    15  4:bs_data       001e3d3000  0000000000  000001e000  f
+    16  7:conv          001e3f1000  0000000000  0000016000  f
+    17  4:bs_data       001e407000  0000000000  0000016000  f
+    18  2:loader_data   001e41d000  0000000000  0000002000  f
+    19  4:bs_data       001e41f000  0000000000  0000828000  f
+    20  3:bs_code       001ec47000  0000000000  0000045000  f
+    21  4:bs_data       001ec8c000  0000000000  0000001000  f
+    22  3:bs_code       001ec8d000  0000000000  000000e000  f
+    23  4:bs_data       001ec9b000  0000000000  0000001000  f
+    24  3:bs_code       001ec9c000  0000000000  000002c000  f
+    25  4:bs_data       001ecc8000  0000000000  0000001000  f
+    26  3:bs_code       001ecc9000  0000000000  000000c000  f
+    27  4:bs_data       001ecd5000  0000000000  0000006000  f
+    28  3:bs_code       001ecdb000  0000000000  0000014000  f
+    29  4:bs_data       001ecef000  0000000000  0000001000  f
+    30  3:bs_code       001ecf0000  0000000000  000005b000  f
+    31  4:bs_data       001ed4b000  0000000000  000000b000  f
+    32  3:bs_code       001ed56000  0000000000  0000024000  f
+    33  4:bs_data       001ed7a000  0000000000  0000006000  f
+    34  3:bs_code       001ed80000  0000000000  0000010000  f
+    35  4:bs_data       001ed90000  0000000000  0000002000  f
+    36  3:bs_code       001ed92000  0000000000  0000025000  f
+    37  4:bs_data       001edb7000  0000000000  0000003000  f
+    38  3:bs_code       001edba000  0000000000  0000011000  f
+    39  4:bs_data       001edcb000  0000000000  0000008000  f
+    40  3:bs_code       001edd3000  0000000000  000002d000  f
+    41  4:bs_data       001ee00000  0000000000  0000201000  f
+    42  3:bs_code       001f001000  0000000000  0000024000  f
+    43  4:bs_data       001f025000  0000000000  0000002000  f
+    44  3:bs_code       001f027000  0000000000  0000009000  f
+    45  4:bs_data       001f030000  0000000000  0000005000  f
+    46  3:bs_code       001f035000  0000000000  000002f000  f
+    47  4:bs_data       001f064000  0000000000  0000001000  f
+    48  3:bs_code       001f065000  0000000000  0000005000  f
+    49  4:bs_data       001f06a000  0000000000  0000005000  f
+    50  3:bs_code       001f06f000  0000000000  0000007000  f
+    51  4:bs_data       001f076000  0000000000  0000007000  f
+    52  3:bs_code       001f07d000  0000000000  000000d000  f
+    53  4:bs_data       001f08a000  0000000000  0000001000  f
+    54  3:bs_code       001f08b000  0000000000  0000006000  f
+    55  4:bs_data       001f091000  0000000000  0000004000  f
+    56  3:bs_code       001f095000  0000000000  000000d000  f
+    57  4:bs_data       001f0a2000  0000000000  0000003000  f
+    58  3:bs_code       001f0a5000  0000000000  0000026000  f
+    59  4:bs_data       001f0cb000  0000000000  0000005000  f
+    60  3:bs_code       001f0d0000  0000000000  0000019000  f
+    61  4:bs_data       001f0e9000  0000000000  0000004000  f
+    62  3:bs_code       001f0ed000  0000000000  0000024000  f
+    63  4:bs_data       001f111000  0000000000  0000008000  f
+    64  3:bs_code       001f119000  0000000000  000000b000  f
+    65  4:bs_data       001f124000  0000000000  0000001000  f
+    66  3:bs_code       001f125000  0000000000  0000002000  f
+    67  4:bs_data       001f127000  0000000000  0000002000  f
+    68  3:bs_code       001f129000  0000000000  0000009000  f
+    69  4:bs_data       001f132000  0000000000  0000003000  f
+    70  3:bs_code       001f135000  0000000000  0000005000  f
+    71  4:bs_data       001f13a000  0000000000  0000003000  f
+    72  3:bs_code       001f13d000  0000000000  0000005000  f
+    73  4:bs_data       001f142000  0000000000  0000003000  f
+    74  3:bs_code       001f145000  0000000000  0000011000  f
+    75  4:bs_data       001f156000  0000000000  000000b000  f
+    76  3:bs_code       001f161000  0000000000  0000009000  f
+    77  4:bs_data       001f16a000  0000000000  0000400000  f
+    78  3:bs_code       001f56a000  0000000000  0000006000  f
+    79  4:bs_data       001f570000  0000000000  0000001000  f
+    80  3:bs_code       001f571000  0000000000  0000001000  f
+    81  4:bs_data       001f572000  0000000000  0000002000  f
+    82  3:bs_code       001f574000  0000000000  0000017000  f
+    83  4:bs_data       001f58b000  0000000000  0000364000  f
+    84  6:rt_data       001f8ef000  0000000000  0000100000  rf
+    85  5:rt_code       001f9ef000  0000000000  0000100000  rf
+    86  0:reserved      001faef000  0000000000  0000080000  f
+    87  9:acpi_reclaim  001fb6f000  0000000000  0000010000  f
+    88  a:acpi_nvs      001fb7f000  0000000000  0000080000  f
+    89  4:bs_data       001fbff000  0000000000  0000201000  f
+    90  7:conv          001fe00000  0000000000  00000e8000  f
+    91  4:bs_data       001fee8000  0000000000  0000020000  f
+    92  3:bs_code       001ff08000  0000000000  0000026000  f
+    93  4:bs_data       001ff2e000  0000000000  0000009000  f
+    94  3:bs_code       001ff37000  0000000000  0000021000  f
+    95  6:rt_data       001ff58000  0000000000  0000020000  rf
+    96  a:acpi_nvs      001ff78000  0000000000  0000088000  f
+        <gap>           0020000000              0090000000
+    97  0:reserved      00b0000000  0000000000  0010000000  1
+
+    Attributes key:
+     f: uncached, write-coalescing, write-through, write-back
+    rf: uncached, write-coalescing, write-through, write-back, needs runtime mapping
+     1: uncached
doc/usage/index.rst +1 -0
index cde7dcb14a6..68522c18c04 100644
@@ -42,6 +42,7 @@ Shell commands
    cmd/cyclic
    cmd/dm
    cmd/echo
+   cmd/efi
    cmd/eficonfig
    cmd/env
    cmd/event
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#12 lore raw

PATCH 9/10 efi: Support showing tables

In reply to Simon Glass

Add a command to display the tables provided by EFI.

---

 cmd/efi.c             | 40 +++++++++++++++++++++++++++++++++++++++-
 doc/usage/cmd/efi.rst | 22 ++++++++++++++++++++++
 2 files changed, 61 insertions(+), 1 deletion(-)
cmd/efi.c +39 -1
index c0384e0db28..86988d9e9e2 100644
@@ -7,10 +7,12 @@
 #include <common.h>
 #include <command.h>
 #include <efi.h>
+#include <efi_api.h>
 #include <errno.h>
 #include <log.h>
 #include <malloc.h>
 #include <sort.h>
+#include <uuid.h>
 #include <asm/global_data.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -273,8 +275,43 @@ done:
 	return ret ? CMD_RET_FAILURE : 0;
 }
 
+static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc,
+			 char *const argv[])
+{
+	struct efi_system_table *systab;
+	int i;
+
+	if (IS_ENABLED(CONFIG_EFI_APP)) {
+		systab = efi_get_sys_table();
+		if (!systab) {
+			printf("Cannot read system table\n");
+			return CMD_RET_FAILURE;
+		}
+	} else {
+		int size;
+		int ret;
+
+		ret = efi_info_get(EFIET_SYS_TABLE, (void **)&systab, &size);
+		if (ret) {
+			printf("Cannot find EFI system table (err=%d)\n", ret);
+			return CMD_RET_FAILURE;
+		}
+	}
+	for (i = 0; i < systab->nr_tables; i++) {
+		struct efi_configuration_table *tab = &systab->tables[i];
+		char guid_str[37];
+
+		uuid_bin_to_str(tab->guid.b, guid_str, 1);
+		printf("%p  %s  %s\n", tab->table, guid_str,
+		       uuid_guid_get_str(tab->guid.b));
+	}
+
+	return 0;
+}
+
 static struct cmd_tbl efi_commands[] = {
 	U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""),
+	U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""),
 };
 
 static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
@@ -298,5 +335,6 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 U_BOOT_CMD(
 	efi,     3,      1,      do_efi,
 	"EFI access",
-	"mem [all]        Dump memory information [include boot services]"
+	"mem [all]        Dump memory information [include boot services]\n"
+	"tables               Dump tables"
 );
doc/usage/cmd/efi.rst +22 -0
index c029c423879..2424d3bb587 100644
@@ -10,6 +10,7 @@ Synopsis
 ::
 
     efi mem [all]
+    efi tables
 
 Description
 -----------
@@ -54,6 +55,14 @@ Attributes
     Shows a code for memory attributes. The key for this is shown below the
     table.
 
+efi tables
+~~~~~~~~~~
+
+This shows a list of the EFI tables provided in the system table. These use
+GUIDs so it is not possible in general to show the name of a table. But some
+effort is made to provide a useful table, where the GUID is known by U-Boot.
+
+
 Example
 -------
 
@@ -195,3 +204,16 @@ Example
      f: uncached, write-coalescing, write-through, write-back
     rf: uncached, write-coalescing, write-through, write-back, needs runtime mapping
      1: uncached
+
+
+    => efi tables
+    000000001f8eda98  ee4e5898-3914-4259-9d6e-dc7bd79403cf  EFI_LZMA_COMPRESSED
+    000000001ff2ace0  05ad34ba-6f02-4214-952e-4da0398e2bb9  EFI_DXE_SERVICES
+    000000001f8ea018  7739f24c-93d7-11d4-9a3a-0090273fc14d  EFI_HOB_LIST
+    000000001ff2bac0  4c19049f-4137-4dd3-9c10-8b97a83ffdfa  EFI_MEMORY_TYPE
+    000000001ff2cb10  49152e77-1ada-4764-b7a2-7afefed95e8b  <NULL>
+    000000001f9ac018  060cc026-4c0d-4dda-8f41-595fef00a502  EFI_MEM_STATUS_CODE_REC
+    000000001f9ab000  eb9d2d31-2d88-11d3-9a16-0090273fc14d  EFI_SMBIOS
+    000000001fb7e000  eb9d2d30-2d88-11d3-9a16-0090273fc14d  EFI_GUID_EFI_ACPI1
+    000000001fb7e014  8868e871-e4f1-11d3-bc22-0080c73c8881  EFI_GUID_EFI_ACPI2
+    000000001e550018  dcfa911d-26eb-469f-a220-38b7dc461220  <NULL>
Signature · 1 line
2.39.2.637.g21b0678d19-goog
#13 lore raw

Re: [PATCH 09/10] efi: Support showing tables

Quoted 27 lines · Simon Glass

Add a command to display the tables provided by EFI.

---

  cmd/efi.c             | 40 +++++++++++++++++++++++++++++++++++++++-
  doc/usage/cmd/efi.rst | 22 ++++++++++++++++++++++
  2 files changed, 61 insertions(+), 1 deletion(-)
cmd/efi.c +2 -0
index c0384e0db28..86988d9e9e2 100644
@@ -7,10 +7,12 @@
  #include <common.h>
  #include <command.h>
  #include <efi.h>
+#include <efi_api.h>
  #include <errno.h>
  #include <log.h>
  #include <malloc.h>
  #include <sort.h>
+#include <uuid.h>
  #include <asm/global_data.h>
 
  DECLARE_GLOBAL_DATA_PTR;

cmd/efi.c done: · line 279

Quoted 5 lines
cmd/efi.c +2 -0
@@ -273,8 +275,43 @@ done:
  	return ret ? CMD_RET_FAILURE : 0;
  }
 
+static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc,
+			 char *const argv[])

We already have function do_efi_show_tables() to print the list of EFI configuration tables. Please, avoid code duplication.

Quoted 17 lines
cmd/efi.c +17 -0
+{
+	struct efi_system_table *systab;
+	int i;
+
+	if (IS_ENABLED(CONFIG_EFI_APP)) {
+		systab = efi_get_sys_table();
+		if (!systab) {
+			printf("Cannot read system table\n");
+			return CMD_RET_FAILURE;
+		}
+	} else {
+		int size;
+		int ret;
+
+		ret = efi_info_get(EFIET_SYS_TABLE, (void **)&systab, &size);
+		if (ret) {
+			printf("Cannot find EFI system table (err=%d)\n", ret);

cmd/efi.c done: · line 306

Quoted 10 lines
cmd/efi.c +10 -0
+			return CMD_RET_FAILURE;
+		}
+	}
+	for (i = 0; i < systab->nr_tables; i++) {
+		struct efi_configuration_table *tab = &systab->tables[i];
+		char guid_str[37];
+
+		uuid_bin_to_str(tab->guid.b, guid_str, 1);
+		printf("%p  %s  %s\n", tab->table, guid_str,
+		       uuid_guid_get_str(tab->guid.b));

do_efi_show_tables() does this with printf("%pUl (%pUs)\n",..).

Quoted 48 lines
cmd/efi.c +8 -1
+	}
+
+	return 0;
+}
+
  static struct cmd_tbl efi_commands[] = {
  	U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""),
+	U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""),
  };
 
  static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
@@ -298,5 +335,6 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  U_BOOT_CMD(
  	efi,     3,      1,      do_efi,
  	"EFI access",
-	"mem [all]        Dump memory information [include boot services]"
+	"mem [all]        Dump memory information [include boot services]\n"
+	"tables               Dump tables"
  );
doc/usage/cmd/efi.rst +9 -0
index c029c423879..2424d3bb587 100644
@@ -10,6 +10,7 @@ Synopsis
  ::
 
      efi mem [all]
+    efi tables
 
  Description
  -----------
@@ -54,6 +55,14 @@ Attributes
      Shows a code for memory attributes. The key for this is shown below the
      table.
 
+efi tables
+~~~~~~~~~~
+
+This shows a list of the EFI tables provided in the system table. These use
+GUIDs so it is not possible in general to show the name of a table. But some
+effort is made to provide a useful table, where the GUID is known by U-Boot.
+
+
  Example
  -------
 
@@ -195,3 +204,16 @@ Example
       f: uncached, write-coalescing, write-through, write-back

doc/usage/cmd/efi.rst Example · line 214

Quoted 10 lines
doc/usage/cmd/efi.rst +8 -0
      rf: uncached, write-coalescing, write-through, write-back, needs runtime mapping
       1: uncached
+
+
+    => efi tables
+    000000001f8eda98  ee4e5898-3914-4259-9d6e-dc7bd79403cf  EFI_LZMA_COMPRESSED
+    000000001ff2ace0  05ad34ba-6f02-4214-952e-4da0398e2bb9  EFI_DXE_SERVICES
+    000000001f8ea018  7739f24c-93d7-11d4-9a3a-0090273fc14d  EFI_HOB_LIST
+    000000001ff2bac0  4c19049f-4137-4dd3-9c10-8b97a83ffdfa  EFI_MEMORY_TYPE
+    000000001ff2cb10  49152e77-1ada-4764-b7a2-7afefed95e8b  <NULL>

This is what 'efi tables' / printf("%pUl (%pUs)\n",..). would output for an unknown table:

8868e871-e4f1-11d3-bc22-0080c73c8881 (8868e871-e4f1-11d3-bc22-0080c73c8881)

Maybe uuid_guid_get_str() should return an empty string in case of an unknown GUID.

doc/usage/cmd/efi.rst Example · line 219

Quoted 5 lines
doc/usage/cmd/efi.rst +5 -0
+    000000001f9ac018  060cc026-4c0d-4dda-8f41-595fef00a502  EFI_MEM_STATUS_CODE_REC
+    000000001f9ab000  eb9d2d31-2d88-11d3-9a16-0090273fc14d  EFI_SMBIOS
+    000000001fb7e000  eb9d2d30-2d88-11d3-9a16-0090273fc14d  EFI_GUID_EFI_ACPI1
+    000000001fb7e014  8868e871-e4f1-11d3-bc22-0080c73c8881  EFI_GUID_EFI_ACPI2
+    000000001e550018  dcfa911d-26eb-469f-a220-38b7dc461220  <NULL>

Who would care about the address of the table?

Best regards

Heinrich

#14 lore raw

Re: [PATCH 09/10] efi: Support showing tables

Hi Heinrich,

Quoted 32 lines · Heinrich Schuchardt
Quoted 30 lines · Simon Glass

Add a command to display the tables provided by EFI.

---

  cmd/efi.c             | 40 +++++++++++++++++++++++++++++++++++++++-
  doc/usage/cmd/efi.rst | 22 ++++++++++++++++++++++
  2 files changed, 61 insertions(+), 1 deletion(-)
cmd/efi.c +2 -0
index c0384e0db28..86988d9e9e2 100644
@@ -7,10 +7,12 @@
  #include <common.h>
  #include <command.h>
  #include <efi.h>
+#include <efi_api.h>
  #include <errno.h>
  #include <log.h>
  #include <malloc.h>
  #include <sort.h>
+#include <uuid.h>
  #include <asm/global_data.h>
 
  DECLARE_GLOBAL_DATA_PTR;
@@ -273,8 +275,43 @@ done:
      return ret ? CMD_RET_FAILURE : 0;
  }
 
Quoted 6 lines

cmd/efi.c done: · line 279

Quoted 2 lines
cmd/efi.c +2 -0
+static int do_efi_tables(struct cmd_tbl *cmdtp, int flag, int argc,
+                      char *const argv[])

We already have function do_efi_show_tables() to print the list of EFI configuration tables. Please, avoid code duplication.

OK I created a separate file.

Of course the 'efidebug' command cannot be used in the app or payload, since it did not create the systab.

Quoted 94 lines
Quoted 18 lines
cmd/efi.c +17 -0
+{
+     struct efi_system_table *systab;
+     int i;
+
+     if (IS_ENABLED(CONFIG_EFI_APP)) {
+             systab = efi_get_sys_table();
+             if (!systab) {
+                     printf("Cannot read system table\n");
+                     return CMD_RET_FAILURE;
+             }
+     } else {
+             int size;
+             int ret;
+
+             ret = efi_info_get(EFIET_SYS_TABLE, (void **)&systab, &size);
+             if (ret) {
+                     printf("Cannot find EFI system table (err=%d)\n", ret);

cmd/efi.c done: · line 306

Quoted 10 lines
cmd/efi.c +10 -0
+                     return CMD_RET_FAILURE;
+             }
+     }
+     for (i = 0; i < systab->nr_tables; i++) {
+             struct efi_configuration_table *tab = &systab->tables[i];
+             char guid_str[37];
+
+             uuid_bin_to_str(tab->guid.b, guid_str, 1);
+             printf("%p  %s  %s\n", tab->table, guid_str,
+                    uuid_guid_get_str(tab->guid.b));

do_efi_show_tables() does this with printf("%pUl (%pUs)\n",..).

Quoted 48 lines
cmd/efi.c +8 -1
+     }
+
+     return 0;
+}
+
  static struct cmd_tbl efi_commands[] = {
      U_BOOT_CMD_MKENT(mem, 1, 1, do_efi_mem, "", ""),
+     U_BOOT_CMD_MKENT(tables, 1, 1, do_efi_tables, "", ""),
  };
 
  static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
@@ -298,5 +335,6 @@ static int do_efi(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
  U_BOOT_CMD(
      efi,     3,      1,      do_efi,
      "EFI access",
-     "mem [all]        Dump memory information [include boot services]"
+     "mem [all]        Dump memory information [include boot services]\n"
+     "tables               Dump tables"
  );
doc/usage/cmd/efi.rst +9 -0
index c029c423879..2424d3bb587 100644
@@ -10,6 +10,7 @@ Synopsis
  ::
 
      efi mem [all]
+    efi tables
 
  Description
  -----------
@@ -54,6 +55,14 @@ Attributes
      Shows a code for memory attributes. The key for this is shown below the
      table.
 
+efi tables
+~~~~~~~~~~
+
+This shows a list of the EFI tables provided in the system table. These use
+GUIDs so it is not possible in general to show the name of a table. But some
+effort is made to provide a useful table, where the GUID is known by U-Boot.
+
+
  Example
  -------
 
@@ -195,3 +204,16 @@ Example
       f: uncached, write-coalescing, write-through, write-back

doc/usage/cmd/efi.rst Example · line 214

Quoted 10 lines
doc/usage/cmd/efi.rst +8 -0
      rf: uncached, write-coalescing, write-through, write-back, needs runtime mapping
       1: uncached
+
+
+    => efi tables
+    000000001f8eda98  ee4e5898-3914-4259-9d6e-dc7bd79403cf  EFI_LZMA_COMPRESSED
+    000000001ff2ace0  05ad34ba-6f02-4214-952e-4da0398e2bb9  EFI_DXE_SERVICES
+    000000001f8ea018  7739f24c-93d7-11d4-9a3a-0090273fc14d  EFI_HOB_LIST
+    000000001ff2bac0  4c19049f-4137-4dd3-9c10-8b97a83ffdfa  EFI_MEMORY_TYPE
+    000000001ff2cb10  49152e77-1ada-4764-b7a2-7afefed95e8b  <NULL>

This is what 'efi tables' / printf("%pUl (%pUs)\n",..). would output for an unknown table:

Quoted 4 lines

8868e871-e4f1-11d3-bc22-0080c73c8881 (8868e871-e4f1-11d3-bc22-0080c73c8881)

Maybe uuid_guid_get_str() should return an empty string in case of an unknown GUID.

OK

Quoted 8 lines

doc/usage/cmd/efi.rst Example · line 219

Quoted 6 lines
doc/usage/cmd/efi.rst +5 -0
+    000000001f9ac018  060cc026-4c0d-4dda-8f41-595fef00a502  EFI_MEM_STATUS_CODE_REC
+    000000001f9ab000  eb9d2d31-2d88-11d3-9a16-0090273fc14d  EFI_SMBIOS
+    000000001fb7e000  eb9d2d30-2d88-11d3-9a16-0090273fc14d  EFI_GUID_EFI_ACPI1
+    000000001fb7e014  8868e871-e4f1-11d3-bc22-0080c73c8881  EFI_GUID_EFI_ACPI2
+    000000001e550018  dcfa911d-26eb-469f-a220-38b7dc461220  <NULL>

Who would care about the address of the table?

Me when I am looking at them!

Regards,
Simon

#15 lore raw

PATCH 10/10 efI: Allow packaging a kernel in the debugging script

In reply to Simon Glass

Add an option to package a kernel into the debugging script used for EFI.

The name of the kernel must be added to the script. Bd efault it is assumed that the kernel is built in the /tmp/kernel directory.

---

 scripts/build-efi.sh | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
scripts/build-efi.sh +13 -1
index 46c28807ef1..6b7df2e9bfe 100755
@@ -18,12 +18,15 @@
 # OVMF-pure-efi.x64.fd at
 # https://drive.google.com/file/d/1c39YI9QtpByGQ4V0UNNQtGqttEzS-eFV/view?usp=sharing
 
+bzimage_fname=/tmp/kernel/arch/x86/boot/bzImage
+
 set -e
 
 usage() {
 	echo "Usage: $0 [-a | -p] [other opts]" 1>&2
 	echo 1>&2
 	echo "   -a   - Package up the app" 1>&2
+	echo "   -k   - Add a kernel" 1>&2
 	echo "   -o   - Use old EFI app build (before 32/64 split)" 1>&2
 	echo "   -p   - Package up the payload" 1>&2
 	echo "   -P   - Create a partition table" 1>&2
@@ -52,11 +55,14 @@ serial=
 # before the 32/64 split of the app
 old=
 
+# package up a kernel as well
+kernel=
+
 # Set ubdir to the build directory where you build U-Boot out-of-tree
 # We avoid in-tree build because it gets confusing trying different builds
 ubdir=/tmp/b/
 
-while getopts "aopPrsw" opt; do
+while getopts "akopPrsw" opt; do
 	case "${opt}" in
 	a)
 		type=app
@@ -64,6 +70,9 @@ while getopts "aopPrsw" opt; do
 	p)
 		type=payload
 		;;
+	k)
+		kernel=1
+		;;
 	r)
 		run=1
 		;;
@@ -124,6 +133,9 @@ EOF
 # Copy files into the filesystem
 copy_files() {
 	sudo cp $TMP/* $MNT
+	if [[ -n "${kernel}" ]]; then
+		sudo cp ${bzimage_fname} $MNT/vmlinuz
+	fi
 }
 
 # Create a filesystem on a raw device and copy in the files
Signature · 1 line
2.39.2.637.g21b0678d19-goog