Pull request for UEFI sub-system for efi-2020-10-rc2
This series comprises error corrections for the UEFI subsystem: * make the memory size reserved for the U-Boot stack customizable and reduce it for the MAIX board * correct build dependencies for UEFI unit test * enable read-only UEFI variable are enabled with the TEE backend * add 10 ms wait to sysreset to fix a problem with unit testing -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEbcT5xx8ppvoGt20zxIHbvCwFGsQFAl8li/IACgkQxIHbvCwF GsT2Ng/+Nvi034xRczd3Y4JiDf2eAHGlgTomtgtR+zVEKGA2bs5HHuG81Zf/56oU E3HHOk14FaAxbq+L5h0d8MusShxoQYxWTytlSUpyIiYyaqUAczkUxmcfpxTF/z0B LiuUGFAZZE53dvMTlbMydModLeKYf+4E1eGj+0PLF4Pxn6in15zZhz6QOXDZwo8E Ht2gVDjB0Br9GGAvIs3joy98PK9W3Q0i36/rGQ4jkJKOpEZCJorgvDQjOGgMWiin hGzg6AqoEFFfK7KFrMRYW2yWbnd8Mlo3+WsfsyeUnq7jVbPVY1oVvJxiz7Msg2Qd wWEAGuSg+aXgJULbxKqfG55j3k32LpheaUd8VNOZKJ2eu0anmx3/S/K8qNSGFdmu 69scnf77xZSZHintjLY8SFvWAhNONCPcM3G8X/1mvn98hKIs1NBiRYD0DBSImQ76 ewl7yyLIYStayFcpMn7fi//u6dKpNETXXIoAHuyAo/ol2wGMmjohgyn12vHuP5B0 tvjzL42/6rJ1WzQEyZc50A6WoFPD4QEOq7BYznBiYdN3ACsZWiFvZGvrg6PAF1rC l20yD7Pq3uaVI4zvr9KyfOltHgn9KXiQkMz+o5BGNEp0gE67XD/vyRfspifH+8sv RARDLCiXDR0BfeNdzfXRede41wPPIP4+hNm2PX4FacptRucdPO8= =ysb+ -----END PGP SIGNATURE----- Merge tag 'efi-2020-10-rc2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi Pull request for UEFI sub-system for efi-2020-10-rc2 This series comprises error corrections for the UEFI subsystem: * make the memory size reserved for the U-Boot stack customizable and reduce it for the MAIX board * correct build dependencies for UEFI unit test * enable read-only UEFI variable are enabled with the TEE backend * add 10 ms wait to sysreset to fix a problem with unit testing
This commit is contained in:
commit
4dc3ba568f
10
Kconfig
10
Kconfig
@ -369,6 +369,16 @@ config PLATFORM_ELFENTRY
|
||||
default "__start" if MIPS
|
||||
default "_start"
|
||||
|
||||
config STACK_SIZE
|
||||
hex "Define max stack size that can be used by U-Boot"
|
||||
default 0x4000000 if ARCH_VERSAL || ARCH_ZYNQMP
|
||||
default 0x200000 if MICROBLAZE
|
||||
default 0x1000000
|
||||
help
|
||||
Define Max stack size that can be used by U-Boot. This value is used
|
||||
by the UEFI sub-system. On some boards initrd_high is calculated as
|
||||
base stack pointer minus this stack size.
|
||||
|
||||
endmenu # General setup
|
||||
|
||||
menu "Boot images"
|
||||
|
@ -503,23 +503,6 @@ config TPL_USE_ARCH_MEMSET
|
||||
Such an implementation may be faster under some conditions
|
||||
but may increase the binary size.
|
||||
|
||||
config SET_STACK_SIZE
|
||||
bool "Enable an option to set max stack size that can be used"
|
||||
default y if ARCH_VERSAL || ARCH_ZYNQMP || ARCH_ZYNQ
|
||||
help
|
||||
This will enable an option to set max stack size that can be
|
||||
used by U-Boot.
|
||||
|
||||
config STACK_SIZE
|
||||
hex "Define max stack size that can be used by U-Boot"
|
||||
depends on SET_STACK_SIZE
|
||||
default 0x4000000 if ARCH_VERSAL || ARCH_ZYNQMP
|
||||
default 0x1000000 if ARCH_ZYNQ
|
||||
help
|
||||
Define Max stack size that can be used by U-Boot so that the
|
||||
initrd_high will be calculated as base stack pointer minus this
|
||||
stack size.
|
||||
|
||||
config ARM64_SUPPORT_AARCH32
|
||||
bool "ARM64 system support AArch32 execution state"
|
||||
depends on ARM64
|
||||
|
@ -20,14 +20,6 @@ config TARGET_MICROBLAZE_GENERIC
|
||||
|
||||
endchoice
|
||||
|
||||
config STACK_SIZE
|
||||
hex "Define max stack size that can be used by u-boot"
|
||||
default 0x200000
|
||||
help
|
||||
Defines Max stack size that can be used by u-boot so that the
|
||||
initrd_high will be calculated as base stack pointer minus this
|
||||
stack size.
|
||||
|
||||
source "board/xilinx/microblaze-generic/Kconfig"
|
||||
|
||||
endmenu
|
||||
|
@ -811,7 +811,7 @@ config S3_VGA_ROM_RUN
|
||||
graphics console won't work without VGA options ROMs. Set it to N
|
||||
if your kernel is only on a serial console.
|
||||
|
||||
config STACK_SIZE
|
||||
config STACK_SIZE_RESUME
|
||||
hex
|
||||
depends on HAVE_ACPI_RESUME
|
||||
default 0x1000
|
||||
|
@ -121,7 +121,7 @@ unsigned int install_e820_map(unsigned int max_entries,
|
||||
ulong stack_size;
|
||||
|
||||
stack_size = CONFIG_IS_ENABLED(HAVE_ACPI_RESUME,
|
||||
(CONFIG_STACK_SIZE), (0));
|
||||
(CONFIG_STACK_SIZE_RESUME), (0));
|
||||
/*
|
||||
* Everything between U-Boot's stack and ram top needs to be
|
||||
* reserved in order for ACPI S3 resume to work.
|
||||
|
@ -1,6 +1,7 @@
|
||||
CONFIG_RISCV=y
|
||||
CONFIG_TARGET_SIPEED_MAIX=y
|
||||
CONFIG_ARCH_RV64I=y
|
||||
CONFIG_STACK_SIZE=0x100000
|
||||
# CONFIG_NET is not set
|
||||
# CONFIG_INPUT is not set
|
||||
# CONFIG_DM_ETH is not set
|
||||
|
@ -117,6 +117,7 @@ void reset_cpu(ulong addr)
|
||||
int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
||||
{
|
||||
printf("resetting ...\n");
|
||||
mdelay(100);
|
||||
|
||||
sysreset_walk_halt(SYSRESET_COLD);
|
||||
|
||||
|
@ -142,6 +142,22 @@ struct efi_var_file {
|
||||
*/
|
||||
efi_status_t efi_var_to_file(void);
|
||||
|
||||
/**
|
||||
* efi_var_collect() - collect variables in buffer
|
||||
*
|
||||
* A buffer is allocated and filled with variables in a format ready to be
|
||||
* written to disk.
|
||||
*
|
||||
* @bufp: pointer to pointer of buffer with collected variables
|
||||
* @lenp: pointer to length of buffer
|
||||
* @check_attr_mask: bitmask with required attributes of variables to be collected.
|
||||
* variables are only collected if all of the required
|
||||
* attributes are set.
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t __maybe_unused efi_var_collect(struct efi_var_file **bufp, loff_t *lenp,
|
||||
u32 check_attr_mask);
|
||||
|
||||
/**
|
||||
* efi_var_restore() - restore EFI variables from buffer
|
||||
*
|
||||
@ -233,4 +249,62 @@ efi_status_t efi_init_secure_state(void);
|
||||
*/
|
||||
enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid);
|
||||
|
||||
/**
|
||||
* efi_get_next_variable_name_mem() - Runtime common code across efi variable
|
||||
* implementations for GetNextVariable()
|
||||
* from the cached memory copy
|
||||
* @variable_name_size: size of variable_name buffer in byte
|
||||
* @variable_name: name of uefi variable's name in u16
|
||||
* @vendor: vendor's guid
|
||||
*
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t __efi_runtime
|
||||
efi_get_next_variable_name_mem(efi_uintn_t *variable_name_size, u16 *variable_name,
|
||||
efi_guid_t *vendor);
|
||||
/**
|
||||
* efi_get_variable_mem() - Runtime common code across efi variable
|
||||
* implementations for GetVariable() from
|
||||
* the cached memory copy
|
||||
*
|
||||
* @variable_name: name of the variable
|
||||
* @vendor: vendor GUID
|
||||
* @attributes: attributes of the variable
|
||||
* @data_size: size of the buffer to which the variable value is copied
|
||||
* @data: buffer to which the variable value is copied
|
||||
* @timep: authentication time (seconds since start of epoch)
|
||||
* Return: status code
|
||||
|
||||
*/
|
||||
efi_status_t __efi_runtime
|
||||
efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes,
|
||||
efi_uintn_t *data_size, void *data, u64 *timep);
|
||||
|
||||
/**
|
||||
* efi_get_variable_runtime() - runtime implementation of GetVariable()
|
||||
*
|
||||
* @variable_name: name of the variable
|
||||
* @guid: vendor GUID
|
||||
* @attributes: attributes of the variable
|
||||
* @data_size: size of the buffer to which the variable value is copied
|
||||
* @data: buffer to which the variable value is copied
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *guid,
|
||||
u32 *attributes, efi_uintn_t *data_size, void *data);
|
||||
|
||||
/**
|
||||
* efi_get_next_variable_name_runtime() - runtime implementation of
|
||||
* GetNextVariable()
|
||||
*
|
||||
* @variable_name_size: size of variable_name buffer in byte
|
||||
* @variable_name: name of uefi variable's name in u16
|
||||
* @guid: vendor's guid
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
|
||||
u16 *variable_name, efi_guid_t *guid);
|
||||
|
||||
#endif
|
||||
|
@ -37,11 +37,11 @@ obj-y += efi_setup.o
|
||||
obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += efi_unicode_collation.o
|
||||
obj-y += efi_var_common.o
|
||||
obj-y += efi_var_mem.o
|
||||
obj-y += efi_var_file.o
|
||||
ifeq ($(CONFIG_EFI_MM_COMM_TEE),y)
|
||||
obj-y += efi_variable_tee.o
|
||||
else
|
||||
obj-y += efi_variable.o
|
||||
obj-y += efi_var_file.o
|
||||
obj-$(CONFIG_EFI_VARIABLES_PRESEED) += efi_var_seed.o
|
||||
endif
|
||||
obj-y += efi_watchdog.o
|
||||
|
@ -762,7 +762,7 @@ static void add_u_boot_and_runtime(void)
|
||||
unsigned long runtime_start, runtime_end, runtime_pages;
|
||||
unsigned long runtime_mask = EFI_PAGE_MASK;
|
||||
unsigned long uboot_start, uboot_pages;
|
||||
unsigned long uboot_stack_size = 16 * 1024 * 1024;
|
||||
unsigned long uboot_stack_size = CONFIG_STACK_SIZE;
|
||||
|
||||
/* Add U-Boot */
|
||||
uboot_start = ((uintptr_t)map_sysmem(gd->start_addr_sp, 0) -
|
||||
|
@ -166,6 +166,28 @@ efi_status_t EFIAPI efi_query_variable_info(
|
||||
return EFI_EXIT(ret);
|
||||
}
|
||||
|
||||
efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *guid,
|
||||
u32 *attributes, efi_uintn_t *data_size, void *data)
|
||||
{
|
||||
efi_status_t ret;
|
||||
|
||||
ret = efi_get_variable_mem(variable_name, guid, attributes, data_size, data, NULL);
|
||||
|
||||
/* Remove EFI_VARIABLE_READ_ONLY flag */
|
||||
if (attributes)
|
||||
*attributes &= EFI_VARIABLE_MASK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
|
||||
u16 *variable_name, efi_guid_t *guid)
|
||||
{
|
||||
return efi_get_next_variable_name_mem(variable_name_size, variable_name, guid);
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_set_secure_state - modify secure boot state variables
|
||||
* @secure_boot: value of SecureBoot
|
||||
|
@ -46,18 +46,8 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_var_collect() - collect non-volatile variables in buffer
|
||||
*
|
||||
* A buffer is allocated and filled with all non-volatile variables in a
|
||||
* format ready to be written to disk.
|
||||
*
|
||||
* @bufp: pointer to pointer of buffer with collected variables
|
||||
* @lenp: pointer to length of buffer
|
||||
* Return: status code
|
||||
*/
|
||||
static efi_status_t __maybe_unused efi_var_collect(struct efi_var_file **bufp,
|
||||
loff_t *lenp)
|
||||
efi_status_t __maybe_unused efi_var_collect(struct efi_var_file **bufp, loff_t *lenp,
|
||||
u32 check_attr_mask)
|
||||
{
|
||||
size_t len = EFI_VAR_BUF_SIZE;
|
||||
struct efi_var_file *buf;
|
||||
@ -102,11 +92,10 @@ static efi_status_t __maybe_unused efi_var_collect(struct efi_var_file **bufp,
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
if (!(var->attr & EFI_VARIABLE_NON_VOLATILE))
|
||||
continue;
|
||||
var->length = data_length;
|
||||
var = (struct efi_var_entry *)
|
||||
ALIGN((uintptr_t)data + data_length, 8);
|
||||
if ((var->attr & check_attr_mask) == check_attr_mask) {
|
||||
var->length = data_length;
|
||||
var = (struct efi_var_entry *)ALIGN((uintptr_t)data + data_length, 8);
|
||||
}
|
||||
}
|
||||
|
||||
buf->reserved = 0;
|
||||
@ -137,7 +126,7 @@ efi_status_t efi_var_to_file(void)
|
||||
loff_t actlen;
|
||||
int r;
|
||||
|
||||
ret = efi_var_collect(&buf, &len);
|
||||
ret = efi_var_collect(&buf, &len, EFI_VARIABLE_NON_VOLATILE);
|
||||
if (ret != EFI_SUCCESS)
|
||||
goto error;
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <efi_variable.h>
|
||||
#include <u-boot/crc.h>
|
||||
|
||||
static struct efi_var_file __efi_runtime_data *efi_var_buf;
|
||||
struct efi_var_file __efi_runtime_data *efi_var_buf;
|
||||
static struct efi_var_entry __efi_runtime_data *efi_current_var;
|
||||
|
||||
/**
|
||||
@ -266,3 +266,71 @@ efi_status_t efi_var_mem_init(void)
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
efi_status_t __efi_runtime
|
||||
efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes,
|
||||
efi_uintn_t *data_size, void *data, u64 *timep)
|
||||
{
|
||||
efi_uintn_t old_size;
|
||||
struct efi_var_entry *var;
|
||||
u16 *pdata;
|
||||
|
||||
if (!variable_name || !vendor || !data_size)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
var = efi_var_mem_find(vendor, variable_name, NULL);
|
||||
if (!var)
|
||||
return EFI_NOT_FOUND;
|
||||
|
||||
if (attributes)
|
||||
*attributes = var->attr;
|
||||
if (timep)
|
||||
*timep = var->time;
|
||||
|
||||
old_size = *data_size;
|
||||
*data_size = var->length;
|
||||
if (old_size < var->length)
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
|
||||
if (!data)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
for (pdata = var->name; *pdata; ++pdata)
|
||||
;
|
||||
++pdata;
|
||||
|
||||
efi_memcpy_runtime(data, pdata, var->length);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
efi_status_t __efi_runtime
|
||||
efi_get_next_variable_name_mem(efi_uintn_t *variable_name_size, u16 *variable_name,
|
||||
efi_guid_t *vendor)
|
||||
{
|
||||
struct efi_var_entry *var;
|
||||
efi_uintn_t old_size;
|
||||
u16 *pdata;
|
||||
|
||||
if (!variable_name_size || !variable_name || !vendor)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
efi_var_mem_find(vendor, variable_name, &var);
|
||||
|
||||
if (!var)
|
||||
return EFI_NOT_FOUND;
|
||||
|
||||
for (pdata = var->name; *pdata; ++pdata)
|
||||
;
|
||||
++pdata;
|
||||
|
||||
old_size = *variable_name_size;
|
||||
*variable_name_size = (uintptr_t)pdata - (uintptr_t)var->name;
|
||||
|
||||
if (old_size < *variable_name_size)
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
|
||||
efi_memcpy_runtime(variable_name, var->name, *variable_name_size);
|
||||
efi_memcpy_runtime(vendor, &var->guid, sizeof(efi_guid_t));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
@ -282,68 +282,14 @@ efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
||||
u32 *attributes, efi_uintn_t *data_size, void *data,
|
||||
u64 *timep)
|
||||
{
|
||||
efi_uintn_t old_size;
|
||||
struct efi_var_entry *var;
|
||||
u16 *pdata;
|
||||
|
||||
if (!variable_name || !vendor || !data_size)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
var = efi_var_mem_find(vendor, variable_name, NULL);
|
||||
if (!var)
|
||||
return EFI_NOT_FOUND;
|
||||
|
||||
if (attributes)
|
||||
*attributes = var->attr;
|
||||
if (timep)
|
||||
*timep = var->time;
|
||||
|
||||
old_size = *data_size;
|
||||
*data_size = var->length;
|
||||
if (old_size < var->length)
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
|
||||
if (!data)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
for (pdata = var->name; *pdata; ++pdata)
|
||||
;
|
||||
++pdata;
|
||||
|
||||
efi_memcpy_runtime(data, pdata, var->length);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
return efi_get_variable_mem(variable_name, vendor, attributes, data_size, data, timep);
|
||||
}
|
||||
|
||||
efi_status_t __efi_runtime
|
||||
efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
|
||||
u16 *variable_name, efi_guid_t *vendor)
|
||||
{
|
||||
struct efi_var_entry *var;
|
||||
efi_uintn_t old_size;
|
||||
u16 *pdata;
|
||||
|
||||
if (!variable_name_size || !variable_name || !vendor)
|
||||
return EFI_INVALID_PARAMETER;
|
||||
|
||||
efi_var_mem_find(vendor, variable_name, &var);
|
||||
|
||||
if (!var)
|
||||
return EFI_NOT_FOUND;
|
||||
|
||||
for (pdata = var->name; *pdata; ++pdata)
|
||||
;
|
||||
++pdata;
|
||||
|
||||
old_size = *variable_name_size;
|
||||
*variable_name_size = (uintptr_t)pdata - (uintptr_t)var->name;
|
||||
|
||||
if (old_size < *variable_name_size)
|
||||
return EFI_BUFFER_TOO_SMALL;
|
||||
|
||||
efi_memcpy_runtime(variable_name, var->name, *variable_name_size);
|
||||
efi_memcpy_runtime(vendor, &var->guid, sizeof(efi_guid_t));
|
||||
|
||||
return EFI_SUCCESS;
|
||||
return efi_get_next_variable_name_mem(variable_name_size, variable_name, vendor);
|
||||
}
|
||||
|
||||
efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
|
||||
@ -504,49 +450,6 @@ efi_status_t __efi_runtime EFIAPI efi_query_variable_info_runtime(
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_get_variable_runtime() - runtime implementation of GetVariable()
|
||||
*
|
||||
* @variable_name: name of the variable
|
||||
* @vendor: vendor GUID
|
||||
* @attributes: attributes of the variable
|
||||
* @data_size: size of the buffer to which the variable value is copied
|
||||
* @data: buffer to which the variable value is copied
|
||||
* Return: status code
|
||||
*/
|
||||
static efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
|
||||
u32 *attributes, efi_uintn_t *data_size, void *data)
|
||||
{
|
||||
efi_status_t ret;
|
||||
|
||||
ret = efi_get_variable_int(variable_name, vendor, attributes,
|
||||
data_size, data, NULL);
|
||||
|
||||
/* Remove EFI_VARIABLE_READ_ONLY flag */
|
||||
if (attributes)
|
||||
*attributes &= EFI_VARIABLE_MASK;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_get_next_variable_name_runtime() - runtime implementation of
|
||||
* GetNextVariable()
|
||||
*
|
||||
* @variable_name_size: size of variable_name buffer in byte
|
||||
* @variable_name: name of uefi variable's name in u16
|
||||
* @vendor: vendor's guid
|
||||
* Return: status code
|
||||
*/
|
||||
static efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
|
||||
u16 *variable_name, efi_guid_t *vendor)
|
||||
{
|
||||
return efi_get_next_variable_name_int(variable_name_size, variable_name,
|
||||
vendor);
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_set_variable_runtime() - runtime implementation of SetVariable()
|
||||
*
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include <malloc.h>
|
||||
#include <mm_communication.h>
|
||||
|
||||
#define OPTEE_PAGE_SIZE BIT(12)
|
||||
extern struct efi_var_file __efi_runtime_data *efi_var_buf;
|
||||
static efi_uintn_t max_buffer_size; /* comm + var + func + data */
|
||||
static efi_uintn_t max_payload_size; /* func + data */
|
||||
|
||||
@ -237,8 +239,32 @@ efi_status_t EFIAPI get_max_payload(efi_uintn_t *size)
|
||||
if (ret != EFI_SUCCESS)
|
||||
goto out;
|
||||
|
||||
/* Make sure the buffer is big enough for storing variables */
|
||||
if (var_payload->size < MM_VARIABLE_ACCESS_HEADER_SIZE + 0x20) {
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
goto out;
|
||||
}
|
||||
*size = var_payload->size;
|
||||
|
||||
/*
|
||||
* Although the max payload is configurable on StMM, we only share a
|
||||
* single page from OP-TEE for the non-secure buffer used to communicate
|
||||
* with StMM. Since OP-TEE will reject to map anything bigger than that,
|
||||
* make sure we are in bounds.
|
||||
*/
|
||||
if (*size > OPTEE_PAGE_SIZE)
|
||||
*size = OPTEE_PAGE_SIZE - MM_COMMUNICATE_HEADER_SIZE -
|
||||
MM_VARIABLE_COMMUNICATE_SIZE;
|
||||
/*
|
||||
* There seems to be a bug in EDK2 miscalculating the boundaries and
|
||||
* size checks, so deduct 2 more bytes to fulfill this requirement. Fix
|
||||
* it up here to ensure backwards compatibility with older versions
|
||||
* (cf. StandaloneMmPkg/Drivers/StandaloneMmCpu/AArch64/EventHandle.c.
|
||||
* sizeof (EFI_MM_COMMUNICATE_HEADER) instead the size minus the
|
||||
* flexible array member).
|
||||
*
|
||||
* size is guaranteed to be > 2 due to checks on the beginning.
|
||||
*/
|
||||
*size -= 2;
|
||||
out:
|
||||
free(comm_buf);
|
||||
return ret;
|
||||
@ -410,7 +436,6 @@ efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
|
||||
efi_uintn_t payload_size;
|
||||
efi_uintn_t out_name_size;
|
||||
efi_uintn_t in_name_size;
|
||||
efi_uintn_t tmp_dsize;
|
||||
u8 *comm_buf = NULL;
|
||||
efi_status_t ret;
|
||||
|
||||
@ -433,13 +458,8 @@ efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
|
||||
}
|
||||
|
||||
/* Trim output buffer size */
|
||||
tmp_dsize = *variable_name_size;
|
||||
if (in_name_size + tmp_dsize >
|
||||
max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE) {
|
||||
tmp_dsize = max_payload_size -
|
||||
MM_VARIABLE_GET_NEXT_HEADER_SIZE -
|
||||
in_name_size;
|
||||
}
|
||||
if (out_name_size > max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE)
|
||||
out_name_size = max_payload_size - MM_VARIABLE_GET_NEXT_HEADER_SIZE;
|
||||
|
||||
payload_size = MM_VARIABLE_GET_NEXT_HEADER_SIZE + out_name_size;
|
||||
comm_buf = setup_mm_hdr((void **)&var_getnext, payload_size,
|
||||
@ -465,8 +485,7 @@ efi_status_t efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
|
||||
goto out;
|
||||
|
||||
guidcpy(guid, &var_getnext->guid);
|
||||
memcpy(variable_name, (u8 *)var_getnext->name,
|
||||
var_getnext->name_size);
|
||||
memcpy(variable_name, var_getnext->name, var_getnext->name_size);
|
||||
|
||||
out:
|
||||
free(comm_buf);
|
||||
@ -599,39 +618,6 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_get_variable_runtime() - runtime implementation of GetVariable()
|
||||
*
|
||||
* @variable_name: name of the variable
|
||||
* @guid: vendor GUID
|
||||
* @attributes: attributes of the variable
|
||||
* @data_size: size of the buffer to which the variable value is copied
|
||||
* @data: buffer to which the variable value is copied
|
||||
* Return: status code
|
||||
*/
|
||||
static efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_variable_runtime(u16 *variable_name, const efi_guid_t *guid,
|
||||
u32 *attributes, efi_uintn_t *data_size, void *data)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_get_next_variable_name_runtime() - runtime implementation of
|
||||
* GetNextVariable()
|
||||
*
|
||||
* @variable_name_size: size of variable_name buffer in byte
|
||||
* @variable_name: name of uefi variable's name in u16
|
||||
* @guid: vendor's guid
|
||||
* Return: status code
|
||||
*/
|
||||
static efi_status_t __efi_runtime EFIAPI
|
||||
efi_get_next_variable_name_runtime(efi_uintn_t *variable_name_size,
|
||||
u16 *variable_name, efi_guid_t *guid)
|
||||
{
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_query_variable_info() - get information about EFI variables
|
||||
*
|
||||
@ -681,8 +667,10 @@ efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *guid,
|
||||
*/
|
||||
void efi_variables_boot_exit_notify(void)
|
||||
{
|
||||
u8 *comm_buf;
|
||||
efi_status_t ret;
|
||||
u8 *comm_buf;
|
||||
loff_t len;
|
||||
struct efi_var_file *var_buf;
|
||||
|
||||
comm_buf = setup_mm_hdr(NULL, 0,
|
||||
SMM_VARIABLE_FUNCTION_EXIT_BOOT_SERVICE, &ret);
|
||||
@ -695,6 +683,18 @@ void efi_variables_boot_exit_notify(void)
|
||||
log_err("Unable to notify StMM for ExitBootServices\n");
|
||||
free(comm_buf);
|
||||
|
||||
/*
|
||||
* Populate the list for runtime variables.
|
||||
* asking EFI_VARIABLE_RUNTIME_ACCESS is redundant, since
|
||||
* efi_var_mem_notify_exit_boot_services will clean those, but that's fine
|
||||
*/
|
||||
ret = efi_var_collect(&var_buf, &len, EFI_VARIABLE_RUNTIME_ACCESS);
|
||||
if (ret != EFI_SUCCESS)
|
||||
log_err("Can't populate EFI variables. No runtime variables will be available\n");
|
||||
else
|
||||
memcpy(efi_var_buf, var_buf, len);
|
||||
free(var_buf);
|
||||
|
||||
/* Update runtime service table */
|
||||
efi_runtime_services.query_variable_info =
|
||||
efi_query_variable_info_runtime;
|
||||
@ -714,6 +714,11 @@ efi_status_t efi_init_variables(void)
|
||||
{
|
||||
efi_status_t ret;
|
||||
|
||||
/* Create a cached copy of the variables that will be enabled on ExitBootServices() */
|
||||
ret = efi_var_mem_init();
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = get_max_payload(&max_payload_size);
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
|
@ -1,6 +1,8 @@
|
||||
config CMD_BOOTEFI_SELFTEST
|
||||
bool "UEFI unit tests"
|
||||
depends on CMD_BOOTEFI
|
||||
imply PARTITIONS
|
||||
imply DOS_PARTITION
|
||||
imply FAT
|
||||
imply FAT_WRITE
|
||||
imply CMD_POWEROFF if PSCI_RESET || SYSRESET_PSCI
|
||||
|
@ -32,7 +32,6 @@ efi_selftest_memory.o \
|
||||
efi_selftest_open_protocol.o \
|
||||
efi_selftest_register_notify.o \
|
||||
efi_selftest_set_virtual_address_map.o \
|
||||
efi_selftest_snp.o \
|
||||
efi_selftest_textinput.o \
|
||||
efi_selftest_textinputex.o \
|
||||
efi_selftest_textoutput.o \
|
||||
@ -42,6 +41,8 @@ efi_selftest_variables.o \
|
||||
efi_selftest_variables_runtime.o \
|
||||
efi_selftest_watchdog.o
|
||||
|
||||
obj-$(CONFIG_NET) += efi_selftest_snp.o
|
||||
|
||||
obj-$(CONFIG_EFI_DEVICE_PATH_TO_TEXT) += efi_selftest_devicepath.o
|
||||
obj-$(CONFIG_EFI_UNICODE_COLLATION_PROTOCOL2) += \
|
||||
efi_selftest_unicode_collation.o
|
||||
@ -56,7 +57,7 @@ ifeq ($(CONFIG_GENERATE_ACPI_TABLE),)
|
||||
obj-y += efi_selftest_fdt.o
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
|
||||
ifeq ($(CONFIG_BLK)$(CONFIG_DOS_PARTITION),yy)
|
||||
obj-y += efi_selftest_block_device.o
|
||||
endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user