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-fixes-for-v6.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi

Pull EFI fixes from Ard Biesheuvel:
"The only notable change here is the patch that changes the way we deal
with spurious errors from the EFI memory attribute protocol. This will
be backported to v6.6, and is intended to ensure that we will not
paint ourselves into a corner when we tighten this further in order to
comply with MS requirements on signed EFI code.

Note that this protocol does not currently exist in x86 production
systems in the field, only in Microsoft's fork of OVMF, but it will be
mandatory for Windows logo certification for x86 PCs in the future.

- Tighten ELF relocation checks on the RISC-V EFI stub

- Give up if the new EFI memory attributes protocol fails spuriously
on x86

- Take care not to place the kernel in the lowest 16 MB of DRAM on
x86

- Omit special purpose EFI memory from memblock

- Some fixes for the CXL CPER reporting code

- Make the PE/COFF layout of mixed-mode capable images comply with a
strict interpretation of the spec"

* tag 'efi-fixes-for-v6.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi:
x86/efistub: Use 1:1 file:memory mapping for PE/COFF .compat section
cxl/trace: Remove unnecessary memcpy's
cxl/cper: Fix errant CPER prints for CXL events
efi: Don't add memblocks for soft-reserved memory
efi: runtime: Fix potential overflow of soft-reserved region size
efi/libstub: Add one kernel-doc comment
x86/efistub: Avoid placing the kernel below LOAD_PHYSICAL_ADDR
x86/efistub: Give up if memory attribute protocol returns an error
riscv/efistub: Tighten ELF relocation check
riscv/efistub: Ensure GP-relative addressing is not used

+97 -73
+6 -8
arch/x86/boot/header.S
··· 106 106 .word 0 # MinorSubsystemVersion 107 107 .long 0 # Win32VersionValue 108 108 109 - .long setup_size + ZO__end + pecompat_vsize 110 - # SizeOfImage 109 + .long setup_size + ZO__end # SizeOfImage 111 110 112 111 .long salign # SizeOfHeaders 113 112 .long 0 # CheckSum ··· 142 143 .ascii ".setup" 143 144 .byte 0 144 145 .byte 0 145 - .long setup_size - salign # VirtualSize 146 + .long pecompat_fstart - salign # VirtualSize 146 147 .long salign # VirtualAddress 147 148 .long pecompat_fstart - salign # SizeOfRawData 148 149 .long salign # PointerToRawData ··· 155 156 #ifdef CONFIG_EFI_MIXED 156 157 .asciz ".compat" 157 158 158 - .long 8 # VirtualSize 159 - .long setup_size + ZO__end # VirtualAddress 159 + .long pecompat_fsize # VirtualSize 160 + .long pecompat_fstart # VirtualAddress 160 161 .long pecompat_fsize # SizeOfRawData 161 162 .long pecompat_fstart # PointerToRawData 162 163 ··· 171 172 * modes this image supports. 172 173 */ 173 174 .pushsection ".pecompat", "a", @progbits 174 - .balign falign 175 - .set pecompat_vsize, salign 175 + .balign salign 176 176 .globl pecompat_fstart 177 177 pecompat_fstart: 178 178 .byte 0x1 # Version 179 179 .byte 8 # Size 180 180 .word IMAGE_FILE_MACHINE_I386 # PE machine type 181 181 .long setup_size + ZO_efi32_pe_entry # Entrypoint 182 + .byte 0x0 # Sentinel 182 183 .popsection 183 184 #else 184 - .set pecompat_vsize, 0 185 185 .set pecompat_fstart, setup_size 186 186 #endif 187 187 .ascii ".text"
+3 -3
arch/x86/boot/setup.ld
··· 24 24 .text : { *(.text .text.*) } 25 25 .text32 : { *(.text32) } 26 26 27 + .pecompat : { *(.pecompat) } 28 + PROVIDE(pecompat_fsize = setup_size - pecompat_fstart); 29 + 27 30 . = ALIGN(16); 28 31 .rodata : { *(.rodata*) } 29 32 ··· 38 35 39 36 . = ALIGN(16); 40 37 .data : { *(.data*) } 41 - 42 - .pecompat : { *(.pecompat) } 43 - PROVIDE(pecompat_fsize = setup_size - pecompat_fstart); 44 38 45 39 .signature : { 46 40 setup_sig = .;
-26
drivers/acpi/apei/ghes.c
··· 680 680 static DECLARE_RWSEM(cxl_cper_rw_sem); 681 681 static cxl_cper_callback cper_callback; 682 682 683 - /* CXL Event record UUIDs are formatted as GUIDs and reported in section type */ 684 - 685 - /* 686 - * General Media Event Record 687 - * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 688 - */ 689 - #define CPER_SEC_CXL_GEN_MEDIA_GUID \ 690 - GUID_INIT(0xfbcd0a77, 0xc260, 0x417f, \ 691 - 0x85, 0xa9, 0x08, 0x8b, 0x16, 0x21, 0xeb, 0xa6) 692 - 693 - /* 694 - * DRAM Event Record 695 - * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 696 - */ 697 - #define CPER_SEC_CXL_DRAM_GUID \ 698 - GUID_INIT(0x601dcbb3, 0x9c06, 0x4eab, \ 699 - 0xb8, 0xaf, 0x4e, 0x9b, 0xfb, 0x5c, 0x96, 0x24) 700 - 701 - /* 702 - * Memory Module Event Record 703 - * CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45 704 - */ 705 - #define CPER_SEC_CXL_MEM_MODULE_GUID \ 706 - GUID_INIT(0xfe927475, 0xdd59, 0x4339, \ 707 - 0xa5, 0x86, 0x79, 0xba, 0xb1, 0x13, 0xb7, 0x74) 708 - 709 683 static void cxl_cper_post_event(enum cxl_event_type event_type, 710 684 struct cxl_cper_event_rec *rec) 711 685 {
+3 -3
drivers/cxl/core/trace.h
··· 338 338 339 339 TP_fast_assign( 340 340 CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); 341 - memcpy(&__entry->hdr_uuid, &CXL_EVENT_GEN_MEDIA_UUID, sizeof(uuid_t)); 341 + __entry->hdr_uuid = CXL_EVENT_GEN_MEDIA_UUID; 342 342 343 343 /* General Media */ 344 344 __entry->dpa = le64_to_cpu(rec->phys_addr); ··· 425 425 426 426 TP_fast_assign( 427 427 CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); 428 - memcpy(&__entry->hdr_uuid, &CXL_EVENT_DRAM_UUID, sizeof(uuid_t)); 428 + __entry->hdr_uuid = CXL_EVENT_DRAM_UUID; 429 429 430 430 /* DRAM */ 431 431 __entry->dpa = le64_to_cpu(rec->phys_addr); ··· 573 573 574 574 TP_fast_assign( 575 575 CXL_EVT_TP_fast_assign(cxlmd, log, rec->hdr); 576 - memcpy(&__entry->hdr_uuid, &CXL_EVENT_MEM_MODULE_UUID, sizeof(uuid_t)); 576 + __entry->hdr_uuid = CXL_EVENT_MEM_MODULE_UUID; 577 577 578 578 /* Memory Module Event */ 579 579 __entry->event_type = rec->event_type;
+1 -1
drivers/firmware/efi/arm-runtime.c
··· 107 107 efi_memory_desc_t *md; 108 108 109 109 for_each_efi_memory_desc(md) { 110 - int md_size = md->num_pages << EFI_PAGE_SHIFT; 110 + u64 md_size = md->num_pages << EFI_PAGE_SHIFT; 111 111 struct resource *res; 112 112 113 113 if (!(md->attribute & EFI_MEMORY_SP))
+19
drivers/firmware/efi/cper.c
··· 523 523 } 524 524 } 525 525 526 + struct ignore_section { 527 + guid_t guid; 528 + const char *name; 529 + }; 530 + 531 + static const struct ignore_section ignore_sections[] = { 532 + { .guid = CPER_SEC_CXL_GEN_MEDIA_GUID, .name = "CXL General Media Event" }, 533 + { .guid = CPER_SEC_CXL_DRAM_GUID, .name = "CXL DRAM Event" }, 534 + { .guid = CPER_SEC_CXL_MEM_MODULE_GUID, .name = "CXL Memory Module Event" }, 535 + }; 536 + 526 537 static void 527 538 cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata, 528 539 int sec_no) ··· 554 543 printk("%s""fru_text: %.20s\n", pfx, gdata->fru_text); 555 544 556 545 snprintf(newpfx, sizeof(newpfx), "%s ", pfx); 546 + 547 + for (int i = 0; i < ARRAY_SIZE(ignore_sections); i++) { 548 + if (guid_equal(sec_type, &ignore_sections[i].guid)) { 549 + printk("%ssection_type: %s\n", newpfx, ignore_sections[i].name); 550 + return; 551 + } 552 + } 553 + 557 554 if (guid_equal(sec_type, &CPER_SEC_PROC_GENERIC)) { 558 555 struct cper_sec_proc_generic *proc_err = acpi_hest_get_payload(gdata); 559 556
+10 -9
drivers/firmware/efi/efi-init.c
··· 144 144 case EFI_CONVENTIONAL_MEMORY: 145 145 case EFI_PERSISTENT_MEMORY: 146 146 /* 147 - * Special purpose memory is 'soft reserved', which means it 148 - * is set aside initially, but can be hotplugged back in or 149 - * be assigned to the dax driver after boot. 150 - */ 151 - if (efi_soft_reserve_enabled() && 152 - (md->attribute & EFI_MEMORY_SP)) 153 - return false; 154 - 155 - /* 156 147 * According to the spec, these regions are no longer reserved 157 148 * after calling ExitBootServices(). However, we can only use 158 149 * them as System RAM if they can be mapped writeback cacheable. ··· 187 196 size = npages << PAGE_SHIFT; 188 197 189 198 if (is_memory(md)) { 199 + /* 200 + * Special purpose memory is 'soft reserved', which 201 + * means it is set aside initially. Don't add a memblock 202 + * for it now so that it can be hotplugged back in or 203 + * be assigned to the dax driver after boot. 204 + */ 205 + if (efi_soft_reserve_enabled() && 206 + (md->attribute & EFI_MEMORY_SP)) 207 + continue; 208 + 190 209 early_init_dt_add_memory_arch(paddr, size); 191 210 192 211 if (!is_usable_memory(md))
+2 -2
drivers/firmware/efi/libstub/Makefile
··· 28 28 -DEFI_HAVE_MEMCHR -DEFI_HAVE_STRRCHR \ 29 29 -DEFI_HAVE_STRCMP -fno-builtin -fpic \ 30 30 $(call cc-option,-mno-single-pic-base) 31 - cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE 31 + cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE -mno-relax 32 32 cflags-$(CONFIG_LOONGARCH) += -fpie 33 33 34 34 cflags-$(CONFIG_EFI_PARAMS_FROM_FDT) += -I$(srctree)/scripts/dtc/libfdt ··· 143 143 # exist. 144 144 STUBCOPY_FLAGS-$(CONFIG_RISCV) += --prefix-alloc-sections=.init \ 145 145 --prefix-symbols=__efistub_ 146 - STUBCOPY_RELOC-$(CONFIG_RISCV) := R_RISCV_HI20 146 + STUBCOPY_RELOC-$(CONFIG_RISCV) := -E R_RISCV_HI20\|R_RISCV_$(BITS)\|R_RISCV_RELAX 147 147 148 148 # For LoongArch, keep all the symbols in .init section and make sure that no 149 149 # absolute symbols references exist.
+1
drivers/firmware/efi/libstub/alignedmem.c
··· 14 14 * @max: the address that the last allocated memory page shall not 15 15 * exceed 16 16 * @align: minimum alignment of the base of the allocation 17 + * @memory_type: the type of memory to allocate 17 18 * 18 19 * Allocate pages as EFI_LOADER_DATA. The allocated pages are aligned according 19 20 * to @align, which should be >= EFI_ALLOC_ALIGN. The last allocated page will
+2 -1
drivers/firmware/efi/libstub/efistub.h
··· 956 956 957 957 efi_status_t efi_random_alloc(unsigned long size, unsigned long align, 958 958 unsigned long *addr, unsigned long random_seed, 959 - int memory_type, unsigned long alloc_limit); 959 + int memory_type, unsigned long alloc_min, 960 + unsigned long alloc_max); 960 961 961 962 efi_status_t efi_random_get_seed(void); 962 963
+1 -1
drivers/firmware/efi/libstub/kaslr.c
··· 119 119 */ 120 120 status = efi_random_alloc(*reserve_size, min_kimg_align, 121 121 reserve_addr, phys_seed, 122 - EFI_LOADER_CODE, EFI_ALLOC_LIMIT); 122 + EFI_LOADER_CODE, 0, EFI_ALLOC_LIMIT); 123 123 if (status != EFI_SUCCESS) 124 124 efi_warn("efi_random_alloc() failed: 0x%lx\n", status); 125 125 } else {
+7 -5
drivers/firmware/efi/libstub/randomalloc.c
··· 17 17 static unsigned long get_entry_num_slots(efi_memory_desc_t *md, 18 18 unsigned long size, 19 19 unsigned long align_shift, 20 - u64 alloc_limit) 20 + u64 alloc_min, u64 alloc_max) 21 21 { 22 22 unsigned long align = 1UL << align_shift; 23 23 u64 first_slot, last_slot, region_end; ··· 30 30 return 0; 31 31 32 32 region_end = min(md->phys_addr + md->num_pages * EFI_PAGE_SIZE - 1, 33 - alloc_limit); 33 + alloc_max); 34 34 if (region_end < size) 35 35 return 0; 36 36 37 - first_slot = round_up(md->phys_addr, align); 37 + first_slot = round_up(max(md->phys_addr, alloc_min), align); 38 38 last_slot = round_down(region_end - size + 1, align); 39 39 40 40 if (first_slot > last_slot) ··· 56 56 unsigned long *addr, 57 57 unsigned long random_seed, 58 58 int memory_type, 59 - unsigned long alloc_limit) 59 + unsigned long alloc_min, 60 + unsigned long alloc_max) 60 61 { 61 62 unsigned long total_slots = 0, target_slot; 62 63 unsigned long total_mirrored_slots = 0; ··· 79 78 efi_memory_desc_t *md = (void *)map->map + map_offset; 80 79 unsigned long slots; 81 80 82 - slots = get_entry_num_slots(md, size, ilog2(align), alloc_limit); 81 + slots = get_entry_num_slots(md, size, ilog2(align), alloc_min, 82 + alloc_max); 83 83 MD_NUM_SLOTS(md) = slots; 84 84 total_slots += slots; 85 85 if (md->attribute & EFI_MEMORY_MORE_RELIABLE)
+15 -10
drivers/firmware/efi/libstub/x86-stub.c
··· 223 223 } 224 224 } 225 225 226 - void efi_adjust_memory_range_protection(unsigned long start, 227 - unsigned long size) 226 + efi_status_t efi_adjust_memory_range_protection(unsigned long start, 227 + unsigned long size) 228 228 { 229 229 efi_status_t status; 230 230 efi_gcd_memory_space_desc_t desc; ··· 236 236 rounded_end = roundup(start + size, EFI_PAGE_SIZE); 237 237 238 238 if (memattr != NULL) { 239 - efi_call_proto(memattr, clear_memory_attributes, rounded_start, 240 - rounded_end - rounded_start, EFI_MEMORY_XP); 241 - return; 239 + status = efi_call_proto(memattr, clear_memory_attributes, 240 + rounded_start, 241 + rounded_end - rounded_start, 242 + EFI_MEMORY_XP); 243 + if (status != EFI_SUCCESS) 244 + efi_warn("Failed to clear EFI_MEMORY_XP attribute\n"); 245 + return status; 242 246 } 243 247 244 248 if (efi_dxe_table == NULL) 245 - return; 249 + return EFI_SUCCESS; 246 250 247 251 /* 248 252 * Don't modify memory region attributes, they are ··· 259 255 status = efi_dxe_call(get_memory_space_descriptor, start, &desc); 260 256 261 257 if (status != EFI_SUCCESS) 262 - return; 258 + break; 263 259 264 260 next = desc.base_address + desc.length; 265 261 ··· 284 280 unprotect_start, 285 281 unprotect_start + unprotect_size, 286 282 status); 283 + break; 287 284 } 288 285 } 286 + return EFI_SUCCESS; 289 287 } 290 288 291 289 static void setup_unaccepted_memory(void) ··· 799 793 800 794 status = efi_random_alloc(alloc_size, CONFIG_PHYSICAL_ALIGN, &addr, 801 795 seed[0], EFI_LOADER_CODE, 796 + LOAD_PHYSICAL_ADDR, 802 797 EFI_X86_KERNEL_ALLOC_LIMIT); 803 798 if (status != EFI_SUCCESS) 804 799 return status; ··· 812 805 813 806 *kernel_entry = addr + entry; 814 807 815 - efi_adjust_memory_range_protection(addr, kernel_total_size); 816 - 817 - return EFI_SUCCESS; 808 + return efi_adjust_memory_range_protection(addr, kernel_total_size); 818 809 } 819 810 820 811 static void __noreturn enter_kernel(unsigned long kernel_addr,
+2 -2
drivers/firmware/efi/libstub/x86-stub.h
··· 5 5 extern void trampoline_32bit_src(void *, bool); 6 6 extern const u16 trampoline_ljmp_imm_offset; 7 7 8 - void efi_adjust_memory_range_protection(unsigned long start, 9 - unsigned long size); 8 + efi_status_t efi_adjust_memory_range_protection(unsigned long start, 9 + unsigned long size); 10 10 11 11 #ifdef CONFIG_X86_64 12 12 efi_status_t efi_setup_5level_paging(void);
+1 -1
drivers/firmware/efi/libstub/zboot.c
··· 119 119 } 120 120 121 121 status = efi_random_alloc(alloc_size, min_kimg_align, &image_base, 122 - seed, EFI_LOADER_CODE, EFI_ALLOC_LIMIT); 122 + seed, EFI_LOADER_CODE, 0, EFI_ALLOC_LIMIT); 123 123 if (status != EFI_SUCCESS) { 124 124 efi_err("Failed to allocate memory\n"); 125 125 goto free_cmdline;
+1 -1
drivers/firmware/efi/riscv-runtime.c
··· 85 85 efi_memory_desc_t *md; 86 86 87 87 for_each_efi_memory_desc(md) { 88 - int md_size = md->num_pages << EFI_PAGE_SHIFT; 88 + u64 md_size = md->num_pages << EFI_PAGE_SHIFT; 89 89 struct resource *res; 90 90 91 91 if (!(md->attribute & EFI_MEMORY_SP))
+23
include/linux/cper.h
··· 90 90 GUID_INIT(0x667DD791, 0xC6B3, 0x4c27, 0x8A, 0x6B, 0x0F, 0x8E, \ 91 91 0x72, 0x2D, 0xEB, 0x41) 92 92 93 + /* CXL Event record UUIDs are formatted as GUIDs and reported in section type */ 94 + /* 95 + * General Media Event Record 96 + * CXL rev 3.0 Section 8.2.9.2.1.1; Table 8-43 97 + */ 98 + #define CPER_SEC_CXL_GEN_MEDIA_GUID \ 99 + GUID_INIT(0xfbcd0a77, 0xc260, 0x417f, \ 100 + 0x85, 0xa9, 0x08, 0x8b, 0x16, 0x21, 0xeb, 0xa6) 101 + /* 102 + * DRAM Event Record 103 + * CXL rev 3.0 section 8.2.9.2.1.2; Table 8-44 104 + */ 105 + #define CPER_SEC_CXL_DRAM_GUID \ 106 + GUID_INIT(0x601dcbb3, 0x9c06, 0x4eab, \ 107 + 0xb8, 0xaf, 0x4e, 0x9b, 0xfb, 0x5c, 0x96, 0x24) 108 + /* 109 + * Memory Module Event Record 110 + * CXL rev 3.0 section 8.2.9.2.1.3; Table 8-45 111 + */ 112 + #define CPER_SEC_CXL_MEM_MODULE_GUID \ 113 + GUID_INIT(0xfe927475, 0xdd59, 0x4339, \ 114 + 0xa5, 0x86, 0x79, 0xba, 0xb1, 0x13, 0xb7, 0x74) 115 + 93 116 /* 94 117 * Flags bits definitions for flags in struct cper_record_header 95 118 * If set, the error has been recovered