From 1786e83011644e18732ed006413339d5323766e9 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Tue, 24 Dec 2019 16:10:08 +0100 Subject: efi/libstub: Extend native protocol definitions with mixed_mode aliases In preparation of moving to a native vs. mixed mode split rather than a 32 vs. 64 bit split when it comes to invoking EFI firmware services, update all the native protocol definitions and redefine them as unions containing an anonymous struct for the native view and a struct called 'mixed_mode' describing the 32-bit view of the protocol when called from 64-bit code. While at it, flesh out some PCI I/O member definitions that we will be needing shortly. Signed-off-by: Ard Biesheuvel Cc: Arvind Sankar Cc: Borislav Petkov Cc: James Morse Cc: Matt Fleming Cc: Thomas Gleixner Cc: linux-efi@vger.kernel.org Link: https://lkml.kernel.org/r/20191224151025.32482-9-ardb@kernel.org Signed-off-by: Ingo Molnar --- drivers/firmware/efi/libstub/arm-stub.c | 4 ++-- drivers/firmware/efi/libstub/random.c | 22 ++++++++++++++-------- 2 files changed, 16 insertions(+), 10 deletions(-) (limited to 'drivers/firmware') diff --git a/drivers/firmware/efi/libstub/arm-stub.c b/drivers/firmware/efi/libstub/arm-stub.c index 817237ce2420..60a301e1c072 100644 --- a/drivers/firmware/efi/libstub/arm-stub.c +++ b/drivers/firmware/efi/libstub/arm-stub.c @@ -40,9 +40,9 @@ static u64 virtmap_base = EFI_RT_VIRTUAL_BASE; void efi_char16_printk(efi_system_table_t *sys_table_arg, efi_char16_t *str) { - struct efi_simple_text_output_protocol *out; + efi_simple_text_output_protocol_t *out; - out = (struct efi_simple_text_output_protocol *)sys_table_arg->con_out; + out = (efi_simple_text_output_protocol_t *)sys_table_arg->con_out; out->output_string(out, str); } diff --git a/drivers/firmware/efi/libstub/random.c b/drivers/firmware/efi/libstub/random.c index 97378cf96a2e..d92cd640c73d 100644 --- a/drivers/firmware/efi/libstub/random.c +++ b/drivers/firmware/efi/libstub/random.c @@ -9,7 +9,7 @@ #include "efistub.h" -typedef struct efi_rng_protocol efi_rng_protocol_t; +typedef union efi_rng_protocol efi_rng_protocol_t; typedef struct { u32 get_info; @@ -21,11 +21,17 @@ typedef struct { u64 get_rng; } efi_rng_protocol_64_t; -struct efi_rng_protocol { - efi_status_t (*get_info)(struct efi_rng_protocol *, - unsigned long *, efi_guid_t *); - efi_status_t (*get_rng)(struct efi_rng_protocol *, - efi_guid_t *, unsigned long, u8 *out); +union efi_rng_protocol { + struct { + efi_status_t (*get_info)(efi_rng_protocol_t *, + unsigned long *, efi_guid_t *); + efi_status_t (*get_rng)(efi_rng_protocol_t *, + efi_guid_t *, unsigned long, u8 *out); + }; + struct { + u32 get_info; + u32 get_rng; + } mixed_mode; }; efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg, @@ -33,7 +39,7 @@ efi_status_t efi_get_random_bytes(efi_system_table_t *sys_table_arg, { efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; efi_status_t status; - struct efi_rng_protocol *rng = NULL; + efi_rng_protocol_t *rng = NULL; status = efi_call_early(locate_protocol, &rng_proto, NULL, (void **)&rng); @@ -162,7 +168,7 @@ efi_status_t efi_random_get_seed(efi_system_table_t *sys_table_arg) efi_guid_t rng_proto = EFI_RNG_PROTOCOL_GUID; efi_guid_t rng_algo_raw = EFI_RNG_ALGORITHM_RAW; efi_guid_t rng_table_guid = LINUX_EFI_RANDOM_SEED_TABLE_GUID; - struct efi_rng_protocol *rng = NULL; + efi_rng_protocol_t *rng = NULL; struct linux_efi_random_seed *seed = NULL; efi_status_t status; -- cgit v1.2.3-59-g8ed1b