[PATCH] uefi/esrt : Added esrt_test2 for EBBR

ivanhu ivan.hu at canonical.com
Tue May 3 04:08:25 UTC 2022


Hi Edhay,


On 5/3/22 10:22, Ivan Hu wrote:
> 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

This patch make the all AARCH64 platforms must be the UBOOT GUID, How
about those non U-BOOT platforms? Any specification makes all AARCH64
platforms need to use U-BOOT GUID on ESRT table?


> 
> 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
Please use "/*" instead of "//"

> +#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
			same here.


Cheers,
Ivan	

> +                        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 }
>  };
>  



More information about the fwts-devel mailing list