diff options
| -rw-r--r-- | drivers/firmware/efi/capsule.c | 4 | ||||
| -rw-r--r-- | drivers/firmware/efi/efi.c | 31 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/efi-stub-entry.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/efi-stub-helper.c | 10 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/efi-stub.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/file.c | 8 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/gop.c | 17 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/kaslr.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/mem.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/pci.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/random.c | 8 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/riscv.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/smbios.c | 3 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/tpm.c | 8 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/unaccepted_memory.c | 2 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/x86-stub.c | 13 | ||||
| -rw-r--r-- | drivers/firmware/efi/libstub/zboot.c | 3 | ||||
| -rw-r--r-- | drivers/firmware/efi/runtime-wrappers.c | 28 | ||||
| -rw-r--r-- | include/linux/efi.h | 1 |
19 files changed, 107 insertions, 41 deletions
diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index dd62526380d2..417e8f13a014 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c @@ -245,7 +245,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages) for (i = 0; i < sg_count; i++) { efi_capsule_block_desc_t *sglist; - sglist = kmap_atomic(sg_pages[i]); + sglist = kmap_local_page(sg_pages[i]); for (j = 0; j < SGLIST_PER_PAGE && count > 0; j++) { u64 sz = min_t(u64, imagesize, @@ -277,7 +277,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages) */ efi_capsule_flush_cache_range(sglist, PAGE_SIZE); #endif - kunmap_atomic(sglist); + kunmap_local(sglist); } mutex_lock(&capsule_mutex); diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index 0327a39d31fa..6d987d7f9778 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c @@ -401,6 +401,32 @@ static void __init efi_debugfs_init(void) static inline void efi_debugfs_init(void) {} #endif +static ssize_t efi_runtime_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) +{ + return sprintf(buf, "%d\n", efi_enabled(EFI_RUNTIME_SERVICES)); +} + +static ssize_t efi_runtime_store(struct kobject *kobj, struct kobj_attribute *attr, + const char *buf, size_t count) +{ + int ret; + bool enable; + + ret = kstrtobool(buf, &enable); + if (ret) + return ret; + + if (efi_runtime_set_enable_flag(enable) != EFI_SUCCESS) { + pr_warn("unable to enable/disable efi runtime service\n"); + return -EAGAIN; + } + + return count; +} + +static struct kobj_attribute efi_runtime_attr = + __ATTR(runtime_enable, 0644, efi_runtime_show, efi_runtime_store); + static int __init efipostcore_init(void) { if (!efi_enabled(EFI_RUNTIME_SERVICES)) @@ -446,6 +472,11 @@ static int __init efisubsys_init(void) goto err_destroy_wq; } + if (IS_ENABLED(CONFIG_PREEMPT_RT) && efi.runtime_supported_mask) { + if (sysfs_create_file(efi_kobj, &efi_runtime_attr.attr)) + pr_warn("unable to register efi dynamic sysfs interface\n"); + } + if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE | EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) { error = generic_ops_register(); diff --git a/drivers/firmware/efi/libstub/efi-stub-entry.c b/drivers/firmware/efi/libstub/efi-stub-entry.c index aa85e910fe59..8ecd8cd72561 100644 --- a/drivers/firmware/efi/libstub/efi-stub-entry.c +++ b/drivers/firmware/efi/libstub/efi-stub-entry.c @@ -35,13 +35,13 @@ struct sysfb_display_info *alloc_primary_display(void) efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, efi_system_table_t *systab) { + static efi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID; efi_loaded_image_t *image; efi_status_t status; unsigned long image_addr; unsigned long image_size = 0; /* addr/point and size pairs for memory management*/ char *cmdline_ptr = NULL; - efi_guid_t loaded_image_proto = LOADED_IMAGE_PROTOCOL_GUID; unsigned long reserve_addr = 0; unsigned long reserve_size = 0; diff --git a/drivers/firmware/efi/libstub/efi-stub-helper.c b/drivers/firmware/efi/libstub/efi-stub-helper.c index f27f2e1f0019..48f93f7758e9 100644 --- a/drivers/firmware/efi/libstub/efi-stub-helper.c +++ b/drivers/firmware/efi/libstub/efi-stub-helper.c @@ -248,6 +248,7 @@ static efi_status_t efi_measure_tagged_event(unsigned long load_addr, unsigned long load_size, enum efistub_event_type event) { + static efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID; union { efi_status_t (__efiapi *hash_log_extend_event)(void *, u64, efi_physical_addr_t, @@ -257,7 +258,6 @@ static efi_status_t efi_measure_tagged_event(unsigned long load_addr, struct efistub_measured_event *evt __free(efi_pool) = NULL; int size = struct_size(evt, tagged_event.tagged_event_data, events[event].event_data_len); - efi_guid_t tcg2_guid = EFI_TCG2_PROTOCOL_GUID; efi_tcg2_protocol_t *tcg2 = NULL; union efistub_event ev; efi_status_t status; @@ -276,7 +276,7 @@ static efi_status_t efi_measure_tagged_event(unsigned long load_addr, method.hash_log_extend_event = (void *)efi_table_attr(tcg2, hash_log_extend_event); } else { - efi_guid_t cc_guid = EFI_CC_MEASUREMENT_PROTOCOL_GUID; + static efi_guid_t cc_guid = EFI_CC_MEASUREMENT_PROTOCOL_GUID; efi_cc_protocol_t *cc = NULL; efi_bs_call(locate_protocol, &cc_guid, NULL, (void **)&cc); @@ -552,7 +552,7 @@ static efi_status_t efi_load_initrd_dev_path(struct linux_efi_initrd *initrd, unsigned long max) { - efi_guid_t lf2_proto_guid = EFI_LOAD_FILE2_PROTOCOL_GUID; + static efi_guid_t lf2_proto_guid = EFI_LOAD_FILE2_PROTOCOL_GUID; efi_device_path_protocol_t *dp; efi_load_file2_protocol_t *lf2; efi_handle_t handle; @@ -614,7 +614,7 @@ efi_status_t efi_load_initrd(efi_loaded_image_t *image, unsigned long hard_limit, const struct linux_efi_initrd **out) { - efi_guid_t tbl_guid = LINUX_EFI_INITRD_MEDIA_GUID; + static efi_guid_t tbl_guid = LINUX_EFI_INITRD_MEDIA_GUID; efi_status_t status = EFI_SUCCESS; struct linux_efi_initrd initrd, *tbl; @@ -725,7 +725,7 @@ efi_status_t efi_wait_for_key(unsigned long usec, efi_input_key_t *key) void efi_remap_image(unsigned long image_base, unsigned alloc_size, unsigned long code_size) { - efi_guid_t guid = EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; + static efi_guid_t guid = EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; efi_memory_attribute_protocol_t *memattr; efi_status_t status; u64 attr; diff --git a/drivers/firmware/efi/libstub/efi-stub.c b/drivers/firmware/efi/libstub/efi-stub.c index 42d6073bcd06..235c9738da2d 100644 --- a/drivers/firmware/efi/libstub/efi-stub.c +++ b/drivers/firmware/efi/libstub/efi-stub.c @@ -79,8 +79,8 @@ err_free_primary_display: static void install_memreserve_table(void) { + static efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; struct linux_efi_memreserve *rsv; - efi_guid_t memreserve_table_guid = LINUX_EFI_MEMRESERVE_TABLE_GUID; efi_status_t status; status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, sizeof(*rsv), diff --git a/drivers/firmware/efi/libstub/file.c b/drivers/firmware/efi/libstub/file.c index bd626d55dcbc..b2601e284695 100644 --- a/drivers/firmware/efi/libstub/file.c +++ b/drivers/firmware/efi/libstub/file.c @@ -29,6 +29,8 @@ */ #define EFI_READ_CHUNK_SIZE SZ_1M +static efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; + struct finfo { efi_file_info_t info; efi_char16_t filename[MAX_FILENAME_SIZE]; @@ -39,7 +41,7 @@ static efi_status_t efi_open_file(efi_file_protocol_t *volume, efi_file_protocol_t **handle, unsigned long *file_size) { - efi_guid_t info_guid = EFI_FILE_INFO_ID; + static efi_guid_t info_guid = EFI_FILE_INFO_ID; efi_file_protocol_t *fh; unsigned long info_sz; efi_status_t status; @@ -74,7 +76,6 @@ static efi_status_t efi_open_file(efi_file_protocol_t *volume, static efi_status_t efi_open_volume(efi_loaded_image_t *image, efi_file_protocol_t **fh) { - efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; efi_simple_file_system_protocol_t *io; efi_status_t status; @@ -128,9 +129,8 @@ static int find_file_option(const efi_char16_t *cmdline, int cmdline_len, static efi_status_t efi_open_device_path(efi_file_protocol_t **volume, struct finfo *fi) { - efi_guid_t text_to_dp_guid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; + static efi_guid_t text_to_dp_guid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID; static efi_device_path_from_text_protocol_t *text_to_dp = NULL; - efi_guid_t fs_proto = EFI_FILE_SYSTEM_GUID; efi_device_path_protocol_t *initrd_dp; efi_simple_file_system_protocol_t *io; struct efi_file_path_dev_path *fpath; diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c index 80dc8cfeb33e..fa324d4abcaa 100644 --- a/drivers/firmware/efi/libstub/gop.c +++ b/drivers/firmware/efi/libstub/gop.c @@ -24,6 +24,8 @@ enum efi_cmdline_option { EFI_CMDLINE_LIST }; +static efi_guid_t graphics_output_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; + static struct { enum efi_cmdline_option option; union { @@ -425,6 +427,7 @@ static void setup_edid_info(struct edid_info *edid, u32 gop_size_of_edid, u8 *go static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_handle_t handles[], efi_graphics_output_protocol_t **found_gop) { + static efi_guid_t console_out_device_guid = EFI_CONSOLE_OUT_DEVICE_GUID; efi_graphics_output_protocol_t *first_gop; efi_handle_t h, first_gop_handle; @@ -439,8 +442,7 @@ static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_ha efi_graphics_output_mode_info_t *info; void *dummy = NULL; - status = efi_bs_call(handle_protocol, h, - &EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID, + status = efi_bs_call(handle_protocol, h, &graphics_output_guid, (void **)&gop); if (status != EFI_SUCCESS) continue; @@ -462,7 +464,7 @@ static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_ha * don't bother looking any further. */ status = efi_bs_call(handle_protocol, h, - &EFI_CONSOLE_OUT_DEVICE_GUID, &dummy); + &console_out_device_guid, &dummy); if (status == EFI_SUCCESS) { if (found_gop) *found_gop = gop; @@ -480,6 +482,8 @@ static efi_handle_t find_handle_with_primary_gop(unsigned long num, const efi_ha efi_status_t efi_setup_graphics(struct screen_info *si, struct edid_info *edid) { + static efi_guid_t edid_active_guid = EFI_EDID_ACTIVE_PROTOCOL_GUID; + static efi_guid_t edid_discovered_guid = EFI_EDID_DISCOVERED_PROTOCOL_GUID; efi_handle_t *handles __free(efi_pool) = NULL; efi_handle_t handle; efi_graphics_output_protocol_t *gop; @@ -487,8 +491,7 @@ efi_status_t efi_setup_graphics(struct screen_info *si, struct edid_info *edid) unsigned long num; status = efi_bs_call(locate_handle_buffer, EFI_LOCATE_BY_PROTOCOL, - &EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID, NULL, &num, - &handles); + &graphics_output_guid, NULL, &num, &handles); if (status != EFI_SUCCESS) return status; @@ -510,14 +513,14 @@ efi_status_t efi_setup_graphics(struct screen_info *si, struct edid_info *edid) u32 gop_size_of_edid = 0; u8 *gop_edid = NULL; - status = efi_bs_call(handle_protocol, handle, &EFI_EDID_ACTIVE_PROTOCOL_GUID, + status = efi_bs_call(handle_protocol, handle, &edid_active_guid, (void **)&active_edid); if (status == EFI_SUCCESS) { gop_size_of_edid = efi_table_attr(active_edid, size_of_edid); gop_edid = efi_table_attr(active_edid, edid); } else { status = efi_bs_call(handle_protocol, handle, - &EFI_EDID_DISCOVERED_PROTOCOL_GUID, + &edid_discovered_guid, (void **)&discovered_edid); if (status == EFI_SUCCESS) { gop_size_of_edid = efi_table_attr(discovered_edid, size_of_edid); diff --git a/drivers/firmware/efi/libstub/kaslr.c b/drivers/firmware/efi/libstub/kaslr.c index 4bc963e999eb..f5074656457a 100644 --- a/drivers/firmware/efi/libstub/kaslr.c +++ b/drivers/firmware/efi/libstub/kaslr.c @@ -18,7 +18,7 @@ */ u32 efi_kaslr_get_phys_seed(efi_handle_t image_handle) { - efi_guid_t li_fixed_proto = LINUX_EFI_LOADED_IMAGE_FIXED_GUID; + static efi_guid_t li_fixed_proto = LINUX_EFI_LOADED_IMAGE_FIXED_GUID; void *p; if (!IS_ENABLED(CONFIG_RANDOMIZE_BASE)) diff --git a/drivers/firmware/efi/libstub/mem.c b/drivers/firmware/efi/libstub/mem.c index 59f3f83de50c..fec561e3a792 100644 --- a/drivers/firmware/efi/libstub/mem.c +++ b/drivers/firmware/efi/libstub/mem.c @@ -20,10 +20,10 @@ efi_status_t efi_get_memory_map(struct efi_boot_memmap **map, bool install_cfg_tbl) { + static efi_guid_t tbl_guid = LINUX_EFI_BOOT_MEMMAP_GUID; struct efi_boot_memmap tmp, *m __free(efi_pool) = NULL; int memtype = install_cfg_tbl ? EFI_ACPI_RECLAIM_MEMORY : EFI_LOADER_DATA; - efi_guid_t tbl_guid = LINUX_EFI_BOOT_MEMMAP_GUID; efi_status_t status; unsigned long size; diff --git a/drivers/firmware/efi/libstub/pci.c b/drivers/firmware/efi/libstub/pci.c index 1dccf77958d3..5daa7a0a0e87 100644 --- a/drivers/firmware/efi/libstub/pci.c +++ b/drivers/firmware/efi/libstub/pci.c @@ -15,7 +15,7 @@ void efi_pci_disable_bridge_busmaster(void) { - efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; + static efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; efi_handle_t *pci_handle __free(efi_pool) = NULL; unsigned long pci_handle_num; efi_handle_t handle; diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c index 7109b8a2dcba..d63262d36e47 100644 --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c @@ -8,6 +8,8 @@ #include "efistub.h" +static efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; + typedef union efi_rng_protocol efi_rng_protocol_t; union efi_rng_protocol { @@ -38,7 +40,6 @@ union efi_rng_protocol { */ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out) { - efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; efi_status_t status; efi_rng_protocol_t *rng = NULL; @@ -64,9 +65,8 @@ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out) */ efi_status_t efi_random_get_seed(void) { - efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; - efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; - efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; + static efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; + static efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; struct linux_efi_random_seed *prev_seed, *seed = NULL; int prev_seed_size = 0, seed_size = EFI_RANDOM_SEED_SIZE; unsigned long nv_seed_size = 0, offset = 0; diff --git a/drivers/firmware/efi/libstub/riscv.c b/drivers/firmware/efi/libstub/riscv.c index f66f33ceb99e..49db47c05bfe 100644 --- a/drivers/firmware/efi/libstub/riscv.c +++ b/drivers/firmware/efi/libstub/riscv.c @@ -45,7 +45,7 @@ static int get_boot_hartid_from_fdt(void) static efi_status_t get_boot_hartid_from_efi(void) { - efi_guid_t boot_protocol_guid = RISCV_EFI_BOOT_PROTOCOL_GUID; + static efi_guid_t boot_protocol_guid = RISCV_EFI_BOOT_PROTOCOL_GUID; struct riscv_efi_boot_protocol *boot_protocol; efi_status_t status; diff --git a/drivers/firmware/efi/libstub/smbios.c b/drivers/firmware/efi/libstub/smbios.c index f31410d7e7e1..efbbfc3c2c0d 100644 --- a/drivers/firmware/efi/libstub/smbios.c +++ b/drivers/firmware/efi/libstub/smbios.c @@ -35,12 +35,13 @@ union efi_smbios_protocol { const struct efi_smbios_record *efi_get_smbios_record(u8 type) { + static efi_guid_t smbios_guid = EFI_SMBIOS_PROTOCOL_GUID; struct efi_smbios_record *record; efi_smbios_protocol_t *smbios; efi_status_t status; u16 handle = 0xfffe; - status = efi_bs_call(locate_protocol, &EFI_SMBIOS_PROTOCOL_GUID, NULL, + status = efi_bs_call(locate_protocol, &smbios_guid, NULL, (void **)&smbios) ?: efi_call_proto(smbios, get_next, &handle, &type, &record, NULL); if (status != EFI_SUCCESS) diff --git a/drivers/firmware/efi/libstub/tpm.c b/drivers/firmware/efi/libstub/tpm.c index a5c6c4f163fc..73f001114732 100644 --- a/drivers/firmware/efi/libstub/tpm.c +++ b/drivers/firmware/efi/libstub/tpm.c @@ -28,8 +28,8 @@ static const efi_char16_t efi_MemoryOverWriteRequest_name[] = */ void efi_enable_reset_attack_mitigation(void) { + static efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID; u8 val = 1; - efi_guid_t var_guid = MEMORY_ONLY_RESET_CONTROL_GUID; efi_status_t status; unsigned long datasize = 0; @@ -52,7 +52,7 @@ static void efi_retrieve_tcg2_eventlog(int version, efi_physical_addr_t log_loca efi_bool_t truncated, struct efi_tcg2_final_events_table *final_events_table) { - efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; + static efi_guid_t linux_eventlog_guid = LINUX_EFI_TPM_EVENT_LOG_GUID; efi_status_t status; struct linux_efi_tpm_eventlog *log_tbl = NULL; unsigned long first_entry_addr, last_entry_addr; @@ -150,9 +150,9 @@ err_free: void efi_retrieve_eventlog(void) { + static efi_guid_t tpm2_guid = EFI_TCG2_PROTOCOL_GUID; struct efi_tcg2_final_events_table *final_events_table = NULL; efi_physical_addr_t log_location = 0, log_last_entry = 0; - efi_guid_t tpm2_guid = EFI_TCG2_PROTOCOL_GUID; int version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2; efi_tcg2_protocol_t *tpm2 = NULL; efi_bool_t truncated; @@ -173,7 +173,7 @@ void efi_retrieve_eventlog(void) get_efi_config_table(EFI_TCG2_FINAL_EVENTS_TABLE_GUID); } } else { - efi_guid_t cc_guid = EFI_CC_MEASUREMENT_PROTOCOL_GUID; + static efi_guid_t cc_guid = EFI_CC_MEASUREMENT_PROTOCOL_GUID; efi_cc_protocol_t *cc = NULL; status = efi_bs_call(locate_protocol, &cc_guid, NULL, (void **)&cc); diff --git a/drivers/firmware/efi/libstub/unaccepted_memory.c b/drivers/firmware/efi/libstub/unaccepted_memory.c index 757dbe734a47..2a7eac7fef86 100644 --- a/drivers/firmware/efi/libstub/unaccepted_memory.c +++ b/drivers/firmware/efi/libstub/unaccepted_memory.c @@ -9,7 +9,7 @@ struct efi_unaccepted_memory *unaccepted_table; efi_status_t allocate_unaccepted_bitmap(__u32 nr_desc, struct efi_boot_memmap *map) { - efi_guid_t unaccepted_table_guid = LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID; + static efi_guid_t unaccepted_table_guid = LINUX_EFI_UNACCEPTED_MEM_TABLE_GUID; u64 unaccepted_start = ULLONG_MAX, unaccepted_end = 0, bitmap_size; efi_status_t status; int i; diff --git a/drivers/firmware/efi/libstub/x86-stub.c b/drivers/firmware/efi/libstub/x86-stub.c index cef32e2c82d8..0bae0f06b676 100644 --- a/drivers/firmware/efi/libstub/x86-stub.c +++ b/drivers/firmware/efi/libstub/x86-stub.c @@ -114,9 +114,9 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) */ static void setup_efi_pci(struct boot_params *params) { + static efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; efi_status_t status; efi_handle_t *pci_handle __free(efi_pool) = NULL; - efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID; struct setup_data *data; unsigned long num; efi_handle_t h; @@ -155,7 +155,7 @@ static void setup_efi_pci(struct boot_params *params) static void retrieve_apple_device_properties(struct boot_params *boot_params) { - efi_guid_t guid = APPLE_PROPERTIES_PROTOCOL_GUID; + static efi_guid_t guid = APPLE_PROPERTIES_PROTOCOL_GUID; struct setup_data *data, *new; efi_status_t status; u32 size = 0; @@ -335,6 +335,7 @@ static bool apple_match_product_name(void) static void apple_set_os(void) { + static efi_guid_t apple_set_os_guid = APPLE_SET_OS_PROTOCOL_GUID; struct { unsigned long version; efi_status_t (__efiapi *set_os_version)(const char *); @@ -345,7 +346,7 @@ static void apple_set_os(void) if (!efi_is_64bit() || !apple_match_product_name()) return; - status = efi_bs_call(locate_protocol, &APPLE_SET_OS_PROTOCOL_GUID, NULL, + status = efi_bs_call(locate_protocol, &apple_set_os_guid, NULL, (void **)&set_os); if (status != EFI_SUCCESS) return; @@ -444,7 +445,7 @@ efi_status_t efi_adjust_memory_range_protection(unsigned long start, static void setup_unaccepted_memory(void) { - efi_guid_t mem_acceptance_proto = OVMF_SEV_MEMORY_ACCEPTANCE_PROTOCOL_GUID; + static efi_guid_t mem_acceptance_proto = OVMF_SEV_MEMORY_ACCEPTANCE_PROTOCOL_GUID; sev_memory_acceptance_protocol_t *proto; efi_status_t status; @@ -507,7 +508,7 @@ static void __noreturn efi_exit(efi_handle_t handle, efi_status_t status) static efi_status_t efi_allocate_bootparams(efi_handle_t handle, struct boot_params **bp) { - efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID; + static efi_guid_t proto = LOADED_IMAGE_PROTOCOL_GUID; struct boot_params *boot_params; struct setup_header *hdr; efi_status_t status; @@ -914,7 +915,7 @@ void __noreturn efi_stub_entry(efi_handle_t handle, struct boot_params *boot_params) { - efi_guid_t guid = EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; + static efi_guid_t guid = EFI_MEMORY_ATTRIBUTE_PROTOCOL_GUID; const struct linux_efi_initrd *initrd = NULL; unsigned long kernel_entry; struct setup_header *hdr; diff --git a/drivers/firmware/efi/libstub/zboot.c b/drivers/firmware/efi/libstub/zboot.c index 4b76f74c56da..4a5ffe164873 100644 --- a/drivers/firmware/efi/libstub/zboot.c +++ b/drivers/firmware/efi/libstub/zboot.c @@ -34,6 +34,7 @@ struct sysfb_display_info *alloc_primary_display(void) asmlinkage efi_status_t __efiapi efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab) { + static efi_guid_t loaded_image_guid = LOADED_IMAGE_PROTOCOL_GUID; char *cmdline_ptr __free(efi_pool) = NULL; unsigned long image_base, alloc_size; efi_loaded_image_t *image; @@ -42,7 +43,7 @@ efi_zboot_entry(efi_handle_t handle, efi_system_table_t *systab) WRITE_ONCE(efi_system_table, systab); status = efi_bs_call(handle_protocol, handle, - &LOADED_IMAGE_PROTOCOL_GUID, (void **)&image); + &loaded_image_guid, (void **)&image); if (status != EFI_SUCCESS) { efi_err("Failed to locate parent's loaded image protocol\n"); return status; diff --git a/drivers/firmware/efi/runtime-wrappers.c b/drivers/firmware/efi/runtime-wrappers.c index 2344b9d1e81f..740f422df337 100644 --- a/drivers/firmware/efi/runtime-wrappers.c +++ b/drivers/firmware/efi/runtime-wrappers.c @@ -652,3 +652,31 @@ void efi_runtime_assert_lock_held(void) { WARN_ON(efi_runtime_lock_owner != current); } + +efi_status_t efi_runtime_set_enable_flag(bool enable) +{ + static bool runtime_disabled; + efi_status_t ret = EFI_NOT_READY; + + if (down_interruptible(&efi_runtime_lock)) + return EFI_ABORTED; + + if (enable) { + /* It could be enabled only if it is disabled here */ + if (runtime_disabled) { + set_bit(EFI_RUNTIME_SERVICES, &efi.flags); + runtime_disabled = false; + ret = EFI_SUCCESS; + } + } else { + if (efi_enabled(EFI_RUNTIME_SERVICES)) { + clear_bit(EFI_RUNTIME_SERVICES, &efi.flags); + runtime_disabled = true; + ret = EFI_SUCCESS; + } + } + + up(&efi_runtime_lock); + + return ret; +} diff --git a/include/linux/efi.h b/include/linux/efi.h index aa15ff88539b..c35446a0b66f 100644 --- a/include/linux/efi.h +++ b/include/linux/efi.h @@ -1109,6 +1109,7 @@ extern void efi_call_virt_check_flags(unsigned long flags, const void *caller); extern unsigned long efi_call_virt_save_flags(void); void efi_runtime_assert_lock_held(void); +efi_status_t efi_runtime_set_enable_flag(bool enable); enum efi_secureboot_mode { efi_secureboot_mode_unset, |
