Merge branch 'master' into next
Merge in v2020.10-rc5
This commit is contained in:
@@ -42,9 +42,9 @@ LIST_HEAD(efi_register_notify_events);
|
||||
/* Handle of the currently executing image */
|
||||
static efi_handle_t current_image;
|
||||
|
||||
#ifdef CONFIG_ARM
|
||||
#if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
|
||||
/*
|
||||
* The "gd" pointer lives in a register on ARM and AArch64 that we declare
|
||||
* The "gd" pointer lives in a register on ARM and RISC-V that we declare
|
||||
* fixed when compiling U-Boot. However, the payload does not know about that
|
||||
* restriction so we need to manually swap its and our view of that register on
|
||||
* EFI callback entry/exit.
|
||||
@@ -86,7 +86,7 @@ static efi_status_t EFIAPI efi_disconnect_controller(
|
||||
int __efi_entry_check(void)
|
||||
{
|
||||
int ret = entry_count++ == 0;
|
||||
#ifdef CONFIG_ARM
|
||||
#if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
|
||||
assert(efi_gd);
|
||||
app_gd = gd;
|
||||
set_gd(efi_gd);
|
||||
@@ -98,7 +98,7 @@ int __efi_entry_check(void)
|
||||
int __efi_exit_check(void)
|
||||
{
|
||||
int ret = --entry_count == 0;
|
||||
#ifdef CONFIG_ARM
|
||||
#if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
|
||||
set_gd(app_gd);
|
||||
#endif
|
||||
return ret;
|
||||
@@ -107,7 +107,7 @@ int __efi_exit_check(void)
|
||||
/**
|
||||
* efi_save_gd() - save global data register
|
||||
*
|
||||
* On the ARM architecture gd is mapped to a fixed register (r9 or x18).
|
||||
* On the ARM and RISC-V architectures gd is mapped to a fixed register.
|
||||
* As this register may be overwritten by an EFI payload we save it here
|
||||
* and restore it on every callback entered.
|
||||
*
|
||||
@@ -115,7 +115,7 @@ int __efi_exit_check(void)
|
||||
*/
|
||||
void efi_save_gd(void)
|
||||
{
|
||||
#ifdef CONFIG_ARM
|
||||
#if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
|
||||
efi_gd = gd;
|
||||
#endif
|
||||
}
|
||||
@@ -123,13 +123,13 @@ void efi_save_gd(void)
|
||||
/**
|
||||
* efi_restore_gd() - restore global data register
|
||||
*
|
||||
* On the ARM architecture gd is mapped to a fixed register (r9 or x18).
|
||||
* On the ARM and RISC-V architectures gd is mapped to a fixed register.
|
||||
* Restore it after returning from the UEFI world to the value saved via
|
||||
* efi_save_gd().
|
||||
*/
|
||||
void efi_restore_gd(void)
|
||||
{
|
||||
#ifdef CONFIG_ARM
|
||||
#if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
|
||||
/* Only restore if we're already in EFI context */
|
||||
if (!efi_gd)
|
||||
return;
|
||||
@@ -2920,7 +2920,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
|
||||
* us to the current line. This implies that the second half
|
||||
* of the EFI_CALL macro has not been executed.
|
||||
*/
|
||||
#ifdef CONFIG_ARM
|
||||
#if defined(CONFIG_ARM) || defined(CONFIG_RISCV)
|
||||
/*
|
||||
* efi_exit() called efi_restore_gd(). We have to undo this
|
||||
* otherwise __efi_entry_check() will put the wrong value into
|
||||
|
||||
@@ -235,7 +235,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map,
|
||||
* @start: start address, must be a multiple of EFI_PAGE_SIZE
|
||||
* @pages: number of pages to add
|
||||
* @memory_type: type of memory added
|
||||
* @overlap_only_ram: the memory area must overlap existing
|
||||
* @overlap_only_ram: region may only overlap RAM
|
||||
* Return: status code
|
||||
*/
|
||||
static efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
|
||||
|
||||
@@ -211,7 +211,7 @@ static void efi_var_mem_bs_del(void)
|
||||
* @event: callback event
|
||||
* @context: callback context
|
||||
*/
|
||||
static void EFIAPI __efi_runtime
|
||||
static void EFIAPI
|
||||
efi_var_mem_notify_exit_boot_services(struct efi_event *event, void *context)
|
||||
{
|
||||
EFI_ENTRY("%p, %p", event, context);
|
||||
|
||||
@@ -311,11 +311,13 @@ efi_status_t EFIAPI efi_selftest(efi_handle_t image_handle,
|
||||
efi_st_printf("Preparing for reset. Press any key...\n");
|
||||
efi_st_get_key();
|
||||
|
||||
if (IS_ENABLED(CONFIG_EFI_HAVE_RUNTIME_RESET))
|
||||
if (IS_ENABLED(CONFIG_EFI_HAVE_RUNTIME_RESET)) {
|
||||
runtime->reset_system(EFI_RESET_WARM, EFI_NOT_READY,
|
||||
sizeof(reset_message), reset_message);
|
||||
else
|
||||
} else {
|
||||
efi_restore_gd();
|
||||
do_reset(NULL, 0, 0, NULL);
|
||||
}
|
||||
|
||||
efi_st_printf("\n");
|
||||
efi_st_error("Reset failed\n");
|
||||
|
||||
@@ -42,35 +42,48 @@ static uint32_t f2h(fdt32_t val)
|
||||
return *(uint32_t *)buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* Return the value of a property of the FDT root node.
|
||||
/**
|
||||
* get_property() - return value of a property of an FDT node
|
||||
*
|
||||
* @name name of the property
|
||||
* A property of the root node or one of its direct children can be
|
||||
* retrieved.
|
||||
*
|
||||
* @property name of the property
|
||||
* @node name of the node or NULL for root node
|
||||
* @return value of the property
|
||||
*/
|
||||
static char *get_property(const u16 *property)
|
||||
static char *get_property(const u16 *property, const u16 *node)
|
||||
{
|
||||
struct fdt_header *header = (struct fdt_header *)fdt;
|
||||
const fdt32_t *end;
|
||||
const fdt32_t *pos;
|
||||
const char *strings;
|
||||
size_t level = 0;
|
||||
const char *nodelabel = NULL;
|
||||
|
||||
if (!header)
|
||||
if (!header) {
|
||||
efi_st_error("Missing device tree\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (f2h(header->magic) != FDT_MAGIC) {
|
||||
printf("Wrong magic\n");
|
||||
efi_st_error("Wrong device tree magic\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pos = (fdt32_t *)(fdt + f2h(header->off_dt_struct));
|
||||
end = &pos[f2h(header->totalsize) >> 2];
|
||||
strings = fdt + f2h(header->off_dt_strings);
|
||||
|
||||
for (;;) {
|
||||
for (; pos < end;) {
|
||||
switch (f2h(pos[0])) {
|
||||
case FDT_BEGIN_NODE: {
|
||||
char *c = (char *)&pos[1];
|
||||
const char *c = (char *)&pos[1];
|
||||
size_t i;
|
||||
|
||||
if (level == 1)
|
||||
nodelabel = c;
|
||||
++level;
|
||||
for (i = 0; c[i]; ++i)
|
||||
;
|
||||
pos = &pos[2 + (i >> 2)];
|
||||
@@ -82,7 +95,10 @@ static char *get_property(const u16 *property)
|
||||
efi_status_t ret;
|
||||
|
||||
/* Check if this is the property to be returned */
|
||||
if (!efi_st_strcmp_16_8(property, label)) {
|
||||
if (!efi_st_strcmp_16_8(property, label) &&
|
||||
((level == 1 && !node) ||
|
||||
(level == 2 && node &&
|
||||
!efi_st_strcmp_16_8(node, nodelabel)))) {
|
||||
char *str;
|
||||
efi_uintn_t len = f2h(prop->len);
|
||||
|
||||
@@ -96,7 +112,7 @@ static char *get_property(const u16 *property)
|
||||
EFI_LOADER_DATA, len + 1,
|
||||
(void **)&str);
|
||||
if (ret != EFI_SUCCESS) {
|
||||
efi_st_printf("AllocatePool failed\n");
|
||||
efi_st_error("AllocatePool failed\n");
|
||||
return NULL;
|
||||
}
|
||||
boottime->copy_mem(str, &pos[3], len);
|
||||
@@ -109,12 +125,21 @@ static char *get_property(const u16 *property)
|
||||
break;
|
||||
}
|
||||
case FDT_NOP:
|
||||
pos = &pos[1];
|
||||
++pos;
|
||||
break;
|
||||
case FDT_END_NODE:
|
||||
--level;
|
||||
++pos;
|
||||
break;
|
||||
case FDT_END:
|
||||
return NULL;
|
||||
default:
|
||||
efi_st_error("Invalid device tree token\n");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
efi_st_error("Missing FDT_END token\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,7 +198,7 @@ static int execute(void)
|
||||
char *str;
|
||||
efi_status_t ret;
|
||||
|
||||
str = get_property(L"compatible");
|
||||
str = get_property(L"compatible", NULL);
|
||||
if (str) {
|
||||
efi_st_printf("compatible: %s\n", str);
|
||||
ret = boottime->free_pool(str);
|
||||
@@ -182,10 +207,10 @@ static int execute(void)
|
||||
return EFI_ST_FAILURE;
|
||||
}
|
||||
} else {
|
||||
efi_st_printf("Missing property 'compatible'\n");
|
||||
efi_st_error("Missing property 'compatible'\n");
|
||||
return EFI_ST_FAILURE;
|
||||
}
|
||||
str = get_property(L"serial-number");
|
||||
str = get_property(L"serial-number", NULL);
|
||||
if (str) {
|
||||
efi_st_printf("serial-number: %s\n", str);
|
||||
ret = boottime->free_pool(str);
|
||||
@@ -194,6 +219,21 @@ static int execute(void)
|
||||
return EFI_ST_FAILURE;
|
||||
}
|
||||
}
|
||||
str = get_property(L"boot-hartid", L"chosen");
|
||||
if (IS_ENABLED(CONFIG_RISCV)) {
|
||||
if (str) {
|
||||
efi_st_printf("boot-hartid: %u\n",
|
||||
f2h(*(fdt32_t *)str));
|
||||
ret = boottime->free_pool(str);
|
||||
if (ret != EFI_SUCCESS) {
|
||||
efi_st_error("FreePool failed\n");
|
||||
return EFI_ST_FAILURE;
|
||||
}
|
||||
} else {
|
||||
efi_st_error("boot-hartid not found\n");
|
||||
return EFI_ST_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
return EFI_ST_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -1099,7 +1099,7 @@ int fdtdec_setup_memory_banksize(void)
|
||||
if (ret < 0) {
|
||||
reg = 0;
|
||||
mem = get_next_memory_node(mem);
|
||||
if (ofnode_valid(mem))
|
||||
if (!ofnode_valid(mem))
|
||||
break;
|
||||
|
||||
ret = ofnode_read_resource(mem, reg++, &res);
|
||||
@@ -1144,7 +1144,7 @@ int fdtdec_setup_mem_size_base_lowest(void)
|
||||
if (ret < 0) {
|
||||
reg = 0;
|
||||
mem = get_next_memory_node(mem);
|
||||
if (ofnode_valid(mem))
|
||||
if (!ofnode_valid(mem))
|
||||
break;
|
||||
|
||||
ret = ofnode_read_resource(mem, reg++, &res);
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
#include <common.h>
|
||||
#include <image.h>
|
||||
#include <malloc.h>
|
||||
#include <asm/byteorder.h>
|
||||
#include <crypto/internal/rsa.h>
|
||||
#include <u-boot/rsa-mod-exp.h>
|
||||
#include <asm/unaligned.h>
|
||||
|
||||
/**
|
||||
* br_dec16be() - Convert 16-bit big-endian integer to native
|
||||
@@ -23,7 +23,7 @@
|
||||
*/
|
||||
static unsigned br_dec16be(const void *src)
|
||||
{
|
||||
return be16_to_cpup(src);
|
||||
return get_unaligned_be16(src);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,7 +33,7 @@ static unsigned br_dec16be(const void *src)
|
||||
*/
|
||||
static uint32_t br_dec32be(const void *src)
|
||||
{
|
||||
return be32_to_cpup(src);
|
||||
return get_unaligned_be32(src);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user