mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-02 09:46:37 +03:00
Merge branch 'next'
This commit is contained in:
@@ -71,10 +71,14 @@ config DYNAMIC_CRC_TABLE
|
||||
Enable this option to calculate entries for CRC tables at runtime.
|
||||
This can be helpful when reducing the size of the build image
|
||||
|
||||
config FW_LOADER
|
||||
bool "Enable firmware loader using environment script"
|
||||
config SUPPORTS_FW_LOADER
|
||||
bool
|
||||
depends on CMDLINE
|
||||
depends on ENV_SUPPORT
|
||||
|
||||
config FW_LOADER
|
||||
bool "Enable firmware loader using environment script"
|
||||
depends on SUPPORTS_FW_LOADER
|
||||
help
|
||||
Enable this option to make firmware loading using user-provided
|
||||
U-Boot environment script functionality accessible to U-Boot code.
|
||||
@@ -334,6 +338,7 @@ config SPL_ACPI
|
||||
config GENERATE_ACPI_TABLE
|
||||
bool "Generate an ACPI (Advanced Configuration and Power Interface) table"
|
||||
depends on ACPI
|
||||
select ACPIGEN if !QFW_ACPI
|
||||
select BLOBLIST
|
||||
select QFW if QEMU
|
||||
help
|
||||
|
||||
@@ -147,6 +147,7 @@ else
|
||||
obj-$(CONFIG_$(PHASE_)SPRINTF) += vsprintf.o
|
||||
endif
|
||||
obj-$(CONFIG_$(PHASE_)STRTO) += strto.o
|
||||
obj-$(CONFIG_$(PHASE_)UFS_SUPPORT) += charset.o
|
||||
else
|
||||
# Main U-Boot always uses the full printf support
|
||||
obj-y += vsprintf.o strto.o
|
||||
|
||||
@@ -15,6 +15,8 @@ config EFI_LOADER
|
||||
# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
|
||||
depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
|
||||
depends on !EFI_APP
|
||||
# The EFI specification requires 128 KiB or more of stack space
|
||||
depends on STACK_SIZE >= 0x20000
|
||||
default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
|
||||
select EFI
|
||||
select CHARSET
|
||||
@@ -112,7 +114,8 @@ menu "UEFI Variables"
|
||||
|
||||
choice
|
||||
prompt "Store for non-volatile UEFI variables"
|
||||
default EFI_VARIABLE_FILE_STORE
|
||||
default EFI_VARIABLE_FILE_STORE if FAT_WRITE
|
||||
default EFI_VARIABLE_NO_STORE
|
||||
help
|
||||
Select where non-volatile UEFI variables shall be stored.
|
||||
|
||||
@@ -123,6 +126,24 @@ config EFI_VARIABLE_FILE_STORE
|
||||
Select this option if you want non-volatile UEFI variables to be
|
||||
stored as file /ubootefi.var on the EFI system partition.
|
||||
|
||||
config EFI_VARIABLE_SF_STORE
|
||||
bool "Store non-volatile UEFI variables in SPI Flash"
|
||||
depends on SPI_FLASH
|
||||
help
|
||||
Select this option if you want non-volatile UEFI variables to be
|
||||
stored in SPI Flash.
|
||||
|
||||
Define CONFIG_EFI_VARIABLE_SF_OFFSET as offset in SPI Flash to use as
|
||||
the storage for variables. CONFIG_EFI_VAR_BUF_SIZE defines the space
|
||||
needed.
|
||||
|
||||
Note that SPI Flash devices have a limited number of program/erase
|
||||
cycles. Frequent updates to UEFI variables may cause excessive wear
|
||||
and can permanently damage the flash device, particularly on SPI NAND
|
||||
or low-end SPI NOR parts without wear leveling. This option should be
|
||||
used with care on such systems, and is not recommended for platforms
|
||||
where UEFI variables are updated frequently.
|
||||
|
||||
config EFI_MM_COMM_TEE
|
||||
bool "UEFI variables storage service via the trusted world"
|
||||
depends on OPTEE
|
||||
@@ -193,6 +214,21 @@ config FFA_SHARED_MM_BUF_ADDR
|
||||
the MM SP in secure world.
|
||||
It is assumed that the MM SP knows the address of the shared MM communication buffer.
|
||||
|
||||
config EFI_VARIABLE_SF_OFFSET
|
||||
hex "EFI variables in SPI flash offset"
|
||||
depends on EFI_VARIABLE_SF_STORE
|
||||
help
|
||||
Offset from the start of the SPI Flash where EFI variables will be stored.
|
||||
This should be aligned to the sector size of SPI Flash.
|
||||
|
||||
config EFI_VARIABLE_SF_DEVICE_INDEX
|
||||
int "Device Index for target SPI Flash"
|
||||
depends on EFI_VARIABLE_SF_STORE
|
||||
default 0
|
||||
help
|
||||
The index of SPI Flash device used for storing EFI variables. This would be
|
||||
needed if there are more than 1 SPI Flash devices available to use.
|
||||
|
||||
config EFI_VARIABLES_PRESEED
|
||||
bool "Initial values for UEFI variables"
|
||||
depends on !COMPILE_TEST
|
||||
|
||||
@@ -53,7 +53,8 @@ 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_VARIABLE_FILE_STORE) += efi_var_file.o
|
||||
obj-$(CONFIG_EFI_VARIABLE_SF_STORE) += efi_var_sf.o
|
||||
obj-$(CONFIG_EFI_VARIABLES_PRESEED) += efi_var_seed.o
|
||||
endif
|
||||
obj-y += efi_watchdog.o
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
#include <mapmem.h>
|
||||
#include <sort.h>
|
||||
#include <sysreset.h>
|
||||
#include <asm/global_data.h>
|
||||
#include <u-boot/uuid.h>
|
||||
|
||||
#include <asm/sections.h>
|
||||
@@ -29,8 +28,6 @@
|
||||
#include <crypto/pkcs7_parser.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID;
|
||||
static const efi_guid_t efi_guid_firmware_management_capsule_id =
|
||||
EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
|
||||
@@ -465,7 +462,7 @@ static __maybe_unused efi_status_t fwu_empty_capsule_process(
|
||||
log_err("Unable to set the Accept bit for the image %pUs\n",
|
||||
image_guid);
|
||||
|
||||
status = fwu_state_machine_updates(0, active_idx);
|
||||
status = fwu_state_machine_updates(FWU_BANK_ACCEPTED, active_idx);
|
||||
if (status < 0)
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
|
||||
@@ -510,7 +507,8 @@ static __maybe_unused efi_status_t fwu_post_update_process(bool fw_accept_os)
|
||||
log_err("Failed to update FWU metadata index values\n");
|
||||
} else {
|
||||
log_debug("Successfully updated the active_index\n");
|
||||
status = fwu_state_machine_updates(fw_accept_os ? 1 : 0,
|
||||
status = fwu_state_machine_updates(fw_accept_os ?
|
||||
FWU_BANK_VALID : FWU_BANK_ACCEPTED,
|
||||
update_index);
|
||||
if (status < 0)
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <efi_api.h>
|
||||
#include <malloc.h>
|
||||
|
||||
static const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
|
||||
const efi_guid_t efi_ecpt_guid = EFI_CONFORMANCE_PROFILES_TABLE_GUID;
|
||||
|
||||
/**
|
||||
* efi_ecpt_register() - Install the ECPT system table.
|
||||
|
||||
@@ -475,9 +475,12 @@ static efi_status_t efi_disk_add_dev(
|
||||
#if CONFIG_IS_ENABLED(DOS_PARTITION)
|
||||
case PART_TYPE_DOS:
|
||||
info->type = PARTITION_TYPE_MBR;
|
||||
|
||||
/* TODO: implement support for MBR partition types */
|
||||
log_debug("EFI_PARTITION_INFO_PROTOCOL doesn't support MBR\n");
|
||||
ret = part_get_mbr(desc, part, &info->info.mbr);
|
||||
if (ret) {
|
||||
log_debug("get MBR for part %d failed %ld\n",
|
||||
part, ret);
|
||||
goto error;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
|
||||
@@ -13,9 +13,6 @@
|
||||
#include <malloc.h>
|
||||
#include <mapmem.h>
|
||||
#include <video.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
static const efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
|
||||
|
||||
|
||||
@@ -10,9 +10,6 @@
|
||||
#include <efi_rng.h>
|
||||
#include <log.h>
|
||||
#include <rng.h>
|
||||
#include <asm/global_data.h>
|
||||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
const efi_guid_t efi_guid_rng_protocol = EFI_RNG_PROTOCOL_GUID;
|
||||
|
||||
|
||||
@@ -209,6 +209,30 @@ void __efi_runtime efi_memcpy_runtime(void *dest, const void *src, size_t n)
|
||||
*d++ = *s++;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_memcmp_runtime() - compare memory areas
|
||||
*
|
||||
* At runtime memcmp() is not available.
|
||||
*
|
||||
* @s1: first memory area
|
||||
* @s2: second memory area
|
||||
* @n: number of bytes to compare
|
||||
* Return: 0 if equal, negative if s1 < s2, positive if s1 > s2
|
||||
*/
|
||||
int __efi_runtime efi_memcmp_runtime(const void *s1, const void *s2, size_t n)
|
||||
{
|
||||
const u8 *pos1 = s1;
|
||||
const u8 *pos2 = s2;
|
||||
|
||||
for (; n; --n) {
|
||||
if (*pos1 != *pos2)
|
||||
return *pos1 - *pos2;
|
||||
++pos1;
|
||||
++pos2;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_update_table_header_crc32() - Update crc32 in table header
|
||||
*
|
||||
|
||||
@@ -41,6 +41,7 @@ static const struct efi_auth_var_name_type name_type[] = {
|
||||
|
||||
static bool efi_secure_boot;
|
||||
static enum efi_secure_mode efi_secure_mode;
|
||||
static const efi_guid_t shim_lock_guid = SHIM_LOCK_GUID;
|
||||
|
||||
/**
|
||||
* efi_efi_get_variable() - retrieve value of a UEFI variable
|
||||
@@ -488,3 +489,46 @@ efi_status_t __maybe_unused efi_var_collect(struct efi_var_file **bufp, loff_t *
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
efi_status_t efi_var_restore(struct efi_var_file *buf, bool safe)
|
||||
{
|
||||
struct efi_var_entry *var, *last_var;
|
||||
u16 *data;
|
||||
efi_status_t ret;
|
||||
|
||||
if (buf->reserved || buf->magic != EFI_VAR_FILE_MAGIC ||
|
||||
buf->length > EFI_VAR_BUF_SIZE ||
|
||||
buf->length < sizeof(struct efi_var_file) ||
|
||||
buf->crc32 != crc32(0, (u8 *)buf->var,
|
||||
buf->length - sizeof(struct efi_var_file))) {
|
||||
log_err("Invalid EFI variables file\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
last_var = (struct efi_var_entry *)((u8 *)buf + buf->length);
|
||||
for (var = buf->var; var < last_var;
|
||||
var = (struct efi_var_entry *)ALIGN((uintptr_t)data + var->length, 8)) {
|
||||
data = var->name + u16_strlen(var->name) + 1;
|
||||
|
||||
/*
|
||||
* Secure boot related and volatile variables shall only be
|
||||
* restored from U-Boot's preseed.
|
||||
*/
|
||||
if (!safe &&
|
||||
(efi_auth_var_get_type(var->name, &var->guid) !=
|
||||
EFI_AUTH_VAR_NONE ||
|
||||
!guidcmp(&var->guid, &shim_lock_guid) ||
|
||||
!(var->attr & EFI_VARIABLE_NON_VOLATILE)))
|
||||
continue;
|
||||
if (!var->length)
|
||||
continue;
|
||||
if (efi_var_mem_find(&var->guid, var->name, NULL))
|
||||
continue;
|
||||
ret = efi_var_mem_ins(var->name, &var->guid, var->attr,
|
||||
var->length, data, 0, NULL,
|
||||
var->time, NULL);
|
||||
if (ret != EFI_SUCCESS)
|
||||
log_err("Failed to set EFI variable %ls\n", var->name);
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -14,17 +14,9 @@
|
||||
#include <mapmem.h>
|
||||
#include <efi_loader.h>
|
||||
#include <efi_variable.h>
|
||||
#include <u-boot/crc.h>
|
||||
|
||||
#define PART_STR_LEN 10
|
||||
|
||||
/* GUID used by Shim to store the MOK database */
|
||||
#define SHIM_LOCK_GUID \
|
||||
EFI_GUID(0x605dab50, 0xe046, 0x4300, \
|
||||
0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23)
|
||||
|
||||
static const efi_guid_t shim_lock_guid = SHIM_LOCK_GUID;
|
||||
|
||||
/**
|
||||
* efi_set_blk_dev_to_system_partition() - select EFI system partition
|
||||
*
|
||||
@@ -51,15 +43,14 @@ static efi_status_t __maybe_unused efi_set_blk_dev_to_system_partition(void)
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_var_to_file() - save non-volatile variables as file
|
||||
* efi_var_to_storage() - save non-volatile variables as file
|
||||
*
|
||||
* File ubootefi.var is created on the EFI system partion.
|
||||
*
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t efi_var_to_file(void)
|
||||
efi_status_t efi_var_to_storage(void)
|
||||
{
|
||||
#ifdef CONFIG_EFI_VARIABLE_FILE_STORE
|
||||
efi_status_t ret;
|
||||
struct efi_var_file *buf;
|
||||
loff_t len;
|
||||
@@ -91,56 +82,10 @@ error:
|
||||
out:
|
||||
free(buf);
|
||||
return ret;
|
||||
#else
|
||||
return EFI_SUCCESS;
|
||||
#endif
|
||||
}
|
||||
|
||||
efi_status_t efi_var_restore(struct efi_var_file *buf, bool safe)
|
||||
{
|
||||
struct efi_var_entry *var, *last_var;
|
||||
u16 *data;
|
||||
efi_status_t ret;
|
||||
|
||||
if (buf->reserved || buf->magic != EFI_VAR_FILE_MAGIC ||
|
||||
buf->crc32 != crc32(0, (u8 *)buf->var,
|
||||
buf->length - sizeof(struct efi_var_file))) {
|
||||
log_err("Invalid EFI variables file\n");
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
last_var = (struct efi_var_entry *)((u8 *)buf + buf->length);
|
||||
for (var = buf->var; var < last_var;
|
||||
var = (struct efi_var_entry *)
|
||||
ALIGN((uintptr_t)data + var->length, 8)) {
|
||||
|
||||
data = var->name + u16_strlen(var->name) + 1;
|
||||
|
||||
/*
|
||||
* Secure boot related and volatile variables shall only be
|
||||
* restored from U-Boot's preseed.
|
||||
*/
|
||||
if (!safe &&
|
||||
(efi_auth_var_get_type(var->name, &var->guid) !=
|
||||
EFI_AUTH_VAR_NONE ||
|
||||
!guidcmp(&var->guid, &shim_lock_guid) ||
|
||||
!(var->attr & EFI_VARIABLE_NON_VOLATILE)))
|
||||
continue;
|
||||
if (!var->length)
|
||||
continue;
|
||||
if (efi_var_mem_find(&var->guid, var->name, NULL))
|
||||
continue;
|
||||
ret = efi_var_mem_ins(var->name, &var->guid, var->attr,
|
||||
var->length, data, 0, NULL,
|
||||
var->time);
|
||||
if (ret != EFI_SUCCESS)
|
||||
log_err("Failed to set EFI variable %ls\n", var->name);
|
||||
}
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_var_from_file() - read variables from file
|
||||
* efi_var_from_storage() - read variables from file
|
||||
*
|
||||
* File ubootefi.var is read from the EFI system partitions and the variables
|
||||
* stored in the file are created.
|
||||
@@ -153,9 +98,8 @@ efi_status_t efi_var_restore(struct efi_var_file *buf, bool safe)
|
||||
*
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t efi_var_from_file(void)
|
||||
efi_status_t efi_var_from_storage(void)
|
||||
{
|
||||
#ifdef CONFIG_EFI_VARIABLE_FILE_STORE
|
||||
struct efi_var_file *buf;
|
||||
loff_t len;
|
||||
efi_status_t ret;
|
||||
@@ -180,6 +124,5 @@ efi_status_t efi_var_from_file(void)
|
||||
log_err("Invalid EFI variables file\n");
|
||||
error:
|
||||
free(buf);
|
||||
#endif
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -159,12 +159,39 @@ efi_status_t __efi_runtime efi_var_mem_ins(
|
||||
const efi_guid_t *vendor, u32 attributes,
|
||||
const efi_uintn_t size1, const void *data1,
|
||||
const efi_uintn_t size2, const void *data2,
|
||||
const u64 time)
|
||||
const u64 time, bool *changep)
|
||||
{
|
||||
u16 *data;
|
||||
struct efi_var_entry *var;
|
||||
u32 var_name_len;
|
||||
|
||||
if (changep)
|
||||
*changep = true;
|
||||
|
||||
/*
|
||||
* If this is not an append (size2 == 0), check whether the variable
|
||||
* already exists with identical attributes and data. When nothing
|
||||
* changed we can skip the write and avoid superfluous erases.
|
||||
*/
|
||||
if (!size2 && changep) {
|
||||
struct efi_var_entry *old;
|
||||
|
||||
old = efi_var_mem_find(vendor, variable_name, NULL);
|
||||
if (old && old->attr == attributes &&
|
||||
old->length == size1 && old->time == time) {
|
||||
u16 *old_data;
|
||||
|
||||
for (old_data = old->name; *old_data; ++old_data)
|
||||
;
|
||||
++old_data;
|
||||
|
||||
if (!efi_memcmp_runtime(old_data, data1, size1)) {
|
||||
*changep = false;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var = (struct efi_var_entry *)
|
||||
((uintptr_t)efi_var_buf + efi_var_buf->length);
|
||||
var_name_len = u16_strlen(variable_name) + 1;
|
||||
|
||||
111
lib/efi_loader/efi_var_sf.c
Normal file
111
lib/efi_loader/efi_var_sf.c
Normal file
@@ -0,0 +1,111 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
/*
|
||||
* SPI Flash interface for UEFI variables
|
||||
*
|
||||
* Copyright (c) 2023, Shantur Rathore
|
||||
* Copyright (C) 2026, Advanced Micro Devices, Inc.
|
||||
*/
|
||||
|
||||
#define LOG_CATEGORY LOGC_EFI
|
||||
|
||||
#include <efi_loader.h>
|
||||
#include <efi_variable.h>
|
||||
#include <spi_flash.h>
|
||||
#include <dm.h>
|
||||
|
||||
efi_status_t efi_var_to_storage(void)
|
||||
{
|
||||
struct efi_var_file *buf;
|
||||
struct spi_flash *flash;
|
||||
struct udevice *sfdev;
|
||||
efi_status_t ret;
|
||||
size_t erase_len;
|
||||
loff_t len;
|
||||
int r;
|
||||
|
||||
ret = efi_var_collect(&buf, &len, EFI_VARIABLE_NON_VOLATILE);
|
||||
if (ret != EFI_SUCCESS)
|
||||
goto error;
|
||||
|
||||
if (len > EFI_VAR_BUF_SIZE) {
|
||||
log_debug("EFI var buffer length more than target SPI Flash size\n");
|
||||
ret = EFI_OUT_OF_RESOURCES;
|
||||
goto error;
|
||||
}
|
||||
|
||||
log_debug("Got buffer to write buf->len: %d\n", buf->length);
|
||||
|
||||
r = uclass_get_device(UCLASS_SPI_FLASH,
|
||||
CONFIG_EFI_VARIABLE_SF_DEVICE_INDEX, &sfdev);
|
||||
if (r) {
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
flash = dev_get_uclass_priv(sfdev);
|
||||
if (!flash) {
|
||||
log_debug("Failed to get SPI Flash priv data\n");
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
goto error;
|
||||
}
|
||||
erase_len = ALIGN(len, flash->sector_size);
|
||||
|
||||
r = spi_flash_erase_dm(sfdev, CONFIG_EFI_VARIABLE_SF_OFFSET,
|
||||
erase_len);
|
||||
if (r) {
|
||||
log_debug("Failed to erase SPI Flash\n");
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
r = spi_flash_write_dm(sfdev, CONFIG_EFI_VARIABLE_SF_OFFSET, len, buf);
|
||||
if (r) {
|
||||
log_debug("Failed to write to SPI Flash: %d\n", r);
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
error:
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
efi_status_t efi_var_from_storage(void)
|
||||
{
|
||||
struct efi_var_file *buf;
|
||||
struct udevice *sfdev;
|
||||
efi_status_t ret;
|
||||
int r;
|
||||
|
||||
buf = calloc(1, EFI_VAR_BUF_SIZE);
|
||||
if (!buf) {
|
||||
log_err("Unable to allocate buffer\n");
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
r = uclass_get_device(UCLASS_SPI_FLASH,
|
||||
CONFIG_EFI_VARIABLE_SF_DEVICE_INDEX, &sfdev);
|
||||
if (r) {
|
||||
log_err("Failed to get SPI Flash device: %d\n", r);
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
r = spi_flash_read_dm(sfdev, CONFIG_EFI_VARIABLE_SF_OFFSET,
|
||||
EFI_VAR_BUF_SIZE, buf);
|
||||
if (r) {
|
||||
log_err("Failed to read from SPI Flash: %d\n", r);
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (efi_var_restore(buf, false) != EFI_SUCCESS) {
|
||||
log_err("No valid EFI variables in SPI Flash\n");
|
||||
ret = EFI_DEVICE_ERROR;
|
||||
goto error;
|
||||
}
|
||||
|
||||
ret = EFI_SUCCESS;
|
||||
error:
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
@@ -277,6 +277,7 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
|
||||
struct efi_var_entry *var;
|
||||
efi_uintn_t ret;
|
||||
bool append, delete;
|
||||
bool changed = false;
|
||||
u64 time = 0;
|
||||
enum efi_auth_var_type var_type;
|
||||
|
||||
@@ -366,6 +367,7 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
|
||||
if (delete) {
|
||||
/* EFI_NOT_FOUND has been handled before */
|
||||
attributes = var->attr;
|
||||
changed = true;
|
||||
ret = EFI_SUCCESS;
|
||||
} else if (append && var) {
|
||||
/*
|
||||
@@ -380,15 +382,19 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
|
||||
ret = efi_var_mem_ins(variable_name, vendor,
|
||||
attributes & ~EFI_VARIABLE_APPEND_WRITE,
|
||||
var->length, old_data, data_size, data,
|
||||
time);
|
||||
time, &changed);
|
||||
} else {
|
||||
ret = efi_var_mem_ins(variable_name, vendor, attributes,
|
||||
data_size, data, 0, NULL, time);
|
||||
data_size, data, 0, NULL, time,
|
||||
&changed);
|
||||
}
|
||||
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
|
||||
if (!changed)
|
||||
return EFI_SUCCESS;
|
||||
|
||||
efi_var_mem_del(var);
|
||||
|
||||
if (var_type == EFI_AUTH_VAR_PK)
|
||||
@@ -396,12 +402,13 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
|
||||
else
|
||||
ret = EFI_SUCCESS;
|
||||
|
||||
/*
|
||||
* Write non-volatile EFI variables to file
|
||||
* TODO: check if a value change has occured to avoid superfluous writes
|
||||
*/
|
||||
if (attributes & EFI_VARIABLE_NON_VOLATILE)
|
||||
efi_var_to_file();
|
||||
/* Write non-volatile EFI variables to storage */
|
||||
if (attributes & EFI_VARIABLE_NON_VOLATILE) {
|
||||
if (IS_ENABLED(CONFIG_EFI_VARIABLE_NO_STORE))
|
||||
return EFI_SUCCESS;
|
||||
|
||||
efi_var_to_storage();
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -494,6 +501,7 @@ efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
|
||||
struct efi_var_entry *var;
|
||||
efi_uintn_t ret;
|
||||
bool append, delete;
|
||||
bool changed = false;
|
||||
u64 time = 0;
|
||||
|
||||
if (!IS_ENABLED(CONFIG_EFI_RT_VOLATILE_STORE))
|
||||
@@ -545,6 +553,7 @@ efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
|
||||
if (delete) {
|
||||
/* EFI_NOT_FOUND has been handled before */
|
||||
attributes = var->attr;
|
||||
changed = true;
|
||||
ret = EFI_SUCCESS;
|
||||
} else if (append && var) {
|
||||
u16 *old_data = (void *)((uintptr_t)var->name +
|
||||
@@ -552,15 +561,19 @@ efi_set_variable_runtime(u16 *variable_name, const efi_guid_t *vendor,
|
||||
|
||||
ret = efi_var_mem_ins(variable_name, vendor, attributes,
|
||||
var->length, old_data, data_size, data,
|
||||
time);
|
||||
time, &changed);
|
||||
} else {
|
||||
ret = efi_var_mem_ins(variable_name, vendor, attributes,
|
||||
data_size, data, 0, NULL, time);
|
||||
data_size, data, 0, NULL, time,
|
||||
&changed);
|
||||
}
|
||||
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
/* We are always inserting new variables, get rid of the old copy */
|
||||
|
||||
if (!changed)
|
||||
return EFI_SUCCESS;
|
||||
|
||||
efi_var_mem_del(var);
|
||||
|
||||
return EFI_SUCCESS;
|
||||
@@ -594,9 +607,12 @@ efi_status_t efi_init_variables(void)
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
|
||||
ret = efi_var_from_file();
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
if (!IS_ENABLED(CONFIG_EFI_VARIABLE_NO_STORE)) {
|
||||
ret = efi_var_from_storage();
|
||||
if (ret != EFI_SUCCESS)
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (IS_ENABLED(CONFIG_EFI_VARIABLES_PRESEED)) {
|
||||
ret = efi_var_restore((struct efi_var_file *)
|
||||
__efi_var_file_begin, true);
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "efi_selftest_disk_image.h"
|
||||
#include <asm/cache.h>
|
||||
#include <part_efi.h>
|
||||
#include <part.h>
|
||||
|
||||
/* Block size of compressed disk image */
|
||||
#define COMPRESSED_DISK_IMAGE_BLOCK_SIZE 8
|
||||
@@ -319,6 +320,25 @@ static int execute(void)
|
||||
u64 pos;
|
||||
char block_io_aligned[1 << LB_BLOCK_SIZE] __aligned(1 << LB_BLOCK_SIZE);
|
||||
|
||||
/*
|
||||
* The test disk image is defined in efi_selftest_disk_image.h,
|
||||
* it contains a single FAT12 partition of 127 sectors size.
|
||||
*/
|
||||
static const dos_partition_t mbr_expected = {
|
||||
.boot_ind = 0x00,
|
||||
.head = 0x00,
|
||||
.sector = 0x02,
|
||||
.cyl = 0x00,
|
||||
.sys_ind = 0x01, /* FAT12 */
|
||||
.end_head = 0x02,
|
||||
.end_sector = 0x02,
|
||||
.end_cyl = 0x00,
|
||||
/* LBA 1 */
|
||||
.start_sect = cpu_to_le32(1),
|
||||
/* Size 127 sectors (0x7f) */
|
||||
.nr_sects = cpu_to_le32(127),
|
||||
};
|
||||
|
||||
/* Connect controller to virtual disk */
|
||||
ret = boottime->connect_controller(disk_handle, NULL, NULL, 1);
|
||||
if (ret != EFI_SUCCESS) {
|
||||
@@ -405,6 +425,12 @@ static int execute(void)
|
||||
return EFI_ST_FAILURE;
|
||||
}
|
||||
|
||||
/* Compare the obtained MBR with the expected one for the test partition */
|
||||
if (memcmp(&part_info->info.mbr, &mbr_expected, sizeof(mbr_expected))) {
|
||||
efi_st_error("MBR partition record mismatch\n");
|
||||
return EFI_ST_FAILURE;
|
||||
}
|
||||
|
||||
/* Open the simple file system protocol */
|
||||
ret = boottime->open_protocol(handle_partition,
|
||||
&guid_simple_file_system_protocol,
|
||||
|
||||
16
lib/fdtdec.c
16
lib/fdtdec.c
@@ -1077,13 +1077,12 @@ int fdtdec_setup_mem_size_base(void)
|
||||
|
||||
gd->ram_size = (phys_size_t)(res.end - res.start + 1);
|
||||
gd->ram_base = (unsigned long)res.start;
|
||||
debug("%s: Initial DRAM size %llx\n", __func__,
|
||||
(unsigned long long)gd->ram_size);
|
||||
debug("%s: Initial DRAM size %pap\n", __func__, &gd->ram_size);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
ofnode get_next_memory_node(ofnode mem)
|
||||
static ofnode get_next_memory_node(ofnode mem)
|
||||
{
|
||||
do {
|
||||
mem = ofnode_by_prop_value(mem, "device_type", "memory", 7);
|
||||
@@ -1092,6 +1091,11 @@ ofnode get_next_memory_node(ofnode mem)
|
||||
return mem;
|
||||
}
|
||||
|
||||
ofnode fdtdec_get_next_memory_node(ofnode mem)
|
||||
{
|
||||
return get_next_memory_node(mem);
|
||||
}
|
||||
|
||||
int fdtdec_setup_memory_banksize(void)
|
||||
{
|
||||
int bank, ret, reg = 0;
|
||||
@@ -1124,10 +1128,10 @@ int fdtdec_setup_memory_banksize(void)
|
||||
gd->bd->bi_dram[bank].size =
|
||||
(phys_size_t)(res.end - res.start + 1);
|
||||
|
||||
debug("%s: DRAM Bank #%d: start = 0x%llx, size = 0x%llx\n",
|
||||
debug("%s: DRAM Bank #%d: start = %pap, size = %pap\n",
|
||||
__func__, bank,
|
||||
(unsigned long long)gd->bd->bi_dram[bank].start,
|
||||
(unsigned long long)gd->bd->bi_dram[bank].size);
|
||||
&gd->bd->bi_dram[bank].start,
|
||||
&gd->bd->bi_dram[bank].size);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
menuconfig FWU_MULTI_BANK_UPDATE
|
||||
bool "Enable FWU Multi Bank Update Feature"
|
||||
depends on EFI_CAPSULE_ON_DISK
|
||||
select EFI_PARTITION
|
||||
select PARTITION_TYPE_GUID
|
||||
select FWU_MDATA
|
||||
imply EFI_CAPSULE_ON_DISK_EARLY
|
||||
|
||||
@@ -766,6 +766,12 @@ static int fwu_boottime_checks(void)
|
||||
if (boot_idx != active_idx) {
|
||||
log_info("Boot idx %u is not matching active idx %u, changing active_idx\n",
|
||||
boot_idx, active_idx);
|
||||
|
||||
ret = fwu_state_machine_updates(FWU_BANK_INVALID, active_idx);
|
||||
if (ret)
|
||||
log_err("Unable to set bank %u state as invalid",
|
||||
active_idx);
|
||||
|
||||
ret = fwu_set_active_index(boot_idx);
|
||||
if (!ret)
|
||||
boottime_check = 1;
|
||||
|
||||
@@ -98,27 +98,27 @@ void fwu_populate_mdata_image_info(struct fwu_data *data)
|
||||
|
||||
/**
|
||||
* fwu_state_machine_updates() - Update FWU state of the platform
|
||||
* @trial_state: Is platform transitioning into Trial State
|
||||
* @state: FWU bank state
|
||||
* @update_index: Bank number to which images have been updated
|
||||
*
|
||||
* On successful completion of updates, transition the platform to
|
||||
* either Trial State or Regular State.
|
||||
* FWU_BANK_VALID transition the platform to Trial state
|
||||
* FWU_BANK_ACCEPTED accept the FWU bank state
|
||||
* FWU_BANK_INVALID invalid the FWU bank state
|
||||
*
|
||||
* To transition the platform to Trial State, start the
|
||||
* TrialStateCtr counter, followed by setting the value of bank_state
|
||||
* field of the metadata to Valid state(applicable only in version 2
|
||||
* of metadata).
|
||||
*
|
||||
* In case, the platform is to transition directly to Regular State,
|
||||
* update the bank_state field of the metadata to Accepted
|
||||
* state(applicable only in version 2 of metadata).
|
||||
* Saving the bank_state field of the metadata is only applicable in
|
||||
* version 2 of metadata.
|
||||
*
|
||||
* Return: 0 if OK, -ve on error
|
||||
*/
|
||||
int fwu_state_machine_updates(bool trial_state,
|
||||
int fwu_state_machine_updates(enum fwu_bank_states state,
|
||||
uint32_t update_index)
|
||||
{
|
||||
return fwu_trial_state_update(trial_state, update_index);
|
||||
return fwu_trial_state_update(state == FWU_BANK_VALID, update_index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -80,42 +80,27 @@ static int fwu_mdata_sanity_checks(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fwu_bank_state_update(bool trial_state, uint32_t bank)
|
||||
static int fwu_bank_state_update(enum fwu_bank_states state, uint32_t bank)
|
||||
{
|
||||
int ret;
|
||||
struct fwu_data *data = fwu_get_data();
|
||||
struct fwu_mdata *mdata = data->fwu_mdata;
|
||||
|
||||
if (!trial_state && !fwu_bank_accepted(data, bank))
|
||||
if (state == FWU_BANK_ACCEPTED && !fwu_bank_accepted(data, bank))
|
||||
return 0;
|
||||
|
||||
mdata->bank_state[bank] = data->bank_state[bank] = trial_state ?
|
||||
FWU_BANK_VALID : FWU_BANK_ACCEPTED;
|
||||
mdata->bank_state[bank] = (uint8_t)state;
|
||||
data->bank_state[bank] = (uint8_t)state;
|
||||
|
||||
ret = fwu_sync_mdata(mdata, BOTH_PARTS);
|
||||
if (ret)
|
||||
log_err("Unable to set bank_state for bank %u\n", bank);
|
||||
else
|
||||
data->trial_state = trial_state;
|
||||
data->trial_state = state == FWU_BANK_VALID ? 1 : 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int fwu_trial_state_start(uint update_index)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = fwu_trial_state_ctr_start();
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = fwu_bank_state_update(1, update_index);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool fwu_get_mdata_mandatory(uint part)
|
||||
{
|
||||
int ret = 0;
|
||||
@@ -171,27 +156,34 @@ void fwu_populate_mdata_image_info(struct fwu_data *data)
|
||||
|
||||
/**
|
||||
* fwu_state_machine_updates() - Update FWU state of the platform
|
||||
* @trial_state: Is platform transitioning into Trial State
|
||||
* @state: FWU bank state
|
||||
* @update_index: Bank number to which images have been updated
|
||||
*
|
||||
* On successful completion of updates, transition the platform to
|
||||
* either Trial State or Regular State.
|
||||
* FWU_BANK_VALID transition the platform to Trial state
|
||||
* FWU_BANK_ACCEPTED accept the FWU bank state
|
||||
* FWU_BANK_INVALID invalid the FWU bank state
|
||||
*
|
||||
* To transition the platform to Trial State, start the
|
||||
* TrialStateCtr counter, followed by setting the value of bank_state
|
||||
* field of the metadata to Valid state(applicable only in version 2
|
||||
* of metadata).
|
||||
*
|
||||
* In case, the platform is to transition directly to Regular State,
|
||||
* update the bank_state field of the metadata to Accepted
|
||||
* state(applicable only in version 2 of metadata).
|
||||
* Saving the bank_state field of the metadata is only applicable in
|
||||
* version 2 of metadata.
|
||||
*
|
||||
* Return: 0 if OK, -ve on error
|
||||
*/
|
||||
int fwu_state_machine_updates(bool trial_state, uint32_t update_index)
|
||||
int fwu_state_machine_updates(enum fwu_bank_states state, uint32_t update_index)
|
||||
{
|
||||
return trial_state ? fwu_trial_state_start(update_index) :
|
||||
fwu_bank_state_update(0, update_index);
|
||||
int ret;
|
||||
|
||||
if (state == FWU_BANK_VALID) {
|
||||
ret = fwu_trial_state_ctr_start();
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
return fwu_bank_state_update(state, update_index);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,6 +32,9 @@ struct kmem_cache *get_mem(int element_sz)
|
||||
struct kmem_cache *ret;
|
||||
|
||||
ret = memalign(ARCH_DMA_MINALIGN, sizeof(struct kmem_cache));
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
ret->sz = element_sz;
|
||||
|
||||
return ret;
|
||||
|
||||
17
lib/lmb.c
17
lib/lmb.c
@@ -611,7 +611,6 @@ static __maybe_unused void lmb_reserve_common_spl(void)
|
||||
static void lmb_add_memory(void)
|
||||
{
|
||||
int i;
|
||||
phys_addr_t bank_end;
|
||||
phys_size_t size;
|
||||
u64 ram_top = gd->ram_top;
|
||||
struct bd_info *bd = gd->bd;
|
||||
@@ -625,23 +624,9 @@ static void lmb_add_memory(void)
|
||||
|
||||
for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) {
|
||||
size = bd->bi_dram[i].size;
|
||||
bank_end = bd->bi_dram[i].start + size;
|
||||
|
||||
if (size) {
|
||||
if (size)
|
||||
lmb_add(bd->bi_dram[i].start, size);
|
||||
|
||||
/*
|
||||
* Reserve memory above ram_top as
|
||||
* no-overwrite so that it cannot be
|
||||
* allocated
|
||||
*/
|
||||
if (bd->bi_dram[i].start >= ram_top)
|
||||
lmb_reserve(bd->bi_dram[i].start, size,
|
||||
LMB_NOOVERWRITE);
|
||||
else if (bank_end > ram_top)
|
||||
lmb_reserve(ram_top, bank_end - ram_top,
|
||||
LMB_NOOVERWRITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,21 @@
|
||||
#define MEM_ALIGNMENT 8
|
||||
|
||||
#define MEMP_NUM_TCP_SEG 16
|
||||
|
||||
/* IP fragmentation parameters for TFTP reassembly */
|
||||
#define IP_FRAG_MTU_USABLE 1480
|
||||
#define PBUF_POOL_HEADROOM 6
|
||||
#define PBUF_POOL_RESERVE 4
|
||||
#define TFTP_BLOCKSIZE_THRESHOLD 4096
|
||||
|
||||
#if defined(CONFIG_TFTP_BLOCKSIZE) && (CONFIG_TFTP_BLOCKSIZE > TFTP_BLOCKSIZE_THRESHOLD)
|
||||
#define PBUF_POOL_SIZE (((CONFIG_TFTP_BLOCKSIZE + (IP_FRAG_MTU_USABLE - 1)) / \
|
||||
IP_FRAG_MTU_USABLE) + PBUF_POOL_HEADROOM)
|
||||
#define IP_REASS_MAX_PBUFS (PBUF_POOL_SIZE - PBUF_POOL_RESERVE)
|
||||
#else
|
||||
#define PBUF_POOL_SIZE 8
|
||||
#define IP_REASS_MAX_PBUFS 4
|
||||
#endif
|
||||
|
||||
#define LWIP_ARP 1
|
||||
#define ARP_TABLE_SIZE 4
|
||||
@@ -76,7 +90,7 @@
|
||||
#define IP_REASSEMBLY 1
|
||||
#define IP_FRAG 1
|
||||
#define IP_REASS_MAXAGE 3
|
||||
#define IP_REASS_MAX_PBUFS 4
|
||||
|
||||
#define IP_FRAG_USES_STATIC_BUF 0
|
||||
|
||||
#define IP_DEFAULT_TTL 255
|
||||
@@ -121,9 +135,13 @@
|
||||
#define LWIP_UDP 0
|
||||
#endif
|
||||
|
||||
/*
|
||||
* PBUF_POOL_BUFSIZE is derived from TCP_MSS even when
|
||||
* CONFIG_PROT_TCP_LWIP is not defined
|
||||
*/
|
||||
#define TCP_MSS 1460
|
||||
#if defined(CONFIG_PROT_TCP_LWIP)
|
||||
#define LWIP_TCP 1
|
||||
#define TCP_MSS 1460
|
||||
#define TCP_WND CONFIG_LWIP_TCP_WND
|
||||
#define LWIP_WND_SCALE 1
|
||||
#define TCP_RCV_SCALE 0x7
|
||||
|
||||
@@ -40,6 +40,7 @@ config OPTEE_TZDRAM_SIZE
|
||||
|
||||
config BOOTM_OPTEE
|
||||
bool "Support OPTEE bootm command"
|
||||
depends on LIB_BOOTI || LIB_BOOTM || LIB_BOOTZ
|
||||
select BOOTM_LINUX
|
||||
select OPTEE_IMAGE
|
||||
help
|
||||
|
||||
1151
lib/smbios.c
1151
lib/smbios.c
File diff suppressed because it is too large
Load Diff
@@ -254,6 +254,12 @@ static const struct {
|
||||
NULL, "EFI Conformance Profiles Table",
|
||||
EFI_CONFORMANCE_PROFILES_TABLE_GUID,
|
||||
},
|
||||
#if CONFIG_IS_ENABLED(EFI_ECPT)
|
||||
{
|
||||
NULL, "EFI EBBR 2.1 Conformance Profile",
|
||||
EFI_CONFORMANCE_PROFILE_EBBR_2_1_GUID,
|
||||
},
|
||||
#endif
|
||||
#ifdef CONFIG_EFI_RISCV_BOOT_PROTOCOL
|
||||
{
|
||||
NULL, "RISC-V Boot",
|
||||
|
||||
Reference in New Issue
Block a user