Skip to content

Commit e38abda

Browse files
committed
efi/runtime-wrappers: Remove duplicated macro for service returning void
__efi_call_virt() exists as an alternative for efi_call_virt() for the sole reason that ResetSystem() returns void, and so we cannot use a call to it in the RHS of an assignment. Given that there is only a single user, let's drop the macro, and expand it into the caller. That way, the remaining macro can be tightened somewhat in terms of type safety too. Note that the use of typeof() on the runtime service invocation does not result in an actual call being made, but it does require a few pointer types to be fixed up and converted into the proper function pointer prototypes. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent c99ba6e commit e38abda

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

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 */

drivers/acpi/prmt.c

Lines changed: 1 addition & 1 deletion
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

drivers/firmware/efi/runtime-wrappers.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
*/
4242
#define efi_call_virt(f, args...) \
4343
efi_call_virt_pointer(efi.runtime, f, args)
44-
#define __efi_call_virt(f, args...) \
45-
__efi_call_virt_pointer(efi.runtime, f, args)
4644

4745
union efi_rts_args {
4846
struct {
@@ -491,8 +489,13 @@ static void virt_efi_reset_system(int reset_type,
491489
"could not get exclusive access to the firmware\n");
492490
return;
493491
}
492+
493+
arch_efi_call_virt_setup();
494494
efi_rts_work.efi_rts_id = EFI_RESET_SYSTEM;
495-
__efi_call_virt(reset_system, reset_type, status, data_size, data);
495+
arch_efi_call_virt(efi.runtime, reset_system, reset_type, status,
496+
data_size, data);
497+
arch_efi_call_virt_teardown();
498+
496499
up(&efi_runtime_lock);
497500
}
498501

include/linux/efi.h

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,8 +1170,7 @@ static inline void efi_check_for_embedded_firmwares(void) { }
11701170
#define arch_efi_call_virt(p, f, args...) ((p)->f(args))
11711171

11721172
/*
1173-
* Arch code can implement the following three template macros, avoiding
1174-
* reptition for the void/non-void return cases of {__,}efi_call_virt():
1173+
* Arch code must implement the following three routines:
11751174
*
11761175
* * arch_efi_call_virt_setup()
11771176
*
@@ -1180,9 +1179,8 @@ static inline void efi_check_for_embedded_firmwares(void) { }
11801179
*
11811180
* * arch_efi_call_virt()
11821181
*
1183-
* Performs the call. The last expression in the macro must be the call
1184-
* itself, allowing the logic to be shared by the void and non-void
1185-
* cases.
1182+
* Performs the call. This routine takes a variable number of arguments so
1183+
* it must be implemented as a variadic preprocessor macro.
11861184
*
11871185
* * arch_efi_call_virt_teardown()
11881186
*
@@ -1191,7 +1189,7 @@ static inline void efi_check_for_embedded_firmwares(void) { }
11911189

11921190
#define efi_call_virt_pointer(p, f, args...) \
11931191
({ \
1194-
efi_status_t __s; \
1192+
typeof((p)->f(args)) __s; \
11951193
unsigned long __flags; \
11961194
\
11971195
arch_efi_call_virt_setup(); \
@@ -1205,19 +1203,6 @@ static inline void efi_check_for_embedded_firmwares(void) { }
12051203
__s; \
12061204
})
12071205

1208-
#define __efi_call_virt_pointer(p, f, args...) \
1209-
({ \
1210-
unsigned long __flags; \
1211-
\
1212-
arch_efi_call_virt_setup(); \
1213-
\
1214-
__flags = efi_call_virt_save_flags(); \
1215-
arch_efi_call_virt(p, f, args); \
1216-
efi_call_virt_check_flags(__flags, __stringify(f)); \
1217-
\
1218-
arch_efi_call_virt_teardown(); \
1219-
})
1220-
12211206
#define EFI_RANDOM_SEED_SIZE 32U // BLAKE2S_HASH_SIZE
12221207

12231208
struct linux_efi_random_seed {

0 commit comments

Comments
 (0)