Commit 960a8d01 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Ingo Molnar

efi/libstub: Use stricter typing for firmware function pointers

We will soon remove another level of pointer casting, so let's make
sure all type handling involving firmware calls at boot time is correct.
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
Cc: Arvind Sankar <nivedita@alum.mit.edu>
Cc: Borislav Petkov <bp@alien8.de>
Cc: James Morse <james.morse@arm.com>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: https://lkml.kernel.org/r/20191224151025.32482-12-ardb@kernel.orgSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent e8bd5ddf
...@@ -70,7 +70,8 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom) ...@@ -70,7 +70,8 @@ preserve_pci_rom_image(efi_pci_io_protocol_t *pci, struct pci_setup_rom **__rom)
size = romsize + sizeof(*rom); size = romsize + sizeof(*rom);
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size, &rom); status = efi_call_early(allocate_pool, EFI_LOADER_DATA, size,
(void **)&rom);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to allocate memory for 'rom'\n"); efi_printk(sys_table, "Failed to allocate memory for 'rom'\n");
return status; return status;
...@@ -195,9 +196,9 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) ...@@ -195,9 +196,9 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
struct setup_data *data, *new; struct setup_data *data, *new;
efi_status_t status; efi_status_t status;
u32 size = 0; u32 size = 0;
void *p; apple_properties_protocol_t *p;
status = efi_call_early(locate_protocol, &guid, NULL, &p); status = efi_call_early(locate_protocol, &guid, NULL, (void **)&p);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return; return;
...@@ -212,7 +213,8 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params) ...@@ -212,7 +213,8 @@ static void retrieve_apple_device_properties(struct boot_params *boot_params)
do { do {
status = efi_call_early(allocate_pool, EFI_LOADER_DATA, status = efi_call_early(allocate_pool, EFI_LOADER_DATA,
size + sizeof(struct setup_data), &new); size + sizeof(struct setup_data),
(void **)&new);
if (status != EFI_SUCCESS) { if (status != EFI_SUCCESS) {
efi_printk(sys_table, "Failed to allocate memory for 'properties'\n"); efi_printk(sys_table, "Failed to allocate memory for 'properties'\n");
return; return;
......
...@@ -12,9 +12,12 @@ ...@@ -12,9 +12,12 @@
#define DESC_TYPE_CODE_DATA (1 << 0) #define DESC_TYPE_CODE_DATA (1 << 0)
typedef union { typedef union efi_uga_draw_protocol efi_uga_draw_protocol_t;
union efi_uga_draw_protocol {
struct { struct {
void *get_mode; efi_status_t (*get_mode)(efi_uga_draw_protocol_t *,
u32*, u32*, u32*, u32*);
void *set_mode; void *set_mode;
void *blt; void *blt;
}; };
...@@ -23,6 +26,6 @@ typedef union { ...@@ -23,6 +26,6 @@ typedef union {
u32 set_mode; u32 set_mode;
u32 blt; u32 blt;
} mixed_mode; } mixed_mode;
} efi_uga_draw_protocol_t; };
#endif /* BOOT_COMPRESSED_EBOOT_H */ #endif /* BOOT_COMPRESSED_EBOOT_H */
...@@ -385,7 +385,7 @@ static int __init efi_systab_init(void *phys) ...@@ -385,7 +385,7 @@ static int __init efi_systab_init(void *phys)
tmp |= systab64->con_in; tmp |= systab64->con_in;
efi_systab.con_out_handle = systab64->con_out_handle; efi_systab.con_out_handle = systab64->con_out_handle;
tmp |= systab64->con_out_handle; tmp |= systab64->con_out_handle;
efi_systab.con_out = systab64->con_out; efi_systab.con_out = (void *)(unsigned long)systab64->con_out;
tmp |= systab64->con_out; tmp |= systab64->con_out;
efi_systab.stderr_handle = systab64->stderr_handle; efi_systab.stderr_handle = systab64->stderr_handle;
tmp |= systab64->stderr_handle; tmp |= systab64->stderr_handle;
...@@ -427,7 +427,7 @@ static int __init efi_systab_init(void *phys) ...@@ -427,7 +427,7 @@ static int __init efi_systab_init(void *phys)
efi_systab.con_in_handle = systab32->con_in_handle; efi_systab.con_in_handle = systab32->con_in_handle;
efi_systab.con_in = systab32->con_in; efi_systab.con_in = systab32->con_in;
efi_systab.con_out_handle = systab32->con_out_handle; efi_systab.con_out_handle = systab32->con_out_handle;
efi_systab.con_out = systab32->con_out; efi_systab.con_out = (void *)(unsigned long)systab32->con_out;
efi_systab.stderr_handle = systab32->stderr_handle; efi_systab.stderr_handle = systab32->stderr_handle;
efi_systab.stderr = systab32->stderr; efi_systab.stderr = systab32->stderr;
efi_systab.runtime = (void *)(unsigned long)systab32->runtime; efi_systab.runtime = (void *)(unsigned long)systab32->runtime;
......
...@@ -31,7 +31,7 @@ static efi_system_table_t efi_systab_xen __initdata = { ...@@ -31,7 +31,7 @@ static efi_system_table_t efi_systab_xen __initdata = {
.con_in_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ .con_in_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
.con_in = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ .con_in = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
.con_out_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ .con_out_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
.con_out = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ .con_out = NULL, /* Not used under Xen. */
.stderr_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ .stderr_handle = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
.stderr = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */ .stderr = EFI_INVALID_TABLE_ADDR, /* Not used under Xen. */
.runtime = (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR, .runtime = (efi_runtime_services_t *)EFI_INVALID_TABLE_ADDR,
......
...@@ -413,12 +413,13 @@ static efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh, ...@@ -413,12 +413,13 @@ static efi_status_t efi_file_size(efi_system_table_t *sys_table_arg, void *__fh,
return status; return status;
} }
static efi_status_t efi_file_read(void *handle, unsigned long *size, void *addr) static efi_status_t efi_file_read(efi_file_handle_t *handle,
unsigned long *size, void *addr)
{ {
return efi_call_proto(efi_file_handle, read, handle, size, addr); return efi_call_proto(efi_file_handle, read, handle, size, addr);
} }
static efi_status_t efi_file_close(void *handle) static efi_status_t efi_file_close(efi_file_handle_t *handle)
{ {
return efi_call_proto(efi_file_handle, close, handle); return efi_call_proto(efi_file_handle, close, handle);
} }
......
...@@ -69,11 +69,11 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg) ...@@ -69,11 +69,11 @@ void efi_retrieve_tpm2_eventlog(efi_system_table_t *sys_table_arg)
size_t log_size, last_entry_size; size_t log_size, last_entry_size;
efi_bool_t truncated; efi_bool_t truncated;
int version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2; int version = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
void *tcg2_protocol = NULL; efi_tcg2_protocol_t *tcg2_protocol = NULL;
int final_events_size = 0; int final_events_size = 0;
status = efi_call_early(locate_protocol, &tcg2_guid, NULL, status = efi_call_early(locate_protocol, &tcg2_guid, NULL,
&tcg2_protocol); (void **)&tcg2_protocol);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return; return;
......
...@@ -382,7 +382,11 @@ union efi_pci_io_protocol { ...@@ -382,7 +382,11 @@ union efi_pci_io_protocol {
void *allocate_buffer; void *allocate_buffer;
void *free_buffer; void *free_buffer;
void *flush; void *flush;
void *get_location; efi_status_t (*get_location)(efi_pci_io_protocol_t *,
unsigned long *segment_nr,
unsigned long *bus_nr,
unsigned long *device_nr,
unsigned long *function_nr);
void *attributes; void *attributes;
void *get_bar_attributes; void *get_bar_attributes;
void *set_bar_attributes; void *set_bar_attributes;
...@@ -730,6 +734,8 @@ typedef struct { ...@@ -730,6 +734,8 @@ typedef struct {
u32 tables; u32 tables;
} efi_system_table_32_t; } efi_system_table_32_t;
typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t;
typedef union { typedef union {
struct { struct {
efi_table_hdr_t hdr; efi_table_hdr_t hdr;
...@@ -738,7 +744,7 @@ typedef union { ...@@ -738,7 +744,7 @@ typedef union {
unsigned long con_in_handle; unsigned long con_in_handle;
unsigned long con_in; unsigned long con_in;
unsigned long con_out_handle; unsigned long con_out_handle;
unsigned long con_out; efi_simple_text_output_protocol_t *con_out;
unsigned long stderr_handle; unsigned long stderr_handle;
unsigned long stderr; unsigned long stderr;
efi_runtime_services_t *runtime; efi_runtime_services_t *runtime;
...@@ -1337,8 +1343,6 @@ struct efivar_entry { ...@@ -1337,8 +1343,6 @@ struct efivar_entry {
bool deleting; bool deleting;
}; };
typedef union efi_simple_text_output_protocol efi_simple_text_output_protocol_t;
union efi_simple_text_output_protocol { union efi_simple_text_output_protocol {
struct { struct {
void *reset; void *reset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment