History

efi/x86: Drop 'systab' member from struct efi

The systab member in struct efi has outlived its usefulness, now that we have better ways to access the only piece of information we are interested in after init, which is the EFI runtime services table address. So instead of instantiating a doctored copy at early boot with lots of mangled values, and switching the pointer when switching into virtual mode, let's grab the values we need directly, and get rid of the systab pointer entirely.

Ard Biesheuvel committed 6 years ago

Commit fd268301 parent 8819ba32 files · +41 −98Browse files

Unified · Split

2 files
  1. arch/x86/platform/efi/efi.c +14 −73
  2. include/linux/efi.h +27 −25
arch/x86/platform/efi/efi.c+14−73
@@ -54,8 +54,6 @@ · 53 unmodified lines
5454 #include <asm/x86_init.h>
5555 #include <asm/uv/uv.h>
5656
57−static efi_system_table_t efi_systab __initdata;
58−
5957 static unsigned long efi_systab_phys __initdata;
6058 static unsigned long prop_phys = EFI_INVALID_TABLE_ADDR;
6159 static unsigned long uga_phys = EFI_INVALID_TABLE_ADDR;
@@ -359,28 +357,8 @@ static int __init efi_systab_init(unsigned long phys) · 297 unmodified lines
359357 if (efi_enabled(EFI_64BIT)) {
360358 const efi_system_table_64_t *systab64 = p;
361359
362− efi_systab.hdr = systab64->hdr;
363− efi_systab.fw_vendor = systab64->fw_vendor;
364− efi_systab.fw_revision = systab64->fw_revision;
365− efi_systab.con_in_handle = systab64->con_in_handle;
366− efi_systab.con_in = systab64->con_in;
367− efi_systab.con_out_handle = systab64->con_out_handle;
368− efi_systab.con_out = (void *)(unsigned long)systab64->con_out;
369− efi_systab.stderr_handle = systab64->stderr_handle;
370− efi_systab.stderr = systab64->stderr;
371− efi_systab.runtime = (void *)(unsigned long)systab64->runtime;
372− efi_systab.boottime = (void *)(unsigned long)systab64->boottime;
373− efi_systab.nr_tables = systab64->nr_tables;
374− efi_systab.tables = systab64->tables;
375−
376− over4g = systab64->con_in_handle > U32_MAX ||
377− systab64->con_in > U32_MAX ||
378− systab64->con_out_handle > U32_MAX ||
379− systab64->con_out > U32_MAX ||
380− systab64->stderr_handle > U32_MAX ||
381− systab64->stderr > U32_MAX ||
382− systab64->runtime > U32_MAX ||
383− systab64->boottime > U32_MAX;
360+ efi_runtime = systab64->runtime;
361+ over4g = systab64->runtime > U32_MAX;
384362
385363 if (efi_setup) {
386364 struct efi_setup_data *data;
@@ -391,38 +369,33 @@ static int __init efi_systab_init(unsigned long phys) · 4 unmodified lines
391369 return -ENOMEM;
392370 }
393371
394− efi_systab.fw_vendor = (unsigned long)data->fw_vendor;
395− efi_systab.tables = (unsigned long)data->tables;
372+ efi_fw_vendor = (unsigned long)data->fw_vendor;
373+ efi_config_table = (unsigned long)data->tables;
396374
397375 over4g |= data->fw_vendor > U32_MAX ||
398376 data->tables > U32_MAX;
399377
400378 early_memunmap(data, sizeof(*data));
401379 } else {
380+ efi_fw_vendor = systab64->fw_vendor;
381+ efi_config_table = systab64->tables;
382+
402383 over4g |= systab64->fw_vendor > U32_MAX ||
403384 systab64->tables > U32_MAX;
404385 }
386+ efi_nr_tables = systab64->nr_tables;
405387 } else {
406388 const efi_system_table_32_t *systab32 = p;
407389
408− efi_systab.hdr = systab32->hdr;
409− efi_systab.fw_vendor = systab32->fw_vendor;
410− efi_systab.fw_revision = systab32->fw_revision;
411− efi_systab.con_in_handle = systab32->con_in_handle;
412− efi_systab.con_in = systab32->con_in;
413− efi_systab.con_out_handle = systab32->con_out_handle;
414− efi_systab.con_out = (void *)(unsigned long)systab32->con_out;
415− efi_systab.stderr_handle = systab32->stderr_handle;
416− efi_systab.stderr = systab32->stderr;
417− efi_systab.runtime = (void *)(unsigned long)systab32->runtime;
418− efi_systab.boottime = (void *)(unsigned long)systab32->boottime;
419− efi_systab.nr_tables = systab32->nr_tables;
420− efi_systab.tables = systab32->tables;
390+ efi_fw_vendor = systab32->fw_vendor;
391+ efi_runtime = systab32->runtime;
392+ efi_config_table = systab32->tables;
393+ efi_nr_tables = systab32->nr_tables;
421394 }
422395
423396 efi.runtime_version = hdr->revision;
424397
425− efi_systab_report_header(hdr, efi_systab.fw_vendor);
398+ efi_systab_report_header(hdr, efi_fw_vendor);
426399 early_memunmap(p, size);
427400
428401 if (IS_ENABLED(CONFIG_X86_32) && over4g) {
@@ -430,7 +403,6 @@ static int __init efi_systab_init(unsigned long phys) · 1 unmodified line
430403 return -EINVAL;
431404 }
432405
433− efi.systab = &efi_systab;
434406 return 0;
435407 }
436408
@@ -478,11 +450,6 @@ void __init efi_init(void) · 41 unmodified lines
478450 if (efi_systab_init(efi_systab_phys))
479451 return;
480452
481− efi_config_table = (unsigned long)efi.systab->tables;
482− efi_nr_tables = efi.systab->nr_tables;
483− efi_fw_vendor = (unsigned long)efi.systab->fw_vendor;
484− efi_runtime = (unsigned long)efi.systab->runtime;
485−
486453 if (efi_reuse_config(efi_config_table, efi_nr_tables))
487454 return;
488455
@@ -624,20 +591,6 @@ static void __init efi_merge_regions(void) · 135 unmodified lines
624591 }
625592 }
626593
627−static void __init get_systab_virt_addr(efi_memory_desc_t *md)
628−{
629− unsigned long size;
630− u64 end, systab;
631−
632− size = md->num_pages << EFI_PAGE_SHIFT;
633− end = md->phys_addr + size;
634− systab = efi_systab_phys;
635− if (md->phys_addr <= systab && systab < end) {
636− systab += md->virt_addr - md->phys_addr;
637− efi.systab = (efi_system_table_t *)(unsigned long)systab;
638− }
639−}
640−
641594 static void *realloc_pages(void *old_memmap, int old_shift)
642595 {
643596 void *ret;
@@ -793,7 +746,6 @@ static void * __init efi_map_regions(int *count, int *pg_shift) · 149 unmodified lines
793746 continue;
794747
795748 efi_map_region(md);
796− get_systab_virt_addr(md);
797749
798750 if (left < desc_size) {
799751 new_memmap = realloc_pages(new_memmap, *pg_shift);
@@ -819,8 +771,6 @@ static void __init kexec_enter_virtual_mode(void) · 19 unmodified lines
819771 efi_memory_desc_t *md;
820772 unsigned int num_pages;
821773
822− efi.systab = NULL;
823−
824774 /*
825775 * We don't do virtual mode, since we don't do runtime services, on
826776 * non-native EFI. With the UV1 memmap, we don't do runtime services in
@@ -843,10 +793,8 @@ static void __init kexec_enter_virtual_mode(void) · 16 unmodified lines
843793 * Map efi regions which were passed via setup_data. The virt_addr is a
844794 * fixed addr which was used in first kernel of a kexec boot.
845795 */
846− for_each_efi_memory_desc(md) {
796+ for_each_efi_memory_desc(md)
847797 efi_map_region_fixed(md); /* FIXME: add error handling */
848− get_systab_virt_addr(md);
849− }
850798
851799 /*
852800 * Unregister the early EFI memmap from efi_init() and install
@@ -861,8 +809,6 @@ static void __init kexec_enter_virtual_mode(void) · 8 unmodified lines
861809 return;
862810 }
863811
864− BUG_ON(!efi.systab);
865−
866812 num_pages = ALIGN(efi.memmap.nr_map * efi.memmap.desc_size, PAGE_SIZE);
867813 num_pages >>= PAGE_SHIFT;
868814
@@ -905,8 +851,6 @@ static void __init __efi_enter_virtual_mode(void) · 36 unmodified lines
905851 efi_status_t status;
906852 unsigned long pa;
907853
908− efi.systab = NULL;
909−
910854 if (efi_alloc_page_tables()) {
911855 pr_err("Failed to allocate EFI page tables\n");
912856 goto err;
@@ -938,9 +882,6 @@ static void __init __efi_enter_virtual_mode(void) · 25 unmodified lines
938882 efi_print_memmap();
939883 }
940884
941− if (WARN_ON(!efi.systab))
942− goto err;
943−
944885 if (efi_setup_page_tables(pa, 1 << pg_shift))
945886 goto err;
946887
include/linux/efi.h+27−25
@@ -530,31 +530,33 @@ typedef struct { · 529 unmodified lines
530530 */
531531 extern struct efi {
532532 const efi_runtime_services_t *runtime; /* EFI runtime services table */
533− efi_system_table_t *systab; /* EFI system table */
534− unsigned int runtime_version; /* Runtime services version */
535− unsigned long acpi; /* ACPI table (IA64 ext 0.71) */
536− unsigned long acpi20; /* ACPI table (ACPI 2.0) */
537− unsigned long smbios; /* SMBIOS table (32 bit entry point) */
538− unsigned long smbios3; /* SMBIOS table (64 bit entry point) */
539− unsigned long esrt; /* ESRT table */
540− unsigned long tpm_log; /* TPM2 Event Log table */
541− unsigned long tpm_final_log; /* TPM2 Final Events Log table */
542− efi_get_time_t *get_time;
543− efi_set_time_t *set_time;
544− efi_get_wakeup_time_t *get_wakeup_time;
545− efi_set_wakeup_time_t *set_wakeup_time;
546− efi_get_variable_t *get_variable;
547− efi_get_next_variable_t *get_next_variable;
548− efi_set_variable_t *set_variable;
549− efi_set_variable_t *set_variable_nonblocking;
550− efi_query_variable_info_t *query_variable_info;
551− efi_query_variable_info_t *query_variable_info_nonblocking;
552− efi_update_capsule_t *update_capsule;
553− efi_query_capsule_caps_t *query_capsule_caps;
554− efi_get_next_high_mono_count_t *get_next_high_mono_count;
555− efi_reset_system_t *reset_system;
556− struct efi_memory_map memmap;
557− unsigned long flags;
533+ unsigned int runtime_version; /* Runtime services version */
534+
535+ unsigned long acpi; /* ACPI table (IA64 ext 0.71) */
536+ unsigned long acpi20; /* ACPI table (ACPI 2.0) */
537+ unsigned long smbios; /* SMBIOS table (32 bit entry point) */
538+ unsigned long smbios3; /* SMBIOS table (64 bit entry point) */
539+ unsigned long esrt; /* ESRT table */
540+ unsigned long tpm_log; /* TPM2 Event Log table */
541+ unsigned long tpm_final_log; /* TPM2 Final Events Log table */
542+
543+ efi_get_time_t *get_time;
544+ efi_set_time_t *set_time;
545+ efi_get_wakeup_time_t *get_wakeup_time;
546+ efi_set_wakeup_time_t *set_wakeup_time;
547+ efi_get_variable_t *get_variable;
548+ efi_get_next_variable_t *get_next_variable;
549+ efi_set_variable_t *set_variable;
550+ efi_set_variable_t *set_variable_nonblocking;
551+ efi_query_variable_info_t *query_variable_info;
552+ efi_query_variable_info_t *query_variable_info_nonblocking;
553+ efi_update_capsule_t *update_capsule;
554+ efi_query_capsule_caps_t *query_capsule_caps;
555+ efi_get_next_high_mono_count_t *get_next_high_mono_count;
556+ efi_reset_system_t *reset_system;
557+
558+ struct efi_memory_map memmap;
559+ unsigned long flags;
558560 } efi;
559561
560562 extern struct mm_struct efi_mm;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t