* [U-Boot] [PATCH 1/2] efi_loader: Improve install_configuration_table
@ 2017-07-26 11:41 Alexander Graf
2017-07-26 11:41 ` [U-Boot] [PATCH 2/2] efi_loader: Fix configuration table override Alexander Graf
2017-07-28 22:25 ` [U-Boot] [U-Boot, 1/2] efi_loader: Improve install_configuration_table Alexander Graf
0 siblings, 2 replies; 4+ messages in thread
From: Alexander Graf @ 2017-07-26 11:41 UTC (permalink / raw)
To: u-boot
The INSTALL_CONFIGURATION_TABLE callback also provides the ability to
remove table entries. This patch adds that functionality.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
lib/efi_loader/efi_boottime.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index 9a1a93fade..17c531a480 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -630,6 +630,17 @@ static efi_status_t EFIAPI efi_locate_device_path(efi_guid_t *protocol,
return EFI_EXIT(EFI_NOT_FOUND);
}
+/* Collapses configuration table entries, removing index i */
+static void efi_remove_configuration_table(int i)
+{
+ struct efi_configuration_table *this = &efi_conf_table[i];
+ struct efi_configuration_table *next = &efi_conf_table[i+1];
+ struct efi_configuration_table *end = &efi_conf_table[systab.nr_tables];
+
+ memmove(this, next, (ulong)end - (ulong)next);
+ systab.nr_tables--;
+}
+
efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table)
{
int i;
@@ -637,11 +648,17 @@ efi_status_t efi_install_configuration_table(const efi_guid_t *guid, void *table
/* Check for guid override */
for (i = 0; i < systab.nr_tables; i++) {
if (!guidcmp(guid, &efi_conf_table[i].guid)) {
- efi_conf_table[i].table = table;
+ if (table)
+ efi_conf_table[i].table = table;
+ else
+ efi_remove_configuration_table(i);
return EFI_SUCCESS;
}
}
+ if (!table)
+ return EFI_NOT_FOUND;
+
/* No override, check for overflow */
if (i >= ARRAY_SIZE(efi_conf_table))
return EFI_OUT_OF_RESOURCES;
--
2.12.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH 2/2] efi_loader: Fix configuration table override
2017-07-26 11:41 [U-Boot] [PATCH 1/2] efi_loader: Improve install_configuration_table Alexander Graf
@ 2017-07-26 11:41 ` Alexander Graf
2017-07-28 22:25 ` [U-Boot] [U-Boot, " Alexander Graf
2017-07-28 22:25 ` [U-Boot] [U-Boot, 1/2] efi_loader: Improve install_configuration_table Alexander Graf
1 sibling, 1 reply; 4+ messages in thread
From: Alexander Graf @ 2017-07-26 11:41 UTC (permalink / raw)
To: u-boot
Before commit 7cbc12415d ("efi_loader: initalize EFI object list
only once") we recreated the world on every bootefi invocation.
That included the object tree as well as the configuration tables.
Now however we don't recreate them, which means we must not explicitly
override the configuration tables, as otherwise we may lose our SMBIOS
table from the configuration table list on second bootefi invocation.
This patch makes bootefi call our normal configuration table modification
APIs to add/remove the FDT instead of recreating all tables from scratch.
That way the SMBIOS table gets preserved across multiple invocations.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
cmd/bootefi.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/cmd/bootefi.c b/cmd/bootefi.c
index 9526f6c60d..d20775eccd 100644
--- a/cmd/bootefi.c
+++ b/cmd/bootefi.c
@@ -215,6 +215,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
ulong (*entry)(void *image_handle, struct efi_system_table *st)
asmlinkage;
ulong fdt_pages, fdt_size, fdt_start, fdt_end;
+ const efi_guid_t fdt_guid = EFI_FDT_GUID;
bootm_headers_t img = { 0 };
/*
@@ -233,9 +234,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
}
/* Link to it in the efi tables */
- systab.tables[0].guid = EFI_FDT_GUID;
- systab.tables[0].table = fdt;
- systab.nr_tables = 1;
+ efi_install_configuration_table(&fdt_guid, fdt);
/* And reserve the space in the memory map */
fdt_start = ((ulong)fdt) & ~EFI_PAGE_MASK;
@@ -248,7 +247,7 @@ static unsigned long do_bootefi_exec(void *efi, void *fdt)
EFI_BOOT_SERVICES_DATA, true);
} else {
printf("WARNING: Invalid device tree, expect boot to fail\n");
- systab.nr_tables = 0;
+ efi_install_configuration_table(&fdt_guid, NULL);
}
/* Load the EFI payload */
--
2.12.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [U-Boot, 1/2] efi_loader: Improve install_configuration_table
2017-07-26 11:41 [U-Boot] [PATCH 1/2] efi_loader: Improve install_configuration_table Alexander Graf
2017-07-26 11:41 ` [U-Boot] [PATCH 2/2] efi_loader: Fix configuration table override Alexander Graf
@ 2017-07-28 22:25 ` Alexander Graf
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2017-07-28 22:25 UTC (permalink / raw)
To: u-boot
> The INSTALL_CONFIGURATION_TABLE callback also provides the ability to
> remove table entries. This patch adds that functionality.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [U-Boot, 2/2] efi_loader: Fix configuration table override
2017-07-26 11:41 ` [U-Boot] [PATCH 2/2] efi_loader: Fix configuration table override Alexander Graf
@ 2017-07-28 22:25 ` Alexander Graf
0 siblings, 0 replies; 4+ messages in thread
From: Alexander Graf @ 2017-07-28 22:25 UTC (permalink / raw)
To: u-boot
> Before commit 7cbc12415d ("efi_loader: initalize EFI object list
> only once") we recreated the world on every bootefi invocation.
>
> That included the object tree as well as the configuration tables.
>
> Now however we don't recreate them, which means we must not explicitly
> override the configuration tables, as otherwise we may lose our SMBIOS
> table from the configuration table list on second bootefi invocation.
>
> This patch makes bootefi call our normal configuration table modification
> APIs to add/remove the FDT instead of recreating all tables from scratch.
> That way the SMBIOS table gets preserved across multiple invocations.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
Thanks, applied to efi-next
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-07-28 22:25 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-26 11:41 [U-Boot] [PATCH 1/2] efi_loader: Improve install_configuration_table Alexander Graf
2017-07-26 11:41 ` [U-Boot] [PATCH 2/2] efi_loader: Fix configuration table override Alexander Graf
2017-07-28 22:25 ` [U-Boot] [U-Boot, " Alexander Graf
2017-07-28 22:25 ` [U-Boot] [U-Boot, 1/2] efi_loader: Improve install_configuration_table Alexander Graf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox