diff mbox series

[v2,1/1] efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot

Message ID 20211104104546.13696-2-masahisa.kojima@linaro.org
State New
Headers show
Series add selftest for EFI_TCG2_PROTOCOL and Measured Boot | expand

Commit Message

Masahisa Kojima Nov. 4, 2021, 10:45 a.m. UTC
This commit adds the missing EFI_TCG2_PROTOCOL selftest
and Measured Boot selftest in lib/efi_selftest.

This selftest includes PE/COFF image measurement test,
some PCR values are different in each architecture.
With that, this commit also adds the pre-build efi application
for PE/COFF image measurement test for 32-bit arm, arm64,
ia32, x86_64, riscv32 and riscv64.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>

---
 lib/efi_selftest/efi_miniapp_tcg2_arm.h     | 152 ++++
 lib/efi_selftest/efi_miniapp_tcg2_arm64.h   | 207 +++++
 lib/efi_selftest/efi_miniapp_tcg2_ia32.h    | 177 ++++
 lib/efi_selftest/efi_miniapp_tcg2_riscv32.h | 173 ++++
 lib/efi_selftest/efi_miniapp_tcg2_riscv64.h | 189 ++++
 lib/efi_selftest/efi_miniapp_tcg2_x86_64.h  | 178 ++++
 lib/efi_selftest/efi_selftest_tcg2.c        | 941 +++++++++++++++++++-
 7 files changed, 2016 insertions(+), 1 deletion(-)
 create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm.h
 create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm64.h
 create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_ia32.h
 create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv32.h
 create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv64.h
 create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_x86_64.h

-- 
2.17.1

Comments

Simon Glass Nov. 5, 2021, 2:02 a.m. UTC | #1
Hi,

On Thu, 4 Nov 2021 at 04:43, Masahisa Kojima <masahisa.kojima@linaro.org> wrote:
>

> This commit adds the missing EFI_TCG2_PROTOCOL selftest

> and Measured Boot selftest in lib/efi_selftest.

>

> This selftest includes PE/COFF image measurement test,

> some PCR values are different in each architecture.

> With that, this commit also adds the pre-build efi application

> for PE/COFF image measurement test for 32-bit arm, arm64,

> ia32, x86_64, riscv32 and riscv64.

>

> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>

> ---

>  lib/efi_selftest/efi_miniapp_tcg2_arm.h     | 152 ++++

>  lib/efi_selftest/efi_miniapp_tcg2_arm64.h   | 207 +++++

>  lib/efi_selftest/efi_miniapp_tcg2_ia32.h    | 177 ++++

>  lib/efi_selftest/efi_miniapp_tcg2_riscv32.h | 173 ++++

>  lib/efi_selftest/efi_miniapp_tcg2_riscv64.h | 189 ++++

>  lib/efi_selftest/efi_miniapp_tcg2_x86_64.h  | 178 ++++

>  lib/efi_selftest/efi_selftest_tcg2.c        | 941 +++++++++++++++++++-

>  7 files changed, 2016 insertions(+), 1 deletion(-)

>  create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm.h

>  create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm64.h

>  create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_ia32.h

>  create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv32.h

>  create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv64.h

>  create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_x86_64.h


I assume this was generated somehow. Can you add the script to docs or
something like that?

Regards,
Simon
Heinrich Schuchardt Nov. 7, 2021, 10:16 a.m. UTC | #2
On 11/4/21 11:45, Masahisa Kojima wrote:
> This commit adds the missing EFI_TCG2_PROTOCOL selftest
> and Measured Boot selftest in lib/efi_selftest.
>
> This selftest includes PE/COFF image measurement test,
> some PCR values are different in each architecture.
> With that, this commit also adds the pre-build efi application
> for PE/COFF image measurement test for 32-bit arm, arm64,
> ia32, x86_64, riscv32 and riscv64.

Please, add some information about the includes here:

* From which C code were they compiled?
* State that the precompiled form is needed due the problem of
reproducible builds.

>
> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
> ---
>   lib/efi_selftest/efi_miniapp_tcg2_arm.h     | 152 ++++
>   lib/efi_selftest/efi_miniapp_tcg2_arm64.h   | 207 +++++
>   lib/efi_selftest/efi_miniapp_tcg2_ia32.h    | 177 ++++
>   lib/efi_selftest/efi_miniapp_tcg2_riscv32.h | 173 ++++
>   lib/efi_selftest/efi_miniapp_tcg2_riscv64.h | 189 ++++
>   lib/efi_selftest/efi_miniapp_tcg2_x86_64.h  | 178 ++++
>   lib/efi_selftest/efi_selftest_tcg2.c        | 941 +++++++++++++++++++-
>   7 files changed, 2016 insertions(+), 1 deletion(-)
>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm.h
>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm64.h
>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_ia32.h
>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv32.h
>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv64.h
>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_x86_64.h
>
> 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 0000000000..37ce1a0ce5
> --- /dev/null
> +++ b/lib/efi_selftest/efi_miniapp_tcg2_arm.h
> @@ -0,0 +1,152 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + *  Non-zero 8 byte strings of a disk image
> + *
> + *  Generated with tools/file2include

Please, edit the headers of the includes and describe from which C code
the EFI binaries were compiled.

To me it looks like lib/efi_selftest/efi_miniapp_file_image_exit.c.

How about:

+/* 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.
+ */

Best regards

Heinrich

> + */
> +
> +#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 0000000000..e824ac8312
> --- /dev/null
> +++ b/lib/efi_selftest/efi_miniapp_tcg2_arm64.h
> @@ -0,0 +1,207 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + *  Non-zero 8 byte strings of a disk image
> + *
> + *  Generated with tools/file2include
> + */
> +
> +#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 0000000000..465ea1aded
> --- /dev/null
> +++ b/lib/efi_selftest/efi_miniapp_tcg2_ia32.h
> @@ -0,0 +1,177 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + *  Non-zero 8 byte strings of a disk image
> + *
> + *  Generated with tools/file2include
> + */
> +
> +#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 0000000000..3dc1b1b83e
> --- /dev/null
> +++ b/lib/efi_selftest/efi_miniapp_tcg2_riscv32.h
> @@ -0,0 +1,173 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + *  Non-zero 8 byte strings of a disk image
> + *
> + *  Generated with tools/file2include
> + */
> +
> +#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 0000000000..621c5731c4
> --- /dev/null
> +++ b/lib/efi_selftest/efi_miniapp_tcg2_riscv64.h
> @@ -0,0 +1,189 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + *  Non-zero 8 byte strings of a disk image
> + *
> + *  Generated with tools/file2include
> + */
> +
> +#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 0000000000..a0b9347a86
> --- /dev/null
> +++ b/lib/efi_selftest/efi_miniapp_tcg2_x86_64.h
> @@ -0,0 +1,178 @@
> +/* SPDX-License-Identifier: GPL-2.0+ */
> +/*
> + *  Non-zero 8 byte strings of a disk image
> + *
> + *  Generated with tools/file2include
> + */
> +
> +#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_tcg2.c b/lib/efi_selftest/efi_selftest_tcg2.c
> index 1399309cec..6bc677c096 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,160 @@ 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,
>   };
>
Heinrich Schuchardt Nov. 7, 2021, 2:43 p.m. UTC | #3
On 11/7/21 11:16, Heinrich Schuchardt wrote:
> On 11/4/21 11:45, Masahisa Kojima wrote:
>> This commit adds the missing EFI_TCG2_PROTOCOL selftest
>> and Measured Boot selftest in lib/efi_selftest.
>>
>> This selftest includes PE/COFF image measurement test,
>> some PCR values are different in each architecture.
>> With that, this commit also adds the pre-build efi application
>> for PE/COFF image measurement test for 32-bit arm, arm64,
>> ia32, x86_64, riscv32 and riscv64.
> 
> Please, add some information about the includes here:
> 
> * From which C code were they compiled?
> * State that the precompiled form is needed due the problem of
> reproducible builds.
> 
>>
>> Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
>> ---
>>   lib/efi_selftest/efi_miniapp_tcg2_arm.h     | 152 ++++
>>   lib/efi_selftest/efi_miniapp_tcg2_arm64.h   | 207 +++++
>>   lib/efi_selftest/efi_miniapp_tcg2_ia32.h    | 177 ++++
>>   lib/efi_selftest/efi_miniapp_tcg2_riscv32.h | 173 ++++
>>   lib/efi_selftest/efi_miniapp_tcg2_riscv64.h | 189 ++++
>>   lib/efi_selftest/efi_miniapp_tcg2_x86_64.h  | 178 ++++
>>   lib/efi_selftest/efi_selftest_tcg2.c        | 941 +++++++++++++++++++-
>>   7 files changed, 2016 insertions(+), 1 deletion(-)
>>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm.h
>>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_arm64.h
>>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_ia32.h
>>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv32.h
>>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_riscv64.h
>>   create mode 100644 lib/efi_selftest/efi_miniapp_tcg2_x86_64.h
>>
>> 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 0000000000..37ce1a0ce5
>> --- /dev/null
>> +++ b/lib/efi_selftest/efi_miniapp_tcg2_arm.h
>> @@ -0,0 +1,152 @@
>> +/* SPDX-License-Identifier: GPL-2.0+ */
>> +/*
>> + *  Non-zero 8 byte strings of a disk image
>> + *
>> + *  Generated with tools/file2include
> 
> Please, edit the headers of the includes and describe from which C code
> the EFI binaries were compiled.
> 
> To me it looks like lib/efi_selftest/efi_miniapp_file_image_exit.c.
> 
> How about:
> 
> +/* 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.
> + */
> 
> Best regards
> 
> Heinrich
> 
>> + */

<snip/>

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

Is this really a failure? It could simply be that no TPM chip or 
emulation is available. We could imply write a warning and exit with 
EFI_SUCCESS. But as described below we have to make the test "onrequest" 
let's leave this now as iss

>>       }
>> +
>> +    /* 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,160 @@ 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,

Please add:

.on_request = true,

because we have to execute tpm2 startup TPM2_SU_CLEAR before it can succeed.

Best regards

Heinrich

>>   };
>>
diff mbox series

Patch

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 0000000000..37ce1a0ce5
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_arm.h
@@ -0,0 +1,152 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  Non-zero 8 byte strings of a disk image
+ *
+ *  Generated with tools/file2include
+ */
+
+#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 0000000000..e824ac8312
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_arm64.h
@@ -0,0 +1,207 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  Non-zero 8 byte strings of a disk image
+ *
+ *  Generated with tools/file2include
+ */
+
+#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 0000000000..465ea1aded
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_ia32.h
@@ -0,0 +1,177 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  Non-zero 8 byte strings of a disk image
+ *
+ *  Generated with tools/file2include
+ */
+
+#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 0000000000..3dc1b1b83e
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_riscv32.h
@@ -0,0 +1,173 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  Non-zero 8 byte strings of a disk image
+ *
+ *  Generated with tools/file2include
+ */
+
+#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 0000000000..621c5731c4
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_riscv64.h
@@ -0,0 +1,189 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  Non-zero 8 byte strings of a disk image
+ *
+ *  Generated with tools/file2include
+ */
+
+#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 0000000000..a0b9347a86
--- /dev/null
+++ b/lib/efi_selftest/efi_miniapp_tcg2_x86_64.h
@@ -0,0 +1,178 @@ 
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ *  Non-zero 8 byte strings of a disk image
+ *
+ *  Generated with tools/file2include
+ */
+
+#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_tcg2.c b/lib/efi_selftest/efi_selftest_tcg2.c
index 1399309cec..6bc677c096 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,160 @@  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,
 };