Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit cd61938

Browse files
committed
x86/efistub: Enable SMBIOS protocol handling for x86
The smbios.c source file is not currently included in the x86 build, and before we can do so, it needs some tweaks to build correctly in combination with the EFI mixed mode support. Reviewed-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
1 parent 0dad9ee commit cd61938

File tree

4 files changed

+34
-18
lines changed

4 files changed

+34
-18
lines changed

arch/x86/include/asm/efi.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ static inline bool efi_is_native(void)
229229

230230
static inline void *efi64_zero_upper(void *p)
231231
{
232-
((u32 *)p)[1] = 0;
232+
if (p)
233+
((u32 *)p)[1] = 0;
233234
return p;
234235
}
235236

@@ -315,6 +316,10 @@ static inline u32 efi64_convert_status(efi_status_t status)
315316
#define __efi64_argmap_clear_memory_attributes(protocol, phys, size, flags) \
316317
((protocol), __efi64_split(phys), __efi64_split(size), __efi64_split(flags))
317318

319+
/* EFI SMBIOS protocol */
320+
#define __efi64_argmap_get_next(protocol, smbioshandle, type, record, phandle) \
321+
((protocol), (smbioshandle), (type), efi64_zero_upper(record), \
322+
efi64_zero_upper(phandle))
318323
/*
319324
* The macros below handle the plumbing for the argument mapping. To add a
320325
* mapping for a specific EFI method, simply define a macro

drivers/firmware/efi/libstub/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ lib-$(CONFIG_EFI_GENERIC_STUB) += efi-stub.o string.o intrinsics.o systable.o \
7676

7777
lib-$(CONFIG_ARM) += arm32-stub.o
7878
lib-$(CONFIG_ARM64) += kaslr.o arm64.o arm64-stub.o smbios.o
79-
lib-$(CONFIG_X86) += x86-stub.o
79+
lib-$(CONFIG_X86) += x86-stub.o smbios.o
8080
lib-$(CONFIG_X86_64) += x86-5lvl.o
8181
lib-$(CONFIG_RISCV) += kaslr.o riscv.o riscv-stub.o
8282
lib-$(CONFIG_LOONGARCH) += loongarch.o loongarch-stub.o

drivers/firmware/efi/libstub/smbios.c

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,31 @@
66

77
#include "efistub.h"
88

9-
typedef struct efi_smbios_protocol efi_smbios_protocol_t;
10-
11-
struct efi_smbios_protocol {
12-
efi_status_t (__efiapi *add)(efi_smbios_protocol_t *, efi_handle_t,
13-
u16 *, struct efi_smbios_record *);
14-
efi_status_t (__efiapi *update_string)(efi_smbios_protocol_t *, u16 *,
15-
unsigned long *, u8 *);
16-
efi_status_t (__efiapi *remove)(efi_smbios_protocol_t *, u16);
17-
efi_status_t (__efiapi *get_next)(efi_smbios_protocol_t *, u16 *, u8 *,
18-
struct efi_smbios_record **,
19-
efi_handle_t *);
20-
21-
u8 major_version;
22-
u8 minor_version;
9+
typedef union efi_smbios_protocol efi_smbios_protocol_t;
10+
11+
union efi_smbios_protocol {
12+
struct {
13+
efi_status_t (__efiapi *add)(efi_smbios_protocol_t *, efi_handle_t,
14+
u16 *, struct efi_smbios_record *);
15+
efi_status_t (__efiapi *update_string)(efi_smbios_protocol_t *, u16 *,
16+
unsigned long *, u8 *);
17+
efi_status_t (__efiapi *remove)(efi_smbios_protocol_t *, u16);
18+
efi_status_t (__efiapi *get_next)(efi_smbios_protocol_t *, u16 *, u8 *,
19+
struct efi_smbios_record **,
20+
efi_handle_t *);
21+
22+
u8 major_version;
23+
u8 minor_version;
24+
};
25+
struct {
26+
u32 add;
27+
u32 update_string;
28+
u32 remove;
29+
u32 get_next;
30+
31+
u8 major_version;
32+
u8 minor_version;
33+
} mixed_mode;
2334
};
2435

2536
const struct efi_smbios_record *efi_get_smbios_record(u8 type)

include/linux/efi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,10 @@ typedef void *efi_handle_t;
7474
*/
7575
typedef guid_t efi_guid_t __aligned(__alignof__(u32));
7676

77-
#define EFI_GUID(a, b, c, d...) (efi_guid_t){ { \
77+
#define EFI_GUID(a, b, c, d...) ((efi_guid_t){ { \
7878
(a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \
7979
(b) & 0xff, ((b) >> 8) & 0xff, \
80-
(c) & 0xff, ((c) >> 8) & 0xff, d } }
80+
(c) & 0xff, ((c) >> 8) & 0xff, d } })
8181

8282
/*
8383
* Generic EFI table header

0 commit comments

Comments
 (0)