Skip to contentSkip to conversation

efi: Add esrt support.

PATCH In review Peter Jones 2 participants 6 messages Jan 9, 2015 – Jan 20, 2015 4 messages not in the archive EFI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 efi: Add esrt support.

Add sysfs files for the EFI System Resource Table (ESRT) under /sys/firmware/efi/esrt and for each EFI System Resource Entry under entries/ as a subdir.

The EFI System Resource Table (ESRT) provides a read-only catalog of system components for which the system accepts firmware upgrades via UEFI's "Capsule Update" feature. This module allows userland utilities to evaluate what firmware updates can be applied to this system, and potentially arrange for those updates to occur.

The ESRT is described as part of the UEFI specification, in version 2.5 which should be available from http://uefi.org/specifications in early 2015. If you're a member of the UEFI Forum, information about its addition to the standard is available as UEFI Mantis 1090.

For some hardware platforms, additional restrictions may be found at
http://msdn.microsoft.com/en-us/library/windows/hardware/jj128256.aspx , and additional documentation may be found at
http://download.microsoft.com/download/5/F/5/5F5D16CD-2530-4289-8019-94C6A20BED3C/windows-uefi-firmware-update-platform.docx
.

---
 drivers/firmware/efi/Makefile |   2 +-
 drivers/firmware/efi/efi.c    |  60 ++++++-
 drivers/firmware/efi/esrt.c   | 402 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/efi.h           |   7 +
 4 files changed, 469 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/efi/esrt.c
drivers/firmware/efi/Makefile +1 -1
index d8be608..26eabbc 100644
@@ -1,7 +1,7 @@
 #
 # Makefile for linux kernel
 #
-obj-$(CONFIG_EFI)			+= efi.o vars.o reboot.o
+obj-$(CONFIG_EFI)			+= efi.o esrt.o vars.o reboot.o
 obj-$(CONFIG_EFI_VARS)			+= efivars.o
 obj-$(CONFIG_EFI_VARS_PSTORE)		+= efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)			+= cper.o
drivers/firmware/efi/efi.c +59 -1

90 lines not on this page · raw message

drivers/firmware/efi/esrt.c new file +402 -0

402 lines not on this page · raw message

include/linux/efi.h +7 -0
index 0238d61..094d14c 100644
@@ -565,6 +565,9 @@ void efi_native_runtime_setup(void);
 #define UV_SYSTEM_TABLE_GUID \
     EFI_GUID(  0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 )
 
+#define EFI_SYSTEM_RESOURCE_TABLE_GUID \
+    EFI_GUID(  0xb122a263, 0x3661, 0x4f68, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 )
+
 #define LINUX_EFI_CRASH_GUID \
     EFI_GUID(  0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 )
 
@@ -823,6 +826,7 @@ extern struct efi {
 	unsigned long fw_vendor;	/* fw_vendor */
 	unsigned long runtime;		/* runtime table */
 	unsigned long config_table;	/* config tables */
+	unsigned long esrt;		/* EFI System Resource Table */
 	efi_get_time_t *get_time;
 	efi_set_time_t *set_time;
 	efi_get_wakeup_time_t *get_wakeup_time;
@@ -880,12 +884,15 @@ extern u32 efi_mem_type (unsigned long phys_addr);
 extern u64 efi_mem_attributes (unsigned long phys_addr);
 extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
 extern int __init efi_uart_console_only (void);
+extern u64 efi_mem_desc_end(efi_memory_desc_t *md);
+extern int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md);
 extern void efi_initialize_iomem_resources(struct resource *code_resource,
 		struct resource *data_resource, struct resource *bss_resource);
 extern void efi_get_time(struct timespec *now);
 extern void efi_reserve_boot_services(void);
 extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose);
 extern struct efi_memory_map memmap;
+extern struct kobject *efi_kobj;
 
 extern int efi_reboot_quirk_mode;
 extern bool efi_poweroff_required(void);
Signature · 1 line
2.1.0
#2 lore raw
In reply to a message not in the archive
Quoted 29 lines · Peter Jones

Add sysfs files for the EFI System Resource Table (ESRT) under /sys/firmware/efi/esrt and for each EFI System Resource Entry under entries/ as a subdir.

The EFI System Resource Table (ESRT) provides a read-only catalog of system components for which the system accepts firmware upgrades via UEFI's "Capsule Update" feature. This module allows userland utilities to evaluate what firmware updates can be applied to this system, and potentially arrange for those updates to occur.

The ESRT is described as part of the UEFI specification, in version 2.5 which should be available from http://uefi.org/specifications in early 2015. If you're a member of the UEFI Forum, information about its addition to the standard is available as UEFI Mantis 1090.

For some hardware platforms, additional restrictions may be found at
http://msdn.microsoft.com/en-us/library/windows/hardware/jj128256.aspx , and additional documentation may be found at
http://download.microsoft.com/download/5/F/5/5F5D16CD-2530-4289-8019-94C6A20BED3C/windows-uefi-firmware-update-platform.docx
.

---
 drivers/firmware/efi/Makefile |   2 +-
 drivers/firmware/efi/efi.c    |  60 ++++++-
 drivers/firmware/efi/esrt.c   | 402 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/efi.h           |   7 +
 4 files changed, 469 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/efi/esrt.c

[...]

Quoted 4 lines
drivers/firmware/efi/efi.c +0 -0
@@ -223,6 +226,60 @@ err_put:
 
 subsys_initcall(efisubsys_init);
 

drivers/firmware/efi/efi.c err_put: · line 238

Quoted 10 lines
drivers/firmware/efi/efi.c +10 -0
+/*
+ * Find the efi memory descriptor for a given physical address.  Given a
+ * physicall address, determine if it exists within an EFI Memory Map entry,
+ * and if so, populate the supplied memory descriptor with the appropriate
+ * data.
+ */
+int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md)
+{
+	struct efi_memory_map *map = efi.memmap;
+	void *p, *e;

This is missing,

	if (!efi_enabled(EFI_MEMMAP))
		return -EINVAL;

drivers/firmware/efi/efi.c err_put: · line 247

Quoted 9 lines
drivers/firmware/efi/efi.c +9 -0
+
+	if (!map)
+		return -1;
+	if (!out_md)
+		return -1;
+	if (WARN_ON(!map->phys_map))
+		return -1;
+	if (WARN_ON(map->nr_map == 0) || WARN_ON(map->desc_size == 0))
+		return -1;

Should we be returning -EINVAL here instead?

Quoted 14 lines
drivers/firmware/efi/efi.c +14 -0
+
+	e = map->phys_map + map->nr_map * map->desc_size;
+	for (p = map->phys_map; p < e; p += map->desc_size) {
+		/*
+		 * If a driver calls this after efi_free_boot_services,
+		 * ->map will be NULL.
+		 * So just always get our own virtual map on the CPU.
+		 */
+		efi_memory_desc_t *md = phys_to_virt((phys_addr_t)p);
+		u64 size = md->num_pages << EFI_PAGE_SHIFT;
+		u64 end = md->phys_addr + size;
+
+		if (!(md->attribute & EFI_MEMORY_RUNTIME) &&
+		    md->type != EFI_BOOT_SERVICES_CODE &&

drivers/firmware/efi/efi.c err_put: · line 271

Quoted 10 lines
drivers/firmware/efi/efi.c +10 -0
+		    md->type != EFI_BOOT_SERVICES_DATA)
+			continue;
+		if (!md->virt_addr)
+			continue;
+		if (phys_addr >= md->phys_addr && phys_addr < end) {
+			memcpy(out_md, md, sizeof(*out_md));
+			return 0;
+		}
+	}
+	return -1;

-ENOENT?

[...]

drivers/firmware/efi/esrt.c line 265

Quoted 6 lines
drivers/firmware/efi/esrt.c new file +6 -0
+
+	tmpesrt = ioremap(efi.esrt, size);
+	if (!tmpesrt) {
+		pr_err("ioremap failed.\n");
+		return -ENOMEM;
+	}

Sadly, this isn't going to work with kexec. I don't that should hold up this patch, but I just wanted to raise the issue and make people aware.

Dave, Ard, original thread is here,

http://article.gmane.org/gmane.linux.kernel.efi/5233

Ard has come up with a nice solution to this kind of problem for arm64:
basically you perform all such mappings in the EFI boot stub so that the kexec and non-kexec code paths are always dealing with virtual addresses. It's a neat idea.

I'm going to take a look at that this week to see whether we can do something similar for x86, because no doubt we're going to want to map more tables in the future (right now we have the ESRT and memmap tables).

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#4 lore raw

PATCH 1/1 efi: Add esrt support.

In reply to a message not in the archive

Add sysfs files for the EFI System Resource Table (ESRT) under /sys/firmware/efi/esrt and for each EFI System Resource Entry under entries/ as a subdir.

The EFI System Resource Table (ESRT) provides a read-only catalog of system components for which the system accepts firmware upgrades via UEFI's "Capsule Update" feature. This module allows userland utilities to evaluate what firmware updates can be applied to this system, and potentially arrange for those updates to occur.

The ESRT is described as part of the UEFI specification, in version 2.5 which should be available from http://uefi.org/specifications in early 2015. If you're a member of the UEFI Forum, information about its addition to the standard is available as UEFI Mantis 1090.

For some hardware platforms, additional restrictions may be found at
http://msdn.microsoft.com/en-us/library/windows/hardware/jj128256.aspx , and additional documentation may be found at
http://download.microsoft.com/download/5/F/5/5F5D16CD-2530-4289-8019-94C6A20BED3C/windows-uefi-firmware-update-platform.docx
.

---
 drivers/firmware/efi/Makefile |   2 +-
 drivers/firmware/efi/efi.c    |  63 ++++++-
 drivers/firmware/efi/esrt.c   | 402 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/efi.h           |   7 +
 4 files changed, 472 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/efi/esrt.c
drivers/firmware/efi/Makefile +1 -1
index d8be608..26eabbc 100644
@@ -1,7 +1,7 @@
 #
 # Makefile for linux kernel
 #
-obj-$(CONFIG_EFI)			+= efi.o vars.o reboot.o
+obj-$(CONFIG_EFI)			+= efi.o esrt.o vars.o reboot.o
 obj-$(CONFIG_EFI_VARS)			+= efivars.o
 obj-$(CONFIG_EFI_VARS_PSTORE)		+= efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)			+= cper.o
drivers/firmware/efi/efi.c +62 -1

93 lines not on this page · raw message

drivers/firmware/efi/esrt.c new file +402 -0

402 lines not on this page · raw message

include/linux/efi.h +7 -0
index 0238d61..094d14c 100644
@@ -565,6 +565,9 @@ void efi_native_runtime_setup(void);
 #define UV_SYSTEM_TABLE_GUID \
     EFI_GUID(  0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 )
 
+#define EFI_SYSTEM_RESOURCE_TABLE_GUID \
+    EFI_GUID(  0xb122a263, 0x3661, 0x4f68, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 )
+
 #define LINUX_EFI_CRASH_GUID \
     EFI_GUID(  0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 )
 
@@ -823,6 +826,7 @@ extern struct efi {
 	unsigned long fw_vendor;	/* fw_vendor */
 	unsigned long runtime;		/* runtime table */
 	unsigned long config_table;	/* config tables */
+	unsigned long esrt;		/* EFI System Resource Table */
 	efi_get_time_t *get_time;
 	efi_set_time_t *set_time;
 	efi_get_wakeup_time_t *get_wakeup_time;
@@ -880,12 +884,15 @@ extern u32 efi_mem_type (unsigned long phys_addr);
 extern u64 efi_mem_attributes (unsigned long phys_addr);
 extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
 extern int __init efi_uart_console_only (void);
+extern u64 efi_mem_desc_end(efi_memory_desc_t *md);
+extern int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md);
 extern void efi_initialize_iomem_resources(struct resource *code_resource,
 		struct resource *data_resource, struct resource *bss_resource);
 extern void efi_get_time(struct timespec *now);
 extern void efi_reserve_boot_services(void);
 extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose);
 extern struct efi_memory_map memmap;
+extern struct kobject *efi_kobj;
 
 extern int efi_reboot_quirk_mode;
 extern bool efi_poweroff_required(void);
Signature · 1 line
2.1.0
#6 lore raw
In reply to a message not in the archive
Quoted 29 lines · Peter Jones

Add sysfs files for the EFI System Resource Table (ESRT) under /sys/firmware/efi/esrt and for each EFI System Resource Entry under entries/ as a subdir.

The EFI System Resource Table (ESRT) provides a read-only catalog of system components for which the system accepts firmware upgrades via UEFI's "Capsule Update" feature. This module allows userland utilities to evaluate what firmware updates can be applied to this system, and potentially arrange for those updates to occur.

The ESRT is described as part of the UEFI specification, in version 2.5 which should be available from http://uefi.org/specifications in early 2015. If you're a member of the UEFI Forum, information about its addition to the standard is available as UEFI Mantis 1090.

For some hardware platforms, additional restrictions may be found at
http://msdn.microsoft.com/en-us/library/windows/hardware/jj128256.aspx , and additional documentation may be found at
http://download.microsoft.com/download/5/F/5/5F5D16CD-2530-4289-8019-94C6A20BED3C/windows-uefi-firmware-update-platform.docx
.

---
 drivers/firmware/efi/Makefile |   2 +-
 drivers/firmware/efi/efi.c    |  63 ++++++-
 drivers/firmware/efi/esrt.c   | 402 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/efi.h           |   7 +
 4 files changed, 472 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/efi/esrt.c

[...]

Quoted 9 lines
drivers/firmware/efi/esrt.c new file +9 -0
+/*
+ * ioremap the table, copy it to kmalloced pages, and unmap it.
+ */
+static int esrt_duplicate_pages(void)
+{
+	struct efi_system_resource_table *tmpesrt;
+	struct efi_system_resource_entry *entries;
+	size_t size, max;
+	efi_memory_desc_t md;

drivers/firmware/efi/esrt.c line 245

Quoted 10 lines
drivers/firmware/efi/esrt.c new file +10 -0
+	int err = -EINVAL;
+	int rc;
+
+	if (!esrt_table_exists())
+		return err;
+
+	rc = efi_mem_desc_lookup(efi.esrt, &md);
+	if (rc < 0) {
+		pr_err("ESRT header is not in the memory map.\n");
+		return err;

Probably wanna return 'rc' here? Since efi_mem_desc_lookup() now may return -ENOENT or -EINVAL on failure.

Quoted 4 lines
drivers/firmware/efi/esrt.c new file +4 -0
+	}
+
+	max = efi_mem_desc_end(&md);
+	if (max < 0) {

drivers/firmware/efi/esrt.c line 259

Quoted 10 lines
drivers/firmware/efi/esrt.c new file +10 -0
+		pr_err("EFI memory descriptor is invalid.\n");
+		return err;
+	}
+
+	size = sizeof(*esrt);
+
+	if (max < size) {
+		pr_err("ESRT header doen't fit on single memory map entry.\n");
+		return err;
+	}

This doesn't look right. You're comparing an address 'max' and a size 'size'. Unless we have memory descriptors at address 0x0, this condition will never be false.

drivers/firmware/efi/esrt.c line 270

Quoted 11 lines
drivers/firmware/efi/esrt.c new file +11 -0
+
+	tmpesrt = ioremap(efi.esrt, size);
+	if (!tmpesrt) {
+		pr_err("ioremap failed.\n");
+		return -ENOMEM;
+	}
+
+	if (tmpesrt->fw_resource_count > 0 && max - size < sizeof(*entries)) {
+		pr_err("ESRT memory map entry can only hold the header.\n");
+		goto err_iounmap;
+	}

Ditto. Is this ever going to be false?

Quoted 12 lines
drivers/firmware/efi/esrt.c new file +12 -0
+	/*
+	 * The format doesn't really give us any boundary to test here,
+	 * so I'm making up 128 as the max number of individually updatable
+	 * components we support.
+	 * 128 should be pretty excessive, but there's still some chance
+	 * somebody will do that someday and we'll need to raise this.
+	 */
+	if (tmpesrt->fw_resource_count > 128) {
+		pr_err("ESRT says fw_resource_count has very large value %d.\n",
+		       tmpesrt->fw_resource_count);
+		goto err_iounmap;
+	}

drivers/firmware/efi/esrt.c line 293

Quoted 10 lines
drivers/firmware/efi/esrt.c new file +10 -0
+
+	/*
+	 * We know it can't be larger than N * sizeof() here, and N is limited
+	 * by the previous test to a small number, so there's no overflow.
+	 */
+	size += tmpesrt->fw_resource_count * sizeof(*entries);
+	if (max < size) {
+		pr_err("ESRT does not fit on single memory map entry.\n");
+		goto err_iounmap;
+	}

Ditto^2

Quoted 12 lines
drivers/firmware/efi/esrt.c new file +12 -0
+	esrt = kmalloc(size, GFP_KERNEL);
+	if (!esrt) {
+		err = -ENOMEM;
+		goto err_iounmap;
+	}
+
+	memcpy(esrt, tmpesrt, size);
+	err = 0;
+err_iounmap:
+	iounmap(tmpesrt);
+	return err;
+}

drivers/firmware/efi/esrt.c line 316

Quoted 10 lines
drivers/firmware/efi/esrt.c new file +10 -0
+
+static int register_entries(void)
+{
+	struct efi_system_resource_entry *entries = esrt->entries;
+	int i, rc;
+
+	if (!esrt_table_exists())
+		return 0;
+
+	for (i = 0; i < le32_to_cpu(esrt->fw_resource_count); i++) {

This caught my eye. Do any of the architectures with UEFI support running in big endian mode?

Signature · 1 line
Matt Fleming, Intel Open Source Technology Center
#8 lore raw
In reply to a message not in the archive
Quoted 47 lines · Matt Fleming
Quoted 29 lines · Peter Jones

Add sysfs files for the EFI System Resource Table (ESRT) under /sys/firmware/efi/esrt and for each EFI System Resource Entry under entries/ as a subdir.

The EFI System Resource Table (ESRT) provides a read-only catalog of system components for which the system accepts firmware upgrades via UEFI's "Capsule Update" feature. This module allows userland utilities to evaluate what firmware updates can be applied to this system, and potentially arrange for those updates to occur.

The ESRT is described as part of the UEFI specification, in version 2.5 which should be available from http://uefi.org/specifications in early 2015. If you're a member of the UEFI Forum, information about its addition to the standard is available as UEFI Mantis 1090.

For some hardware platforms, additional restrictions may be found at
http://msdn.microsoft.com/en-us/library/windows/hardware/jj128256.aspx , and additional documentation may be found at
http://download.microsoft.com/download/5/F/5/5F5D16CD-2530-4289-8019-94C6A20BED3C/windows-uefi-firmware-update-platform.docx
.

---
 drivers/firmware/efi/Makefile |   2 +-
 drivers/firmware/efi/efi.c    |  63 ++++++-
 drivers/firmware/efi/esrt.c   | 402 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/efi.h           |   7 +
 4 files changed, 472 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/efi/esrt.c

[...]

Quoted 14 lines
drivers/firmware/efi/esrt.c new file +14 -0
+/*
+ * ioremap the table, copy it to kmalloced pages, and unmap it.
+ */
+static int esrt_duplicate_pages(void)
+{
+	struct efi_system_resource_table *tmpesrt;
+	struct efi_system_resource_entry *entries;
+	size_t size, max;
+	efi_memory_desc_t md;
+	int err = -EINVAL;
+	int rc;
+
+	if (!esrt_table_exists())
+		return err;
Quoted 8 lines

drivers/firmware/efi/esrt.c line 245

Quoted 5 lines
drivers/firmware/efi/esrt.c new file +5 -0
+
+	rc = efi_mem_desc_lookup(efi.esrt, &md);
+	if (rc < 0) {
+		pr_err("ESRT header is not in the memory map.\n");
+		return err;

Probably wanna return 'rc' here? Since efi_mem_desc_lookup() now may return -ENOENT or -EINVAL on failure.

Yeah, sure.

Quoted 10 lines
Quoted 10 lines
drivers/firmware/efi/esrt.c new file +10 -0
+	}
+
+	max = efi_mem_desc_end(&md);
+	if (max < 0) {
+		pr_err("EFI memory descriptor is invalid.\n");
+		return err;
+	}
+
+	size = sizeof(*esrt);
+
Quoted 8 lines

drivers/firmware/efi/esrt.c line 259

Quoted 4 lines
drivers/firmware/efi/esrt.c new file +4 -0
+	if (max < size) {
+		pr_err("ESRT header doen't fit on single memory map entry.\n");
+		return err;
+	}

This doesn't look right. You're comparing an address 'max' and a size 'size'. Unless we have memory descriptors at address 0x0, this condition will never be false.

Right you are.

Quoted 5 lines
Quoted 5 lines
drivers/firmware/efi/esrt.c new file +5 -0
+
+	tmpesrt = ioremap(efi.esrt, size);
+	if (!tmpesrt) {
+		pr_err("ioremap failed.\n");
+		return -ENOMEM;
Quoted 8 lines

drivers/firmware/efi/esrt.c line 270

Quoted 6 lines
drivers/firmware/efi/esrt.c new file +6 -0
+	}
+
+	if (tmpesrt->fw_resource_count > 0 && max - size < sizeof(*entries)) {
+		pr_err("ESRT memory map entry can only hold the header.\n");
+		goto err_iounmap;
+	}

Ditto. Is this ever going to be false?

Clearly in my mind's eye there was a "max -= efi.esrt;" up above somewhere.

Quoted 16 lines
Quoted 16 lines
drivers/firmware/efi/esrt.c new file +16 -0
+	/*
+	 * The format doesn't really give us any boundary to test here,
+	 * so I'm making up 128 as the max number of individually updatable
+	 * components we support.
+	 * 128 should be pretty excessive, but there's still some chance
+	 * somebody will do that someday and we'll need to raise this.
+	 */
+	if (tmpesrt->fw_resource_count > 128) {
+		pr_err("ESRT says fw_resource_count has very large value %d.\n",
+		       tmpesrt->fw_resource_count);
+		goto err_iounmap;
+	}
+
+	/*
+	 * We know it can't be larger than N * sizeof() here, and N is limited
+	 * by the previous test to a small number, so there's no overflow.
Quoted 8 lines

drivers/firmware/efi/esrt.c line 293

Quoted 6 lines
drivers/firmware/efi/esrt.c new file +6 -0
+	 */
+	size += tmpesrt->fw_resource_count * sizeof(*entries);
+	if (max < size) {
+		pr_err("ESRT does not fit on single memory map entry.\n");
+		goto err_iounmap;
+	}

Ditto^2

Likewise.

Quoted 4 lines

drivers/firmware/efi/esrt.c line 316

Quoted 1 line
drivers/firmware/efi/esrt.c new file +1 -0
+	for (i = 0; i < le32_to_cpu(esrt->fw_resource_count); i++) {

This caught my eye. Do any of the architectures with UEFI support running in big endian mode?

All EFI data is defined as being little endian unless expressly defined otherwise by UEFI 1.8.1 , which also defines UEFI implementations as using little endian processor modes. There's also a lot of text in the per-arch bits that says the same thing.

So there aren't, and there won't be without some major changes everywhere else.

Signature · 1 line
        Peter
#9 lore raw

PATCH 1/1 efi: Add esrt support.

In reply to a message not in the archive

Add sysfs files for the EFI System Resource Table (ESRT) under /sys/firmware/efi/esrt and for each EFI System Resource Entry under entries/ as a subdir.

The EFI System Resource Table (ESRT) provides a read-only catalog of system components for which the system accepts firmware upgrades via UEFI's "Capsule Update" feature. This module allows userland utilities to evaluate what firmware updates can be applied to this system, and potentially arrange for those updates to occur.

The ESRT is described as part of the UEFI specification, in version 2.5 which should be available from http://uefi.org/specifications in early 2015. If you're a member of the UEFI Forum, information about its addition to the standard is available as UEFI Mantis 1090.

For some hardware platforms, additional restrictions may be found at
http://msdn.microsoft.com/en-us/library/windows/hardware/jj128256.aspx , and additional documentation may be found at
http://download.microsoft.com/download/5/F/5/5F5D16CD-2530-4289-8019-94C6A20BED3C/windows-uefi-firmware-update-platform.docx
.

---
 drivers/firmware/efi/Makefile |   2 +-
 drivers/firmware/efi/efi.c    |  63 ++++++-
 drivers/firmware/efi/esrt.c   | 402 ++++++++++++++++++++++++++++++++++++++++++
 include/linux/efi.h           |   7 +
 4 files changed, 472 insertions(+), 2 deletions(-)
 create mode 100644 drivers/firmware/efi/esrt.c
drivers/firmware/efi/Makefile +1 -1
index d8be608..26eabbc 100644
@@ -1,7 +1,7 @@
 #
 # Makefile for linux kernel
 #
-obj-$(CONFIG_EFI)			+= efi.o vars.o reboot.o
+obj-$(CONFIG_EFI)			+= efi.o esrt.o vars.o reboot.o
 obj-$(CONFIG_EFI_VARS)			+= efivars.o
 obj-$(CONFIG_EFI_VARS_PSTORE)		+= efi-pstore.o
 obj-$(CONFIG_UEFI_CPER)			+= cper.o
drivers/firmware/efi/efi.c +62 -1

93 lines not on this page · raw message

drivers/firmware/efi/esrt.c new file +402 -0

402 lines not on this page · raw message

include/linux/efi.h +7 -0
index 0238d61..094d14c 100644
@@ -565,6 +565,9 @@ void efi_native_runtime_setup(void);
 #define UV_SYSTEM_TABLE_GUID \
     EFI_GUID(  0x3b13a7d4, 0x633e, 0x11dd, 0x93, 0xec, 0xda, 0x25, 0x56, 0xd8, 0x95, 0x93 )
 
+#define EFI_SYSTEM_RESOURCE_TABLE_GUID \
+    EFI_GUID(  0xb122a263, 0x3661, 0x4f68, 0x99, 0x29, 0x78, 0xf8, 0xb0, 0xd6, 0x21, 0x80 )
+
 #define LINUX_EFI_CRASH_GUID \
     EFI_GUID(  0xcfc8fc79, 0xbe2e, 0x4ddc, 0x97, 0xf0, 0x9f, 0x98, 0xbf, 0xe2, 0x98, 0xa0 )
 
@@ -823,6 +826,7 @@ extern struct efi {
 	unsigned long fw_vendor;	/* fw_vendor */
 	unsigned long runtime;		/* runtime table */
 	unsigned long config_table;	/* config tables */
+	unsigned long esrt;		/* EFI System Resource Table */
 	efi_get_time_t *get_time;
 	efi_set_time_t *set_time;
 	efi_get_wakeup_time_t *get_wakeup_time;
@@ -880,12 +884,15 @@ extern u32 efi_mem_type (unsigned long phys_addr);
 extern u64 efi_mem_attributes (unsigned long phys_addr);
 extern u64 efi_mem_attribute (unsigned long phys_addr, unsigned long size);
 extern int __init efi_uart_console_only (void);
+extern u64 efi_mem_desc_end(efi_memory_desc_t *md);
+extern int efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md);
 extern void efi_initialize_iomem_resources(struct resource *code_resource,
 		struct resource *data_resource, struct resource *bss_resource);
 extern void efi_get_time(struct timespec *now);
 extern void efi_reserve_boot_services(void);
 extern int efi_get_fdt_params(struct efi_fdt_params *params, int verbose);
 extern struct efi_memory_map memmap;
+extern struct kobject *efi_kobj;
 
 extern int efi_reboot_quirk_mode;
 extern bool efi_poweroff_required(void);
Signature · 1 line
2.1.0