Skip to content

Commit d8ea2ff

Browse files
committed
efi/riscv: Move EFI runtime call setup/teardown helpers out of line
Only the arch_efi_call_virt() macro that some architectures override needs to be a macro, given that it is variadic and encapsulates calls via function pointers that have different prototypes. The associated setup and teardown code are not special in this regard, and don't need to be instantiated at each call site. So turn them into ordinary C functions and move them out of line. Cc: Paul Walmsley <paul.walmsley@sifive.com> Cc: Palmer Dabbelt <palmer@dabbelt.com> Cc: Albert Ou <aou@eecs.berkeley.edu> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent c37ce23 commit d8ea2ff

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

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

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)