aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Kiper <daniel.kiper@oracle.com>2014-06-30 13:52:56 -0400
committerMatt Fleming <matt.fleming@intel.com>2014-07-18 16:23:54 -0400
commitabc93f8eb6e46a480485f19256bdbda36ec78a84 (patch)
treee12ae6d90ab8682dea7dc61980f0d086e9af66a0
parent4fa62481e231111373418f0d95dd1f24f6e83321 (diff)
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>
-rw-r--r--arch/x86/platform/efi/efi.c28
-rw-r--r--drivers/firmware/efi/efi.c4
2 files changed, 16 insertions, 16 deletions
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 135812b593cc..b40597209623 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -256,7 +256,7 @@ void __init efi_unmap_memmap(void)
256{ 256{
257 clear_bit(EFI_MEMMAP, &efi.flags); 257 clear_bit(EFI_MEMMAP, &efi.flags);
258 if (memmap.map) { 258 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);
260 memmap.map = NULL; 260 memmap.map = NULL;
261 } 261 }
262} 262}
@@ -273,12 +273,12 @@ static int __init efi_systab_init(void *phys)
273 if (!data) 273 if (!data)
274 return -ENOMEM; 274 return -ENOMEM;
275 } 275 }
276 systab64 = early_ioremap((unsigned long)phys, 276 systab64 = early_memremap((unsigned long)phys,
277 sizeof(*systab64)); 277 sizeof(*systab64));
278 if (systab64 == NULL) { 278 if (systab64 == NULL) {
279 pr_err("Couldn't map the system table!\n"); 279 pr_err("Couldn't map the system table!\n");
280 if (data) 280 if (data)
281 early_iounmap(data, sizeof(*data)); 281 early_memunmap(data, sizeof(*data));
282 return -ENOMEM; 282 return -ENOMEM;
283 } 283 }
284 284
@@ -310,9 +310,9 @@ static int __init efi_systab_init(void *phys)
310 systab64->tables; 310 systab64->tables;
311 tmp |= data ? data->tables : systab64->tables; 311 tmp |= data ? data->tables : systab64->tables;
312 312
313 early_iounmap(systab64, sizeof(*systab64)); 313 early_memunmap(systab64, sizeof(*systab64));
314 if (data) 314 if (data)
315 early_iounmap(data, sizeof(*data)); 315 early_memunmap(data, sizeof(*data));
316#ifdef CONFIG_X86_32 316#ifdef CONFIG_X86_32
317 if (tmp >> 32) { 317 if (tmp >> 32) {
318 pr_err("EFI data located above 4GB, disabling EFI.\n"); 318 pr_err("EFI data located above 4GB, disabling EFI.\n");
@@ -322,7 +322,7 @@ static int __init efi_systab_init(void *phys)
322 } else { 322 } else {
323 efi_system_table_32_t *systab32; 323 efi_system_table_32_t *systab32;
324 324
325 systab32 = early_ioremap((unsigned long)phys, 325 systab32 = early_memremap((unsigned long)phys,
326 sizeof(*systab32)); 326 sizeof(*systab32));
327 if (systab32 == NULL) { 327 if (systab32 == NULL) {
328 pr_err("Couldn't map the system table!\n"); 328 pr_err("Couldn't map the system table!\n");
@@ -343,7 +343,7 @@ static int __init efi_systab_init(void *phys)
343 efi_systab.nr_tables = systab32->nr_tables; 343 efi_systab.nr_tables = systab32->nr_tables;
344 efi_systab.tables = systab32->tables; 344 efi_systab.tables = systab32->tables;
345 345
346 early_iounmap(systab32, sizeof(*systab32)); 346 early_memunmap(systab32, sizeof(*systab32));
347 } 347 }
348 348
349 efi.systab = &efi_systab; 349 efi.systab = &efi_systab;
@@ -369,7 +369,7 @@ static int __init efi_runtime_init32(void)
369{ 369{
370 efi_runtime_services_32_t *runtime; 370 efi_runtime_services_32_t *runtime;
371 371
372 runtime = early_ioremap((unsigned long)efi.systab->runtime, 372 runtime = early_memremap((unsigned long)efi.systab->runtime,
373 sizeof(efi_runtime_services_32_t)); 373 sizeof(efi_runtime_services_32_t));
374 if (!runtime) { 374 if (!runtime) {
375 pr_err("Could not map the runtime service table!\n"); 375 pr_err("Could not map the runtime service table!\n");
@@ -384,7 +384,7 @@ static int __init efi_runtime_init32(void)
384 efi_phys.set_virtual_address_map = 384 efi_phys.set_virtual_address_map =
385 (efi_set_virtual_address_map_t *) 385 (efi_set_virtual_address_map_t *)
386 (unsigned long)runtime->set_virtual_address_map; 386 (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));
388 388
389 return 0; 389 return 0;
390} 390}
@@ -393,7 +393,7 @@ static int __init efi_runtime_init64(void)
393{ 393{
394 efi_runtime_services_64_t *runtime; 394 efi_runtime_services_64_t *runtime;
395 395
396 runtime = early_ioremap((unsigned long)efi.systab->runtime, 396 runtime = early_memremap((unsigned long)efi.systab->runtime,
397 sizeof(efi_runtime_services_64_t)); 397 sizeof(efi_runtime_services_64_t));
398 if (!runtime) { 398 if (!runtime) {
399 pr_err("Could not map the runtime service table!\n"); 399 pr_err("Could not map the runtime service table!\n");
@@ -408,7 +408,7 @@ static int __init efi_runtime_init64(void)
408 efi_phys.set_virtual_address_map = 408 efi_phys.set_virtual_address_map =
409 (efi_set_virtual_address_map_t *) 409 (efi_set_virtual_address_map_t *)
410 (unsigned long)runtime->set_virtual_address_map; 410 (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));
412 412
413 return 0; 413 return 0;
414} 414}
@@ -439,7 +439,7 @@ static int __init efi_runtime_init(void)
439static int __init efi_memmap_init(void) 439static int __init efi_memmap_init(void)
440{ 440{
441 /* Map the EFI memory map */ 441 /* 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,
443 memmap.nr_map * memmap.desc_size); 443 memmap.nr_map * memmap.desc_size);
444 if (memmap.map == NULL) { 444 if (memmap.map == NULL) {
445 pr_err("Could not map the memory map!\n"); 445 pr_err("Could not map the memory map!\n");
@@ -487,14 +487,14 @@ void __init efi_init(void)
487 /* 487 /*
488 * Show what we know for posterity 488 * Show what we know for posterity
489 */ 489 */
490 c16 = tmp = early_ioremap(efi.systab->fw_vendor, 2); 490 c16 = tmp = early_memremap(efi.systab->fw_vendor, 2);
491 if (c16) { 491 if (c16) {
492 for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i) 492 for (i = 0; i < sizeof(vendor) - 1 && *c16; ++i)
493 vendor[i] = *c16++; 493 vendor[i] = *c16++;
494 vendor[i] = '\0'; 494 vendor[i] = '\0';
495 } else 495 } else
496 pr_err("Could not map the firmware vendor!\n"); 496 pr_err("Could not map the firmware vendor!\n");
497 early_iounmap(tmp, 2); 497 early_memunmap(tmp, 2);
498 498
499 pr_info("EFI v%u.%.02u by %s\n", 499 pr_info("EFI v%u.%.02u by %s\n",
500 efi.systab->hdr.revision >> 16, 500 efi.systab->hdr.revision >> 16,
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index cd36deb619fa..023937a63a48 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -298,7 +298,7 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
298 if (table64 >> 32) { 298 if (table64 >> 32) {
299 pr_cont("\n"); 299 pr_cont("\n");
300 pr_err("Table located above 4GB, disabling EFI.\n"); 300 pr_err("Table located above 4GB, disabling EFI.\n");
301 early_iounmap(config_tables, 301 early_memunmap(config_tables,
302 efi.systab->nr_tables * sz); 302 efi.systab->nr_tables * sz);
303 return -EINVAL; 303 return -EINVAL;
304 } 304 }
@@ -314,7 +314,7 @@ int __init efi_config_init(efi_config_table_type_t *arch_tables)
314 tablep += sz; 314 tablep += sz;
315 } 315 }
316 pr_cont("\n"); 316 pr_cont("\n");
317 early_iounmap(config_tables, efi.systab->nr_tables * sz); 317 early_memunmap(config_tables, efi.systab->nr_tables * sz);
318 318
319 set_bit(EFI_CONFIG_TABLES, &efi.flags); 319 set_bit(EFI_CONFIG_TABLES, &efi.flags);
320 320