Skip to content

Commit e6f39a9

Browse files
committed
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
2 parents 5ddfc24 + 1ad55ce commit e6f39a9

File tree

17 files changed

+97
-73
lines changed

17 files changed

+97
-73
lines changed

arch/x86/boot/header.S

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ extra_header_fields:
106106
.word 0 # MinorSubsystemVersion
107107
.long 0 # Win32VersionValue
108108

109-
.long setup_size + ZO__end + pecompat_vsize
110-
# SizeOfImage
109+
.long setup_size + ZO__end # SizeOfImage
111110

112111
.long salign # SizeOfHeaders
113112
.long 0 # CheckSum
@@ -143,7 +142,7 @@ section_table:
143142
.ascii ".setup"
144143
.byte 0
145144
.byte 0
146-
.long setup_size - salign # VirtualSize
145+
.long pecompat_fstart - salign # VirtualSize
147146
.long salign # VirtualAddress
148147
.long pecompat_fstart - salign # SizeOfRawData
149148
.long salign # PointerToRawData
@@ -156,8 +155,8 @@ section_table:
156155
#ifdef CONFIG_EFI_MIXED
157156
.asciz ".compat"
158157

159-
.long 8 # VirtualSize
160-
.long setup_size + ZO__end # VirtualAddress
158+
.long pecompat_fsize # VirtualSize
159+
.long pecompat_fstart # VirtualAddress
161160
.long pecompat_fsize # SizeOfRawData
162161
.long pecompat_fstart # PointerToRawData
163162

@@ -172,17 +171,16 @@ section_table:
172171
* modes this image supports.
173172
*/
174173
.pushsection ".pecompat", "a", @progbits
175-
.balign falign
176-
.set pecompat_vsize, salign
174+
.balign salign
177175
.globl pecompat_fstart
178176
pecompat_fstart:
179177
.byte 0x1 # Version
180178
.byte 8 # Size
181179
.word IMAGE_FILE_MACHINE_I386 # PE machine type
182180
.long setup_size + ZO_efi32_pe_entry # Entrypoint
181+
.byte 0x0 # Sentinel
183182
.popsection
184183
#else
185-
.set pecompat_vsize, 0
186184
.set pecompat_fstart, setup_size
187185
#endif
188186
.ascii ".text"

arch/x86/boot/setup.ld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ SECTIONS
2424
.text : { *(.text .text.*) }
2525
.text32 : { *(.text32) }
2626

27+
.pecompat : { *(.pecompat) }
28+
PROVIDE(pecompat_fsize = setup_size - pecompat_fstart);
29+
2730
. = ALIGN(16);
2831
.rodata : { *(.rodata*) }
2932

@@ -36,9 +39,6 @@ SECTIONS
3639
. = ALIGN(16);
3740
.data : { *(.data*) }
3841

39-
.pecompat : { *(.pecompat) }
40-
PROVIDE(pecompat_fsize = setup_size - pecompat_fstart);
41-
4242
.signature : {
4343
setup_sig = .;
4444
LONG(0x5a5aaa55)

drivers/acpi/apei/ghes.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -680,32 +680,6 @@ static void ghes_defer_non_standard_event(struct acpi_hest_generic_data *gdata,
680680
static DECLARE_RWSEM(cxl_cper_rw_sem);
681681
static cxl_cper_callback cper_callback;
682682

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-
709683
static void cxl_cper_post_event(enum cxl_event_type event_type,
710684
struct cxl_cper_event_rec *rec)
711685
{

drivers/cxl/core/trace.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ TRACE_EVENT(cxl_general_media,
338338

339339
TP_fast_assign(
340340
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;
342342

343343
/* General Media */
344344
__entry->dpa = le64_to_cpu(rec->phys_addr);
@@ -425,7 +425,7 @@ TRACE_EVENT(cxl_dram,
425425

426426
TP_fast_assign(
427427
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;
429429

430430
/* DRAM */
431431
__entry->dpa = le64_to_cpu(rec->phys_addr);
@@ -573,7 +573,7 @@ TRACE_EVENT(cxl_memory_module,
573573

574574
TP_fast_assign(
575575
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;
577577

578578
/* Memory Module Event */
579579
__entry->event_type = rec->event_type;

drivers/firmware/efi/arm-runtime.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static int __init arm_enable_runtime_services(void)
107107
efi_memory_desc_t *md;
108108

109109
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;
111111
struct resource *res;
112112

113113
if (!(md->attribute & EFI_MEMORY_SP))

drivers/firmware/efi/cper.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,17 @@ static void cper_print_tstamp(const char *pfx,
523523
}
524524
}
525525

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+
526537
static void
527538
cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata,
528539
int sec_no)
@@ -543,6 +554,14 @@ cper_estatus_print_section(const char *pfx, struct acpi_hest_generic_data *gdata
543554
printk("%s""fru_text: %.20s\n", pfx, gdata->fru_text);
544555

545556
snprintf(newpfx, sizeof(newpfx), "%s ", pfx);
557+
558+
for (int i = 0; i < ARRAY_SIZE(ignore_sections); i++) {
559+
if (guid_equal(sec_type, &ignore_sections[i].guid)) {
560+
printk("%ssection_type: %s\n", newpfx, ignore_sections[i].name);
561+
return;
562+
}
563+
}
564+
546565
if (guid_equal(sec_type, &CPER_SEC_PROC_GENERIC)) {
547566
struct cper_sec_proc_generic *proc_err = acpi_hest_get_payload(gdata);
548567

drivers/firmware/efi/efi-init.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,6 @@ static __init int is_usable_memory(efi_memory_desc_t *md)
143143
case EFI_BOOT_SERVICES_DATA:
144144
case EFI_CONVENTIONAL_MEMORY:
145145
case EFI_PERSISTENT_MEMORY:
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-
155146
/*
156147
* According to the spec, these regions are no longer reserved
157148
* after calling ExitBootServices(). However, we can only use
@@ -196,6 +187,16 @@ static __init void reserve_regions(void)
196187
size = npages << PAGE_SHIFT;
197188

198189
if (is_memory(md)) {
190+
/*
191+
* Special purpose memory is 'soft reserved', which
192+
* means it is set aside initially. Don't add a memblock
193+
* for it now so that it can be hotplugged back in or
194+
* be assigned to the dax driver after boot.
195+
*/
196+
if (efi_soft_reserve_enabled() &&
197+
(md->attribute & EFI_MEMORY_SP))
198+
continue;
199+
199200
early_init_dt_add_memory_arch(paddr, size);
200201

201202
if (!is_usable_memory(md))

drivers/firmware/efi/libstub/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ cflags-$(CONFIG_ARM) += -DEFI_HAVE_STRLEN -DEFI_HAVE_STRNLEN \
2828
-DEFI_HAVE_MEMCHR -DEFI_HAVE_STRRCHR \
2929
-DEFI_HAVE_STRCMP -fno-builtin -fpic \
3030
$(call cc-option,-mno-single-pic-base)
31-
cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE
31+
cflags-$(CONFIG_RISCV) += -fpic -DNO_ALTERNATIVE -mno-relax
3232
cflags-$(CONFIG_LOONGARCH) += -fpie
3333

3434
cflags-$(CONFIG_EFI_PARAMS_FROM_FDT) += -I$(srctree)/scripts/dtc/libfdt
@@ -143,7 +143,7 @@ STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
143143
# exist.
144144
STUBCOPY_FLAGS-$(CONFIG_RISCV) += --prefix-alloc-sections=.init \
145145
--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
147147

148148
# For LoongArch, keep all the symbols in .init section and make sure that no
149149
# absolute symbols references exist.

drivers/firmware/efi/libstub/alignedmem.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* @max: the address that the last allocated memory page shall not
1515
* exceed
1616
* @align: minimum alignment of the base of the allocation
17+
* @memory_type: the type of memory to allocate
1718
*
1819
* Allocate pages as EFI_LOADER_DATA. The allocated pages are aligned according
1920
* to @align, which should be >= EFI_ALLOC_ALIGN. The last allocated page will

drivers/firmware/efi/libstub/efistub.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,8 @@ efi_status_t efi_get_random_bytes(unsigned long size, u8 *out);
956956

957957
efi_status_t efi_random_alloc(unsigned long size, unsigned long align,
958958
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);
960961

961962
efi_status_t efi_random_get_seed(void);
962963

0 commit comments

Comments
 (0)