mirror of
https://xff.cz/git/u-boot/
synced 2025-08-31 16:22:36 +02:00
Merge tag 'efi-2020-07-rc1' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-07-rc1 This pull request * provides an implementation of UEFI secure booting * fixes a problem with the rsa_mod_exp driver which stops some boards from booting when CONFIG_RSA is enabled which is needed for UEFI secure booting * enables the EFI_RNG_PROTOCOL if DM_RNG is enabled * fixes some function comments
This commit is contained in:
@@ -1089,6 +1089,78 @@ static int do_efi_boot_opt(cmd_tbl_t *cmdtp, int flag,
|
||||
return cp->cmd(cmdtp, flag, argc, argv);
|
||||
}
|
||||
|
||||
/**
|
||||
* do_efi_test_bootmgr() - run simple bootmgr for test
|
||||
*
|
||||
* @cmdtp: Command table
|
||||
* @flag: Command flag
|
||||
* @argc: Number of arguments
|
||||
* @argv: Argument array
|
||||
* Return: CMD_RET_SUCCESS on success,
|
||||
* CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
|
||||
*
|
||||
* Implement efidebug "test bootmgr" sub-command.
|
||||
* Run simple bootmgr for test.
|
||||
*
|
||||
* efidebug test bootmgr
|
||||
*/
|
||||
static int do_efi_test_bootmgr(cmd_tbl_t *cmdtp, int flag,
|
||||
int argc, char * const argv[])
|
||||
{
|
||||
efi_handle_t image;
|
||||
efi_uintn_t exit_data_size = 0;
|
||||
u16 *exit_data = NULL;
|
||||
efi_status_t ret;
|
||||
|
||||
ret = efi_bootmgr_load(&image);
|
||||
printf("efi_bootmgr_load() returned: %ld\n", ret & ~EFI_ERROR_MASK);
|
||||
|
||||
/* We call efi_start_image() even if error for test purpose. */
|
||||
ret = EFI_CALL(efi_start_image(image, &exit_data_size, &exit_data));
|
||||
printf("efi_start_image() returned: %ld\n", ret & ~EFI_ERROR_MASK);
|
||||
if (ret && exit_data)
|
||||
efi_free_pool(exit_data);
|
||||
|
||||
efi_restore_gd();
|
||||
|
||||
return CMD_RET_SUCCESS;
|
||||
}
|
||||
|
||||
static cmd_tbl_t cmd_efidebug_test_sub[] = {
|
||||
U_BOOT_CMD_MKENT(bootmgr, CONFIG_SYS_MAXARGS, 1, do_efi_test_bootmgr,
|
||||
"", ""),
|
||||
};
|
||||
|
||||
/**
|
||||
* do_efi_test() - manage UEFI load options
|
||||
*
|
||||
* @cmdtp: Command table
|
||||
* @flag: Command flag
|
||||
* @argc: Number of arguments
|
||||
* @argv: Argument array
|
||||
* Return: CMD_RET_SUCCESS on success,
|
||||
* CMD_RET_USAGE or CMD_RET_RET_FAILURE on failure
|
||||
*
|
||||
* Implement efidebug "test" sub-command.
|
||||
*/
|
||||
static int do_efi_test(cmd_tbl_t *cmdtp, int flag,
|
||||
int argc, char * const argv[])
|
||||
{
|
||||
cmd_tbl_t *cp;
|
||||
|
||||
if (argc < 2)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
argc--; argv++;
|
||||
|
||||
cp = find_cmd_tbl(argv[0], cmd_efidebug_test_sub,
|
||||
ARRAY_SIZE(cmd_efidebug_test_sub));
|
||||
if (!cp)
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
return cp->cmd(cmdtp, flag, argc, argv);
|
||||
}
|
||||
|
||||
static cmd_tbl_t cmd_efidebug_sub[] = {
|
||||
U_BOOT_CMD_MKENT(boot, CONFIG_SYS_MAXARGS, 1, do_efi_boot_opt, "", ""),
|
||||
U_BOOT_CMD_MKENT(devices, CONFIG_SYS_MAXARGS, 1, do_efi_show_devices,
|
||||
@@ -1103,6 +1175,8 @@ static cmd_tbl_t cmd_efidebug_sub[] = {
|
||||
"", ""),
|
||||
U_BOOT_CMD_MKENT(tables, CONFIG_SYS_MAXARGS, 1, do_efi_show_tables,
|
||||
"", ""),
|
||||
U_BOOT_CMD_MKENT(test, CONFIG_SYS_MAXARGS, 1, do_efi_test,
|
||||
"", ""),
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1172,7 +1246,9 @@ static char efidebug_help_text[] =
|
||||
"efidebug memmap\n"
|
||||
" - show UEFI memory map\n"
|
||||
"efidebug tables\n"
|
||||
" - show UEFI configuration tables\n";
|
||||
" - show UEFI configuration tables\n"
|
||||
"efidebug test bootmgr\n"
|
||||
" - run simple bootmgr for test\n";
|
||||
#endif
|
||||
|
||||
U_BOOT_CMD(
|
||||
|
@@ -1417,7 +1417,7 @@ static char env_help_text[] =
|
||||
#endif
|
||||
#endif
|
||||
#if defined(CONFIG_CMD_NVEDIT_EFI)
|
||||
"env set -e [-nv][-bs][-rt][-a][-i addr,size][-v] name [arg ...]\n"
|
||||
"env set -e [-nv][-bs][-rt][-at][-a][-i addr,size][-v] name [arg ...]\n"
|
||||
" - set UEFI variable; unset if '-i' or 'arg' not specified\n"
|
||||
#endif
|
||||
"env set [-f] name [arg ...]\n";
|
||||
@@ -1479,13 +1479,14 @@ U_BOOT_CMD_COMPLETE(
|
||||
setenv, CONFIG_SYS_MAXARGS, 0, do_env_set,
|
||||
"set environment variables",
|
||||
#if defined(CONFIG_CMD_NVEDIT_EFI)
|
||||
"-e [-guid guid][-nv][-bs][-rt][-a][-v]\n"
|
||||
"-e [-guid guid][-nv][-bs][-rt][-at][-a][-v]\n"
|
||||
" [-i addr,size name], or [name [value ...]]\n"
|
||||
" - set UEFI variable 'name' to 'value' ...'\n"
|
||||
" \"-guid\": set vendor guid\n"
|
||||
" \"-nv\": set non-volatile attribute\n"
|
||||
" \"-bs\": set boot-service attribute\n"
|
||||
" \"-rt\": set runtime attribute\n"
|
||||
" \"-at\": set time-based authentication attribute\n"
|
||||
" \"-a\": append-write\n"
|
||||
" \"-i addr,size\": use <addr,size> as variable's value\n"
|
||||
" \"-v\": verbose message\n"
|
||||
|
@@ -41,6 +41,11 @@ static const struct {
|
||||
} efi_guid_text[] = {
|
||||
/* signature database */
|
||||
{EFI_GLOBAL_VARIABLE_GUID, "EFI_GLOBAL_VARIABLE_GUID"},
|
||||
{EFI_IMAGE_SECURITY_DATABASE_GUID, "EFI_IMAGE_SECURITY_DATABASE_GUID"},
|
||||
/* certificate type */
|
||||
{EFI_CERT_SHA256_GUID, "EFI_CERT_SHA256_GUID"},
|
||||
{EFI_CERT_X509_GUID, "EFI_CERT_X509_GUID"},
|
||||
{EFI_CERT_TYPE_PKCS7_GUID, "EFI_CERT_TYPE_PKCS7_GUID"},
|
||||
};
|
||||
|
||||
/* "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" */
|
||||
@@ -453,7 +458,7 @@ out:
|
||||
* Return: CMD_RET_SUCCESS on success, or CMD_RET_RET_FAILURE
|
||||
*
|
||||
* This function is for "env set -e" or "setenv -e" command:
|
||||
* => env set -e [-guid guid][-nv][-bs][-rt][-a][-v]
|
||||
* => env set -e [-guid guid][-nv][-bs][-rt][-at][-a][-v]
|
||||
* [-i address,size] var, or
|
||||
* var [value ...]
|
||||
* Encode values specified and set given UEFI variable.
|
||||
@@ -512,6 +517,9 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
attributes |= EFI_VARIABLE_RUNTIME_ACCESS;
|
||||
} else if (!strcmp(argv[0], "-nv")) {
|
||||
attributes |= EFI_VARIABLE_NON_VOLATILE;
|
||||
} else if (!strcmp(argv[0], "-at")) {
|
||||
attributes |=
|
||||
EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS;
|
||||
} else if (!strcmp(argv[0], "-a")) {
|
||||
attributes |= EFI_VARIABLE_APPEND_WRITE;
|
||||
} else if (!strcmp(argv[0], "-i")) {
|
||||
@@ -525,9 +533,9 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
if (*ep != ',')
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
/* 0 should be allowed for delete */
|
||||
size = simple_strtoul(++ep, NULL, 16);
|
||||
if (!size)
|
||||
return CMD_RET_FAILURE;
|
||||
|
||||
value_on_memory = true;
|
||||
} else if (!strcmp(argv[0], "-v")) {
|
||||
verbose = true;
|
||||
@@ -539,8 +547,13 @@ int do_env_set_efi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
||||
return CMD_RET_USAGE;
|
||||
|
||||
var_name = argv[0];
|
||||
if (default_guid)
|
||||
guid = efi_global_variable_guid;
|
||||
if (default_guid) {
|
||||
if (!strcmp(var_name, "db") || !strcmp(var_name, "dbx") ||
|
||||
!strcmp(var_name, "dbt"))
|
||||
guid = efi_guid_image_security_database;
|
||||
else
|
||||
guid = efi_global_variable_guid;
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
printf("GUID: %s\n", efi_guid_to_str((const efi_guid_t *)
|
||||
|
Reference in New Issue
Block a user