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: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Ard Biesheuvel
2020-02-14 14:29:21 +01:00
parent 832187f039
commit f7b85b33eb
3 changed files with 35 additions and 18 deletions

View File

@@ -377,7 +377,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
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;
status = efi_allocate_pages(0x4000, (unsigned long *)&boot_params,
@@ -392,7 +392,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
hdr = &boot_params->hdr;
/* 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