From: "Vincent Stehlé" <vincent.stehle@arm.com>
To: u-boot@lists.u-boot-project.org
Cc: "Heinrich Schuchardt" <xypron.glpk@gmx.de>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Tom Rini" <trini@konsulko.com>,
"Leif Lindholm" <leif.lindholm@oss.qualcomm.com>,
"Rob Clark" <robin.clark@oss.qualcomm.com>,
"AKASHI Takahiro" <akashi.tkhro@gmail.com>,
"Alexander Graf" <agraf@csgraf.de>,
"Vincent Stehlé" <vincent.stehle@arm.com>
Subject: [PATCH v2 2/2] efi_selftest: test set_string() HII string table realloc
Date: Tue, 22 Sep 2026 11:15:17 +0200 [thread overview]
Message-ID: <20260922-ptr-v2-2-58817a31c67f@arm.com> (raw)
In-Reply-To: <20260922-ptr-v2-0-58817a31c67f@arm.com>
Enhance the HII selftest to cause string table reallocation with
set_string().
The test method is the following:
1. Add string packages with two strings for en-US, and only one string
for fr-FR.
2. Set string 2 for fr-FR, causing reallocation of the string table.
3. Get string 2 again, to verify that we did not forget the new string
table size.
This can be tested on the sandbox with the following command:
./u-boot -T -c "setenv efi_selftest HII database protocols; \
bootefi selftest"
Signed-off-by: Vincent Stehlé <vincent.stehle@arm.com>
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Cc: Tom Rini <trini@konsulko.com>
---
lib/efi_selftest/efi_selftest_hii.c | 44 ++++++++++++++++++++++++++
lib/efi_selftest/efi_selftest_hii_data.c | 53 ++++++++++++++++++++++++++++++++
2 files changed, 97 insertions(+)
diff --git a/lib/efi_selftest/efi_selftest_hii.c b/lib/efi_selftest/efi_selftest_hii.c
index fdbb08fb417..2d7151b638f 100644
--- a/lib/efi_selftest/efi_selftest_hii.c
+++ b/lib/efi_selftest/efi_selftest_hii.c
@@ -820,6 +820,8 @@ static int test_hii_string_set_string(void)
efi_string_id_t id;
efi_status_t ret;
int result = EFI_ST_FAILURE;
+ u16 string[32];
+ efi_uintn_t string_size;
PRINT_TESTNAME;
ret = hii_database_protocol->new_package_list(hii_database_protocol,
@@ -849,6 +851,48 @@ static int test_hii_string_set_string(void)
goto out;
}
+ ret = hii_database_protocol->remove_package_list(hii_database_protocol,
+ handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("remove_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ /*
+ * Test the reallocation path.
+ * We create string 2 in package fr-FR, which has only one string.
+ * This forces the reallocation of the string table.
+ * Then we read string 2 again, to verify that we did not forget the
+ * size of the string table.
+ */
+ ret = hii_database_protocol->new_package_list(hii_database_protocol,
+ (struct efi_hii_package_list_header *)packagelist3,
+ NULL, &handle);
+ if (ret != EFI_SUCCESS || !handle) {
+ efi_st_error("new_package_list returned %u\n",
+ (unsigned int)ret);
+ return EFI_ST_FAILURE;
+ }
+
+ ret = hii_string_protocol->set_string(hii_string_protocol, handle, 2,
+ (u8 *)"fr-FR", u"Realloc", NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("set_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
+ string_size = sizeof(string);
+ ret = hii_string_protocol->get_string(hii_string_protocol,
+ (u8 *)"fr-FR", handle, 2, string,
+ &string_size, NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("get_string returned %u\n",
+ (unsigned int)ret);
+ goto out;
+ }
+
result = EFI_ST_SUCCESS;
out:
diff --git a/lib/efi_selftest/efi_selftest_hii_data.c b/lib/efi_selftest/efi_selftest_hii_data.c
index 2d29bb045d3..7ab70c61148 100644
--- a/lib/efi_selftest/efi_selftest_hii_data.c
+++ b/lib/efi_selftest/efi_selftest_hii_data.c
@@ -424,6 +424,59 @@ static u8 packagelist2[] = {
EFI_HII_PACKAGE_END // 1
};
+/*
+ * This package list is meant for testing the reallocation path of set_string().
+ * It contains two strings in en-US and only one string in fr-FR.
+ */
+static u8 packagelist3[] = {
+ // EFI_HII_PACKAGE_LIST_HEADER, length = 20
+ 0xd3, 0xde, 0x85, 0x86, 0xce, 0x1b, 0xf3, 0x43,
+ 0xa2, 0x0c, 0xa3, 0x06, 0xec, 0x69, 0x72, 0xdd, //16
+ 0xad, 0x00, 0x00, 0x00, // 4: total 173
+ //
+ // EFI_HII_PACKAGE_STRINGS, length = 77
+ //
+ 0x4d, 0x00, 0x00, // 3: length(header)
+ EFI_HII_PACKAGE_STRINGS, // 1: type(header)
+ 0x34, 0x00, 0x00, 0x00, // 4: header_size
+ 0x34, 0x00, 0x00, 0x00, // 4: string_offset
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //32: language_window
+ 0x01, 0x00, // 2: language name
+ 0x65, 0x6e, 0x2d, 0x55, 0x53, 0x00, // 6: language "en-US"
+ EFI_HII_SIBT_STRING_UCS2, // 1
+ 0x45, 0x00, 0x6E, 0x00, 0x67, 0x00, 0x6C, 0x00,
+ 0x69, 0x00, 0x73, 0x00, 0x68, 0x00, 0x00, 0x00, //16: "English"
+ EFI_HII_SIBT_STRING_UCS2, // 1
+ 0x55, 0x00, 0x53, 0x00, 0x00, 0x00, // 6: "US"
+ EFI_HII_SIBT_END, // 1
+ //
+ // EFI_HII_PACKAGE_STRINGS, length = 72
+ //
+ 0x48, 0x00, 0x00, // 3: length(header)
+ EFI_HII_PACKAGE_STRINGS, // 1: type(header)
+ 0x34, 0x00, 0x00, 0x00, // 4: header_size
+ 0x34, 0x00, 0x00, 0x00, // 4: string_offset
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, //32: language_window
+ 0x01, 0x00, // 2: language name
+ 0x66, 0x72, 0x2d, 0x46, 0x52, 0x00, // 6: language "fr-FR"
+ EFI_HII_SIBT_STRING_UCS2, // 1
+ 0x46, 0x00, 0x72, 0x00, 0x61, 0x00, 0x6e, 0x00,
+ 0xe7, 0x00, 0x61, 0x00, 0x69, 0x00, 0x73, 0x00,
+ 0x00, 0x00, //18: "Français"
+ EFI_HII_SIBT_END, // 1
+ //
+ // End of package list, length = 4
+ //
+ 0x4, 0x00, 0x00, // 3
+ EFI_HII_PACKAGE_END // 1
+};
+
static efi_guid_t kb_layout_guid11 =
EFI_GUID(0x8d40e495, 0xe2aa, 0x4c6f,
0x89, 0x70, 0x68, 0x85, 0x09, 0xee, 0xc7, 0xd2);
--
2.53.0
prev parent reply other threads:[~2026-09-22 9:15 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 9:45 [PATCH] efi_loader: fix string table reallocations Vincent Stehlé
2026-09-17 16:23 ` Heinrich Schuchardt
2026-09-18 8:51 ` Vincent Stehlé
2026-09-18 16:22 ` Heinrich Schuchardt
2026-09-21 9:25 ` Vincent Stehlé
2026-09-22 9:10 ` Vincent Stehlé
2026-09-22 9:15 ` [PATCH v2 0/2] efi: fix and test hii " Vincent Stehlé
2026-09-22 9:15 ` [PATCH v2 1/2] efi_loader: fix " Vincent Stehlé
2026-10-11 6:32 ` Heinrich Schuchardt
2026-09-22 9:15 ` Vincent Stehlé [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260922-ptr-v2-2-58817a31c67f@arm.com \
--to=vincent.stehle@arm.com \
--cc=agraf@csgraf.de \
--cc=akashi.tkhro@gmail.com \
--cc=ilias.apalodimas@linaro.org \
--cc=leif.lindholm@oss.qualcomm.com \
--cc=robin.clark@oss.qualcomm.com \
--cc=trini@konsulko.com \
--cc=u-boot@lists.u-boot-project.org \
--cc=xypron.glpk@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox