Skip to content

Commit d7dd9b4

Browse files
committed
Merge tag 'efi-next-for-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi
Pull EFI updates from Ard Biesheuvel: "This primarily covers some cleanup work on the EFI runtime wrappers, which are shared between all EFI architectures except Itanium, and which provide some level of isolation to prevent faults occurring in the firmware code (which runs at the same privilege level as the kernel) from bringing down the system. Beyond that, there is a fix that did not make it into v6.5, and some doc fixes and dead code cleanup. - one bugfix for x86 mixed mode that did not make it into v6.5 - first pass of cleanup for the EFI runtime wrappers - some cosmetic touchups" * tag 'efi-next-for-v6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/efi/efi: x86/efistub: Fix PCI ROM preservation in mixed mode efi/runtime-wrappers: Clean up white space and add __init annotation acpi/prmt: Use EFI runtime sandbox to invoke PRM handlers efi/runtime-wrappers: Don't duplicate setup/teardown code efi/runtime-wrappers: Remove duplicated macro for service returning void efi/runtime-wrapper: Move workqueue manipulation out of line efi/runtime-wrappers: Use type safe encapsulation of call arguments efi/riscv: Move EFI runtime call setup/teardown helpers out of line efi/arm64: Move EFI runtime call setup/teardown helpers out of line efi/riscv: libstub: Fix comment about absolute relocation efi: memmap: Remove kernel-doc warnings efi: Remove unused extern declaration efi_lookup_mapped_addr()
2 parents 42a7f6e + b691118 commit d7dd9b4

File tree

12 files changed

+299
-191
lines changed

12 files changed

+299
-191
lines changed

arch/arm64/include/asm/efi.h

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,28 +30,16 @@ int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
3030
int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md,
3131
bool has_bti);
3232

33-
#define arch_efi_call_virt_setup() \
34-
({ \
35-
efi_virtmap_load(); \
36-
__efi_fpsimd_begin(); \
37-
raw_spin_lock(&efi_rt_lock); \
38-
})
39-
4033
#undef arch_efi_call_virt
4134
#define arch_efi_call_virt(p, f, args...) \
4235
__efi_rt_asm_wrapper((p)->f, #f, args)
4336

44-
#define arch_efi_call_virt_teardown() \
45-
({ \
46-
raw_spin_unlock(&efi_rt_lock); \
47-
__efi_fpsimd_end(); \
48-
efi_virtmap_unload(); \
49-
})
50-
51-
extern raw_spinlock_t efi_rt_lock;
5237
extern u64 *efi_rt_stack_top;
5338
efi_status_t __efi_rt_asm_wrapper(void *, const char *, ...);
5439

40+
void arch_efi_call_virt_setup(void);
41+
void arch_efi_call_virt_teardown(void);
42+
5543
/*
5644
* efi_rt_stack_top[-1] contains the value the stack pointer had before
5745
* switching to the EFI runtime stack.

arch/arm64/kernel/efi.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,21 @@ asmlinkage efi_status_t efi_handle_corrupted_x18(efi_status_t s, const char *f)
158158
return s;
159159
}
160160

161-
DEFINE_RAW_SPINLOCK(efi_rt_lock);
161+
static DEFINE_RAW_SPINLOCK(efi_rt_lock);
162+
163+
void arch_efi_call_virt_setup(void)
164+
{
165+
efi_virtmap_load();
166+
__efi_fpsimd_begin();
167+
raw_spin_lock(&efi_rt_lock);
168+
}
169+
170+
void arch_efi_call_virt_teardown(void)
171+
{
172+
raw_spin_unlock(&efi_rt_lock);
173+
__efi_fpsimd_end();
174+
efi_virtmap_unload();
175+
}
162176

163177
asmlinkage u64 *efi_rt_stack_top __ro_after_init;
164178

arch/riscv/include/asm/efi.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ extern void efi_init(void);
2121
int efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md);
2222
int efi_set_mapping_permissions(struct mm_struct *mm, efi_memory_desc_t *md, bool);
2323

24-
#define arch_efi_call_virt_setup() ({ \
25-
sync_kernel_mappings(efi_mm.pgd); \
26-
efi_virtmap_load(); \
27-
})
28-
#define arch_efi_call_virt_teardown() efi_virtmap_unload()
29-
3024
#define ARCH_EFI_IRQ_FLAGS_MASK (SR_IE | SR_SPIE)
3125

3226
/* Load initrd anywhere in system RAM */
@@ -46,8 +40,8 @@ static inline unsigned long efi_get_kimg_min_align(void)
4640

4741
#define EFI_KIMG_PREFERRED_ADDRESS efi_get_kimg_min_align()
4842

49-
void efi_virtmap_load(void);
50-
void efi_virtmap_unload(void);
43+
void arch_efi_call_virt_setup(void);
44+
void arch_efi_call_virt_teardown(void);
5145

5246
unsigned long stext_offset(void);
5347

arch/x86/include/asm/uv/bios.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Copyright (c) Russ Anderson <rja@sgi.com>
1111
*/
1212

13+
#include <linux/efi.h>
1314
#include <linux/rtc.h>
1415

1516
/*
@@ -115,7 +116,8 @@ struct uv_arch_type_entry {
115116
struct uv_systab {
116117
char signature[4]; /* must be UV_SYSTAB_SIG */
117118
u32 revision; /* distinguish different firmware revs */
118-
u64 function; /* BIOS runtime callback function ptr */
119+
u64 (__efiapi *function)(enum uv_bios_cmd, ...);
120+
/* BIOS runtime callback function ptr */
119121
u32 size; /* systab size (starting with _VERSION_UV4) */
120122
struct {
121123
u32 type:8; /* type of entry */

arch/x86/platform/efi/memmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ int __init efi_memmap_alloc(unsigned int num_entries,
8282

8383
/**
8484
* efi_memmap_install - Install a new EFI memory map in efi.memmap
85-
* @ctx: map allocation parameters (address, size, flags)
85+
* @data: efi memmap installation parameters
8686
*
8787
* Unlike efi_memmap_init_*(), this function does not allow the caller
8888
* to switch from early to late mappings. It simply uses the existing

drivers/acpi/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ config ACPI_VIOT
581581

582582
config ACPI_PRMT
583583
bool "Platform Runtime Mechanism Support"
584-
depends on EFI && (X86_64 || ARM64)
584+
depends on EFI_RUNTIME_WRAPPERS && (X86_64 || ARM64)
585585
default y
586586
help
587587
Platform Runtime Mechanism (PRM) is a firmware interface exposing a

drivers/acpi/prmt.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static LIST_HEAD(prm_module_list);
5353

5454
struct prm_handler_info {
5555
guid_t guid;
56-
void *handler_addr;
56+
efi_status_t (__efiapi *handler_addr)(u64, void *);
5757
u64 static_data_buffer_addr;
5858
u64 acpi_param_buffer_addr;
5959

@@ -260,9 +260,9 @@ static acpi_status acpi_platformrt_space_handler(u32 function,
260260
context.static_data_buffer = handler->static_data_buffer_addr;
261261
context.mmio_ranges = module->mmio_info;
262262

263-
status = efi_call_virt_pointer(handler, handler_addr,
264-
handler->acpi_param_buffer_addr,
265-
&context);
263+
status = efi_call_acpi_prm_handler(handler->handler_addr,
264+
handler->acpi_param_buffer_addr,
265+
&context);
266266
if (status == EFI_SUCCESS) {
267267
buffer->prm_status = PRM_HANDLER_SUCCESS;
268268
} else {

drivers/firmware/efi/libstub/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ STUBCOPY_RELOC-$(CONFIG_ARM64) := R_AARCH64_ABS
147147

148148
# For RISC-V, we don't need anything special other than arm64. Keep all the
149149
# symbols in .init section and make sure that no absolute symbols references
150-
# doesn't exist.
150+
# exist.
151151
STUBCOPY_FLAGS-$(CONFIG_RISCV) += --prefix-alloc-sections=.init \
152152
--prefix-symbols=__efistub_
153153
STUBCOPY_RELOC-$(CONFIG_RISCV) := R_RISCV_HI20

drivers/firmware/efi/libstub/x86-stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
7272
rom->data.type = SETUP_PCI;
7373
rom->data.len = size - sizeof(struct setup_data);
7474
rom->data.next = 0;
75-
rom->pcilen = pci->romsize;
75+
rom->pcilen = romsize;
7676
*__rom = rom;
7777

7878
status = efi_call_proto(pci, pci.read, EfiPciIoWidthUint16,

drivers/firmware/efi/riscv-runtime.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,25 @@ static int __init riscv_enable_runtime_services(void)
130130
}
131131
early_initcall(riscv_enable_runtime_services);
132132

133-
void efi_virtmap_load(void)
133+
static void efi_virtmap_load(void)
134134
{
135135
preempt_disable();
136136
switch_mm(current->active_mm, &efi_mm, NULL);
137137
}
138138

139-
void efi_virtmap_unload(void)
139+
static void efi_virtmap_unload(void)
140140
{
141141
switch_mm(&efi_mm, current->active_mm, NULL);
142142
preempt_enable();
143143
}
144+
145+
void arch_efi_call_virt_setup(void)
146+
{
147+
sync_kernel_mappings(efi_mm.pgd);
148+
efi_virtmap_load();
149+
}
150+
151+
void arch_efi_call_virt_teardown(void)
152+
{
153+
efi_virtmap_unload();
154+
}

0 commit comments

Comments
 (0)