diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-16 16:06:27 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-05-16 16:06:27 -0400 |
commit | 49817c33433a3cd6f320b13699e6746cc39b453b (patch) | |
tree | 1eb8c4a4d585e648b0783741c02ab611149971d9 /drivers/firmware/efi/efi.c | |
parent | 230e51f21101e49c8d73018d414adbd0d57459a1 (diff) | |
parent | 6c5450ef66816216e574885cf8d3ddb31ef77428 (diff) |
Merge branch 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull EFI updates from Ingo Molnar:
"The main changes in this cycle were:
- Drop the unused EFI_SYSTEM_TABLES efi.flags bit and ensure the
ARM/arm64 EFI System Table mapping is read-only (Ard Biesheuvel)
- Add a comment to explain that one of the code paths in the x86/pat
code is only executed for EFI boot (Matt Fleming)
- Improve Secure Boot status checks on arm64 and handle unexpected
errors (Linn Crosetto)
- Remove the global EFI memory map variable 'memmap' as the same
information is already available in efi::memmap (Matt Fleming)
- Add EFI Memory Attribute table support for ARM/arm64 (Ard
Biesheuvel)
- Add EFI GOP framebuffer support for ARM/arm64 (Ard Biesheuvel)
- Add EFI Bootloader Control driver for storing reboot(2) data in EFI
variables for consumption by bootloaders (Jeremy Compostella)
- Add Core EFI capsule support (Matt Fleming)
- Add EFI capsule char driver (Kweh, Hock Leong)
- Unify EFI memory map code for ARM and arm64 (Ard Biesheuvel)
- Add generic EFI support for detecting when firmware corrupts CPU
status register bits (like IRQ flags) when performing EFI runtime
service calls (Mark Rutland)
... and other misc cleanups"
* 'efi-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (46 commits)
efivarfs: Make efivarfs_file_ioctl() static
efi: Merge boolean flag arguments
efi/capsule: Move 'capsule' to the stack in efi_capsule_supported()
efibc: Fix excessive stack footprint warning
efi/capsule: Make efi_capsule_pending() lockless
efi: Remove unnecessary (and buggy) .memmap initialization from the Xen EFI driver
efi/runtime-wrappers: Remove ARCH_EFI_IRQ_FLAGS_MASK #ifdef
x86/efi: Enable runtime call flag checking
arm/efi: Enable runtime call flag checking
arm64/efi: Enable runtime call flag checking
efi/runtime-wrappers: Detect firmware IRQ flag corruption
efi/runtime-wrappers: Remove redundant #ifdefs
x86/efi: Move to generic {__,}efi_call_virt()
arm/efi: Move to generic {__,}efi_call_virt()
arm64/efi: Move to generic {__,}efi_call_virt()
efi/runtime-wrappers: Add {__,}efi_call_virt() templates
efi/arm-init: Reserve rather than unmap the memory map for ARM as well
efi: Add misc char driver interface to update EFI firmware
x86/efi: Force EFI reboot to process pending capsules
efi: Add 'capsule' update support
...
Diffstat (limited to 'drivers/firmware/efi/efi.c')
-rw-r--r-- | drivers/firmware/efi/efi.c | 48 |
1 files changed, 40 insertions, 8 deletions
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 3a69ed5ecfcb..05509f3aaee8 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
@@ -43,6 +43,7 @@ struct efi __read_mostly efi = { | |||
43 | .config_table = EFI_INVALID_TABLE_ADDR, | 43 | .config_table = EFI_INVALID_TABLE_ADDR, |
44 | .esrt = EFI_INVALID_TABLE_ADDR, | 44 | .esrt = EFI_INVALID_TABLE_ADDR, |
45 | .properties_table = EFI_INVALID_TABLE_ADDR, | 45 | .properties_table = EFI_INVALID_TABLE_ADDR, |
46 | .mem_attr_table = EFI_INVALID_TABLE_ADDR, | ||
46 | }; | 47 | }; |
47 | EXPORT_SYMBOL(efi); | 48 | EXPORT_SYMBOL(efi); |
48 | 49 | ||
@@ -256,7 +257,7 @@ subsys_initcall(efisubsys_init); | |||
256 | */ | 257 | */ |
257 | int __init efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md) | 258 | int __init efi_mem_desc_lookup(u64 phys_addr, efi_memory_desc_t *out_md) |
258 | { | 259 | { |
259 | struct efi_memory_map *map = efi.memmap; | 260 | struct efi_memory_map *map = &efi.memmap; |
260 | phys_addr_t p, e; | 261 | phys_addr_t p, e; |
261 | 262 | ||
262 | if (!efi_enabled(EFI_MEMMAP)) { | 263 | if (!efi_enabled(EFI_MEMMAP)) { |
@@ -338,6 +339,7 @@ static __initdata efi_config_table_type_t common_tables[] = { | |||
338 | {UGA_IO_PROTOCOL_GUID, "UGA", &efi.uga}, | 339 | {UGA_IO_PROTOCOL_GUID, "UGA", &efi.uga}, |
339 | {EFI_SYSTEM_RESOURCE_TABLE_GUID, "ESRT", &efi.esrt}, | 340 | {EFI_SYSTEM_RESOURCE_TABLE_GUID, "ESRT", &efi.esrt}, |
340 | {EFI_PROPERTIES_TABLE_GUID, "PROP", &efi.properties_table}, | 341 | {EFI_PROPERTIES_TABLE_GUID, "PROP", &efi.properties_table}, |
342 | {EFI_MEMORY_ATTRIBUTES_TABLE_GUID, "MEMATTR", &efi.mem_attr_table}, | ||
341 | {NULL_GUID, NULL, NULL}, | 343 | {NULL_GUID, NULL, NULL}, |
342 | }; | 344 | }; |
343 | 345 | ||
@@ -351,8 +353,9 @@ static __init int match_config_table(efi_guid_t *guid, | |||
351 | for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) { | 353 | for (i = 0; efi_guidcmp(table_types[i].guid, NULL_GUID); i++) { |
352 | if (!efi_guidcmp(*guid, table_types[i].guid)) { | 354 | if (!efi_guidcmp(*guid, table_types[i].guid)) { |
353 | *(table_types[i].ptr) = table; | 355 | *(table_types[i].ptr) = table; |
354 | pr_cont(" %s=0x%lx ", | 356 | if (table_types[i].name) |
355 | table_types[i].name, table); | 357 | pr_cont(" %s=0x%lx ", |
358 | table_types[i].name, table); | ||
356 | return 1; | 359 | return 1; |
357 | } | 360 | } |
358 | } | 361 | } |
@@ -620,16 +623,12 @@ char * __init efi_md_typeattr_format(char *buf, size_t size, | |||
620 | */ | 623 | */ |
621 | u64 __weak efi_mem_attributes(unsigned long phys_addr) | 624 | u64 __weak efi_mem_attributes(unsigned long phys_addr) |
622 | { | 625 | { |
623 | struct efi_memory_map *map; | ||
624 | efi_memory_desc_t *md; | 626 | efi_memory_desc_t *md; |
625 | void *p; | ||
626 | 627 | ||
627 | if (!efi_enabled(EFI_MEMMAP)) | 628 | if (!efi_enabled(EFI_MEMMAP)) |
628 | return 0; | 629 | return 0; |
629 | 630 | ||
630 | map = efi.memmap; | 631 | for_each_efi_memory_desc(md) { |
631 | for (p = map->map; p < map->map_end; p += map->desc_size) { | ||
632 | md = p; | ||
633 | if ((md->phys_addr <= phys_addr) && | 632 | if ((md->phys_addr <= phys_addr) && |
634 | (phys_addr < (md->phys_addr + | 633 | (phys_addr < (md->phys_addr + |
635 | (md->num_pages << EFI_PAGE_SHIFT)))) | 634 | (md->num_pages << EFI_PAGE_SHIFT)))) |
@@ -637,3 +636,36 @@ u64 __weak efi_mem_attributes(unsigned long phys_addr) | |||
637 | } | 636 | } |
638 | return 0; | 637 | return 0; |
639 | } | 638 | } |
639 | |||
640 | int efi_status_to_err(efi_status_t status) | ||
641 | { | ||
642 | int err; | ||
643 | |||
644 | switch (status) { | ||
645 | case EFI_SUCCESS: | ||
646 | err = 0; | ||
647 | break; | ||
648 | case EFI_INVALID_PARAMETER: | ||
649 | err = -EINVAL; | ||
650 | break; | ||
651 | case EFI_OUT_OF_RESOURCES: | ||
652 | err = -ENOSPC; | ||
653 | break; | ||
654 | case EFI_DEVICE_ERROR: | ||
655 | err = -EIO; | ||
656 | break; | ||
657 | case EFI_WRITE_PROTECTED: | ||
658 | err = -EROFS; | ||
659 | break; | ||
660 | case EFI_SECURITY_VIOLATION: | ||
661 | err = -EACCES; | ||
662 | break; | ||
663 | case EFI_NOT_FOUND: | ||
664 | err = -ENOENT; | ||
665 | break; | ||
666 | default: | ||
667 | err = -EINVAL; | ||
668 | } | ||
669 | |||
670 | return err; | ||
671 | } | ||