Skip to contentSkip to conversation

efi/arm*: wire up ESRT table

PATCH New Ard Biesheuvel 2 participants 5 messages Jul 11, 2016 – Jul 15, 2016 EFI

lore
Share & tools
lore
#0 lore raw

v2 cover efi/arm*: wire up ESRT table

This v2 is a followup to the series I sent out on Feb 15. These now apply onto Matt's memmap refactoring work which is intended for inclusion in v4.9, and the diffstat below reveals that enabling ESRT is now absolutely trivial. The only things needed are replacing ioremap() with memremap(), and adding the missing efi_esrt_init() invocation.

I dropped the Tested-by tags, simply because the underlying code is completely different now. I kept Peter's ack on #1, though.

Ard Biesheuvel (2):
efi: esrt: use memremap not ioremap to access ESRT table in memory efi/arm*: esrt: add missing call to efi_esrt_init()

 drivers/firmware/efi/arm-init.c | 1 +
 drivers/firmware/efi/esrt.c     | 5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/2 efi: esrt: use memremap not ioremap to access ESRT table in memory

On ARM and arm64, ioremap() and memremap() are not interchangeable like on x86, and the use of ioremap() on ordinary RAM is typically flagged as an error if the memory region being mapped is also covered by the linear mapping, since that would lead to aliases with conflicting cacheability attributes.

Since what we are dealing with is not an I/O region with side effects, using ioremap() here is arguably incorrect anyway, so let's replace it with memremap() instead.

---
 drivers/firmware/efi/esrt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/firmware/efi/esrt.c +3 -2
index b93cd11f9bcc..14914074f716 100644
@@ -16,6 +16,7 @@
 #include <linux/device.h>
 #include <linux/efi.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/kernel.h>
 #include <linux/kobject.h>
 #include <linux/list.h>
@@ -387,9 +388,9 @@ static int __init esrt_sysfs_init(void)
 	if (!esrt_data || !esrt_data_size)
 		return -ENOSYS;
 
-	esrt = ioremap(esrt_data, esrt_data_size);
+	esrt = memremap(esrt_data, esrt_data_size, MEMREMAP_WB);
 	if (!esrt) {
-		pr_err("ioremap(%pa, %zu) failed.\n", &esrt_data,
+		pr_err("memremap(%pa, %zu) failed.\n", &esrt_data,
 		       esrt_data_size);
 		return -ENOMEM;
 	}
Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/2 efi: esrt: use memremap not ioremap to access ESRT table in memory

Quoted 10 lines · Ard Biesheuvel

On ARM and arm64, ioremap() and memremap() are not interchangeable like on x86, and the use of ioremap() on ordinary RAM is typically flagged as an error if the memory region being mapped is also covered by the linear mapping, since that would lead to aliases with conflicting cacheability attributes.

Since what we are dealing with is not an I/O region with side effects, using ioremap() here is arguably incorrect anyway, so let's replace it with memremap() instead.

Quoted 5 lines
---
 drivers/firmware/efi/esrt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Looks sensible, thanks Ard, applied.

#3 lore raw

PATCH v2 2/2 efi/arm*: esrt: add missing call to efi_esrt_init()

In reply to Ard Biesheuvel

ESRT support is built by default for all architectures that define CONFIG_EFI. However, this support was not wired up yet for ARM/arm64, since efi_esrt_init() was never called. So add the missing call.

---
 drivers/firmware/efi/arm-init.c | 1 +
 1 file changed, 1 insertion(+)
drivers/firmware/efi/arm-init.c +1 -0
index 5a2df3fefccc..e0a511d4074f 100644
@@ -247,6 +247,7 @@ void __init efi_init(void)
 
 	reserve_regions();
 	efi_memattr_init();
+	efi_esrt_init();
 	efi_memmap_unmap();
 
 	memblock_reserve(params.mmap & PAGE_MASK,
Signature · 1 line
1.9.1
#4 lore raw

PATCH v2 2/2 efi/arm*: esrt: add missing call to efi_esrt_init()

Quoted 8 lines · Ard Biesheuvel

ESRT support is built by default for all architectures that define CONFIG_EFI. However, this support was not wired up yet for ARM/arm64, since efi_esrt_init() was never called. So add the missing call.

---
 drivers/firmware/efi/arm-init.c | 1 +
 1 file changed, 1 insertion(+)

Thanks Ard, applied and queued up for v4.9 on top of the EFI memmap refactoring.