mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
efi_loader: execute efi_save_gd() first
If DEBUG is defined we may be calling EFI_CALL already during the initialization of the EFI subsystem. We must make sure efi_save_gd() has already been called at that moment. Anyway it is better to have this call in one location instead of three. This fixes an illegal memory access occurring since4e6b5d6503
("efi_loader: create root node") with DEBUG = 1. Fixes:4e6b5d6503
("efi_loader: create root node") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Signed-off-by: Alexander Graf <agraf@suse.de>
This commit is contained in:

committed by
Alexander Graf

parent
0801d4d2fb
commit
1e1e1c27c5
@ -40,6 +40,13 @@ efi_status_t efi_init_obj_list(void)
|
|||||||
{
|
{
|
||||||
efi_status_t ret = EFI_SUCCESS;
|
efi_status_t ret = EFI_SUCCESS;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* On the ARM architecture gd is mapped to a fixed register (r9 or x18).
|
||||||
|
* As this register may be overwritten by an EFI payload we save it here
|
||||||
|
* and restore it on every callback entered.
|
||||||
|
*/
|
||||||
|
efi_save_gd();
|
||||||
|
|
||||||
/* Initialize once only */
|
/* Initialize once only */
|
||||||
if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
|
if (efi_obj_list_initialized != OBJ_LIST_NOT_INITIALIZED)
|
||||||
return efi_obj_list_initialized;
|
return efi_obj_list_initialized;
|
||||||
@ -374,12 +381,6 @@ static efi_status_t do_bootefi_exec(void *efi,
|
|||||||
if (ret != EFI_SUCCESS)
|
if (ret != EFI_SUCCESS)
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
/*
|
|
||||||
* gd lives in a fixed register which may get clobbered while we execute
|
|
||||||
* the payload. So save it here and restore it on every callback entry
|
|
||||||
*/
|
|
||||||
efi_save_gd();
|
|
||||||
|
|
||||||
/* Transfer environment variable bootargs as load options */
|
/* Transfer environment variable bootargs as load options */
|
||||||
set_load_options(loaded_image_info, "bootargs");
|
set_load_options(loaded_image_info, "bootargs");
|
||||||
/* Load the EFI payload */
|
/* Load the EFI payload */
|
||||||
@ -460,12 +461,6 @@ static int do_bootefi_bootmgr_exec(void)
|
|||||||
void *addr;
|
void *addr;
|
||||||
efi_status_t r;
|
efi_status_t r;
|
||||||
|
|
||||||
/*
|
|
||||||
* gd lives in a fixed register which may get clobbered while we execute
|
|
||||||
* the payload. So save it here and restore it on every callback entry
|
|
||||||
*/
|
|
||||||
efi_save_gd();
|
|
||||||
|
|
||||||
addr = efi_bootmgr_load(&device_path, &file_path);
|
addr = efi_bootmgr_load(&device_path, &file_path);
|
||||||
if (!addr)
|
if (!addr)
|
||||||
return 1;
|
return 1;
|
||||||
@ -547,11 +542,6 @@ static int do_bootefi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
if (r != EFI_SUCCESS)
|
if (r != EFI_SUCCESS)
|
||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
|
|
||||||
/*
|
|
||||||
* gd lives in a fixed register which may get clobbered while we
|
|
||||||
* execute the payload. So save it here and restore it on every
|
|
||||||
* callback entry
|
|
||||||
*/
|
|
||||||
efi_save_gd();
|
efi_save_gd();
|
||||||
/* Transfer environment variable efi_selftest as load options */
|
/* Transfer environment variable efi_selftest as load options */
|
||||||
set_load_options(loaded_image_info, "efi_selftest");
|
set_load_options(loaded_image_info, "efi_selftest");
|
||||||
|
Reference in New Issue
Block a user