mirror of
https://github.com/u-boot/u-boot.git
synced 2025-04-26 15:28:50 +00:00
Pull request efi-2025-04-rc3
UEFI: * create a parent device for all EFI block devices * move lmb_map_update_notify() to EFI * make efi_add_memory_map_pg() static * remove comparisons to string literals from runtime * ix potential deref-after-null Other: * avoid superfluous value check in lmb_map_update_notify() * support more efi protocols in uuid_guid_get_str() -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEK7wKXt3/btL6/yA+hO4vgnE3U0sFAme3XJYACgkQhO4vgnE3 U0tbDRAAo8wMa/PLC0dB/NRwCclbZxRfLbirwKTawPC5Ub8HYH5aXtvd4JW+qvKJ A1fz8092P1Rbv8zXILME6Cig3LOBZrvQhbgfTKbPK/VYXrpLPD0f6jyfEywLj1Fn pqMp0VkH60qj9xh3axqdJPS1lL7yGr6+L1AOmqptZ6hr2IjtWGZ7/VYj26WqIf9X awV7hjmxJTwvivy9aezcb3cyBq82TvVLfm+TFTsXJHIlgbYnyYHE3b5uuM+XOOgt bVL+Wj4kEU1t7qtkR7ZTn6k1VyEgSRecdJP0Q4pP3TFLxUX2ku4MyHvCl4BwQOBf UV4AT2SgiOIZKcaVpzb1ukMACgCBba6RTvjB86MWU9N0dgbHs8ZTXmmQPYmEUxgR 68ufeA89xuSFNoQ8ft2lMYjfY0OjtNr6riTVdEeEwXVq+r/ogCY/p2/NpRMAR8LG yNwLBQ3Hwqmyy+VYHJ53anvRR44hPf4ZFLtlgGtuDEfrgZ03ZNU5TPB+1v6A0C1L K772WYp6LOn1nedYoWp3fB5GhA1oiFdUvgOXi0nxkPr1jW+rewAFyGWtV8AP9msz AtAEfJPLBV4LhxZBR4mHADeOAt+AUThWRuY1i3yOg1o+XAJazK3K2DIlfnmr4cc1 TZbMR4NPTtgpZomJlSYlGWRutgQwHt/la5qlfF+sFdqUmy+Dq/A= =7bV8 -----END PGP SIGNATURE----- Merge tag 'efi-2025-04-rc3' of https://source.denx.de/u-boot/custodians/u-boot-efi CI: * https://source.denx.de/u-boot/custodians/u-boot-efi/-/pipelines/24709 UEFI: * create a parent device for all EFI block devices * move lmb_map_update_notify() to EFI * make efi_add_memory_map_pg() static * remove comparisons to string literals from runtime * ix potential deref-after-null Other: * avoid superfluous value check in lmb_map_update_notify() * support more efi protocols in uuid_guid_get_str()
This commit is contained in:
commit
313b9856f9
10 changed files with 115 additions and 62 deletions
|
@ -852,21 +852,6 @@ efi_status_t efi_get_memory_map(efi_uintn_t *memory_map_size,
|
|||
/* Adds a range into the EFI memory map */
|
||||
efi_status_t efi_add_memory_map(u64 start, u64 size, int memory_type);
|
||||
|
||||
/**
|
||||
* efi_add_memory_map_pg() - add pages to the memory 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_conventional: region may only overlap free(conventional)
|
||||
* memory
|
||||
* Return: status code
|
||||
*/
|
||||
efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
|
||||
int memory_type,
|
||||
bool overlap_conventional);
|
||||
|
||||
/* Called by board init to initialize the EFI drivers */
|
||||
efi_status_t efi_driver_init(void);
|
||||
/* Called when a block device is added */
|
||||
|
@ -1263,6 +1248,21 @@ efi_status_t efi_disk_get_device_name(const efi_handle_t handle, char *buf, int
|
|||
*/
|
||||
void efi_add_known_memory(void);
|
||||
|
||||
/**
|
||||
* efi_map_update_notify() - notify EFI of memory map changes
|
||||
*
|
||||
* @addr: start of memory area
|
||||
* @size: size of memory area
|
||||
* @op: type of change
|
||||
* Return: 0 if change could be processed
|
||||
*/
|
||||
#ifdef CONFIG_EFI_LOADER
|
||||
int efi_map_update_notify(phys_addr_t addr, phys_size_t size,
|
||||
enum lmb_map_op op);
|
||||
#else
|
||||
#define efi_map_update_notify(addr, size, op) (0)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* efi_load_option_dp_join() - join device-paths for load option
|
||||
*
|
||||
|
|
|
@ -31,6 +31,18 @@
|
|||
#define LMB_NOOVERWRITE BIT(1)
|
||||
#define LMB_NONOTIFY BIT(2)
|
||||
|
||||
/**
|
||||
* enum lmb_map_op - memory map operation
|
||||
*/
|
||||
enum lmb_map_op {
|
||||
/** @LMB_MAP_OP_RESERVE: reserve memory */
|
||||
LMB_MAP_OP_RESERVE = 1,
|
||||
/** @LMB_MAP_OP_FREE: free memory */
|
||||
LMB_MAP_OP_FREE,
|
||||
/** @LMB_MAP_OP_ADD: add memory */
|
||||
LMB_MAP_OP_ADD,
|
||||
};
|
||||
|
||||
/**
|
||||
* struct lmb_region - Description of one region
|
||||
* @base: Base address of the region
|
||||
|
|
|
@ -35,8 +35,10 @@
|
|||
#include <efi_driver.h>
|
||||
#include <malloc.h>
|
||||
#include <dm/device-internal.h>
|
||||
#include <dm/lists.h>
|
||||
#include <dm/root.h>
|
||||
#include <dm/tag.h>
|
||||
#include <dm/uclass-internal.h>
|
||||
|
||||
/**
|
||||
* struct efi_blk_plat - attributes of a block device
|
||||
|
@ -118,13 +120,18 @@ static ulong efi_bl_write(struct udevice *dev, lbaint_t blknr, lbaint_t blkcnt,
|
|||
static efi_status_t
|
||||
efi_bl_create_block_device(efi_handle_t handle, void *interface)
|
||||
{
|
||||
struct udevice *bdev = NULL, *parent = dm_root();
|
||||
struct udevice *bdev = NULL, *parent;
|
||||
efi_status_t ret;
|
||||
int r;
|
||||
int devnum;
|
||||
char *name;
|
||||
struct efi_block_io *io = interface;
|
||||
struct efi_blk_plat *plat;
|
||||
|
||||
r = uclass_find_first_device(UCLASS_EFI_LOADER, &parent);
|
||||
if (r)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
||||
devnum = blk_next_free_devnum(UCLASS_EFI_LOADER);
|
||||
if (devnum < 0)
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
|
@ -221,6 +228,24 @@ efi_bl_init(struct efi_driver_binding_extended_protocol *this)
|
|||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* efi_block_device_create() - create parent for EFI block devices
|
||||
*
|
||||
* Create a device that serves as parent for all block devices created via
|
||||
* ConnectController().
|
||||
*
|
||||
* Return: 0 for success
|
||||
*/
|
||||
static int efi_block_device_create(void)
|
||||
{
|
||||
int ret;
|
||||
struct udevice *dev;
|
||||
|
||||
ret = device_bind_driver(gd->dm_root, "EFI block driver", "efi", &dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Block device driver operators */
|
||||
static const struct blk_ops efi_blk_ops = {
|
||||
.read = efi_bl_read,
|
||||
|
@ -249,3 +274,5 @@ U_BOOT_DRIVER(efi_block) = {
|
|||
.id = UCLASS_EFI_LOADER,
|
||||
.ops = &driver_ops,
|
||||
};
|
||||
|
||||
EVENT_SPY_SIMPLE(EVT_LAST_STAGE_INIT, efi_block_device_create);
|
||||
|
|
|
@ -531,7 +531,8 @@ static efi_status_t efi_disk_add_dev(
|
|||
|
||||
/* Store first EFI system partition */
|
||||
if (part && efi_system_partition.uclass_id == UCLASS_INVALID) {
|
||||
if (part_info->bootable & PART_EFI_SYSTEM_PARTITION) {
|
||||
if (part_info &&
|
||||
part_info->bootable & PART_EFI_SYSTEM_PARTITION) {
|
||||
efi_system_partition.uclass_id = desc->uclass_id;
|
||||
efi_system_partition.devnum = desc->devnum;
|
||||
efi_system_partition.part = part;
|
||||
|
|
|
@ -268,6 +268,7 @@ static s64 efi_mem_carve_out(struct efi_mem_list *map,
|
|||
* memory
|
||||
* Return: status code
|
||||
*/
|
||||
static
|
||||
efi_status_t efi_add_memory_map_pg(u64 start, u64 pages,
|
||||
int memory_type,
|
||||
bool overlap_conventional)
|
||||
|
@ -865,3 +866,30 @@ int efi_memory_init(void)
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int efi_map_update_notify(phys_addr_t addr, phys_size_t size,
|
||||
enum lmb_map_op op)
|
||||
{
|
||||
u64 efi_addr;
|
||||
u64 pages;
|
||||
efi_status_t status;
|
||||
|
||||
efi_addr = (uintptr_t)map_sysmem(addr, 0);
|
||||
pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK));
|
||||
efi_addr &= ~EFI_PAGE_MASK;
|
||||
|
||||
status = efi_add_memory_map_pg(efi_addr, pages,
|
||||
op == LMB_MAP_OP_RESERVE ?
|
||||
EFI_BOOT_SERVICES_DATA :
|
||||
EFI_CONVENTIONAL_MEMORY,
|
||||
false);
|
||||
if (status != EFI_SUCCESS) {
|
||||
log_err("LMB Map notify failure %lu\n",
|
||||
status & ~EFI_ERROR_MASK);
|
||||
return -1;
|
||||
}
|
||||
unmap_sysmem((void *)(uintptr_t)efi_addr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
*/
|
||||
static struct efi_var_file __efi_runtime_data *efi_var_buf;
|
||||
static struct efi_var_entry __efi_runtime_data *efi_current_var;
|
||||
static const u16 __efi_runtime_rodata vtf[] = u"VarToFile";
|
||||
|
||||
/**
|
||||
* efi_var_mem_compare() - compare GUID and name with a variable
|
||||
|
@ -331,7 +332,7 @@ efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor,
|
|||
if (timep)
|
||||
*timep = var->time;
|
||||
|
||||
if (!u16_strcmp(variable_name, u"VarToFile"))
|
||||
if (!u16_strcmp(variable_name, vtf))
|
||||
return efi_var_collect_mem(data, data_size, EFI_VARIABLE_NON_VOLATILE);
|
||||
|
||||
old_size = *data_size;
|
||||
|
|
|
@ -41,6 +41,7 @@ static u16 mm_sp_id;
|
|||
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 */
|
||||
static const u16 __efi_runtime_rodata pk[] = u"PK";
|
||||
|
||||
struct mm_connection {
|
||||
struct udevice *tee;
|
||||
|
@ -858,7 +859,7 @@ efi_status_t efi_set_variable_int(const u16 *variable_name,
|
|||
if (alt_ret != EFI_SUCCESS)
|
||||
goto out;
|
||||
|
||||
if (!u16_strcmp(variable_name, u"PK"))
|
||||
if (!u16_strcmp(variable_name, pk))
|
||||
alt_ret = efi_init_secure_state();
|
||||
out:
|
||||
free(comm_buf);
|
||||
|
|
52
lib/lmb.c
52
lib/lmb.c
|
@ -23,10 +23,6 @@
|
|||
|
||||
DECLARE_GLOBAL_DATA_PTR;
|
||||
|
||||
#define MAP_OP_RESERVE (u8)0x1
|
||||
#define MAP_OP_FREE (u8)0x2
|
||||
#define MAP_OP_ADD (u8)0x3
|
||||
|
||||
/*
|
||||
* The following low level LMB functions must not access the global LMB memory
|
||||
* map since they are also used to manage IOVA memory maps in iommu drivers like
|
||||
|
@ -430,42 +426,12 @@ long io_lmb_free(struct lmb *io_lmb, phys_addr_t base, phys_size_t size)
|
|||
|
||||
static struct lmb lmb;
|
||||
|
||||
static bool lmb_should_notify(u32 flags)
|
||||
static int lmb_map_update_notify(phys_addr_t addr, phys_size_t size,
|
||||
enum lmb_map_op op, u32 flags)
|
||||
{
|
||||
return !lmb.test && !(flags & LMB_NONOTIFY) &&
|
||||
CONFIG_IS_ENABLED(EFI_LOADER);
|
||||
}
|
||||
|
||||
static int lmb_map_update_notify(phys_addr_t addr, phys_size_t size, u8 op,
|
||||
u32 flags)
|
||||
{
|
||||
u64 efi_addr;
|
||||
u64 pages;
|
||||
efi_status_t status;
|
||||
|
||||
if (op != MAP_OP_RESERVE && op != MAP_OP_FREE && op != MAP_OP_ADD) {
|
||||
log_err("Invalid map update op received (%d)\n", op);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!lmb_should_notify(flags))
|
||||
return 0;
|
||||
|
||||
efi_addr = (uintptr_t)map_sysmem(addr, 0);
|
||||
pages = efi_size_in_pages(size + (efi_addr & EFI_PAGE_MASK));
|
||||
efi_addr &= ~EFI_PAGE_MASK;
|
||||
|
||||
status = efi_add_memory_map_pg(efi_addr, pages,
|
||||
op == MAP_OP_RESERVE ?
|
||||
EFI_BOOT_SERVICES_DATA :
|
||||
EFI_CONVENTIONAL_MEMORY,
|
||||
false);
|
||||
if (status != EFI_SUCCESS) {
|
||||
log_err("%s: LMB Map notify failure %lu\n", __func__,
|
||||
status & ~EFI_ERROR_MASK);
|
||||
return -1;
|
||||
}
|
||||
unmap_sysmem((void *)(uintptr_t)efi_addr);
|
||||
if (CONFIG_IS_ENABLED(EFI_LOADER) &&
|
||||
!lmb.test && !(flags & LMB_NONOTIFY))
|
||||
return efi_map_update_notify(addr, size, op);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -642,7 +608,7 @@ long lmb_add(phys_addr_t base, phys_size_t size)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
return lmb_map_update_notify(base, size, MAP_OP_ADD, LMB_NONE);
|
||||
return lmb_map_update_notify(base, size, LMB_MAP_OP_ADD, LMB_NONE);
|
||||
}
|
||||
|
||||
long lmb_free_flags(phys_addr_t base, phys_size_t size,
|
||||
|
@ -654,7 +620,7 @@ long lmb_free_flags(phys_addr_t base, phys_size_t size,
|
|||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
return lmb_map_update_notify(base, size, MAP_OP_FREE, flags);
|
||||
return lmb_map_update_notify(base, size, LMB_MAP_OP_FREE, flags);
|
||||
}
|
||||
|
||||
long lmb_free(phys_addr_t base, phys_size_t size)
|
||||
|
@ -671,7 +637,7 @@ long lmb_reserve(phys_addr_t base, phys_size_t size, u32 flags)
|
|||
if (ret)
|
||||
return ret;
|
||||
|
||||
return lmb_map_update_notify(base, size, MAP_OP_RESERVE, flags);
|
||||
return lmb_map_update_notify(base, size, LMB_MAP_OP_RESERVE, flags);
|
||||
}
|
||||
|
||||
static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
|
||||
|
@ -712,7 +678,7 @@ static phys_addr_t _lmb_alloc_base(phys_size_t size, ulong align,
|
|||
return 0;
|
||||
|
||||
ret = lmb_map_update_notify(base, size,
|
||||
MAP_OP_RESERVE,
|
||||
LMB_MAP_OP_RESERVE,
|
||||
flags);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
|
16
lib/uuid.c
16
lib/uuid.c
|
@ -119,6 +119,10 @@ static const struct {
|
|||
"Block IO",
|
||||
EFI_BLOCK_IO_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"Disk IO",
|
||||
EFI_DISK_IO_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"Simple File System",
|
||||
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID,
|
||||
|
@ -127,6 +131,10 @@ static const struct {
|
|||
"Loaded Image",
|
||||
EFI_LOADED_IMAGE_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"Loaded Image Device Path",
|
||||
EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"Graphics Output",
|
||||
EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID,
|
||||
|
@ -139,10 +147,18 @@ static const struct {
|
|||
"HII Database",
|
||||
EFI_HII_DATABASE_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"HII Config Access",
|
||||
EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"HII Config Routing",
|
||||
EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"Load File",
|
||||
EFI_LOAD_FILE_PROTOCOL_GUID,
|
||||
},
|
||||
{
|
||||
"Load File2",
|
||||
EFI_LOAD_FILE2_PROTOCOL_GUID,
|
||||
|
|
|
@ -19,6 +19,7 @@ def test_event_dump(u_boot_console):
|
|||
EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.*
|
||||
EVT_FT_FIXUP bootmeth_vbe_simple_ft_fixup .*boot/vbe_simple_os.c:.*
|
||||
EVT_LAST_STAGE_INIT alloc_write_acpi_tables .*lib/acpi/acpi_table.c:.*
|
||||
EVT_LAST_STAGE_INIT efi_block_device_create .*lib/efi_driver/efi_block_device.c:.*
|
||||
EVT_LAST_STAGE_INIT install_smbios_table .*lib/efi_loader/efi_smbios.c:.*
|
||||
EVT_MISC_INIT_F sandbox_early_getopt_check .*arch/sandbox/cpu/start.c:.*
|
||||
EVT_TEST h_adder_simple .*test/common/event.c:'''
|
||||
|
|
Loading…
Add table
Reference in a new issue