[PATCH] uefi/esrt : Added esrt_test2 for EBBR
Ivan Hu
ivan.hu at canonical.com
Tue May 3 02:22:12 UTC 2022
From: G Edhaya Chandran <edhaya.chandran at arm.com>
Added esrt_test2 which will validate if GUIDs (fw_class) in the ESRT
table is not equal to the default U-Boot GUIDs.
The test is applicable only for AARCH64 and --ebbr option
Signed-off-by: G Edhaya Chandran <edhaya.chandran at arm.com>
---
src/uefi/esrt/esrt.c | 65 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 65 insertions(+)
diff --git a/src/uefi/esrt/esrt.c b/src/uefi/esrt/esrt.c
index f75fbe9a..fd9013ed 100644
--- a/src/uefi/esrt/esrt.c
+++ b/src/uefi/esrt/esrt.c
@@ -37,6 +37,9 @@
/* Current Entry Version */
#define ESRT_FIRMWARE_RESOURCE_VERSION 1
+#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID "DAFFD814-6EBA-4D8C-8A91-BC9BBF4AA301"
+#define EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID "E2BB9C06-70E9-4B14-97A3-5A7913176e3F"
+
static int esrt_init(fwts_framework *fw)
{
@@ -252,8 +255,70 @@ static int esrt_test1(fwts_framework *fw)
}
+//esrt_test2 is applicable only for EBBR recipe of Arm BBR
+#if defined(FWTS_ARCH_AARCH64)
+static int esrt_test2(fwts_framework *fw)
+{
+
+ DIR *dir;
+ struct dirent *entry;
+ bool passed = true;
+ const int SIZE_OF_GUID = 36;
+
+ if (!(fw->flags & FWTS_FLAG_EBBR)) {
+ fwts_skipped(fw, "This test is applicable only for EBBR, hence skipped.");
+ return FWTS_SKIP;
+ }
+
+ if (!(dir = opendir(FWTS_ESRT_ENTRY_PATH))) {
+ fwts_failed(fw, LOG_LEVEL_MEDIUM, "CannotOpenDir",
+ "Cannot open directory %s", FWTS_ESRT_ENTRY_PATH);
+ passed = false;
+ return FWTS_ERROR;
+ }
+ do {
+ entry = readdir(dir);
+ if (entry && strstr(entry->d_name, "entry")) {
+ char path[PATH_MAX] = {0x0};
+ char *str = NULL;
+
+ //str contains the GUID
+ snprintf(path, sizeof(path), FWTS_ESRT_ENTRY_PATH "/%s/fw_class", entry->d_name);
+ if ((str = fwts_get(path)) == NULL) {
+ fwts_failed(fw, LOG_LEVEL_MEDIUM, "CannotGetFwClass",
+ "Missing or failed to get FwClass on %s.", entry->d_name);
+ passed = false;
+ return FWTS_ERROR;
+ }
+ if (!strncasecmp(str, EFI_FIRMWARE_IMAGE_TYPE_UBOOT_FIT_GUID, SIZE_OF_GUID)) {
+ fwts_failed(fw, LOG_LEVEL_MEDIUM, "The fw_class is set to default u-boot fit guid",
+ " %s This is an invalid entry.", str);
+ passed = false;
+ return FWTS_ERROR;
+ }
+ if (!strncasecmp(str, EFI_FIRMWARE_IMAGE_TYPE_UBOOT_RAW_GUID, SIZE_OF_GUID)) {
+ fwts_failed(fw, LOG_LEVEL_MEDIUM, "The fw_class is set to default u-boot raw guid",
+ " %s This is an invalid entry.", str);
+ passed = false;
+ return FWTS_ERROR;
+ }
+ free(str);
+ }
+ } while (entry);
+
+ closedir(dir);
+
+ fwts_passed(fw, "The fw_class in the ESRT are not default u-boot guids %d", passed);
+ return FWTS_OK;
+}
+#endif
+
+
static fwts_framework_minor_test esrt_tests[] = {
{ esrt_test1, "Sanity check UEFI ESRT Table." },
+#if defined(FWTS_ARCH_AARCH64)
+ { esrt_test2, "Validity of fw_class in UEFI ESRT Table for EBBR." },
+#endif
{ NULL, NULL }
};
--
2.17.1
More information about the fwts-devel
mailing list