Skip to content

Commit b2c99e3

Browse files
Bjorn HelgaasLinus Torvalds
authored andcommitted
[PATCH] EFI: keep physical table addresses in efi structure
Almost all users of the table addresses from the EFI system table want physical addresses. So rather than doing the pa->va->pa conversion, just keep physical addresses in struct efi. This fixes a DMI bug: the efi structure contained the physical SMBIOS address on x86 but the virtual address on ia64, so dmi_scan_machine() used ioremap() on a virtual address on ia64. This is essentially the same as an earlier patch by Matt Tolentino: http://marc.theaimsgroup.com/?l=linux-kernel&m=112130292316281&w=2 except that this changes all table addresses, not just ACPI addresses. Matt's original patch was backed out because it caused MCAs on HP sx1000 systems. That problem is resolved by the ioremap() attribute checking added for ia64. Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com> Cc: Matt Domsch <Matt_Domsch@dell.com> Cc: "Tolentino, Matthew E" <matthew.e.tolentino@intel.com> Cc: "Brown, Len" <len.brown@intel.com> Cc: Andi Kleen <ak@muc.de> Acked-by: "Luck, Tony" <tony.luck@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 27d8e3d commit b2c99e3

12 files changed

Lines changed: 84 additions & 60 deletions

File tree

‎arch/i386/kernel/acpi/boot.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -668,10 +668,10 @@ unsigned long __init acpi_find_rsdp(void)
668668
unsigned long rsdp_phys = 0;
669669

670670
if (efi_enabled) {
671-
if (efi.acpi20)
672-
return __pa(efi.acpi20);
673-
else if (efi.acpi)
674-
return __pa(efi.acpi);
671+
if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
672+
return efi.acpi20;
673+
else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
674+
return efi.acpi;
675675
}
676676
/*
677677
* Scan memory looking for the RSDP signature. First search EBDA (low

‎arch/i386/kernel/dmi_scan.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,14 +217,14 @@ void __init dmi_scan_machine(void)
217217
int rc;
218218

219219
if (efi_enabled) {
220-
if (!efi.smbios)
220+
if (efi.smbios == EFI_INVALID_TABLE_ADDR)
221221
goto out;
222222

223223
/* This is called as a core_initcall() because it isn't
224224
* needed during early boot. This also means we can
225225
* iounmap the space when we're done with it.
226226
*/
227-
p = dmi_ioremap((unsigned long)efi.smbios, 32);
227+
p = dmi_ioremap(efi.smbios, 32);
228228
if (p == NULL)
229229
goto out;
230230

‎arch/i386/kernel/efi.c‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -381,29 +381,38 @@ void __init efi_init(void)
381381
if (config_tables == NULL)
382382
printk(KERN_ERR PFX "Could not map EFI Configuration Table!\n");
383383

384+
efi.mps = EFI_INVALID_TABLE_ADDR;
385+
efi.acpi = EFI_INVALID_TABLE_ADDR;
386+
efi.acpi20 = EFI_INVALID_TABLE_ADDR;
387+
efi.smbios = EFI_INVALID_TABLE_ADDR;
388+
efi.sal_systab = EFI_INVALID_TABLE_ADDR;
389+
efi.boot_info = EFI_INVALID_TABLE_ADDR;
390+
efi.hcdp = EFI_INVALID_TABLE_ADDR;
391+
efi.uga = EFI_INVALID_TABLE_ADDR;
392+
384393
for (i = 0; i < num_config_tables; i++) {
385394
if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
386-
efi.mps = (void *)config_tables[i].table;
395+
efi.mps = config_tables[i].table;
387396
printk(KERN_INFO " MPS=0x%lx ", config_tables[i].table);
388397
} else
389398
if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
390-
efi.acpi20 = __va(config_tables[i].table);
399+
efi.acpi20 = config_tables[i].table;
391400
printk(KERN_INFO " ACPI 2.0=0x%lx ", config_tables[i].table);
392401
} else
393402
if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
394-
efi.acpi = __va(config_tables[i].table);
403+
efi.acpi = config_tables[i].table;
395404
printk(KERN_INFO " ACPI=0x%lx ", config_tables[i].table);
396405
} else
397406
if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
398-
efi.smbios = (void *) config_tables[i].table;
407+
efi.smbios = config_tables[i].table;
399408
printk(KERN_INFO " SMBIOS=0x%lx ", config_tables[i].table);
400409
} else
401410
if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
402-
efi.hcdp = (void *)config_tables[i].table;
411+
efi.hcdp = config_tables[i].table;
403412
printk(KERN_INFO " HCDP=0x%lx ", config_tables[i].table);
404413
} else
405414
if (efi_guidcmp(config_tables[i].guid, UGA_IO_PROTOCOL_GUID) == 0) {
406-
efi.uga = (void *)config_tables[i].table;
415+
efi.uga = config_tables[i].table;
407416
printk(KERN_INFO " UGA=0x%lx ", config_tables[i].table);
408417
}
409418
}

‎arch/ia64/kernel/acpi.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -651,9 +651,9 @@ unsigned long __init acpi_find_rsdp(void)
651651
{
652652
unsigned long rsdp_phys = 0;
653653

654-
if (efi.acpi20)
655-
rsdp_phys = __pa(efi.acpi20);
656-
else if (efi.acpi)
654+
if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
655+
rsdp_phys = efi.acpi20;
656+
else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
657657
printk(KERN_WARNING PREFIX
658658
"v1.0/r0.71 tables no longer supported\n");
659659
return rsdp_phys;

‎arch/ia64/kernel/efi.c‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -458,24 +458,33 @@ efi_init (void)
458458
printk(KERN_INFO "EFI v%u.%.02u by %s:",
459459
efi.systab->hdr.revision >> 16, efi.systab->hdr.revision & 0xffff, vendor);
460460

461+
efi.mps = EFI_INVALID_TABLE_ADDR;
462+
efi.acpi = EFI_INVALID_TABLE_ADDR;
463+
efi.acpi20 = EFI_INVALID_TABLE_ADDR;
464+
efi.smbios = EFI_INVALID_TABLE_ADDR;
465+
efi.sal_systab = EFI_INVALID_TABLE_ADDR;
466+
efi.boot_info = EFI_INVALID_TABLE_ADDR;
467+
efi.hcdp = EFI_INVALID_TABLE_ADDR;
468+
efi.uga = EFI_INVALID_TABLE_ADDR;
469+
461470
for (i = 0; i < (int) efi.systab->nr_tables; i++) {
462471
if (efi_guidcmp(config_tables[i].guid, MPS_TABLE_GUID) == 0) {
463-
efi.mps = __va(config_tables[i].table);
472+
efi.mps = config_tables[i].table;
464473
printk(" MPS=0x%lx", config_tables[i].table);
465474
} else if (efi_guidcmp(config_tables[i].guid, ACPI_20_TABLE_GUID) == 0) {
466-
efi.acpi20 = __va(config_tables[i].table);
475+
efi.acpi20 = config_tables[i].table;
467476
printk(" ACPI 2.0=0x%lx", config_tables[i].table);
468477
} else if (efi_guidcmp(config_tables[i].guid, ACPI_TABLE_GUID) == 0) {
469-
efi.acpi = __va(config_tables[i].table);
478+
efi.acpi = config_tables[i].table;
470479
printk(" ACPI=0x%lx", config_tables[i].table);
471480
} else if (efi_guidcmp(config_tables[i].guid, SMBIOS_TABLE_GUID) == 0) {
472-
efi.smbios = __va(config_tables[i].table);
481+
efi.smbios = config_tables[i].table;
473482
printk(" SMBIOS=0x%lx", config_tables[i].table);
474483
} else if (efi_guidcmp(config_tables[i].guid, SAL_SYSTEM_TABLE_GUID) == 0) {
475-
efi.sal_systab = __va(config_tables[i].table);
484+
efi.sal_systab = config_tables[i].table;
476485
printk(" SALsystab=0x%lx", config_tables[i].table);
477486
} else if (efi_guidcmp(config_tables[i].guid, HCDP_TABLE_GUID) == 0) {
478-
efi.hcdp = __va(config_tables[i].table);
487+
efi.hcdp = config_tables[i].table;
479488
printk(" HCDP=0x%lx", config_tables[i].table);
480489
}
481490
}

‎arch/ia64/kernel/setup.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ setup_arch (char **cmdline_p)
434434
find_memory();
435435

436436
/* process SAL system table: */
437-
ia64_sal_init(efi.sal_systab);
437+
ia64_sal_init(__va(efi.sal_systab));
438438

439439
ia64_setup_printk_clock();
440440

‎arch/ia64/sn/kernel/setup.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,11 @@ sn_scan_pcdp(void)
327327
struct pcdp_interface_pci if_pci;
328328
extern struct efi efi;
329329

330-
pcdp = efi.hcdp;
331-
if (! pcdp)
330+
if (efi.hcdp == EFI_INVALID_TABLE_ADDR)
332331
return; /* no hcdp/pcdp table */
333332

333+
pcdp = __va(efi.hcdp);
334+
334335
if (pcdp->rev < 3)
335336
return; /* only support PCDP (rev >= 3) */
336337

‎drivers/acpi/osl.c‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,10 @@ acpi_status acpi_os_get_root_pointer(u32 flags, struct acpi_pointer *addr)
156156
{
157157
if (efi_enabled) {
158158
addr->pointer_type = ACPI_PHYSICAL_POINTER;
159-
if (efi.acpi20)
160-
addr->pointer.physical =
161-
(acpi_physical_address) virt_to_phys(efi.acpi20);
162-
else if (efi.acpi)
163-
addr->pointer.physical =
164-
(acpi_physical_address) virt_to_phys(efi.acpi);
159+
if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
160+
addr->pointer.physical = efi.acpi20;
161+
else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
162+
addr->pointer.physical = efi.acpi;
165163
else {
166164
printk(KERN_ERR PREFIX
167165
"System description tables not found\n");

‎drivers/firmware/efivars.c‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -568,20 +568,20 @@ systab_read(struct subsystem *entry, char *buf)
568568
if (!entry || !buf)
569569
return -EINVAL;
570570

571-
if (efi.mps)
572-
str += sprintf(str, "MPS=0x%lx\n", __pa(efi.mps));
573-
if (efi.acpi20)
574-
str += sprintf(str, "ACPI20=0x%lx\n", __pa(efi.acpi20));
575-
if (efi.acpi)
576-
str += sprintf(str, "ACPI=0x%lx\n", __pa(efi.acpi));
577-
if (efi.smbios)
578-
str += sprintf(str, "SMBIOS=0x%lx\n", __pa(efi.smbios));
579-
if (efi.hcdp)
580-
str += sprintf(str, "HCDP=0x%lx\n", __pa(efi.hcdp));
581-
if (efi.boot_info)
582-
str += sprintf(str, "BOOTINFO=0x%lx\n", __pa(efi.boot_info));
583-
if (efi.uga)
584-
str += sprintf(str, "UGA=0x%lx\n", __pa(efi.uga));
571+
if (efi.mps != EFI_INVALID_TABLE_ADDR)
572+
str += sprintf(str, "MPS=0x%lx\n", efi.mps);
573+
if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
574+
str += sprintf(str, "ACPI20=0x%lx\n", efi.acpi20);
575+
if (efi.acpi != EFI_INVALID_TABLE_ADDR)
576+
str += sprintf(str, "ACPI=0x%lx\n", efi.acpi);
577+
if (efi.smbios != EFI_INVALID_TABLE_ADDR)
578+
str += sprintf(str, "SMBIOS=0x%lx\n", efi.smbios);
579+
if (efi.hcdp != EFI_INVALID_TABLE_ADDR)
580+
str += sprintf(str, "HCDP=0x%lx\n", efi.hcdp);
581+
if (efi.boot_info != EFI_INVALID_TABLE_ADDR)
582+
str += sprintf(str, "BOOTINFO=0x%lx\n", efi.boot_info);
583+
if (efi.uga != EFI_INVALID_TABLE_ADDR)
584+
str += sprintf(str, "UGA=0x%lx\n", efi.uga);
585585

586586
return str - buf;
587587
}

‎drivers/firmware/pcdp.c‎

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,20 @@ efi_setup_pcdp_console(char *cmdline)
8989
struct pcdp_uart *uart;
9090
struct pcdp_device *dev, *end;
9191
int i, serial = 0;
92+
int rc = -ENODEV;
9293

93-
pcdp = efi.hcdp;
94-
if (!pcdp)
94+
if (efi.hcdp == EFI_INVALID_TABLE_ADDR)
9595
return -ENODEV;
9696

97-
printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp));
97+
pcdp = ioremap(efi.hcdp, 4096);
98+
printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, efi.hcdp);
9899

99100
if (strstr(cmdline, "console=hcdp")) {
100101
if (pcdp->rev < 3)
101102
serial = 1;
102103
} else if (strstr(cmdline, "console=")) {
103104
printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
104-
return -ENODEV;
105+
goto out;
105106
}
106107

107108
if (pcdp->rev < 3 && efi_uart_console_only())
@@ -110,7 +111,8 @@ efi_setup_pcdp_console(char *cmdline)
110111
for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
111112
if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
112113
if (uart->type == PCDP_CONSOLE_UART) {
113-
return setup_serial_console(uart);
114+
rc = setup_serial_console(uart);
115+
goto out;
114116
}
115117
}
116118
}
@@ -121,10 +123,13 @@ efi_setup_pcdp_console(char *cmdline)
121123
dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
122124
if (dev->flags & PCDP_PRIMARY_CONSOLE) {
123125
if (dev->type == PCDP_CONSOLE_VGA) {
124-
return setup_vga_console(dev);
126+
rc = setup_vga_console(dev);
127+
goto out;
125128
}
126129
}
127130
}
128131

129-
return -ENODEV;
132+
out:
133+
iounmap(pcdp);
134+
return rc;
130135
}

0 commit comments

Comments
 (0)