Highlights this time: - Many small fixes to improve spec compatibility (found by SCT) - Almost enough to run with sandbox target - GetTime() improvements - Enable EFI_LOADER and HYP entry on ARMv7 with NONSEC=y -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAABAgAGBQJbWHUwAAoJECszeR4D/txgKlUP/3Lu6pxScwzL7TsSD6OFZQ6M qQq2FH89XOA6/3r04RXrJZoHwOKIH5uj7ea6FlitpS1sQ4UOCQhp/lJJuJennHHj +veeuzI1sKTCX8Kd9ptrZDEF3G8lbF/zSyCFa1MOd1ONDVsTgSO9fOGmiqcC9FBF UrUH7dzXlE2CWs/mv/UikCBI7rYF+NOFJNuwHVXfsW4PyQ/7uaNsa7Rl3mXYb/Lr gjdcJkeHZAmFv/r84tGS9AFv+m0So9AGEYD7MeQDt02hSOuH9/nu4HgPmiwln3Fn 3sFA3+daMrlFNi6kFw10S0sjKz94nN+Arm6cIXlvGaoc/wnPM2wEcKOSiXhzVM8d CoP/26N/ETRoI9P01C2WyTrKjo0O0aFwp3ubfmmbdcaKr/pyjAJgb3BnqXBfAr7T OjsE086jtHzdyKYKXDIz8+ZxSo4VsiDjBzDK7LVA0L5KtqAFFa+OYjlgEMJnQCk3 YJfj+rhxfpjzFI7x5BAgq0q3XQRvAJS8QcUq+V2todQ3JkUlCIaVUNQLWAfNJN0q ze/WR8l4nwj5YFo8XiEbFHpQi/1bkR6cSzyjlBKUqrtHUUEu32vWlzZpNi6HzPMq cP7gehboFlcCSr8T2UMjBTE1LWI35eWNQQoiNRrS2UVcTH9h1vXMFV9PT+I82BBl ivJ+YwF9nU1JdS8CG3n7 =ePTT -----END PGP SIGNATURE----- Merge tag 'signed-efi-next' of git://github.com/agraf/u-boot Patch queue for efi - 2018-07-25 Highlights this time: - Many small fixes to improve spec compatibility (found by SCT) - Almost enough to run with sandbox target - GetTime() improvements - Enable EFI_LOADER and HYP entry on ARMv7 with NONSEC=ylime2-spi
commit
406fd7e207
@ -1,45 +0,0 @@ |
||||
/* SPDX-License-Identifier: GPL-2.0+ */ |
||||
/*
|
||||
* Brought in from Linux 4.1, removed things not useful to U-Boot. |
||||
* The definitions perhaps came from the GNU Library which is GPL. |
||||
*/ |
||||
|
||||
#ifndef _ASM_X86_ELF_H |
||||
#define _ASM_X86_ELF_H |
||||
|
||||
/* ELF register definitions */ |
||||
#define R_386_NONE 0 |
||||
#define R_386_32 1 |
||||
#define R_386_PC32 2 |
||||
#define R_386_GOT32 3 |
||||
#define R_386_PLT32 4 |
||||
#define R_386_COPY 5 |
||||
#define R_386_GLOB_DAT 6 |
||||
#define R_386_JMP_SLOT 7 |
||||
#define R_386_RELATIVE 8 |
||||
#define R_386_GOTOFF 9 |
||||
#define R_386_GOTPC 10 |
||||
#define R_386_NUM 11 |
||||
|
||||
/* x86-64 relocation types */ |
||||
#define R_X86_64_NONE 0 /* No reloc */ |
||||
#define R_X86_64_64 1 /* Direct 64 bit */ |
||||
#define R_X86_64_PC32 2 /* PC relative 32 bit signed */ |
||||
#define R_X86_64_GOT32 3 /* 32 bit GOT entry */ |
||||
#define R_X86_64_PLT32 4 /* 32 bit PLT address */ |
||||
#define R_X86_64_COPY 5 /* Copy symbol at runtime */ |
||||
#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */ |
||||
#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */ |
||||
#define R_X86_64_RELATIVE 8 /* Adjust by program base */ |
||||
/* 32 bit signed pc relative offset to GOT */ |
||||
#define R_X86_64_GOTPCREL 9 |
||||
#define R_X86_64_32 10 /* Direct 32 bit zero extended */ |
||||
#define R_X86_64_32S 11 /* Direct 32 bit sign extended */ |
||||
#define R_X86_64_16 12 /* Direct 16 bit zero extended */ |
||||
#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */ |
||||
#define R_X86_64_8 14 /* Direct 8 bit sign extended */ |
||||
#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */ |
||||
|
||||
#define R_X86_64_NUM 16 |
||||
|
||||
#endif |
@ -1,2 +1,4 @@ |
||||
efi_miniapp_file_image.h |
||||
efi_miniapp_file_image_exit.h |
||||
efi_miniapp_file_image_return.h |
||||
*.efi |
||||
*.so |
||||
|
@ -0,0 +1,266 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* efi_selftest_config_tables |
||||
* |
||||
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de> |
||||
* |
||||
* This test checks the following service: |
||||
* InstallConfigurationTable. |
||||
*/ |
||||
|
||||
#include <efi_selftest.h> |
||||
|
||||
static const struct efi_system_table *sys_table; |
||||
static struct efi_boot_services *boottime; |
||||
|
||||
static efi_guid_t table_guid = |
||||
EFI_GUID(0xff1c3f9e, 0x795b, 0x1529, 0xf1, 0x55, |
||||
0x17, 0x2e, 0x51, 0x6b, 0x49, 0x75); |
||||
|
||||
/*
|
||||
* Notification function, increments the notfication count if parameter |
||||
* context is provided. |
||||
* |
||||
* @event notified event |
||||
* @context pointer to the notification count |
||||
*/ |
||||
static void EFIAPI notify(struct efi_event *event, void *context) |
||||
{ |
||||
unsigned int *count = context; |
||||
|
||||
if (count) |
||||
++*count; |
||||
} |
||||
|
||||
/*
|
||||
* Check crc32 of a table. |
||||
*/ |
||||
static int check_table(const void *table) |
||||
{ |
||||
efi_status_t ret; |
||||
u32 crc32, res; |
||||
/* Casting from const to not const */ |
||||
struct efi_table_hdr *hdr = (struct efi_table_hdr *)table; |
||||
|
||||
crc32 = hdr->crc32; |
||||
/*
|
||||
* Setting the crc32 of the 'const' table to zero is easier than |
||||
* copying |
||||
*/ |
||||
hdr->crc32 = 0; |
||||
ret = boottime->calculate_crc32(table, hdr->headersize, &res); |
||||
/* Reset table crc32 so it stays constant */ |
||||
hdr->crc32 = crc32; |
||||
if (ret != EFI_ST_SUCCESS) { |
||||
efi_st_error("CalculateCrc32 failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (res != crc32) { |
||||
efi_st_error("Incorrect CRC32\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
/*
|
||||
* Setup unit test. |
||||
* |
||||
* @handle: handle of the loaded image |
||||
* @systable: system table |
||||
* @return: EFI_ST_SUCCESS for success |
||||
*/ |
||||
static int setup(const efi_handle_t handle, |
||||
const struct efi_system_table *systable) |
||||
{ |
||||
sys_table = systable; |
||||
boottime = systable->boottime; |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
/*
|
||||
* Execute unit test. |
||||
* |
||||
* A table is installed, updated, removed. The table entry and the |
||||
* triggering of events is checked. |
||||
* |
||||
* @return: EFI_ST_SUCCESS for success |
||||
*/ |
||||
static int execute(void) |
||||
{ |
||||
efi_status_t ret; |
||||
unsigned int counter = 0; |
||||
struct efi_event *event; |
||||
void *table; |
||||
const unsigned int tables[2]; |
||||
efi_uintn_t i; |
||||
efi_uintn_t tabcnt; |
||||
efi_uintn_t table_count = sys_table->nr_tables; |
||||
|
||||
ret = boottime->create_event_ex(0, TPL_NOTIFY, |
||||
notify, (void *)&counter, |
||||
&table_guid, &event); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Failed to create event\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
/* Try to delete non-existent table */ |
||||
ret = boottime->install_configuration_table(&table_guid, NULL); |
||||
if (ret != EFI_NOT_FOUND) { |
||||
efi_st_error("Failed to detect missing table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (counter) { |
||||
efi_st_error("Notification function was called.\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Check if the event was signaled */ |
||||
ret = boottime->check_event(event); |
||||
if (ret == EFI_SUCCESS) { |
||||
efi_st_error("Event was signaled on EFI_NOT_FOUND\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (counter != 1) { |
||||
efi_st_error("Notification function was not called.\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (table_count != sys_table->nr_tables) { |
||||
efi_st_error("Incorrect table count %u, expected %u\n", |
||||
(unsigned int)sys_table->nr_tables, |
||||
(unsigned int)table_count); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
/* Install table */ |
||||
ret = boottime->install_configuration_table(&table_guid, |
||||
(void *)&tables[0]); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Failed to install table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Check signaled state */ |
||||
ret = boottime->check_event(event); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Event was not signaled on insert\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (++table_count != sys_table->nr_tables) { |
||||
efi_st_error("Incorrect table count %u, expected %u\n", |
||||
(unsigned int)sys_table->nr_tables, |
||||
(unsigned int)table_count); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
table = NULL; |
||||
for (i = 0; i < sys_table->nr_tables; ++i) { |
||||
if (!efi_st_memcmp(&sys_table->tables[i].guid, &table_guid, |
||||
sizeof(efi_guid_t))) |
||||
table = sys_table->tables[i].table; |
||||
} |
||||
if (!table) { |
||||
efi_st_error("Installed table not found\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (table != &tables[0]) { |
||||
efi_st_error("Incorrect table address\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (check_table(sys_table) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking system table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
/* Update table */ |
||||
ret = boottime->install_configuration_table(&table_guid, |
||||
(void *)&tables[1]); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Failed to update table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Check signaled state */ |
||||
ret = boottime->check_event(event); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Event was not signaled on update\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (table_count != sys_table->nr_tables) { |
||||
efi_st_error("Incorrect table count %u, expected %u\n", |
||||
(unsigned int)sys_table->nr_tables, |
||||
(unsigned int)table_count); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
table = NULL; |
||||
tabcnt = 0; |
||||
for (i = 0; i < sys_table->nr_tables; ++i) { |
||||
if (!efi_st_memcmp(&sys_table->tables[i].guid, &table_guid, |
||||
sizeof(efi_guid_t))) { |
||||
table = sys_table->tables[i].table; |
||||
++tabcnt; |
||||
} |
||||
} |
||||
if (!table) { |
||||
efi_st_error("Installed table not found\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (tabcnt > 1) { |
||||
efi_st_error("Duplicate table guid\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (table != &tables[1]) { |
||||
efi_st_error("Incorrect table address\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (check_table(sys_table) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking system table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
/* Delete table */ |
||||
ret = boottime->install_configuration_table(&table_guid, NULL); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Failed to delete table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
/* Check signaled state */ |
||||
ret = boottime->check_event(event); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Event was not signaled on delete\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (--table_count != sys_table->nr_tables) { |
||||
efi_st_error("Incorrect table count %u, expected %u\n", |
||||
(unsigned int)sys_table->nr_tables, |
||||
(unsigned int)table_count); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
table = NULL; |
||||
for (i = 0; i < sys_table->nr_tables; ++i) { |
||||
if (!efi_st_memcmp(&sys_table->tables[i].guid, &table_guid, |
||||
sizeof(efi_guid_t))) { |
||||
table = sys_table->tables[i].table; |
||||
} |
||||
} |
||||
if (table) { |
||||
efi_st_error("Wrong table deleted\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
ret = boottime->close_event(event); |
||||
if (ret != EFI_SUCCESS) { |
||||
efi_st_error("Failed to close event\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (check_table(sys_table) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking system table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
EFI_UNIT_TEST(configtables) = { |
||||
.name = "configuration tables", |
||||
.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, |
||||
.setup = setup, |
||||
.execute = execute, |
||||
}; |
@ -0,0 +1,141 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* efi_selftest_crc32 |
||||
* |
||||
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de> |
||||
* |
||||
* This unit test checks the CalculateCrc32 bootservice and checks the |
||||
* headers of the system table, the boot services tablle, and the runtime |
||||
* services table before and after ExitBootServices(). |
||||
*/ |
||||
|
||||
#include <efi_selftest.h> |
||||
|
||||
const struct efi_system_table *st; |
||||
efi_status_t (EFIAPI *bs_crc32)(const void *data, efi_uintn_t data_size, |
||||
u32 *crc32); |
||||
|
||||
static int check_table(const void *table) |
||||
{ |
||||
efi_status_t ret; |
||||
u32 crc32, res; |
||||
/* Casting from const to not const */ |
||||
struct efi_table_hdr *hdr = (struct efi_table_hdr *)table; |
||||
|
||||
if (!hdr->signature) { |
||||
efi_st_error("Missing header signature\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (!hdr->revision) { |
||||
efi_st_error("Missing header revision\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (hdr->headersize <= sizeof(struct efi_table_hdr)) { |
||||
efi_st_error("Incorrect headersize value\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (hdr->reserved) { |
||||
efi_st_error("Reserved header field is not zero\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
crc32 = hdr->crc32; |
||||
/*
|
||||
* Setting the crc32 of the 'const' table to zero is easier than |
||||
* copying |
||||
*/ |
||||
hdr->crc32 = 0; |
||||
ret = bs_crc32(table, hdr->headersize, &res); |
||||
/* Reset table crc32 so it stays constant */ |
||||
hdr->crc32 = crc32; |
||||
if (ret != EFI_ST_SUCCESS) { |
||||
efi_st_error("CalculateCrc32 failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (res != crc32) { |
||||
efi_st_error("Incorrect CRC32\n"); |
||||
// return EFI_ST_FAILURE;
|
||||
} |
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
/*
|
||||
* Setup unit test. |
||||
* |
||||
* Check that CalculateCrc32 is working correctly. |
||||
* Check tables before ExitBootServices(). |
||||
* |
||||
* @handle: handle of the loaded image |
||||
* @systable: system table |
||||
* @return: EFI_ST_SUCCESS for success |
||||
*/ |
||||
static int setup(const efi_handle_t handle, |
||||
const struct efi_system_table *systable) |
||||
{ |
||||
efi_status_t ret; |
||||
u32 res; |
||||
|
||||
st = systable; |
||||
bs_crc32 = systable->boottime->calculate_crc32; |
||||
|
||||
/* Check that CalculateCrc32 is working */ |
||||
ret = bs_crc32("U-Boot", 6, &res); |
||||
if (ret != EFI_ST_SUCCESS) { |
||||
efi_st_error("CalculateCrc32 failed\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (res != 0x134b0db4) { |
||||
efi_st_error("Incorrect CRC32\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
/* Check tables before ExitBootServices() */ |
||||
if (check_table(st) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking system table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (check_table(st->boottime) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking boottime table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (check_table(st->runtime) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking runtime table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
/*
|
||||
* Execute unit test |
||||
* |
||||
* Check tables after ExitBootServices() |
||||
* |
||||
* @return: EFI_ST_SUCCESS for success |
||||
*/ |
||||
static int execute(void) |
||||
{ |
||||
if (check_table(st) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking system table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
if (check_table(st->runtime) != EFI_ST_SUCCESS) { |
||||
efi_st_error("Checking runtime table\n"); |
||||
return EFI_ST_FAILURE; |
||||
} |
||||
|
||||
/*
|
||||
* We cannot call SetVirtualAddressMap() and recheck the runtime |
||||
* table afterwards because this would invalidate the addresses of the |
||||
* unit tests. |
||||
*/ |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
EFI_UNIT_TEST(crc32) = { |
||||
.name = "crc32", |
||||
.phase = EFI_SETUP_BEFORE_BOOTTIME_EXIT, |
||||
.setup = setup, |
||||
.execute = execute, |
||||
}; |
@ -0,0 +1,67 @@ |
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* efi_selftest_rtc |
||||
* |
||||
* Copyright (c) 2018 Heinrich Schuchardt <xypron.glpk@gmx.de> |
||||
* |
||||
* Test the real time clock runtime services. |
||||
*/ |
||||
|
||||
#include <efi_selftest.h> |
||||
|
||||
#define EFI_ST_NO_RTC "Could not read real time clock\n" |
||||
|
||||
static struct efi_runtime_services *runtime; |
||||
|
||||
/*
|
||||
* Setup unit test. |
||||
* |
||||
* @handle: handle of the loaded image |
||||
* @systable: system table |
||||
* @return: EFI_ST_SUCCESS for success |
||||
*/ |
||||
static int setup(const efi_handle_t handle, |
||||
const struct efi_system_table *systable) |
||||
{ |
||||
runtime = systable->runtime; |
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
/*
|
||||
* Execute unit test. |
||||
* |
||||
* Display current time. |
||||
* |
||||
* @return: EFI_ST_SUCCESS for success |
||||
*/ |
||||
static int execute(void) |
||||
{ |
||||
efi_status_t ret; |
||||
struct efi_time tm; |
||||
|
||||
/* Display current time */ |
||||
ret = runtime->get_time(&tm, NULL); |
||||
if (ret != EFI_SUCCESS) { |
||||
#ifdef CONFIG_CMD_DATE |
||||
efi_st_error(EFI_ST_NO_RTC); |
||||
return EFI_ST_FAILURE; |
||||
#else |
||||
efi_st_todo(EFI_ST_NO_RTC); |
||||
return EFI_ST_SUCCESS; |
||||
#endif |
||||
} else { |
||||
efi_st_printf("Time according to real time clock: " |
||||
"%.4u-%.2u-%.2u %.2u:%.2u:%.2u\n", |
||||
tm.year, tm.month, tm.day, |
||||
tm.hour, tm.minute, tm.second); |
||||
} |
||||
|
||||
return EFI_ST_SUCCESS; |
||||
} |
||||
|
||||
EFI_UNIT_TEST(rtc) = { |
||||
.name = "real time clock", |
||||
.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, |
||||
.setup = setup, |
||||
.execute = execute, |
||||
}; |
Loading…
Reference in new issue