Commit f7b85b33 authored by Ard Biesheuvel's avatar Ard Biesheuvel

efi/libstub/x86: Make loaded_image protocol handling mixed mode safe

Add the definitions and use the special wrapper so that the loaded_image
UEFI protocol can be safely used from mixed mode.
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 832187f0
...@@ -171,8 +171,8 @@ char *efi_convert_cmdline(efi_loaded_image_t *image, ...@@ -171,8 +171,8 @@ char *efi_convert_cmdline(efi_loaded_image_t *image,
const u16 *s2; const u16 *s2;
u8 *s1 = NULL; u8 *s1 = NULL;
unsigned long cmdline_addr = 0; unsigned long cmdline_addr = 0;
int load_options_chars = image->load_options_size / 2; /* UTF-16 */ int load_options_chars = efi_table_attr(image, load_options_size) / 2;
const u16 *options = image->load_options; const u16 *options = efi_table_attr(image, load_options);
int options_bytes = 0; /* UTF-8 bytes */ int options_bytes = 0; /* UTF-8 bytes */
int options_chars = 0; /* UTF-16 chars */ int options_chars = 0; /* UTF-16 chars */
efi_status_t status; efi_status_t status;
......
...@@ -308,20 +308,37 @@ union efi_graphics_output_protocol { ...@@ -308,20 +308,37 @@ union efi_graphics_output_protocol {
} mixed_mode; } mixed_mode;
}; };
typedef struct { typedef union {
u32 revision; struct {
efi_handle_t parent_handle; u32 revision;
efi_system_table_t *system_table; efi_handle_t parent_handle;
efi_handle_t device_handle; efi_system_table_t *system_table;
void *file_path; efi_handle_t device_handle;
void *reserved; void *file_path;
u32 load_options_size; void *reserved;
void *load_options; u32 load_options_size;
void *image_base; void *load_options;
__aligned_u64 image_size; void *image_base;
unsigned int image_code_type; __aligned_u64 image_size;
unsigned int image_data_type; unsigned int image_code_type;
efi_status_t (__efiapi *unload)(efi_handle_t image_handle); unsigned int image_data_type;
efi_status_t (__efiapi *unload)(efi_handle_t image_handle);
};
struct {
u32 revision;
u32 parent_handle;
u32 system_table;
u32 device_handle;
u32 file_path;
u32 reserved;
u32 load_options_size;
u32 load_options;
u32 image_base;
__aligned_u64 image_size;
u32 image_code_type;
u32 image_data_type;
u32 unload;
} mixed_mode;
} efi_loaded_image_t; } efi_loaded_image_t;
typedef struct { typedef struct {
......
...@@ -377,7 +377,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, ...@@ -377,7 +377,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
return status; return status;
} }
hdr = &((struct boot_params *)image->image_base)->hdr; hdr = &((struct boot_params *)efi_table_attr(image, image_base))->hdr;
above4g = hdr->xloadflags & XLF_CAN_BE_LOADED_ABOVE_4G; above4g = hdr->xloadflags & XLF_CAN_BE_LOADED_ABOVE_4G;
status = efi_allocate_pages(0x4000, (unsigned long *)&boot_params, status = efi_allocate_pages(0x4000, (unsigned long *)&boot_params,
...@@ -392,7 +392,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, ...@@ -392,7 +392,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
hdr = &boot_params->hdr; hdr = &boot_params->hdr;
/* Copy the second sector to boot_params */ /* Copy the second sector to boot_params */
memcpy(&hdr->jump, image->image_base + 512, 512); memcpy(&hdr->jump, efi_table_attr(image, image_base) + 512, 512);
/* /*
* Fill out some of the header fields ourselves because the * Fill out some of the header fields ourselves because the
......
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