mirror of
https://xff.cz/git/u-boot/
synced 2025-09-03 09:42:22 +02:00
Merge tag 'efi-2020-10-rc4' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-10-rc4 Bug fixes are provided in the following areas: * convert file system debug and print messages go log messages * convert UEFI booting messages to log messages * UEFI related code clean up and simplification
This commit is contained in:
@@ -433,7 +433,9 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
|
|||||||
{
|
{
|
||||||
efi_handle_t mem_handle = NULL, handle;
|
efi_handle_t mem_handle = NULL, handle;
|
||||||
struct efi_device_path *file_path = NULL;
|
struct efi_device_path *file_path = NULL;
|
||||||
|
struct efi_device_path *msg_path;
|
||||||
efi_status_t ret;
|
efi_status_t ret;
|
||||||
|
u16 *load_options;
|
||||||
|
|
||||||
if (!bootefi_device_path || !bootefi_image_path) {
|
if (!bootefi_device_path || !bootefi_image_path) {
|
||||||
/*
|
/*
|
||||||
@@ -456,17 +458,21 @@ efi_status_t efi_run_image(void *source_buffer, efi_uintn_t source_size)
|
|||||||
file_path);
|
file_path);
|
||||||
if (ret != EFI_SUCCESS)
|
if (ret != EFI_SUCCESS)
|
||||||
goto out;
|
goto out;
|
||||||
|
msg_path = file_path;
|
||||||
} else {
|
} else {
|
||||||
file_path = efi_dp_append(bootefi_device_path,
|
file_path = efi_dp_append(bootefi_device_path,
|
||||||
bootefi_image_path);
|
bootefi_image_path);
|
||||||
|
msg_path = bootefi_image_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log_info("Booting %pD\n", msg_path);
|
||||||
|
|
||||||
ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer,
|
ret = EFI_CALL(efi_load_image(false, efi_root, file_path, source_buffer,
|
||||||
source_size, &handle));
|
source_size, &handle));
|
||||||
if (ret != EFI_SUCCESS)
|
if (ret != EFI_SUCCESS) {
|
||||||
|
log_err("Loading image failed\n");
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
u16 *load_options;
|
|
||||||
|
|
||||||
/* Transfer environment variable as load options */
|
/* Transfer environment variable as load options */
|
||||||
ret = efi_env_set_load_options(handle, "bootargs", &load_options);
|
ret = efi_env_set_load_options(handle, "bootargs", &load_options);
|
||||||
|
26
cmd/efi.c
26
cmd/efi.c
@@ -71,7 +71,19 @@ static int h_cmp_entry(const void *v1, const void *v2)
|
|||||||
return diff < 0 ? -1 : diff > 0 ? 1 : 0;
|
return diff < 0 ? -1 : diff > 0 ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *efi_build_mem_table(struct efi_entry_memmap *map, int size, bool skip_bs)
|
/**
|
||||||
|
* efi_build_mem_table() - make a sorted copy of the memory table
|
||||||
|
*
|
||||||
|
* @map: Pointer to EFI memory map table
|
||||||
|
* @size: Size of table in bytes
|
||||||
|
* @skip_bs: True to skip boot-time memory and merge it with conventional
|
||||||
|
* memory. This will significantly reduce the number of table
|
||||||
|
* entries.
|
||||||
|
* Return: pointer to the new table. It should be freed with free() by the
|
||||||
|
* caller.
|
||||||
|
*/
|
||||||
|
static void *efi_build_mem_table(struct efi_entry_memmap *map, int size,
|
||||||
|
bool skip_bs)
|
||||||
{
|
{
|
||||||
struct efi_mem_desc *desc, *end, *base, *dest, *prev;
|
struct efi_mem_desc *desc, *end, *base, *dest, *prev;
|
||||||
int count;
|
int count;
|
||||||
@@ -92,7 +104,13 @@ void *efi_build_mem_table(struct efi_entry_memmap *map, int size, bool skip_bs)
|
|||||||
end = (struct efi_mem_desc *)((ulong)base + count * map->desc_size);
|
end = (struct efi_mem_desc *)((ulong)base + count * map->desc_size);
|
||||||
for (desc = base; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
|
for (desc = base; desc < end; desc = efi_get_next_mem_desc(map, desc)) {
|
||||||
bool merge = true;
|
bool merge = true;
|
||||||
int type = desc->type;
|
u32 type = desc->type;
|
||||||
|
|
||||||
|
if (type >= EFI_MAX_MEMORY_TYPE) {
|
||||||
|
printf("Memory map contains invalid entry type %u\n",
|
||||||
|
type);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (skip_bs && is_boot_services(desc->type))
|
if (skip_bs && is_boot_services(desc->type))
|
||||||
type = EFI_CONVENTIONAL_MEMORY;
|
type = EFI_CONVENTIONAL_MEMORY;
|
||||||
@@ -119,7 +137,7 @@ void *efi_build_mem_table(struct efi_entry_memmap *map, int size, bool skip_bs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Mark the end */
|
/* Mark the end */
|
||||||
dest->type = EFI_TABLE_END;
|
dest->type = EFI_MAX_MEMORY_TYPE;
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
@@ -138,7 +156,7 @@ static void efi_print_mem_table(struct efi_entry_memmap *map,
|
|||||||
/* Keep track of all the different attributes we have seen */
|
/* Keep track of all the different attributes we have seen */
|
||||||
attr_seen_count = 0;
|
attr_seen_count = 0;
|
||||||
addr = 0;
|
addr = 0;
|
||||||
for (upto = 0; desc->type != EFI_TABLE_END;
|
for (upto = 0; desc->type != EFI_MAX_MEMORY_TYPE;
|
||||||
upto++, desc = efi_get_next_mem_desc(map, desc)) {
|
upto++, desc = efi_get_next_mem_desc(map, desc)) {
|
||||||
const char *name;
|
const char *name;
|
||||||
u64 size;
|
u64 size;
|
||||||
|
16
fs/fs.c
16
fs/fs.c
@@ -3,6 +3,8 @@
|
|||||||
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
|
* Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define LOG_CATEGORY LOGC_CORE
|
||||||
|
|
||||||
#include <command.h>
|
#include <command.h>
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@@ -34,7 +36,7 @@ static int fs_type = FS_TYPE_ANY;
|
|||||||
static inline int fs_probe_unsupported(struct blk_desc *fs_dev_desc,
|
static inline int fs_probe_unsupported(struct blk_desc *fs_dev_desc,
|
||||||
struct disk_partition *fs_partition)
|
struct disk_partition *fs_partition)
|
||||||
{
|
{
|
||||||
printf("** Unrecognized filesystem type **\n");
|
log_err("** Unrecognized filesystem type **\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -508,7 +510,7 @@ static int fs_read_lmb_check(const char *filename, ulong addr, loff_t offset,
|
|||||||
if (lmb_alloc_addr(&lmb, addr, read_len) == addr)
|
if (lmb_alloc_addr(&lmb, addr, read_len) == addr)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
printf("** Reading file would overwrite reserved memory **\n");
|
log_err("** Reading file would overwrite reserved memory **\n");
|
||||||
return -ENOSPC;
|
return -ENOSPC;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -538,7 +540,7 @@ static int _fs_read(const char *filename, ulong addr, loff_t offset, loff_t len,
|
|||||||
|
|
||||||
/* If we requested a specific number of bytes, check we got it */
|
/* If we requested a specific number of bytes, check we got it */
|
||||||
if (ret == 0 && len && *actread != len)
|
if (ret == 0 && len && *actread != len)
|
||||||
debug("** %s shorter than offset + len **\n", filename);
|
log_debug("** %s shorter than offset + len **\n", filename);
|
||||||
fs_close();
|
fs_close();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -562,7 +564,7 @@ int fs_write(const char *filename, ulong addr, loff_t offset, loff_t len,
|
|||||||
unmap_sysmem(buf);
|
unmap_sysmem(buf);
|
||||||
|
|
||||||
if (ret < 0 && len != *actwrite) {
|
if (ret < 0 && len != *actwrite) {
|
||||||
printf("** Unable to write file %s **\n", filename);
|
log_err("** Unable to write file %s **\n", filename);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
fs_close();
|
fs_close();
|
||||||
@@ -656,7 +658,7 @@ int fs_ln(const char *fname, const char *target)
|
|||||||
ret = info->ln(fname, target);
|
ret = info->ln(fname, target);
|
||||||
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("** Unable to create link %s -> %s **\n", fname, target);
|
log_err("** Unable to create link %s -> %s **\n", fname, target);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
}
|
}
|
||||||
fs_close();
|
fs_close();
|
||||||
@@ -737,7 +739,7 @@ int do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
|
|||||||
ret = _fs_read(filename, addr, pos, bytes, 1, &len_read);
|
ret = _fs_read(filename, addr, pos, bytes, 1, &len_read);
|
||||||
time = get_timer(time);
|
time = get_timer(time);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
printf("Failed to load '%s'\n", filename);
|
log_err("Failed to load '%s'\n", filename);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -902,7 +904,7 @@ int do_mkdir(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[],
|
|||||||
|
|
||||||
ret = fs_mkdir(argv[3]);
|
ret = fs_mkdir(argv[3]);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
printf("** Unable to create a directory \"%s\" **\n", argv[3]);
|
log_err("** Unable to create a directory \"%s\" **\n", argv[3]);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -5,6 +5,8 @@
|
|||||||
* Derived from code in ext4/dev.c, which was based on reiserfs/dev.c
|
* Derived from code in ext4/dev.c, which was based on reiserfs/dev.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define LOG_CATEGORY LOGC_CORE
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <blk.h>
|
#include <blk.h>
|
||||||
#include <compiler.h>
|
#include <compiler.h>
|
||||||
@@ -19,7 +21,7 @@ int fs_devread(struct blk_desc *blk, struct disk_partition *partition,
|
|||||||
int log2blksz;
|
int log2blksz;
|
||||||
ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, (blk ? blk->blksz : 0));
|
ALLOC_CACHE_ALIGN_BUFFER(char, sec_buf, (blk ? blk->blksz : 0));
|
||||||
if (blk == NULL) {
|
if (blk == NULL) {
|
||||||
printf("** Invalid Block Device Descriptor (NULL)\n");
|
log_err("** Invalid Block Device Descriptor (NULL)\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
log2blksz = blk->log2blksz;
|
log2blksz = blk->log2blksz;
|
||||||
@@ -27,8 +29,8 @@ int fs_devread(struct blk_desc *blk, struct disk_partition *partition,
|
|||||||
/* Check partition boundaries */
|
/* Check partition boundaries */
|
||||||
if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
|
if ((sector + ((byte_offset + byte_len - 1) >> log2blksz))
|
||||||
>= partition->size) {
|
>= partition->size) {
|
||||||
printf("%s read outside partition " LBAFU "\n", __func__,
|
log_err("%s read outside partition " LBAFU "\n", __func__,
|
||||||
sector);
|
sector);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,14 +38,14 @@ int fs_devread(struct blk_desc *blk, struct disk_partition *partition,
|
|||||||
sector += byte_offset >> log2blksz;
|
sector += byte_offset >> log2blksz;
|
||||||
byte_offset &= blk->blksz - 1;
|
byte_offset &= blk->blksz - 1;
|
||||||
|
|
||||||
debug(" <" LBAFU ", %d, %d>\n", sector, byte_offset, byte_len);
|
log_debug(" <" LBAFU ", %d, %d>\n", sector, byte_offset, byte_len);
|
||||||
|
|
||||||
if (byte_offset != 0) {
|
if (byte_offset != 0) {
|
||||||
int readlen;
|
int readlen;
|
||||||
/* read first part which isn't aligned with start of sector */
|
/* read first part which isn't aligned with start of sector */
|
||||||
if (blk_dread(blk, partition->start + sector, 1,
|
if (blk_dread(blk, partition->start + sector, 1,
|
||||||
(void *)sec_buf) != 1) {
|
(void *)sec_buf) != 1) {
|
||||||
printf(" ** %s read error **\n", __func__);
|
log_err(" ** %s read error **\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
readlen = min((int)blk->blksz - byte_offset,
|
readlen = min((int)blk->blksz - byte_offset,
|
||||||
@@ -73,7 +75,7 @@ int fs_devread(struct blk_desc *blk, struct disk_partition *partition,
|
|||||||
if (blk_dread(blk, partition->start + sector,
|
if (blk_dread(blk, partition->start + sector,
|
||||||
block_len >> log2blksz, (void *)buf) !=
|
block_len >> log2blksz, (void *)buf) !=
|
||||||
block_len >> log2blksz) {
|
block_len >> log2blksz) {
|
||||||
printf(" ** %s read error - block\n", __func__);
|
log_err(" ** %s read error - block\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
block_len = byte_len & ~(blk->blksz - 1);
|
block_len = byte_len & ~(blk->blksz - 1);
|
||||||
@@ -85,7 +87,7 @@ int fs_devread(struct blk_desc *blk, struct disk_partition *partition,
|
|||||||
/* read rest of data which are not in whole sector */
|
/* read rest of data which are not in whole sector */
|
||||||
if (blk_dread(blk, partition->start + sector, 1,
|
if (blk_dread(blk, partition->start + sector, 1,
|
||||||
(void *)sec_buf) != 1) {
|
(void *)sec_buf) != 1) {
|
||||||
printf("* %s read error - last part\n", __func__);
|
log_err("* %s read error - last part\n", __func__);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
memcpy(buf, sec_buf, byte_len);
|
memcpy(buf, sec_buf, byte_len);
|
||||||
|
@@ -180,7 +180,6 @@ enum efi_mem_type {
|
|||||||
EFI_PERSISTENT_MEMORY_TYPE,
|
EFI_PERSISTENT_MEMORY_TYPE,
|
||||||
|
|
||||||
EFI_MAX_MEMORY_TYPE,
|
EFI_MAX_MEMORY_TYPE,
|
||||||
EFI_TABLE_END, /* For efi_build_mem_table() */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Attribute values */
|
/* Attribute values */
|
||||||
@@ -481,17 +480,4 @@ void efi_putc(struct efi_priv *priv, const char ch);
|
|||||||
*/
|
*/
|
||||||
int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
|
int efi_info_get(enum efi_entry_t type, void **datap, int *sizep);
|
||||||
|
|
||||||
/**
|
|
||||||
* efi_build_mem_table() - make a sorted copy of the memory table
|
|
||||||
*
|
|
||||||
* @map: Pointer to EFI memory map table
|
|
||||||
* @size: Size of table in bytes
|
|
||||||
* @skip_bs: True to skip boot-time memory and merge it with conventional
|
|
||||||
* memory. This will significantly reduce the number of table
|
|
||||||
* entries.
|
|
||||||
* @return pointer to the new table. It should be freed with free() by the
|
|
||||||
* caller
|
|
||||||
*/
|
|
||||||
void *efi_build_mem_table(struct efi_entry_memmap *map, int size, bool skip_bs);
|
|
||||||
|
|
||||||
#endif /* _LINUX_EFI_H */
|
#endif /* _LINUX_EFI_H */
|
||||||
|
@@ -1883,10 +1883,6 @@ efi_status_t EFIAPI efi_load_image(bool boot_policy,
|
|||||||
if (ret != EFI_SUCCESS)
|
if (ret != EFI_SUCCESS)
|
||||||
goto error;
|
goto error;
|
||||||
} else {
|
} else {
|
||||||
if (!source_size) {
|
|
||||||
ret = EFI_LOAD_ERROR;
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
dest_buffer = source_buffer;
|
dest_buffer = source_buffer;
|
||||||
}
|
}
|
||||||
/* split file_path which contains both the device and file parts */
|
/* split file_path which contains both the device and file parts */
|
||||||
|
@@ -7,9 +7,12 @@
|
|||||||
* Copyright (c) 2016 Alexander Graf
|
* Copyright (c) 2016 Alexander Graf
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#define LOG_CATEGORY LOGC_EFI
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <cpu_func.h>
|
#include <cpu_func.h>
|
||||||
#include <efi_loader.h>
|
#include <efi_loader.h>
|
||||||
|
#include <log.h>
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <pe.h>
|
#include <pe.h>
|
||||||
#include <sort.h>
|
#include <sort.h>
|
||||||
@@ -153,14 +156,14 @@ static efi_status_t efi_loader_relocate(const IMAGE_BASE_RELOCATION *rel,
|
|||||||
case IMAGE_REL_BASED_RISCV_LOW12S:
|
case IMAGE_REL_BASED_RISCV_LOW12S:
|
||||||
/* We know that we're 4k aligned */
|
/* We know that we're 4k aligned */
|
||||||
if (delta & 0xfff) {
|
if (delta & 0xfff) {
|
||||||
printf("Unsupported reloc offset\n");
|
log_err("Unsupported reloc offset\n");
|
||||||
return EFI_LOAD_ERROR;
|
return EFI_LOAD_ERROR;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
printf("Unknown Relocation off %x type %x\n",
|
log_err("Unknown Relocation off %x type %x\n",
|
||||||
offset, type);
|
offset, type);
|
||||||
return EFI_LOAD_ERROR;
|
return EFI_LOAD_ERROR;
|
||||||
}
|
}
|
||||||
relocs++;
|
relocs++;
|
||||||
@@ -202,7 +205,7 @@ static void efi_set_code_and_data_type(
|
|||||||
loaded_image_info->image_data_type = EFI_RUNTIME_SERVICES_DATA;
|
loaded_image_info->image_data_type = EFI_RUNTIME_SERVICES_DATA;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printf("%s: invalid image type: %u\n", __func__, image_type);
|
log_err("invalid image type: %u\n", image_type);
|
||||||
/* Let's assume it is an application */
|
/* Let's assume it is an application */
|
||||||
loaded_image_info->image_code_type = EFI_LOADER_CODE;
|
loaded_image_info->image_code_type = EFI_LOADER_CODE;
|
||||||
loaded_image_info->image_data_type = EFI_LOADER_DATA;
|
loaded_image_info->image_data_type = EFI_LOADER_DATA;
|
||||||
@@ -499,7 +502,7 @@ static bool efi_image_authenticate(void *efi, size_t efi_size)
|
|||||||
size_t new_efi_size, auth_size;
|
size_t new_efi_size, auth_size;
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
debug("%s: Enter, %d\n", __func__, ret);
|
EFI_PRINT("%s: Enter, %d\n", __func__, ret);
|
||||||
|
|
||||||
if (!efi_secure_boot_enabled())
|
if (!efi_secure_boot_enabled())
|
||||||
return true;
|
return true;
|
||||||
@@ -645,14 +648,14 @@ static bool efi_image_authenticate(void *efi, size_t efi_size)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Signature was not verified by \"db\"\n");
|
EFI_PRINT("Signature was not verified by \"db\"\n");
|
||||||
|
|
||||||
if (efi_signature_lookup_digest(regs, db)) {
|
if (efi_signature_lookup_digest(regs, db)) {
|
||||||
ret = true;
|
ret = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Image's digest was not found in \"db\" or \"dbx\"\n");
|
EFI_PRINT("Image's digest was not found in \"db\" or \"dbx\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
err:
|
err:
|
||||||
@@ -662,7 +665,7 @@ err:
|
|||||||
free(regs);
|
free(regs);
|
||||||
free(new_efi);
|
free(new_efi);
|
||||||
|
|
||||||
debug("%s: Exit, %d\n", __func__, ret);
|
EFI_PRINT("%s: Exit, %d\n", __func__, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -704,14 +707,14 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
|||||||
|
|
||||||
/* Sanity check for a file header */
|
/* Sanity check for a file header */
|
||||||
if (efi_size < sizeof(*dos)) {
|
if (efi_size < sizeof(*dos)) {
|
||||||
printf("%s: Truncated DOS Header\n", __func__);
|
log_err("Truncated DOS Header\n");
|
||||||
ret = EFI_LOAD_ERROR;
|
ret = EFI_LOAD_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
dos = efi;
|
dos = efi;
|
||||||
if (dos->e_magic != IMAGE_DOS_SIGNATURE) {
|
if (dos->e_magic != IMAGE_DOS_SIGNATURE) {
|
||||||
printf("%s: Invalid DOS Signature\n", __func__);
|
log_err("Invalid DOS Signature\n");
|
||||||
ret = EFI_LOAD_ERROR;
|
ret = EFI_LOAD_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -722,14 +725,14 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
|||||||
* of the 64bit header which is longer than the 32bit header.
|
* of the 64bit header which is longer than the 32bit header.
|
||||||
*/
|
*/
|
||||||
if (efi_size < dos->e_lfanew + sizeof(IMAGE_NT_HEADERS64)) {
|
if (efi_size < dos->e_lfanew + sizeof(IMAGE_NT_HEADERS64)) {
|
||||||
printf("%s: Invalid offset for Extended Header\n", __func__);
|
log_err("Invalid offset for Extended Header\n");
|
||||||
ret = EFI_LOAD_ERROR;
|
ret = EFI_LOAD_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
nt = (void *) ((char *)efi + dos->e_lfanew);
|
nt = (void *) ((char *)efi + dos->e_lfanew);
|
||||||
if (nt->Signature != IMAGE_NT_SIGNATURE) {
|
if (nt->Signature != IMAGE_NT_SIGNATURE) {
|
||||||
printf("%s: Invalid NT Signature\n", __func__);
|
log_err("Invalid NT Signature\n");
|
||||||
ret = EFI_LOAD_ERROR;
|
ret = EFI_LOAD_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -741,8 +744,8 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!supported) {
|
if (!supported) {
|
||||||
printf("%s: Machine type 0x%04x is not supported\n",
|
log_err("Machine type 0x%04x is not supported\n",
|
||||||
__func__, nt->FileHeader.Machine);
|
nt->FileHeader.Machine);
|
||||||
ret = EFI_LOAD_ERROR;
|
ret = EFI_LOAD_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -753,17 +756,18 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
|||||||
|
|
||||||
if (efi_size < ((void *)sections + sizeof(sections[0]) * num_sections
|
if (efi_size < ((void *)sections + sizeof(sections[0]) * num_sections
|
||||||
- efi)) {
|
- efi)) {
|
||||||
printf("%s: Invalid number of sections: %d\n",
|
log_err("Invalid number of sections: %d\n", num_sections);
|
||||||
__func__, num_sections);
|
|
||||||
ret = EFI_LOAD_ERROR;
|
ret = EFI_LOAD_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Authenticate an image */
|
/* Authenticate an image */
|
||||||
if (efi_image_authenticate(efi, efi_size))
|
if (efi_image_authenticate(efi, efi_size)) {
|
||||||
handle->auth_status = EFI_IMAGE_AUTH_PASSED;
|
handle->auth_status = EFI_IMAGE_AUTH_PASSED;
|
||||||
else
|
} else {
|
||||||
handle->auth_status = EFI_IMAGE_AUTH_FAILED;
|
handle->auth_status = EFI_IMAGE_AUTH_FAILED;
|
||||||
|
log_err("Image not authenticated\n");
|
||||||
|
}
|
||||||
|
|
||||||
/* Calculate upper virtual address boundary */
|
/* Calculate upper virtual address boundary */
|
||||||
for (i = num_sections - 1; i >= 0; i--) {
|
for (i = num_sections - 1; i >= 0; i--) {
|
||||||
@@ -782,8 +786,7 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
|||||||
efi_reloc = efi_alloc(virt_size,
|
efi_reloc = efi_alloc(virt_size,
|
||||||
loaded_image_info->image_code_type);
|
loaded_image_info->image_code_type);
|
||||||
if (!efi_reloc) {
|
if (!efi_reloc) {
|
||||||
printf("%s: Could not allocate %lu bytes\n",
|
log_err("Out of memory\n");
|
||||||
__func__, virt_size);
|
|
||||||
ret = EFI_OUT_OF_RESOURCES;
|
ret = EFI_OUT_OF_RESOURCES;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -799,8 +802,7 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
|||||||
efi_reloc = efi_alloc(virt_size,
|
efi_reloc = efi_alloc(virt_size,
|
||||||
loaded_image_info->image_code_type);
|
loaded_image_info->image_code_type);
|
||||||
if (!efi_reloc) {
|
if (!efi_reloc) {
|
||||||
printf("%s: Could not allocate %lu bytes\n",
|
log_err("Out of memory\n");
|
||||||
__func__, virt_size);
|
|
||||||
ret = EFI_OUT_OF_RESOURCES;
|
ret = EFI_OUT_OF_RESOURCES;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
@@ -809,8 +811,8 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
|
|||||||
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
|
rel = efi_reloc + opt->DataDirectory[rel_idx].VirtualAddress;
|
||||||
virt_size = ALIGN(virt_size, opt->SectionAlignment);
|
virt_size = ALIGN(virt_size, opt->SectionAlignment);
|
||||||
} else {
|
} else {
|
||||||
printf("%s: Invalid optional header magic %x\n", __func__,
|
log_err("Invalid optional header magic %x\n",
|
||||||
nt->OptionalHeader.Magic);
|
nt->OptionalHeader.Magic);
|
||||||
ret = EFI_LOAD_ERROR;
|
ret = EFI_LOAD_ERROR;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@@ -62,10 +62,6 @@ ifeq ($(CONFIG_BLK)$(CONFIG_DOS_PARTITION),yy)
|
|||||||
obj-y += efi_selftest_block_device.o
|
obj-y += efi_selftest_block_device.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# TODO: As of v2019.10 the relocation code for the EFI application cannot
|
|
||||||
# be built on ARMv7-M.
|
|
||||||
ifeq ($(CONFIG_CPU_V7M),)
|
|
||||||
|
|
||||||
obj-y += \
|
obj-y += \
|
||||||
efi_selftest_exception.o \
|
efi_selftest_exception.o \
|
||||||
efi_selftest_loadimage.o \
|
efi_selftest_loadimage.o \
|
||||||
@@ -99,5 +95,3 @@ $(obj)/efi_selftest_exception.o: $(obj)/efi_miniapp_file_image_exception.h
|
|||||||
$(obj)/efi_selftest_startimage_exit.o: $(obj)/efi_miniapp_file_image_exit.h
|
$(obj)/efi_selftest_startimage_exit.o: $(obj)/efi_miniapp_file_image_exit.h
|
||||||
|
|
||||||
$(obj)/efi_selftest_startimage_return.o: $(obj)/efi_miniapp_file_image_return.h
|
$(obj)/efi_selftest_startimage_return.o: $(obj)/efi_miniapp_file_image_return.h
|
||||||
|
|
||||||
endif
|
|
||||||
|
Reference in New Issue
Block a user