mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2025-12-19 16:31:27 +01:00
efi_loader: Assure fitImage from capsule is used from 8-byte aligned address
The fitImage may be stored in EFI update capsule at address that is not aligned to 8 bytes. Since fitImage is a DT, new version of libfdt 1.7.2 rejects such an unaligned DT. Patch the code and copy the fitImage into aligned buffer in case it is not aligned. This does increase overhead for unaligned fitImages in EFI capsules, but tries to keep the overhead low for aligned ones. Signed-off-by: Marek Vasut <marek.vasut+renesas@mailbox.org> Reviewed-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
This commit is contained in:
parent
b8f2614eca
commit
8cc144227e
@ -651,6 +651,7 @@ efi_status_t EFIAPI efi_firmware_fit_set_image(
|
|||||||
efi_status_t status;
|
efi_status_t status;
|
||||||
struct fmp_state state = { 0 };
|
struct fmp_state state = { 0 };
|
||||||
char *orig_dfu_env;
|
char *orig_dfu_env;
|
||||||
|
void *img;
|
||||||
|
|
||||||
EFI_ENTRY("%p %d %p %zu %p %p %p\n", this, image_index, image,
|
EFI_ENTRY("%p %d %p %zu %p %p %p\n", this, image_index, image,
|
||||||
image_size, vendor_code, progress, abort_reason);
|
image_size, vendor_code, progress, abort_reason);
|
||||||
@ -677,7 +678,20 @@ efi_status_t EFIAPI efi_firmware_fit_set_image(
|
|||||||
return EFI_EXIT(EFI_DEVICE_ERROR);
|
return EFI_EXIT(EFI_DEVICE_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fit_update(image);
|
/* Make sure the update fitImage is properly aligned to 8-bytes */
|
||||||
|
if (!IS_ALIGNED((uintptr_t)image, 8)) {
|
||||||
|
img = memalign(8, image_size);
|
||||||
|
if (!img)
|
||||||
|
return EFI_EXIT(EFI_BAD_BUFFER_SIZE);
|
||||||
|
memcpy(img, image, image_size);
|
||||||
|
} else {
|
||||||
|
img = (void *)image;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = fit_update(img);
|
||||||
|
|
||||||
|
if (!IS_ALIGNED((uintptr_t)image, 8))
|
||||||
|
free(img);
|
||||||
|
|
||||||
if (env_set("dfu_alt_info", orig_dfu_env))
|
if (env_set("dfu_alt_info", orig_dfu_env))
|
||||||
log_warning("Unable to restore env variable \"dfu_alt_info\". Further DFU operations may fail!\n");
|
log_warning("Unable to restore env variable \"dfu_alt_info\". Further DFU operations may fail!\n");
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user