Skip to content

Commit abc93f8

Browse files
Daniel KiperMatt Fleming
authored andcommitted
efi: Use early_mem*() instead of early_io*()
Use early_mem*() instead of early_io*() because all mapped EFI regions are memory (usually RAM but they could also be ROM, EPROM, EEPROM, flash, etc.) not I/O regions. Additionally, I/O family calls do not work correctly under Xen in our case. early_ioremap() skips the PFN to MFN conversion when building the PTE. Using it for memory will attempt to map the wrong machine frame. However, all artificial EFI structures created under Xen live in dom0 memory and should be mapped/unmapped using early_mem*() family calls which map domain memory. Signed-off-by: Daniel Kiper <daniel.kiper@oracle.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Mark Salter <msalter@redhat.com> Signed-off-by: Matt Fleming <matt.fleming@intel.com>
1 parent 4fa6248 commit abc93f8

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

  • arch/x86/platform/efi
  • drivers/firmware/efi

‎arch/x86/platform/efi/efi.c‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ void __init efi_unmap_memmap(void)
256256
{
257257
clear_bit(EFI_MEMMAP, &efi.flags);
258258
if (memmap.map) {
259-
early_iounmap(memmap.map, memmap.nr_map * memmap.desc_size);
259+
early_memunmap(memmap.map, memmap.nr_map * memmap.desc_size);
260260
memmap.map = NULL;
261261
}
262262
}
@@ -273,12 +273,12 @@ static int __init efi_systab_init(void *phys)
273273
if (!data)
274274
return -ENOMEM;
275275
}
276-
systab64 = early_ioremap((unsigned long)phys,
276+
systab64 = early_memremap((unsigned long)phys,
277277
sizeof(*systab64));
278278
if (systab64 == NULL) {
279279
pr_err("Couldn't map the system table!\n");
280280
if (data)
281-
early_iounmap(data, sizeof(*data));
281+
early_memunmap(data, sizeof(*data));
282282
return -ENOMEM;
283283
}
284284

@@ -310,9 +310,9 @@ static int __init efi_systab_init(void *phys)
310310
systab64->tables;
311311
tmp |= data ? data->tables : systab64->tables;
312312

313-
early_iounmap(systab64, sizeof(*systab64));
313+
early_memunmap(systab64, sizeof(*systab64));
314314
if (data)
315-
early_iounmap(data, sizeof(*data));
315+
early_memunmap(data, sizeof(*data));
316316
#ifdef CONFIG_X86_32
317317
if (tmp >> 32) {
318318
pr_err("EFI data located above 4GB, disabling EFI.\n");
@@ -322,7 +322,7 @@ static int __init efi_systab_init(void *phys)
322322
} else {
323323
efi_system_table_32_t *systab32;
324324

325-
systab32 = early_ioremap((unsigned long)phys,
325+
systab32 = early_memremap((unsigned long)phys,
326326
sizeof(*systab32));
327327
if (systab32 == NULL) {
328328
pr_err("Couldn't map the system table!\n");
@@ -343,7 +343,7 @@ static int __init efi_systab_init(void *phys)
343343
efi_systab.nr_tables = systab32->nr_tables;
344344
efi_systab.tables = systab32->tables;
345345

346-
early_iounmap(systab32, sizeof(*systab32));
346+
early_memunmap(systab32, sizeof(*systab32));
347347
}
348348

349349
efi.systab = &efi_systab;
@@ -369,7 +369,7 @@ static int __init efi_runtime_init32(void)
369369
{
370370
efi_runtime_services_32_t *runtime;
371371

372-
runtime = early_ioremap((unsigned long)efi.systab->runtime,
372+
runtime = early_memremap((unsigned long)efi.systab->runtime,
373373
sizeof(efi_runtime_services_32_t));
374374
if (!runtime) {
375375
pr_err("Could not map the runtime service table!\n");
@@ -384,7 +384,7 @@ static int __init efi_runtime_init32(void)
384384
efi_phys.set_virtual_address_map =
385385
(efi_set_virtual_address_map_t *)
386386
(unsigned long)runtime->set_virtual_address_map;
387-
early_iounmap(runtime, sizeof(efi_runtime_services_32_t));
387+
early_memunmap(runtime, sizeof(efi_runtime_services_32_t));
388388

389389
return 0;
390390
}
@@ -393,7 +393,7 @@ static int __init efi_runtime_init64(void)
393393
{
394394
efi_runtime_services_64_t *runtime;
395395

396-
runtime = early_ioremap((unsigned long)efi.systab->runtime,
396+
runtime = early_memremap((unsigned long)efi.systab->runtime,
397397
sizeof(efi_runtime_services_64_t));
398398
if (!runtime) {
399399
pr_err("Could not map the runtime service table!\n");
@@ -408,7 +408,7 @@ static int __init efi_runtime_init64(void)
408408
efi_phys.set_virtual_address_map =
409409
(efi_set_virtual_address_map_t *)
410410
(unsigned long)runtime->set_virtual_address_map;
411-
early_iounmap(runtime, sizeof(efi_runtime_services_64_t));
411+
early_memunmap(runtime, sizeof(efi_runtime_services_64_t));
412412

413413
return 0;
414414
}
@@ -439,7 +439,7 @@ static int __init efi_runtime_init(void)
439439
static int __init efi_memmap_init(void)
440440
{
441441
/* Map the EFI memory map */
442-
memmap.map = early_ioremap((unsigned long)memmap.phys_map,
442+
memmap.map = early_memremap((unsigned long)memmap.phys_map,
443443
memmap.nr_map * memmap.desc_size);
444444
if (memmap.map == NULL) {
445445
pr_err("Could not map the memory map!\n");
@@ -487,14 +487,14 @@ void __init efi_init(void)
487487
/*
488488
* Show what we know for posterity
489489
*/
490-
c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2);
490+
c16 = tmp = early_memremap(efi.systab->fw_vendor, 2);
491491
if (c16) {
492492
for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
493493
vendor[i] = *c16++;
494494
vendor[i] = '\0';
495495
} else
496496
pr_err("Could not map the firmware vendor!\n");
497-
early_iounmap(tmp, 2);
497+
early_memunmap(tmp, 2);
498498

499499
pr_info("EFI v%u.%.02u by %s\n",
500500
efi.systab->hdr.revision >> 16,

‎drivers/firmware/efi/efi.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
298298
if (table64 >> 32) {
299299
pr_cont("\n");
300300
pr_err("Table located above 4GB, disabling EFI.\n");
301-
early_iounmap(config_tables,
301+
early_memunmap(config_tables,
302302
efi.systab->nr_tables * sz);
303303
return -EINVAL;
304304
}
@@ -314,7 +314,7 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
314314
tablep += sz;
315315
}
316316
pr_cont("\n");
317-
early_iounmap(config_tables, efi.systab->nr_tables * sz);
317+
early_memunmap(config_tables, efi.systab->nr_tables * sz);
318318

319319
set_bit(EFI_CONFIG_TABLES, &efi.flags);
320320

0 commit comments

Comments
 (0)