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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'efi-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip into master

Pull EFI fixes from Ingo Molnar:
"Various EFI fixes:

- Fix the layering violation in the use of the EFI runtime services
availability mask in users of the 'efivars' abstraction

- Revert build fix for GCC v4.8 which is no longer supported

- Clean up some x86 EFI stub details, some of which are borderline
bugs that copy around garbage into padding fields - let's fix these
out of caution.

- Fix build issues while working on RISC-V support

- Avoid --whole-archive when linking the stub on arm64"

* tag 'efi-urgent-2020-07-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
efi: Revert "efi/x86: Fix build with gcc 4"
efi/efivars: Expose RT service availability via efivars abstraction
efi/libstub: Move the function prototypes to header file
efi/libstub: Fix gcc error around __umoddi3 for 32 bit builds
efi/libstub/arm64: link stub lib.a conditionally
efi/x86: Only copy upto the end of setup_header
efi/x86: Remove unused variables

+43 -40
+1 -1
arch/arm64/Makefile
··· 137 137 138 138 core-y += arch/arm64/ 139 139 libs-y := arch/arm64/lib/ $(libs-y) 140 - core-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a 140 + libs-$(CONFIG_EFI_STUB) += $(objtree)/drivers/firmware/efi/libstub/lib.a 141 141 142 142 # Default target when executing plain make 143 143 boot := arch/arm64/boot
+1 -4
drivers/firmware/efi/efi-pstore.c
··· 356 356 357 357 static __init int efivars_pstore_init(void) 358 358 { 359 - if (!efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES)) 360 - return 0; 361 - 362 - if (!efivars_kobject()) 359 + if (!efivars_kobject() || !efivar_supports_writes()) 363 360 return 0; 364 361 365 362 if (efivars_pstore_disable)
+8 -4
drivers/firmware/efi/efi.c
··· 176 176 static int generic_ops_register(void) 177 177 { 178 178 generic_ops.get_variable = efi.get_variable; 179 - generic_ops.set_variable = efi.set_variable; 180 - generic_ops.set_variable_nonblocking = efi.set_variable_nonblocking; 181 179 generic_ops.get_next_variable = efi.get_next_variable; 182 180 generic_ops.query_variable_store = efi_query_variable_store; 183 181 182 + if (efi_rt_services_supported(EFI_RT_SUPPORTED_SET_VARIABLE)) { 183 + generic_ops.set_variable = efi.set_variable; 184 + generic_ops.set_variable_nonblocking = efi.set_variable_nonblocking; 185 + } 184 186 return efivars_register(&generic_efivars, &generic_ops, efi_kobj); 185 187 } 186 188 ··· 384 382 return -ENOMEM; 385 383 } 386 384 387 - if (efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES)) { 385 + if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE | 386 + EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) { 388 387 efivar_ssdt_load(); 389 388 error = generic_ops_register(); 390 389 if (error) ··· 419 416 err_remove_group: 420 417 sysfs_remove_group(efi_kobj, &efi_subsys_attr_group); 421 418 err_unregister: 422 - if (efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES)) 419 + if (efi_rt_services_supported(EFI_RT_SUPPORTED_GET_VARIABLE | 420 + EFI_RT_SUPPORTED_GET_NEXT_VARIABLE_NAME)) 423 421 generic_ops_unregister(); 424 422 err_put: 425 423 kobject_put(efi_kobj);
+1 -4
drivers/firmware/efi/efivars.c
··· 680 680 struct kobject *parent_kobj = efivars_kobject(); 681 681 int error = 0; 682 682 683 - if (!efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES)) 684 - return -ENODEV; 685 - 686 683 /* No efivars has been registered yet */ 687 - if (!parent_kobj) 684 + if (!parent_kobj || !efivar_supports_writes()) 688 685 return 0; 689 686 690 687 printk(KERN_INFO "EFI Variables Facility v%s %s\n", EFIVARS_VERSION,
+1 -2
drivers/firmware/efi/libstub/Makefile
··· 6 6 # enabled, even if doing so doesn't break the build. 7 7 # 8 8 cflags-$(CONFIG_X86_32) := -march=i386 9 - cflags-$(CONFIG_X86_64) := -mcmodel=small \ 10 - $(call cc-option,-maccumulate-outgoing-args) 9 + cflags-$(CONFIG_X86_64) := -mcmodel=small 11 10 cflags-$(CONFIG_X86) += -m$(BITS) -D__KERNEL__ \ 12 11 -fPIC -fno-strict-aliasing -mno-red-zone \ 13 12 -mno-mmx -mno-sse -fshort-wchar \
+1 -1
drivers/firmware/efi/libstub/alignedmem.c
··· 44 44 *addr = ALIGN((unsigned long)alloc_addr, align); 45 45 46 46 if (slack > 0) { 47 - int l = (alloc_addr % align) / EFI_PAGE_SIZE; 47 + int l = (alloc_addr & (align - 1)) / EFI_PAGE_SIZE; 48 48 49 49 if (l) { 50 50 efi_bs_call(free_pages, alloc_addr, slack - l + 1);
-17
drivers/firmware/efi/libstub/efi-stub.c
··· 122 122 } 123 123 124 124 /* 125 - * This function handles the architcture specific differences between arm and 126 - * arm64 regarding where the kernel image must be loaded and any memory that 127 - * must be reserved. On failure it is required to free all 128 - * all allocations it has made. 129 - */ 130 - efi_status_t handle_kernel_image(unsigned long *image_addr, 131 - unsigned long *image_size, 132 - unsigned long *reserve_addr, 133 - unsigned long *reserve_size, 134 - unsigned long dram_base, 135 - efi_loaded_image_t *image); 136 - 137 - asmlinkage void __noreturn efi_enter_kernel(unsigned long entrypoint, 138 - unsigned long fdt_addr, 139 - unsigned long fdt_size); 140 - 141 - /* 142 125 * EFI entry point for the arm/arm64 EFI stubs. This is the entrypoint 143 126 * that is described in the PE/COFF header. Most of the code is the same 144 127 * for both archictectures, with the arch-specific code provided in the
+16
drivers/firmware/efi/libstub/efistub.h
··· 776 776 unsigned long *load_size, 777 777 unsigned long soft_limit, 778 778 unsigned long hard_limit); 779 + /* 780 + * This function handles the architcture specific differences between arm and 781 + * arm64 regarding where the kernel image must be loaded and any memory that 782 + * must be reserved. On failure it is required to free all 783 + * all allocations it has made. 784 + */ 785 + efi_status_t handle_kernel_image(unsigned long *image_addr, 786 + unsigned long *image_size, 787 + unsigned long *reserve_addr, 788 + unsigned long *reserve_size, 789 + unsigned long dram_base, 790 + efi_loaded_image_t *image); 791 + 792 + asmlinkage void __noreturn efi_enter_kernel(unsigned long entrypoint, 793 + unsigned long fdt_addr, 794 + unsigned long fdt_size); 779 795 780 796 void efi_handle_post_ebs_state(void); 781 797
+4 -4
drivers/firmware/efi/libstub/x86-stub.c
··· 8 8 9 9 #include <linux/efi.h> 10 10 #include <linux/pci.h> 11 + #include <linux/stddef.h> 11 12 12 13 #include <asm/efi.h> 13 14 #include <asm/e820/types.h> ··· 362 361 int options_size = 0; 363 362 efi_status_t status; 364 363 char *cmdline_ptr; 365 - unsigned long ramdisk_addr; 366 - unsigned long ramdisk_size; 367 364 368 365 efi_system_table = sys_table_arg; 369 366 ··· 389 390 390 391 hdr = &boot_params->hdr; 391 392 392 - /* Copy the second sector to boot_params */ 393 - memcpy(&hdr->jump, image_base + 512, 512); 393 + /* Copy the setup header from the second sector to boot_params */ 394 + memcpy(&hdr->jump, image_base + 512, 395 + sizeof(struct setup_header) - offsetof(struct setup_header, jump)); 394 396 395 397 /* 396 398 * Fill out some of the header fields ourselves because the
+6
drivers/firmware/efi/vars.c
··· 1229 1229 return rv; 1230 1230 } 1231 1231 EXPORT_SYMBOL_GPL(efivars_unregister); 1232 + 1233 + int efivar_supports_writes(void) 1234 + { 1235 + return __efivars && __efivars->ops->set_variable; 1236 + } 1237 + EXPORT_SYMBOL_GPL(efivar_supports_writes);
+3 -3
fs/efivarfs/super.c
··· 201 201 sb->s_d_op = &efivarfs_d_ops; 202 202 sb->s_time_gran = 1; 203 203 204 + if (!efivar_supports_writes()) 205 + sb->s_flags |= SB_RDONLY; 206 + 204 207 inode = efivarfs_get_inode(sb, NULL, S_IFDIR | 0755, 0, true); 205 208 if (!inode) 206 209 return -ENOMEM; ··· 255 252 256 253 static __init int efivarfs_init(void) 257 254 { 258 - if (!efi_rt_services_supported(EFI_RT_SUPPORTED_VARIABLE_SERVICES)) 259 - return -ENODEV; 260 - 261 255 if (!efivars_kobject()) 262 256 return -ENODEV; 263 257
+1
include/linux/efi.h
··· 994 994 int efivars_unregister(struct efivars *efivars); 995 995 struct kobject *efivars_kobject(void); 996 996 997 + int efivar_supports_writes(void); 997 998 int efivar_init(int (*func)(efi_char16_t *, efi_guid_t, unsigned long, void *), 998 999 void *data, bool duplicates, struct list_head *head); 999 1000