Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

efi: Move UGA and PROP table handling to x86 code

The UGA table is x86 specific (its handling was introduced when the
EFI support code was modified to accommodate IA32), so there is no
need to handle it in generic code.

The EFI properties table is not strictly x86 specific, but it was
deprecated almost immediately after having been introduced, due to
implementation difficulties. Only x86 takes it into account today,
and this is not going to change, so make this table x86 only as well.

Tested-by: Tony Luck <tony.luck@intel.com> # arch/ia64
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

+31 -28
+30 -2
arch/x86/platform/efi/efi.c
··· 57 57 static efi_system_table_t efi_systab __initdata; 58 58 static u64 efi_systab_phys __initdata; 59 59 60 + static unsigned long prop_phys = EFI_INVALID_TABLE_ADDR; 61 + static unsigned long uga_phys = EFI_INVALID_TABLE_ADDR; 62 + 60 63 static efi_config_table_type_t arch_tables[] __initdata = { 64 + {EFI_PROPERTIES_TABLE_GUID, "PROP", &prop_phys}, 65 + {UGA_IO_PROTOCOL_GUID, "UGA", &uga_phys}, 61 66 #ifdef CONFIG_X86_UV 62 67 {UV_SYSTEM_TABLE_GUID, "UVsystab", &uv_systab_phys}, 63 68 #endif ··· 74 69 &efi.acpi20, 75 70 &efi.smbios, 76 71 &efi.smbios3, 77 - &efi.uga, 72 + &uga_phys, 78 73 #ifdef CONFIG_X86_UV 79 74 &uv_systab_phys, 80 75 #endif ··· 82 77 &efi.runtime, 83 78 &efi.config_table, 84 79 &efi.esrt, 85 - &efi.properties_table, 80 + &prop_phys, 86 81 &efi.mem_attr_table, 87 82 #ifdef CONFIG_EFI_RCI2_TABLE 88 83 &rci2_table_phys, ··· 493 488 if (!efi_runtime_supported() || efi_runtime_disabled()) { 494 489 efi_memmap_unmap(); 495 490 return; 491 + } 492 + 493 + /* Parse the EFI Properties table if it exists */ 494 + if (prop_phys != EFI_INVALID_TABLE_ADDR) { 495 + efi_properties_table_t *tbl; 496 + 497 + tbl = early_memremap_ro(prop_phys, sizeof(*tbl)); 498 + if (tbl == NULL) { 499 + pr_err("Could not map Properties table!\n"); 500 + } else { 501 + if (tbl->memory_protection_attribute & 502 + EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) 503 + set_bit(EFI_NX_PE_DATA, &efi.flags); 504 + 505 + early_memunmap(tbl, sizeof(*tbl)); 506 + } 496 507 } 497 508 498 509 set_bit(EFI_RUNTIME_SERVICES, &efi.flags); ··· 1013 992 return true; 1014 993 1015 994 return false; 995 + } 996 + 997 + char *efi_systab_show_arch(char *str) 998 + { 999 + if (uga_phys != EFI_INVALID_TABLE_ADDR) 1000 + str += sprintf(str, "UGA=0x%lx\n", uga_phys); 1001 + return str; 1016 1002 }
+1 -24
drivers/firmware/efi/efi.c
··· 39 39 .acpi20 = EFI_INVALID_TABLE_ADDR, 40 40 .smbios = EFI_INVALID_TABLE_ADDR, 41 41 .smbios3 = EFI_INVALID_TABLE_ADDR, 42 - .uga = EFI_INVALID_TABLE_ADDR, 43 42 .fw_vendor = EFI_INVALID_TABLE_ADDR, 44 43 .runtime = EFI_INVALID_TABLE_ADDR, 45 44 .config_table = EFI_INVALID_TABLE_ADDR, 46 45 .esrt = EFI_INVALID_TABLE_ADDR, 47 - .properties_table = EFI_INVALID_TABLE_ADDR, 48 46 .mem_attr_table = EFI_INVALID_TABLE_ADDR, 49 47 .rng_seed = EFI_INVALID_TABLE_ADDR, 50 48 .tpm_log = EFI_INVALID_TABLE_ADDR, ··· 130 132 str += sprintf(str, "SMBIOS3=0x%lx\n", efi.smbios3); 131 133 if (efi.smbios != EFI_INVALID_TABLE_ADDR) 132 134 str += sprintf(str, "SMBIOS=0x%lx\n", efi.smbios); 133 - if (efi.uga != EFI_INVALID_TABLE_ADDR) 134 - str += sprintf(str, "UGA=0x%lx\n", efi.uga); 135 135 136 - if (IS_ENABLED(CONFIG_IA64)) { 136 + if (IS_ENABLED(CONFIG_IA64) || IS_ENABLED(CONFIG_X86)) { 137 137 extern char *efi_systab_show_arch(char *str); 138 138 139 139 str = efi_systab_show_arch(str); ··· 465 469 {ACPI_TABLE_GUID, "ACPI", &efi.acpi}, 466 470 {SMBIOS_TABLE_GUID, "SMBIOS", &efi.smbios}, 467 471 {SMBIOS3_TABLE_GUID, "SMBIOS 3.0", &efi.smbios3}, 468 - {UGA_IO_PROTOCOL_GUID, "UGA", &efi.uga}, 469 472 {EFI_SYSTEM_RESOURCE_TABLE_GUID, "ESRT", &efi.esrt}, 470 - {EFI_PROPERTIES_TABLE_GUID, "PROP", &efi.properties_table}, 471 473 {EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi.mem_attr_table}, 472 474 {LINUX_EFI_RANDOM_SEED_TABLE_GUID, "RNG", &efi.rng_seed}, 473 475 {LINUX_EFI_TPM_EVENT_LOG_GUID, "TPMEventLog", &efi.tpm_log}, ··· 563 569 efi_memattr_init(); 564 570 565 571 efi_tpm_eventlog_init(); 566 - 567 - /* Parse the EFI Properties table if it exists */ 568 - if (efi.properties_table != EFI_INVALID_TABLE_ADDR) { 569 - efi_properties_table_t *tbl; 570 - 571 - tbl = early_memremap(efi.properties_table, sizeof(*tbl)); 572 - if (tbl == NULL) { 573 - pr_err("Could not map Properties table!\n"); 574 - return -ENOMEM; 575 - } 576 - 577 - if (tbl->memory_protection_attribute & 578 - EFI_PROPERTIES_RUNTIME_MEMORY_PROTECTION_NON_EXECUTABLE_PE_DATA) 579 - set_bit(EFI_NX_PE_DATA, &efi.flags); 580 - 581 - early_memunmap(tbl, sizeof(*tbl)); 582 - } 583 572 584 573 if (efi.mem_reserve != EFI_INVALID_TABLE_ADDR) { 585 574 unsigned long prsv = efi.mem_reserve;
-2
include/linux/efi.h
··· 535 535 unsigned long acpi20; /* ACPI table (ACPI 2.0) */ 536 536 unsigned long smbios; /* SMBIOS table (32 bit entry point) */ 537 537 unsigned long smbios3; /* SMBIOS table (64 bit entry point) */ 538 - unsigned long uga; /* UGA table */ 539 538 unsigned long fw_vendor; /* fw_vendor */ 540 539 unsigned long runtime; /* runtime table */ 541 540 unsigned long config_table; /* config tables */ 542 541 unsigned long esrt; /* ESRT table */ 543 - unsigned long properties_table; /* properties table */ 544 542 unsigned long mem_attr_table; /* memory attributes table */ 545 543 unsigned long rng_seed; /* UEFI firmware random seed */ 546 544 unsigned long tpm_log; /* TPM2 Event Log table */