Sfoglia il codice sorgente

efi/esrt: Use efi_mem_reserve() and avoid a kmalloc()

We can use the new efi_mem_reserve() API to mark the ESRT table as
reserved forever and save ourselves the trouble of copying the data
out into a kmalloc buffer.

The added advantage is that now the ESRT driver will work across
kexec reboot.

Tested-by: Dave Young <dyoung@redhat.com> [kexec/kdump]
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> [arm]
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Peter Jones <pjones@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Matt Fleming 9 anni fa
parent
commit
8e80632fb2
1 ha cambiato i file con 4 aggiunte e 16 eliminazioni
  1. 4 16
      drivers/firmware/efi/esrt.c

+ 4 - 16
drivers/firmware/efi/esrt.c

@@ -235,7 +235,7 @@ static struct attribute_group esrt_attr_group = {
 };
 };
 
 
 /*
 /*
- * remap the table, copy it to kmalloced pages, and unmap it.
+ * remap the table, validate it, mark it reserved and unmap it.
  */
  */
 void __init efi_esrt_init(void)
 void __init efi_esrt_init(void)
 {
 {
@@ -335,7 +335,7 @@ void __init efi_esrt_init(void)
 
 
 	end = esrt_data + size;
 	end = esrt_data + size;
 	pr_info("Reserving ESRT space from %pa to %pa.\n", &esrt_data, &end);
 	pr_info("Reserving ESRT space from %pa to %pa.\n", &esrt_data, &end);
-	memblock_reserve(esrt_data, esrt_data_size);
+	efi_mem_reserve(esrt_data, esrt_data_size);
 
 
 	pr_debug("esrt-init: loaded.\n");
 	pr_debug("esrt-init: loaded.\n");
 err_memunmap:
 err_memunmap:
@@ -382,28 +382,18 @@ static void cleanup_entry_list(void)
 static int __init esrt_sysfs_init(void)
 static int __init esrt_sysfs_init(void)
 {
 {
 	int error;
 	int error;
-	struct efi_system_resource_table __iomem *ioesrt;
 
 
 	pr_debug("esrt-sysfs: loading.\n");
 	pr_debug("esrt-sysfs: loading.\n");
 	if (!esrt_data || !esrt_data_size)
 	if (!esrt_data || !esrt_data_size)
 		return -ENOSYS;
 		return -ENOSYS;
 
 
-	ioesrt = ioremap(esrt_data, esrt_data_size);
-	if (!ioesrt) {
+	esrt = ioremap(esrt_data, esrt_data_size);
+	if (!esrt) {
 		pr_err("ioremap(%pa, %zu) failed.\n", &esrt_data,
 		pr_err("ioremap(%pa, %zu) failed.\n", &esrt_data,
 		       esrt_data_size);
 		       esrt_data_size);
 		return -ENOMEM;
 		return -ENOMEM;
 	}
 	}
 
 
-	esrt = kmalloc(esrt_data_size, GFP_KERNEL);
-	if (!esrt) {
-		pr_err("kmalloc failed. (wanted %zu bytes)\n", esrt_data_size);
-		iounmap(ioesrt);
-		return -ENOMEM;
-	}
-
-	memcpy_fromio(esrt, ioesrt, esrt_data_size);
-
 	esrt_kobj = kobject_create_and_add("esrt", efi_kobj);
 	esrt_kobj = kobject_create_and_add("esrt", efi_kobj);
 	if (!esrt_kobj) {
 	if (!esrt_kobj) {
 		pr_err("Firmware table registration failed.\n");
 		pr_err("Firmware table registration failed.\n");
@@ -429,8 +419,6 @@ static int __init esrt_sysfs_init(void)
 	if (error)
 	if (error)
 		goto err_cleanup_list;
 		goto err_cleanup_list;
 
 
-	memblock_remove(esrt_data, esrt_data_size);
-
 	pr_debug("esrt-sysfs: loaded.\n");
 	pr_debug("esrt-sysfs: loaded.\n");
 
 
 	return 0;
 	return 0;