summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/efi/Kconfig34
-rw-r--r--lib/efi/efi.c9
-rw-r--r--lib/efi/efi_app.c10
-rw-r--r--lib/efi_driver/Makefile2
-rw-r--r--lib/efi_loader/Kconfig3
-rw-r--r--lib/efi_loader/efi_boottime.c9
-rw-r--r--lib/efi_loader/efi_capsule.c36
-rw-r--r--lib/efi_loader/efi_device_path.c130
-rw-r--r--lib/efi_loader/efi_disk.c48
-rw-r--r--lib/efi_loader/efi_helper.c24
-rw-r--r--lib/efi_loader/efi_image_loader.c12
-rw-r--r--lib/efi_loader/efi_load_initrd.c3
-rw-r--r--lib/efi_loader/efi_memory.c52
-rw-r--r--lib/efi_loader/efi_signature.c38
-rw-r--r--lib/efi_loader/efi_smbios.c2
-rw-r--r--lib/efi_loader/efi_tcg2.c359
-rw-r--r--lib/efi_loader/efi_var_common.c14
-rw-r--r--lib/efi_loader/efi_var_file.c8
-rw-r--r--lib/efi_loader/efi_var_mem.c7
-rw-r--r--lib/efi_loader/efi_variable.c9
-rw-r--r--lib/efi_loader/efi_variable_tee.c16
-rw-r--r--lib/efi_selftest/efi_miniapp_tcg2_arm.h153
-rw-r--r--lib/efi_selftest/efi_miniapp_tcg2_arm64.h208
-rw-r--r--lib/efi_selftest/efi_miniapp_tcg2_ia32.h178
-rw-r--r--lib/efi_selftest/efi_miniapp_tcg2_riscv32.h174
-rw-r--r--lib/efi_selftest/efi_miniapp_tcg2_riscv64.h190
-rw-r--r--lib/efi_selftest/efi_miniapp_tcg2_x86_64.h179
-rw-r--r--lib/efi_selftest/efi_selftest_snp.c90
-rw-r--r--lib/efi_selftest/efi_selftest_tcg2.c942
-rw-r--r--lib/fdtdec.c14
-rw-r--r--lib/rsa/Kconfig4
-rw-r--r--lib/rsa/rsa-verify.c2
-rw-r--r--lib/smbios-parser.c152
-rw-r--r--lib/tpm-v2.c6
-rw-r--r--lib/uuid.c2
-rw-r--r--lib/vsprintf.c20
36 files changed, 2806 insertions, 333 deletions
diff --git a/lib/efi/Kconfig b/lib/efi/Kconfig
index 93b85644920..15ce99e1a74 100644
--- a/lib/efi/Kconfig
+++ b/lib/efi/Kconfig
@@ -26,18 +26,26 @@ config EFI_STUB
endchoice
-config EFI_RAM_SIZE
- hex "Amount of EFI RAM for U-Boot"
+choice
+ prompt "EFI app 32/64-bit selection"
depends on EFI_APP
- default 0x2000000
help
- Set the amount of EFI RAM which is claimed by U-Boot for its own
- use. U-Boot allocates this from EFI on start-up (along with a few
- other smaller amounts) and it can never be increased after that.
- It is used as the RAM size in with U-Boot.
+ EFI does not support mixing 32-bit and 64-bit modes. This is a
+ significant problem because it means that you must build a stub with
+ the correct type for EFI to load it correctly. If you are using
+ 32-bit EFI, select 32-bit here, else select 64-bit. Failure to do
+ this may produce no error message - it just won't start!
+
+config EFI_APP_32BIT
+ bool "Produce an app for running with 32-bit EFI"
+
+config EFI_APP_64BIT
+ bool "Produce an app for running with 64-bit EFI"
+
+endchoice
choice
- prompt "EFI 32/64-bit selection"
+ prompt "EFI stub 32/64-bit selection"
depends on EFI_STUB
help
EFI does not support mixing 32-bit and 64-bit modes. This is a
@@ -53,3 +61,13 @@ config EFI_STUB_64BIT
bool "Produce a stub for running with 64-bit EFI"
endchoice
+
+config EFI_RAM_SIZE
+ hex "Amount of EFI RAM for U-Boot"
+ depends on EFI_APP
+ default 0x10000000
+ help
+ Set the amount of EFI RAM which is claimed by U-Boot for its own
+ use. U-Boot allocates this from EFI on start-up (along with a few
+ other smaller amounts) and it can never be increased after that.
+ It is used as the RAM size in with U-Boot.
diff --git a/lib/efi/efi.c b/lib/efi/efi.c
index 0c16a5fdd38..69e52e45748 100644
--- a/lib/efi/efi.c
+++ b/lib/efi/efi.c
@@ -18,6 +18,15 @@
#include <efi_api.h>
/*
+ * Global declaration of gd.
+ *
+ * As we write to it before relocation we have to make sure it is not put into
+ * a .bss section which may overlap a .rela section. Initialization forces it
+ * into a .data section which cannot overlap any .rela section.
+ */
+struct global_data *global_data_ptr = (struct global_data *)~0;
+
+/*
* Unfortunately we cannot access any code outside what is built especially
* for the stub. lib/string.c is already being built for the U-Boot payload
* so it uses the wrong compiler flags. Add our own memset() here.
diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c
index 907bacd716a..f61665686c5 100644
--- a/lib/efi/efi_app.c
+++ b/lib/efi/efi_app.c
@@ -31,11 +31,21 @@ struct efi_system_table *efi_get_sys_table(void)
return global_priv->sys_table;
}
+struct efi_boot_services *efi_get_boot(void)
+{
+ return global_priv->boot;
+}
+
unsigned long efi_get_ram_base(void)
{
return global_priv->ram_base;
}
+int efi_info_get(enum efi_entry_t type, void **datap, int *sizep)
+{
+ return -ENOSYS;
+}
+
static efi_status_t setup_memory(struct efi_priv *priv)
{
struct efi_boot_services *boot = priv->boot;
diff --git a/lib/efi_driver/Makefile b/lib/efi_driver/Makefile
index 83baa1c9a49..f2b6c05cc24 100644
--- a/lib/efi_driver/Makefile
+++ b/lib/efi_driver/Makefile
@@ -6,6 +6,6 @@
# object inclusion implicitly depends on it
obj-y += efi_uclass.o
-ifeq ($(CONFIG_BLK)$(CONFIG_PARTITIONS),yy)
+ifeq ($(CONFIG_PARTITIONS),y)
obj-y += efi_block_device.o
endif
diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig
index 83d584a60e5..700dc838ddb 100644
--- a/lib/efi_loader/Kconfig
+++ b/lib/efi_loader/Kconfig
@@ -11,6 +11,8 @@ config EFI_LOADER
# We need EFI_STUB_32BIT to be set on x86_32 with EFI_STUB
depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT
depends on BLK
+ depends on DM_ETH || !NET
+ depends on !EFI_APP
default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8
select LIB_UUID
select PARTITION_UUIDS
@@ -311,6 +313,7 @@ config EFI_TCG2_PROTOCOL
select SHA384
select SHA512
select HASH
+ select SMBIOS_PARSER
help
Provide a EFI_TCG2_PROTOCOL implementation using the TPM hardware
of the platform.
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c
index f0283b539e4..1823990d9bd 100644
--- a/lib/efi_loader/efi_boottime.c
+++ b/lib/efi_loader/efi_boottime.c
@@ -86,6 +86,8 @@ const efi_guid_t efi_guid_event_group_reset_system =
/* GUIDs of the Load File and Load File2 protocols */
const efi_guid_t efi_guid_load_file_protocol = EFI_LOAD_FILE_PROTOCOL_GUID;
const efi_guid_t efi_guid_load_file2_protocol = EFI_LOAD_FILE2_PROTOCOL_GUID;
+/* GUID of the SMBIOS table */
+const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
static efi_status_t EFIAPI efi_disconnect_controller(
efi_handle_t controller_handle,
@@ -1690,8 +1692,9 @@ out:
*
* Return: status code
*/
-static efi_status_t EFIAPI efi_install_configuration_table_ext(efi_guid_t *guid,
- void *table)
+static efi_status_t
+EFIAPI efi_install_configuration_table_ext(const efi_guid_t *guid,
+ void *table)
{
EFI_ENTRY("%pUl, %p", guid, table);
return EFI_EXIT(efi_install_configuration_table(guid, table));
@@ -3001,7 +3004,7 @@ efi_status_t EFIAPI efi_start_image(efi_handle_t image_handle,
if (IS_ENABLED(CONFIG_EFI_TCG2_PROTOCOL)) {
if (image_obj->image_type == IMAGE_SUBSYSTEM_EFI_APPLICATION) {
- ret = efi_tcg2_measure_efi_app_invocation();
+ ret = efi_tcg2_measure_efi_app_invocation(image_obj);
if (ret != EFI_SUCCESS) {
log_warning("tcg2 measurement fails(0x%lx)\n",
ret);
diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c
index b75e4bcba1a..850937fd120 100644
--- a/lib/efi_loader/efi_capsule.c
+++ b/lib/efi_loader/efi_capsule.c
@@ -11,15 +11,20 @@
#include <common.h>
#include <efi_loader.h>
#include <efi_variable.h>
+#include <env.h>
+#include <fdtdec.h>
#include <fs.h>
#include <malloc.h>
#include <mapmem.h>
#include <sort.h>
+#include <asm/global_data.h>
#include <crypto/pkcs7.h>
#include <crypto/pkcs7_parser.h>
#include <linux/err.h>
+DECLARE_GLOBAL_DATA_PTR;
+
const efi_guid_t efi_guid_capsule_report = EFI_CAPSULE_REPORT_GUID;
static const efi_guid_t efi_guid_firmware_management_capsule_id =
EFI_FIRMWARE_MANAGEMENT_CAPSULE_ID_GUID;
@@ -251,6 +256,37 @@ out:
}
#if defined(CONFIG_EFI_CAPSULE_AUTHENTICATE)
+int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len)
+{
+ const void *fdt_blob = gd->fdt_blob;
+ const void *blob;
+ const char *cnode_name = "capsule-key";
+ const char *snode_name = "signature";
+ int sig_node;
+ int len;
+
+ sig_node = fdt_subnode_offset(fdt_blob, 0, snode_name);
+ if (sig_node < 0) {
+ log_err("Unable to get signature node offset\n");
+
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ blob = fdt_getprop(fdt_blob, sig_node, cnode_name, &len);
+
+ if (!blob || len < 0) {
+ log_err("Unable to get capsule-key value\n");
+ *pkey = NULL;
+ *pkey_len = 0;
+
+ return -FDT_ERR_NOTFOUND;
+ }
+
+ *pkey = (void *)blob;
+ *pkey_len = len;
+
+ return 0;
+}
efi_status_t efi_capsule_authenticate(const void *capsule, efi_uintn_t capsule_size,
void **image, efi_uintn_t *image_size)
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index cbdb466da41..735ed0bd0f4 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -46,7 +46,7 @@ static const struct efi_device_path_vendor ROOT = {
.guid = U_BOOT_GUID,
};
-#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
+#if defined(CONFIG_MMC)
/*
* Determine if an MMC device is an SD card.
*
@@ -486,7 +486,6 @@ bool efi_dp_is_multi_instance(const struct efi_device_path *dp)
return p->sub_type == DEVICE_PATH_SUB_TYPE_INSTANCE_END;
}
-#ifdef CONFIG_DM
/* size of device-path not including END node for device and all parents
* up to the root device.
*/
@@ -503,7 +502,6 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
case UCLASS_ETH:
return dp_size(dev->parent) +
sizeof(struct efi_device_path_mac_addr);
-#ifdef CONFIG_BLK
case UCLASS_BLK:
switch (dev->parent->uclass->uc_drv->id) {
#ifdef CONFIG_IDE
@@ -511,12 +509,12 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
return dp_size(dev->parent) +
sizeof(struct efi_device_path_atapi);
#endif
-#if defined(CONFIG_SCSI) && defined(CONFIG_DM_SCSI)
+#if defined(CONFIG_SCSI)
case UCLASS_SCSI:
return dp_size(dev->parent) +
sizeof(struct efi_device_path_scsi);
#endif
-#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
+#if defined(CONFIG_MMC)
case UCLASS_MMC:
return dp_size(dev->parent) +
sizeof(struct efi_device_path_sd_mmc_path);
@@ -554,8 +552,7 @@ __maybe_unused static unsigned int dp_size(struct udevice *dev)
default:
return dp_size(dev->parent);
}
-#endif
-#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
+#if defined(CONFIG_MMC)
case UCLASS_MMC:
return dp_size(dev->parent) +
sizeof(struct efi_device_path_sd_mmc_path);
@@ -590,7 +587,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
*vdp = ROOT;
return &vdp[1];
}
-#ifdef CONFIG_DM_ETH
+#ifdef CONFIG_NET
case UCLASS_ETH: {
struct efi_device_path_mac_addr *dp =
dp_fill(buf, dev->parent);
@@ -607,7 +604,6 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
return &dp[1];
}
#endif
-#ifdef CONFIG_BLK
case UCLASS_BLK:
switch (dev->parent->uclass->uc_drv->id) {
#ifdef CONFIG_SANDBOX
@@ -662,7 +658,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
return &dp[1];
}
#endif
-#if defined(CONFIG_SCSI) && defined(CONFIG_DM_SCSI)
+#if defined(CONFIG_SCSI)
case UCLASS_SCSI: {
struct efi_device_path_scsi *dp =
dp_fill(buf, dev->parent);
@@ -676,7 +672,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
return &dp[1];
}
#endif
-#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
+#if defined(CONFIG_MMC)
case UCLASS_MMC: {
struct efi_device_path_sd_mmc_path *sddp =
dp_fill(buf, dev->parent);
@@ -727,8 +723,7 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
dev->name, dev->parent->uclass->uc_drv->id);
return dp_fill(buf, dev->parent);
}
-#endif
-#if defined(CONFIG_DM_MMC) && defined(CONFIG_MMC)
+#if defined(CONFIG_MMC)
case UCLASS_MMC: {
struct efi_device_path_sd_mmc_path *sddp =
dp_fill(buf, dev->parent);
@@ -770,24 +765,18 @@ __maybe_unused static void *dp_fill(void *buf, struct udevice *dev)
return dp_fill(buf, dev->parent);
}
}
-#endif
static unsigned dp_part_size(struct blk_desc *desc, int part)
{
unsigned dpsize;
+ struct udevice *dev;
+ int ret;
-#ifdef CONFIG_BLK
- {
- struct udevice *dev;
- int ret = blk_find_device(desc->if_type, desc->devnum, &dev);
+ ret = blk_find_device(desc->if_type, desc->devnum, &dev);
- if (ret)
- dev = desc->bdev->parent;
- dpsize = dp_size(dev);
- }
-#else
- dpsize = sizeof(ROOT) + sizeof(struct efi_device_path_usb);
-#endif
+ if (ret)
+ dev = desc->bdev->parent;
+ dpsize = dp_size(dev);
if (part == 0) /* the actual disk, not a partition */
return dpsize;
@@ -877,36 +866,14 @@ static void *dp_part_node(void *buf, struct blk_desc *desc, int part)
*/
static void *dp_part_fill(void *buf, struct blk_desc *desc, int part)
{
-#ifdef CONFIG_BLK
- {
- struct udevice *dev;
- int ret = blk_find_device(desc->if_type, desc->devnum, &dev);
+ struct udevice *dev;
+ int ret;
- if (ret)
- dev = desc->bdev->parent;
- buf = dp_fill(buf, dev);
- }
-#else
- /*
- * We *could* make a more accurate path, by looking at if_type
- * and handling all the different cases like we do for non-
- * legacy (i.e. CONFIG_BLK=y) case. But most important thing
- * is just to have a unique device-path for if_type+devnum.
- * So map things to a fictitious USB device.
- */
- struct efi_device_path_usb *udp;
-
- memcpy(buf, &ROOT, sizeof(ROOT));
- buf += sizeof(ROOT);
-
- udp = buf;
- udp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
- udp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_USB;
- udp->dp.length = sizeof(*udp);
- udp->parent_port_number = desc->if_type;
- udp->usb_interface = desc->devnum;
- buf = &udp[1];
-#endif
+ ret = blk_find_device(desc->if_type, desc->devnum, &dev);
+
+ if (ret)
+ dev = desc->bdev->parent;
+ buf = dp_fill(buf, dev);
if (part == 0) /* the actual disk, not a partition */
return buf;
@@ -1051,39 +1018,18 @@ struct efi_device_path *efi_dp_from_uart(void)
#ifdef CONFIG_NET
struct efi_device_path *efi_dp_from_eth(void)
{
-#ifndef CONFIG_DM_ETH
- struct efi_device_path_mac_addr *ndp;
-#endif
void *buf, *start;
unsigned dpsize = 0;
assert(eth_get_dev());
-#ifdef CONFIG_DM_ETH
dpsize += dp_size(eth_get_dev());
-#else
- dpsize += sizeof(ROOT);
- dpsize += sizeof(*ndp);
-#endif
start = buf = dp_alloc(dpsize + sizeof(END));
if (!buf)
return NULL;
-#ifdef CONFIG_DM_ETH
buf = dp_fill(buf, eth_get_dev());
-#else
- memcpy(buf, &ROOT, sizeof(ROOT));
- buf += sizeof(ROOT);
-
- ndp = buf;
- ndp->dp.type = DEVICE_PATH_TYPE_MESSAGING_DEVICE;
- ndp->dp.sub_type = DEVICE_PATH_SUB_TYPE_MSG_MAC_ADDR;
- ndp->dp.length = sizeof(*ndp);
- ndp->if_type = 1; /* Ethernet */
- memcpy(ndp->mac.addr, eth_get_ethaddr(), ARP_HLEN);
- buf = &ndp[1];
-#endif
*((struct efi_device_path *)buf) = END;
@@ -1263,7 +1209,6 @@ ssize_t efi_dp_check_length(const struct efi_device_path *dp,
* initrd location
*
* @lo: EFI_LOAD_OPTION containing a valid device path
- * @size: size of the discovered device path
* @guid: guid to search for
*
* Return:
@@ -1272,7 +1217,7 @@ ssize_t efi_dp_check_length(const struct efi_device_path *dp,
*/
struct
efi_device_path *efi_dp_from_lo(struct efi_load_option *lo,
- efi_uintn_t *size, efi_guid_t guid)
+ const efi_guid_t *guid)
{
struct efi_device_path *fp = lo->file_path;
struct efi_device_path_vendor *vendor;
@@ -1287,10 +1232,37 @@ efi_device_path *efi_dp_from_lo(struct efi_load_option *lo,
continue;
vendor = (struct efi_device_path_vendor *)fp;
- if (!guidcmp(&vendor->guid, &guid))
- return efi_dp_dup(fp);
+ if (!guidcmp(&vendor->guid, guid))
+ return efi_dp_dup(efi_dp_next(fp));
}
log_debug("VenMedia(%pUl) not found in %ls\n", &guid, lo->label);
return NULL;
}
+
+/**
+ * search_gpt_dp_node() - search gpt device path node
+ *
+ * @device_path: device path
+ *
+ * Return: pointer to the gpt device path node
+ */
+struct efi_device_path *search_gpt_dp_node(struct efi_device_path *device_path)
+{
+ struct efi_device_path *dp = device_path;
+
+ while (dp) {
+ if (dp->type == DEVICE_PATH_TYPE_MEDIA_DEVICE &&
+ dp->sub_type == DEVICE_PATH_SUB_TYPE_HARD_DRIVE_PATH) {
+ struct efi_device_path_hard_drive_path *hd_dp =
+ (struct efi_device_path_hard_drive_path *)dp;
+
+ if (hd_dp->partmap_type == PART_FORMAT_GPT &&
+ hd_dp->signature_type == SIG_TYPE_GUID)
+ return dp;
+ }
+ dp = efi_dp_next(dp);
+ }
+
+ return NULL;
+}
diff --git a/lib/efi_loader/efi_disk.c b/lib/efi_loader/efi_disk.c
index 988907ecb91..ef8b5c88ff9 100644
--- a/lib/efi_loader/efi_disk.c
+++ b/lib/efi_loader/efi_disk.c
@@ -555,7 +555,6 @@ efi_status_t efi_disk_register(void)
struct efi_disk_obj *disk;
int disks = 0;
efi_status_t ret;
-#ifdef CONFIG_BLK
struct udevice *dev;
for (uclass_first_device_check(UCLASS_BLK, &dev); dev;
@@ -583,54 +582,7 @@ efi_status_t efi_disk_register(void)
&disk->header, desc, if_typename,
desc->devnum, dev->name);
}
-#else
- int i, if_type;
- /* Search for all available disk devices */
- for (if_type = 0; if_type < IF_TYPE_COUNT; if_type++) {
- const struct blk_driver *cur_drvr;
- const char *if_typename;
-
- cur_drvr = blk_driver_lookup_type(if_type);
- if (!cur_drvr)
- continue;
-
- if_typename = cur_drvr->if_typename;
- log_info("Scanning disks on %s...\n", if_typename);
- for (i = 0; i < 4; i++) {
- struct blk_desc *desc;
- char devname[32] = { 0 }; /* dp->str is u16[32] long */
-
- desc = blk_get_devnum_by_type(if_type, i);
- if (!desc)
- continue;
- if (desc->type == DEV_TYPE_UNKNOWN)
- continue;
-
- snprintf(devname, sizeof(devname), "%s%d",
- if_typename, i);
-
- /* Add block device for the full device */
- ret = efi_disk_add_dev(NULL, NULL, if_typename, desc,
- i, NULL, 0, &disk);
- if (ret == EFI_NOT_READY) {
- log_notice("Disk %s not ready\n", devname);
- continue;
- }
- if (ret) {
- log_err("ERROR: failure to add disk device %s, r = %lu\n",
- devname, ret & ~EFI_ERROR_MASK);
- return ret;
- }
- disks++;
-
- /* Partitions show up as block devices in EFI */
- disks += efi_disk_create_partitions
- (&disk->header, desc,
- if_typename, i, devname);
- }
- }
-#endif
log_info("Found %d disks\n", disks);
return EFI_SUCCESS;
diff --git a/lib/efi_loader/efi_helper.c b/lib/efi_loader/efi_helper.c
index d03a7364615..b80a6e07dff 100644
--- a/lib/efi_loader/efi_helper.c
+++ b/lib/efi_loader/efi_helper.c
@@ -13,6 +13,11 @@
#include <efi_loader.h>
#include <efi_variable.h>
+#if defined(CONFIG_CMD_EFIDEBUG) || defined(CONFIG_EFI_LOAD_FILE2_INITRD)
+/* GUID used by Linux to identify the LoadFile2 protocol with the initrd */
+const efi_guid_t efi_lf2_initrd_guid = EFI_INITRD_MEDIA_GUID;
+#endif
+
/**
* efi_create_current_boot_var() - Return Boot#### name were #### is replaced by
* the value of BootCurrent
@@ -63,10 +68,8 @@ out:
*/
struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t guid)
{
- struct efi_device_path *file_path = NULL;
- struct efi_device_path *tmp = NULL;
struct efi_load_option lo;
- void *var_value = NULL;
+ void *var_value;
efi_uintn_t size;
efi_status_t ret;
u16 var_name[16];
@@ -81,18 +84,11 @@ struct efi_device_path *efi_get_dp_from_boot(const efi_guid_t guid)
ret = efi_deserialize_load_option(&lo, var_value, &size);
if (ret != EFI_SUCCESS)
- goto out;
-
- tmp = efi_dp_from_lo(&lo, &size, guid);
- if (!tmp)
- goto out;
+ goto err;
- /* efi_dp_dup will just return NULL if efi_dp_next is NULL */
- file_path = efi_dp_dup(efi_dp_next(tmp));
+ return efi_dp_from_lo(&lo, &guid);
-out:
- efi_free_pool(tmp);
+err:
free(var_value);
-
- return file_path;
+ return NULL;
}
diff --git a/lib/efi_loader/efi_image_loader.c b/lib/efi_loader/efi_image_loader.c
index e9572d4d5db..eb95580538c 100644
--- a/lib/efi_loader/efi_image_loader.c
+++ b/lib/efi_loader/efi_image_loader.c
@@ -898,9 +898,9 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
image_base = opt->ImageBase;
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
handle->image_type = opt->Subsystem;
- virt_size = ALIGN(virt_size, opt->SectionAlignment);
- efi_reloc = efi_alloc(virt_size,
- loaded_image_info->image_code_type);
+ efi_reloc = efi_alloc_aligned_pages(virt_size,
+ loaded_image_info->image_code_type,
+ opt->SectionAlignment);
if (!efi_reloc) {
log_err("Out of memory\n");
ret = EFI_OUT_OF_RESOURCES;
@@ -914,9 +914,9 @@ efi_status_t efi_load_pe(struct efi_loaded_image_obj *handle,
image_base = opt->ImageBase;
efi_set_code_and_data_type(loaded_image_info, opt->Subsystem);
handle->image_type = opt->Subsystem;
- virt_size = ALIGN(virt_size, opt->SectionAlignment);
- efi_reloc = efi_alloc(virt_size,
- loaded_image_info->image_code_type);
+ efi_reloc = efi_alloc_aligned_pages(virt_size,
+ loaded_image_info->image_code_type,
+ opt->SectionAlignment);
if (!efi_reloc) {
log_err("Out of memory\n");
ret = EFI_OUT_OF_RESOURCES;
diff --git a/lib/efi_loader/efi_load_initrd.c b/lib/efi_loader/efi_load_initrd.c
index e2a80630230..c5e6652e664 100644
--- a/lib/efi_loader/efi_load_initrd.c
+++ b/lib/efi_loader/efi_load_initrd.c
@@ -52,7 +52,6 @@ static efi_handle_t efi_initrd_handle;
*/
static efi_status_t get_initrd_fp(struct efi_device_path **initrd_fp)
{
- const efi_guid_t lf2_initrd_guid = EFI_INITRD_MEDIA_GUID;
struct efi_device_path *dp = NULL;
/*
@@ -65,7 +64,7 @@ static efi_status_t get_initrd_fp(struct efi_device_path **initrd_fp)
* We can then use this specific return value and not install the
* protocol, while allowing the boot to continue
*/
- dp = efi_get_dp_from_boot(lf2_initrd_guid);
+ dp = efi_get_dp_from_boot(efi_lf2_initrd_guid);
if (!dp)
return EFI_INVALID_PARAMETER;
diff --git a/lib/efi_loader/efi_memory.c b/lib/efi_loader/efi_memory.c
index f4acbee4f9b..7f0b5072819 100644
--- a/lib/efi_loader/efi_memory.c
+++ b/lib/efi_loader/efi_memory.c
@@ -550,6 +550,58 @@ efi_status_t efi_free_pages(uint64_t memory, efi_uintn_t pages)
}
/**
+ * efi_alloc_aligned_pages - allocate
+ *
+ * @len: len in bytes
+ * @memory_type: usage type of the allocated memory
+ * @align: alignment in bytes
+ * Return: aligned memory or NULL
+ */
+void *efi_alloc_aligned_pages(u64 len, int memory_type, size_t align)
+{
+ u64 req_pages = efi_size_in_pages(len);
+ u64 true_pages = req_pages + efi_size_in_pages(align) - 1;
+ u64 free_pages;
+ u64 aligned_mem;
+ efi_status_t r;
+ u64 mem;
+
+ /* align must be zero or a power of two */
+ if (align & (align - 1))
+ return NULL;
+
+ /* Check for overflow */
+ if (true_pages < req_pages)
+ return NULL;
+
+ if (align < EFI_PAGE_SIZE) {
+ r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, memory_type,
+ req_pages, &mem);
+ return (r == EFI_SUCCESS) ? (void *)(uintptr_t)mem : NULL;
+ }
+
+ r = efi_allocate_pages(EFI_ALLOCATE_ANY_PAGES, memory_type,
+ true_pages, &mem);
+ if (r != EFI_SUCCESS)
+ return NULL;
+
+ aligned_mem = ALIGN(mem, align);
+ /* Free pages before alignment */
+ free_pages = efi_size_in_pages(aligned_mem - mem);
+ if (free_pages)
+ efi_free_pages(mem, free_pages);
+
+ /* Free trailing pages */
+ free_pages = true_pages - (req_pages + free_pages);
+ if (free_pages) {
+ mem = aligned_mem + req_pages * EFI_PAGE_SIZE;
+ efi_free_pages(mem, free_pages);
+ }
+
+ return (void *)(uintptr_t)aligned_mem;
+}
+
+/**
* efi_allocate_pool - allocate memory from pool
*
* @pool_type: type of the pool from which memory is to be allocated
diff --git a/lib/efi_loader/efi_signature.c b/lib/efi_loader/efi_signature.c
index bdd09881fc9..6e3ee3c0c00 100644
--- a/lib/efi_loader/efi_signature.c
+++ b/lib/efi_loader/efi_signature.c
@@ -7,6 +7,7 @@
#include <common.h>
#include <charset.h>
#include <efi_loader.h>
+#include <efi_variable.h>
#include <image.h>
#include <hexdump.h>
#include <malloc.h>
@@ -740,44 +741,15 @@ err:
*/
struct efi_signature_store *efi_sigstore_parse_sigdb(u16 *name)
{
- struct efi_signature_store *sigstore = NULL;
const efi_guid_t *vendor;
void *db;
efi_uintn_t db_size;
- efi_status_t ret;
-
- if (!u16_strcmp(name, L"PK") || !u16_strcmp(name, L"KEK")) {
- vendor = &efi_global_variable_guid;
- } else if (!u16_strcmp(name, L"db") || !u16_strcmp(name, L"dbx")) {
- vendor = &efi_guid_image_security_database;
- } else {
- EFI_PRINT("unknown signature database, %ls\n", name);
- return NULL;
- }
-
- /* retrieve variable data */
- db_size = 0;
- ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, NULL));
- if (ret == EFI_NOT_FOUND) {
- EFI_PRINT("variable, %ls, not found\n", name);
- sigstore = calloc(sizeof(*sigstore), 1);
- return sigstore;
- } else if (ret != EFI_BUFFER_TOO_SMALL) {
- EFI_PRINT("Getting variable, %ls, failed\n", name);
- return NULL;
- }
- db = malloc(db_size);
+ vendor = efi_auth_var_get_guid(name);
+ db = efi_get_var(name, vendor, &db_size);
if (!db) {
- EFI_PRINT("Out of memory\n");
- return NULL;
- }
-
- ret = EFI_CALL(efi_get_variable(name, vendor, NULL, &db_size, db));
- if (ret != EFI_SUCCESS) {
- EFI_PRINT("Getting variable, %ls, failed\n", name);
- free(db);
- return NULL;
+ EFI_PRINT("variable, %ls, not found\n", name);
+ return calloc(sizeof(struct efi_signature_store), 1);
}
return efi_build_signature_store(db, db_size);
diff --git a/lib/efi_loader/efi_smbios.c b/lib/efi_loader/efi_smbios.c
index 2eb4cb1c1af..fc0b23397cf 100644
--- a/lib/efi_loader/efi_smbios.c
+++ b/lib/efi_loader/efi_smbios.c
@@ -13,8 +13,6 @@
#include <mapmem.h>
#include <smbios.h>
-static const efi_guid_t smbios_guid = SMBIOS_TABLE_GUID;
-
/*
* Install the SMBIOS table as a configuration table.
*
diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c
index 74f0bef2396..189e4a5ba59 100644
--- a/lib/efi_loader/efi_tcg2.c
+++ b/lib/efi_loader/efi_tcg2.c
@@ -11,16 +11,19 @@
#include <common.h>
#include <dm.h>
#include <efi_loader.h>
+#include <efi_variable.h>
#include <efi_tcg2.h>
#include <log.h>
#include <malloc.h>
+#include <smbios.h>
#include <version_string.h>
#include <tpm-v2.h>
#include <u-boot/hash-checksum.h>
#include <u-boot/sha1.h>
#include <u-boot/sha256.h>
#include <u-boot/sha512.h>
-#include <linux/unaligned/access_ok.h>
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/le_byteshift.h>
#include <linux/unaligned/generic.h>
#include <hexdump.h>
@@ -80,16 +83,21 @@ static const struct digest_info hash_algo_list[] = {
};
struct variable_info {
- u16 *name;
- const efi_guid_t *guid;
+ const u16 *name;
+ bool accept_empty;
+ u32 pcr_index;
};
static struct variable_info secure_variables[] = {
- {L"SecureBoot", &efi_global_variable_guid},
- {L"PK", &efi_global_variable_guid},
- {L"KEK", &efi_global_variable_guid},
- {L"db", &efi_guid_image_security_database},
- {L"dbx", &efi_guid_image_security_database},
+ {u"SecureBoot", true, 7},
+ {u"PK", true, 7},
+ {u"KEK", true, 7},
+ {u"db", true, 7},
+ {u"dbx", true, 7},
+ {u"dbt", false, 7},
+ {u"dbr", false, 7},
+ {u"DeployedMode", false, 1},
+ {u"AuditMode", false, 1},
};
#define MAX_HASH_COUNT ARRAY_SIZE(hash_algo_list)
@@ -1026,13 +1034,39 @@ out:
* Return: status code
*/
static efi_status_t EFIAPI
-efi_tcg2_submit_command(__maybe_unused struct efi_tcg2_protocol *this,
- u32 __maybe_unused input_param_block_size,
- u8 __maybe_unused *input_param_block,
- u32 __maybe_unused output_param_block_size,
- u8 __maybe_unused *output_param_block)
+efi_tcg2_submit_command(struct efi_tcg2_protocol *this,
+ u32 input_param_block_size,
+ u8 *input_param_block,
+ u32 output_param_block_size,
+ u8 *output_param_block)
{
- return EFI_UNSUPPORTED;
+ struct udevice *dev;
+ efi_status_t ret;
+ u32 rc;
+ size_t resp_buf_size = output_param_block_size;
+
+ EFI_ENTRY("%p, %u, %p, %u, %p", this, input_param_block_size,
+ input_param_block, output_param_block_size, output_param_block);
+
+ if (!this || !input_param_block || !input_param_block_size) {
+ ret = EFI_INVALID_PARAMETER;
+ goto out;
+ }
+
+ ret = platform_get_tpm2_device(&dev);
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+ rc = tpm2_submit_command(dev, input_param_block,
+ output_param_block, &resp_buf_size);
+ if (rc) {
+ ret = (rc == -ENOSPC) ? EFI_OUT_OF_RESOURCES : EFI_DEVICE_ERROR;
+
+ goto out;
+ }
+
+out:
+ return EFI_EXIT(ret);
}
/**
@@ -1366,7 +1400,7 @@ static efi_status_t efi_append_scrtm_version(struct udevice *dev)
* Return: status code
*/
static efi_status_t tcg2_measure_variable(struct udevice *dev, u32 pcr_index,
- u32 event_type, u16 *var_name,
+ u32 event_type, const u16 *var_name,
const efi_guid_t *guid,
efi_uintn_t data_size, u8 *data)
{
@@ -1418,8 +1452,8 @@ static efi_status_t tcg2_measure_boot_variable(struct udevice *dev)
boot_order = efi_get_var(var_name, &efi_global_variable_guid,
&var_data_size);
if (!boot_order) {
- ret = EFI_NOT_FOUND;
- goto error;
+ /* If "BootOrder" is not defined, skip the boot variable measurement */
+ return EFI_SUCCESS;
}
ret = tcg2_measure_variable(dev, 1, EV_EFI_VARIABLE_BOOT2, var_name,
@@ -1457,16 +1491,232 @@ error:
}
/**
+ * tcg2_measure_smbios() - measure smbios table
+ *
+ * @dev: TPM device
+ * @entry: pointer to the smbios_entry structure
+ *
+ * Return: status code
+ */
+static efi_status_t
+tcg2_measure_smbios(struct udevice *dev,
+ const struct smbios_entry *entry)
+{
+ efi_status_t ret;
+ struct smbios_header *smbios_copy;
+ struct smbios_handoff_table_pointers2 *event = NULL;
+ u32 event_size;
+
+ /*
+ * TCG PC Client PFP Spec says
+ * "SMBIOS structures that contain static configuration information
+ * (e.g. Platform Manufacturer Enterprise Number assigned by IANA,
+ * platform model number, Vendor and Device IDs for each SMBIOS table)
+ * that is relevant to the security of the platform MUST be measured".
+ * Device dependent parameters such as serial number are cleared to
+ * zero or spaces for the measurement.
+ */
+ event_size = sizeof(struct smbios_handoff_table_pointers2) +
+ FIELD_SIZEOF(struct efi_configuration_table, guid) +
+ entry->struct_table_length;
+ event = calloc(1, event_size);
+ if (!event) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto out;
+ }
+
+ event->table_description_size = sizeof(SMBIOS_HANDOFF_TABLE_DESC);
+ memcpy(event->table_description, SMBIOS_HANDOFF_TABLE_DESC,
+ sizeof(SMBIOS_HANDOFF_TABLE_DESC));
+ put_unaligned_le64(1, &event->number_of_tables);
+ guidcpy(&event->table_entry[0].guid, &smbios_guid);
+ smbios_copy = (struct smbios_header *)((uintptr_t)&event->table_entry[0].table);
+ memcpy(&event->table_entry[0].table,
+ (void *)((uintptr_t)entry->struct_table_address),
+ entry->struct_table_length);
+
+ smbios_prepare_measurement(entry, smbios_copy);
+
+ ret = tcg2_measure_event(dev, 1, EV_EFI_HANDOFF_TABLES2, event_size,
+ (u8 *)event);
+ if (ret != EFI_SUCCESS)
+ goto out;
+
+out:
+ free(event);
+
+ return ret;
+}
+
+/**
+ * find_smbios_table() - find smbios table
+ *
+ * Return: pointer to the smbios table
+ */
+static void *find_smbios_table(void)
+{
+ u32 i;
+
+ for (i = 0; i < systab.nr_tables; i++) {
+ if (!guidcmp(&smbios_guid, &systab.tables[i].guid))
+ return systab.tables[i].table;
+ }
+
+ return NULL;
+}
+
+/**
+ * tcg2_measure_gpt_table() - measure gpt table
+ *
+ * @dev: TPM device
+ * @loaded_image: handle to the loaded image
+ *
+ * Return: status code
+ */
+static efi_status_t
+tcg2_measure_gpt_data(struct udevice *dev,
+ struct efi_loaded_image_obj *loaded_image)
+{
+ efi_status_t ret;
+ efi_handle_t handle;
+ struct efi_handler *dp_handler;
+ struct efi_device_path *orig_device_path;
+ struct efi_device_path *device_path;
+ struct efi_device_path *dp;
+ struct efi_block_io *block_io;
+ struct efi_gpt_data *event = NULL;
+ efi_guid_t null_guid = NULL_GUID;
+ gpt_header *gpt_h;
+ gpt_entry *entry = NULL;
+ gpt_entry *gpt_e;
+ u32 num_of_valid_entry = 0;
+ u32 event_size;
+ u32 i;
+ u32 total_gpt_entry_size;
+
+ ret = efi_search_protocol(&loaded_image->header,
+ &efi_guid_loaded_image_device_path,
+ &dp_handler);
+ if (ret != EFI_SUCCESS)
+ return ret;
+
+ orig_device_path = dp_handler->protocol_interface;
+ if (!orig_device_path) /* no device path, skip GPT measurement */
+ return EFI_SUCCESS;
+
+ device_path = efi_dp_dup(orig_device_path);
+ if (!device_path)
+ return EFI_OUT_OF_RESOURCES;
+
+ dp = search_gpt_dp_node(device_path);
+ if (!dp) {
+ /* no GPT device path node found, skip GPT measurement */
+ ret = EFI_SUCCESS;
+ goto out1;
+ }
+
+ /* read GPT header */
+ dp->type = DEVICE_PATH_TYPE_END;
+ dp->sub_type = DEVICE_PATH_SUB_TYPE_END;
+ dp = device_path;
+ ret = EFI_CALL(systab.boottime->locate_device_path(&efi_block_io_guid,
+ &dp, &handle));
+ if (ret != EFI_SUCCESS)
+ goto out1;
+
+ ret = EFI_CALL(efi_handle_protocol(handle,
+ &efi_block_io_guid, (void **)&block_io));
+ if (ret != EFI_SUCCESS)
+ goto out1;
+
+ gpt_h = memalign(block_io->media->io_align, block_io->media->block_size);
+ if (!gpt_h) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto out2;
+ }
+
+ ret = block_io->read_blocks(block_io, block_io->media->media_id, 1,
+ block_io->media->block_size, gpt_h);
+ if (ret != EFI_SUCCESS)
+ goto out2;
+
+ /* read GPT entry */
+ total_gpt_entry_size = gpt_h->num_partition_entries *
+ gpt_h->sizeof_partition_entry;
+ entry = memalign(block_io->media->io_align, total_gpt_entry_size);
+ if (!entry) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto out2;
+ }
+
+ ret = block_io->read_blocks(block_io, block_io->media->media_id,
+ gpt_h->partition_entry_lba,
+ total_gpt_entry_size, entry);
+ if (ret != EFI_SUCCESS)
+ goto out2;
+
+ /* count valid GPT entry */
+ gpt_e = entry;
+ for (i = 0; i < gpt_h->num_partition_entries; i++) {
+ if (guidcmp(&null_guid, &gpt_e->partition_type_guid))
+ num_of_valid_entry++;
+
+ gpt_e = (gpt_entry *)((u8 *)gpt_e + gpt_h->sizeof_partition_entry);
+ }
+
+ /* prepare event data for measurement */
+ event_size = sizeof(struct efi_gpt_data) +
+ (num_of_valid_entry * gpt_h->sizeof_partition_entry);
+ event = calloc(1, event_size);
+ if (!event) {
+ ret = EFI_OUT_OF_RESOURCES;
+ goto out2;
+ }
+ memcpy(event, gpt_h, sizeof(gpt_header));
+ put_unaligned_le64(num_of_valid_entry, &event->number_of_partitions);
+
+ /* copy valid GPT entry */
+ gpt_e = entry;
+ num_of_valid_entry = 0;
+ for (i = 0; i < gpt_h->num_partition_entries; i++) {
+ if (guidcmp(&null_guid, &gpt_e->partition_type_guid)) {
+ memcpy((u8 *)event->partitions +
+ (num_of_valid_entry * gpt_h->sizeof_partition_entry),
+ gpt_e, gpt_h->sizeof_partition_entry);
+ num_of_valid_entry++;
+ }
+
+ gpt_e = (gpt_entry *)((u8 *)gpt_e + gpt_h->sizeof_partition_entry);
+ }
+
+ ret = tcg2_measure_event(dev, 5, EV_EFI_GPT_EVENT, event_size, (u8 *)event);
+ if (ret != EFI_SUCCESS)
+ goto out2;
+
+out2:
+ EFI_CALL(efi_close_protocol((efi_handle_t)block_io, &efi_block_io_guid,
+ NULL, NULL));
+ free(gpt_h);
+ free(entry);
+ free(event);
+out1:
+ efi_free_pool(device_path);
+
+ return ret;
+}
+
+/**
* efi_tcg2_measure_efi_app_invocation() - measure efi app invocation
*
* Return: status code
*/
-efi_status_t efi_tcg2_measure_efi_app_invocation(void)
+efi_status_t efi_tcg2_measure_efi_app_invocation(struct efi_loaded_image_obj *handle)
{
efi_status_t ret;
u32 pcr_index;
struct udevice *dev;
u32 event = 0;
+ struct smbios_entry *entry;
if (tcg2_efi_app_invoked)
return EFI_SUCCESS;
@@ -1485,6 +1735,17 @@ efi_status_t efi_tcg2_measure_efi_app_invocation(void)
if (ret != EFI_SUCCESS)
goto out;
+ entry = (struct smbios_entry *)find_smbios_table();
+ if (entry) {
+ ret = tcg2_measure_smbios(dev, entry);
+ if (ret != EFI_SUCCESS)
+ goto out;
+ }
+
+ ret = tcg2_measure_gpt_data(dev, handle);
+ if (ret != EFI_SUCCESS)
+ goto out;
+
for (pcr_index = 0; pcr_index <= 7; pcr_index++) {
ret = tcg2_measure_event(dev, pcr_index, EV_SEPARATOR,
sizeof(event), (u8 *)&event);
@@ -1591,54 +1852,38 @@ static efi_status_t tcg2_measure_secure_boot_variable(struct udevice *dev)
efi_uintn_t data_size;
u32 count, i;
efi_status_t ret;
+ u8 deployed_mode;
+ efi_uintn_t size;
+ u32 deployed_audit_pcr_index = 1;
+
+ size = sizeof(deployed_mode);
+ ret = efi_get_variable_int(u"DeployedMode", &efi_global_variable_guid,
+ NULL, &size, &deployed_mode, NULL);
+ if (ret != EFI_SUCCESS || !deployed_mode)
+ deployed_audit_pcr_index = 7;
count = ARRAY_SIZE(secure_variables);
for (i = 0; i < count; i++) {
- /*
- * According to the TCG2 PC Client PFP spec, "SecureBoot",
- * "PK", "KEK", "db" and "dbx" variables must be measured
- * even if they are empty.
- */
- data = efi_get_var(secure_variables[i].name,
- secure_variables[i].guid,
- &data_size);
+ const efi_guid_t *guid;
- ret = tcg2_measure_variable(dev, 7,
- EV_EFI_VARIABLE_DRIVER_CONFIG,
- secure_variables[i].name,
- secure_variables[i].guid,
- data_size, data);
- free(data);
- if (ret != EFI_SUCCESS)
- goto error;
- }
+ guid = efi_auth_var_get_guid(secure_variables[i].name);
- /*
- * TCG2 PC Client PFP spec says "dbt" and "dbr" are
- * measured if present and not empty.
- */
- data = efi_get_var(L"dbt",
- &efi_guid_image_security_database,
- &data_size);
- if (data) {
- ret = tcg2_measure_variable(dev, 7,
- EV_EFI_VARIABLE_DRIVER_CONFIG,
- L"dbt",
- &efi_guid_image_security_database,
- data_size, data);
- free(data);
- }
+ data = efi_get_var(secure_variables[i].name, guid, &data_size);
+ if (!data && !secure_variables[i].accept_empty)
+ continue;
- data = efi_get_var(L"dbr",
- &efi_guid_image_security_database,
- &data_size);
- if (data) {
- ret = tcg2_measure_variable(dev, 7,
+ if (u16_strcmp(u"DeployedMode", secure_variables[i].name))
+ secure_variables[i].pcr_index = deployed_audit_pcr_index;
+ if (u16_strcmp(u"AuditMode", secure_variables[i].name))
+ secure_variables[i].pcr_index = deployed_audit_pcr_index;
+
+ ret = tcg2_measure_variable(dev, secure_variables[i].pcr_index,
EV_EFI_VARIABLE_DRIVER_CONFIG,
- L"dbr",
- &efi_guid_image_security_database,
+ secure_variables[i].name, guid,
data_size, data);
free(data);
+ if (ret != EFI_SUCCESS)
+ goto error;
}
error:
diff --git a/lib/efi_loader/efi_var_common.c b/lib/efi_loader/efi_var_common.c
index a00bbf16206..3cbb7c96c2e 100644
--- a/lib/efi_loader/efi_var_common.c
+++ b/lib/efi_loader/efi_var_common.c
@@ -374,7 +374,8 @@ bool efi_secure_boot_enabled(void)
return efi_secure_boot;
}
-enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid)
+enum efi_auth_var_type efi_auth_var_get_type(const u16 *name,
+ const efi_guid_t *guid)
{
for (size_t i = 0; i < ARRAY_SIZE(name_type); ++i) {
if (!u16_strcmp(name, name_type[i].name) &&
@@ -384,6 +385,15 @@ enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid)
return EFI_AUTH_VAR_NONE;
}
+const efi_guid_t *efi_auth_var_get_guid(const u16 *name)
+{
+ for (size_t i = 0; i < ARRAY_SIZE(name_type); ++i) {
+ if (!u16_strcmp(name, name_type[i].name))
+ return name_type[i].guid;
+ }
+ return &efi_global_variable_guid;
+}
+
/**
* efi_get_var() - read value of an EFI variable
*
@@ -393,7 +403,7 @@ enum efi_auth_var_type efi_auth_var_get_type(u16 *name, const efi_guid_t *guid)
*
* Return: buffer with variable data or NULL
*/
-void *efi_get_var(u16 *name, const efi_guid_t *vendor, efi_uintn_t *size)
+void *efi_get_var(const u16 *name, const efi_guid_t *vendor, efi_uintn_t *size)
{
efi_status_t ret;
void *buf = NULL;
diff --git a/lib/efi_loader/efi_var_file.c b/lib/efi_loader/efi_var_file.c
index c7c6805ed05..76a2ff9e412 100644
--- a/lib/efi_loader/efi_var_file.c
+++ b/lib/efi_loader/efi_var_file.c
@@ -19,6 +19,13 @@
#define PART_STR_LEN 10
+/* GUID used by Shim to store the MOK database */
+#define SHIM_LOCK_GUID \
+ EFI_GUID(0x605dab50, 0xe046, 0x4300, \
+ 0xab, 0xb6, 0x3d, 0xd8, 0x10, 0xdd, 0x8b, 0x23)
+
+static const efi_guid_t shim_lock_guid = SHIM_LOCK_GUID;
+
/**
* efi_set_blk_dev_to_system_partition() - select EFI system partition
*
@@ -175,6 +182,7 @@ efi_status_t efi_var_restore(struct efi_var_file *buf, bool safe)
if (!safe &&
(efi_auth_var_get_type(var->name, &var->guid) !=
EFI_AUTH_VAR_NONE ||
+ !guidcmp(&var->guid, &shim_lock_guid) ||
!(var->attr & EFI_VARIABLE_NON_VOLATILE)))
continue;
if (!var->length)
diff --git a/lib/efi_loader/efi_var_mem.c b/lib/efi_loader/efi_var_mem.c
index 3d335a82746..13909b1d263 100644
--- a/lib/efi_loader/efi_var_mem.c
+++ b/lib/efi_loader/efi_var_mem.c
@@ -134,7 +134,7 @@ void __efi_runtime efi_var_mem_del(struct efi_var_entry *var)
}
efi_status_t __efi_runtime efi_var_mem_ins(
- u16 *variable_name,
+ const u16 *variable_name,
const efi_guid_t *vendor, u32 attributes,
const efi_uintn_t size1, const void *data1,
const efi_uintn_t size2, const void *data2,
@@ -274,8 +274,9 @@ efi_status_t efi_var_mem_init(void)
}
efi_status_t __efi_runtime
-efi_get_variable_mem(u16 *variable_name, const efi_guid_t *vendor, u32 *attributes,
- efi_uintn_t *data_size, void *data, u64 *timep)
+efi_get_variable_mem(const u16 *variable_name, const efi_guid_t *vendor,
+ u32 *attributes, efi_uintn_t *data_size, void *data,
+ u64 *timep)
{
efi_uintn_t old_size;
struct efi_var_entry *var;
diff --git a/lib/efi_loader/efi_variable.c b/lib/efi_loader/efi_variable.c
index fa2b6bc7a86..5adc7f821a8 100644
--- a/lib/efi_loader/efi_variable.c
+++ b/lib/efi_loader/efi_variable.c
@@ -45,7 +45,7 @@
*
* Return: status code
*/
-static efi_status_t efi_variable_authenticate(u16 *variable,
+static efi_status_t efi_variable_authenticate(const u16 *variable,
const efi_guid_t *vendor,
efi_uintn_t *data_size,
const void **data, u32 given_attr,
@@ -194,7 +194,7 @@ err:
return ret;
}
#else
-static efi_status_t efi_variable_authenticate(u16 *variable,
+static efi_status_t efi_variable_authenticate(const u16 *variable,
const efi_guid_t *vendor,
efi_uintn_t *data_size,
const void **data, u32 given_attr,
@@ -205,7 +205,7 @@ static efi_status_t efi_variable_authenticate(u16 *variable,
#endif /* CONFIG_EFI_SECURE_BOOT */
efi_status_t __efi_runtime
-efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_get_variable_int(const u16 *variable_name, const efi_guid_t *vendor,
u32 *attributes, efi_uintn_t *data_size, void *data,
u64 *timep)
{
@@ -219,7 +219,8 @@ efi_get_next_variable_name_int(efi_uintn_t *variable_name_size,
return efi_get_next_variable_name_mem(variable_name_size, variable_name, vendor);
}
-efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_status_t efi_set_variable_int(const u16 *variable_name,
+ const efi_guid_t *vendor,
u32 attributes, efi_uintn_t data_size,
const void *data, bool ro_check)
{
diff --git a/lib/efi_loader/efi_variable_tee.c b/lib/efi_loader/efi_variable_tee.c
index 51920bcb51a..281f886124a 100644
--- a/lib/efi_loader/efi_variable_tee.c
+++ b/lib/efi_loader/efi_variable_tee.c
@@ -284,7 +284,8 @@ out:
* StMM can store internal attributes and properties for variables, i.e enabling
* R/O variables
*/
-static efi_status_t set_property_int(u16 *variable_name, efi_uintn_t name_size,
+static efi_status_t set_property_int(const u16 *variable_name,
+ efi_uintn_t name_size,
const efi_guid_t *vendor,
struct var_check_property *var_property)
{
@@ -317,7 +318,8 @@ out:
return ret;
}
-static efi_status_t get_property_int(u16 *variable_name, efi_uintn_t name_size,
+static efi_status_t get_property_int(const u16 *variable_name,
+ efi_uintn_t name_size,
const efi_guid_t *vendor,
struct var_check_property *var_property)
{
@@ -361,7 +363,8 @@ out:
return ret;
}
-efi_status_t efi_get_variable_int(u16 *variable_name, const efi_guid_t *vendor,
+efi_status_t efi_get_variable_int(const u16 *variable_name,
+ const efi_guid_t *vendor,
u32 *attributes, efi_uintn_t *data_size,
void *data, u64 *timep)
{
@@ -502,9 +505,10 @@ out:
return ret;
}
-efi_status_t efi_set_variable_int(u16 *variable_name, const efi_guid_t *vendor,
- u32 attributes, efi_uintn_t data_size,
- const void *data, bool ro_check)
+efi_status_t efi_set_variable_int(const u16 *variable_name,
+ const efi_guid_t *vendor, u32 attributes,
+ efi_uintn_t data_size, const void *data,
+ bool ro_check)
{
efi_status_t ret, alt_ret = EFI_SUCCESS;
struct var_check_property var_property;
diff --git a/lib/efi_selftest/efi_miniapp_tcg2_arm.h b/lib/efi_selftest/efi_miniapp_tcg2_arm.h
new file mode 100644
index 00000000000..bddd78289a4
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_arm.h
@@ -0,0 +1,153 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * This file contains a precompiled EFI binary built from
+ * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include
+ * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL.
+ * The precompiled form is needed to avoid the problem of reproducible builds.
+ */
+
+#define EFI_ST_DISK_IMG { 0x00000570, { \
+ {0x00000000, "\x4d\x5a\x00\x00\x00\x00\x00\x00"}, /* MZ...... */ \
+ {0x00000038, "\x00\x00\x00\x00\x40\x00\x00\x00"}, /* ....@... */ \
+ {0x00000040, "\x50\x45\x00\x00\xc2\x01\x02\x00"}, /* PE...... */ \
+ {0x00000050, "\x00\x00\x00\x00\x90\x00\x0e\x03"}, /* ........ */ \
+ {0x00000058, "\x0b\x01\x02\x14\x38\x04\x00\x00"}, /* ....8... */ \
+ {0x00000068, "\x38\x01\x00\x00\x38\x01\x00\x00"}, /* 8...8... */ \
+ {0x00000078, "\x20\x00\x00\x00\x08\x00\x00\x00"}, /* ....... */ \
+ {0x00000090, "\x70\x05\x00\x00\x38\x01\x00\x00"}, /* p...8... */ \
+ {0x00000098, "\x00\x00\x00\x00\x0a\x00\x00\x00"}, /* ........ */ \
+ {0x000000b0, "\x00\x00\x00\x00\x06\x00\x00\x00"}, /* ........ */ \
+ {0x000000e8, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \
+ {0x00000108, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \
+ {0x00000110, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \
+ {0x00000118, "\x38\x04\x00\x00\x38\x01\x00\x00"}, /* 8...8... */ \
+ {0x00000120, "\x38\x04\x00\x00\x38\x01\x00\x00"}, /* 8...8... */ \
+ {0x00000130, "\x00\x00\x00\x00\x20\x00\x50\xe0"}, /* .... .P. */ \
+ {0x00000138, "\x07\x40\x2d\xe9\x24\x10\x8f\xe2"}, /* .@-.$... */ \
+ {0x00000140, "\x00\x00\x91\xe5\x01\x10\x80\xe0"}, /* ........ */ \
+ {0x00000148, "\x15\x0e\x4f\xe2\x5a\x00\x00\xeb"}, /* ..O.Z... */ \
+ {0x00000150, "\x00\x00\x30\xe3\x01\x00\x00\x1a"}, /* ..0..... */ \
+ {0x00000158, "\x03\x00\x9d\xe8\x2e\x00\x00\xeb"}, /* ........ */ \
+ {0x00000160, "\x0c\xd0\x8d\xe2\x04\xf0\x9d\xe4"}, /* ........ */ \
+ {0x00000168, "\xa8\x03\x00\x00\x02\x30\xa0\xe3"}, /* .....0.. */ \
+ {0x00000170, "\x30\x40\x2d\xe9\x14\xd0\x4d\xe2"}, /* 0@-...M. */ \
+ {0x00000178, "\x3c\x20\x91\xe5\x2c\x50\x91\xe5"}, /* < ..,P.. */ \
+ {0x00000180, "\x04\x30\x8d\xe5\x00\x30\xa0\xe3"}, /* .0...0.. */ \
+ {0x00000188, "\x7c\x10\x9f\xe5\x00\x30\x8d\xe5"}, /* |....0.. */ \
+ {0x00000190, "\x98\x40\x92\xe5\x01\x10\x8f\xe0"}, /* .@...... */ \
+ {0x00000198, "\x0c\x20\x8d\xe2\x34\xff\x2f\xe1"}, /* . ..4./. */ \
+ {0x000001a0, "\x00\x40\x50\xe2\x07\x00\x00\x0a"}, /* .@P..... */ \
+ {0x000001a8, "\x60\x10\x9f\xe5\x05\x00\xa0\xe1"}, /* `....... */ \
+ {0x000001b0, "\x04\x30\x95\xe5\x01\x10\x8f\xe0"}, /* .0...... */ \
+ {0x000001b8, "\x33\xff\x2f\xe1\x04\x00\xa0\xe1"}, /* 3./..... */ \
+ {0x000001c0, "\x14\xd0\x8d\xe2\x30\x80\xbd\xe8"}, /* ....0... */ \
+ {0x000001c8, "\x0c\x10\x9d\xe5\x40\x20\x9f\xe5"}, /* ....@ .. */ \
+ {0x000001d0, "\x20\x30\x91\xe5\x02\x20\x8f\xe0"}, /* 0... .. */ \
+ {0x000001d8, "\x02\x00\x53\xe1\x03\x00\x00\x8a"}, /* ..S..... */ \
+ {0x000001e0, "\x28\x10\x91\xe5\x01\x30\x83\xe0"}, /* (....0.. */ \
+ {0x000001e8, "\x02\x00\x53\xe1\xf2\xff\xff\x8a"}, /* ..S..... */ \
+ {0x000001f0, "\x20\x10\x9f\xe5\x05\x00\xa0\xe1"}, /* ....... */ \
+ {0x000001f8, "\x04\x30\x95\xe5\x01\x10\x8f\xe0"}, /* .0...... */ \
+ {0x00000200, "\x33\xff\x2f\xe1\x3a\x41\xa0\xe3"}, /* 3./.:A.. */ \
+ {0x00000208, "\xeb\xff\xff\xea\xac\x03\x00\x00"}, /* ........ */ \
+ {0x00000210, "\x34\x02\x00\x00\x90\xff\xff\xff"}, /* 4....... */ \
+ {0x00000218, "\x36\x02\x00\x00\xf0\x40\x2d\xe9"}, /* 6....@-. */ \
+ {0x00000220, "\x14\xd0\x4d\xe2\x0d\x70\xa0\xe1"}, /* ..M..p.. */ \
+ {0x00000228, "\x00\x50\xa0\xe1\x01\x40\xa0\xe1"}, /* .P...@.. */ \
+ {0x00000230, "\x2c\x60\x91\xe5\x74\x10\x9f\xe5"}, /* ,`..t... */ \
+ {0x00000238, "\x10\x20\xa0\xe3\x01\x10\x8f\xe0"}, /* . ...... */ \
+ {0x00000240, "\x07\x00\xa0\xe1\x60\x00\x00\xeb"}, /* ....`... */ \
+ {0x00000248, "\x64\x10\x9f\xe5\x04\x30\x96\xe5"}, /* d....0.. */ \
+ {0x00000250, "\x01\x10\x8f\xe0\x06\x00\xa0\xe1"}, /* ........ */ \
+ {0x00000258, "\x33\xff\x2f\xe1\x04\x10\xa0\xe1"}, /* 3./..... */ \
+ {0x00000260, "\x05\x00\xa0\xe1\xc0\xff\xff\xeb"}, /* ........ */ \
+ {0x00000268, "\x00\x00\x50\xe3\x0e\x11\xa0\x03"}, /* ..P..... */ \
+ {0x00000270, "\x05\x00\x00\x0a\x3c\x10\x9f\xe5"}, /* ....<... */ \
+ {0x00000278, "\x06\x00\xa0\xe1\x01\x10\x8f\xe0"}, /* ........ */ \
+ {0x00000280, "\x04\x30\x96\xe5\x33\xff\x2f\xe1"}, /* .0..3./. */ \
+ {0x00000288, "\x3a\x11\xa0\xe3\x3c\x30\x94\xe5"}, /* :...<0.. */ \
+ {0x00000290, "\x10\x20\xa0\xe3\x78\x40\x93\xe5"}, /* . ..x@.. */ \
+ {0x00000298, "\x05\x00\xa0\xe1\x07\x30\xa0\xe1"}, /* .....0.. */ \
+ {0x000002a0, "\x34\xff\x2f\xe1\x00\x00\xa0\xe3"}, /* 4./..... */ \
+ {0x000002a8, "\x14\xd0\x8d\xe2\xf0\x80\xbd\xe8"}, /* ........ */ \
+ {0x000002b0, "\xb8\x02\x00\x00\x2a\x02\x00\x00"}, /* ........ */ \
+ {0x000002b8, "\x3a\x02\x00\x00\x00\x30\xa0\xe3"}, /* :....0.. */ \
+ {0x000002c0, "\x03\x20\xa0\xe1\x03\xc0\xa0\xe1"}, /* . ...... */ \
+ {0x000002c8, "\x04\xe0\x2d\xe5\x00\xe0\x91\xe5"}, /* ..-..... */ \
+ {0x000002d0, "\x00\x00\x5e\xe3\x03\x00\x00\x1a"}, /* ..^..... */ \
+ {0x000002d8, "\x02\x10\x93\xe1\x0c\x00\x00\x1a"}, /* ........ */ \
+ {0x000002e0, "\x00\x00\xa0\xe3\x04\xf0\x9d\xe4"}, /* ........ */ \
+ {0x000002e8, "\x12\x00\x5e\xe3\x04\xc0\x91\x05"}, /* ..^..... */ \
+ {0x000002f0, "\x05\x00\x00\x0a\x13\x00\x5e\xe3"}, /* ......^. */ \
+ {0x000002f8, "\x04\x20\x91\x05\x02\x00\x00\x0a"}, /* . ...... */ \
+ {0x00000300, "\x11\x00\x5e\xe3\x04\x30\x91\x05"}, /* ..^..0.. */ \
+ {0x00000308, "\x03\x30\x80\x00\x08\x10\x81\xe2"}, /* .0...... */ \
+ {0x00000310, "\xed\xff\xff\xea\x00\x00\x52\xe3"}, /* ......R. */ \
+ {0x00000318, "\x00\x00\x53\x13\x09\x00\x00\x1a"}, /* ..S..... */ \
+ {0x00000320, "\x06\x01\xa0\xe3\x04\xf0\x9d\xe4"}, /* ........ */ \
+ {0x00000328, "\x04\x10\xd3\xe5\x02\xc0\x4c\xe0"}, /* ......L. */ \
+ {0x00000330, "\x17\x00\x51\xe3\x00\xe0\x93\x05"}, /* ..Q..... */ \
+ {0x00000338, "\x02\x30\x83\xe0\x0e\x10\x90\x07"}, /* .0...... */ \
+ {0x00000340, "\x00\x10\x81\x00\x0e\x10\x80\x07"}, /* ........ */ \
+ {0x00000348, "\x00\x00\x5c\xe3\xf5\xff\xff\xca"}, /* ..\..... */ \
+ {0x00000350, "\xe2\xff\xff\xea\x01\x10\x41\xe2"}, /* ......A. */ \
+ {0x00000358, "\x02\x20\x80\xe0\x02\x00\x50\xe1"}, /* . ....P. */ \
+ {0x00000360, "\x01\x00\x00\x1a\x00\x00\xa0\xe3"}, /* ........ */ \
+ {0x00000368, "\x1e\xff\x2f\xe1\x00\x30\xd0\xe5"}, /* ../..0.. */ \
+ {0x00000370, "\x01\xc0\xf1\xe5\x0c\x00\x53\xe1"}, /* ......S. */ \
+ {0x00000378, "\x01\x00\x00\x0a\x0c\x00\x43\xe0"}, /* ......C. */ \
+ {0x00000380, "\x1e\xff\x2f\xe1\x01\x00\x80\xe2"}, /* ../..... */ \
+ {0x00000388, "\xf3\xff\xff\xea\x01\x00\x50\xe1"}, /* ......P. */ \
+ {0x00000390, "\x02\x30\x81\xe0\x01\x20\x40\x92"}, /* .0... @. */ \
+ {0x00000398, "\x08\x00\x00\x9a\x00\x10\xa0\xe1"}, /* ........ */ \
+ {0x000003a0, "\x02\x20\x80\xe0\x01\x00\x52\xe1"}, /* . ....R. */ \
+ {0x000003a8, "\x1e\xff\x2f\x01\x01\xc0\x73\xe5"}, /* ../...s. */ \
+ {0x000003b0, "\x01\xc0\x62\xe5\xfa\xff\xff\xea"}, /* ..b..... */ \
+ {0x000003b8, "\x01\xc0\xd1\xe4\x01\xc0\xe2\xe5"}, /* ........ */ \
+ {0x000003c0, "\x03\x00\x51\xe1\xfb\xff\xff\x1a"}, /* ..Q..... */ \
+ {0x000003c8, "\x1e\xff\x2f\xe1\xee\xff\xff\xea"}, /* ../..... */ \
+ {0x000003d0, "\x00\x30\xa0\xe1\x02\x20\x80\xe0"}, /* .0... .. */ \
+ {0x000003d8, "\x02\x00\x53\xe1\x1e\xff\x2f\x01"}, /* ..S.../. */ \
+ {0x000003e0, "\x01\x10\xc3\xe4\xfb\xff\xff\xea"}, /* ........ */ \
+ {0x000003e8, "\x1e\xff\x2f\xe1\x1e\xff\x2f\xe1"}, /* ../.../. */ \
+ {0x000003f0, "\x43\x00\x6f\x00\x75\x00\x6c\x00"}, /* C.o.u.l. */ \
+ {0x000003f8, "\x64\x00\x20\x00\x6e\x00\x6f\x00"}, /* d. .n.o. */ \
+ {0x00000400, "\x74\x00\x20\x00\x6f\x00\x70\x00"}, /* t. .o.p. */ \
+ {0x00000408, "\x65\x00\x6e\x00\x20\x00\x6c\x00"}, /* e.n. .l. */ \
+ {0x00000410, "\x6f\x00\x61\x00\x64\x00\x65\x00"}, /* o.a.d.e. */ \
+ {0x00000418, "\x64\x00\x20\x00\x69\x00\x6d\x00"}, /* d. .i.m. */ \
+ {0x00000420, "\x61\x00\x67\x00\x65\x00\x20\x00"}, /* a.g.e. . */ \
+ {0x00000428, "\x70\x00\x72\x00\x6f\x00\x74\x00"}, /* p.r.o.t. */ \
+ {0x00000430, "\x6f\x00\x63\x00\x6f\x00\x6c\x00"}, /* o.c.o.l. */ \
+ {0x00000438, "\x00\x00\x49\x00\x6e\x00\x63\x00"}, /* ..I.n.c. */ \
+ {0x00000440, "\x6f\x00\x72\x00\x72\x00\x65\x00"}, /* o.r.r.e. */ \
+ {0x00000448, "\x63\x00\x74\x00\x20\x00\x69\x00"}, /* c.t. .i. */ \
+ {0x00000450, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000458, "\x5f\x00\x62\x00\x61\x00\x73\x00"}, /* _.b.a.s. */ \
+ {0x00000460, "\x65\x00\x20\x00\x6f\x00\x72\x00"}, /* e. .o.r. */ \
+ {0x00000468, "\x20\x00\x69\x00\x6d\x00\x61\x00"}, /* .i.m.a. */ \
+ {0x00000470, "\x67\x00\x65\x00\x5f\x00\x73\x00"}, /* g.e._.s. */ \
+ {0x00000478, "\x69\x00\x7a\x00\x65\x00\x0a\x00"}, /* i.z.e... */ \
+ {0x00000480, "\x00\x00\x45\x00\x46\x00\x49\x00"}, /* ..E.F.I. */ \
+ {0x00000488, "\x20\x00\x61\x00\x70\x00\x70\x00"}, /* .a.p.p. */ \
+ {0x00000490, "\x6c\x00\x69\x00\x63\x00\x61\x00"}, /* l.i.c.a. */ \
+ {0x00000498, "\x74\x00\x69\x00\x6f\x00\x6e\x00"}, /* t.i.o.n. */ \
+ {0x000004a0, "\x20\x00\x63\x00\x61\x00\x6c\x00"}, /* .c.a.l. */ \
+ {0x000004a8, "\x6c\x00\x69\x00\x6e\x00\x67\x00"}, /* l.i.n.g. */ \
+ {0x000004b0, "\x20\x00\x45\x00\x78\x00\x69\x00"}, /* .E.x.i. */ \
+ {0x000004b8, "\x74\x00\x0a\x00\x00\x00\x4c\x00"}, /* t.....L. */ \
+ {0x000004c0, "\x6f\x00\x61\x00\x64\x00\x65\x00"}, /* o.a.d.e. */ \
+ {0x000004c8, "\x64\x00\x20\x00\x69\x00\x6d\x00"}, /* d. .i.m. */ \
+ {0x000004d0, "\x61\x00\x67\x00\x65\x00\x20\x00"}, /* a.g.e. . */ \
+ {0x000004d8, "\x70\x00\x72\x00\x6f\x00\x74\x00"}, /* p.r.o.t. */ \
+ {0x000004e0, "\x6f\x00\x63\x00\x6f\x00\x6c\x00"}, /* o.c.o.l. */ \
+ {0x000004e8, "\x20\x00\x6d\x00\x69\x00\x73\x00"}, /* .m.i.s. */ \
+ {0x000004f0, "\x73\x00\x69\x00\x6e\x00\x67\x00"}, /* s.i.n.g. */ \
+ {0x000004f8, "\x0a\x00\x00\x00\x53\x00\x55\x00"}, /* ....S.U. */ \
+ {0x00000500, "\x43\x00\x43\x00\x45\x00\x53\x00"}, /* C.C.E.S. */ \
+ {0x00000508, "\x53\x00\x00\x00\x00\x00\x00\x00"}, /* S....... */ \
+ {0x00000510, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000548, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \
+ {0x00000550, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \
+ {0x00000558, "\x10\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0, NULL} } }
diff --git a/lib/efi_selftest/efi_miniapp_tcg2_arm64.h b/lib/efi_selftest/efi_miniapp_tcg2_arm64.h
new file mode 100644
index 00000000000..bfe589438f5
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_arm64.h
@@ -0,0 +1,208 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * This file contains a precompiled EFI binary built from
+ * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include
+ * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL.
+ * The precompiled form is needed to avoid the problem of reproducible builds.
+ */
+
+#define EFI_ST_DISK_IMG { 0x000011e0, { \
+ {0x00000000, "\x4d\x5a\x00\x00\x00\x00\x00\x00"}, /* MZ...... */ \
+ {0x00000038, "\x41\x52\x4d\x64\x40\x00\x00\x00"}, /* ARMd@... */ \
+ {0x00000040, "\x50\x45\x00\x00\x64\xaa\x02\x00"}, /* PE..d... */ \
+ {0x00000050, "\x00\x00\x00\x00\xa0\x00\x0e\x02"}, /* ........ */ \
+ {0x00000058, "\x0b\x02\x02\x14\xd8\x04\x00\x00"}, /* ........ */ \
+ {0x00000068, "\x48\x01\x00\x00\x48\x01\x00\x00"}, /* H...H... */ \
+ {0x00000078, "\x20\x00\x00\x00\x08\x00\x00\x00"}, /* ....... */ \
+ {0x00000090, "\x20\x06\x00\x00\x48\x01\x00\x00"}, /* ...H... */ \
+ {0x00000098, "\x00\x00\x00\x00\x0a\x00\x00\x00"}, /* ........ */ \
+ {0x000000c0, "\x00\x00\x00\x00\x06\x00\x00\x00"}, /* ........ */ \
+ {0x000000f8, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \
+ {0x00000118, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \
+ {0x00000120, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \
+ {0x00000128, "\xd8\x04\x00\x00\x48\x01\x00\x00"}, /* ....H... */ \
+ {0x00000130, "\xd8\x04\x00\x00\x48\x01\x00\x00"}, /* ....H... */ \
+ {0x00000140, "\x00\x00\x00\x00\x20\x00\x50\xe0"}, /* .... .P. */ \
+ {0x00000148, "\xfd\x7b\xbe\xa9\xfd\x03\x00\x91"}, /* .{...... */ \
+ {0x00000150, "\xe0\x07\x01\xa9\x60\xf5\xff\x10"}, /* ....`... */ \
+ {0x00000158, "\x01\x00\x00\x90\x21\xc0\x14\x91"}, /* ....!... */ \
+ {0x00000160, "\x5a\x00\x00\x94\x60\x00\x00\xb5"}, /* Z...`... */ \
+ {0x00000168, "\xe0\x07\x41\xa9\x2d\x00\x00\x94"}, /* ..A.-... */ \
+ {0x00000170, "\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6"}, /* .{...._. */ \
+ {0x00000178, "\xfd\x7b\xbd\xa9\x45\x00\x80\x52"}, /* .{..E..R */ \
+ {0x00000180, "\x04\x00\x80\xd2\x03\x00\x80\xd2"}, /* ........ */ \
+ {0x00000188, "\xfd\x03\x00\x91\xf3\x53\x01\xa9"}, /* .....S.. */ \
+ {0x00000190, "\xa2\xa3\x00\x91\x33\x20\x40\xf9"}, /* ....3 @. */ \
+ {0x00000198, "\x21\x30\x40\xf9\x26\x8c\x40\xf9"}, /* !0@.&.@. */ \
+ {0x000001a0, "\x01\x00\x00\x90\x21\xc0\x17\x91"}, /* ....!... */ \
+ {0x000001a8, "\xc0\x00\x3f\xd6\xf4\x03\x00\xaa"}, /* ..?..... */ \
+ {0x000001b0, "\x40\x01\x00\xb4\x62\x06\x40\xf9"}, /* @...b.@. */ \
+ {0x000001b8, "\x01\x00\x00\x90\xe0\x03\x13\xaa"}, /* ........ */ \
+ {0x000001c0, "\x21\x50\x10\x91\x40\x00\x3f\xd6"}, /* !P..@.?. */ \
+ {0x000001c8, "\xe0\x03\x14\xaa\xf3\x53\x41\xa9"}, /* .....SA. */ \
+ {0x000001d0, "\xfd\x7b\xc3\xa8\xc0\x03\x5f\xd6"}, /* .{...._. */ \
+ {0x000001d8, "\xa2\x17\x40\xf9\x00\x00\x00\x90"}, /* ..@..... */ \
+ {0x000001e0, "\x00\xe0\x05\x91\x41\x20\x40\xf9"}, /* ....A @. */ \
+ {0x000001e8, "\x3f\x00\x00\xeb\xa8\x00\x00\x54"}, /* ?......T */ \
+ {0x000001f0, "\x42\x24\x40\xf9\x21\x00\x02\x8b"}, /* B$@.!... */ \
+ {0x000001f8, "\x3f\x00\x00\xeb\x68\xfe\xff\x54"}, /* ?...h..T */ \
+ {0x00000200, "\x62\x06\x40\xf9\xd4\x01\x80\xd2"}, /* b.@..... */ \
+ {0x00000208, "\x01\x00\x00\x90\xe0\x03\x13\xaa"}, /* ........ */ \
+ {0x00000210, "\x21\x78\x11\x91\x14\x00\xf0\xf2"}, /* !x...... */ \
+ {0x00000218, "\x40\x00\x3f\xd6\xeb\xff\xff\x17"}, /* @.?..... */ \
+ {0x00000220, "\xfd\x7b\xbc\xa9\x02\x02\x80\xd2"}, /* .{...... */ \
+ {0x00000228, "\xfd\x03\x00\x91\xf5\x5b\x02\xa9"}, /* .....[.. */ \
+ {0x00000230, "\xb6\xc3\x00\x91\xf3\x53\x01\xa9"}, /* .....S.. */ \
+ {0x00000238, "\xf5\x03\x00\xaa\xf4\x03\x01\xaa"}, /* ........ */ \
+ {0x00000240, "\xe0\x03\x16\xaa\x33\x20\x40\xf9"}, /* ....3 @. */ \
+ {0x00000248, "\x01\x00\x00\x90\x21\x80\x14\x91"}, /* ....!... */ \
+ {0x00000250, "\x67\x00\x00\x94\x01\x00\x00\x90"}, /* g....... */ \
+ {0x00000258, "\xe0\x03\x13\xaa\x62\x06\x40\xf9"}, /* ....b.@. */ \
+ {0x00000260, "\x21\x98\x12\x91\x40\x00\x3f\xd6"}, /* !...@.?. */ \
+ {0x00000268, "\xe1\x03\x14\xaa\xe0\x03\x15\xaa"}, /* ........ */ \
+ {0x00000270, "\xc2\xff\xff\x97\x60\x02\x00\xb4"}, /* ....`... */ \
+ {0x00000278, "\x62\x06\x40\xf9\x01\x00\x00\x90"}, /* b.@..... */ \
+ {0x00000280, "\xe0\x03\x13\xaa\x21\x88\x13\x91"}, /* ....!... */ \
+ {0x00000288, "\x40\x00\x3f\xd6\xc1\x01\x80\xd2"}, /* @.?..... */ \
+ {0x00000290, "\x01\x00\xf0\xf2\x80\x32\x40\xf9"}, /* .....2@. */ \
+ {0x00000298, "\xe3\x03\x16\xaa\x02\x02\x80\xd2"}, /* ........ */ \
+ {0x000002a0, "\x04\x6c\x40\xf9\xe0\x03\x15\xaa"}, /* .l@..... */ \
+ {0x000002a8, "\x80\x00\x3f\xd6\x00\x00\x80\xd2"}, /* ..?..... */ \
+ {0x000002b0, "\xf3\x53\x41\xa9\xf5\x5b\x42\xa9"}, /* .SA..[B. */ \
+ {0x000002b8, "\xfd\x7b\xc4\xa8\xc0\x03\x5f\xd6"}, /* .{...._. */ \
+ {0x000002c0, "\xe1\x0b\x41\xb2\xf4\xff\xff\x17"}, /* ..A..... */ \
+ {0x000002c8, "\x21\x20\x00\x91\x02\x00\x80\xd2"}, /* ! ...... */ \
+ {0x000002d0, "\x04\x00\x80\xd2\x03\x00\x80\xd2"}, /* ........ */ \
+ {0x000002d8, "\x25\x80\x5f\xf8\x25\x01\x00\xb5"}, /* %._.%... */ \
+ {0x000002e0, "\x5f\x00\x00\xf1\xe1\x17\x9f\x1a"}, /* _....... */ \
+ {0x000002e8, "\x9f\x00\x00\xf1\xe5\x17\x9f\x1a"}, /* ........ */ \
+ {0x000002f0, "\x3f\x00\x05\x6a\x20\x02\x00\x54"}, /* ?..j ..T */ \
+ {0x000002f8, "\x00\x00\x80\xd2\xc0\x03\x5f\xd6"}, /* ......_. */ \
+ {0x00000300, "\xbf\x20\x00\xf1\x20\x01\x00\x54"}, /* . .. ..T */ \
+ {0x00000308, "\xbf\x24\x00\xf1\x20\x01\x00\x54"}, /* .$.. ..T */ \
+ {0x00000310, "\xbf\x1c\x00\xf1\x61\x00\x00\x54"}, /* ....a..T */ \
+ {0x00000318, "\x22\x00\x40\xf9\x02\x00\x02\x8b"}, /* ".@..... */ \
+ {0x00000320, "\x21\x40\x00\x91\xed\xff\xff\x17"}, /* !@...... */ \
+ {0x00000328, "\x23\x00\x40\xf9\xfd\xff\xff\x17"}, /* #.@..... */ \
+ {0x00000330, "\x24\x00\x40\xf9\xfb\xff\xff\x17"}, /* $.@..... */ \
+ {0x00000338, "\x21\x00\x05\x2a\xa1\x01\x00\x35"}, /* !......5 */ \
+ {0x00000340, "\x7f\x00\x00\xf1\xad\xfd\xff\x54"}, /* .......T */ \
+ {0x00000348, "\x41\x08\x40\xb9\x3f\x0c\x10\xf1"}, /* A.@.?... */ \
+ {0x00000350, "\xa1\x00\x00\x54\x45\x00\x40\xf9"}, /* ...TE.@. */ \
+ {0x00000358, "\x41\x08\x40\xf9\x21\x00\x00\x8b"}, /* A.@.!... */ \
+ {0x00000360, "\xa1\x68\x20\xf8\x42\x00\x04\x8b"}, /* .h .B... */ \
+ {0x00000368, "\x63\x00\x04\xcb\xf5\xff\xff\x17"}, /* c....... */ \
+ {0x00000370, "\xe0\x07\x41\xb2\xc0\x03\x5f\xd6"}, /* ..A..._. */ \
+ {0x00000378, "\x04\x00\x80\xd2\x5f\x00\x04\xeb"}, /* ...._... */ \
+ {0x00000380, "\x61\x00\x00\x54\x00\x00\x80\x52"}, /* a..T...R */ \
+ {0x00000388, "\xc0\x03\x5f\xd6\x03\x68\x64\x38"}, /* .._..hd8 */ \
+ {0x00000390, "\x84\x04\x00\x91\x25\x00\x04\x8b"}, /* ....%... */ \
+ {0x00000398, "\xa5\xf0\x5f\x38\x7f\x00\x05\x6b"}, /* .._8...k */ \
+ {0x000003a0, "\xe0\xfe\xff\x54\x60\x00\x05\x4b"}, /* ...T`..K */ \
+ {0x000003a8, "\xc0\x03\x5f\xd6\x1f\x00\x01\xeb"}, /* .._..... */ \
+ {0x000003b0, "\x68\x01\x00\x54\x03\x00\x80\xd2"}, /* h..T.... */ \
+ {0x000003b8, "\x7f\x00\x02\xeb\x41\x00\x00\x54"}, /* ....A..T */ \
+ {0x000003c0, "\xc0\x03\x5f\xd6\x24\x68\x63\x38"}, /* .._.$hc8 */ \
+ {0x000003c8, "\x04\x68\x23\x38\x63\x04\x00\x91"}, /* .h#8c... */ \
+ {0x000003d0, "\xfa\xff\xff\x17\x23\x68\x62\x38"}, /* ....#hb8 */ \
+ {0x000003d8, "\x03\x68\x22\x38\x42\x04\x00\xd1"}, /* .h"8B... */ \
+ {0x000003e0, "\x5f\x04\x00\xb1\x81\xff\xff\x54"}, /* _......T */ \
+ {0x000003e8, "\xc0\x03\x5f\xd6\xf0\xff\xff\x17"}, /* .._..... */ \
+ {0x000003f0, "\x03\x00\x80\xd2\x5f\x00\x03\xeb"}, /* ...._... */ \
+ {0x000003f8, "\x41\x00\x00\x54\xc0\x03\x5f\xd6"}, /* A..T.._. */ \
+ {0x00000400, "\x01\x68\x23\x38\x63\x04\x00\x91"}, /* .h#8c... */ \
+ {0x00000408, "\xfb\xff\xff\x17\xc0\x03\x5f\xd6"}, /* ......_. */ \
+ {0x00000410, "\xc0\x03\x5f\xd6\x43\x00\x6f\x00"}, /* .._.C.o. */ \
+ {0x00000418, "\x75\x00\x6c\x00\x64\x00\x20\x00"}, /* u.l.d. . */ \
+ {0x00000420, "\x6e\x00\x6f\x00\x74\x00\x20\x00"}, /* n.o.t. . */ \
+ {0x00000428, "\x6f\x00\x70\x00\x65\x00\x6e\x00"}, /* o.p.e.n. */ \
+ {0x00000430, "\x20\x00\x6c\x00\x6f\x00\x61\x00"}, /* .l.o.a. */ \
+ {0x00000438, "\x64\x00\x65\x00\x64\x00\x20\x00"}, /* d.e.d. . */ \
+ {0x00000440, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \
+ {0x00000448, "\x65\x00\x20\x00\x70\x00\x72\x00"}, /* e. .p.r. */ \
+ {0x00000450, "\x6f\x00\x74\x00\x6f\x00\x63\x00"}, /* o.t.o.c. */ \
+ {0x00000458, "\x6f\x00\x6c\x00\x00\x00\x49\x00"}, /* o.l...I. */ \
+ {0x00000460, "\x6e\x00\x63\x00\x6f\x00\x72\x00"}, /* n.c.o.r. */ \
+ {0x00000468, "\x72\x00\x65\x00\x63\x00\x74\x00"}, /* r.e.c.t. */ \
+ {0x00000470, "\x20\x00\x69\x00\x6d\x00\x61\x00"}, /* .i.m.a. */ \
+ {0x00000478, "\x67\x00\x65\x00\x5f\x00\x62\x00"}, /* g.e._.b. */ \
+ {0x00000480, "\x61\x00\x73\x00\x65\x00\x20\x00"}, /* a.s.e. . */ \
+ {0x00000488, "\x6f\x00\x72\x00\x20\x00\x69\x00"}, /* o.r. .i. */ \
+ {0x00000490, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000498, "\x5f\x00\x73\x00\x69\x00\x7a\x00"}, /* _.s.i.z. */ \
+ {0x000004a0, "\x65\x00\x0a\x00\x00\x00\x45\x00"}, /* e.....E. */ \
+ {0x000004a8, "\x46\x00\x49\x00\x20\x00\x61\x00"}, /* F.I. .a. */ \
+ {0x000004b0, "\x70\x00\x70\x00\x6c\x00\x69\x00"}, /* p.p.l.i. */ \
+ {0x000004b8, "\x63\x00\x61\x00\x74\x00\x69\x00"}, /* c.a.t.i. */ \
+ {0x000004c0, "\x6f\x00\x6e\x00\x20\x00\x63\x00"}, /* o.n. .c. */ \
+ {0x000004c8, "\x61\x00\x6c\x00\x6c\x00\x69\x00"}, /* a.l.l.i. */ \
+ {0x000004d0, "\x6e\x00\x67\x00\x20\x00\x45\x00"}, /* n.g. .E. */ \
+ {0x000004d8, "\x78\x00\x69\x00\x74\x00\x0a\x00"}, /* x.i.t... */ \
+ {0x000004e0, "\x00\x00\x4c\x00\x6f\x00\x61\x00"}, /* ..L.o.a. */ \
+ {0x000004e8, "\x64\x00\x65\x00\x64\x00\x20\x00"}, /* d.e.d. . */ \
+ {0x000004f0, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \
+ {0x000004f8, "\x65\x00\x20\x00\x70\x00\x72\x00"}, /* e. .p.r. */ \
+ {0x00000500, "\x6f\x00\x74\x00\x6f\x00\x63\x00"}, /* o.t.o.c. */ \
+ {0x00000508, "\x6f\x00\x6c\x00\x20\x00\x6d\x00"}, /* o.l. .m. */ \
+ {0x00000510, "\x69\x00\x73\x00\x73\x00\x69\x00"}, /* i.s.s.i. */ \
+ {0x00000518, "\x6e\x00\x67\x00\x0a\x00\x00\x00"}, /* n.g..... */ \
+ {0x00000520, "\x53\x00\x55\x00\x43\x00\x43\x00"}, /* S.U.C.C. */ \
+ {0x00000528, "\x45\x00\x53\x00\x53\x00\x00\x00"}, /* E.S.S... */ \
+ {0x00000530, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000540, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000548, "\xb0\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \
+ {0x00000550, "\x05\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000558, "\x00\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \
+ {0x00000560, "\x06\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000568, "\x00\x10\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000570, "\x0a\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000578, "\xaa\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000580, "\x0b\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000588, "\x18\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000005f0, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \
+ {0x000005f8, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \
+ {0x00000618, "\x30\x05\x00\x00\x00\x00\x00\x00"}, /* 0....... */ \
+ {0x00001018, "\x00\x00\x00\x00\x03\x00\x01\x00"}, /* ........ */ \
+ {0x00001030, "\x00\x00\x00\x00\x03\x00\x03\x00"}, /* ........ */ \
+ {0x00001038, "\xf0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001048, "\x33\x00\x00\x00\x12\x00\x01\x00"}, /* 3....... */ \
+ {0x00001050, "\xac\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001058, "\x40\x00\x00\x00\x00\x00\x00\x00"}, /* @....... */ \
+ {0x00001060, "\x5b\x00\x00\x00\x12\x00\x01\x00"}, /* [....... */ \
+ {0x00001068, "\x10\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001070, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001078, "\x79\x00\x00\x00\x10\x00\x01\x00"}, /* y....... */ \
+ {0x00001080, "\x30\x05\x00\x00\x00\x00\x00\x00"}, /* 0....... */ \
+ {0x00001090, "\x01\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x00001098, "\x20\x02\x00\x00\x00\x00\x00\x00"}, /* ....... */ \
+ {0x000010a0, "\xa8\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010a8, "\x0a\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x000010b0, "\xec\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010b8, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010c0, "\x96\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000010c8, "\x20\x06\x00\x00\x00\x00\x00\x00"}, /* ....... */ \
+ {0x000010d8, "\x22\x00\x00\x00\x12\x00\x01\x00"}, /* "....... */ \
+ {0x000010e0, "\xc8\x02\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010e8, "\xb0\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010f0, "\x91\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000010f8, "\x20\x06\x00\x00\x00\x00\x00\x00"}, /* ....... */ \
+ {0x00001108, "\x2c\x00\x00\x00\x12\x00\x01\x00"}, /* ,....... */ \
+ {0x00001110, "\x78\x03\x00\x00\x00\x00\x00\x00"}, /* x....... */ \
+ {0x00001118, "\x34\x00\x00\x00\x00\x00\x00\x00"}, /* 4....... */ \
+ {0x00001120, "\x73\x00\x00\x00\x10\x00\x01\x00"}, /* s....... */ \
+ {0x00001138, "\x9f\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x00001140, "\xf0\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001150, "\x11\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \
+ {0x00001168, "\x42\x00\x00\x00\x12\x00\x01\x00"}, /* B....... */ \
+ {0x00001170, "\x0c\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001178, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001180, "\x3b\x00\x00\x00\x12\x00\x01\x00"}, /* ;....... */ \
+ {0x00001188, "\xf0\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001190, "\x1c\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001198, "\x8b\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000011a0, "\xf0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000011b0, "\x1b\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000011b8, "\x20\x06\x00\x00\x00\x00\x00\x00"}, /* ....... */ \
+ {0x000011c8, "\x80\x00\x00\x00\x10\x00\xf1\xff"}, /* ........ */ \
+ {0x000011d0, "\x30\x05\x00\x00\x00\x00\x00\x00"}, /* 0....... */ \
+ {0, NULL} } }
diff --git a/lib/efi_selftest/efi_miniapp_tcg2_ia32.h b/lib/efi_selftest/efi_miniapp_tcg2_ia32.h
new file mode 100644
index 00000000000..aa8c13939cc
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_ia32.h
@@ -0,0 +1,178 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * This file contains a precompiled EFI binary built from
+ * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include
+ * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL.
+ * The precompiled form is needed to avoid the problem of reproducible builds.
+ */
+
+#define EFI_ST_DISK_IMG { 0x00001200, { \
+ {0x00000000, "\x4d\x5a\x90\x00\x03\x00\x00\x00"}, /* MZ...... */ \
+ {0x00000008, "\x04\x00\x00\x00\xff\xff\x00\x00"}, /* ........ */ \
+ {0x00000010, "\xb8\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000018, "\x40\x00\x00\x00\x00\x00\x00\x00"}, /* @....... */ \
+ {0x00000038, "\x00\x00\x00\x00\x80\x00\x00\x00"}, /* ........ */ \
+ {0x00000040, "\x0e\x1f\xba\x0e\x00\xb4\x09\xcd"}, /* ........ */ \
+ {0x00000048, "\x21\xb8\x01\x4c\xcd\x21\x54\x68"}, /* !..L.!Th */ \
+ {0x00000050, "\x69\x73\x20\x70\x72\x6f\x67\x72"}, /* is progr */ \
+ {0x00000058, "\x61\x6d\x20\x63\x61\x6e\x6e\x6f"}, /* am canno */ \
+ {0x00000060, "\x74\x20\x62\x65\x20\x72\x75\x6e"}, /* t be run */ \
+ {0x00000068, "\x20\x69\x6e\x20\x44\x4f\x53\x20"}, /* in DOS */ \
+ {0x00000070, "\x6d\x6f\x64\x65\x2e\x0d\x0d\x0a"}, /* mode.... */ \
+ {0x00000078, "\x24\x00\x00\x00\x00\x00\x00\x00"}, /* $....... */ \
+ {0x00000080, "\x50\x45\x00\x00\x4c\x01\x06\x00"}, /* PE..L... */ \
+ {0x00000090, "\x00\x00\x00\x00\xe0\x00\x0e\x03"}, /* ........ */ \
+ {0x00000098, "\x0b\x01\x02\x1e\x00\x04\x00\x00"}, /* ........ */ \
+ {0x000000a0, "\x00\x0a\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000000a8, "\x00\x10\x00\x00\x00\x10\x00\x00"}, /* ........ */ \
+ {0x000000b0, "\x00\x30\x00\x00\x00\x00\x00\x00"}, /* .0...... */ \
+ {0x000000b8, "\x00\x10\x00\x00\x00\x02\x00\x00"}, /* ........ */ \
+ {0x000000d0, "\x00\x70\x00\x00\x00\x04\x00\x00"}, /* .p...... */ \
+ {0x000000d8, "\x6c\xdf\x00\x00\x0a\x00\x00\x00"}, /* l....... */ \
+ {0x000000f0, "\x00\x00\x00\x00\x10\x00\x00\x00"}, /* ........ */ \
+ {0x00000120, "\x00\x50\x00\x00\x0a\x00\x00\x00"}, /* .P...... */ \
+ {0x00000178, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \
+ {0x00000180, "\x1b\x02\x00\x00\x00\x10\x00\x00"}, /* ........ */ \
+ {0x00000188, "\x00\x04\x00\x00\x00\x04\x00\x00"}, /* ........ */ \
+ {0x00000198, "\x00\x00\x00\x00\x20\x00\x30\x60"}, /* .... .0` */ \
+ {0x000001a0, "\x2e\x73\x64\x61\x74\x61\x00\x00"}, /* .sdata.. */ \
+ {0x000001a8, "\x0c\x00\x00\x00\x00\x20\x00\x00"}, /* ..... .. */ \
+ {0x000001b0, "\x00\x02\x00\x00\x00\x08\x00\x00"}, /* ........ */ \
+ {0x000001c0, "\x00\x00\x00\x00\x40\x00\x30\xc0"}, /* ....@.0. */ \
+ {0x000001c8, "\x2e\x64\x61\x74\x61\x00\x00\x00"}, /* .data... */ \
+ {0x000001d0, "\x38\x01\x00\x00\x00\x30\x00\x00"}, /* 8....0.. */ \
+ {0x000001d8, "\x00\x02\x00\x00\x00\x0a\x00\x00"}, /* ........ */ \
+ {0x000001e8, "\x00\x00\x00\x00\x40\x00\x40\xc0"}, /* ....@.@. */ \
+ {0x000001f0, "\x2e\x64\x79\x6e\x61\x6d\x69\x63"}, /* .dynamic */ \
+ {0x000001f8, "\x70\x00\x00\x00\x00\x40\x00\x00"}, /* p....@.. */ \
+ {0x00000200, "\x00\x02\x00\x00\x00\x0c\x00\x00"}, /* ........ */ \
+ {0x00000210, "\x00\x00\x00\x00\x40\x00\x30\xc0"}, /* ....@.0. */ \
+ {0x00000218, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \
+ {0x00000220, "\x0a\x00\x00\x00\x00\x50\x00\x00"}, /* .....P.. */ \
+ {0x00000228, "\x00\x02\x00\x00\x00\x0e\x00\x00"}, /* ........ */ \
+ {0x00000238, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \
+ {0x00000240, "\x2e\x64\x79\x6e\x73\x79\x6d\x00"}, /* .dynsym. */ \
+ {0x00000248, "\x30\x00\x00\x00\x00\x60\x00\x00"}, /* 0....`.. */ \
+ {0x00000250, "\x00\x02\x00\x00\x00\x10\x00\x00"}, /* ........ */ \
+ {0x00000260, "\x00\x00\x00\x00\x40\x00\x30\x40"}, /* ....@.0@ */ \
+ {0x00000400, "\x55\x89\xe5\xff\x75\x0c\xff\x75"}, /* U...u..u */ \
+ {0x00000408, "\x08\xe8\x00\x00\x00\x00\x58\x89"}, /* ......X. */ \
+ {0x00000410, "\xc3\x05\xf2\xef\xff\xff\x81\xc3"}, /* ........ */ \
+ {0x00000418, "\xf2\x2f\x00\x00\x53\x50\xe8\x20"}, /* ./..SP. */ \
+ {0x00000420, "\x01\x00\x00\x5b\x5b\x85\xc0\x75"}, /* ...[[..u */ \
+ {0x00000428, "\x05\xe8\x8a\x00\x00\x00\xc9\xc3"}, /* ........ */ \
+ {0x00000430, "\x57\x56\x53\x83\xec\x18\xe8\x00"}, /* WVS..... */ \
+ {0x00000438, "\x01\x00\x00\x81\xc6\xc5\x0f\x00"}, /* ........ */ \
+ {0x00000440, "\x00\x8b\x44\x24\x2c\x8b\x58\x2c"}, /* ..D$,.X, */ \
+ {0x00000448, "\x8b\x40\x3c\x6a\x02\x6a\x00\x6a"}, /* .@<j.j.j */ \
+ {0x00000450, "\x00\x8d\x54\x24\x20\x52\x8d\x96"}, /* ..T$ R.. */ \
+ {0x00000458, "\x28\x11\x00\x00\x52\xff\x74\x24"}, /* (...R.t$ */ \
+ {0x00000460, "\x3c\xff\x90\x98\x00\x00\x00\x89"}, /* <....... */ \
+ {0x00000468, "\xc7\x83\xc4\x20\x85\xc0\x74\x12"}, /* ... ..t. */ \
+ {0x00000470, "\x52\x52\x8d\x86\x02\x10\x00\x00"}, /* RR...... */ \
+ {0x00000478, "\x50\x53\xff\x53\x04\x83\xc4\x10"}, /* PS.S.... */ \
+ {0x00000480, "\xeb\x2d\x8b\x4c\x24\x0c\x8b\x41"}, /* .-.L$..A */ \
+ {0x00000488, "\x20\x8d\x96\x30\xf0\xff\xff\x39"}, /* ..0...9 */ \
+ {0x00000490, "\xd0\x77\x07\x03\x41\x28\x39\xd0"}, /* .w..A(9. */ \
+ {0x00000498, "\x77\x15\x50\x50\x8d\x86\x4c\x10"}, /* w.PP..L. */ \
+ {0x000004a0, "\x00\x00\x50\x53\xff\x53\x04\x83"}, /* ..PS.S.. */ \
+ {0x000004a8, "\xc4\x10\xbf\x0e\x00\x00\x80\x89"}, /* ........ */ \
+ {0x000004b0, "\xf8\x83\xc4\x10\x5b\x5e\x5f\xc3"}, /* ....[^_. */ \
+ {0x000004b8, "\x55\x57\x56\x53\x83\xec\x1c\xe8"}, /* UWVS.... */ \
+ {0x000004c0, "\x7b\x00\x00\x00\x81\xc5\x3c\x0f"}, /* {.....<. */ \
+ {0x000004c8, "\x00\x00\x8b\x44\x24\x34\x8b\x58"}, /* ...D$4.X */ \
+ {0x000004d0, "\x2c\x89\xe7\x8d\xb5\x0e\x11\x00"}, /* ,....... */ \
+ {0x000004d8, "\x00\xb9\x04\x00\x00\x00\xf3\xa5"}, /* ........ */ \
+ {0x000004e0, "\x52\x52\x8d\x85\x94\x10\x00\x00"}, /* RR...... */ \
+ {0x000004e8, "\x50\x53\xff\x53\x04\x59\x5e\xff"}, /* PS.S.Y^. */ \
+ {0x000004f0, "\x74\x24\x3c\xff\x74\x24\x3c\xe8"}, /* t$<.t$<. */ \
+ {0x000004f8, "\x34\xff\xff\xff\x83\xc4\x10\xba"}, /* 4....... */ \
+ {0x00000500, "\x03\x00\x00\x80\x85\xc0\x74\x15"}, /* ......t. */ \
+ {0x00000508, "\x50\x50\x8d\x85\xd0\x10\x00\x00"}, /* PP...... */ \
+ {0x00000510, "\x50\x53\xff\x53\x04\x83\xc4\x10"}, /* PS.S.... */ \
+ {0x00000518, "\xba\x0e\x00\x00\x80\x8b\x44\x24"}, /* ......D$ */ \
+ {0x00000520, "\x34\x8b\x40\x3c\x89\xe1\x51\x6a"}, /* 4.@<..Qj */ \
+ {0x00000528, "\x10\x52\xff\x74\x24\x3c\xff\x50"}, /* .R.t$<.P */ \
+ {0x00000530, "\x78\x31\xc0\x83\xc4\x2c\x5b\x5e"}, /* x1...,[^ */ \
+ {0x00000538, "\x5f\x5d\xc3\x8b\x34\x24\xc3\x8b"}, /* _]..4$.. */ \
+ {0x00000540, "\x2c\x24\xc3\x57\x56\x53\x8b\x7c"}, /* ,$.WVS.| */ \
+ {0x00000548, "\x24\x10\x8b\x44\x24\x14\x83\xc0"}, /* $..D$... */ \
+ {0x00000550, "\x04\x31\xd2\x31\xc9\x31\xdb\x8b"}, /* .1.1.1.. */ \
+ {0x00000558, "\x70\xfc\x85\xf6\x74\x20\x83\xfe"}, /* p...t .. */ \
+ {0x00000560, "\x12\x74\x10\x83\xfe\x13\x74\x0f"}, /* .t....t. */ \
+ {0x00000568, "\x83\xfe\x11\x75\x0c\x8b\x10\x01"}, /* ...u.... */ \
+ {0x00000570, "\xfa\xeb\x06\x8b\x18\xeb\x02\x8b"}, /* ........ */ \
+ {0x00000578, "\x08\x83\xc0\x08\xeb\xd9\xb8\x01"}, /* ........ */ \
+ {0x00000580, "\x00\x00\x80\x85\xd2\x75\x08\x85"}, /* .....u.. */ \
+ {0x00000588, "\xc9\x75\x1e\x31\xc0\xeb\x1a\x85"}, /* .u.1.... */ \
+ {0x00000590, "\xc9\x74\x16\x85\xdb\x7e\xf4\x80"}, /* .t...~.. */ \
+ {0x00000598, "\x7a\x04\x08\x75\x06\x8b\x02\x01"}, /* z..u.... */ \
+ {0x000005a0, "\xf8\x01\x38\x01\xca\x29\xcb\xeb"}, /* ..8..).. */ \
+ {0x000005a8, "\xea\x5b\x5e\x5f\xc3\x57\x56\x53"}, /* .[^_.WVS */ \
+ {0x000005b0, "\x53\x89\xc7\x31\xf6\x39\xf1\x74"}, /* S..1.9.t */ \
+ {0x000005b8, "\x1c\x8a\x1c\x37\x46\x8a\x44\x32"}, /* ...7F.D2 */ \
+ {0x000005c0, "\xff\x88\x44\x24\x03\x38\xc3\x74"}, /* ..D$.8.t */ \
+ {0x000005c8, "\xec\x0f\xb6\xc3\x0f\xb6\x54\x24"}, /* ......T$ */ \
+ {0x000005d0, "\x03\x29\xd0\xeb\x02\x31\xc0\x5a"}, /* .)...1.Z */ \
+ {0x000005d8, "\x5b\x5e\x5f\xc3\x56\x53\x89\xce"}, /* [^_.VS.. */ \
+ {0x000005e0, "\x39\xd0\x77\x0f\x31\xdb\x39\xde"}, /* 9.w.1.9. */ \
+ {0x000005e8, "\x74\x18\x8a\x0c\x1a\x88\x0c\x18"}, /* t....... */ \
+ {0x000005f0, "\x43\xeb\xf3\x85\xf6\x74\x0b\x8a"}, /* C....t.. */ \
+ {0x000005f8, "\x5c\x32\xff\x88\x5c\x30\xff\x4e"}, /* \2..\0.N */ \
+ {0x00000600, "\xeb\xf1\x5b\x5e\xc3\xe9\xd2\xff"}, /* ..[^.... */ \
+ {0x00000608, "\xff\xff\x53\x31\xdb\x39\xd9\x74"}, /* ..S1.9.t */ \
+ {0x00000610, "\x06\x88\x14\x18\x43\xeb\xf6\x5b"}, /* ....C..[ */ \
+ {0x00000618, "\xc3\xc3\xc3\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000800, "\x00\x40\x00\x00\x00\x00\x00\x00"}, /* .@...... */ \
+ {0x00000a00, "\x00\x00\x43\x00\x6f\x00\x75\x00"}, /* ..C.o.u. */ \
+ {0x00000a08, "\x6c\x00\x64\x00\x20\x00\x6e\x00"}, /* l.d. .n. */ \
+ {0x00000a10, "\x6f\x00\x74\x00\x20\x00\x6f\x00"}, /* o.t. .o. */ \
+ {0x00000a18, "\x70\x00\x65\x00\x6e\x00\x20\x00"}, /* p.e.n. . */ \
+ {0x00000a20, "\x6c\x00\x6f\x00\x61\x00\x64\x00"}, /* l.o.a.d. */ \
+ {0x00000a28, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \
+ {0x00000a30, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000a38, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \
+ {0x00000a40, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \
+ {0x00000a48, "\x6c\x00\x00\x00\x49\x00\x6e\x00"}, /* l...I.n. */ \
+ {0x00000a50, "\x63\x00\x6f\x00\x72\x00\x72\x00"}, /* c.o.r.r. */ \
+ {0x00000a58, "\x65\x00\x63\x00\x74\x00\x20\x00"}, /* e.c.t. . */ \
+ {0x00000a60, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \
+ {0x00000a68, "\x65\x00\x5f\x00\x62\x00\x61\x00"}, /* e._.b.a. */ \
+ {0x00000a70, "\x73\x00\x65\x00\x20\x00\x6f\x00"}, /* s.e. .o. */ \
+ {0x00000a78, "\x72\x00\x20\x00\x69\x00\x6d\x00"}, /* r. .i.m. */ \
+ {0x00000a80, "\x61\x00\x67\x00\x65\x00\x5f\x00"}, /* a.g.e._. */ \
+ {0x00000a88, "\x73\x00\x69\x00\x7a\x00\x65\x00"}, /* s.i.z.e. */ \
+ {0x00000a90, "\x0a\x00\x00\x00\x45\x00\x46\x00"}, /* ....E.F. */ \
+ {0x00000a98, "\x49\x00\x20\x00\x61\x00\x70\x00"}, /* I. .a.p. */ \
+ {0x00000aa0, "\x70\x00\x6c\x00\x69\x00\x63\x00"}, /* p.l.i.c. */ \
+ {0x00000aa8, "\x61\x00\x74\x00\x69\x00\x6f\x00"}, /* a.t.i.o. */ \
+ {0x00000ab0, "\x6e\x00\x20\x00\x63\x00\x61\x00"}, /* n. .c.a. */ \
+ {0x00000ab8, "\x6c\x00\x6c\x00\x69\x00\x6e\x00"}, /* l.l.i.n. */ \
+ {0x00000ac0, "\x67\x00\x20\x00\x45\x00\x78\x00"}, /* g. .E.x. */ \
+ {0x00000ac8, "\x69\x00\x74\x00\x0a\x00\x00\x00"}, /* i.t..... */ \
+ {0x00000ad0, "\x4c\x00\x6f\x00\x61\x00\x64\x00"}, /* L.o.a.d. */ \
+ {0x00000ad8, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \
+ {0x00000ae0, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000ae8, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \
+ {0x00000af0, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \
+ {0x00000af8, "\x6c\x00\x20\x00\x6d\x00\x69\x00"}, /* l. .m.i. */ \
+ {0x00000b00, "\x73\x00\x73\x00\x69\x00\x6e\x00"}, /* s.s.i.n. */ \
+ {0x00000b08, "\x67\x00\x0a\x00\x00\x00\x53\x00"}, /* g.....S. */ \
+ {0x00000b10, "\x55\x00\x43\x00\x43\x00\x45\x00"}, /* U.C.C.E. */ \
+ {0x00000b18, "\x53\x00\x53\x00\x00\x00\x00\x00"}, /* S.S..... */ \
+ {0x00000b28, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \
+ {0x00000b30, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \
+ {0x00000c00, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c08, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c10, "\xf5\xfe\xff\x6f\x14\x70\x00\x00"}, /* ...o.p.. */ \
+ {0x00000c18, "\x05\x00\x00\x00\x00\x70\x00\x00"}, /* .....p.. */ \
+ {0x00000c20, "\x06\x00\x00\x00\x00\x60\x00\x00"}, /* .....`.. */ \
+ {0x00000c28, "\x0a\x00\x00\x00\x13\x00\x00\x00"}, /* ........ */ \
+ {0x00000c30, "\x0b\x00\x00\x00\x10\x00\x00\x00"}, /* ........ */ \
+ {0x00000c38, "\x1e\x00\x00\x00\x02\x00\x00\x00"}, /* ........ */ \
+ {0x00000e00, "\x20\x31\x00\x00\x0a\x00\x00\x00"}, /* 1...... */ \
+ {0x00001010, "\x01\x00\x00\x00\x00\x10\x00\x00"}, /* ........ */ \
+ {0x00001018, "\x00\x00\x00\x00\x10\x00\x02\x00"}, /* ........ */ \
+ {0x00001020, "\x08\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001028, "\x00\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \
+ {0, NULL} } }
diff --git a/lib/efi_selftest/efi_miniapp_tcg2_riscv32.h b/lib/efi_selftest/efi_miniapp_tcg2_riscv32.h
new file mode 100644
index 00000000000..c184d4decc6
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_riscv32.h
@@ -0,0 +1,174 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * This file contains a precompiled EFI binary built from
+ * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include
+ * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL.
+ * The precompiled form is needed to avoid the problem of reproducible builds.
+ */
+
+#define EFI_ST_DISK_IMG { 0x00001130, { \
+ {0x00000000, "\x4d\x5a\x00\x00\x00\x00\x00\x00"}, /* MZ...... */ \
+ {0x00000030, "\x52\x49\x53\x43\x56\x00\x00\x00"}, /* RISCV... */ \
+ {0x00000038, "\x52\x53\x43\x05\x40\x00\x00\x00"}, /* RSC.@... */ \
+ {0x00000040, "\x50\x45\x00\x00\x32\x50\x02\x00"}, /* PE..2P.. */ \
+ {0x00000050, "\x00\x00\x00\x00\xe0\x00\x0e\x02"}, /* ........ */ \
+ {0x00000058, "\x0b\x01\x02\x14\xb8\x03\x00\x00"}, /* ........ */ \
+ {0x00000068, "\x88\x01\x00\x00\x88\x01\x00\x00"}, /* ........ */ \
+ {0x00000078, "\x20\x00\x00\x00\x08\x00\x00\x00"}, /* ....... */ \
+ {0x00000080, "\x00\x00\x00\x00\x01\x00\x00\x00"}, /* ........ */ \
+ {0x00000090, "\x40\x05\x00\x00\x88\x01\x00\x00"}, /* @....... */ \
+ {0x00000098, "\x00\x00\x00\x00\x0a\x00\x00\x00"}, /* ........ */ \
+ {0x000000b0, "\x00\x00\x00\x00\x06\x00\x00\x00"}, /* ........ */ \
+ {0x00000138, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \
+ {0x00000158, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \
+ {0x00000160, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \
+ {0x00000168, "\xb8\x03\x00\x00\x88\x01\x00\x00"}, /* ........ */ \
+ {0x00000170, "\xb8\x03\x00\x00\x88\x01\x00\x00"}, /* ........ */ \
+ {0x00000180, "\x00\x00\x00\x00\x20\x00\x50\xe0"}, /* .... .P. */ \
+ {0x00000188, "\x51\x11\x2a\xc0\x2e\xc2\x06\xc4"}, /* Q....... */ \
+ {0x00000190, "\x17\x05\x00\x00\x13\x05\x05\xe7"}, /* ........ */ \
+ {0x00000198, "\x97\x05\x00\x00\x93\x85\x85\x30"}, /* .......0 */ \
+ {0x000001a0, "\xe5\x28\x09\xe5\x92\x45\x02\x45"}, /* .(...E.E */ \
+ {0x000001a8, "\x9d\x28\xa2\x40\x31\x01\x82\x80"}, /* .(.@1... */ \
+ {0x000001b0, "\x01\x11\x22\xcc\x06\xce\x26\xca"}, /* .."...&. */ \
+ {0x000001b8, "\xdc\x5d\xc4\x55\x01\x47\x03\xa8"}, /* .].U.G.. */ \
+ {0x000001c0, "\x87\x09\x81\x46\x89\x47\x70\x00"}, /* ...F.Gp. */ \
+ {0x000001c8, "\x97\x05\x00\x00\x93\x85\x85\x35"}, /* .......5 */ \
+ {0x000001d0, "\x02\x98\x2a\x84\x11\xcd\xdc\x40"}, /* .......@ */ \
+ {0x000001d8, "\x97\x05\x00\x00\x93\x85\x05\x1a"}, /* ........ */ \
+ {0x000001e0, "\x26\x85\x82\x97\xf2\x40\x22\x85"}, /* &....@". */ \
+ {0x000001e8, "\x62\x44\xd2\x44\x05\x61\x82\x80"}, /* bD.D.a.. */ \
+ {0x000001f0, "\xb2\x46\x17\x07\x00\x00\x13\x07"}, /* .F...... */ \
+ {0x000001f8, "\xe7\xfb\x9c\x52\x63\x66\xf7\x00"}, /* ...Rcf.. */ \
+ {0x00000200, "\x94\x56\xb6\x97\xe3\x60\xf7\xfe"}, /* .V...`.. */ \
+ {0x00000208, "\xdc\x40\x97\x05\x00\x00\x93\x85"}, /* .@...... */ \
+ {0x00000210, "\xa5\x1b\x26\x85\x37\x04\x00\x80"}, /* ..&.7... */ \
+ {0x00000218, "\x82\x97\x39\x04\xe1\xb7\x79\x71"}, /* ..9...yq */ \
+ {0x00000220, "\x06\xd6\x22\xd4\x26\xd2\x4e\xce"}, /* ..".&.N. */ \
+ {0x00000228, "\x4a\xd0\x03\xa9\xc5\x02\x8a\x89"}, /* J....... */ \
+ {0x00000230, "\xaa\x84\x2e\x84\x41\x46\x97\x05"}, /* ....AF.. */ \
+ {0x00000238, "\x00\x00\x93\x85\x25\x25\x4e\x85"}, /* ....%%N. */ \
+ {0x00000240, "\x39\x2a\x83\x27\x49\x00\x97\x05"}, /* 9..'I... */ \
+ {0x00000248, "\x00\x00\x93\x85\x65\x1c\x4a\x85"}, /* ....e.J. */ \
+ {0x00000250, "\x82\x97\xa2\x85\x26\x85\xa9\x3f"}, /* ....&..? */ \
+ {0x00000258, "\x1d\xc9\x83\x27\x49\x00\x97\x05"}, /* ...'I... */ \
+ {0x00000260, "\x00\x00\x93\x85\xa5\x1e\x4a\x85"}, /* ......J. */ \
+ {0x00000268, "\x82\x97\xb7\x07\x00\x80\x93\x85"}, /* ........ */ \
+ {0x00000270, "\xe7\x00\x5c\x5c\xce\x86\x26\x85"}, /* ..\\..&. */ \
+ {0x00000278, "\xbc\x5f\x41\x46\x82\x97\xb2\x50"}, /* ._AF...P */ \
+ {0x00000280, "\x22\x54\x92\x54\x02\x59\xf2\x49"}, /* "T.T.Y.I */ \
+ {0x00000288, "\x01\x45\x45\x61\x82\x80\xb7\x07"}, /* .EEa.... */ \
+ {0x00000290, "\x00\x80\x93\x85\x37\x00\xf1\xbf"}, /* ....7... */ \
+ {0x00000298, "\x81\x47\x01\x47\x81\x46\x21\x48"}, /* .G.G.F!H */ \
+ {0x000002a0, "\xa5\x48\x1d\x43\x90\x41\x09\xe6"}, /* .H.C.A.. */ \
+ {0x000002a8, "\x95\xe3\x1d\xe3\x01\x45\x82\x80"}, /* .....E.. */ \
+ {0x000002b0, "\x63\x0a\x06\x01\x63\x0a\x16\x01"}, /* c...c... */ \
+ {0x000002b8, "\x63\x14\x66\x00\xdc\x41\xaa\x97"}, /* c.f..A.. */ \
+ {0x000002c0, "\xa1\x05\xcd\xb7\xd4\x41\xed\xbf"}, /* .....A.. */ \
+ {0x000002c8, "\xd8\x41\xdd\xbf\x0d\x48\x05\xe3"}, /* .A...H.. */ \
+ {0x000002d0, "\x37\x05\x00\x80\x05\x05\x82\x80"}, /* 7....... */ \
+ {0x000002d8, "\x03\xc6\x47\x00\x63\x1c\x06\x01"}, /* ..G.c... */ \
+ {0x000002e0, "\x90\x43\x8c\x47\x99\x8e\x2a\x96"}, /* .C.G.... */ \
+ {0x000002e8, "\xaa\x95\x0c\xc2\xba\x97\xe3\x45"}, /* .......E */ \
+ {0x000002f0, "\xd0\xfe\x6d\xbf\x01\xa0\x01\x47"}, /* ..m....G */ \
+ {0x000002f8, "\x63\x14\xe6\x00\x01\x45\x82\x80"}, /* c....E.. */ \
+ {0x00000300, "\xb3\x07\xe5\x00\x05\x07\xb3\x86"}, /* ........ */ \
+ {0x00000308, "\xe5\x00\x83\xc7\x07\x00\x83\xc6"}, /* ........ */ \
+ {0x00000310, "\xf6\xff\xe3\x83\xd7\xfe\x33\x85"}, /* ......3. */ \
+ {0x00000318, "\xd7\x40\x82\x80\x63\xf5\xa5\x02"}, /* .@..c... */ \
+ {0x00000320, "\x93\x46\xf6\xff\x81\x47\xfd\x17"}, /* .F...G.. */ \
+ {0x00000328, "\x63\x91\xd7\x02\x82\x80\x33\x87"}, /* c.....3. */ \
+ {0x00000330, "\xf5\x00\x83\x46\x07\x00\x33\x07"}, /* ...F..3. */ \
+ {0x00000338, "\xf5\x00\x85\x07\x23\x00\xd7\x00"}, /* ....#... */ \
+ {0x00000340, "\xe3\x97\xc7\xfe\x82\x80\x81\x47"}, /* .......G */ \
+ {0x00000348, "\xe5\xbf\x33\x07\xf6\x00\x33\x88"}, /* ..3...3. */ \
+ {0x00000350, "\xe5\x00\x03\x48\x08\x00\x2a\x97"}, /* ...H.... */ \
+ {0x00000358, "\x23\x00\x07\x01\xe9\xb7\x7d\xbf"}, /* #.....}. */ \
+ {0x00000360, "\x2a\x96\xaa\x87\x63\x93\xc7\x00"}, /* ....c... */ \
+ {0x00000368, "\x82\x80\x85\x07\xa3\x8f\xb7\xfe"}, /* ........ */ \
+ {0x00000370, "\xd5\xbf\x82\x80\x82\x80\x00\x00"}, /* ........ */ \
+ {0x00000378, "\x43\x00\x6f\x00\x75\x00\x6c\x00"}, /* C.o.u.l. */ \
+ {0x00000380, "\x64\x00\x20\x00\x6e\x00\x6f\x00"}, /* d. .n.o. */ \
+ {0x00000388, "\x74\x00\x20\x00\x6f\x00\x70\x00"}, /* t. .o.p. */ \
+ {0x00000390, "\x65\x00\x6e\x00\x20\x00\x6c\x00"}, /* e.n. .l. */ \
+ {0x00000398, "\x6f\x00\x61\x00\x64\x00\x65\x00"}, /* o.a.d.e. */ \
+ {0x000003a0, "\x64\x00\x20\x00\x69\x00\x6d\x00"}, /* d. .i.m. */ \
+ {0x000003a8, "\x61\x00\x67\x00\x65\x00\x20\x00"}, /* a.g.e. . */ \
+ {0x000003b0, "\x70\x00\x72\x00\x6f\x00\x74\x00"}, /* p.r.o.t. */ \
+ {0x000003b8, "\x6f\x00\x63\x00\x6f\x00\x6c\x00"}, /* o.c.o.l. */ \
+ {0x000003c0, "\x00\x00\x00\x00\x49\x00\x6e\x00"}, /* ....I.n. */ \
+ {0x000003c8, "\x63\x00\x6f\x00\x72\x00\x72\x00"}, /* c.o.r.r. */ \
+ {0x000003d0, "\x65\x00\x63\x00\x74\x00\x20\x00"}, /* e.c.t. . */ \
+ {0x000003d8, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \
+ {0x000003e0, "\x65\x00\x5f\x00\x62\x00\x61\x00"}, /* e._.b.a. */ \
+ {0x000003e8, "\x73\x00\x65\x00\x20\x00\x6f\x00"}, /* s.e. .o. */ \
+ {0x000003f0, "\x72\x00\x20\x00\x69\x00\x6d\x00"}, /* r. .i.m. */ \
+ {0x000003f8, "\x61\x00\x67\x00\x65\x00\x5f\x00"}, /* a.g.e._. */ \
+ {0x00000400, "\x73\x00\x69\x00\x7a\x00\x65\x00"}, /* s.i.z.e. */ \
+ {0x00000408, "\x0a\x00\x00\x00\x45\x00\x46\x00"}, /* ....E.F. */ \
+ {0x00000410, "\x49\x00\x20\x00\x61\x00\x70\x00"}, /* I. .a.p. */ \
+ {0x00000418, "\x70\x00\x6c\x00\x69\x00\x63\x00"}, /* p.l.i.c. */ \
+ {0x00000420, "\x61\x00\x74\x00\x69\x00\x6f\x00"}, /* a.t.i.o. */ \
+ {0x00000428, "\x6e\x00\x20\x00\x63\x00\x61\x00"}, /* n. .c.a. */ \
+ {0x00000430, "\x6c\x00\x6c\x00\x69\x00\x6e\x00"}, /* l.l.i.n. */ \
+ {0x00000438, "\x67\x00\x20\x00\x45\x00\x78\x00"}, /* g. .E.x. */ \
+ {0x00000440, "\x69\x00\x74\x00\x0a\x00\x00\x00"}, /* i.t..... */ \
+ {0x00000448, "\x4c\x00\x6f\x00\x61\x00\x64\x00"}, /* L.o.a.d. */ \
+ {0x00000450, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \
+ {0x00000458, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000460, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \
+ {0x00000468, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \
+ {0x00000470, "\x6c\x00\x20\x00\x6d\x00\x69\x00"}, /* l. .m.i. */ \
+ {0x00000478, "\x73\x00\x73\x00\x69\x00\x6e\x00"}, /* s.s.i.n. */ \
+ {0x00000480, "\x67\x00\x0a\x00\x00\x00\x00\x00"}, /* g....... */ \
+ {0x00000488, "\x53\x00\x55\x00\x43\x00\x43\x00"}, /* S.U.C.C. */ \
+ {0x00000490, "\x45\x00\x53\x00\x53\x00\x00\x00"}, /* E.S.S... */ \
+ {0x000004a0, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000004a8, "\x04\x00\x00\x00\xac\x20\x00\x00"}, /* ..... .. */ \
+ {0x000004b0, "\xf5\xfe\xff\x6f\x44\x21\x00\x00"}, /* ...oD!.. */ \
+ {0x000004b8, "\x05\x00\x00\x00\x00\x20\x00\x00"}, /* ..... .. */ \
+ {0x000004c0, "\x06\x00\x00\x00\x00\x10\x00\x00"}, /* ........ */ \
+ {0x000004c8, "\x0a\x00\x00\x00\xaa\x00\x00\x00"}, /* ........ */ \
+ {0x000004d0, "\x0b\x00\x00\x00\x10\x00\x00\x00"}, /* ........ */ \
+ {0x000004d8, "\x07\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000004e0, "\x08\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000004e8, "\x09\x00\x00\x00\x0c\x00\x00\x00"}, /* ........ */ \
+ {0x00000520, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \
+ {0x00000528, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \
+ {0x00000530, "\xa0\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001018, "\x00\x00\x00\x00\x03\x00\x01\x00"}, /* ........ */ \
+ {0x00001020, "\x42\x00\x00\x00\x72\x03\x00\x00"}, /* B...r... */ \
+ {0x00001028, "\x02\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x00001030, "\x73\x00\x00\x00\x00\x00\x00\x00"}, /* s....... */ \
+ {0x00001038, "\x00\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \
+ {0x00001040, "\x3b\x00\x00\x00\x60\x03\x00\x00"}, /* ;...`... */ \
+ {0x00001048, "\x12\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x00001050, "\x96\x00\x00\x00\x40\x05\x00\x00"}, /* ....@... */ \
+ {0x00001058, "\x00\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x00001060, "\x22\x00\x00\x00\x98\x02\x00\x00"}, /* "....... */ \
+ {0x00001068, "\x5e\x00\x00\x00\x12\x00\x01\x00"}, /* ^....... */ \
+ {0x00001070, "\x2c\x00\x00\x00\xf6\x02\x00\x00"}, /* ,....... */ \
+ {0x00001078, "\x26\x00\x00\x00\x12\x00\x01\x00"}, /* &....... */ \
+ {0x00001080, "\x1b\x00\x00\x00\x40\x05\x00\x00"}, /* ....@... */ \
+ {0x00001088, "\x00\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x00001090, "\x5b\x00\x00\x00\x74\x03\x00\x00"}, /* [...t... */ \
+ {0x00001098, "\x02\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x000010a0, "\x9f\x00\x00\x00\xa0\x00\x00\x00"}, /* ........ */ \
+ {0x000010a8, "\x00\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000010b0, "\x79\x00\x00\x00\xa0\x04\x00\x00"}, /* y....... */ \
+ {0x000010b8, "\x00\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \
+ {0x000010c0, "\x33\x00\x00\x00\x1c\x03\x00\x00"}, /* 3....... */ \
+ {0x000010c8, "\x42\x00\x00\x00\x12\x00\x01\x00"}, /* B....... */ \
+ {0x000010d0, "\x01\x00\x00\x00\x1e\x02\x00\x00"}, /* ........ */ \
+ {0x000010d8, "\x7a\x00\x00\x00\x12\x00\x01\x00"}, /* z....... */ \
+ {0x000010e0, "\x91\x00\x00\x00\x40\x05\x00\x00"}, /* ....@... */ \
+ {0x000010e8, "\x00\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000010f0, "\x11\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010f8, "\x00\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \
+ {0x00001100, "\x80\x00\x00\x00\xa0\x04\x00\x00"}, /* ........ */ \
+ {0x00001108, "\x00\x00\x00\x00\x10\x00\xf1\xff"}, /* ........ */ \
+ {0x00001110, "\x0a\x00\x00\x00\x5e\x03\x00\x00"}, /* ....^... */ \
+ {0x00001118, "\x02\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x00001120, "\x8b\x00\x00\x00\x20\x05\x00\x00"}, /* .... ... */ \
+ {0x00001128, "\x00\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0, NULL} } }
diff --git a/lib/efi_selftest/efi_miniapp_tcg2_riscv64.h b/lib/efi_selftest/efi_miniapp_tcg2_riscv64.h
new file mode 100644
index 00000000000..d5972df2085
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_riscv64.h
@@ -0,0 +1,190 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * This file contains a precompiled EFI binary built from
+ * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include
+ * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL.
+ * The precompiled form is needed to avoid the problem of reproducible builds.
+ */
+
+#define EFI_ST_DISK_IMG { 0x000011c8, { \
+ {0x00000000, "\x4d\x5a\x00\x00\x00\x00\x00\x00"}, /* MZ...... */ \
+ {0x00000030, "\x52\x49\x53\x43\x56\x00\x00\x00"}, /* RISCV... */ \
+ {0x00000038, "\x52\x53\x43\x05\x40\x00\x00\x00"}, /* RSC.@... */ \
+ {0x00000040, "\x50\x45\x00\x00\x64\x50\x02\x00"}, /* PE..dP.. */ \
+ {0x00000050, "\x00\x00\x00\x00\xf0\x00\x0e\x02"}, /* ........ */ \
+ {0x00000058, "\x0b\x02\x02\x14\x58\x04\x00\x00"}, /* ....X... */ \
+ {0x00000068, "\x98\x01\x00\x00\x98\x01\x00\x00"}, /* ........ */ \
+ {0x00000078, "\x20\x00\x00\x00\x08\x00\x00\x00"}, /* ....... */ \
+ {0x00000080, "\x00\x00\x00\x00\x01\x00\x00\x00"}, /* ........ */ \
+ {0x00000090, "\xf0\x05\x00\x00\x98\x01\x00\x00"}, /* ........ */ \
+ {0x00000098, "\x00\x00\x00\x00\x0a\x00\x00\x00"}, /* ........ */ \
+ {0x000000c0, "\x00\x00\x00\x00\x06\x00\x00\x00"}, /* ........ */ \
+ {0x00000148, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \
+ {0x00000168, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \
+ {0x00000170, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \
+ {0x00000178, "\x58\x04\x00\x00\x98\x01\x00\x00"}, /* X....... */ \
+ {0x00000180, "\x58\x04\x00\x00\x98\x01\x00\x00"}, /* X....... */ \
+ {0x00000190, "\x00\x00\x00\x00\x20\x00\x50\xe0"}, /* .... .P. */ \
+ {0x00000198, "\x21\x11\x2a\xe0\x2e\xe4\x06\xe8"}, /* !....... */ \
+ {0x000001a0, "\x17\x05\x00\x00\x13\x05\x05\xe6"}, /* ........ */ \
+ {0x000001a8, "\x97\x05\x00\x00\x93\x85\x85\x31"}, /* .......1 */ \
+ {0x000001b0, "\xef\x00\x20\x0f\x63\x17\x05\x00"}, /* .. .c... */ \
+ {0x000001b8, "\xa2\x65\x02\x65\xef\x00\x80\x07"}, /* .e.e.... */ \
+ {0x000001c0, "\xc2\x60\x61\x01\x82\x80\x79\x71"}, /* .`a...yq */ \
+ {0x000001c8, "\x22\xf0\x06\xf4\x26\xec\xbc\x71"}, /* "...&..q */ \
+ {0x000001d0, "\xa4\x61\x01\x47\x03\xb8\x87\x11"}, /* .a.G.... */ \
+ {0x000001d8, "\x81\x46\x89\x47\x30\x00\x97\x05"}, /* .F.G0... */ \
+ {0x000001e0, "\x00\x00\x93\x85\x25\x3f\x02\x98"}, /* ....%?.. */ \
+ {0x000001e8, "\x2a\x84\x11\xcd\x9c\x64\x97\x05"}, /* .....d.. */ \
+ {0x000001f0, "\x00\x00\x93\x85\x25\x1a\x26\x85"}, /* ....%.&. */ \
+ {0x000001f8, "\x82\x97\x22\x85\xa2\x70\x02\x74"}, /* .."..p.t */ \
+ {0x00000200, "\xe2\x64\x45\x61\x82\x80\xa2\x66"}, /* .dEa...f */ \
+ {0x00000208, "\x17\x07\x00\x00\x13\x07\xe7\xfb"}, /* ........ */ \
+ {0x00000210, "\xbc\x62\x63\x66\xf7\x00\xb4\x66"}, /* .bcf...f */ \
+ {0x00000218, "\xb6\x97\xe3\x60\xf7\xfe\x9c\x64"}, /* ...`...d */ \
+ {0x00000220, "\x7d\x54\x97\x05\x00\x00\x93\x85"}, /* }T...... */ \
+ {0x00000228, "\xe5\x1b\x26\x85\x7e\x14\x82\x97"}, /* ..&.~... */ \
+ {0x00000230, "\x39\x04\xe1\xb7\x79\x71\x97\x07"}, /* 9...yq.. */ \
+ {0x00000238, "\x00\x00\x93\x87\x27\x27\x26\xec"}, /* ....''&. */ \
+ {0x00000240, "\x4a\xe8\x06\xf4\x22\xf0\x98\x63"}, /* J..."..c */ \
+ {0x00000248, "\x9c\x67\xa0\x61\x3a\xe0\x3e\xe4"}, /* .g.a:.>. */ \
+ {0x00000250, "\x1c\x64\x2a\x89\xae\x84\x22\x85"}, /* .d....". */ \
+ {0x00000258, "\x97\x05\x00\x00\x93\x85\x05\x1d"}, /* ........ */ \
+ {0x00000260, "\x82\x97\xa6\x85\x4a\x85\xef\xf0"}, /* ....J... */ \
+ {0x00000268, "\x1f\xf6\x05\xc9\x1c\x64\x97\x05"}, /* .....d.. */ \
+ {0x00000270, "\x00\x00\x93\x85\xa5\x1f\x22\x85"}, /* ......". */ \
+ {0x00000278, "\x82\x97\xfd\x55\xfe\x15\xb9\x05"}, /* ...U.... */ \
+ {0x00000280, "\xbc\x70\x8a\x86\x4a\x85\xfc\x6f"}, /* .p..J..o */ \
+ {0x00000288, "\x41\x46\x82\x97\xa2\x70\x02\x74"}, /* AF...p.t */ \
+ {0x00000290, "\xe2\x64\x42\x69\x01\x45\x45\x61"}, /* .dBi.EEa */ \
+ {0x00000298, "\x82\x80\xfd\x55\xfe\x15\x8d\x05"}, /* ...U.... */ \
+ {0x000002a0, "\xc5\xb7\xa1\x05\x81\x47\x01\x47"}, /* .....G.G */ \
+ {0x000002a8, "\x81\x46\x21\x48\xa5\x48\x1d\x43"}, /* .F!H.H.C */ \
+ {0x000002b0, "\x03\xb6\x85\xff\x09\xe6\x95\xe3"}, /* ........ */ \
+ {0x000002b8, "\x31\xe7\x01\x45\x82\x80\x63\x0a"}, /* 1..E..c. */ \
+ {0x000002c0, "\x06\x01\x63\x0a\x16\x01\x63\x14"}, /* ..c...c. */ \
+ {0x000002c8, "\x66\x00\x9c\x61\xaa\x97\xc1\x05"}, /* f..a.... */ \
+ {0x000002d0, "\xc5\xb7\x94\x61\xed\xbf\x98\x61"}, /* ...a...a */ \
+ {0x000002d8, "\xdd\xbf\x0d\xc7\x7d\x56\x01\x92"}, /* ....}V.. */ \
+ {0x000002e0, "\x8d\x48\xe3\x5c\xd0\xfc\x8c\x67"}, /* .H.\...g */ \
+ {0x000002e8, "\xf1\x8d\x63\x9c\x15\x01\x8c\x63"}, /* ..c....c */ \
+ {0x000002f0, "\x03\xb8\x07\x01\x99\x8e\xaa\x95"}, /* ........ */ \
+ {0x000002f8, "\x2a\x98\x23\xb0\x05\x01\xba\x97"}, /* ..#..... */ \
+ {0x00000300, "\xcd\xb7\x01\xa0\x7d\x55\x7e\x15"}, /* ....}U~. */ \
+ {0x00000308, "\x05\x05\x82\x80\x01\x47\x63\x14"}, /* .....Gc. */ \
+ {0x00000310, "\xe6\x00\x01\x45\x82\x80\xb3\x07"}, /* ...E.... */ \
+ {0x00000318, "\xe5\x00\x05\x07\xb3\x86\xe5\x00"}, /* ........ */ \
+ {0x00000320, "\x83\xc7\x07\x00\x83\xc6\xf6\xff"}, /* ........ */ \
+ {0x00000328, "\xe3\x83\xd7\xfe\x3b\x85\xd7\x40"}, /* ....;..@ */ \
+ {0x00000330, "\x82\x80\x63\xf5\xa5\x02\x93\x46"}, /* ..c....F */ \
+ {0x00000338, "\xf6\xff\x81\x47\xfd\x17\x63\x91"}, /* ...G..c. */ \
+ {0x00000340, "\xd7\x02\x82\x80\x33\x87\xf5\x00"}, /* ....3... */ \
+ {0x00000348, "\x83\x46\x07\x00\x33\x07\xf5\x00"}, /* .F..3... */ \
+ {0x00000350, "\x85\x07\x23\x00\xd7\x00\xe3\x17"}, /* ..#..... */ \
+ {0x00000358, "\xf6\xfe\x82\x80\x81\x47\xe5\xbf"}, /* .....G.. */ \
+ {0x00000360, "\x33\x07\xf6\x00\x33\x88\xe5\x00"}, /* 3...3... */ \
+ {0x00000368, "\x03\x48\x08\x00\x2a\x97\x23\x00"}, /* .H....#. */ \
+ {0x00000370, "\x07\x01\xe9\xb7\x6f\xf0\xff\xfb"}, /* ....o... */ \
+ {0x00000378, "\x2a\x96\xaa\x87\x63\x93\xc7\x00"}, /* ....c... */ \
+ {0x00000380, "\x82\x80\x85\x07\xa3\x8f\xb7\xfe"}, /* ........ */ \
+ {0x00000388, "\xd5\xbf\x82\x80\x82\x80\x00\x00"}, /* ........ */ \
+ {0x00000390, "\x43\x00\x6f\x00\x75\x00\x6c\x00"}, /* C.o.u.l. */ \
+ {0x00000398, "\x64\x00\x20\x00\x6e\x00\x6f\x00"}, /* d. .n.o. */ \
+ {0x000003a0, "\x74\x00\x20\x00\x6f\x00\x70\x00"}, /* t. .o.p. */ \
+ {0x000003a8, "\x65\x00\x6e\x00\x20\x00\x6c\x00"}, /* e.n. .l. */ \
+ {0x000003b0, "\x6f\x00\x61\x00\x64\x00\x65\x00"}, /* o.a.d.e. */ \
+ {0x000003b8, "\x64\x00\x20\x00\x69\x00\x6d\x00"}, /* d. .i.m. */ \
+ {0x000003c0, "\x61\x00\x67\x00\x65\x00\x20\x00"}, /* a.g.e. . */ \
+ {0x000003c8, "\x70\x00\x72\x00\x6f\x00\x74\x00"}, /* p.r.o.t. */ \
+ {0x000003d0, "\x6f\x00\x63\x00\x6f\x00\x6c\x00"}, /* o.c.o.l. */ \
+ {0x000003e0, "\x49\x00\x6e\x00\x63\x00\x6f\x00"}, /* I.n.c.o. */ \
+ {0x000003e8, "\x72\x00\x72\x00\x65\x00\x63\x00"}, /* r.r.e.c. */ \
+ {0x000003f0, "\x74\x00\x20\x00\x69\x00\x6d\x00"}, /* t. .i.m. */ \
+ {0x000003f8, "\x61\x00\x67\x00\x65\x00\x5f\x00"}, /* a.g.e._. */ \
+ {0x00000400, "\x62\x00\x61\x00\x73\x00\x65\x00"}, /* b.a.s.e. */ \
+ {0x00000408, "\x20\x00\x6f\x00\x72\x00\x20\x00"}, /* .o.r. . */ \
+ {0x00000410, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \
+ {0x00000418, "\x65\x00\x5f\x00\x73\x00\x69\x00"}, /* e._.s.i. */ \
+ {0x00000420, "\x7a\x00\x65\x00\x0a\x00\x00\x00"}, /* z.e..... */ \
+ {0x00000428, "\x45\x00\x46\x00\x49\x00\x20\x00"}, /* E.F.I. . */ \
+ {0x00000430, "\x61\x00\x70\x00\x70\x00\x6c\x00"}, /* a.p.p.l. */ \
+ {0x00000438, "\x69\x00\x63\x00\x61\x00\x74\x00"}, /* i.c.a.t. */ \
+ {0x00000440, "\x69\x00\x6f\x00\x6e\x00\x20\x00"}, /* i.o.n. . */ \
+ {0x00000448, "\x63\x00\x61\x00\x6c\x00\x6c\x00"}, /* c.a.l.l. */ \
+ {0x00000450, "\x69\x00\x6e\x00\x67\x00\x20\x00"}, /* i.n.g. . */ \
+ {0x00000458, "\x45\x00\x78\x00\x69\x00\x74\x00"}, /* E.x.i.t. */ \
+ {0x00000460, "\x0a\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000468, "\x4c\x00\x6f\x00\x61\x00\x64\x00"}, /* L.o.a.d. */ \
+ {0x00000470, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \
+ {0x00000478, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000480, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \
+ {0x00000488, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \
+ {0x00000490, "\x6c\x00\x20\x00\x6d\x00\x69\x00"}, /* l. .m.i. */ \
+ {0x00000498, "\x73\x00\x73\x00\x69\x00\x6e\x00"}, /* s.s.i.n. */ \
+ {0x000004a0, "\x67\x00\x0a\x00\x00\x00\x00\x00"}, /* g....... */ \
+ {0x000004a8, "\x53\x00\x55\x00\x43\x00\x43\x00"}, /* S.U.C.C. */ \
+ {0x000004b0, "\x45\x00\x53\x00\x53\x00\x00\x00"}, /* E.S.S... */ \
+ {0x000004c0, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000004d0, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000004d8, "\xb0\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \
+ {0x000004e0, "\xf5\xfe\xff\x6f\x00\x00\x00\x00"}, /* ...o.... */ \
+ {0x000004e8, "\x48\x21\x00\x00\x00\x00\x00\x00"}, /* H!...... */ \
+ {0x000004f0, "\x05\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000004f8, "\x00\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \
+ {0x00000500, "\x06\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000508, "\x00\x10\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000510, "\x0a\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000518, "\xaa\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000520, "\x0b\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000528, "\x18\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000530, "\x07\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000540, "\x08\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000550, "\x09\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000558, "\x18\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000560, "\x1e\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000568, "\x02\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000005d0, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \
+ {0x000005d8, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \
+ {0x000005e0, "\xc0\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001018, "\x00\x00\x00\x00\x03\x00\x01\x00"}, /* ........ */ \
+ {0x00001030, "\x42\x00\x00\x00\x12\x00\x01\x00"}, /* B....... */ \
+ {0x00001038, "\x8a\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001040, "\x02\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001048, "\x73\x00\x00\x00\x10\x00\x01\x00"}, /* s....... */ \
+ {0x00001060, "\x3b\x00\x00\x00\x12\x00\x01\x00"}, /* ;....... */ \
+ {0x00001068, "\x78\x03\x00\x00\x00\x00\x00\x00"}, /* x....... */ \
+ {0x00001070, "\x12\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001078, "\x96\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x00001080, "\xf0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001090, "\x1b\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x00001098, "\xa2\x02\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010a0, "\x6a\x00\x00\x00\x00\x00\x00\x00"}, /* j....... */ \
+ {0x000010a8, "\x25\x00\x00\x00\x12\x00\x01\x00"}, /* %....... */ \
+ {0x000010b0, "\x0c\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010b8, "\x26\x00\x00\x00\x00\x00\x00\x00"}, /* &....... */ \
+ {0x000010c0, "\x14\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000010c8, "\xf0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010d8, "\x5b\x00\x00\x00\x12\x00\x01\x00"}, /* [....... */ \
+ {0x000010e0, "\x8c\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010e8, "\x02\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000010f0, "\x9f\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000010f8, "\x30\x01\x00\x00\x00\x00\x00\x00"}, /* 0....... */ \
+ {0x00001108, "\x79\x00\x00\x00\x10\x00\x01\x00"}, /* y....... */ \
+ {0x00001110, "\xc0\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001120, "\x2c\x00\x00\x00\x12\x00\x01\x00"}, /* ,....... */ \
+ {0x00001128, "\x32\x03\x00\x00\x00\x00\x00\x00"}, /* 2....... */ \
+ {0x00001130, "\x42\x00\x00\x00\x00\x00\x00\x00"}, /* B....... */ \
+ {0x00001138, "\x01\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \
+ {0x00001140, "\x34\x02\x00\x00\x00\x00\x00\x00"}, /* 4....... */ \
+ {0x00001148, "\x6e\x00\x00\x00\x00\x00\x00\x00"}, /* n....... */ \
+ {0x00001150, "\x91\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x00001158, "\xf0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001168, "\x0a\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \
+ {0x00001180, "\x80\x00\x00\x00\x10\x00\xf1\xff"}, /* ........ */ \
+ {0x00001188, "\xc0\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00001198, "\x34\x00\x00\x00\x12\x00\x01\x00"}, /* 4....... */ \
+ {0x000011a0, "\x74\x03\x00\x00\x00\x00\x00\x00"}, /* t....... */ \
+ {0x000011a8, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000011b0, "\x8b\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x000011b8, "\xd0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0, NULL} } }
diff --git a/lib/efi_selftest/efi_miniapp_tcg2_x86_64.h b/lib/efi_selftest/efi_miniapp_tcg2_x86_64.h
new file mode 100644
index 00000000000..9b0413facd7
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_x86_64.h
@@ -0,0 +1,179 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * This file contains a precompiled EFI binary built from
+ * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include
+ * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL.
+ * The precompiled form is needed to avoid the problem of reproducible builds.
+ */
+
+#define EFI_ST_DISK_IMG { 0x00001000, { \
+ {0x00000000, "\x4d\x5a\x90\x00\x03\x00\x00\x00"}, /* MZ...... */ \
+ {0x00000008, "\x04\x00\x00\x00\xff\xff\x00\x00"}, /* ........ */ \
+ {0x00000010, "\xb8\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000018, "\x40\x00\x00\x00\x00\x00\x00\x00"}, /* @....... */ \
+ {0x00000038, "\x00\x00\x00\x00\x80\x00\x00\x00"}, /* ........ */ \
+ {0x00000040, "\x0e\x1f\xba\x0e\x00\xb4\x09\xcd"}, /* ........ */ \
+ {0x00000048, "\x21\xb8\x01\x4c\xcd\x21\x54\x68"}, /* !..L.!Th */ \
+ {0x00000050, "\x69\x73\x20\x70\x72\x6f\x67\x72"}, /* is progr */ \
+ {0x00000058, "\x61\x6d\x20\x63\x61\x6e\x6e\x6f"}, /* am canno */ \
+ {0x00000060, "\x74\x20\x62\x65\x20\x72\x75\x6e"}, /* t be run */ \
+ {0x00000068, "\x20\x69\x6e\x20\x44\x4f\x53\x20"}, /* in DOS */ \
+ {0x00000070, "\x6d\x6f\x64\x65\x2e\x0d\x0d\x0a"}, /* mode.... */ \
+ {0x00000078, "\x24\x00\x00\x00\x00\x00\x00\x00"}, /* $....... */ \
+ {0x00000080, "\x50\x45\x00\x00\x64\x86\x05\x00"}, /* PE..d... */ \
+ {0x00000090, "\x00\x00\x00\x00\xf0\x00\x0e\x02"}, /* ........ */ \
+ {0x00000098, "\x0b\x02\x02\x1e\x00\x04\x00\x00"}, /* ........ */ \
+ {0x000000a0, "\x00\x08\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x000000a8, "\x00\x20\x00\x00\x00\x20\x00\x00"}, /* . ... .. */ \
+ {0x000000b8, "\x00\x10\x00\x00\x00\x02\x00\x00"}, /* ........ */ \
+ {0x000000d0, "\x00\x70\x00\x00\x00\x04\x00\x00"}, /* .p...... */ \
+ {0x000000d8, "\x24\xe3\x00\x00\x0a\x00\x00\x00"}, /* $....... */ \
+ {0x00000100, "\x00\x00\x00\x00\x10\x00\x00\x00"}, /* ........ */ \
+ {0x00000130, "\x00\x30\x00\x00\x0a\x00\x00\x00"}, /* .0...... */ \
+ {0x00000188, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \
+ {0x00000190, "\x29\x02\x00\x00\x00\x20\x00\x00"}, /* ).... .. */ \
+ {0x00000198, "\x00\x04\x00\x00\x00\x04\x00\x00"}, /* ........ */ \
+ {0x000001a8, "\x00\x00\x00\x00\x20\x00\x30\x60"}, /* .... .0` */ \
+ {0x000001b0, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \
+ {0x000001b8, "\x0a\x00\x00\x00\x00\x30\x00\x00"}, /* .....0.. */ \
+ {0x000001c0, "\x00\x02\x00\x00\x00\x08\x00\x00"}, /* ........ */ \
+ {0x000001d0, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \
+ {0x000001d8, "\x2e\x64\x61\x74\x61\x00\x00\x00"}, /* .data... */ \
+ {0x000001e0, "\x38\x01\x00\x00\x00\x40\x00\x00"}, /* 8....@.. */ \
+ {0x000001e8, "\x00\x02\x00\x00\x00\x0a\x00\x00"}, /* ........ */ \
+ {0x000001f8, "\x00\x00\x00\x00\x40\x00\x50\xc0"}, /* ....@.P. */ \
+ {0x00000200, "\x2e\x64\x79\x6e\x61\x6d\x69\x63"}, /* .dynamic */ \
+ {0x00000208, "\xe0\x00\x00\x00\x00\x50\x00\x00"}, /* .....P.. */ \
+ {0x00000210, "\x00\x02\x00\x00\x00\x0c\x00\x00"}, /* ........ */ \
+ {0x00000220, "\x00\x00\x00\x00\x40\x00\x40\xc0"}, /* ....@.@. */ \
+ {0x00000228, "\x2e\x64\x79\x6e\x73\x79\x6d\x00"}, /* .dynsym. */ \
+ {0x00000230, "\x48\x00\x00\x00\x00\x60\x00\x00"}, /* H....`.. */ \
+ {0x00000238, "\x00\x02\x00\x00\x00\x0e\x00\x00"}, /* ........ */ \
+ {0x00000248, "\x00\x00\x00\x00\x40\x00\x40\x40"}, /* ....@.@@ */ \
+ {0x00000400, "\x48\x83\xec\x08\x51\x52\x48\x8d"}, /* H...QRH. */ \
+ {0x00000408, "\x0d\xf3\xdf\xff\xff\x48\x8d\x15"}, /* .....H.. */ \
+ {0x00000410, "\xec\x2f\x00\x00\xe8\x24\x01\x00"}, /* ./...$.. */ \
+ {0x00000418, "\x00\x5a\x59\x48\x85\xc0\x75\x05"}, /* .ZYH..u. */ \
+ {0x00000420, "\xe8\x8f\x00\x00\x00\x48\x83\xc4"}, /* .....H.. */ \
+ {0x00000428, "\x08\xc3\x56\x45\x31\xc9\x53\x48"}, /* ..VE1.SH */ \
+ {0x00000430, "\x83\xec\x48\x48\x8b\x42\x60\x48"}, /* ..HH.B`H */ \
+ {0x00000438, "\x8b\x5a\x40\x4c\x8d\x44\x24\x38"}, /* .Z@L.D$8 */ \
+ {0x00000440, "\xc7\x44\x24\x28\x02\x00\x00\x00"}, /* .D$(.... */ \
+ {0x00000448, "\x48\xc7\x44\x24\x20\x00\x00\x00"}, /* H.D$ ... */ \
+ {0x00000450, "\x00\x48\x8d\x15\xc8\x20\x00\x00"}, /* .H... .. */ \
+ {0x00000458, "\xff\x90\x18\x01\x00\x00\x48\x85"}, /* ......H. */ \
+ {0x00000460, "\xc0\x48\x89\xc6\x74\x0f\x48\x8d"}, /* .H..t.H. */ \
+ {0x00000468, "\x15\x95\x1f\x00\x00\x48\x89\xd9"}, /* .....H.. */ \
+ {0x00000470, "\xff\x53\x08\xeb\x35\x48\x8b\x4c"}, /* .S..5H.L */ \
+ {0x00000478, "\x24\x38\x48\x8d\x15\xa9\xff\xff"}, /* $8H..... */ \
+ {0x00000480, "\xff\x48\x8b\x41\x40\x48\x39\xd0"}, /* .H.A@H9. */ \
+ {0x00000488, "\x77\x09\x48\x03\x41\x48\x48\x39"}, /* w.H.AHH9 */ \
+ {0x00000490, "\xd0\x77\x17\x48\x8d\x15\xb2\x1f"}, /* .w.H.... */ \
+ {0x00000498, "\x00\x00\x48\x89\xd9\x48\xbe\x0e"}, /* ..H..H.. */ \
+ {0x000004a0, "\x00\x00\x00\x00\x00\x00\x80\xff"}, /* ........ */ \
+ {0x000004a8, "\x53\x08\x48\x83\xc4\x48\x48\x89"}, /* S.H..HH. */ \
+ {0x000004b0, "\xf0\x5b\x5e\xc3\x57\x48\x89\xcf"}, /* .[^.WH.. */ \
+ {0x000004b8, "\x56\x48\x89\xd6\x53\x48\x83\xec"}, /* VH..SH.. */ \
+ {0x000004c0, "\x30\x48\x8b\x5a\x40\x48\x8b\x05"}, /* 0H.Z@H.. */ \
+ {0x000004c8, "\x42\x20\x00\x00\x48\x8b\x15\x43"}, /* B ..H..C */ \
+ {0x000004d0, "\x20\x00\x00\x48\x89\xd9\x48\x89"}, /* ..H..H. */ \
+ {0x000004d8, "\x44\x24\x20\x48\x89\x54\x24\x28"}, /* D$ H.T$( */ \
+ {0x000004e0, "\x48\x8d\x15\xad\x1f\x00\x00\xff"}, /* H....... */ \
+ {0x000004e8, "\x53\x08\x48\x89\xf2\x48\x89\xf9"}, /* S.H..H.. */ \
+ {0x000004f0, "\xe8\x35\xff\xff\xff\x48\xba\x03"}, /* .5...H.. */ \
+ {0x000004f8, "\x00\x00\x00\x00\x00\x00\x80\x48"}, /* .......H */ \
+ {0x00000500, "\x85\xc0\x74\x17\x48\x8d\x15\xc5"}, /* ..t.H... */ \
+ {0x00000508, "\x1f\x00\x00\x48\x89\xd9\xff\x53"}, /* ...H...S */ \
+ {0x00000510, "\x08\x48\xba\x0e\x00\x00\x00\x00"}, /* .H...... */ \
+ {0x00000518, "\x00\x00\x80\x48\x8b\x46\x60\x4c"}, /* ...H.F`L */ \
+ {0x00000520, "\x8d\x4c\x24\x20\x48\x89\xf9\x41"}, /* .L$ H..A */ \
+ {0x00000528, "\xb8\x10\x00\x00\x00\xff\x90\xd8"}, /* ........ */ \
+ {0x00000530, "\x00\x00\x00\x48\x83\xc4\x30\x31"}, /* ...H..01 */ \
+ {0x00000538, "\xc0\x5b\x5e\x5f\xc3\x48\x83\xc2"}, /* .[^_.H.. */ \
+ {0x00000540, "\x08\x31\xc0\x45\x31\xc9\x45\x31"}, /* .1.E1.E1 */ \
+ {0x00000548, "\xc0\x4c\x8b\x52\xf8\x4d\x85\xd2"}, /* .L.R.M.. */ \
+ {0x00000550, "\x74\x28\x49\x83\xfa\x08\x74\x14"}, /* t(I...t. */ \
+ {0x00000558, "\x49\x83\xfa\x09\x74\x13\x49\x83"}, /* I...t.I. */ \
+ {0x00000560, "\xfa\x07\x75\x10\x48\x8b\x02\x48"}, /* ..u.H..H */ \
+ {0x00000568, "\x01\xc8\xeb\x08\x4c\x8b\x02\xeb"}, /* ....L... */ \
+ {0x00000570, "\x03\x4c\x8b\x0a\x48\x83\xc2\x10"}, /* .L..H... */ \
+ {0x00000578, "\xeb\xcf\x48\x85\xc0\x41\x0f\x94"}, /* ..H..A.. */ \
+ {0x00000580, "\xc2\x4d\x85\xc9\x0f\x94\xc2\x45"}, /* .M.....E */ \
+ {0x00000588, "\x84\xd2\x74\x07\x84\xd2\x74\x23"}, /* ..t...t# */ \
+ {0x00000590, "\x31\xc0\xc3\x84\xd2\x75\x1c\x4d"}, /* 1....u.M */ \
+ {0x00000598, "\x85\xc0\x7e\xf4\x83\x78\x08\x08"}, /* ..~..x.. */ \
+ {0x000005a0, "\x75\x09\x48\x8b\x10\x48\x01\xca"}, /* u.H..H.. */ \
+ {0x000005a8, "\x48\x01\x0a\x4c\x01\xc8\x4d\x29"}, /* H..L..M) */ \
+ {0x000005b0, "\xc8\xeb\xe4\x48\xb8\x01\x00\x00"}, /* ...H.... */ \
+ {0x000005b8, "\x00\x00\x00\x00\x80\xc3\x31\xc9"}, /* ......1. */ \
+ {0x000005c0, "\x48\x39\xca\x74\x16\x0f\xb6\x04"}, /* H9.t.... */ \
+ {0x000005c8, "\x0f\x48\xff\xc1\x44\x0f\xb6\x44"}, /* .H..D..D */ \
+ {0x000005d0, "\x0e\xff\x44\x38\xc0\x74\xe9\x44"}, /* ..D8.t.D */ \
+ {0x000005d8, "\x29\xc0\xc3\x31\xc0\xc3\x48\x39"}, /* )..1..H9 */ \
+ {0x000005e0, "\xf7\x48\x89\xf8\x77\x15\x31\xc9"}, /* .H..w.1. */ \
+ {0x000005e8, "\x48\x39\xca\x74\x0d\x40\x8a\x3c"}, /* H9.t.@.< */ \
+ {0x000005f0, "\x0e\x40\x88\x3c\x08\x48\xff\xc1"}, /* .@.<.H.. */ \
+ {0x000005f8, "\xeb\xee\xc3\x48\x85\xd2\x74\x0d"}, /* ...H..t. */ \
+ {0x00000600, "\x8a\x4c\x16\xff\x88\x4c\x10\xff"}, /* .L...L.. */ \
+ {0x00000608, "\x48\xff\xca\xeb\xee\xc3\xe9\xcb"}, /* H....... */ \
+ {0x00000610, "\xff\xff\xff\x48\x89\xf8\x31\xc9"}, /* ...H..1. */ \
+ {0x00000618, "\x48\x39\xca\x74\x09\x40\x88\x34"}, /* H9.t.@.4 */ \
+ {0x00000620, "\x08\x48\xff\xc1\xeb\xf2\xc3\xc3"}, /* .H...... */ \
+ {0x00000628, "\xc3\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000800, "\x30\x11\x00\x00\x0a\x00\x00\x00"}, /* 0....... */ \
+ {0x00000a00, "\x00\x00\x43\x00\x6f\x00\x75\x00"}, /* ..C.o.u. */ \
+ {0x00000a08, "\x6c\x00\x64\x00\x20\x00\x6e\x00"}, /* l.d. .n. */ \
+ {0x00000a10, "\x6f\x00\x74\x00\x20\x00\x6f\x00"}, /* o.t. .o. */ \
+ {0x00000a18, "\x70\x00\x65\x00\x6e\x00\x20\x00"}, /* p.e.n. . */ \
+ {0x00000a20, "\x6c\x00\x6f\x00\x61\x00\x64\x00"}, /* l.o.a.d. */ \
+ {0x00000a28, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \
+ {0x00000a30, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000a38, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \
+ {0x00000a40, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \
+ {0x00000a48, "\x6c\x00\x00\x00\x49\x00\x6e\x00"}, /* l...I.n. */ \
+ {0x00000a50, "\x63\x00\x6f\x00\x72\x00\x72\x00"}, /* c.o.r.r. */ \
+ {0x00000a58, "\x65\x00\x63\x00\x74\x00\x20\x00"}, /* e.c.t. . */ \
+ {0x00000a60, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \
+ {0x00000a68, "\x65\x00\x5f\x00\x62\x00\x61\x00"}, /* e._.b.a. */ \
+ {0x00000a70, "\x73\x00\x65\x00\x20\x00\x6f\x00"}, /* s.e. .o. */ \
+ {0x00000a78, "\x72\x00\x20\x00\x69\x00\x6d\x00"}, /* r. .i.m. */ \
+ {0x00000a80, "\x61\x00\x67\x00\x65\x00\x5f\x00"}, /* a.g.e._. */ \
+ {0x00000a88, "\x73\x00\x69\x00\x7a\x00\x65\x00"}, /* s.i.z.e. */ \
+ {0x00000a90, "\x0a\x00\x00\x00\x45\x00\x46\x00"}, /* ....E.F. */ \
+ {0x00000a98, "\x49\x00\x20\x00\x61\x00\x70\x00"}, /* I. .a.p. */ \
+ {0x00000aa0, "\x70\x00\x6c\x00\x69\x00\x63\x00"}, /* p.l.i.c. */ \
+ {0x00000aa8, "\x61\x00\x74\x00\x69\x00\x6f\x00"}, /* a.t.i.o. */ \
+ {0x00000ab0, "\x6e\x00\x20\x00\x63\x00\x61\x00"}, /* n. .c.a. */ \
+ {0x00000ab8, "\x6c\x00\x6c\x00\x69\x00\x6e\x00"}, /* l.l.i.n. */ \
+ {0x00000ac0, "\x67\x00\x20\x00\x45\x00\x78\x00"}, /* g. .E.x. */ \
+ {0x00000ac8, "\x69\x00\x74\x00\x0a\x00\x00\x00"}, /* i.t..... */ \
+ {0x00000ad0, "\x4c\x00\x6f\x00\x61\x00\x64\x00"}, /* L.o.a.d. */ \
+ {0x00000ad8, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \
+ {0x00000ae0, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \
+ {0x00000ae8, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \
+ {0x00000af0, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \
+ {0x00000af8, "\x6c\x00\x20\x00\x6d\x00\x69\x00"}, /* l. .m.i. */ \
+ {0x00000b00, "\x73\x00\x73\x00\x69\x00\x6e\x00"}, /* s.s.i.n. */ \
+ {0x00000b08, "\x67\x00\x0a\x00\x00\x00\x53\x00"}, /* g.....S. */ \
+ {0x00000b10, "\x55\x00\x43\x00\x43\x00\x45\x00"}, /* U.C.C.E. */ \
+ {0x00000b18, "\x53\x00\x53\x00\x00\x00\x00\x00"}, /* S.S..... */ \
+ {0x00000b20, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \
+ {0x00000b28, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \
+ {0x00000c00, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c10, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c20, "\xf5\xfe\xff\x6f\x00\x00\x00\x00"}, /* ...o.... */ \
+ {0x00000c28, "\x00\x80\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c30, "\x05\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c38, "\x00\x70\x00\x00\x00\x00\x00\x00"}, /* .p...... */ \
+ {0x00000c40, "\x06\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c48, "\x00\x60\x00\x00\x00\x00\x00\x00"}, /* .`...... */ \
+ {0x00000c50, "\x0a\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c58, "\x13\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c60, "\x0b\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c68, "\x18\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c70, "\x1e\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000c78, "\x02\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \
+ {0x00000e18, "\x01\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \
+ {0x00000e20, "\x00\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \
+ {0x00000e30, "\x08\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \
+ {0, NULL} } }
diff --git a/lib/efi_selftest/efi_selftest_snp.c b/lib/efi_selftest/efi_selftest_snp.c
index 79f04678039..818cbfcacd4 100644
--- a/lib/efi_selftest/efi_selftest_snp.c
+++ b/lib/efi_selftest/efi_selftest_snp.c
@@ -309,6 +309,18 @@ static int execute(void)
return EFI_ST_FAILURE;
}
+ /* Check media connected */
+ ret = net->get_status(net, NULL, NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to get status");
+ return EFI_ST_FAILURE;
+ }
+ if (net->mode && net->mode->media_present_supported &&
+ !net->mode->media_present) {
+ efi_st_error("Network media is not connected");
+ return EFI_ST_FAILURE;
+ }
+
/*
* Send DHCP discover message
*/
@@ -328,8 +340,6 @@ static int execute(void)
events[0] = timer;
events[1] = net->wait_for_packet;
for (;;) {
- u32 int_status;
-
/*
* Wait for packet to be received or timer event.
*/
@@ -352,48 +362,46 @@ static int execute(void)
continue;
}
/*
- * Receive packet
+ * Receive packets until buffer is empty
*/
- buffer_size = sizeof(buffer);
- ret = net->get_status(net, &int_status, NULL);
- if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to get status");
- return EFI_ST_FAILURE;
- }
- if (!(int_status & EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT)) {
- efi_st_error("RX interrupt not set");
- return EFI_ST_FAILURE;
- }
- ret = net->receive(net, NULL, &buffer_size, &buffer,
- &srcaddr, &destaddr, NULL);
- if (ret != EFI_SUCCESS) {
- efi_st_error("Failed to receive packet");
- return EFI_ST_FAILURE;
+ for (;;) {
+ buffer_size = sizeof(buffer);
+ ret = net->receive(net, NULL, &buffer_size, &buffer,
+ &srcaddr, &destaddr, NULL);
+ if (ret == EFI_NOT_READY) {
+ /* The received buffer is empty. */
+ break;
+ }
+
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to receive packet");
+ return EFI_ST_FAILURE;
+ }
+ /*
+ * Check the packet is meant for this system.
+ * Unfortunately QEMU ignores the broadcast flag.
+ * So we have to check for broadcasts too.
+ */
+ if (memcmp(&destaddr, &net->mode->current_address, ARP_HLEN) &&
+ memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN))
+ continue;
+ /*
+ * Check this is a DHCP reply
+ */
+ if (buffer.p.eth_hdr.et_protlen != ntohs(PROT_IP) ||
+ buffer.p.ip_udp.ip_hl_v != 0x45 ||
+ buffer.p.ip_udp.ip_p != IPPROTO_UDP ||
+ buffer.p.ip_udp.udp_src != ntohs(67) ||
+ buffer.p.ip_udp.udp_dst != ntohs(68) ||
+ buffer.p.dhcp_hdr.op != BOOTREPLY)
+ continue;
+ /*
+ * We successfully received a DHCP reply.
+ */
+ goto received;
}
- /*
- * Check the packet is meant for this system.
- * Unfortunately QEMU ignores the broadcast flag.
- * So we have to check for broadcasts too.
- */
- if (memcmp(&destaddr, &net->mode->current_address, ARP_HLEN) &&
- memcmp(&destaddr, BROADCAST_MAC, ARP_HLEN))
- continue;
- /*
- * Check this is a DHCP reply
- */
- if (buffer.p.eth_hdr.et_protlen != ntohs(PROT_IP) ||
- buffer.p.ip_udp.ip_hl_v != 0x45 ||
- buffer.p.ip_udp.ip_p != IPPROTO_UDP ||
- buffer.p.ip_udp.udp_src != ntohs(67) ||
- buffer.p.ip_udp.udp_dst != ntohs(68) ||
- buffer.p.dhcp_hdr.op != BOOTREPLY)
- continue;
- /*
- * We successfully received a DHCP reply.
- */
- break;
}
-
+received:
/*
* Write a log message.
*/
diff --git a/lib/efi_selftest/efi_selftest_tcg2.c b/lib/efi_selftest/efi_selftest_tcg2.c
index 1399309cec7..c5b0b7dd02f 100644
--- a/lib/efi_selftest/efi_selftest_tcg2.c
+++ b/lib/efi_selftest/efi_selftest_tcg2.c
@@ -9,10 +9,604 @@
#include <efi_selftest.h>
#include <efi_tcg2.h>
+/*
+ * Include containing the miniapp.efi application.
+ * Note that tcg2 selftest measures the PE/COFF image,
+ * so we must have the pre-build efi application for
+ * each architecture.
+ */
+#if defined(__arm__)
+#include "efi_miniapp_tcg2_arm.h"
+#elif defined(__aarch64__)
+#include "efi_miniapp_tcg2_arm64.h"
+#elif defined(__i386__)
+#include "efi_miniapp_tcg2_ia32.h"
+#elif defined(__x86_64__)
+#include "efi_miniapp_tcg2_x86_64.h"
+#elif defined(__riscv) && (__riscv_xlen == 32)
+#include "efi_miniapp_tcg2_riscv32.h"
+#elif defined(__riscv) && (__riscv_xlen == 64)
+#include "efi_miniapp_tcg2_riscv64.h"
+#endif
+
+#include <linux/unaligned/be_byteshift.h>
+#include <linux/unaligned/le_byteshift.h>
+#include <mapmem.h>
+#include <smbios.h>
+#include <tables_csum.h>
static struct efi_boot_services *boottime;
static const efi_guid_t guid_tcg2 = EFI_TCG2_PROTOCOL_GUID;
+/* Block size of compressed disk image */
+#define COMPRESSED_DISK_IMAGE_BLOCK_SIZE 8
+
+static efi_handle_t image_handle;
+/* Decompressed file image */
+static u8 *image;
+
+/* One 8 byte block of the compressed disk image */
+struct line {
+ size_t addr;
+ char *line;
+};
+
+/* Compressed file image */
+struct compressed_file_image {
+ size_t length;
+ struct line lines[];
+};
+
+static struct compressed_file_image img = EFI_ST_DISK_IMG;
+
+static struct efi_tcg2_event *efi_tcg2_event;
+
+static struct efi_runtime_services *runtime;
+#define BOOT_NAME_1000 u"Boot1000"
+#define BOOT_NAME_1001 u"Boot1001"
+#define BOOT_NAME_1002 u"Boot1002"
+
+#define DEFAULT_ATTR (EFI_VARIABLE_NON_VOLATILE | \
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | \
+ EFI_VARIABLE_RUNTIME_ACCESS)
+
+/* "efidebug boot add -b 1000 test1000 virtio 0:1 /EFI/debian/grubaa64.efi" */
+static const u8 boot_1000[] = {
+0x01, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,
+0x74, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x04, 0x14, 0x00, 0xb9, 0x73,
+0x1d, 0xe6, 0x84, 0xa3, 0xcc, 0x4a, 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3,
+0x62, 0x8b, 0x01, 0x04, 0x15, 0x00, 0x92, 0x37, 0x29, 0x63, 0xf5, 0xad,
+0x25, 0x93, 0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e, 0x00, 0x04,
+0x01, 0x2a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57,
+0x5a, 0x47, 0xc2, 0x35, 0x27, 0x44, 0x47, 0x9f, 0x01, 0x67, 0xfe, 0xfa,
+0x1d, 0x06, 0xae, 0x02, 0x02, 0x04, 0x04, 0x36, 0x00, 0x5c, 0x00, 0x45,
+0x00, 0x46, 0x00, 0x49, 0x00, 0x5c, 0x00, 0x64, 0x00, 0x65, 0x00, 0x62,
+0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x72,
+0x00, 0x75, 0x00, 0x62, 0x00, 0x61, 0x00, 0x61, 0x00, 0x36, 0x00, 0x34,
+0x00, 0x2e, 0x00, 0x65, 0x00, 0x66, 0x00, 0x69, 0x00, 0x00, 0x00, 0x7f,
+0xff, 0x04, 0x00 };
+
+/* "efidebug boot add -b 1001 test1001 virtio 0:1 /EFI/debian/grubaa64.efi" */
+static const u8 boot_1001[] = {
+0x01, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,
+0x74, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x04, 0x14, 0x00, 0xb9, 0x73,
+0x1d, 0xe6, 0x84, 0xa3, 0xcc, 0x4a, 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3,
+0x62, 0x8b, 0x01, 0x04, 0x15, 0x00, 0x92, 0x37, 0x29, 0x63, 0xf5, 0xad,
+0x25, 0x93, 0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e, 0x00, 0x04,
+0x01, 0x2a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57,
+0x5a, 0x47, 0xc2, 0x35, 0x27, 0x44, 0x47, 0x9f, 0x01, 0x67, 0xfe, 0xfa,
+0x1d, 0x06, 0xae, 0x02, 0x02, 0x04, 0x04, 0x36, 0x00, 0x5c, 0x00, 0x45,
+0x00, 0x46, 0x00, 0x49, 0x00, 0x5c, 0x00, 0x64, 0x00, 0x65, 0x00, 0x62,
+0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x72,
+0x00, 0x75, 0x00, 0x62, 0x00, 0x61, 0x00, 0x61, 0x00, 0x36, 0x00, 0x34,
+0x00, 0x2e, 0x00, 0x65, 0x00, 0x66, 0x00, 0x69, 0x00, 0x00, 0x00, 0x7f,
+0xff, 0x04, 0x00 };
+
+/* "efidebug boot add -b 1002 test1002 virtio 0:1 /EFI/debian/grubaa64.efi" */
+static const u8 boot_1002[] = {
+0x01, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00,
+0x74, 0x00, 0x32, 0x00, 0x00, 0x00, 0x01, 0x04, 0x14, 0x00, 0xb9, 0x73,
+0x1d, 0xe6, 0x84, 0xa3, 0xcc, 0x4a, 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3,
+0x62, 0x8b, 0x01, 0x04, 0x15, 0x00, 0x92, 0x37, 0x29, 0x63, 0xf5, 0xad,
+0x25, 0x93, 0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e, 0x00, 0x04,
+0x01, 0x2a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57,
+0x5a, 0x47, 0xc2, 0x35, 0x27, 0x44, 0x47, 0x9f, 0x01, 0x67, 0xfe, 0xfa,
+0x1d, 0x06, 0xae, 0x02, 0x02, 0x04, 0x04, 0x36, 0x00, 0x5c, 0x00, 0x45,
+0x00, 0x46, 0x00, 0x49, 0x00, 0x5c, 0x00, 0x64, 0x00, 0x65, 0x00, 0x62,
+0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x72,
+0x00, 0x75, 0x00, 0x62, 0x00, 0x61, 0x00, 0x61, 0x00, 0x36, 0x00, 0x34,
+0x00, 0x2e, 0x00, 0x65, 0x00, 0x66, 0x00, 0x69, 0x00, 0x00, 0x00, 0x7f,
+0xff, 0x04, 0x00};
+
+/* "efidebug boot order 1002 1000 1001" */
+static u8 boot_order[] = {0x02, 0x10, 0x00, 0x10, 0x01, 0x10};
+
+static void *orig_smbios_table;
+static u64 dmi_addr = U32_MAX;
+#define SMBIOS_ENTRY_HEADER_SIZE 0x20
+/* smbios table for the measurement test */
+static u8 smbios_table_test[] = {
+0x5f, 0x53, 0x4d, 0x5f, 0x2c, 0x1f, 0x03, 0x00, 0x54, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x5f, 0x44, 0x4d, 0x49, 0x5f, 0xe4, 0x5c, 0x01,
+0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00,
+0x01, 0x02, 0x00, 0x00, 0x03, 0x00, 0x80, 0x08, 0x01, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x0c, 0x15, 0x0a, 0xff, 0xff, 0x55, 0x2d, 0x42, 0x6f,
+0x6f, 0x74, 0x00, 0x32, 0x30, 0x32, 0x31, 0x2e, 0x31, 0x30, 0x2d, 0x72,
+0x63, 0x34, 0x2d, 0x30, 0x30, 0x30, 0x30, 0x35, 0x2d, 0x67, 0x37, 0x32,
+0x37, 0x63, 0x33, 0x66, 0x33, 0x32, 0x35, 0x39, 0x2d, 0x64, 0x69, 0x72,
+0x74, 0x79, 0x00, 0x31, 0x30, 0x2f, 0x30, 0x31, 0x2f, 0x32, 0x30, 0x32,
+0x31, 0x00, 0x00, 0x01, 0x1b, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x31,
+0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77,
+0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x50, 0x72,
+0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
+0x37, 0x38, 0x00, 0x00, 0x02, 0x0e, 0x02, 0x00, 0x01, 0x02, 0x00, 0x04,
+0x03, 0x01, 0x01, 0x01, 0x00, 0x0a, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77,
+0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x50, 0x72,
+0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+0x33, 0x33, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00,
+0x00, 0x03, 0x15, 0x03, 0x00, 0x01, 0x03, 0x00, 0x02, 0x03, 0x03, 0x03,
+0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x6e,
+0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36,
+0x37, 0x38, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00,
+0x00, 0x04, 0x30, 0x04, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x01, 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x03, 0x04,
+0x04, 0x04, 0x08, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01,
+0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x31, 0x32, 0x33,
+0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33,
+0x33, 0x33, 0x00, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x00,
+0x00, 0x20, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+0x00, 0x00, 0x7f, 0x04, 0x06, 0x00, 0x00, 0x00
+};
+
+#define IDX_ARRAY_SZ 3 /* support 24 PCRs */
+#define TPM2_CMD_BUF_SIZE 64
+/* TPM command is big endian */
+#define __MSB(x) ((x) >> 8)
+#define __LSB(x) ((x) & 0xFF)
+#define tpm_u16(x) __MSB(x), __LSB(x)
+#define tpm_u32(x) tpm_u16((x) >> 16), tpm_u16((x) & 0xFFFF)
+#define TPM2_PCR_READ_HEADER_SIZE 30
+
+static u8 (*pcrs)[TPM2_SHA256_DIGEST_SIZE];
+static u8 expected_pcrs[EFI_TCG2_MAX_PCR_INDEX + 1][TPM2_SHA256_DIGEST_SIZE] = {
+ {0x91, 0x21, 0x37, 0xc7, 0x1a, 0x49, 0x19, 0xc8,
+ 0xf1, 0xfb, 0xa9, 0x84, 0x5c, 0x65, 0xa9, 0xdd,
+ 0x7b, 0xb9, 0xfe, 0xa1, 0xcd, 0x64, 0x49, 0xdd,
+ 0xed, 0xe2, 0x65, 0x82, 0xc5, 0x3e, 0xf4, 0xc4},
+
+ {0xf5, 0x79, 0xf3, 0x20, 0x62, 0x6e, 0x8b, 0x58,
+ 0x62, 0xa3, 0x4e, 0x2f, 0xb7, 0x10, 0xac, 0x34,
+ 0x4e, 0x68, 0x94, 0x37, 0x87, 0x29, 0xc4, 0xbe,
+ 0xa3, 0xc4, 0xd9, 0x14, 0x2b, 0x66, 0x79, 0x9b},
+
+ {0x3d, 0x45, 0x8c, 0xfe, 0x55, 0xcc, 0x03, 0xea,
+ 0x1f, 0x44, 0x3f, 0x15, 0x62, 0xbe, 0xec, 0x8d,
+ 0xf5, 0x1c, 0x75, 0xe1, 0x4a, 0x9f, 0xcf, 0x9a,
+ 0x72, 0x34, 0xa1, 0x3f, 0x19, 0x8e, 0x79, 0x69},
+
+ {0x3d, 0x45, 0x8c, 0xfe, 0x55, 0xcc, 0x03, 0xea,
+ 0x1f, 0x44, 0x3f, 0x15, 0x62, 0xbe, 0xec, 0x8d,
+ 0xf5, 0x1c, 0x75, 0xe1, 0x4a, 0x9f, 0xcf, 0x9a,
+ 0x72, 0x34, 0xa1, 0x3f, 0x19, 0x8e, 0x79, 0x69},
+
+ /* PCR[4] is different per architecture */
+ {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},
+
+ {0x3d, 0x45, 0x8c, 0xfe, 0x55, 0xcc, 0x03, 0xea,
+ 0x1f, 0x44, 0x3f, 0x15, 0x62, 0xbe, 0xec, 0x8d,
+ 0xf5, 0x1c, 0x75, 0xe1, 0x4a, 0x9f, 0xcf, 0x9a,
+ 0x72, 0x34, 0xa1, 0x3f, 0x19, 0x8e, 0x79, 0x69},
+
+ /* PCR[6] is different per architecture */
+ {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},
+
+ {0x96, 0x74, 0xae, 0xcd, 0x3f, 0x40, 0xb4, 0xa9,
+ 0x36, 0xae, 0x19, 0xc8, 0x84, 0x8a, 0xb9, 0x5a,
+ 0x87, 0x99, 0xd8, 0x89, 0x7f, 0xfc, 0x40, 0x48,
+ 0x05, 0x99, 0x65, 0x2e, 0x55, 0xd4, 0x93, 0x32},
+
+ {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},
+
+ {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},
+
+ {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},
+
+ {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},
+
+ {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},
+
+ {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},
+
+ {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},
+
+ {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},
+
+ {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},
+
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+
+ {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
+
+ {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}
+};
+
+/*
+ * PCR[4] and PCR[6] have the PE/COFF image measurement,
+ * this PCRs have different value in each architecture.
+ */
+#if defined(__arm__)
+static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = {
+ /* PCR[4] */
+ {0xcd, 0xa2, 0x06, 0xad, 0x83, 0x9b, 0x8f, 0x92,
+ 0x01, 0xf9, 0xc8, 0x3d, 0xc9, 0x54, 0x66, 0xb3,
+ 0x97, 0x35, 0x88, 0xe1, 0xea, 0xd3, 0x1a, 0xd6,
+ 0x56, 0xee, 0x43, 0x1c, 0xdb, 0x4b, 0xf9, 0x1f},
+ /* PCR[6] */
+ {0x9c, 0xb8, 0x9d, 0x4a, 0xf6, 0x63, 0x95, 0xb0,
+ 0x95, 0xfe, 0x44, 0x30, 0x0f, 0x3a, 0x0b, 0x7c,
+ 0xef, 0xc7, 0xb6, 0x6a, 0x59, 0xae, 0xcb, 0xf6,
+ 0xbd, 0x2d, 0xb5, 0xb9, 0xb4, 0x95, 0x7d, 0xaf}
+};
+#elif defined(__aarch64__)
+static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = {
+ /* PCR[4] */
+ {0x69, 0xdb, 0x01, 0x5e, 0x07, 0xed, 0x9c, 0xbb,
+ 0x27, 0x65, 0xb1, 0xf0, 0x7b, 0x04, 0xbc, 0x31,
+ 0xd1, 0xec, 0x00, 0xe4, 0xe1, 0x49, 0xdb, 0x1e,
+ 0x8b, 0x2d, 0xa2, 0x26, 0xb5, 0x8d, 0x07, 0xe2},
+ /* PCR[6] */
+ {0x53, 0x1b, 0x27, 0xb2, 0x6f, 0x2d, 0xab, 0x9b,
+ 0x6f, 0xbc, 0xd1, 0x8f, 0xc9, 0x14, 0x48, 0xe7,
+ 0x6d, 0x1b, 0xfb, 0x1b, 0x53, 0xc5, 0x8e, 0xf4,
+ 0x41, 0x50, 0x79, 0x24, 0x66, 0x57, 0x7b, 0xf8}
+};
+#elif defined(__i386__)
+static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = {
+ /* PCR[4] */
+ {0xec, 0x5e, 0xdb, 0x68, 0x13, 0x48, 0x36, 0x0a,
+ 0x3a, 0xbc, 0x7b, 0x7b, 0xbc, 0x74, 0x7a, 0xa5,
+ 0x55, 0xea, 0xb9, 0x09, 0x6a, 0x6e, 0xc3, 0x21,
+ 0x51, 0x46, 0x22, 0xd2, 0x9d, 0xc9, 0xd5, 0x6a},
+ /* PCR[6] */
+ {0x26, 0x14, 0xe7, 0xde, 0x91, 0xd1, 0xf3, 0xde,
+ 0x7a, 0xc2, 0x78, 0xaf, 0x4b, 0x2e, 0x05, 0x9d,
+ 0x35, 0x17, 0xee, 0xcc, 0x0e, 0x77, 0x8d, 0x3f,
+ 0x7e, 0x20, 0x75, 0xfa, 0xbc, 0xbc, 0x24, 0x3e}
+};
+#elif defined(__x86_64__)
+static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = {
+ /* PCR[4] */
+ {0x9a, 0x75, 0x99, 0x8b, 0x74, 0x45, 0xb6, 0x26,
+ 0x50, 0xe0, 0xbb, 0xfa, 0x2a, 0xa6, 0x19, 0xec,
+ 0x97, 0x12, 0x0c, 0xb5, 0xc8, 0x2a, 0xfe, 0xe5,
+ 0x29, 0xc8, 0xd3, 0x98, 0xe9, 0xd1, 0x9d, 0xd5},
+ /* PCR[6] */
+ {0xa2, 0xa2, 0xd3, 0xa7, 0x84, 0xc2, 0x95, 0x2a,
+ 0xab, 0x6f, 0xe7, 0xe8, 0x86, 0x9f, 0x99, 0xc6,
+ 0x6a, 0x8c, 0xcc, 0x5c, 0xb8, 0x83, 0xfa, 0x86,
+ 0x56, 0x5e, 0x91, 0x17, 0x0b, 0x5f, 0x54, 0xa8}
+};
+#elif defined(__riscv) && (__riscv_xlen == 32)
+static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = {
+ /* PCR[4] */
+ {0x64, 0xe9, 0x25, 0xb3, 0xd8, 0x33, 0xb3, 0x1b,
+ 0x74, 0x0c, 0x81, 0x45, 0xef, 0x61, 0xf1, 0x87,
+ 0xef, 0x65, 0x67, 0x28, 0x1a, 0x54, 0x97, 0xb2,
+ 0xd3, 0x62, 0x00, 0xe7, 0xb6, 0x7a, 0xd5, 0x8e},
+ /* PCR[6] */
+ {0x82, 0xab, 0xc5, 0x6a, 0xbf, 0x08, 0x43, 0x3f,
+ 0x85, 0xbd, 0x8f, 0x8e, 0x23, 0x62, 0x48, 0x4a,
+ 0x44, 0x53, 0xf0, 0xae, 0x8d, 0x4c, 0xda, 0x04,
+ 0x89, 0x9c, 0x0b, 0x81, 0x3a, 0x53, 0xf3, 0xac}
+};
+#elif defined(__riscv) && (__riscv_xlen == 64)
+static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = {
+ /* PCR[4] */
+ {0x9b, 0x5f, 0x10, 0x24, 0x28, 0x5d, 0x7d, 0x1f,
+ 0x9f, 0xee, 0xe9, 0x90, 0xf1, 0x7a, 0x03, 0xb1,
+ 0x68, 0x7b, 0x28, 0x45, 0x98, 0x5e, 0xf5, 0x5e,
+ 0xc1, 0x22, 0x61, 0x8c, 0x2f, 0xb5, 0xbf, 0x80},
+ /* PCR[6] */
+ {0x6d, 0x16, 0x17, 0xf4, 0x9a, 0xa8, 0x49, 0xc2,
+ 0xf4, 0x9c, 0x35, 0x30, 0x0c, 0xde, 0x65, 0xdb,
+ 0xd3, 0x37, 0x9c, 0xe2, 0x9f, 0x14, 0x81, 0x74,
+ 0xc3, 0x94, 0x8a, 0x9e, 0x26, 0xbf, 0xfb, 0xb2}
+};
+#endif
+
+struct boot_variable {
+ u16 name[16];
+ u8 *buf;
+ efi_uintn_t size;
+ u32 attr;
+ const u8 *test_data;
+ efi_uintn_t test_data_size;
+};
+
+static struct boot_variable boot_variable_test[] = {
+ {u"BootOrder", NULL, 0, DEFAULT_ATTR, boot_order, sizeof(boot_order)},
+ {BOOT_NAME_1000, NULL, 0, DEFAULT_ATTR, boot_1000, sizeof(boot_1000)},
+ {BOOT_NAME_1001, NULL, 0, DEFAULT_ATTR, boot_1001, sizeof(boot_1001)},
+ {BOOT_NAME_1002, NULL, 0, DEFAULT_ATTR, boot_1002, sizeof(boot_1002)},
+};
+
+/*
+ * efi_status_t decompress() - Decompress the disk image.
+ *
+ * @image decompressed disk image
+ * @return status code
+ */
+static efi_status_t decompress(u8 **image)
+{
+ u8 *buf;
+ size_t i;
+ size_t addr;
+ size_t len;
+ efi_status_t ret;
+
+ ret = boottime->allocate_pool(EFI_LOADER_DATA, img.length,
+ (void **)&buf);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Out of memory\n");
+ return ret;
+ }
+ boottime->set_mem(buf, img.length, 0);
+
+ for (i = 0; ; ++i) {
+ if (!img.lines[i].line)
+ break;
+ addr = img.lines[i].addr;
+ len = COMPRESSED_DISK_IMAGE_BLOCK_SIZE;
+ if (addr + len > img.length)
+ len = img.length - addr;
+ boottime->copy_mem(buf + addr, img.lines[i].line, len);
+ }
+ *image = buf;
+ return ret;
+}
+
+/*
+ * efi_status_t setup_boot_variable() - configure dummy boot variables
+ *
+ * Preexisting variable values are saved and will be restored by
+ * calling restore_boot_variable().
+ *
+ * @return status code
+ */
+static efi_status_t setup_boot_variable(void)
+{
+ efi_status_t ret;
+ u32 i;
+ efi_uintn_t size;
+
+ for (i = 0; i < ARRAY_SIZE(boot_variable_test); i++) {
+ size = 0;
+ ret = runtime->get_variable(boot_variable_test[i].name,
+ &efi_global_variable_guid,
+ &boot_variable_test[i].attr,
+ &size,
+ NULL);
+ if (ret == EFI_BUFFER_TOO_SMALL) {
+ /* Variable exists, save the current value */
+ boot_variable_test[i].size = size;
+ ret = boottime->allocate_pool(EFI_LOADER_DATA,
+ boot_variable_test[i].size,
+ (void **)&boot_variable_test[i].buf);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to allocate buffer for boot variable\n");
+ return ret;
+ }
+ ret = runtime->get_variable(boot_variable_test[i].name,
+ &efi_global_variable_guid,
+ &boot_variable_test[i].attr,
+ &boot_variable_test[i].size,
+ boot_variable_test[i].buf);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to get current boot variable\n");
+ return ret;
+ }
+ }
+
+ /* set boot variable for the measurement test */
+ ret = runtime->set_variable(boot_variable_test[i].name,
+ &efi_global_variable_guid,
+ boot_variable_test[i].attr,
+ boot_variable_test[i].test_data_size,
+ boot_variable_test[i].test_data);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to set test boot variable(%d)n", i);
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+/*
+ * efi_status_t restore_boot_variable() - restore original values
+ *
+ * Restore the variable values saved in setup_boot_variable().
+ *
+ * @return status code
+ */
+static efi_status_t restore_boot_variable(void)
+{
+ int i;
+ efi_status_t ret;
+
+ for (i = 0; i < ARRAY_SIZE(boot_variable_test); i++) {
+ if (boot_variable_test[i].buf) {
+ ret = runtime->set_variable(boot_variable_test[i].name,
+ &efi_global_variable_guid,
+ boot_variable_test[i].attr,
+ boot_variable_test[i].size,
+ boot_variable_test[i].buf);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to restore boot variable\n");
+ return ret;
+ }
+ ret = boottime->free_pool(boot_variable_test[i].buf);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to free boot variable\n");
+ return ret;
+ }
+ } else {
+ /* delete the variable used only for testing */
+ ret = runtime->set_variable(boot_variable_test[i].name,
+ &efi_global_variable_guid,
+ 0, 0, NULL);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to delete boot variable\n");
+ return ret;
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ * void *find_smbios_table() - Find smbios table
+ *
+ * @systable system table
+ * @return status code
+ */
+static void *find_smbios_table(const struct efi_system_table *systable)
+{
+ u32 i;
+
+ for (i = 0; i < systable->nr_tables; i++) {
+ if (!guidcmp(&smbios_guid, &systable->tables[i].guid))
+ return systable->tables[i].table;
+ }
+
+ return NULL;
+}
+
+/**
+ * efi_status_t setup_smbios_table() - Prepare the dummy SMBIOS table
+ *
+ * @systable system table
+ * @return status code
+ */
+static efi_status_t setup_smbios_table(const struct efi_system_table *systable)
+{
+ struct smbios_entry *se;
+ efi_status_t ret;
+ /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */
+ void *dmi;
+ char *istart;
+ int isize;
+
+ if (sizeof(smbios_table_test) > EFI_PAGE_SIZE)
+ return EFI_OUT_OF_RESOURCES;
+
+ orig_smbios_table = find_smbios_table(systable);
+
+ /* Reserve 4kiB page for SMBIOS */
+ ret = boottime->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS,
+ EFI_RUNTIME_SERVICES_DATA, 1, &dmi_addr);
+
+ if (ret != EFI_SUCCESS) {
+ /* Could not find space in lowmem, use highmem instead */
+ ret = boottime->allocate_pages(EFI_ALLOCATE_ANY_PAGES,
+ EFI_RUNTIME_SERVICES_DATA, 1,
+ &dmi_addr);
+
+ if (ret != EFI_SUCCESS)
+ return ret;
+ }
+
+ dmi = (void *)(uintptr_t)dmi_addr;
+ se = dmi;
+ boottime->copy_mem(se, smbios_table_test, sizeof(smbios_table_test));
+
+ /* update smbios table start address */
+ se->struct_table_address = (uintptr_t)((u8 *)dmi + SMBIOS_ENTRY_HEADER_SIZE);
+
+ /* calculate checksums */
+ istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET;
+ isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET;
+ se->intermediate_checksum = table_compute_checksum(istart, isize);
+ se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry));
+
+ /* Install SMBIOS information as configuration table */
+ ret = boottime->install_configuration_table(&smbios_guid, dmi);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Cannot install SMBIOS table\n");
+ boottime->free_pages(dmi_addr, 1);
+ }
+
+ return ret;
+}
+
/**
* efi_st_tcg2_setup() - setup test
*
@@ -23,7 +617,193 @@ static const efi_guid_t guid_tcg2 = EFI_TCG2_PROTOCOL_GUID;
static int efi_st_tcg2_setup(const efi_handle_t img_handle,
const struct efi_system_table *systable)
{
+ efi_status_t ret;
+ struct uefi_image_load_event image_load_event;
+
+ image_handle = img_handle;
boottime = systable->boottime;
+ runtime = systable->runtime;
+
+ /* Load the application image into memory */
+ decompress(&image);
+
+ ret = boottime->allocate_pool(EFI_LOADER_DATA,
+ sizeof(struct efi_tcg2_event) +
+ sizeof(struct uefi_image_load_event),
+ (void **)&efi_tcg2_event);
+ if (!efi_tcg2_event)
+ return EFI_ST_FAILURE;
+
+ efi_tcg2_event->size = sizeof(struct efi_tcg2_event) +
+ sizeof(struct uefi_image_load_event);
+ efi_tcg2_event->header.header_size = sizeof(struct efi_tcg2_event_header);
+ efi_tcg2_event->header.header_version = 1;
+ efi_tcg2_event->header.pcr_index = 6;
+ efi_tcg2_event->header.event_type = EV_EFI_RUNTIME_SERVICES_DRIVER;
+ image_load_event.image_location_in_memory = 0x12345678;
+ image_load_event.image_length_in_memory = 0x300000;
+ image_load_event.image_link_time_address = 0x87654321;
+ image_load_event.length_of_device_path = 0;
+ boottime->copy_mem(efi_tcg2_event->event, &image_load_event,
+ sizeof(struct uefi_image_load_event));
+
+ ret = setup_boot_variable();
+ if (ret != EFI_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = setup_smbios_table(systable);
+ if (ret != EFI_SUCCESS)
+ return EFI_ST_FAILURE;
+
+ ret = boottime->allocate_pool(EFI_LOADER_DATA,
+ (EFI_TCG2_MAX_PCR_INDEX + 1) *
+ TPM2_SHA256_DIGEST_SIZE,
+ (void **)&pcrs);
+ if (!pcrs)
+ return EFI_ST_FAILURE;
+
+ boottime->set_mem(pcrs, (EFI_TCG2_MAX_PCR_INDEX + 1) * TPM2_SHA256_DIGEST_SIZE, 0);
+
+ /* setup expected PCRs per architecture */
+ boottime->copy_mem(&expected_pcrs[4], &expected_pcrs_per_arch[0], TPM2_SHA256_DIGEST_SIZE);
+ boottime->copy_mem(&expected_pcrs[6], &expected_pcrs_per_arch[1], TPM2_SHA256_DIGEST_SIZE);
+
+ return EFI_ST_SUCCESS;
+}
+
+/**
+ * efi_status_t get_manufacturer_id() - Get manufacturer_id through submit_command API
+ *
+ * @tcg2 tcg2 protocol
+ * @manufacturer_id pointer to the manufacturer_id
+ * @return status code
+ */
+static efi_status_t get_manufacturer_id(struct efi_tcg2_protocol *tcg2, u32 *manufacturer_id)
+{
+ efi_status_t ret;
+ u8 cmd[TPM2_CMD_BUF_SIZE] = {
+ tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */
+ tpm_u32(22), /* Length */
+ tpm_u32(TPM2_CC_GET_CAPABILITY), /* Command code */
+
+ tpm_u32(TPM2_CAP_TPM_PROPERTIES), /* Capability */
+ tpm_u32(TPM2_PT_MANUFACTURER), /* Property */
+ tpm_u32(1), /* Property count */
+ };
+ u8 resp[TPM2_CMD_BUF_SIZE];
+ unsigned int value_off;
+
+ ret = tcg2->submit_command(tcg2, 22, cmd,
+ TPM2_CMD_BUF_SIZE, resp);
+ if (ret != EFI_SUCCESS)
+ return ret;
+
+ /*
+ * In the response buffer, the properties are located after the:
+ * tag (u16), response size (u32), response code (u32),
+ * YES/NO flag (u8), TPM_CAP (u32).
+ * The value is located after count (u32), property (u32).
+ */
+ value_off = sizeof(u16) + sizeof(u32) + sizeof(u32) +
+ sizeof(u8) + sizeof(u32) + sizeof(u32) + sizeof(u32);
+ *manufacturer_id = get_unaligned_be32(&resp[value_off]);
+
+ return ret;
+}
+
+/**
+ * efi_status_t get_manufacturer_id_buffer_small() - call submit_command with small resp buffer
+ *
+ * @tcg2 tcg2 protocol
+ * @manufacturer_id pointer to the manufacturer_id
+ * @return status code
+ */
+static efi_status_t get_manufacturer_id_buffer_small(struct efi_tcg2_protocol *tcg2)
+{
+ efi_status_t ret;
+ u8 cmd[TPM2_CMD_BUF_SIZE] = {
+ tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */
+ tpm_u32(22), /* Length */
+ tpm_u32(TPM2_CC_GET_CAPABILITY), /* Command code */
+
+ tpm_u32(TPM2_CAP_TPM_PROPERTIES), /* Capability */
+ tpm_u32(TPM2_PT_MANUFACTURER), /* Property */
+ tpm_u32(1), /* Property count */
+ };
+ u8 resp[1]; /* set smaller buffer than expected */
+
+ ret = tcg2->submit_command(tcg2, 22, cmd, 1, resp);
+
+ return ret;
+}
+
+/**
+ * efi_status_t read_pcr() - Read the PCR from the TPM device
+ *
+ * @tcg2 tcg2 protocol
+ * @idx pcr index to read
+ * @return status code
+ */
+static efi_status_t read_pcr(struct efi_tcg2_protocol *tcg2, u32 idx)
+{
+ efi_status_t ret;
+ u32 cmd_len = 17 + IDX_ARRAY_SZ;
+ u8 cmd[TPM2_CMD_BUF_SIZE] = {
+ tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */
+ tpm_u32(cmd_len), /* Length */
+ tpm_u32(TPM2_CC_PCR_READ), /* Command code */
+ /* TPML_PCR_SELECTION */
+ tpm_u32(1), /* Number of selections */
+ tpm_u16(TPM2_ALG_SHA256), /* Algorithm of the hash */
+ IDX_ARRAY_SZ, /* Array size for selection */
+ /* bitmap(idx), Selected PCR bitmap */
+ };
+ u8 resp[TPM2_CMD_BUF_SIZE];
+ u32 pcr_sel_idx = idx / 8;
+ u8 pcr_sel_bit = BIT(idx % 8);
+
+ cmd[17 + pcr_sel_idx] = pcr_sel_bit;
+ ret = tcg2->submit_command(tcg2, cmd_len, cmd,
+ TPM2_CMD_BUF_SIZE, resp);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("tcg2->submit_command fail to read PCR\n");
+ return ret;
+ }
+
+ boottime->copy_mem(pcrs[idx], &resp[TPM2_PCR_READ_HEADER_SIZE],
+ TPM2_SHA256_DIGEST_SIZE);
+
+ return ret;
+}
+
+/**
+ * int validate_pcrs() - Compare the expected and actual pcrs
+ *
+ * @return status code
+ */
+static int validate_pcrs(void)
+{
+ u32 i;
+
+ /*
+ * - Skip PCR[0] validation. PCR[0] contains U-Boot version measurement
+ * it contains the commit hash, so the measurement varies every build
+ * with different commit hash.
+ * - Skip PCR[7] validation. PCR[7] contains UEFI Secure Boot variables
+ * measurement. These variables can not be updated through efi_selftest and
+ * vary depending on the platform.
+ * - Skip PCR[17..22] validation, they are not used in TCG PC Client
+ * Platform Firmware Profile Specification
+ */
+ for (i = 1; i < (EFI_TCG2_MAX_PCR_INDEX + 1); i++) {
+ if (i == 7 || (i > 16 && i < 23))
+ continue; /* skip validation */
+
+ if (memcmp(pcrs[i], expected_pcrs[i], TPM2_SHA256_DIGEST_SIZE)) {
+ efi_st_error("PCR[%d] is not the expected value\n", i);
+ return EFI_ST_FAILURE;
+ }
+ }
return EFI_ST_SUCCESS;
}
@@ -31,7 +811,8 @@ static int efi_st_tcg2_setup(const efi_handle_t img_handle,
/**
* efi_st_tcg2_execute() - execute test
*
- * Call the GetCapability service of the EFI_TCG2_PROTOCOL.
+ * Call EFI_TCG2_PROTOCOL services and check the
+ * Measured Boot behavior.
*
* Return: status code
*/
@@ -40,12 +821,22 @@ static int efi_st_tcg2_execute(void)
struct efi_tcg2_protocol *tcg2;
struct efi_tcg2_boot_service_capability capability;
efi_status_t ret;
+ u32 active_pcr_banks;
+ u64 eventlog, eventlog_last_entry;
+ bool eventlog_truncated;
+ efi_handle_t handle;
+ efi_uintn_t exit_data_size = 0;
+ u16 *exit_data = NULL;
+ u32 i;
+ u32 manufacturer_id;
ret = boottime->locate_protocol(&guid_tcg2, NULL, (void **)&tcg2);
if (ret != EFI_SUCCESS) {
efi_st_error("TCG2 protocol is not available.\n");
return EFI_ST_FAILURE;
}
+
+ /* EFI_TCG2_PROTOCOL.GetCapability test */
capability.size = sizeof(struct efi_tcg2_boot_service_capability) - 1;
ret = tcg2->get_capability(tcg2, &capability);
if (ret != EFI_BUFFER_TOO_SMALL) {
@@ -64,12 +855,161 @@ static int efi_st_tcg2_execute(void)
}
efi_st_printf("TPM supports 0x%.8x event logs\n",
capability.supported_event_logs);
+
+ /* EFI_TCG2_PROTOCOL.GetActivePcrBanks test */
+ ret = tcg2->get_active_pcr_banks(tcg2, &active_pcr_banks);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("tcg2->get_active_pcr_banks failed\n");
+ return EFI_ST_FAILURE;
+ }
+ if (active_pcr_banks != capability.active_pcr_banks) {
+ efi_st_error("tcg2->get_active_pcr_banks return wrong value\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* EFI_TCG2_PROTOCOL.HashLogExtendEvent test */
+ ret = tcg2->hash_log_extend_event(tcg2, EFI_TCG2_EXTEND_ONLY,
+ (uintptr_t)image,
+ img.length, efi_tcg2_event);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("tcg2->hash_log_extend_event(EXTEND_ONLY) failed\n");
+ return EFI_ST_FAILURE;
+ }
+
+ ret = tcg2->hash_log_extend_event(tcg2, PE_COFF_IMAGE, (uintptr_t)image,
+ img.length, efi_tcg2_event);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("tcg2->hash_log_extend_event(PE_COFF_IMAGE) failed\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* EFI_TCG2_PROTOCOL.SubmitCommand test */
+ ret = get_manufacturer_id_buffer_small(tcg2);
+ if (ret != EFI_OUT_OF_RESOURCES) {
+ efi_st_error("get_manufacturer_id buffer too small failed\n");
+ return EFI_ST_FAILURE;
+ }
+
+ ret = get_manufacturer_id(tcg2, &manufacturer_id);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("get_manufacturer_id failed\n");
+ return EFI_ST_FAILURE;
+ }
+ if (capability.manufacturer_id != manufacturer_id) {
+ efi_st_error("tcg2->submit_command test failed\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* tcg2_measure_pe_image test */
+ ret = boottime->load_image(false, image_handle, NULL, image,
+ img.length, &handle);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to load image\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* measure ready_to_boot event(boot variables, smbios table, etc.) */
+ /* TODO: add GPT measurement test */
+ ret = boottime->start_image(handle, &exit_data_size, &exit_data);
+ if (ret != EFI_UNSUPPORTED) {
+ efi_st_error("Wrong return value from application\n");
+ return EFI_ST_FAILURE;
+ }
+ ret = boottime->free_pool(exit_data);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("Failed to free exit data\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* validate PCR read from the TPM device */
+ for (i = 0; i < (EFI_TCG2_MAX_PCR_INDEX + 1); i++) {
+ ret = read_pcr(tcg2, i);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("read pcr error\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+ if (validate_pcrs()) {
+ efi_st_error("PCR validation failed\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /* EFI_TCG2_PROTOCOL.GetEventLog test */
+ ret = tcg2->get_eventlog(tcg2, TCG2_EVENT_LOG_FORMAT_TCG_2, &eventlog,
+ &eventlog_last_entry, &eventlog_truncated);
+ if (ret != EFI_SUCCESS) {
+ efi_st_error("tcg2->get_eventlog failed\n");
+ return EFI_ST_FAILURE;
+ }
+ /* TODO: eventlog format check */
+
return EFI_ST_SUCCESS;
}
+/*
+ * efi_st_tcg2_teardown() - Tear down unit test
+ *
+ * @return: EFI_ST_SUCCESS for success
+ */
+static int efi_st_tcg2_teardown(void)
+{
+ efi_status_t r = EFI_ST_SUCCESS;
+
+ if (image) {
+ r = boottime->free_pool(image);
+ if (r != EFI_SUCCESS) {
+ efi_st_error("Failed to free image\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+ if (efi_tcg2_event) {
+ r = boottime->free_pool(efi_tcg2_event);
+ if (r != EFI_SUCCESS) {
+ efi_st_error("Failed to free efi_tcg2_event\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+ if (pcrs) {
+ r = boottime->free_pool(pcrs);
+ if (r != EFI_SUCCESS) {
+ efi_st_error("Failed to free pcr\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ r = restore_boot_variable();
+ if (r != EFI_SUCCESS) {
+ efi_st_error("Failed to restore boot variables\n");
+ return EFI_ST_FAILURE;
+ }
+
+ /*
+ * Restore SMBIOS table
+ * If orig_smbios_table is NULL, calling install_configuration_table()
+ * removes dummy SMBIOS table form systab.
+ */
+ r = boottime->install_configuration_table(&smbios_guid, orig_smbios_table);
+ if (r != EFI_SUCCESS) {
+ efi_st_error("Failed to restore SMBOIS table\n");
+ return EFI_ST_FAILURE;
+ }
+
+ if (dmi_addr) {
+ r = boottime->free_pages(dmi_addr, 1);
+ if (r != EFI_SUCCESS) {
+ efi_st_error("Failed to free dummy smbios table\n");
+ return EFI_ST_FAILURE;
+ }
+ }
+
+ return r;
+}
+
EFI_UNIT_TEST(tcg2) = {
.name = "tcg2",
.phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT,
.execute = efi_st_tcg2_execute,
.setup = efi_st_tcg2_setup,
+ .teardown = efi_st_tcg2_teardown,
+ .on_request = true,
};
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 959b337cdc8..7681f272d27 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1213,9 +1213,11 @@ static int uncompress_blob(const void *src, ulong sz_src, void **dstp)
* For CONFIG_OF_SEPARATE, the board may optionally implement this to
* provide and/or fixup the fdt.
*/
-__weak void *board_fdt_blob_setup(void)
+__weak void *board_fdt_blob_setup(int *err)
{
void *fdt_blob = NULL;
+
+ *err = 0;
#ifdef CONFIG_SPL_BUILD
/* FDT is at end of BSS unless it is in a different memory region */
if (IS_ENABLED(CONFIG_SPL_SEPARATE_BSS))
@@ -1226,6 +1228,7 @@ __weak void *board_fdt_blob_setup(void)
/* FDT is at end of image */
fdt_blob = (ulong *)&_end;
#endif
+
return fdt_blob;
}
#endif
@@ -1607,12 +1610,9 @@ int fdtdec_setup(void)
# endif
# elif defined(CONFIG_OF_BOARD) || defined(CONFIG_OF_SEPARATE)
/* Allow the board to override the fdt address. */
- gd->fdt_blob = board_fdt_blob_setup();
-# elif defined(CONFIG_OF_HOSTFILE)
- if (sandbox_read_fdt_from_file()) {
- puts("Failed to read control FDT\n");
- return -1;
- }
+ gd->fdt_blob = board_fdt_blob_setup(&ret);
+ if (ret)
+ return ret;
# endif
# ifndef CONFIG_SPL_BUILD
/* Allow the early environment to override the fdt address */
diff --git a/lib/rsa/Kconfig b/lib/rsa/Kconfig
index cf802a6d40a..469596abe7a 100644
--- a/lib/rsa/Kconfig
+++ b/lib/rsa/Kconfig
@@ -1,6 +1,6 @@
config RSA
bool "Use RSA Library"
- select RSA_FREESCALE_EXP if FSL_CAAM && !ARCH_MX7 && !ARCH_MX6 && !ARCH_MX5
+ select RSA_FREESCALE_EXP if FSL_CAAM && !ARCH_MX7 && !ARCH_MX7ULP && !ARCH_MX6 && !ARCH_MX5
select RSA_SOFTWARE_EXP if !RSA_FREESCALE_EXP
help
RSA support. This enables the RSA algorithm used for FIT image
@@ -57,7 +57,7 @@ config RSA_SOFTWARE_EXP
config RSA_FREESCALE_EXP
bool "Enable RSA Modular Exponentiation with FSL crypto accelerator"
- depends on DM && FSL_CAAM && !ARCH_MX7 && !ARCH_MX6 && !ARCH_MX5
+ depends on DM && FSL_CAAM && !ARCH_MX7 && !ARCH_MX7ULP && !ARCH_MX6 && !ARCH_MX5
help
Enables driver for RSA modular exponentiation using Freescale cryptographic
accelerator - CAAM.
diff --git a/lib/rsa/rsa-verify.c b/lib/rsa/rsa-verify.c
index 600c93ab810..83f7564101c 100644
--- a/lib/rsa/rsa-verify.c
+++ b/lib/rsa/rsa-verify.c
@@ -340,7 +340,7 @@ static int rsa_verify_key(struct image_sign_info *info,
struct padding_algo *padding = info->padding;
int hash_len;
- if (!prop || !sig || !hash || !checksum)
+ if (!prop || !sig || !hash || !checksum || !padding)
return -EIO;
if (sig_len != (prop->num_bits / 8)) {
diff --git a/lib/smbios-parser.c b/lib/smbios-parser.c
index 34203f952c9..2b9392936b9 100644
--- a/lib/smbios-parser.c
+++ b/lib/smbios-parser.c
@@ -39,10 +39,8 @@ const struct smbios_entry *smbios_entry(u64 address, u32 size)
return entry;
}
-static const struct smbios_header *next_header(const struct smbios_header *curr)
+static u8 *find_next_header(u8 *pos)
{
- u8 *pos = ((u8 *)curr) + curr->length;
-
/* search for _double_ NULL bytes */
while (!((*pos == 0) && (*(pos + 1) == 0)))
pos++;
@@ -50,13 +48,27 @@ static const struct smbios_header *next_header(const struct smbios_header *curr)
/* step behind the double NULL bytes */
pos += 2;
- return (struct smbios_header *)pos;
+ return pos;
+}
+
+static struct smbios_header *get_next_header(struct smbios_header *curr)
+{
+ u8 *pos = ((u8 *)curr) + curr->length;
+
+ return (struct smbios_header *)find_next_header(pos);
+}
+
+static const struct smbios_header *next_header(const struct smbios_header *curr)
+{
+ u8 *pos = ((u8 *)curr) + curr->length;
+
+ return (struct smbios_header *)find_next_header(pos);
}
const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type)
{
const unsigned int num_header = entry->struct_count;
- const struct smbios_header *header = (struct smbios_header *)entry->struct_table_address;
+ const struct smbios_header *header = (struct smbios_header *)((uintptr_t)entry->struct_table_address);
for (unsigned int i = 0; i < num_header; i++) {
if (header->type == type)
@@ -68,8 +80,8 @@ const struct smbios_header *smbios_header(const struct smbios_entry *entry, int
return NULL;
}
-static const char *string_from_smbios_table(const struct smbios_header *header,
- int idx)
+static char *string_from_smbios_table(const struct smbios_header *header,
+ int idx)
{
unsigned int i = 1;
u8 *pos;
@@ -86,10 +98,10 @@ static const char *string_from_smbios_table(const struct smbios_header *header,
pos++;
}
- return (const char *)pos;
+ return (char *)pos;
}
-const char *smbios_string(const struct smbios_header *header, int index)
+char *smbios_string(const struct smbios_header *header, int index)
{
if (!header)
return NULL;
@@ -109,7 +121,7 @@ int smbios_update_version_full(void *smbios_tab, const char *version)
if (!hdr)
return log_msg_ret("tab", -ENOENT);
bios = (struct smbios_type0 *)hdr;
- ptr = (char *)smbios_string(hdr, bios->bios_ver);
+ ptr = smbios_string(hdr, bios->bios_ver);
if (!ptr)
return log_msg_ret("str", -ENOMEDIUM);
@@ -132,3 +144,123 @@ int smbios_update_version_full(void *smbios_tab, const char *version)
return 0;
}
+
+struct smbios_filter_param {
+ u32 offset;
+ u32 size;
+ bool is_string;
+};
+
+struct smbios_filter_table {
+ int type;
+ struct smbios_filter_param *params;
+ u32 count;
+};
+
+struct smbios_filter_param smbios_type1_filter_params[] = {
+ {offsetof(struct smbios_type1, serial_number),
+ FIELD_SIZEOF(struct smbios_type1, serial_number), true},
+ {offsetof(struct smbios_type1, uuid),
+ FIELD_SIZEOF(struct smbios_type1, uuid), false},
+ {offsetof(struct smbios_type1, wakeup_type),
+ FIELD_SIZEOF(struct smbios_type1, wakeup_type), false},
+};
+
+struct smbios_filter_param smbios_type2_filter_params[] = {
+ {offsetof(struct smbios_type2, serial_number),
+ FIELD_SIZEOF(struct smbios_type2, serial_number), true},
+ {offsetof(struct smbios_type2, chassis_location),
+ FIELD_SIZEOF(struct smbios_type2, chassis_location), false},
+};
+
+struct smbios_filter_param smbios_type3_filter_params[] = {
+ {offsetof(struct smbios_type3, serial_number),
+ FIELD_SIZEOF(struct smbios_type3, serial_number), true},
+ {offsetof(struct smbios_type3, asset_tag_number),
+ FIELD_SIZEOF(struct smbios_type3, asset_tag_number), true},
+};
+
+struct smbios_filter_param smbios_type4_filter_params[] = {
+ {offsetof(struct smbios_type4, serial_number),
+ FIELD_SIZEOF(struct smbios_type4, serial_number), true},
+ {offsetof(struct smbios_type4, asset_tag),
+ FIELD_SIZEOF(struct smbios_type4, asset_tag), true},
+ {offsetof(struct smbios_type4, part_number),
+ FIELD_SIZEOF(struct smbios_type4, part_number), true},
+ {offsetof(struct smbios_type4, core_count),
+ FIELD_SIZEOF(struct smbios_type4, core_count), false},
+ {offsetof(struct smbios_type4, core_enabled),
+ FIELD_SIZEOF(struct smbios_type4, core_enabled), false},
+ {offsetof(struct smbios_type4, thread_count),
+ FIELD_SIZEOF(struct smbios_type4, thread_count), false},
+ {offsetof(struct smbios_type4, core_count2),
+ FIELD_SIZEOF(struct smbios_type4, core_count2), false},
+ {offsetof(struct smbios_type4, core_enabled2),
+ FIELD_SIZEOF(struct smbios_type4, core_enabled2), false},
+ {offsetof(struct smbios_type4, thread_count2),
+ FIELD_SIZEOF(struct smbios_type4, thread_count2), false},
+ {offsetof(struct smbios_type4, voltage),
+ FIELD_SIZEOF(struct smbios_type4, voltage), false},
+};
+
+struct smbios_filter_table smbios_filter_tables[] = {
+ {SMBIOS_SYSTEM_INFORMATION, smbios_type1_filter_params,
+ ARRAY_SIZE(smbios_type1_filter_params)},
+ {SMBIOS_BOARD_INFORMATION, smbios_type2_filter_params,
+ ARRAY_SIZE(smbios_type2_filter_params)},
+ {SMBIOS_SYSTEM_ENCLOSURE, smbios_type3_filter_params,
+ ARRAY_SIZE(smbios_type3_filter_params)},
+ {SMBIOS_PROCESSOR_INFORMATION, smbios_type4_filter_params,
+ ARRAY_SIZE(smbios_type4_filter_params)},
+};
+
+static void clear_smbios_table(struct smbios_header *header,
+ struct smbios_filter_param *filter,
+ u32 count)
+{
+ u32 i;
+ char *str;
+ u8 string_id;
+
+ for (i = 0; i < count; i++) {
+ if (filter[i].is_string) {
+ string_id = *((u8 *)header + filter[i].offset);
+ if (string_id == 0) /* string is empty */
+ continue;
+
+ str = smbios_string(header, string_id);
+ if (!str)
+ continue;
+
+ /* string is cleared to space, keep '\0' terminator */
+ memset(str, ' ', strlen(str));
+
+ } else {
+ memset((void *)((u8 *)header + filter[i].offset),
+ 0, filter[i].size);
+ }
+ }
+}
+
+void smbios_prepare_measurement(const struct smbios_entry *entry,
+ struct smbios_header *smbios_copy)
+{
+ u32 i, j;
+ struct smbios_header *header;
+
+ for (i = 0; i < ARRAY_SIZE(smbios_filter_tables); i++) {
+ header = smbios_copy;
+ for (j = 0; j < entry->struct_count; j++) {
+ if (header->type == smbios_filter_tables[i].type)
+ break;
+
+ header = get_next_header(header);
+ }
+ if (j >= entry->struct_count)
+ continue;
+
+ clear_smbios_table(header,
+ smbios_filter_tables[i].params,
+ smbios_filter_tables[i].count);
+ }
+}
diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c
index 235f8c20d43..2e7b27bd6bb 100644
--- a/lib/tpm-v2.c
+++ b/lib/tpm-v2.c
@@ -659,3 +659,9 @@ u32 tpm2_disable_platform_hierarchy(struct udevice *dev)
return 0;
}
+
+u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf,
+ u8 *recvbuf, size_t *recv_size)
+{
+ return tpm_sendrecv_command(dev, sendbuf, recvbuf, recv_size);
+}
diff --git a/lib/uuid.c b/lib/uuid.c
index 67267c66a3c..e4703dce2b5 100644
--- a/lib/uuid.c
+++ b/lib/uuid.c
@@ -257,7 +257,7 @@ void gen_rand_uuid(unsigned char *uuid_bin)
if (IS_ENABLED(CONFIG_DM_RNG)) {
ret = uclass_get_device(UCLASS_RNG, 0, &devp);
- if (ret) {
+ if (!ret) {
ret = dm_rng_read(devp, &randv, sizeof(randv));
if (ret < 0)
randv = 0;
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index d7ee35b4773..e634bd70b66 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -816,11 +816,12 @@ int vprintf(const char *fmt, va_list args)
}
#endif
+static char local_toa[22];
+
char *simple_itoa(ulong i)
{
/* 21 digits plus null terminator, good for 64-bit or smaller ints */
- static char local[22];
- char *p = &local[21];
+ char *p = &local_toa[21];
*p-- = '\0';
do {
@@ -830,6 +831,21 @@ char *simple_itoa(ulong i)
return p + 1;
}
+char *simple_xtoa(ulong num)
+{
+ /* 16 digits plus nul terminator, good for 64-bit or smaller ints */
+ char *p = &local_toa[17];
+
+ *--p = '\0';
+ do {
+ p -= 2;
+ hex_byte_pack(p, num & 0xff);
+ num >>= 8;
+ } while (num > 0);
+
+ return p;
+}
+
/* We don't seem to have %'d in U-Boot */
void print_grouped_ull(unsigned long long int_val, int digits)
{