From c6e13c71517181df0660ea79aba2b1c40b86cbf4 Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Thu, 21 Oct 2021 07:20:12 +0200 Subject: [PATCH 01/17] doc: Remove obsolete doc/README.nand-boot-ppc440 The PPC440 support has been removed in commit 98f705c9ce ("powerpc: remove 4xx support"). This patch removes this obsolete file as well. Signed-off-by: Stefan Roese Cc: Heinrich Schuchardt Cc: Thomas Huth Reviewed-by: Thomas Huth --- doc/README.nand-boot-ppc440 | 60 ------------------------------------- 1 file changed, 60 deletions(-) delete mode 100644 doc/README.nand-boot-ppc440 diff --git a/doc/README.nand-boot-ppc440 b/doc/README.nand-boot-ppc440 deleted file mode 100644 index 1e9c102644..0000000000 --- a/doc/README.nand-boot-ppc440 +++ /dev/null @@ -1,60 +0,0 @@ ------------------------------ -NAND boot on PPC440 platforms ------------------------------ - -This document describes the U-Boot NAND boot feature as it -is implemented for the AMCC Sequoia (PPC440EPx) board. - -The PPC440EP(x)/GR(x) cpu's can boot directly from NAND FLASH, -completely without NOR FLASH. This can be done by using the NAND -boot feature of the 440 NAND flash controller (NDFC). - -Here a short description of the different boot stages: - -a) IPL (Initial Program Loader, integrated inside CPU) ------------------------------------------------------- -Will load first 4k from NAND (SPL) into cache and execute it from there. - -b) SPL (Secondary Program Loader) ---------------------------------- -Will load special U-Boot version (NUB) from NAND and execute it. This SPL -has to fit into 4kByte. It sets up the CPU and configures the SDRAM -controller and the NAND controller so that the special U-Boot image can be -loaded from NAND to SDRAM. -This special image is build in the directory "nand_spl". - -c) NUB (NAND U-Boot) --------------------- -This NAND U-Boot (NUB) is a special U-Boot version which can be started -from RAM. Therefore it mustn't (re-)configure the SDRAM controller. - -On 440EPx the SPL is copied to internal SRAM before the NAND controller -is set up. While still running from cache, I experienced problems accessing -the NAND controller. - - -Example: Build and install NAND boot image for Sequoia (440EPx): - -a) Configure for sequoia with NAND boot support: -# make sequoia_nand_config - -b) Build image(s) -# make - -This will generate the SPL image in the "nand_spl" directory: -nand_spl/u-boot-spl.bin -Also another image is created spanning a whole NAND block (16kBytes): -nand_spl/u-boot-spl-16k.bin -The main NAND U-Boot image is generated in the toplevel directory: -u-boot.bin -A combined image of u-boot-spl-16k.bin and u-boot.bin is also created: -u-boot-nand.bin - -This image should be programmed at offset 0 in the NAND flash: - -# tftp 100000 /tftpboot/sequoia/u-boot-nand.bin -# nand erase 0 60000 -# nand write 100000 0 60000 - - -September 07 2006, Stefan Roese From a212f5d09c1b2919dbf42b7e4129721691fd54a0 Mon Sep 17 00:00:00 2001 From: Thomas Huth Date: Tue, 26 Oct 2021 08:13:04 +0200 Subject: [PATCH 02/17] doc: Remove the obsolete README.AMCC-eval-boards-cleanup file The related boards have been removed four years ago already, in commit 98f705c9cefd ("powerpc: remove 4xx support"), so this README file is not required anymore. Signed-off-by: Thomas Huth Reviewed-by: Stefan Roese --- doc/README.AMCC-eval-boards-cleanup | 31 ----------------------------- 1 file changed, 31 deletions(-) delete mode 100644 doc/README.AMCC-eval-boards-cleanup diff --git a/doc/README.AMCC-eval-boards-cleanup b/doc/README.AMCC-eval-boards-cleanup deleted file mode 100644 index 901bd875c6..0000000000 --- a/doc/README.AMCC-eval-boards-cleanup +++ /dev/null @@ -1,31 +0,0 @@ ---------------------------------------------------------------------- -Cleanup of AMCC eval boards (Walnut/Sycamore, Bubinga, Ebony, Ocotea) ---------------------------------------------------------------------- - -Changes to all AMCC eval boards: --------------------------------- - -o Changed u-boot image size to 256 kBytes instead of 512 kBytes on most - boards. - -o Use 115200 baud as default console baudrate. - -o Added config option to use redundant environment in flash. This is also - the default setting. Option for environment in nvram is still available - for backward compatibility. - -o Merged board specific flash drivers to common flash driver: - board/amcc/common/flash.c - - -Sycamore/Walnut (one port supporting both eval boards): -------------------------------------------------------- - -o Cleanup to allow easier "cloning" for different (custom) boards: - - o Moved EBC configuration from board specific asm-file "init.S" - using defines in board configuration file. No board specific - asm file needed anymore. - - -August 01 2005, Stefan Roese From 212f078496e4b9df0794fd4f56e0ab342b7efbf9 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 5 Nov 2021 16:35:44 +0100 Subject: [PATCH 03/17] doc: mmc rescan speed mode Provide human readable descriptions of the speed nodes instead of the name of constants from the code. Signed-off-by: Heinrich Schuchardt --- doc/usage/mmc.rst | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/doc/usage/mmc.rst b/doc/usage/mmc.rst index d15b151884..02b5d7b1c7 100644 --- a/doc/usage/mmc.rst +++ b/doc/usage/mmc.rst @@ -51,22 +51,26 @@ The 'mmc rescan' command scans the available MMC device. mode speed mode to set. - CONFIG_MMC_SPEED_MODE_SET should be enabled. The required speed mode is - passed as the index from the following list. + CONFIG_MMC_SPEED_MODE_SET should be enabled. The requested speed mode is + passed as a decimal number according to the following table: - 0 - MMC_LEGACY - 1 - MMC_HS - 2 - SD_HS - 3 - MMC_HS_52 - 4 - MMC_DDR_52 - 5 - UHS_SDR12 - 6 - UHS_SDR25 - 7 - UHS_SDR50 - 8 - UHS_DDR50 - 9 - UHS_SDR104 - 10 - MMC_HS_200 - 11 - MMC_HS_400 - 12 - MMC_HS_400_ES + ========== ========================== + Speed mode Description + ========== ========================== + 0 MMC legacy + 1 MMC High Speed (26MHz) + 2 SD High Speed (50MHz) + 3 MMC High Speed (52MHz) + 4 MMC DDR52 (52MHz) + 5 UHS SDR12 (25MHz) + 6 UHS SDR25 (50MHz) + 7 UHS SDR50 (100MHz) + 8 UHS DDR50 (50MHz) + 9 UHS SDR104 (208MHz) + 10 HS200 (200MHz) + 11 HS400 (200MHz) + 12 HS400ES (200MHz) + ========== ========================== A speed mode can be set only if it has already been enabled in the device tree From 50b05eb6060a67d2cdf9b5114c4575e3f803551e Mon Sep 17 00:00:00 2001 From: AKASHI Takahiro Date: Tue, 2 Nov 2021 09:55:01 +0900 Subject: [PATCH 04/17] efi_loader: capsule: drop __weak from efi_get_public_key_data() As we discussed in ML, currently a device tree is the only place to store public keys for capsule authentication. So __weak is not necessary for now. Signed-off-by: AKASHI Takahiro Reviewed-by: Simon Glass --- lib/efi_loader/efi_capsule.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_capsule.c b/lib/efi_loader/efi_capsule.c index 44f5da61a9..850937fd12 100644 --- a/lib/efi_loader/efi_capsule.c +++ b/lib/efi_loader/efi_capsule.c @@ -256,7 +256,7 @@ out: } #if defined(CONFIG_EFI_CAPSULE_AUTHENTICATE) -int __weak efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len) +int efi_get_public_key_data(void **pkey, efi_uintn_t *pkey_len) { const void *fdt_blob = gd->fdt_blob; const void *blob; From 14cbb330fe8e2723871926a3806954393da83cce Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Wed, 3 Nov 2021 11:04:09 +0900 Subject: [PATCH 05/17] efi_loader: use byteshift unaligned access helper Calling unaligned/access-ok.h version of put_unaligned_le64() causes data abort in arm 32-bit QEMU. The similar issue also occurs in linux kernel, unaligned/access-ok.h is no longer used in linux kernel[1]. This commit uses the unaligned/be_byteshift.h and unaligned/le_byteshift.h helper instead of unaligned/access-ok.h. [1]https://lore.kernel.org/all/20210507220813.365382-8-arnd@kernel.org/ Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas Reviewed-by: Heinrich Schuchardt --- lib/efi_loader/efi_tcg2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index ec20530b6b..64d3d32679 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -22,7 +22,8 @@ #include #include #include -#include +#include +#include #include #include From 7fc93cae4903c5332b8ae94e1517f7c79f250a4d Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Thu, 4 Nov 2021 22:59:16 +0900 Subject: [PATCH 06/17] efi_loader: add EFI_TCG2_PROTOCOL.SubmitCommand This commit adds the EFI_TCG2_PROTOCOL.SubmitCommand required in the TCG PC Client PFP spec. SubmitCommand enables to send the raw command to the TPM device. To implement this api, tpm2_submit_command() is added into tpm-v2.c. Signed-off-by: Masahisa Kojima Reviewed-by: Ilias Apalodimas --- include/tpm-v2.h | 13 +++++++++++++ lib/efi_loader/efi_tcg2.c | 38 ++++++++++++++++++++++++++++++++------ lib/tpm-v2.c | 6 ++++++ 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/include/tpm-v2.h b/include/tpm-v2.h index 13b3db67c6..947458b0bd 100644 --- a/include/tpm-v2.h +++ b/include/tpm-v2.h @@ -641,4 +641,17 @@ u32 tpm2_write_lock(struct udevice *dev, u32 index); */ u32 tpm2_disable_platform_hierarchy(struct udevice *dev); +/** + * submit user specified data to the TPM and get response + * + * @dev TPM device + * @sendbuf: Buffer of the data to send + * @recvbuf: Buffer to save the response to + * @recv_size: Pointer to the size of the response buffer + * + * @return code of the operation + */ +u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf, + u8 *recvbuf, size_t *recv_size); + #endif /* __TPM_V2_H */ diff --git a/lib/efi_loader/efi_tcg2.c b/lib/efi_loader/efi_tcg2.c index 64d3d32679..586f73af6d 100644 --- a/lib/efi_loader/efi_tcg2.c +++ b/lib/efi_loader/efi_tcg2.c @@ -1034,13 +1034,39 @@ out: * Return: status code */ static efi_status_t EFIAPI -efi_tcg2_submit_command(__maybe_unused struct efi_tcg2_protocol *this, - u32 __maybe_unused input_param_block_size, - u8 __maybe_unused *input_param_block, - u32 __maybe_unused output_param_block_size, - u8 __maybe_unused *output_param_block) +efi_tcg2_submit_command(struct efi_tcg2_protocol *this, + u32 input_param_block_size, + u8 *input_param_block, + u32 output_param_block_size, + u8 *output_param_block) { - return EFI_UNSUPPORTED; + struct udevice *dev; + efi_status_t ret; + u32 rc; + size_t resp_buf_size = output_param_block_size; + + EFI_ENTRY("%p, %u, %p, %u, %p", this, input_param_block_size, + input_param_block, output_param_block_size, output_param_block); + + if (!this || !input_param_block || !input_param_block_size) { + ret = EFI_INVALID_PARAMETER; + goto out; + } + + ret = platform_get_tpm2_device(&dev); + if (ret != EFI_SUCCESS) + goto out; + + rc = tpm2_submit_command(dev, input_param_block, + output_param_block, &resp_buf_size); + if (rc) { + ret = (rc == -ENOSPC) ? EFI_OUT_OF_RESOURCES : EFI_DEVICE_ERROR; + + goto out; + } + +out: + return EFI_EXIT(ret); } /** diff --git a/lib/tpm-v2.c b/lib/tpm-v2.c index 235f8c20d4..2e7b27bd6b 100644 --- a/lib/tpm-v2.c +++ b/lib/tpm-v2.c @@ -659,3 +659,9 @@ u32 tpm2_disable_platform_hierarchy(struct udevice *dev) return 0; } + +u32 tpm2_submit_command(struct udevice *dev, const u8 *sendbuf, + u8 *recvbuf, size_t *recv_size) +{ + return tpm_sendrecv_command(dev, sendbuf, recvbuf, recv_size); +} From 6b2f82901e5a2bdcc7b97dadd9defbc18e2a2962 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:03 -0600 Subject: [PATCH 07/17] efi: Add a script to build an image for testing on UEFI It is quite complicated to run U-Boot on QEMU since we have four different builds and they must use different versions of qemu and the UEFI binaries. Add a script to help. It requires U-Boot itself to be built. Once that is done you can use this script to build an image for use with qemu and optionally run it. Signed-off-by: Simon Glass --- MAINTAINERS | 1 + doc/develop/uefi/u-boot_on_efi.rst | 62 +++++++++ scripts/build-efi.sh | 193 +++++++++++++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100755 scripts/build-efi.sh diff --git a/MAINTAINERS b/MAINTAINERS index 9d8cba9028..fa7fe90070 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -710,6 +710,7 @@ M: Heinrich Schuchardt S: Maintained W: https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html F: lib/efi/efi_app.c +F: scripts/build-efi.sh EFI PAYLOAD M: Heinrich Schuchardt diff --git a/doc/develop/uefi/u-boot_on_efi.rst b/doc/develop/uefi/u-boot_on_efi.rst index 43afb11de5..8856af3db5 100644 --- a/doc/develop/uefi/u-boot_on_efi.rst +++ b/doc/develop/uefi/u-boot_on_efi.rst @@ -98,6 +98,11 @@ that EFI does not support booting a 64-bit application from a 32-bit EFI (or vice versa). Also it will often fail to print an error message if you get this wrong. +You may find the script `scripts/build-efi.sh` helpful for building and testing +U-Boot on UEFI on QEMU. It also includes links to UEFI binaries dating from +2021. + +See `Example run`_ for an example run. Inner workings -------------- @@ -193,6 +198,63 @@ of code is built this way (see the extra- line in lib/efi/Makefile). Everything else is built as a normal U-Boot, so is always 32-bit on x86 at present. +Example run +----------- + +This shows running with serial enabled (see `include/configs/efi-x86_app.h`):: + + $ scripts/build-efi.sh -wsPr + Packaging efi-x86_app32 + Running qemu-system-i386 + + BdsDxe: failed to load Boot0001 "UEFI QEMU HARDDISK QM00005 " from PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0): Not Found + BdsDxe: loading Boot0002 "EFI Internal Shell" from Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(7C04A583-9E3E-4F1C-AD65-E05268D0B4D1) + BdsDxe: starting Boot0002 "EFI Internal Shell" from Fv(7CB8BDC9-F8EB-4F34-AAEA-3EE4AF6516A1)/FvFile(7C04A583-9E3E-4F1C-AD65-E05268D0B4D1) + + UEFI Interactive Shell v2.2 + EDK II + UEFI v2.70 (EDK II, 0x00010000) + Mapping table + FS0: Alias(s):HD0a65535a1:;BLK1: + PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0)/HD(1,GPT,0FFD5E61-3B0C-4326-8049-BDCDC910AF72,0x800,0xB000) + BLK0: Alias(s): + PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) + + Press ESC in 5 seconds to skip startup.nsh or any other key to continue. + Shell> fs0:u-boot-app.efi + U-Boot EFI App (using allocated RAM address 47d4000) key=8d4, image=06a6f610 + starting + + + U-Boot 2022.01-rc4 (Sep 19 2021 - 14:03:20 -0600) + + CPU: x86, vendor Intel, device 663h + DRAM: 32 MiB + 0: efi_media_0 PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0) + 1: PciRoot(0x0)/Pci(0x3,0x0)/Sata(0x0,0xFFFF,0x0)/HD(1,GPT,0FFD5E61-3B0C-4326-8049-BDCDC910AF72,0x800,0xB000) + Loading Environment from nowhere... OK + Model: EFI x86 Application + Hit any key to stop autoboot: 0 + + Partition Map for EFI device 0 -- Partition Type: EFI + + Part Start LBA End LBA Name + Attributes + Type GUID + Partition GUID + 1 0x00000800 0x0000b7ff "boot" + attrs: 0x0000000000000000 + type: ebd0a0a2-b9e5-4433-87c0-68b6b72699c7 + guid: 0ffd5e61-3b0c-4326-8049-bdcdc910af72 + 19 startup.nsh + 528384 u-boot-app.efi + 10181 NvVars + + 3 file(s), 0 dir(s) + + => QEMU: Terminated + + Future work ----------- This work could be extended in a number of ways: diff --git a/scripts/build-efi.sh b/scripts/build-efi.sh new file mode 100755 index 0000000000..bc9aeebbf4 --- /dev/null +++ b/scripts/build-efi.sh @@ -0,0 +1,193 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0+ +# +# Script to build an EFI thing suitable for booting with QEMU, possibly running +# it also. + +# This just an example. It assumes that + +# - you build U-Boot in ${ubdir}/ where is the U-Boot board config +# - /mnt/x is a directory used for mounting +# - you have access to the 'pure UEFI' builds for QEMU +# +# UEFI binaries for QEMU used for testing this script: +# +# OVMF-pure-efi.i386.fd at +# https://drive.google.com/file/d/1jWzOAZfQqMmS2_dAK2G518GhIgj9r2RY/view?usp=sharing + +# OVMF-pure-efi.x64.fd at +# https://drive.google.com/file/d/1c39YI9QtpByGQ4V0UNNQtGqttEzS-eFV/view?usp=sharing + +set -e + +usage() { + echo "Usage: $0 [-a | -p] [other opts]" 1>&2 + echo 1>&2 + echo " -a - Package up the app" 1>&2 + echo " -o - Use old EFI app build (before 32/64 split)" 1>&2 + echo " -p - Package up the payload" 1>&2 + echo " -P - Create a partition table" 1>&2 + echo " -r - Run QEMU with the image" 1>&2 + echo " -s - Run QEMU with serial only (no display)" 1>&2 + echo " -w - Use word version (32-bit)" 1>&2 + exit 1 +} + +# 32- or 64-bit EFI +bitness=64 + +# app or payload ? +type=app + +# create a partition table and put the filesystem in that (otherwise put the +# filesystem in the raw device) +part= + +# run the image with QEMU +run= + +# run QEMU without a display (U-Boot must be set to stdout=serial) +serial= + +# before the 32/64 split of the app +old= + +# Set ubdir to the build directory where you build U-Boot out-of-tree +# We avoid in-tree build because it gets confusing trying different builds +ubdir=/tmp/b/ + +while getopts "aopPrsw" opt; do + case "${opt}" in + a) + type=app + ;; + p) + type=payload + ;; + r) + run=1 + ;; + s) + serial=1 + ;; + w) + bitness=32 + ;; + o) + old=1 + ;; + P) + part=1 + ;; + *) + usage + ;; + esac +done + +run_qemu() { + extra= + if [[ "${bitness}" = "64" ]]; then + qemu=qemu-system-x86_64 + bios=OVMF-pure-efi.x64.fd + else + qemu=qemu-system-i386 + bios=OVMF-pure-efi.i386.fd + fi + if [[ -n "${serial}" ]]; then + extra="-display none -serial mon:stdio" + fi + echo "Running ${qemu}" + # Use 512MB since U-Boot EFI likes to have 256MB to play with + "${qemu}" -bios "${bios}" \ + -m 512 \ + -drive id=disk,file="${IMG}",if=none,format=raw \ + -nic none -device ahci,id=ahci \ + -device ide-hd,drive=disk,bus=ahci.0 ${extra} +} + +setup_files() { + echo "Packaging ${BUILD}" + mkdir -p $TMP + cat >$TMP/startup.nsh </dev/null + sudo mount -o loop "${IMG}" $MNT + copy_files + sudo umount $MNT +} + +# Create a partition table and put the filesystem in the first partition +# then copy in the files +setup_part() { + # Create a gpt partition table with one partition + parted "${IMG}" mklabel gpt 2>/dev/null + + # This doesn't work correctly. It creates: + # Number Start End Size File system Name Flags + # 1 1049kB 24.1MB 23.1MB boot msftdata + # Odd if the same is entered interactively it does set the FS type + parted -s -a optimal -- "${IMG}" mkpart boot fat32 1MiB 23MiB + + # Map this partition to a loop device + kp="$(sudo kpartx -av ${IMG})" + read boot_dev<<<$(grep -o 'loop.*p.' <<< "${kp}") + test "${boot_dev}" + dev="/dev/mapper/${boot_dev}" + + mkfs.vfat "${dev}" >/dev/null + + sudo mount -o loop "${dev}" $MNT + + copy_files + + # Sync here since this makes kpartx more likely to work the first time + sync + sudo umount $MNT + + # For some reason this needs a sleep or it sometimes fails, if it was + # run recently (in the last few seconds) + if ! sudo kpartx -d "${IMG}" > /dev/null; then + sleep .5 + sudo kpartx -d "${IMG}" > /dev/null || \ + echo "Failed to remove ${boot_dev}, use: sudo kpartx -d ${IMG}" + fi +} + +TMP="/tmp/efi${bitness}${type}" +MNT=/mnt/x +BUILD="efi-x86_${type}${bitness}" +IMG=try.img + +if [[ -n "${old}" && "${bitness}" = "32" ]]; then + BUILD="efi-x86_${type}" +fi + +setup_files + +qemu-img create "${IMG}" 24M >/dev/null + +if [[ -n "${part}" ]]; then + setup_part +else + setup_raw +fi + +if [[ -n "${run}" ]]; then + run_qemu +fi From 815ef1ca1dcf52b12b8fe9f9db4086ea7a92e569 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:04 -0600 Subject: [PATCH 08/17] efi: Enable DM_ETH for the app There is no need to avoid driver model for networking. Drop this. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- configs/efi-x86_app_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/configs/efi-x86_app_defconfig b/configs/efi-x86_app_defconfig index b1efafe506..f0bc8778e3 100644 --- a/configs/efi-x86_app_defconfig +++ b/configs/efi-x86_app_defconfig @@ -32,7 +32,6 @@ CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_REGMAP=y CONFIG_SYSCON=y -# CONFIG_DM_ETH is not set # CONFIG_REGEX is not set # CONFIG_GZIP is not set CONFIG_EFI=y From 26e24d626b1477b63d62e81565b79d0c889b4485 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:05 -0600 Subject: [PATCH 09/17] efi: Drop the OF_EMBED warning for EFI For the EFI app, we must embed the devicetree in the ELF file since that is the only thing that is run by UEFI. Drop the warning to avoid confusion. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt Signed-off-by: Heinrich Schuchardt --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index c45da3ad88..bf78009e37 100644 --- a/Makefile +++ b/Makefile @@ -1094,7 +1094,7 @@ endif ifeq ($(CONFIG_DEPRECATED),y) $(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.") endif -ifeq ($(CONFIG_OF_EMBED),y) +ifeq ($(CONFIG_OF_EMBED)$(CONFIG_EFI_APP),y) @echo >&2 "===================== WARNING ======================" @echo >&2 "CONFIG_OF_EMBED is enabled. This option should only" @echo >&2 "be used for debugging purposes. Please use" From f4d227c99fbfdf2f518bef6f5ad5e1281998a362 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:06 -0600 Subject: [PATCH 10/17] x86: Create a 32/64-bit selection for the app Most EFI implementations use 64-bit but U-Boot only supports running as a 32-bit app at present. While efi-x86_payload64 does boot from 64-bit UEFI it immediately changes back to 32-bit before starting U-Boot. In order to support a 64-bit U-Boot app, update the Kconfig to add an option for 32/64 bit. Update the prompt for the existing option so it is clear it relates to the stub. Move both up to just under the choice that controls them, since this looks better and the menu. Use CONFIG_EFI_APP in the Makefile instead of CONFIG_TARGET_EFI_APP, since the latter is specific to a single target and we will have two. Memory size is set to 32MB for now so that it can run on qemu without increasing the default memory size. We may need to increase the default later. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- arch/x86/cpu/intel_common/Makefile | 2 +- lib/efi/Kconfig | 34 +++++++++++++++++++++++------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/arch/x86/cpu/intel_common/Makefile b/arch/x86/cpu/intel_common/Makefile index 8b9a810f66..1dc17b4587 100644 --- a/arch/x86/cpu/intel_common/Makefile +++ b/arch/x86/cpu/intel_common/Makefile @@ -27,7 +27,7 @@ obj-y += fast_spi.o obj-y += lpc.o obj-y += lpss.o obj-$(CONFIG_$(SPL_)INTEL_GENERIC_WIFI) += generic_wifi.o -ifndef CONFIG_TARGET_EFI_APP +ifndef CONFIG_EFI_APP obj-$(CONFIG_$(SPL_TPL_)X86_32BIT_INIT) += microcode.o ifndef CONFIG_$(SPL_)X86_64 obj-y += microcode.o diff --git a/lib/efi/Kconfig b/lib/efi/Kconfig index 93b8564492..15ce99e1a7 100644 --- a/lib/efi/Kconfig +++ b/lib/efi/Kconfig @@ -26,18 +26,26 @@ config EFI_STUB endchoice -config EFI_RAM_SIZE - hex "Amount of EFI RAM for U-Boot" +choice + prompt "EFI app 32/64-bit selection" depends on EFI_APP - default 0x2000000 help - Set the amount of EFI RAM which is claimed by U-Boot for its own - use. U-Boot allocates this from EFI on start-up (along with a few - other smaller amounts) and it can never be increased after that. - It is used as the RAM size in with U-Boot. + EFI does not support mixing 32-bit and 64-bit modes. This is a + significant problem because it means that you must build a stub with + the correct type for EFI to load it correctly. If you are using + 32-bit EFI, select 32-bit here, else select 64-bit. Failure to do + this may produce no error message - it just won't start! + +config EFI_APP_32BIT + bool "Produce an app for running with 32-bit EFI" + +config EFI_APP_64BIT + bool "Produce an app for running with 64-bit EFI" + +endchoice choice - prompt "EFI 32/64-bit selection" + prompt "EFI stub 32/64-bit selection" depends on EFI_STUB help EFI does not support mixing 32-bit and 64-bit modes. This is a @@ -53,3 +61,13 @@ config EFI_STUB_64BIT bool "Produce a stub for running with 64-bit EFI" endchoice + +config EFI_RAM_SIZE + hex "Amount of EFI RAM for U-Boot" + depends on EFI_APP + default 0x10000000 + help + Set the amount of EFI RAM which is claimed by U-Boot for its own + use. U-Boot allocates this from EFI on start-up (along with a few + other smaller amounts) and it can never be increased after that. + It is used as the RAM size in with U-Boot. From e16c47fa3d2e051a0035191d473549589bd34fc4 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:07 -0600 Subject: [PATCH 11/17] efi: Create a 64-bit app Most modern platforms use 64-bit EFI so it is useful to have a U-Boot app that runs under that. Add a (non-functional) build for this. Note that --whole-archive causes the gcc 9.2 linker to crash, so disable this for now. Once this is resolved, things should work. For now, avoid mentioning the documentation for the 64-bit app, since it does not work. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- MAINTAINERS | 3 ++ Makefile | 8 +++- arch/x86/cpu/u-boot-64.lds | 2 + arch/x86/cpu/x86_64/Makefile | 4 ++ arch/x86/cpu/x86_64/cpu.c | 17 --------- arch/x86/cpu/x86_64/misc.c | 25 ++++++++++++ board/efi/Kconfig | 15 +++++++- board/efi/efi-x86_app/Kconfig | 2 +- board/efi/efi-x86_app/MAINTAINERS | 11 +++++- ..._app_defconfig => efi-x86_app32_defconfig} | 2 +- configs/efi-x86_app64_defconfig | 38 +++++++++++++++++++ doc/develop/uefi/u-boot_on_efi.rst | 6 +-- lib/efi_loader/Kconfig | 1 + 13 files changed, 106 insertions(+), 28 deletions(-) create mode 100644 arch/x86/cpu/x86_64/misc.c rename configs/{efi-x86_app_defconfig => efi-x86_app32_defconfig} (97%) create mode 100644 configs/efi-x86_app64_defconfig diff --git a/MAINTAINERS b/MAINTAINERS index fa7fe90070..00ff572d4d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -709,6 +709,9 @@ M: Simon Glass M: Heinrich Schuchardt S: Maintained W: https://u-boot.readthedocs.io/en/latest/develop/uefi/u-boot_on_efi.html +F: board/efi/efi-x86_app +F: configs/efi-x86_app* +F: doc/develop/uefi/u-boot_on_efi.rst F: lib/efi/efi_app.c F: scripts/build-efi.sh diff --git a/Makefile b/Makefile index bf78009e37..ea884fec26 100644 --- a/Makefile +++ b/Makefile @@ -1756,12 +1756,16 @@ quiet_cmd_u-boot__ ?= LTO $@ -Wl,-Map,u-boot.map; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) else +# Note: Linking efi-x86_app64 causes a segfault in the linker at present +# when using x86_64-linux-gnu-ld.bfd +# For now, disable --whole-archive which makes things link, although not +# correctly quiet_cmd_u-boot__ ?= LD $@ cmd_u-boot__ ?= $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ -T u-boot.lds $(u-boot-init) \ - --whole-archive \ + $(if $(CONFIG_EFI_APP_64BIT),,--whole-archive) \ $(u-boot-main) \ - --no-whole-archive \ + $(if $(CONFIG_EFI_APP_64BIT),,--no-whole-archive) \ $(PLATFORM_LIBS) -Map u-boot.map; \ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) endif diff --git a/arch/x86/cpu/u-boot-64.lds b/arch/x86/cpu/u-boot-64.lds index ee0812aefb..92a30c2a38 100644 --- a/arch/x86/cpu/u-boot-64.lds +++ b/arch/x86/cpu/u-boot-64.lds @@ -15,7 +15,9 @@ SECTIONS /DISCARD/ : { *(.u_boot_list_2_cmd_*) } #endif +#ifdef CONFIG_SYS_TEXT_BASE . = CONFIG_SYS_TEXT_BASE; /* Location of bootcode in flash */ +#endif __text_start = .; .text.start : { *(.text.start); } diff --git a/arch/x86/cpu/x86_64/Makefile b/arch/x86/cpu/x86_64/Makefile index 400f0ffe39..e929563b2c 100644 --- a/arch/x86/cpu/x86_64/Makefile +++ b/arch/x86/cpu/x86_64/Makefile @@ -4,3 +4,7 @@ # obj-y += cpu.o interrupts.o setjmp.o + +ifndef CONFIG_EFI +obj-y += misc.o +endif diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c index 90a766c3c5..8f72c9951a 100644 --- a/arch/x86/cpu/x86_64/cpu.c +++ b/arch/x86/cpu/x86_64/cpu.c @@ -49,23 +49,6 @@ int x86_mp_init(void) return 0; } -int misc_init_r(void) -{ - return 0; -} - -#ifndef CONFIG_SYS_COREBOOT -int checkcpu(void) -{ - return 0; -} - -int print_cpuinfo(void) -{ - return 0; -} -#endif - int x86_cpu_reinit_f(void) { return 0; diff --git a/arch/x86/cpu/x86_64/misc.c b/arch/x86/cpu/x86_64/misc.c new file mode 100644 index 0000000000..02587ff0c5 --- /dev/null +++ b/arch/x86/cpu/x86_64/misc.c @@ -0,0 +1,25 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2016 Google, Inc + * Written by Simon Glass + */ + +#include +#include + +int misc_init_r(void) +{ + return 0; +} + +#ifndef CONFIG_SYS_COREBOOT +int checkcpu(void) +{ + return 0; +} + +int print_cpuinfo(void) +{ + return 0; +} +#endif diff --git a/board/efi/Kconfig b/board/efi/Kconfig index 291bd2ca15..3df6e31c8b 100644 --- a/board/efi/Kconfig +++ b/board/efi/Kconfig @@ -4,14 +4,25 @@ choice prompt "Mainboard model" optional -config TARGET_EFI_APP - bool "efi application" +config TARGET_EFI_APP32 + bool "32-bit efi application" + select EFI_APP help This target is used for running U-Boot on top of EFI. In this case EFI does the early initialisation, and U-Boot takes over once the RAM, video and CPU are fully running. U-Boot is loaded as an application from EFI. +config TARGET_EFI_APP64 + bool "64-bit efi application" + select EFI_APP + select X86_64 + help + This target is used for running U-Boot on top of EFI in 64-bit mode. + In this case EFI does the early initialisation, and U-Boot + takes over once the RAM, video and CPU are fully running. + U-Boot is loaded as an application from EFI. + config TARGET_EFI_PAYLOAD bool "efi payload" help diff --git a/board/efi/efi-x86_app/Kconfig b/board/efi/efi-x86_app/Kconfig index ae87bf34d3..e412702eed 100644 --- a/board/efi/efi-x86_app/Kconfig +++ b/board/efi/efi-x86_app/Kconfig @@ -1,4 +1,4 @@ -if TARGET_EFI_APP +if EFI_APP config SYS_BOARD default "efi-x86_app" diff --git a/board/efi/efi-x86_app/MAINTAINERS b/board/efi/efi-x86_app/MAINTAINERS index fb8a6b1c2f..b292811a8f 100644 --- a/board/efi/efi-x86_app/MAINTAINERS +++ b/board/efi/efi-x86_app/MAINTAINERS @@ -1,6 +1,13 @@ -EFI-X86_APP BOARD +EFI-X86_APP32 BOARD M: Simon Glass S: Maintained F: board/efi/efi-x86_app/ F: include/configs/efi-x86_app.h -F: configs/efi-x86_app_defconfig +F: configs/efi-x86_app32_defconfig + +EFI-X86_APP64 BOARD +M: Simon Glass +S: Maintained +F: board/efi/efi-x86_app/ +F: include/configs/efi-x86_app.h +F: configs/efi-x86_app64_defconfig diff --git a/configs/efi-x86_app_defconfig b/configs/efi-x86_app32_defconfig similarity index 97% rename from configs/efi-x86_app_defconfig rename to configs/efi-x86_app32_defconfig index f0bc8778e3..480ef648ea 100644 --- a/configs/efi-x86_app_defconfig +++ b/configs/efi-x86_app32_defconfig @@ -5,7 +5,7 @@ CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" CONFIG_DEBUG_UART_BASE=0 CONFIG_DEBUG_UART_CLOCK=0 CONFIG_VENDOR_EFI=y -CONFIG_TARGET_EFI_APP=y +CONFIG_TARGET_EFI_APP32=y CONFIG_DEBUG_UART=y CONFIG_FIT=y CONFIG_SHOW_BOOT_PROGRESS=y diff --git a/configs/efi-x86_app64_defconfig b/configs/efi-x86_app64_defconfig new file mode 100644 index 0000000000..bffbf6958a --- /dev/null +++ b/configs/efi-x86_app64_defconfig @@ -0,0 +1,38 @@ +CONFIG_X86=y +CONFIG_NR_DRAM_BANKS=8 +CONFIG_ENV_SIZE=0x1000 +CONFIG_DEFAULT_DEVICE_TREE="efi-x86_app" +CONFIG_DEBUG_UART_BASE=0 +CONFIG_DEBUG_UART_CLOCK=0 +CONFIG_VENDOR_EFI=y +CONFIG_TARGET_EFI_APP64=y +CONFIG_DEBUG_UART=y +CONFIG_FIT=y +CONFIG_SHOW_BOOT_PROGRESS=y +CONFIG_USE_BOOTARGS=y +CONFIG_BOOTARGS="root=/dev/sdb3 init=/sbin/init rootwait ro" +CONFIG_SYS_CONSOLE_INFO_QUIET=y +CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_LAST_STAGE_INIT=y +CONFIG_HUSH_PARSER=y +# CONFIG_CMD_BOOTM is not set +CONFIG_CMD_PART=y +# CONFIG_CMD_NET is not set +CONFIG_CMD_TIME=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_EXT4=y +CONFIG_CMD_EXT4_WRITE=y +CONFIG_CMD_FAT=y +CONFIG_CMD_FS_GENERIC=y +CONFIG_MAC_PARTITION=y +CONFIG_ISO_PARTITION=y +CONFIG_EFI_PARTITION=y +CONFIG_OF_EMBED=y +CONFIG_ENV_OVERWRITE=y +CONFIG_SYS_RELOC_GD_ENV_ADDR=y +CONFIG_REGMAP=y +CONFIG_SYSCON=y +# CONFIG_REGEX is not set +# CONFIG_GZIP is not set +CONFIG_EFI=y +CONFIG_EFI_APP_64BIT=y diff --git a/doc/develop/uefi/u-boot_on_efi.rst b/doc/develop/uefi/u-boot_on_efi.rst index 8856af3db5..f275a524ce 100644 --- a/doc/develop/uefi/u-boot_on_efi.rst +++ b/doc/develop/uefi/u-boot_on_efi.rst @@ -48,10 +48,10 @@ for that board. It will be either 32-bit or 64-bit. Alternatively, you can opt for using QEMU [1] and the OVMF [2], as detailed below. To build U-Boot as an EFI application (32-bit EFI required), enable CONFIG_EFI -and CONFIG_EFI_APP. The efi-x86_app config (efi-x86_app_defconfig) is set up +and CONFIG_EFI_APP. The efi-x86_app config (efi-x86_app32_defconfig) is set up for this. Just build U-Boot as normal, e.g.:: - make efi-x86_app_defconfig + make efi-x86_app32_defconfig make To build U-Boot as an EFI payload (32-bit or 64-bit EFI can be used), enable @@ -261,7 +261,7 @@ This work could be extended in a number of ways: - Add ARM support -- Add 64-bit application support +- Add 64-bit application support (in progress) - Figure out how to solve the interrupt problem diff --git a/lib/efi_loader/Kconfig b/lib/efi_loader/Kconfig index 52f71c07c9..700dc838dd 100644 --- a/lib/efi_loader/Kconfig +++ b/lib/efi_loader/Kconfig @@ -12,6 +12,7 @@ config EFI_LOADER depends on !EFI_STUB || !X86 || X86_64 || EFI_STUB_32BIT depends on BLK depends on DM_ETH || !NET + depends on !EFI_APP default y if !ARM || SYS_CPU = armv7 || SYS_CPU = armv8 select LIB_UUID select PARTITION_UUIDS From 9c297a3dab2dc830a6abe54039d57612a0ac6918 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:08 -0600 Subject: [PATCH 12/17] x86: Don't duplicate global_ptr in 64-bit EFI app This variable is already defined by the EFI code. Drop the duplicate definition when building a 64-bit EFI app. Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- arch/x86/cpu/x86_64/cpu.c | 15 +-------------- arch/x86/cpu/x86_64/misc.c | 16 ++++++++++++++++ lib/efi/efi.c | 9 +++++++++ 3 files changed, 26 insertions(+), 14 deletions(-) diff --git a/arch/x86/cpu/x86_64/cpu.c b/arch/x86/cpu/x86_64/cpu.c index 8f72c9951a..a3674e8e29 100644 --- a/arch/x86/cpu/x86_64/cpu.c +++ b/arch/x86/cpu/x86_64/cpu.c @@ -8,20 +8,7 @@ #include #include #include - -/* - * Global declaration of gd. - * - * As we write to it before relocation we have to make sure it is not put into - * a .bss section which may overlap a .rela section. Initialization forces it - * into a .data section which cannot overlap any .rela section. - */ -struct global_data *global_data_ptr = (struct global_data *)~0; - -void arch_setup_gd(gd_t *new_gd) -{ - global_data_ptr = new_gd; -} +#include int cpu_has_64bit(void) { diff --git a/arch/x86/cpu/x86_64/misc.c b/arch/x86/cpu/x86_64/misc.c index 02587ff0c5..691b67ff68 100644 --- a/arch/x86/cpu/x86_64/misc.c +++ b/arch/x86/cpu/x86_64/misc.c @@ -7,6 +7,22 @@ #include #include +DECLARE_GLOBAL_DATA_PTR; + +/* + * Global declaration of gd. + * + * As we write to it before relocation we have to make sure it is not put into + * a .bss section which may overlap a .rela section. Initialization forces it + * into a .data section which cannot overlap any .rela section. + */ +struct global_data *global_data_ptr = (struct global_data *)~0; + +void arch_setup_gd(gd_t *new_gd) +{ + global_data_ptr = new_gd; +} + int misc_init_r(void) { return 0; diff --git a/lib/efi/efi.c b/lib/efi/efi.c index 0c16a5fdd3..69e52e4574 100644 --- a/lib/efi/efi.c +++ b/lib/efi/efi.c @@ -17,6 +17,15 @@ #include #include +/* + * Global declaration of gd. + * + * As we write to it before relocation we have to make sure it is not put into + * a .bss section which may overlap a .rela section. Initialization forces it + * into a .data section which cannot overlap any .rela section. + */ +struct global_data *global_data_ptr = (struct global_data *)~0; + /* * Unfortunately we cannot access any code outside what is built especially * for the stub. lib/string.c is already being built for the U-Boot payload From f84457376264913537392a90d7022631af1639b7 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:09 -0600 Subject: [PATCH 13/17] efi: Add a way to obtain boot services in the app Add a function to return this information along with a stub for the efi_info_get() function, since calling it otherwise hangs U-Boot. Signed-off-by: Simon Glass Signed-off-by: Heinrich Schuchardt --- include/efi.h | 8 +++++++- lib/efi/efi_app.c | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/efi.h b/include/efi.h index 18c13e0370..b5835422b9 100644 --- a/include/efi.h +++ b/include/efi.h @@ -444,9 +444,15 @@ extern char _binary_u_boot_bin_start[], _binary_u_boot_bin_end[]; * * @return pointer to EFI system table */ - struct efi_system_table *efi_get_sys_table(void); +/** + * efi_get_boot() - Get access to the EFI boot services table + * + * @return pointer to EFI boot services table + */ +struct efi_boot_services *efi_get_boot(void); + /** * efi_get_ram_base() - Find the base of RAM * diff --git a/lib/efi/efi_app.c b/lib/efi/efi_app.c index 907bacd716..f61665686c 100644 --- a/lib/efi/efi_app.c +++ b/lib/efi/efi_app.c @@ -31,11 +31,21 @@ struct efi_system_table *efi_get_sys_table(void) return global_priv->sys_table; } +struct efi_boot_services *efi_get_boot(void) +{ + return global_priv->boot; +} + unsigned long efi_get_ram_base(void) { return global_priv->ram_base; } +int efi_info_get(enum efi_entry_t type, void **datap, int *sizep) +{ + return -ENOSYS; +} + static efi_status_t setup_memory(struct efi_priv *priv) { struct efi_boot_services *boot = priv->boot; From 1834c081d3db78df045f7e243e8bb169c4a12e2e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Wed, 3 Nov 2021 21:09:10 -0600 Subject: [PATCH 14/17] efi: Add video support to the app The current EFI video driver only works when running in the stub. In that case the stub calls boot services (before jumping to U-Boot proper) and copies the graphics info over to the efi table. This is necessary because the stub exits boot services before jumping to U-Boot. The app maintains access to boot services throughout its life, so does not need to do this. Update the driver to support calling boot services directly. Enable video output for the app. Note that this uses the EFI_GRAPHICS_OUTPUT_PROTOCOL protocol, even though it mentions vesa. A sample qemu command-line for this case is: qemu-system-x86_64 -bios /usr/share/edk2.git/ovmf-ia32/OVMF-pure-efi.fd -drive id=disk,file=try.img,if=none,format=raw -nic none -device ahci,id=ahci -device ide-hd,drive=disk,bus=ahci.0 Signed-off-by: Simon Glass Reviewed-by: Heinrich Schuchardt --- arch/x86/dts/efi-x86_app.dts | 4 +++ board/efi/efi-x86_app/Kconfig | 4 +++ doc/develop/uefi/u-boot_on_efi.rst | 2 +- drivers/video/Kconfig | 2 +- drivers/video/efi.c | 45 ++++++++++++++++++++++++------ include/configs/efi-x86_app.h | 6 ++-- 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/arch/x86/dts/efi-x86_app.dts b/arch/x86/dts/efi-x86_app.dts index 04e044a07a..a5316e2a1a 100644 --- a/arch/x86/dts/efi-x86_app.dts +++ b/arch/x86/dts/efi-x86_app.dts @@ -25,4 +25,8 @@ compatible = "efi,reset"; u-boot,dm-pre-reloc; }; + efi-fb { + compatible = "efi-fb"; + }; + }; diff --git a/board/efi/efi-x86_app/Kconfig b/board/efi/efi-x86_app/Kconfig index e412702eed..ecd08d7314 100644 --- a/board/efi/efi-x86_app/Kconfig +++ b/board/efi/efi-x86_app/Kconfig @@ -12,4 +12,8 @@ config SYS_SOC config SYS_CONFIG_NAME default "efi-x86_app" +config BOARD_SPECIFIC_OPTIONS # dummy + def_bool y + imply VIDEO_EFI + endif diff --git a/doc/develop/uefi/u-boot_on_efi.rst b/doc/develop/uefi/u-boot_on_efi.rst index f275a524ce..5f2f850f07 100644 --- a/doc/develop/uefi/u-boot_on_efi.rst +++ b/doc/develop/uefi/u-boot_on_efi.rst @@ -265,7 +265,7 @@ This work could be extended in a number of ways: - Figure out how to solve the interrupt problem -- Add more drivers to the application side (e.g. video, block devices, USB, +- Add more drivers to the application side (e.g. block devices, USB, environment access). This would mostly be an academic exercise as a strong use case is not readily apparent, but it might be fun. diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 2f4650f830..a58f87f479 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig @@ -250,7 +250,7 @@ config VIDEO_COREBOOT config VIDEO_EFI bool "Enable EFI framebuffer driver support" - depends on EFI_STUB + depends on EFI_STUB || EFI_APP help Turn on this option to enable a framebuffeer driver when U-Boot is loaded as a payload (see README.u-boot_on_efi) by an EFI BIOS where diff --git a/drivers/video/efi.c b/drivers/video/efi.c index c248bd352a..5f9031f2ec 100644 --- a/drivers/video/efi.c +++ b/drivers/video/efi.c @@ -50,6 +50,28 @@ static void efi_find_pixel_bits(u32 mask, u8 *pos, u8 *size) *size = len; } +static int get_mode_info(struct vesa_mode_info *vesa) +{ + efi_guid_t efi_gop_guid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID; + struct efi_boot_services *boot = efi_get_boot(); + struct efi_gop_mode *mode; + struct efi_gop *gop; + int ret; + + if (!boot) + return log_msg_ret("sys", -ENOSYS); + ret = boot->locate_protocol(&efi_gop_guid, NULL, (void **)&gop); + if (ret) + return log_msg_ret("prot", -ENOTSUPP); + + mode = gop->mode; + vesa->phys_base_ptr = mode->fb_base; + vesa->x_resolution = mode->info->width; + vesa->y_resolution = mode->info->height; + + return 0; +} + static int save_vesa_mode(struct vesa_mode_info *vesa) { struct efi_entry_gopmode *mode; @@ -57,16 +79,23 @@ static int save_vesa_mode(struct vesa_mode_info *vesa) int size; int ret; - ret = efi_info_get(EFIET_GOP_MODE, (void **)&mode, &size); - if (ret == -ENOENT) { - debug("efi graphics output protocol mode not found\n"); - return -ENXIO; + if (IS_ENABLED(CONFIG_EFI_APP)) { + ret = get_mode_info(vesa); + if (ret) { + printf("EFI graphics output protocol not found\n"); + return -ENXIO; + } + } else { + ret = efi_info_get(EFIET_GOP_MODE, (void **)&mode, &size); + if (ret == -ENOENT) { + printf("EFI graphics output protocol mode not found\n"); + return -ENXIO; + } + vesa->phys_base_ptr = mode->fb_base; + vesa->x_resolution = mode->info->width; + vesa->y_resolution = mode->info->height; } - vesa->phys_base_ptr = mode->fb_base; - vesa->x_resolution = mode->info->width; - vesa->y_resolution = mode->info->height; - if (mode->info->pixel_format < EFI_GOT_BITMASK) { fbinfo = &efi_framebuffer_format_map[mode->info->pixel_format]; vesa->red_mask_size = fbinfo->red.size; diff --git a/include/configs/efi-x86_app.h b/include/configs/efi-x86_app.h index 33418cfbec..6061a6db0a 100644 --- a/include/configs/efi-x86_app.h +++ b/include/configs/efi-x86_app.h @@ -10,8 +10,8 @@ #undef CONFIG_TPM_TIS_BASE_ADDRESS -#define CONFIG_STD_DEVICES_SETTINGS "stdin=usbkbd,vga,serial\0" \ - "stdout=vga,serial\0" \ - "stderr=vga,serial\0" +#define CONFIG_STD_DEVICES_SETTINGS "stdin=serial\0" \ + "stdout=vidconsole\0" \ + "stderr=vidconsole\0" #endif From aa1b5049278d067ff5aa3fc38b14c66e10264ac3 Mon Sep 17 00:00:00 2001 From: Masahisa Kojima Date: Thu, 4 Nov 2021 19:45:46 +0900 Subject: [PATCH 15/17] efi_selftest: add selftest for EFI_TCG2_PROTOCOL and Measured Boot 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 pre-built versions of lib/efi_selftest/efi_miniapp_file_image_exit.c for PE/COFF image measurement test for 32-bit arm, arm64, ia32, x86_64, riscv32 and riscv64. Prebuilding avoids the problem of reproducible builds. Signed-off-by: Masahisa Kojima Make the test 'onrequest'. Add code comments to the includes with the binaries. Reviewed-by: Heinrich Schuchardt --- lib/efi_selftest/efi_miniapp_tcg2_arm.h | 153 ++++ lib/efi_selftest/efi_miniapp_tcg2_arm64.h | 208 +++++ lib/efi_selftest/efi_miniapp_tcg2_ia32.h | 178 ++++ lib/efi_selftest/efi_miniapp_tcg2_riscv32.h | 174 ++++ lib/efi_selftest/efi_miniapp_tcg2_riscv64.h | 190 ++++ lib/efi_selftest/efi_miniapp_tcg2_x86_64.h | 179 ++++ lib/efi_selftest/efi_selftest_tcg2.c | 942 +++++++++++++++++++- 7 files changed, 2023 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..bddd78289a --- /dev/null +++ b/lib/efi_selftest/efi_miniapp_tcg2_arm.h @@ -0,0 +1,153 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * This file contains a precompiled EFI binary built from + * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include + * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL. + * The precompiled form is needed to avoid the problem of reproducible builds. + */ + +#define EFI_ST_DISK_IMG { 0x00000570, { \ + {0x00000000, "\x4d\x5a\x00\x00\x00\x00\x00\x00"}, /* MZ...... */ \ + {0x00000038, "\x00\x00\x00\x00\x40\x00\x00\x00"}, /* ....@... */ \ + {0x00000040, "\x50\x45\x00\x00\xc2\x01\x02\x00"}, /* PE...... */ \ + {0x00000050, "\x00\x00\x00\x00\x90\x00\x0e\x03"}, /* ........ */ \ + {0x00000058, "\x0b\x01\x02\x14\x38\x04\x00\x00"}, /* ....8... */ \ + {0x00000068, "\x38\x01\x00\x00\x38\x01\x00\x00"}, /* 8...8... */ \ + {0x00000078, "\x20\x00\x00\x00\x08\x00\x00\x00"}, /* ....... */ \ + {0x00000090, "\x70\x05\x00\x00\x38\x01\x00\x00"}, /* p...8... */ \ + {0x00000098, "\x00\x00\x00\x00\x0a\x00\x00\x00"}, /* ........ */ \ + {0x000000b0, "\x00\x00\x00\x00\x06\x00\x00\x00"}, /* ........ */ \ + {0x000000e8, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \ + {0x00000108, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \ + {0x00000110, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \ + {0x00000118, "\x38\x04\x00\x00\x38\x01\x00\x00"}, /* 8...8... */ \ + {0x00000120, "\x38\x04\x00\x00\x38\x01\x00\x00"}, /* 8...8... */ \ + {0x00000130, "\x00\x00\x00\x00\x20\x00\x50\xe0"}, /* .... .P. */ \ + {0x00000138, "\x07\x40\x2d\xe9\x24\x10\x8f\xe2"}, /* .@-.$... */ \ + {0x00000140, "\x00\x00\x91\xe5\x01\x10\x80\xe0"}, /* ........ */ \ + {0x00000148, "\x15\x0e\x4f\xe2\x5a\x00\x00\xeb"}, /* ..O.Z... */ \ + {0x00000150, "\x00\x00\x30\xe3\x01\x00\x00\x1a"}, /* ..0..... */ \ + {0x00000158, "\x03\x00\x9d\xe8\x2e\x00\x00\xeb"}, /* ........ */ \ + {0x00000160, "\x0c\xd0\x8d\xe2\x04\xf0\x9d\xe4"}, /* ........ */ \ + {0x00000168, "\xa8\x03\x00\x00\x02\x30\xa0\xe3"}, /* .....0.. */ \ + {0x00000170, "\x30\x40\x2d\xe9\x14\xd0\x4d\xe2"}, /* 0@-...M. */ \ + {0x00000178, "\x3c\x20\x91\xe5\x2c\x50\x91\xe5"}, /* < ..,P.. */ \ + {0x00000180, "\x04\x30\x8d\xe5\x00\x30\xa0\xe3"}, /* .0...0.. */ \ + {0x00000188, "\x7c\x10\x9f\xe5\x00\x30\x8d\xe5"}, /* |....0.. */ \ + {0x00000190, "\x98\x40\x92\xe5\x01\x10\x8f\xe0"}, /* .@...... */ \ + {0x00000198, "\x0c\x20\x8d\xe2\x34\xff\x2f\xe1"}, /* . ..4./. */ \ + {0x000001a0, "\x00\x40\x50\xe2\x07\x00\x00\x0a"}, /* .@P..... */ \ + {0x000001a8, "\x60\x10\x9f\xe5\x05\x00\xa0\xe1"}, /* `....... */ \ + {0x000001b0, "\x04\x30\x95\xe5\x01\x10\x8f\xe0"}, /* .0...... */ \ + {0x000001b8, "\x33\xff\x2f\xe1\x04\x00\xa0\xe1"}, /* 3./..... */ \ + {0x000001c0, "\x14\xd0\x8d\xe2\x30\x80\xbd\xe8"}, /* ....0... */ \ + {0x000001c8, "\x0c\x10\x9d\xe5\x40\x20\x9f\xe5"}, /* ....@ .. */ \ + {0x000001d0, "\x20\x30\x91\xe5\x02\x20\x8f\xe0"}, /* 0... .. */ \ + {0x000001d8, "\x02\x00\x53\xe1\x03\x00\x00\x8a"}, /* ..S..... */ \ + {0x000001e0, "\x28\x10\x91\xe5\x01\x30\x83\xe0"}, /* (....0.. */ \ + {0x000001e8, "\x02\x00\x53\xe1\xf2\xff\xff\x8a"}, /* ..S..... */ \ + {0x000001f0, "\x20\x10\x9f\xe5\x05\x00\xa0\xe1"}, /* ....... */ \ + {0x000001f8, "\x04\x30\x95\xe5\x01\x10\x8f\xe0"}, /* .0...... */ \ + {0x00000200, "\x33\xff\x2f\xe1\x3a\x41\xa0\xe3"}, /* 3./.:A.. */ \ + {0x00000208, "\xeb\xff\xff\xea\xac\x03\x00\x00"}, /* ........ */ \ + {0x00000210, "\x34\x02\x00\x00\x90\xff\xff\xff"}, /* 4....... */ \ + {0x00000218, "\x36\x02\x00\x00\xf0\x40\x2d\xe9"}, /* 6....@-. */ \ + {0x00000220, "\x14\xd0\x4d\xe2\x0d\x70\xa0\xe1"}, /* ..M..p.. */ \ + {0x00000228, "\x00\x50\xa0\xe1\x01\x40\xa0\xe1"}, /* .P...@.. */ \ + {0x00000230, "\x2c\x60\x91\xe5\x74\x10\x9f\xe5"}, /* ,`..t... */ \ + {0x00000238, "\x10\x20\xa0\xe3\x01\x10\x8f\xe0"}, /* . ...... */ \ + {0x00000240, "\x07\x00\xa0\xe1\x60\x00\x00\xeb"}, /* ....`... */ \ + {0x00000248, "\x64\x10\x9f\xe5\x04\x30\x96\xe5"}, /* d....0.. */ \ + {0x00000250, "\x01\x10\x8f\xe0\x06\x00\xa0\xe1"}, /* ........ */ \ + {0x00000258, "\x33\xff\x2f\xe1\x04\x10\xa0\xe1"}, /* 3./..... */ \ + {0x00000260, "\x05\x00\xa0\xe1\xc0\xff\xff\xeb"}, /* ........ */ \ + {0x00000268, "\x00\x00\x50\xe3\x0e\x11\xa0\x03"}, /* ..P..... */ \ + {0x00000270, "\x05\x00\x00\x0a\x3c\x10\x9f\xe5"}, /* ....<... */ \ + {0x00000278, "\x06\x00\xa0\xe1\x01\x10\x8f\xe0"}, /* ........ */ \ + {0x00000280, "\x04\x30\x96\xe5\x33\xff\x2f\xe1"}, /* .0..3./. */ \ + {0x00000288, "\x3a\x11\xa0\xe3\x3c\x30\x94\xe5"}, /* :...<0.. */ \ + {0x00000290, "\x10\x20\xa0\xe3\x78\x40\x93\xe5"}, /* . ..x@.. */ \ + {0x00000298, "\x05\x00\xa0\xe1\x07\x30\xa0\xe1"}, /* .....0.. */ \ + {0x000002a0, "\x34\xff\x2f\xe1\x00\x00\xa0\xe3"}, /* 4./..... */ \ + {0x000002a8, "\x14\xd0\x8d\xe2\xf0\x80\xbd\xe8"}, /* ........ */ \ + {0x000002b0, "\xb8\x02\x00\x00\x2a\x02\x00\x00"}, /* ........ */ \ + {0x000002b8, "\x3a\x02\x00\x00\x00\x30\xa0\xe3"}, /* :....0.. */ \ + {0x000002c0, "\x03\x20\xa0\xe1\x03\xc0\xa0\xe1"}, /* . ...... */ \ + {0x000002c8, "\x04\xe0\x2d\xe5\x00\xe0\x91\xe5"}, /* ..-..... */ \ + {0x000002d0, "\x00\x00\x5e\xe3\x03\x00\x00\x1a"}, /* ..^..... */ \ + {0x000002d8, "\x02\x10\x93\xe1\x0c\x00\x00\x1a"}, /* ........ */ \ + {0x000002e0, "\x00\x00\xa0\xe3\x04\xf0\x9d\xe4"}, /* ........ */ \ + {0x000002e8, "\x12\x00\x5e\xe3\x04\xc0\x91\x05"}, /* ..^..... */ \ + {0x000002f0, "\x05\x00\x00\x0a\x13\x00\x5e\xe3"}, /* ......^. */ \ + {0x000002f8, "\x04\x20\x91\x05\x02\x00\x00\x0a"}, /* . ...... */ \ + {0x00000300, "\x11\x00\x5e\xe3\x04\x30\x91\x05"}, /* ..^..0.. */ \ + {0x00000308, "\x03\x30\x80\x00\x08\x10\x81\xe2"}, /* .0...... */ \ + {0x00000310, "\xed\xff\xff\xea\x00\x00\x52\xe3"}, /* ......R. */ \ + {0x00000318, "\x00\x00\x53\x13\x09\x00\x00\x1a"}, /* ..S..... */ \ + {0x00000320, "\x06\x01\xa0\xe3\x04\xf0\x9d\xe4"}, /* ........ */ \ + {0x00000328, "\x04\x10\xd3\xe5\x02\xc0\x4c\xe0"}, /* ......L. */ \ + {0x00000330, "\x17\x00\x51\xe3\x00\xe0\x93\x05"}, /* ..Q..... */ \ + {0x00000338, "\x02\x30\x83\xe0\x0e\x10\x90\x07"}, /* .0...... */ \ + {0x00000340, "\x00\x10\x81\x00\x0e\x10\x80\x07"}, /* ........ */ \ + {0x00000348, "\x00\x00\x5c\xe3\xf5\xff\xff\xca"}, /* ..\..... */ \ + {0x00000350, "\xe2\xff\xff\xea\x01\x10\x41\xe2"}, /* ......A. */ \ + {0x00000358, "\x02\x20\x80\xe0\x02\x00\x50\xe1"}, /* . ....P. */ \ + {0x00000360, "\x01\x00\x00\x1a\x00\x00\xa0\xe3"}, /* ........ */ \ + {0x00000368, "\x1e\xff\x2f\xe1\x00\x30\xd0\xe5"}, /* ../..0.. */ \ + {0x00000370, "\x01\xc0\xf1\xe5\x0c\x00\x53\xe1"}, /* ......S. */ \ + {0x00000378, "\x01\x00\x00\x0a\x0c\x00\x43\xe0"}, /* ......C. */ \ + {0x00000380, "\x1e\xff\x2f\xe1\x01\x00\x80\xe2"}, /* ../..... */ \ + {0x00000388, "\xf3\xff\xff\xea\x01\x00\x50\xe1"}, /* ......P. */ \ + {0x00000390, "\x02\x30\x81\xe0\x01\x20\x40\x92"}, /* .0... @. */ \ + {0x00000398, "\x08\x00\x00\x9a\x00\x10\xa0\xe1"}, /* ........ */ \ + {0x000003a0, "\x02\x20\x80\xe0\x01\x00\x52\xe1"}, /* . ....R. */ \ + {0x000003a8, "\x1e\xff\x2f\x01\x01\xc0\x73\xe5"}, /* ../...s. */ \ + {0x000003b0, "\x01\xc0\x62\xe5\xfa\xff\xff\xea"}, /* ..b..... */ \ + {0x000003b8, "\x01\xc0\xd1\xe4\x01\xc0\xe2\xe5"}, /* ........ */ \ + {0x000003c0, "\x03\x00\x51\xe1\xfb\xff\xff\x1a"}, /* ..Q..... */ \ + {0x000003c8, "\x1e\xff\x2f\xe1\xee\xff\xff\xea"}, /* ../..... */ \ + {0x000003d0, "\x00\x30\xa0\xe1\x02\x20\x80\xe0"}, /* .0... .. */ \ + {0x000003d8, "\x02\x00\x53\xe1\x1e\xff\x2f\x01"}, /* ..S.../. */ \ + {0x000003e0, "\x01\x10\xc3\xe4\xfb\xff\xff\xea"}, /* ........ */ \ + {0x000003e8, "\x1e\xff\x2f\xe1\x1e\xff\x2f\xe1"}, /* ../.../. */ \ + {0x000003f0, "\x43\x00\x6f\x00\x75\x00\x6c\x00"}, /* C.o.u.l. */ \ + {0x000003f8, "\x64\x00\x20\x00\x6e\x00\x6f\x00"}, /* d. .n.o. */ \ + {0x00000400, "\x74\x00\x20\x00\x6f\x00\x70\x00"}, /* t. .o.p. */ \ + {0x00000408, "\x65\x00\x6e\x00\x20\x00\x6c\x00"}, /* e.n. .l. */ \ + {0x00000410, "\x6f\x00\x61\x00\x64\x00\x65\x00"}, /* o.a.d.e. */ \ + {0x00000418, "\x64\x00\x20\x00\x69\x00\x6d\x00"}, /* d. .i.m. */ \ + {0x00000420, "\x61\x00\x67\x00\x65\x00\x20\x00"}, /* a.g.e. . */ \ + {0x00000428, "\x70\x00\x72\x00\x6f\x00\x74\x00"}, /* p.r.o.t. */ \ + {0x00000430, "\x6f\x00\x63\x00\x6f\x00\x6c\x00"}, /* o.c.o.l. */ \ + {0x00000438, "\x00\x00\x49\x00\x6e\x00\x63\x00"}, /* ..I.n.c. */ \ + {0x00000440, "\x6f\x00\x72\x00\x72\x00\x65\x00"}, /* o.r.r.e. */ \ + {0x00000448, "\x63\x00\x74\x00\x20\x00\x69\x00"}, /* c.t. .i. */ \ + {0x00000450, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \ + {0x00000458, "\x5f\x00\x62\x00\x61\x00\x73\x00"}, /* _.b.a.s. */ \ + {0x00000460, "\x65\x00\x20\x00\x6f\x00\x72\x00"}, /* e. .o.r. */ \ + {0x00000468, "\x20\x00\x69\x00\x6d\x00\x61\x00"}, /* .i.m.a. */ \ + {0x00000470, "\x67\x00\x65\x00\x5f\x00\x73\x00"}, /* g.e._.s. */ \ + {0x00000478, "\x69\x00\x7a\x00\x65\x00\x0a\x00"}, /* i.z.e... */ \ + {0x00000480, "\x00\x00\x45\x00\x46\x00\x49\x00"}, /* ..E.F.I. */ \ + {0x00000488, "\x20\x00\x61\x00\x70\x00\x70\x00"}, /* .a.p.p. */ \ + {0x00000490, "\x6c\x00\x69\x00\x63\x00\x61\x00"}, /* l.i.c.a. */ \ + {0x00000498, "\x74\x00\x69\x00\x6f\x00\x6e\x00"}, /* t.i.o.n. */ \ + {0x000004a0, "\x20\x00\x63\x00\x61\x00\x6c\x00"}, /* .c.a.l. */ \ + {0x000004a8, "\x6c\x00\x69\x00\x6e\x00\x67\x00"}, /* l.i.n.g. */ \ + {0x000004b0, "\x20\x00\x45\x00\x78\x00\x69\x00"}, /* .E.x.i. */ \ + {0x000004b8, "\x74\x00\x0a\x00\x00\x00\x4c\x00"}, /* t.....L. */ \ + {0x000004c0, "\x6f\x00\x61\x00\x64\x00\x65\x00"}, /* o.a.d.e. */ \ + {0x000004c8, "\x64\x00\x20\x00\x69\x00\x6d\x00"}, /* d. .i.m. */ \ + {0x000004d0, "\x61\x00\x67\x00\x65\x00\x20\x00"}, /* a.g.e. . */ \ + {0x000004d8, "\x70\x00\x72\x00\x6f\x00\x74\x00"}, /* p.r.o.t. */ \ + {0x000004e0, "\x6f\x00\x63\x00\x6f\x00\x6c\x00"}, /* o.c.o.l. */ \ + {0x000004e8, "\x20\x00\x6d\x00\x69\x00\x73\x00"}, /* .m.i.s. */ \ + {0x000004f0, "\x73\x00\x69\x00\x6e\x00\x67\x00"}, /* s.i.n.g. */ \ + {0x000004f8, "\x0a\x00\x00\x00\x53\x00\x55\x00"}, /* ....S.U. */ \ + {0x00000500, "\x43\x00\x43\x00\x45\x00\x53\x00"}, /* C.C.E.S. */ \ + {0x00000508, "\x53\x00\x00\x00\x00\x00\x00\x00"}, /* S....... */ \ + {0x00000510, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000548, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \ + {0x00000550, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \ + {0x00000558, "\x10\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0, NULL} } } diff --git a/lib/efi_selftest/efi_miniapp_tcg2_arm64.h b/lib/efi_selftest/efi_miniapp_tcg2_arm64.h new file mode 100644 index 0000000000..bfe589438f --- /dev/null +++ b/lib/efi_selftest/efi_miniapp_tcg2_arm64.h @@ -0,0 +1,208 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * This file contains a precompiled EFI binary built from + * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include + * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL. + * The precompiled form is needed to avoid the problem of reproducible builds. + */ + +#define EFI_ST_DISK_IMG { 0x000011e0, { \ + {0x00000000, "\x4d\x5a\x00\x00\x00\x00\x00\x00"}, /* MZ...... */ \ + {0x00000038, "\x41\x52\x4d\x64\x40\x00\x00\x00"}, /* ARMd@... */ \ + {0x00000040, "\x50\x45\x00\x00\x64\xaa\x02\x00"}, /* PE..d... */ \ + {0x00000050, "\x00\x00\x00\x00\xa0\x00\x0e\x02"}, /* ........ */ \ + {0x00000058, "\x0b\x02\x02\x14\xd8\x04\x00\x00"}, /* ........ */ \ + {0x00000068, "\x48\x01\x00\x00\x48\x01\x00\x00"}, /* H...H... */ \ + {0x00000078, "\x20\x00\x00\x00\x08\x00\x00\x00"}, /* ....... */ \ + {0x00000090, "\x20\x06\x00\x00\x48\x01\x00\x00"}, /* ...H... */ \ + {0x00000098, "\x00\x00\x00\x00\x0a\x00\x00\x00"}, /* ........ */ \ + {0x000000c0, "\x00\x00\x00\x00\x06\x00\x00\x00"}, /* ........ */ \ + {0x000000f8, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \ + {0x00000118, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \ + {0x00000120, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \ + {0x00000128, "\xd8\x04\x00\x00\x48\x01\x00\x00"}, /* ....H... */ \ + {0x00000130, "\xd8\x04\x00\x00\x48\x01\x00\x00"}, /* ....H... */ \ + {0x00000140, "\x00\x00\x00\x00\x20\x00\x50\xe0"}, /* .... .P. */ \ + {0x00000148, "\xfd\x7b\xbe\xa9\xfd\x03\x00\x91"}, /* .{...... */ \ + {0x00000150, "\xe0\x07\x01\xa9\x60\xf5\xff\x10"}, /* ....`... */ \ + {0x00000158, "\x01\x00\x00\x90\x21\xc0\x14\x91"}, /* ....!... */ \ + {0x00000160, "\x5a\x00\x00\x94\x60\x00\x00\xb5"}, /* Z...`... */ \ + {0x00000168, "\xe0\x07\x41\xa9\x2d\x00\x00\x94"}, /* ..A.-... */ \ + {0x00000170, "\xfd\x7b\xc2\xa8\xc0\x03\x5f\xd6"}, /* .{...._. */ \ + {0x00000178, "\xfd\x7b\xbd\xa9\x45\x00\x80\x52"}, /* .{..E..R */ \ + {0x00000180, "\x04\x00\x80\xd2\x03\x00\x80\xd2"}, /* ........ */ \ + {0x00000188, "\xfd\x03\x00\x91\xf3\x53\x01\xa9"}, /* .....S.. */ \ + {0x00000190, "\xa2\xa3\x00\x91\x33\x20\x40\xf9"}, /* ....3 @. */ \ + {0x00000198, "\x21\x30\x40\xf9\x26\x8c\x40\xf9"}, /* !0@.&.@. */ \ + {0x000001a0, "\x01\x00\x00\x90\x21\xc0\x17\x91"}, /* ....!... */ \ + {0x000001a8, "\xc0\x00\x3f\xd6\xf4\x03\x00\xaa"}, /* ..?..... */ \ + {0x000001b0, "\x40\x01\x00\xb4\x62\x06\x40\xf9"}, /* @...b.@. */ \ + {0x000001b8, "\x01\x00\x00\x90\xe0\x03\x13\xaa"}, /* ........ */ \ + {0x000001c0, "\x21\x50\x10\x91\x40\x00\x3f\xd6"}, /* !P..@.?. */ \ + {0x000001c8, "\xe0\x03\x14\xaa\xf3\x53\x41\xa9"}, /* .....SA. */ \ + {0x000001d0, "\xfd\x7b\xc3\xa8\xc0\x03\x5f\xd6"}, /* .{...._. */ \ + {0x000001d8, "\xa2\x17\x40\xf9\x00\x00\x00\x90"}, /* ..@..... */ \ + {0x000001e0, "\x00\xe0\x05\x91\x41\x20\x40\xf9"}, /* ....A @. */ \ + {0x000001e8, "\x3f\x00\x00\xeb\xa8\x00\x00\x54"}, /* ?......T */ \ + {0x000001f0, "\x42\x24\x40\xf9\x21\x00\x02\x8b"}, /* B$@.!... */ \ + {0x000001f8, "\x3f\x00\x00\xeb\x68\xfe\xff\x54"}, /* ?...h..T */ \ + {0x00000200, "\x62\x06\x40\xf9\xd4\x01\x80\xd2"}, /* b.@..... */ \ + {0x00000208, "\x01\x00\x00\x90\xe0\x03\x13\xaa"}, /* ........ */ \ + {0x00000210, "\x21\x78\x11\x91\x14\x00\xf0\xf2"}, /* !x...... */ \ + {0x00000218, "\x40\x00\x3f\xd6\xeb\xff\xff\x17"}, /* @.?..... */ \ + {0x00000220, "\xfd\x7b\xbc\xa9\x02\x02\x80\xd2"}, /* .{...... */ \ + {0x00000228, "\xfd\x03\x00\x91\xf5\x5b\x02\xa9"}, /* .....[.. */ \ + {0x00000230, "\xb6\xc3\x00\x91\xf3\x53\x01\xa9"}, /* .....S.. */ \ + {0x00000238, "\xf5\x03\x00\xaa\xf4\x03\x01\xaa"}, /* ........ */ \ + {0x00000240, "\xe0\x03\x16\xaa\x33\x20\x40\xf9"}, /* ....3 @. */ \ + {0x00000248, "\x01\x00\x00\x90\x21\x80\x14\x91"}, /* ....!... */ \ + {0x00000250, "\x67\x00\x00\x94\x01\x00\x00\x90"}, /* g....... */ \ + {0x00000258, "\xe0\x03\x13\xaa\x62\x06\x40\xf9"}, /* ....b.@. */ \ + {0x00000260, "\x21\x98\x12\x91\x40\x00\x3f\xd6"}, /* !...@.?. */ \ + {0x00000268, "\xe1\x03\x14\xaa\xe0\x03\x15\xaa"}, /* ........ */ \ + {0x00000270, "\xc2\xff\xff\x97\x60\x02\x00\xb4"}, /* ....`... */ \ + {0x00000278, "\x62\x06\x40\xf9\x01\x00\x00\x90"}, /* b.@..... */ \ + {0x00000280, "\xe0\x03\x13\xaa\x21\x88\x13\x91"}, /* ....!... */ \ + {0x00000288, "\x40\x00\x3f\xd6\xc1\x01\x80\xd2"}, /* @.?..... */ \ + {0x00000290, "\x01\x00\xf0\xf2\x80\x32\x40\xf9"}, /* .....2@. */ \ + {0x00000298, "\xe3\x03\x16\xaa\x02\x02\x80\xd2"}, /* ........ */ \ + {0x000002a0, "\x04\x6c\x40\xf9\xe0\x03\x15\xaa"}, /* .l@..... */ \ + {0x000002a8, "\x80\x00\x3f\xd6\x00\x00\x80\xd2"}, /* ..?..... */ \ + {0x000002b0, "\xf3\x53\x41\xa9\xf5\x5b\x42\xa9"}, /* .SA..[B. */ \ + {0x000002b8, "\xfd\x7b\xc4\xa8\xc0\x03\x5f\xd6"}, /* .{...._. */ \ + {0x000002c0, "\xe1\x0b\x41\xb2\xf4\xff\xff\x17"}, /* ..A..... */ \ + {0x000002c8, "\x21\x20\x00\x91\x02\x00\x80\xd2"}, /* ! ...... */ \ + {0x000002d0, "\x04\x00\x80\xd2\x03\x00\x80\xd2"}, /* ........ */ \ + {0x000002d8, "\x25\x80\x5f\xf8\x25\x01\x00\xb5"}, /* %._.%... */ \ + {0x000002e0, "\x5f\x00\x00\xf1\xe1\x17\x9f\x1a"}, /* _....... */ \ + {0x000002e8, "\x9f\x00\x00\xf1\xe5\x17\x9f\x1a"}, /* ........ */ \ + {0x000002f0, "\x3f\x00\x05\x6a\x20\x02\x00\x54"}, /* ?..j ..T */ \ + {0x000002f8, "\x00\x00\x80\xd2\xc0\x03\x5f\xd6"}, /* ......_. */ \ + {0x00000300, "\xbf\x20\x00\xf1\x20\x01\x00\x54"}, /* . .. ..T */ \ + {0x00000308, "\xbf\x24\x00\xf1\x20\x01\x00\x54"}, /* .$.. ..T */ \ + {0x00000310, "\xbf\x1c\x00\xf1\x61\x00\x00\x54"}, /* ....a..T */ \ + {0x00000318, "\x22\x00\x40\xf9\x02\x00\x02\x8b"}, /* ".@..... */ \ + {0x00000320, "\x21\x40\x00\x91\xed\xff\xff\x17"}, /* !@...... */ \ + {0x00000328, "\x23\x00\x40\xf9\xfd\xff\xff\x17"}, /* #.@..... */ \ + {0x00000330, "\x24\x00\x40\xf9\xfb\xff\xff\x17"}, /* $.@..... */ \ + {0x00000338, "\x21\x00\x05\x2a\xa1\x01\x00\x35"}, /* !......5 */ \ + {0x00000340, "\x7f\x00\x00\xf1\xad\xfd\xff\x54"}, /* .......T */ \ + {0x00000348, "\x41\x08\x40\xb9\x3f\x0c\x10\xf1"}, /* A.@.?... */ \ + {0x00000350, "\xa1\x00\x00\x54\x45\x00\x40\xf9"}, /* ...TE.@. */ \ + {0x00000358, "\x41\x08\x40\xf9\x21\x00\x00\x8b"}, /* A.@.!... */ \ + {0x00000360, "\xa1\x68\x20\xf8\x42\x00\x04\x8b"}, /* .h .B... */ \ + {0x00000368, "\x63\x00\x04\xcb\xf5\xff\xff\x17"}, /* c....... */ \ + {0x00000370, "\xe0\x07\x41\xb2\xc0\x03\x5f\xd6"}, /* ..A..._. */ \ + {0x00000378, "\x04\x00\x80\xd2\x5f\x00\x04\xeb"}, /* ...._... */ \ + {0x00000380, "\x61\x00\x00\x54\x00\x00\x80\x52"}, /* a..T...R */ \ + {0x00000388, "\xc0\x03\x5f\xd6\x03\x68\x64\x38"}, /* .._..hd8 */ \ + {0x00000390, "\x84\x04\x00\x91\x25\x00\x04\x8b"}, /* ....%... */ \ + {0x00000398, "\xa5\xf0\x5f\x38\x7f\x00\x05\x6b"}, /* .._8...k */ \ + {0x000003a0, "\xe0\xfe\xff\x54\x60\x00\x05\x4b"}, /* ...T`..K */ \ + {0x000003a8, "\xc0\x03\x5f\xd6\x1f\x00\x01\xeb"}, /* .._..... */ \ + {0x000003b0, "\x68\x01\x00\x54\x03\x00\x80\xd2"}, /* h..T.... */ \ + {0x000003b8, "\x7f\x00\x02\xeb\x41\x00\x00\x54"}, /* ....A..T */ \ + {0x000003c0, "\xc0\x03\x5f\xd6\x24\x68\x63\x38"}, /* .._.$hc8 */ \ + {0x000003c8, "\x04\x68\x23\x38\x63\x04\x00\x91"}, /* .h#8c... */ \ + {0x000003d0, "\xfa\xff\xff\x17\x23\x68\x62\x38"}, /* ....#hb8 */ \ + {0x000003d8, "\x03\x68\x22\x38\x42\x04\x00\xd1"}, /* .h"8B... */ \ + {0x000003e0, "\x5f\x04\x00\xb1\x81\xff\xff\x54"}, /* _......T */ \ + {0x000003e8, "\xc0\x03\x5f\xd6\xf0\xff\xff\x17"}, /* .._..... */ \ + {0x000003f0, "\x03\x00\x80\xd2\x5f\x00\x03\xeb"}, /* ...._... */ \ + {0x000003f8, "\x41\x00\x00\x54\xc0\x03\x5f\xd6"}, /* A..T.._. */ \ + {0x00000400, "\x01\x68\x23\x38\x63\x04\x00\x91"}, /* .h#8c... */ \ + {0x00000408, "\xfb\xff\xff\x17\xc0\x03\x5f\xd6"}, /* ......_. */ \ + {0x00000410, "\xc0\x03\x5f\xd6\x43\x00\x6f\x00"}, /* .._.C.o. */ \ + {0x00000418, "\x75\x00\x6c\x00\x64\x00\x20\x00"}, /* u.l.d. . */ \ + {0x00000420, "\x6e\x00\x6f\x00\x74\x00\x20\x00"}, /* n.o.t. . */ \ + {0x00000428, "\x6f\x00\x70\x00\x65\x00\x6e\x00"}, /* o.p.e.n. */ \ + {0x00000430, "\x20\x00\x6c\x00\x6f\x00\x61\x00"}, /* .l.o.a. */ \ + {0x00000438, "\x64\x00\x65\x00\x64\x00\x20\x00"}, /* d.e.d. . */ \ + {0x00000440, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \ + {0x00000448, "\x65\x00\x20\x00\x70\x00\x72\x00"}, /* e. .p.r. */ \ + {0x00000450, "\x6f\x00\x74\x00\x6f\x00\x63\x00"}, /* o.t.o.c. */ \ + {0x00000458, "\x6f\x00\x6c\x00\x00\x00\x49\x00"}, /* o.l...I. */ \ + {0x00000460, "\x6e\x00\x63\x00\x6f\x00\x72\x00"}, /* n.c.o.r. */ \ + {0x00000468, "\x72\x00\x65\x00\x63\x00\x74\x00"}, /* r.e.c.t. */ \ + {0x00000470, "\x20\x00\x69\x00\x6d\x00\x61\x00"}, /* .i.m.a. */ \ + {0x00000478, "\x67\x00\x65\x00\x5f\x00\x62\x00"}, /* g.e._.b. */ \ + {0x00000480, "\x61\x00\x73\x00\x65\x00\x20\x00"}, /* a.s.e. . */ \ + {0x00000488, "\x6f\x00\x72\x00\x20\x00\x69\x00"}, /* o.r. .i. */ \ + {0x00000490, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \ + {0x00000498, "\x5f\x00\x73\x00\x69\x00\x7a\x00"}, /* _.s.i.z. */ \ + {0x000004a0, "\x65\x00\x0a\x00\x00\x00\x45\x00"}, /* e.....E. */ \ + {0x000004a8, "\x46\x00\x49\x00\x20\x00\x61\x00"}, /* F.I. .a. */ \ + {0x000004b0, "\x70\x00\x70\x00\x6c\x00\x69\x00"}, /* p.p.l.i. */ \ + {0x000004b8, "\x63\x00\x61\x00\x74\x00\x69\x00"}, /* c.a.t.i. */ \ + {0x000004c0, "\x6f\x00\x6e\x00\x20\x00\x63\x00"}, /* o.n. .c. */ \ + {0x000004c8, "\x61\x00\x6c\x00\x6c\x00\x69\x00"}, /* a.l.l.i. */ \ + {0x000004d0, "\x6e\x00\x67\x00\x20\x00\x45\x00"}, /* n.g. .E. */ \ + {0x000004d8, "\x78\x00\x69\x00\x74\x00\x0a\x00"}, /* x.i.t... */ \ + {0x000004e0, "\x00\x00\x4c\x00\x6f\x00\x61\x00"}, /* ..L.o.a. */ \ + {0x000004e8, "\x64\x00\x65\x00\x64\x00\x20\x00"}, /* d.e.d. . */ \ + {0x000004f0, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \ + {0x000004f8, "\x65\x00\x20\x00\x70\x00\x72\x00"}, /* e. .p.r. */ \ + {0x00000500, "\x6f\x00\x74\x00\x6f\x00\x63\x00"}, /* o.t.o.c. */ \ + {0x00000508, "\x6f\x00\x6c\x00\x20\x00\x6d\x00"}, /* o.l. .m. */ \ + {0x00000510, "\x69\x00\x73\x00\x73\x00\x69\x00"}, /* i.s.s.i. */ \ + {0x00000518, "\x6e\x00\x67\x00\x0a\x00\x00\x00"}, /* n.g..... */ \ + {0x00000520, "\x53\x00\x55\x00\x43\x00\x43\x00"}, /* S.U.C.C. */ \ + {0x00000528, "\x45\x00\x53\x00\x53\x00\x00\x00"}, /* E.S.S... */ \ + {0x00000530, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000540, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000548, "\xb0\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \ + {0x00000550, "\x05\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000558, "\x00\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \ + {0x00000560, "\x06\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000568, "\x00\x10\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000570, "\x0a\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000578, "\xaa\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000580, "\x0b\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000588, "\x18\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000005f0, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \ + {0x000005f8, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \ + {0x00000618, "\x30\x05\x00\x00\x00\x00\x00\x00"}, /* 0....... */ \ + {0x00001018, "\x00\x00\x00\x00\x03\x00\x01\x00"}, /* ........ */ \ + {0x00001030, "\x00\x00\x00\x00\x03\x00\x03\x00"}, /* ........ */ \ + {0x00001038, "\xf0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001048, "\x33\x00\x00\x00\x12\x00\x01\x00"}, /* 3....... */ \ + {0x00001050, "\xac\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001058, "\x40\x00\x00\x00\x00\x00\x00\x00"}, /* @....... */ \ + {0x00001060, "\x5b\x00\x00\x00\x12\x00\x01\x00"}, /* [....... */ \ + {0x00001068, "\x10\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001070, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001078, "\x79\x00\x00\x00\x10\x00\x01\x00"}, /* y....... */ \ + {0x00001080, "\x30\x05\x00\x00\x00\x00\x00\x00"}, /* 0....... */ \ + {0x00001090, "\x01\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \ + {0x00001098, "\x20\x02\x00\x00\x00\x00\x00\x00"}, /* ....... */ \ + {0x000010a0, "\xa8\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000010a8, "\x0a\x00\x00\x00\x12\x00\x01\x00"}, /* ........ */ \ + {0x000010b0, "\xec\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000010b8, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000010c0, "\x96\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \ + {0x000010c8, "\x20\x06\x00\x00\x00\x00\x00\x00"}, /* ....... */ \ + {0x000010d8, "\x22\x00\x00\x00\x12\x00\x01\x00"}, /* "....... */ \ + {0x000010e0, "\xc8\x02\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000010e8, "\xb0\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000010f0, "\x91\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \ + {0x000010f8, "\x20\x06\x00\x00\x00\x00\x00\x00"}, /* ....... */ \ + {0x00001108, "\x2c\x00\x00\x00\x12\x00\x01\x00"}, /* ,....... */ \ + {0x00001110, "\x78\x03\x00\x00\x00\x00\x00\x00"}, /* x....... */ \ + {0x00001118, "\x34\x00\x00\x00\x00\x00\x00\x00"}, /* 4....... */ \ + {0x00001120, "\x73\x00\x00\x00\x10\x00\x01\x00"}, /* s....... */ \ + {0x00001138, "\x9f\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \ + {0x00001140, "\xf0\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001150, "\x11\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \ + {0x00001168, "\x42\x00\x00\x00\x12\x00\x01\x00"}, /* B....... */ \ + {0x00001170, "\x0c\x04\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001178, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001180, "\x3b\x00\x00\x00\x12\x00\x01\x00"}, /* ;....... */ \ + {0x00001188, "\xf0\x03\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001190, "\x1c\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00001198, "\x8b\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \ + {0x000011a0, "\xf0\x05\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000011b0, "\x1b\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \ + {0x000011b8, "\x20\x06\x00\x00\x00\x00\x00\x00"}, /* ....... */ \ + {0x000011c8, "\x80\x00\x00\x00\x10\x00\xf1\xff"}, /* ........ */ \ + {0x000011d0, "\x30\x05\x00\x00\x00\x00\x00\x00"}, /* 0....... */ \ + {0, NULL} } } diff --git a/lib/efi_selftest/efi_miniapp_tcg2_ia32.h b/lib/efi_selftest/efi_miniapp_tcg2_ia32.h new file mode 100644 index 0000000000..aa8c13939c --- /dev/null +++ b/lib/efi_selftest/efi_miniapp_tcg2_ia32.h @@ -0,0 +1,178 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * This file contains a precompiled EFI binary built from + * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include + * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL. + * The precompiled form is needed to avoid the problem of reproducible builds. + */ + +#define EFI_ST_DISK_IMG { 0x00001200, { \ + {0x00000000, "\x4d\x5a\x90\x00\x03\x00\x00\x00"}, /* MZ...... */ \ + {0x00000008, "\x04\x00\x00\x00\xff\xff\x00\x00"}, /* ........ */ \ + {0x00000010, "\xb8\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000018, "\x40\x00\x00\x00\x00\x00\x00\x00"}, /* @....... */ \ + {0x00000038, "\x00\x00\x00\x00\x80\x00\x00\x00"}, /* ........ */ \ + {0x00000040, "\x0e\x1f\xba\x0e\x00\xb4\x09\xcd"}, /* ........ */ \ + {0x00000048, "\x21\xb8\x01\x4c\xcd\x21\x54\x68"}, /* !..L.!Th */ \ + {0x00000050, "\x69\x73\x20\x70\x72\x6f\x67\x72"}, /* is progr */ \ + {0x00000058, "\x61\x6d\x20\x63\x61\x6e\x6e\x6f"}, /* am canno */ \ + {0x00000060, "\x74\x20\x62\x65\x20\x72\x75\x6e"}, /* t be run */ \ + {0x00000068, "\x20\x69\x6e\x20\x44\x4f\x53\x20"}, /* in DOS */ \ + {0x00000070, "\x6d\x6f\x64\x65\x2e\x0d\x0d\x0a"}, /* mode.... */ \ + {0x00000078, "\x24\x00\x00\x00\x00\x00\x00\x00"}, /* $....... */ \ + {0x00000080, "\x50\x45\x00\x00\x4c\x01\x06\x00"}, /* PE..L... */ \ + {0x00000090, "\x00\x00\x00\x00\xe0\x00\x0e\x03"}, /* ........ */ \ + {0x00000098, "\x0b\x01\x02\x1e\x00\x04\x00\x00"}, /* ........ */ \ + {0x000000a0, "\x00\x0a\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000000a8, "\x00\x10\x00\x00\x00\x10\x00\x00"}, /* ........ */ \ + {0x000000b0, "\x00\x30\x00\x00\x00\x00\x00\x00"}, /* .0...... */ \ + {0x000000b8, "\x00\x10\x00\x00\x00\x02\x00\x00"}, /* ........ */ \ + {0x000000d0, "\x00\x70\x00\x00\x00\x04\x00\x00"}, /* .p...... */ \ + {0x000000d8, "\x6c\xdf\x00\x00\x0a\x00\x00\x00"}, /* l....... */ \ + {0x000000f0, "\x00\x00\x00\x00\x10\x00\x00\x00"}, /* ........ */ \ + {0x00000120, "\x00\x50\x00\x00\x0a\x00\x00\x00"}, /* .P...... */ \ + {0x00000178, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \ + {0x00000180, "\x1b\x02\x00\x00\x00\x10\x00\x00"}, /* ........ */ \ + {0x00000188, "\x00\x04\x00\x00\x00\x04\x00\x00"}, /* ........ */ \ + {0x00000198, "\x00\x00\x00\x00\x20\x00\x30\x60"}, /* .... .0` */ \ + {0x000001a0, "\x2e\x73\x64\x61\x74\x61\x00\x00"}, /* .sdata.. */ \ + {0x000001a8, "\x0c\x00\x00\x00\x00\x20\x00\x00"}, /* ..... .. */ \ + {0x000001b0, "\x00\x02\x00\x00\x00\x08\x00\x00"}, /* ........ */ \ + {0x000001c0, "\x00\x00\x00\x00\x40\x00\x30\xc0"}, /* ....@.0. */ \ + {0x000001c8, "\x2e\x64\x61\x74\x61\x00\x00\x00"}, /* .data... */ \ + {0x000001d0, "\x38\x01\x00\x00\x00\x30\x00\x00"}, /* 8....0.. */ \ + {0x000001d8, "\x00\x02\x00\x00\x00\x0a\x00\x00"}, /* ........ */ \ + {0x000001e8, "\x00\x00\x00\x00\x40\x00\x40\xc0"}, /* ....@.@. */ \ + {0x000001f0, "\x2e\x64\x79\x6e\x61\x6d\x69\x63"}, /* .dynamic */ \ + {0x000001f8, "\x70\x00\x00\x00\x00\x40\x00\x00"}, /* p....@.. */ \ + {0x00000200, "\x00\x02\x00\x00\x00\x0c\x00\x00"}, /* ........ */ \ + {0x00000210, "\x00\x00\x00\x00\x40\x00\x30\xc0"}, /* ....@.0. */ \ + {0x00000218, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \ + {0x00000220, "\x0a\x00\x00\x00\x00\x50\x00\x00"}, /* .....P.. */ \ + {0x00000228, "\x00\x02\x00\x00\x00\x0e\x00\x00"}, /* ........ */ \ + {0x00000238, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \ + {0x00000240, "\x2e\x64\x79\x6e\x73\x79\x6d\x00"}, /* .dynsym. */ \ + {0x00000248, "\x30\x00\x00\x00\x00\x60\x00\x00"}, /* 0....`.. */ \ + {0x00000250, "\x00\x02\x00\x00\x00\x10\x00\x00"}, /* ........ */ \ + {0x00000260, "\x00\x00\x00\x00\x40\x00\x30\x40"}, /* ....@.0@ */ \ + {0x00000400, "\x55\x89\xe5\xff\x75\x0c\xff\x75"}, /* U...u..u */ \ + {0x00000408, "\x08\xe8\x00\x00\x00\x00\x58\x89"}, /* ......X. */ \ + {0x00000410, "\xc3\x05\xf2\xef\xff\xff\x81\xc3"}, /* ........ */ \ + {0x00000418, "\xf2\x2f\x00\x00\x53\x50\xe8\x20"}, /* ./..SP. */ \ + {0x00000420, "\x01\x00\x00\x5b\x5b\x85\xc0\x75"}, /* ...[[..u */ \ + {0x00000428, "\x05\xe8\x8a\x00\x00\x00\xc9\xc3"}, /* ........ */ \ + {0x00000430, "\x57\x56\x53\x83\xec\x18\xe8\x00"}, /* WVS..... */ \ + {0x00000438, "\x01\x00\x00\x81\xc6\xc5\x0f\x00"}, /* ........ */ \ + {0x00000440, "\x00\x8b\x44\x24\x2c\x8b\x58\x2c"}, /* ..D$,.X, */ \ + {0x00000448, "\x8b\x40\x3c\x6a\x02\x6a\x00\x6a"}, /* .@. */ \ + {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..9b0413facd --- /dev/null +++ b/lib/efi_selftest/efi_miniapp_tcg2_x86_64.h @@ -0,0 +1,179 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * This file contains a precompiled EFI binary built from + * lib/efi_selftest/efi_miniapp_file_image_exit.c and converted to an include + * using tools/file2include. It is used to testing the EFI_TCG2_PROTOCOL. + * The precompiled form is needed to avoid the problem of reproducible builds. + */ + +#define EFI_ST_DISK_IMG { 0x00001000, { \ + {0x00000000, "\x4d\x5a\x90\x00\x03\x00\x00\x00"}, /* MZ...... */ \ + {0x00000008, "\x04\x00\x00\x00\xff\xff\x00\x00"}, /* ........ */ \ + {0x00000010, "\xb8\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000018, "\x40\x00\x00\x00\x00\x00\x00\x00"}, /* @....... */ \ + {0x00000038, "\x00\x00\x00\x00\x80\x00\x00\x00"}, /* ........ */ \ + {0x00000040, "\x0e\x1f\xba\x0e\x00\xb4\x09\xcd"}, /* ........ */ \ + {0x00000048, "\x21\xb8\x01\x4c\xcd\x21\x54\x68"}, /* !..L.!Th */ \ + {0x00000050, "\x69\x73\x20\x70\x72\x6f\x67\x72"}, /* is progr */ \ + {0x00000058, "\x61\x6d\x20\x63\x61\x6e\x6e\x6f"}, /* am canno */ \ + {0x00000060, "\x74\x20\x62\x65\x20\x72\x75\x6e"}, /* t be run */ \ + {0x00000068, "\x20\x69\x6e\x20\x44\x4f\x53\x20"}, /* in DOS */ \ + {0x00000070, "\x6d\x6f\x64\x65\x2e\x0d\x0d\x0a"}, /* mode.... */ \ + {0x00000078, "\x24\x00\x00\x00\x00\x00\x00\x00"}, /* $....... */ \ + {0x00000080, "\x50\x45\x00\x00\x64\x86\x05\x00"}, /* PE..d... */ \ + {0x00000090, "\x00\x00\x00\x00\xf0\x00\x0e\x02"}, /* ........ */ \ + {0x00000098, "\x0b\x02\x02\x1e\x00\x04\x00\x00"}, /* ........ */ \ + {0x000000a0, "\x00\x08\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x000000a8, "\x00\x20\x00\x00\x00\x20\x00\x00"}, /* . ... .. */ \ + {0x000000b8, "\x00\x10\x00\x00\x00\x02\x00\x00"}, /* ........ */ \ + {0x000000d0, "\x00\x70\x00\x00\x00\x04\x00\x00"}, /* .p...... */ \ + {0x000000d8, "\x24\xe3\x00\x00\x0a\x00\x00\x00"}, /* $....... */ \ + {0x00000100, "\x00\x00\x00\x00\x10\x00\x00\x00"}, /* ........ */ \ + {0x00000130, "\x00\x30\x00\x00\x0a\x00\x00\x00"}, /* .0...... */ \ + {0x00000188, "\x2e\x74\x65\x78\x74\x00\x00\x00"}, /* .text... */ \ + {0x00000190, "\x29\x02\x00\x00\x00\x20\x00\x00"}, /* ).... .. */ \ + {0x00000198, "\x00\x04\x00\x00\x00\x04\x00\x00"}, /* ........ */ \ + {0x000001a8, "\x00\x00\x00\x00\x20\x00\x30\x60"}, /* .... .0` */ \ + {0x000001b0, "\x2e\x72\x65\x6c\x6f\x63\x00\x00"}, /* .reloc.. */ \ + {0x000001b8, "\x0a\x00\x00\x00\x00\x30\x00\x00"}, /* .....0.. */ \ + {0x000001c0, "\x00\x02\x00\x00\x00\x08\x00\x00"}, /* ........ */ \ + {0x000001d0, "\x00\x00\x00\x00\x40\x00\x10\x42"}, /* ....@..B */ \ + {0x000001d8, "\x2e\x64\x61\x74\x61\x00\x00\x00"}, /* .data... */ \ + {0x000001e0, "\x38\x01\x00\x00\x00\x40\x00\x00"}, /* 8....@.. */ \ + {0x000001e8, "\x00\x02\x00\x00\x00\x0a\x00\x00"}, /* ........ */ \ + {0x000001f8, "\x00\x00\x00\x00\x40\x00\x50\xc0"}, /* ....@.P. */ \ + {0x00000200, "\x2e\x64\x79\x6e\x61\x6d\x69\x63"}, /* .dynamic */ \ + {0x00000208, "\xe0\x00\x00\x00\x00\x50\x00\x00"}, /* .....P.. */ \ + {0x00000210, "\x00\x02\x00\x00\x00\x0c\x00\x00"}, /* ........ */ \ + {0x00000220, "\x00\x00\x00\x00\x40\x00\x40\xc0"}, /* ....@.@. */ \ + {0x00000228, "\x2e\x64\x79\x6e\x73\x79\x6d\x00"}, /* .dynsym. */ \ + {0x00000230, "\x48\x00\x00\x00\x00\x60\x00\x00"}, /* H....`.. */ \ + {0x00000238, "\x00\x02\x00\x00\x00\x0e\x00\x00"}, /* ........ */ \ + {0x00000248, "\x00\x00\x00\x00\x40\x00\x40\x40"}, /* ....@.@@ */ \ + {0x00000400, "\x48\x83\xec\x08\x51\x52\x48\x8d"}, /* H...QRH. */ \ + {0x00000408, "\x0d\xf3\xdf\xff\xff\x48\x8d\x15"}, /* .....H.. */ \ + {0x00000410, "\xec\x2f\x00\x00\xe8\x24\x01\x00"}, /* ./...$.. */ \ + {0x00000418, "\x00\x5a\x59\x48\x85\xc0\x75\x05"}, /* .ZYH..u. */ \ + {0x00000420, "\xe8\x8f\x00\x00\x00\x48\x83\xc4"}, /* .....H.. */ \ + {0x00000428, "\x08\xc3\x56\x45\x31\xc9\x53\x48"}, /* ..VE1.SH */ \ + {0x00000430, "\x83\xec\x48\x48\x8b\x42\x60\x48"}, /* ..HH.B`H */ \ + {0x00000438, "\x8b\x5a\x40\x4c\x8d\x44\x24\x38"}, /* .Z@L.D$8 */ \ + {0x00000440, "\xc7\x44\x24\x28\x02\x00\x00\x00"}, /* .D$(.... */ \ + {0x00000448, "\x48\xc7\x44\x24\x20\x00\x00\x00"}, /* H.D$ ... */ \ + {0x00000450, "\x00\x48\x8d\x15\xc8\x20\x00\x00"}, /* .H... .. */ \ + {0x00000458, "\xff\x90\x18\x01\x00\x00\x48\x85"}, /* ......H. */ \ + {0x00000460, "\xc0\x48\x89\xc6\x74\x0f\x48\x8d"}, /* .H..t.H. */ \ + {0x00000468, "\x15\x95\x1f\x00\x00\x48\x89\xd9"}, /* .....H.. */ \ + {0x00000470, "\xff\x53\x08\xeb\x35\x48\x8b\x4c"}, /* .S..5H.L */ \ + {0x00000478, "\x24\x38\x48\x8d\x15\xa9\xff\xff"}, /* $8H..... */ \ + {0x00000480, "\xff\x48\x8b\x41\x40\x48\x39\xd0"}, /* .H.A@H9. */ \ + {0x00000488, "\x77\x09\x48\x03\x41\x48\x48\x39"}, /* w.H.AHH9 */ \ + {0x00000490, "\xd0\x77\x17\x48\x8d\x15\xb2\x1f"}, /* .w.H.... */ \ + {0x00000498, "\x00\x00\x48\x89\xd9\x48\xbe\x0e"}, /* ..H..H.. */ \ + {0x000004a0, "\x00\x00\x00\x00\x00\x00\x80\xff"}, /* ........ */ \ + {0x000004a8, "\x53\x08\x48\x83\xc4\x48\x48\x89"}, /* S.H..HH. */ \ + {0x000004b0, "\xf0\x5b\x5e\xc3\x57\x48\x89\xcf"}, /* .[^.WH.. */ \ + {0x000004b8, "\x56\x48\x89\xd6\x53\x48\x83\xec"}, /* VH..SH.. */ \ + {0x000004c0, "\x30\x48\x8b\x5a\x40\x48\x8b\x05"}, /* 0H.Z@H.. */ \ + {0x000004c8, "\x42\x20\x00\x00\x48\x8b\x15\x43"}, /* B ..H..C */ \ + {0x000004d0, "\x20\x00\x00\x48\x89\xd9\x48\x89"}, /* ..H..H. */ \ + {0x000004d8, "\x44\x24\x20\x48\x89\x54\x24\x28"}, /* D$ H.T$( */ \ + {0x000004e0, "\x48\x8d\x15\xad\x1f\x00\x00\xff"}, /* H....... */ \ + {0x000004e8, "\x53\x08\x48\x89\xf2\x48\x89\xf9"}, /* S.H..H.. */ \ + {0x000004f0, "\xe8\x35\xff\xff\xff\x48\xba\x03"}, /* .5...H.. */ \ + {0x000004f8, "\x00\x00\x00\x00\x00\x00\x80\x48"}, /* .......H */ \ + {0x00000500, "\x85\xc0\x74\x17\x48\x8d\x15\xc5"}, /* ..t.H... */ \ + {0x00000508, "\x1f\x00\x00\x48\x89\xd9\xff\x53"}, /* ...H...S */ \ + {0x00000510, "\x08\x48\xba\x0e\x00\x00\x00\x00"}, /* .H...... */ \ + {0x00000518, "\x00\x00\x80\x48\x8b\x46\x60\x4c"}, /* ...H.F`L */ \ + {0x00000520, "\x8d\x4c\x24\x20\x48\x89\xf9\x41"}, /* .L$ H..A */ \ + {0x00000528, "\xb8\x10\x00\x00\x00\xff\x90\xd8"}, /* ........ */ \ + {0x00000530, "\x00\x00\x00\x48\x83\xc4\x30\x31"}, /* ...H..01 */ \ + {0x00000538, "\xc0\x5b\x5e\x5f\xc3\x48\x83\xc2"}, /* .[^_.H.. */ \ + {0x00000540, "\x08\x31\xc0\x45\x31\xc9\x45\x31"}, /* .1.E1.E1 */ \ + {0x00000548, "\xc0\x4c\x8b\x52\xf8\x4d\x85\xd2"}, /* .L.R.M.. */ \ + {0x00000550, "\x74\x28\x49\x83\xfa\x08\x74\x14"}, /* t(I...t. */ \ + {0x00000558, "\x49\x83\xfa\x09\x74\x13\x49\x83"}, /* I...t.I. */ \ + {0x00000560, "\xfa\x07\x75\x10\x48\x8b\x02\x48"}, /* ..u.H..H */ \ + {0x00000568, "\x01\xc8\xeb\x08\x4c\x8b\x02\xeb"}, /* ....L... */ \ + {0x00000570, "\x03\x4c\x8b\x0a\x48\x83\xc2\x10"}, /* .L..H... */ \ + {0x00000578, "\xeb\xcf\x48\x85\xc0\x41\x0f\x94"}, /* ..H..A.. */ \ + {0x00000580, "\xc2\x4d\x85\xc9\x0f\x94\xc2\x45"}, /* .M.....E */ \ + {0x00000588, "\x84\xd2\x74\x07\x84\xd2\x74\x23"}, /* ..t...t# */ \ + {0x00000590, "\x31\xc0\xc3\x84\xd2\x75\x1c\x4d"}, /* 1....u.M */ \ + {0x00000598, "\x85\xc0\x7e\xf4\x83\x78\x08\x08"}, /* ..~..x.. */ \ + {0x000005a0, "\x75\x09\x48\x8b\x10\x48\x01\xca"}, /* u.H..H.. */ \ + {0x000005a8, "\x48\x01\x0a\x4c\x01\xc8\x4d\x29"}, /* H..L..M) */ \ + {0x000005b0, "\xc8\xeb\xe4\x48\xb8\x01\x00\x00"}, /* ...H.... */ \ + {0x000005b8, "\x00\x00\x00\x00\x80\xc3\x31\xc9"}, /* ......1. */ \ + {0x000005c0, "\x48\x39\xca\x74\x16\x0f\xb6\x04"}, /* H9.t.... */ \ + {0x000005c8, "\x0f\x48\xff\xc1\x44\x0f\xb6\x44"}, /* .H..D..D */ \ + {0x000005d0, "\x0e\xff\x44\x38\xc0\x74\xe9\x44"}, /* ..D8.t.D */ \ + {0x000005d8, "\x29\xc0\xc3\x31\xc0\xc3\x48\x39"}, /* )..1..H9 */ \ + {0x000005e0, "\xf7\x48\x89\xf8\x77\x15\x31\xc9"}, /* .H..w.1. */ \ + {0x000005e8, "\x48\x39\xca\x74\x0d\x40\x8a\x3c"}, /* H9.t.@.< */ \ + {0x000005f0, "\x0e\x40\x88\x3c\x08\x48\xff\xc1"}, /* .@.<.H.. */ \ + {0x000005f8, "\xeb\xee\xc3\x48\x85\xd2\x74\x0d"}, /* ...H..t. */ \ + {0x00000600, "\x8a\x4c\x16\xff\x88\x4c\x10\xff"}, /* .L...L.. */ \ + {0x00000608, "\x48\xff\xca\xeb\xee\xc3\xe9\xcb"}, /* H....... */ \ + {0x00000610, "\xff\xff\xff\x48\x89\xf8\x31\xc9"}, /* ...H..1. */ \ + {0x00000618, "\x48\x39\xca\x74\x09\x40\x88\x34"}, /* H9.t.@.4 */ \ + {0x00000620, "\x08\x48\xff\xc1\xeb\xf2\xc3\xc3"}, /* .H...... */ \ + {0x00000628, "\xc3\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000800, "\x30\x11\x00\x00\x0a\x00\x00\x00"}, /* 0....... */ \ + {0x00000a00, "\x00\x00\x43\x00\x6f\x00\x75\x00"}, /* ..C.o.u. */ \ + {0x00000a08, "\x6c\x00\x64\x00\x20\x00\x6e\x00"}, /* l.d. .n. */ \ + {0x00000a10, "\x6f\x00\x74\x00\x20\x00\x6f\x00"}, /* o.t. .o. */ \ + {0x00000a18, "\x70\x00\x65\x00\x6e\x00\x20\x00"}, /* p.e.n. . */ \ + {0x00000a20, "\x6c\x00\x6f\x00\x61\x00\x64\x00"}, /* l.o.a.d. */ \ + {0x00000a28, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \ + {0x00000a30, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \ + {0x00000a38, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \ + {0x00000a40, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \ + {0x00000a48, "\x6c\x00\x00\x00\x49\x00\x6e\x00"}, /* l...I.n. */ \ + {0x00000a50, "\x63\x00\x6f\x00\x72\x00\x72\x00"}, /* c.o.r.r. */ \ + {0x00000a58, "\x65\x00\x63\x00\x74\x00\x20\x00"}, /* e.c.t. . */ \ + {0x00000a60, "\x69\x00\x6d\x00\x61\x00\x67\x00"}, /* i.m.a.g. */ \ + {0x00000a68, "\x65\x00\x5f\x00\x62\x00\x61\x00"}, /* e._.b.a. */ \ + {0x00000a70, "\x73\x00\x65\x00\x20\x00\x6f\x00"}, /* s.e. .o. */ \ + {0x00000a78, "\x72\x00\x20\x00\x69\x00\x6d\x00"}, /* r. .i.m. */ \ + {0x00000a80, "\x61\x00\x67\x00\x65\x00\x5f\x00"}, /* a.g.e._. */ \ + {0x00000a88, "\x73\x00\x69\x00\x7a\x00\x65\x00"}, /* s.i.z.e. */ \ + {0x00000a90, "\x0a\x00\x00\x00\x45\x00\x46\x00"}, /* ....E.F. */ \ + {0x00000a98, "\x49\x00\x20\x00\x61\x00\x70\x00"}, /* I. .a.p. */ \ + {0x00000aa0, "\x70\x00\x6c\x00\x69\x00\x63\x00"}, /* p.l.i.c. */ \ + {0x00000aa8, "\x61\x00\x74\x00\x69\x00\x6f\x00"}, /* a.t.i.o. */ \ + {0x00000ab0, "\x6e\x00\x20\x00\x63\x00\x61\x00"}, /* n. .c.a. */ \ + {0x00000ab8, "\x6c\x00\x6c\x00\x69\x00\x6e\x00"}, /* l.l.i.n. */ \ + {0x00000ac0, "\x67\x00\x20\x00\x45\x00\x78\x00"}, /* g. .E.x. */ \ + {0x00000ac8, "\x69\x00\x74\x00\x0a\x00\x00\x00"}, /* i.t..... */ \ + {0x00000ad0, "\x4c\x00\x6f\x00\x61\x00\x64\x00"}, /* L.o.a.d. */ \ + {0x00000ad8, "\x65\x00\x64\x00\x20\x00\x69\x00"}, /* e.d. .i. */ \ + {0x00000ae0, "\x6d\x00\x61\x00\x67\x00\x65\x00"}, /* m.a.g.e. */ \ + {0x00000ae8, "\x20\x00\x70\x00\x72\x00\x6f\x00"}, /* .p.r.o. */ \ + {0x00000af0, "\x74\x00\x6f\x00\x63\x00\x6f\x00"}, /* t.o.c.o. */ \ + {0x00000af8, "\x6c\x00\x20\x00\x6d\x00\x69\x00"}, /* l. .m.i. */ \ + {0x00000b00, "\x73\x00\x73\x00\x69\x00\x6e\x00"}, /* s.s.i.n. */ \ + {0x00000b08, "\x67\x00\x0a\x00\x00\x00\x53\x00"}, /* g.....S. */ \ + {0x00000b10, "\x55\x00\x43\x00\x43\x00\x45\x00"}, /* U.C.C.E. */ \ + {0x00000b18, "\x53\x00\x53\x00\x00\x00\x00\x00"}, /* S.S..... */ \ + {0x00000b20, "\xa1\x31\x1b\x5b\x62\x95\xd2\x11"}, /* .1.[b... */ \ + {0x00000b28, "\x8e\x3f\x00\xa0\xc9\x69\x72\x3b"}, /* .?...ir; */ \ + {0x00000c00, "\x10\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c10, "\x04\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c20, "\xf5\xfe\xff\x6f\x00\x00\x00\x00"}, /* ...o.... */ \ + {0x00000c28, "\x00\x80\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c30, "\x05\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c38, "\x00\x70\x00\x00\x00\x00\x00\x00"}, /* .p...... */ \ + {0x00000c40, "\x06\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c48, "\x00\x60\x00\x00\x00\x00\x00\x00"}, /* .`...... */ \ + {0x00000c50, "\x0a\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c58, "\x13\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c60, "\x0b\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c68, "\x18\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c70, "\x1e\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000c78, "\x02\x00\x00\x00\x00\x00\x00\x00"}, /* ........ */ \ + {0x00000e18, "\x01\x00\x00\x00\x10\x00\x03\x00"}, /* ........ */ \ + {0x00000e20, "\x00\x20\x00\x00\x00\x00\x00\x00"}, /* . ...... */ \ + {0x00000e30, "\x08\x00\x00\x00\x10\x00\x01\x00"}, /* ........ */ \ + {0, NULL} } } diff --git a/lib/efi_selftest/efi_selftest_tcg2.c b/lib/efi_selftest/efi_selftest_tcg2.c index 1399309cec..c5b0b7dd02 100644 --- a/lib/efi_selftest/efi_selftest_tcg2.c +++ b/lib/efi_selftest/efi_selftest_tcg2.c @@ -9,10 +9,604 @@ #include #include +/* + * 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 +#include +#include +#include +#include static struct efi_boot_services *boottime; static const efi_guid_t guid_tcg2 = EFI_TCG2_PROTOCOL_GUID; +/* Block size of compressed disk image */ +#define COMPRESSED_DISK_IMAGE_BLOCK_SIZE 8 + +static efi_handle_t image_handle; +/* Decompressed file image */ +static u8 *image; + +/* One 8 byte block of the compressed disk image */ +struct line { + size_t addr; + char *line; +}; + +/* Compressed file image */ +struct compressed_file_image { + size_t length; + struct line lines[]; +}; + +static struct compressed_file_image img = EFI_ST_DISK_IMG; + +static struct efi_tcg2_event *efi_tcg2_event; + +static struct efi_runtime_services *runtime; +#define BOOT_NAME_1000 u"Boot1000" +#define BOOT_NAME_1001 u"Boot1001" +#define BOOT_NAME_1002 u"Boot1002" + +#define DEFAULT_ATTR (EFI_VARIABLE_NON_VOLATILE | \ + EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS) + +/* "efidebug boot add -b 1000 test1000 virtio 0:1 /EFI/debian/grubaa64.efi" */ +static const u8 boot_1000[] = { +0x01, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, +0x74, 0x00, 0x30, 0x00, 0x00, 0x00, 0x01, 0x04, 0x14, 0x00, 0xb9, 0x73, +0x1d, 0xe6, 0x84, 0xa3, 0xcc, 0x4a, 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3, +0x62, 0x8b, 0x01, 0x04, 0x15, 0x00, 0x92, 0x37, 0x29, 0x63, 0xf5, 0xad, +0x25, 0x93, 0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e, 0x00, 0x04, +0x01, 0x2a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, +0x5a, 0x47, 0xc2, 0x35, 0x27, 0x44, 0x47, 0x9f, 0x01, 0x67, 0xfe, 0xfa, +0x1d, 0x06, 0xae, 0x02, 0x02, 0x04, 0x04, 0x36, 0x00, 0x5c, 0x00, 0x45, +0x00, 0x46, 0x00, 0x49, 0x00, 0x5c, 0x00, 0x64, 0x00, 0x65, 0x00, 0x62, +0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x72, +0x00, 0x75, 0x00, 0x62, 0x00, 0x61, 0x00, 0x61, 0x00, 0x36, 0x00, 0x34, +0x00, 0x2e, 0x00, 0x65, 0x00, 0x66, 0x00, 0x69, 0x00, 0x00, 0x00, 0x7f, +0xff, 0x04, 0x00 }; + +/* "efidebug boot add -b 1001 test1001 virtio 0:1 /EFI/debian/grubaa64.efi" */ +static const u8 boot_1001[] = { +0x01, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, +0x74, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x04, 0x14, 0x00, 0xb9, 0x73, +0x1d, 0xe6, 0x84, 0xa3, 0xcc, 0x4a, 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3, +0x62, 0x8b, 0x01, 0x04, 0x15, 0x00, 0x92, 0x37, 0x29, 0x63, 0xf5, 0xad, +0x25, 0x93, 0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e, 0x00, 0x04, +0x01, 0x2a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, +0x5a, 0x47, 0xc2, 0x35, 0x27, 0x44, 0x47, 0x9f, 0x01, 0x67, 0xfe, 0xfa, +0x1d, 0x06, 0xae, 0x02, 0x02, 0x04, 0x04, 0x36, 0x00, 0x5c, 0x00, 0x45, +0x00, 0x46, 0x00, 0x49, 0x00, 0x5c, 0x00, 0x64, 0x00, 0x65, 0x00, 0x62, +0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x72, +0x00, 0x75, 0x00, 0x62, 0x00, 0x61, 0x00, 0x61, 0x00, 0x36, 0x00, 0x34, +0x00, 0x2e, 0x00, 0x65, 0x00, 0x66, 0x00, 0x69, 0x00, 0x00, 0x00, 0x7f, +0xff, 0x04, 0x00 }; + +/* "efidebug boot add -b 1002 test1002 virtio 0:1 /EFI/debian/grubaa64.efi" */ +static const u8 boot_1002[] = { +0x01, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x74, 0x00, 0x65, 0x00, 0x73, 0x00, +0x74, 0x00, 0x32, 0x00, 0x00, 0x00, 0x01, 0x04, 0x14, 0x00, 0xb9, 0x73, +0x1d, 0xe6, 0x84, 0xa3, 0xcc, 0x4a, 0xae, 0xab, 0x82, 0xe8, 0x28, 0xf3, +0x62, 0x8b, 0x01, 0x04, 0x15, 0x00, 0x92, 0x37, 0x29, 0x63, 0xf5, 0xad, +0x25, 0x93, 0xb9, 0x9f, 0x4e, 0x0e, 0x45, 0x5c, 0x1b, 0x1e, 0x00, 0x04, +0x01, 0x2a, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, +0x5a, 0x47, 0xc2, 0x35, 0x27, 0x44, 0x47, 0x9f, 0x01, 0x67, 0xfe, 0xfa, +0x1d, 0x06, 0xae, 0x02, 0x02, 0x04, 0x04, 0x36, 0x00, 0x5c, 0x00, 0x45, +0x00, 0x46, 0x00, 0x49, 0x00, 0x5c, 0x00, 0x64, 0x00, 0x65, 0x00, 0x62, +0x00, 0x69, 0x00, 0x61, 0x00, 0x6e, 0x00, 0x5c, 0x00, 0x67, 0x00, 0x72, +0x00, 0x75, 0x00, 0x62, 0x00, 0x61, 0x00, 0x61, 0x00, 0x36, 0x00, 0x34, +0x00, 0x2e, 0x00, 0x65, 0x00, 0x66, 0x00, 0x69, 0x00, 0x00, 0x00, 0x7f, +0xff, 0x04, 0x00}; + +/* "efidebug boot order 1002 1000 1001" */ +static u8 boot_order[] = {0x02, 0x10, 0x00, 0x10, 0x01, 0x10}; + +static void *orig_smbios_table; +static u64 dmi_addr = U32_MAX; +#define SMBIOS_ENTRY_HEADER_SIZE 0x20 +/* smbios table for the measurement test */ +static u8 smbios_table_test[] = { +0x5f, 0x53, 0x4d, 0x5f, 0x2c, 0x1f, 0x03, 0x00, 0x54, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x5f, 0x44, 0x4d, 0x49, 0x5f, 0xe4, 0x5c, 0x01, +0x20, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, +0x01, 0x02, 0x00, 0x00, 0x03, 0x00, 0x80, 0x08, 0x01, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x0c, 0x15, 0x0a, 0xff, 0xff, 0x55, 0x2d, 0x42, 0x6f, +0x6f, 0x74, 0x00, 0x32, 0x30, 0x32, 0x31, 0x2e, 0x31, 0x30, 0x2d, 0x72, +0x63, 0x34, 0x2d, 0x30, 0x30, 0x30, 0x30, 0x35, 0x2d, 0x67, 0x37, 0x32, +0x37, 0x63, 0x33, 0x66, 0x33, 0x32, 0x35, 0x39, 0x2d, 0x64, 0x69, 0x72, +0x74, 0x79, 0x00, 0x31, 0x30, 0x2f, 0x30, 0x31, 0x2f, 0x32, 0x30, 0x32, +0x31, 0x00, 0x00, 0x01, 0x1b, 0x01, 0x00, 0x01, 0x02, 0x00, 0x03, 0x31, +0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, +0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x50, 0x72, +0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, +0x37, 0x38, 0x00, 0x00, 0x02, 0x0e, 0x02, 0x00, 0x01, 0x02, 0x00, 0x04, +0x03, 0x01, 0x01, 0x01, 0x00, 0x0a, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, +0x6e, 0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x20, 0x50, 0x72, +0x6f, 0x64, 0x75, 0x63, 0x74, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, +0x33, 0x33, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x00, +0x00, 0x03, 0x15, 0x03, 0x00, 0x01, 0x03, 0x00, 0x02, 0x03, 0x03, 0x03, +0x03, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x6e, +0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, +0x37, 0x38, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0x00, +0x00, 0x04, 0x30, 0x04, 0x00, 0x00, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, +0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x01, 0x06, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x02, 0x03, 0x04, +0x04, 0x04, 0x08, 0x00, 0x00, 0x02, 0x00, 0x08, 0x00, 0x08, 0x00, 0x01, +0x00, 0x55, 0x6e, 0x6b, 0x6e, 0x6f, 0x77, 0x6e, 0x00, 0x31, 0x32, 0x33, +0x34, 0x35, 0x36, 0x37, 0x38, 0x00, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, +0x33, 0x33, 0x00, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x35, 0x00, +0x00, 0x20, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +0x00, 0x00, 0x7f, 0x04, 0x06, 0x00, 0x00, 0x00 +}; + +#define IDX_ARRAY_SZ 3 /* support 24 PCRs */ +#define TPM2_CMD_BUF_SIZE 64 +/* TPM command is big endian */ +#define __MSB(x) ((x) >> 8) +#define __LSB(x) ((x) & 0xFF) +#define tpm_u16(x) __MSB(x), __LSB(x) +#define tpm_u32(x) tpm_u16((x) >> 16), tpm_u16((x) & 0xFFFF) +#define TPM2_PCR_READ_HEADER_SIZE 30 + +static u8 (*pcrs)[TPM2_SHA256_DIGEST_SIZE]; +static u8 expected_pcrs[EFI_TCG2_MAX_PCR_INDEX + 1][TPM2_SHA256_DIGEST_SIZE] = { + {0x91, 0x21, 0x37, 0xc7, 0x1a, 0x49, 0x19, 0xc8, + 0xf1, 0xfb, 0xa9, 0x84, 0x5c, 0x65, 0xa9, 0xdd, + 0x7b, 0xb9, 0xfe, 0xa1, 0xcd, 0x64, 0x49, 0xdd, + 0xed, 0xe2, 0x65, 0x82, 0xc5, 0x3e, 0xf4, 0xc4}, + + {0xf5, 0x79, 0xf3, 0x20, 0x62, 0x6e, 0x8b, 0x58, + 0x62, 0xa3, 0x4e, 0x2f, 0xb7, 0x10, 0xac, 0x34, + 0x4e, 0x68, 0x94, 0x37, 0x87, 0x29, 0xc4, 0xbe, + 0xa3, 0xc4, 0xd9, 0x14, 0x2b, 0x66, 0x79, 0x9b}, + + {0x3d, 0x45, 0x8c, 0xfe, 0x55, 0xcc, 0x03, 0xea, + 0x1f, 0x44, 0x3f, 0x15, 0x62, 0xbe, 0xec, 0x8d, + 0xf5, 0x1c, 0x75, 0xe1, 0x4a, 0x9f, 0xcf, 0x9a, + 0x72, 0x34, 0xa1, 0x3f, 0x19, 0x8e, 0x79, 0x69}, + + {0x3d, 0x45, 0x8c, 0xfe, 0x55, 0xcc, 0x03, 0xea, + 0x1f, 0x44, 0x3f, 0x15, 0x62, 0xbe, 0xec, 0x8d, + 0xf5, 0x1c, 0x75, 0xe1, 0x4a, 0x9f, 0xcf, 0x9a, + 0x72, 0x34, 0xa1, 0x3f, 0x19, 0x8e, 0x79, 0x69}, + + /* PCR[4] is different per architecture */ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x3d, 0x45, 0x8c, 0xfe, 0x55, 0xcc, 0x03, 0xea, + 0x1f, 0x44, 0x3f, 0x15, 0x62, 0xbe, 0xec, 0x8d, + 0xf5, 0x1c, 0x75, 0xe1, 0x4a, 0x9f, 0xcf, 0x9a, + 0x72, 0x34, 0xa1, 0x3f, 0x19, 0x8e, 0x79, 0x69}, + + /* PCR[6] is different per architecture */ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x96, 0x74, 0xae, 0xcd, 0x3f, 0x40, 0xb4, 0xa9, + 0x36, 0xae, 0x19, 0xc8, 0x84, 0x8a, 0xb9, 0x5a, + 0x87, 0x99, 0xd8, 0x89, 0x7f, 0xfc, 0x40, 0x48, + 0x05, 0x99, 0x65, 0x2e, 0x55, 0xd4, 0x93, 0x32}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, + + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + + {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, + + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} +}; + +/* + * PCR[4] and PCR[6] have the PE/COFF image measurement, + * this PCRs have different value in each architecture. + */ +#if defined(__arm__) +static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = { + /* PCR[4] */ + {0xcd, 0xa2, 0x06, 0xad, 0x83, 0x9b, 0x8f, 0x92, + 0x01, 0xf9, 0xc8, 0x3d, 0xc9, 0x54, 0x66, 0xb3, + 0x97, 0x35, 0x88, 0xe1, 0xea, 0xd3, 0x1a, 0xd6, + 0x56, 0xee, 0x43, 0x1c, 0xdb, 0x4b, 0xf9, 0x1f}, + /* PCR[6] */ + {0x9c, 0xb8, 0x9d, 0x4a, 0xf6, 0x63, 0x95, 0xb0, + 0x95, 0xfe, 0x44, 0x30, 0x0f, 0x3a, 0x0b, 0x7c, + 0xef, 0xc7, 0xb6, 0x6a, 0x59, 0xae, 0xcb, 0xf6, + 0xbd, 0x2d, 0xb5, 0xb9, 0xb4, 0x95, 0x7d, 0xaf} +}; +#elif defined(__aarch64__) +static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = { + /* PCR[4] */ + {0x69, 0xdb, 0x01, 0x5e, 0x07, 0xed, 0x9c, 0xbb, + 0x27, 0x65, 0xb1, 0xf0, 0x7b, 0x04, 0xbc, 0x31, + 0xd1, 0xec, 0x00, 0xe4, 0xe1, 0x49, 0xdb, 0x1e, + 0x8b, 0x2d, 0xa2, 0x26, 0xb5, 0x8d, 0x07, 0xe2}, + /* PCR[6] */ + {0x53, 0x1b, 0x27, 0xb2, 0x6f, 0x2d, 0xab, 0x9b, + 0x6f, 0xbc, 0xd1, 0x8f, 0xc9, 0x14, 0x48, 0xe7, + 0x6d, 0x1b, 0xfb, 0x1b, 0x53, 0xc5, 0x8e, 0xf4, + 0x41, 0x50, 0x79, 0x24, 0x66, 0x57, 0x7b, 0xf8} +}; +#elif defined(__i386__) +static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = { + /* PCR[4] */ + {0xec, 0x5e, 0xdb, 0x68, 0x13, 0x48, 0x36, 0x0a, + 0x3a, 0xbc, 0x7b, 0x7b, 0xbc, 0x74, 0x7a, 0xa5, + 0x55, 0xea, 0xb9, 0x09, 0x6a, 0x6e, 0xc3, 0x21, + 0x51, 0x46, 0x22, 0xd2, 0x9d, 0xc9, 0xd5, 0x6a}, + /* PCR[6] */ + {0x26, 0x14, 0xe7, 0xde, 0x91, 0xd1, 0xf3, 0xde, + 0x7a, 0xc2, 0x78, 0xaf, 0x4b, 0x2e, 0x05, 0x9d, + 0x35, 0x17, 0xee, 0xcc, 0x0e, 0x77, 0x8d, 0x3f, + 0x7e, 0x20, 0x75, 0xfa, 0xbc, 0xbc, 0x24, 0x3e} +}; +#elif defined(__x86_64__) +static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = { + /* PCR[4] */ + {0x9a, 0x75, 0x99, 0x8b, 0x74, 0x45, 0xb6, 0x26, + 0x50, 0xe0, 0xbb, 0xfa, 0x2a, 0xa6, 0x19, 0xec, + 0x97, 0x12, 0x0c, 0xb5, 0xc8, 0x2a, 0xfe, 0xe5, + 0x29, 0xc8, 0xd3, 0x98, 0xe9, 0xd1, 0x9d, 0xd5}, + /* PCR[6] */ + {0xa2, 0xa2, 0xd3, 0xa7, 0x84, 0xc2, 0x95, 0x2a, + 0xab, 0x6f, 0xe7, 0xe8, 0x86, 0x9f, 0x99, 0xc6, + 0x6a, 0x8c, 0xcc, 0x5c, 0xb8, 0x83, 0xfa, 0x86, + 0x56, 0x5e, 0x91, 0x17, 0x0b, 0x5f, 0x54, 0xa8} +}; +#elif defined(__riscv) && (__riscv_xlen == 32) +static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = { + /* PCR[4] */ + {0x64, 0xe9, 0x25, 0xb3, 0xd8, 0x33, 0xb3, 0x1b, + 0x74, 0x0c, 0x81, 0x45, 0xef, 0x61, 0xf1, 0x87, + 0xef, 0x65, 0x67, 0x28, 0x1a, 0x54, 0x97, 0xb2, + 0xd3, 0x62, 0x00, 0xe7, 0xb6, 0x7a, 0xd5, 0x8e}, + /* PCR[6] */ + {0x82, 0xab, 0xc5, 0x6a, 0xbf, 0x08, 0x43, 0x3f, + 0x85, 0xbd, 0x8f, 0x8e, 0x23, 0x62, 0x48, 0x4a, + 0x44, 0x53, 0xf0, 0xae, 0x8d, 0x4c, 0xda, 0x04, + 0x89, 0x9c, 0x0b, 0x81, 0x3a, 0x53, 0xf3, 0xac} +}; +#elif defined(__riscv) && (__riscv_xlen == 64) +static u8 expected_pcrs_per_arch[][TPM2_SHA256_DIGEST_SIZE] = { + /* PCR[4] */ + {0x9b, 0x5f, 0x10, 0x24, 0x28, 0x5d, 0x7d, 0x1f, + 0x9f, 0xee, 0xe9, 0x90, 0xf1, 0x7a, 0x03, 0xb1, + 0x68, 0x7b, 0x28, 0x45, 0x98, 0x5e, 0xf5, 0x5e, + 0xc1, 0x22, 0x61, 0x8c, 0x2f, 0xb5, 0xbf, 0x80}, + /* PCR[6] */ + {0x6d, 0x16, 0x17, 0xf4, 0x9a, 0xa8, 0x49, 0xc2, + 0xf4, 0x9c, 0x35, 0x30, 0x0c, 0xde, 0x65, 0xdb, + 0xd3, 0x37, 0x9c, 0xe2, 0x9f, 0x14, 0x81, 0x74, + 0xc3, 0x94, 0x8a, 0x9e, 0x26, 0xbf, 0xfb, 0xb2} +}; +#endif + +struct boot_variable { + u16 name[16]; + u8 *buf; + efi_uintn_t size; + u32 attr; + const u8 *test_data; + efi_uintn_t test_data_size; +}; + +static struct boot_variable boot_variable_test[] = { + {u"BootOrder", NULL, 0, DEFAULT_ATTR, boot_order, sizeof(boot_order)}, + {BOOT_NAME_1000, NULL, 0, DEFAULT_ATTR, boot_1000, sizeof(boot_1000)}, + {BOOT_NAME_1001, NULL, 0, DEFAULT_ATTR, boot_1001, sizeof(boot_1001)}, + {BOOT_NAME_1002, NULL, 0, DEFAULT_ATTR, boot_1002, sizeof(boot_1002)}, +}; + +/* + * efi_status_t decompress() - Decompress the disk image. + * + * @image decompressed disk image + * @return status code + */ +static efi_status_t decompress(u8 **image) +{ + u8 *buf; + size_t i; + size_t addr; + size_t len; + efi_status_t ret; + + ret = boottime->allocate_pool(EFI_LOADER_DATA, img.length, + (void **)&buf); + if (ret != EFI_SUCCESS) { + efi_st_error("Out of memory\n"); + return ret; + } + boottime->set_mem(buf, img.length, 0); + + for (i = 0; ; ++i) { + if (!img.lines[i].line) + break; + addr = img.lines[i].addr; + len = COMPRESSED_DISK_IMAGE_BLOCK_SIZE; + if (addr + len > img.length) + len = img.length - addr; + boottime->copy_mem(buf + addr, img.lines[i].line, len); + } + *image = buf; + return ret; +} + +/* + * efi_status_t setup_boot_variable() - configure dummy boot variables + * + * Preexisting variable values are saved and will be restored by + * calling restore_boot_variable(). + * + * @return status code + */ +static efi_status_t setup_boot_variable(void) +{ + efi_status_t ret; + u32 i; + efi_uintn_t size; + + for (i = 0; i < ARRAY_SIZE(boot_variable_test); i++) { + size = 0; + ret = runtime->get_variable(boot_variable_test[i].name, + &efi_global_variable_guid, + &boot_variable_test[i].attr, + &size, + NULL); + if (ret == EFI_BUFFER_TOO_SMALL) { + /* Variable exists, save the current value */ + boot_variable_test[i].size = size; + ret = boottime->allocate_pool(EFI_LOADER_DATA, + boot_variable_test[i].size, + (void **)&boot_variable_test[i].buf); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to allocate buffer for boot variable\n"); + return ret; + } + ret = runtime->get_variable(boot_variable_test[i].name, + &efi_global_variable_guid, + &boot_variable_test[i].attr, + &boot_variable_test[i].size, + boot_variable_test[i].buf); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to get current boot variable\n"); + return ret; + } + } + + /* set boot variable for the measurement test */ + ret = runtime->set_variable(boot_variable_test[i].name, + &efi_global_variable_guid, + boot_variable_test[i].attr, + boot_variable_test[i].test_data_size, + boot_variable_test[i].test_data); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to set test boot variable(%d)n", i); + return ret; + } + } + + return 0; +} + +/* + * efi_status_t restore_boot_variable() - restore original values + * + * Restore the variable values saved in setup_boot_variable(). + * + * @return status code + */ +static efi_status_t restore_boot_variable(void) +{ + int i; + efi_status_t ret; + + for (i = 0; i < ARRAY_SIZE(boot_variable_test); i++) { + if (boot_variable_test[i].buf) { + ret = runtime->set_variable(boot_variable_test[i].name, + &efi_global_variable_guid, + boot_variable_test[i].attr, + boot_variable_test[i].size, + boot_variable_test[i].buf); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to restore boot variable\n"); + return ret; + } + ret = boottime->free_pool(boot_variable_test[i].buf); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to free boot variable\n"); + return ret; + } + } else { + /* delete the variable used only for testing */ + ret = runtime->set_variable(boot_variable_test[i].name, + &efi_global_variable_guid, + 0, 0, NULL); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to delete boot variable\n"); + return ret; + } + } + } + + return EFI_SUCCESS; +} + +/** + * void *find_smbios_table() - Find smbios table + * + * @systable system table + * @return status code + */ +static void *find_smbios_table(const struct efi_system_table *systable) +{ + u32 i; + + for (i = 0; i < systable->nr_tables; i++) { + if (!guidcmp(&smbios_guid, &systable->tables[i].guid)) + return systable->tables[i].table; + } + + return NULL; +} + +/** + * efi_status_t setup_smbios_table() - Prepare the dummy SMBIOS table + * + * @systable system table + * @return status code + */ +static efi_status_t setup_smbios_table(const struct efi_system_table *systable) +{ + struct smbios_entry *se; + efi_status_t ret; + /* Map within the low 32 bits, to allow for 32bit SMBIOS tables */ + void *dmi; + char *istart; + int isize; + + if (sizeof(smbios_table_test) > EFI_PAGE_SIZE) + return EFI_OUT_OF_RESOURCES; + + orig_smbios_table = find_smbios_table(systable); + + /* Reserve 4kiB page for SMBIOS */ + ret = boottime->allocate_pages(EFI_ALLOCATE_MAX_ADDRESS, + EFI_RUNTIME_SERVICES_DATA, 1, &dmi_addr); + + if (ret != EFI_SUCCESS) { + /* Could not find space in lowmem, use highmem instead */ + ret = boottime->allocate_pages(EFI_ALLOCATE_ANY_PAGES, + EFI_RUNTIME_SERVICES_DATA, 1, + &dmi_addr); + + if (ret != EFI_SUCCESS) + return ret; + } + + dmi = (void *)(uintptr_t)dmi_addr; + se = dmi; + boottime->copy_mem(se, smbios_table_test, sizeof(smbios_table_test)); + + /* update smbios table start address */ + se->struct_table_address = (uintptr_t)((u8 *)dmi + SMBIOS_ENTRY_HEADER_SIZE); + + /* calculate checksums */ + istart = (char *)se + SMBIOS_INTERMEDIATE_OFFSET; + isize = sizeof(struct smbios_entry) - SMBIOS_INTERMEDIATE_OFFSET; + se->intermediate_checksum = table_compute_checksum(istart, isize); + se->checksum = table_compute_checksum(se, sizeof(struct smbios_entry)); + + /* Install SMBIOS information as configuration table */ + ret = boottime->install_configuration_table(&smbios_guid, dmi); + if (ret != EFI_SUCCESS) { + efi_st_error("Cannot install SMBIOS table\n"); + boottime->free_pages(dmi_addr, 1); + } + + return ret; +} + /** * efi_st_tcg2_setup() - setup test * @@ -23,7 +617,193 @@ static const efi_guid_t guid_tcg2 = EFI_TCG2_PROTOCOL_GUID; static int efi_st_tcg2_setup(const efi_handle_t img_handle, const struct efi_system_table *systable) { + efi_status_t ret; + struct uefi_image_load_event image_load_event; + + image_handle = img_handle; boottime = systable->boottime; + runtime = systable->runtime; + + /* Load the application image into memory */ + decompress(&image); + + ret = boottime->allocate_pool(EFI_LOADER_DATA, + sizeof(struct efi_tcg2_event) + + sizeof(struct uefi_image_load_event), + (void **)&efi_tcg2_event); + if (!efi_tcg2_event) + return EFI_ST_FAILURE; + + efi_tcg2_event->size = sizeof(struct efi_tcg2_event) + + sizeof(struct uefi_image_load_event); + efi_tcg2_event->header.header_size = sizeof(struct efi_tcg2_event_header); + efi_tcg2_event->header.header_version = 1; + efi_tcg2_event->header.pcr_index = 6; + efi_tcg2_event->header.event_type = EV_EFI_RUNTIME_SERVICES_DRIVER; + image_load_event.image_location_in_memory = 0x12345678; + image_load_event.image_length_in_memory = 0x300000; + image_load_event.image_link_time_address = 0x87654321; + image_load_event.length_of_device_path = 0; + boottime->copy_mem(efi_tcg2_event->event, &image_load_event, + sizeof(struct uefi_image_load_event)); + + ret = setup_boot_variable(); + if (ret != EFI_SUCCESS) + return EFI_ST_FAILURE; + + ret = setup_smbios_table(systable); + if (ret != EFI_SUCCESS) + return EFI_ST_FAILURE; + + ret = boottime->allocate_pool(EFI_LOADER_DATA, + (EFI_TCG2_MAX_PCR_INDEX + 1) * + TPM2_SHA256_DIGEST_SIZE, + (void **)&pcrs); + if (!pcrs) + return EFI_ST_FAILURE; + + boottime->set_mem(pcrs, (EFI_TCG2_MAX_PCR_INDEX + 1) * TPM2_SHA256_DIGEST_SIZE, 0); + + /* setup expected PCRs per architecture */ + boottime->copy_mem(&expected_pcrs[4], &expected_pcrs_per_arch[0], TPM2_SHA256_DIGEST_SIZE); + boottime->copy_mem(&expected_pcrs[6], &expected_pcrs_per_arch[1], TPM2_SHA256_DIGEST_SIZE); + + return EFI_ST_SUCCESS; +} + +/** + * efi_status_t get_manufacturer_id() - Get manufacturer_id through submit_command API + * + * @tcg2 tcg2 protocol + * @manufacturer_id pointer to the manufacturer_id + * @return status code + */ +static efi_status_t get_manufacturer_id(struct efi_tcg2_protocol *tcg2, u32 *manufacturer_id) +{ + efi_status_t ret; + u8 cmd[TPM2_CMD_BUF_SIZE] = { + tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */ + tpm_u32(22), /* Length */ + tpm_u32(TPM2_CC_GET_CAPABILITY), /* Command code */ + + tpm_u32(TPM2_CAP_TPM_PROPERTIES), /* Capability */ + tpm_u32(TPM2_PT_MANUFACTURER), /* Property */ + tpm_u32(1), /* Property count */ + }; + u8 resp[TPM2_CMD_BUF_SIZE]; + unsigned int value_off; + + ret = tcg2->submit_command(tcg2, 22, cmd, + TPM2_CMD_BUF_SIZE, resp); + if (ret != EFI_SUCCESS) + return ret; + + /* + * In the response buffer, the properties are located after the: + * tag (u16), response size (u32), response code (u32), + * YES/NO flag (u8), TPM_CAP (u32). + * The value is located after count (u32), property (u32). + */ + value_off = sizeof(u16) + sizeof(u32) + sizeof(u32) + + sizeof(u8) + sizeof(u32) + sizeof(u32) + sizeof(u32); + *manufacturer_id = get_unaligned_be32(&resp[value_off]); + + return ret; +} + +/** + * efi_status_t get_manufacturer_id_buffer_small() - call submit_command with small resp buffer + * + * @tcg2 tcg2 protocol + * @manufacturer_id pointer to the manufacturer_id + * @return status code + */ +static efi_status_t get_manufacturer_id_buffer_small(struct efi_tcg2_protocol *tcg2) +{ + efi_status_t ret; + u8 cmd[TPM2_CMD_BUF_SIZE] = { + tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */ + tpm_u32(22), /* Length */ + tpm_u32(TPM2_CC_GET_CAPABILITY), /* Command code */ + + tpm_u32(TPM2_CAP_TPM_PROPERTIES), /* Capability */ + tpm_u32(TPM2_PT_MANUFACTURER), /* Property */ + tpm_u32(1), /* Property count */ + }; + u8 resp[1]; /* set smaller buffer than expected */ + + ret = tcg2->submit_command(tcg2, 22, cmd, 1, resp); + + return ret; +} + +/** + * efi_status_t read_pcr() - Read the PCR from the TPM device + * + * @tcg2 tcg2 protocol + * @idx pcr index to read + * @return status code + */ +static efi_status_t read_pcr(struct efi_tcg2_protocol *tcg2, u32 idx) +{ + efi_status_t ret; + u32 cmd_len = 17 + IDX_ARRAY_SZ; + u8 cmd[TPM2_CMD_BUF_SIZE] = { + tpm_u16(TPM2_ST_NO_SESSIONS), /* TAG */ + tpm_u32(cmd_len), /* Length */ + tpm_u32(TPM2_CC_PCR_READ), /* Command code */ + /* TPML_PCR_SELECTION */ + tpm_u32(1), /* Number of selections */ + tpm_u16(TPM2_ALG_SHA256), /* Algorithm of the hash */ + IDX_ARRAY_SZ, /* Array size for selection */ + /* bitmap(idx), Selected PCR bitmap */ + }; + u8 resp[TPM2_CMD_BUF_SIZE]; + u32 pcr_sel_idx = idx / 8; + u8 pcr_sel_bit = BIT(idx % 8); + + cmd[17 + pcr_sel_idx] = pcr_sel_bit; + ret = tcg2->submit_command(tcg2, cmd_len, cmd, + TPM2_CMD_BUF_SIZE, resp); + if (ret != EFI_SUCCESS) { + efi_st_error("tcg2->submit_command fail to read PCR\n"); + return ret; + } + + boottime->copy_mem(pcrs[idx], &resp[TPM2_PCR_READ_HEADER_SIZE], + TPM2_SHA256_DIGEST_SIZE); + + return ret; +} + +/** + * int validate_pcrs() - Compare the expected and actual pcrs + * + * @return status code + */ +static int validate_pcrs(void) +{ + u32 i; + + /* + * - Skip PCR[0] validation. PCR[0] contains U-Boot version measurement + * it contains the commit hash, so the measurement varies every build + * with different commit hash. + * - Skip PCR[7] validation. PCR[7] contains UEFI Secure Boot variables + * measurement. These variables can not be updated through efi_selftest and + * vary depending on the platform. + * - Skip PCR[17..22] validation, they are not used in TCG PC Client + * Platform Firmware Profile Specification + */ + for (i = 1; i < (EFI_TCG2_MAX_PCR_INDEX + 1); i++) { + if (i == 7 || (i > 16 && i < 23)) + continue; /* skip validation */ + + if (memcmp(pcrs[i], expected_pcrs[i], TPM2_SHA256_DIGEST_SIZE)) { + efi_st_error("PCR[%d] is not the expected value\n", i); + return EFI_ST_FAILURE; + } + } return EFI_ST_SUCCESS; } @@ -31,7 +811,8 @@ static int efi_st_tcg2_setup(const efi_handle_t img_handle, /** * efi_st_tcg2_execute() - execute test * - * Call the GetCapability service of the EFI_TCG2_PROTOCOL. + * Call EFI_TCG2_PROTOCOL services and check the + * Measured Boot behavior. * * Return: status code */ @@ -40,12 +821,22 @@ static int efi_st_tcg2_execute(void) struct efi_tcg2_protocol *tcg2; struct efi_tcg2_boot_service_capability capability; efi_status_t ret; + u32 active_pcr_banks; + u64 eventlog, eventlog_last_entry; + bool eventlog_truncated; + efi_handle_t handle; + efi_uintn_t exit_data_size = 0; + u16 *exit_data = NULL; + u32 i; + u32 manufacturer_id; ret = boottime->locate_protocol(&guid_tcg2, NULL, (void **)&tcg2); if (ret != EFI_SUCCESS) { efi_st_error("TCG2 protocol is not available.\n"); return EFI_ST_FAILURE; } + + /* EFI_TCG2_PROTOCOL.GetCapability test */ capability.size = sizeof(struct efi_tcg2_boot_service_capability) - 1; ret = tcg2->get_capability(tcg2, &capability); if (ret != EFI_BUFFER_TOO_SMALL) { @@ -64,12 +855,161 @@ static int efi_st_tcg2_execute(void) } efi_st_printf("TPM supports 0x%.8x event logs\n", capability.supported_event_logs); + + /* EFI_TCG2_PROTOCOL.GetActivePcrBanks test */ + ret = tcg2->get_active_pcr_banks(tcg2, &active_pcr_banks); + if (ret != EFI_SUCCESS) { + efi_st_error("tcg2->get_active_pcr_banks failed\n"); + return EFI_ST_FAILURE; + } + if (active_pcr_banks != capability.active_pcr_banks) { + efi_st_error("tcg2->get_active_pcr_banks return wrong value\n"); + return EFI_ST_FAILURE; + } + + /* EFI_TCG2_PROTOCOL.HashLogExtendEvent test */ + ret = tcg2->hash_log_extend_event(tcg2, EFI_TCG2_EXTEND_ONLY, + (uintptr_t)image, + img.length, efi_tcg2_event); + if (ret != EFI_SUCCESS) { + efi_st_error("tcg2->hash_log_extend_event(EXTEND_ONLY) failed\n"); + return EFI_ST_FAILURE; + } + + ret = tcg2->hash_log_extend_event(tcg2, PE_COFF_IMAGE, (uintptr_t)image, + img.length, efi_tcg2_event); + if (ret != EFI_SUCCESS) { + efi_st_error("tcg2->hash_log_extend_event(PE_COFF_IMAGE) failed\n"); + return EFI_ST_FAILURE; + } + + /* EFI_TCG2_PROTOCOL.SubmitCommand test */ + ret = get_manufacturer_id_buffer_small(tcg2); + if (ret != EFI_OUT_OF_RESOURCES) { + efi_st_error("get_manufacturer_id buffer too small failed\n"); + return EFI_ST_FAILURE; + } + + ret = get_manufacturer_id(tcg2, &manufacturer_id); + if (ret != EFI_SUCCESS) { + efi_st_error("get_manufacturer_id failed\n"); + return EFI_ST_FAILURE; + } + if (capability.manufacturer_id != manufacturer_id) { + efi_st_error("tcg2->submit_command test failed\n"); + return EFI_ST_FAILURE; + } + + /* tcg2_measure_pe_image test */ + ret = boottime->load_image(false, image_handle, NULL, image, + img.length, &handle); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to load image\n"); + return EFI_ST_FAILURE; + } + + /* measure ready_to_boot event(boot variables, smbios table, etc.) */ + /* TODO: add GPT measurement test */ + ret = boottime->start_image(handle, &exit_data_size, &exit_data); + if (ret != EFI_UNSUPPORTED) { + efi_st_error("Wrong return value from application\n"); + return EFI_ST_FAILURE; + } + ret = boottime->free_pool(exit_data); + if (ret != EFI_SUCCESS) { + efi_st_error("Failed to free exit data\n"); + return EFI_ST_FAILURE; + } + + /* validate PCR read from the TPM device */ + for (i = 0; i < (EFI_TCG2_MAX_PCR_INDEX + 1); i++) { + ret = read_pcr(tcg2, i); + if (ret != EFI_SUCCESS) { + efi_st_error("read pcr error\n"); + return EFI_ST_FAILURE; + } + } + if (validate_pcrs()) { + efi_st_error("PCR validation failed\n"); + return EFI_ST_FAILURE; + } + + /* EFI_TCG2_PROTOCOL.GetEventLog test */ + ret = tcg2->get_eventlog(tcg2, TCG2_EVENT_LOG_FORMAT_TCG_2, &eventlog, + &eventlog_last_entry, &eventlog_truncated); + if (ret != EFI_SUCCESS) { + efi_st_error("tcg2->get_eventlog failed\n"); + return EFI_ST_FAILURE; + } + /* TODO: eventlog format check */ + return EFI_ST_SUCCESS; } +/* + * efi_st_tcg2_teardown() - Tear down unit test + * + * @return: EFI_ST_SUCCESS for success + */ +static int efi_st_tcg2_teardown(void) +{ + efi_status_t r = EFI_ST_SUCCESS; + + if (image) { + r = boottime->free_pool(image); + if (r != EFI_SUCCESS) { + efi_st_error("Failed to free image\n"); + return EFI_ST_FAILURE; + } + } + if (efi_tcg2_event) { + r = boottime->free_pool(efi_tcg2_event); + if (r != EFI_SUCCESS) { + efi_st_error("Failed to free efi_tcg2_event\n"); + return EFI_ST_FAILURE; + } + } + if (pcrs) { + r = boottime->free_pool(pcrs); + if (r != EFI_SUCCESS) { + efi_st_error("Failed to free pcr\n"); + return EFI_ST_FAILURE; + } + } + + r = restore_boot_variable(); + if (r != EFI_SUCCESS) { + efi_st_error("Failed to restore boot variables\n"); + return EFI_ST_FAILURE; + } + + /* + * Restore SMBIOS table + * If orig_smbios_table is NULL, calling install_configuration_table() + * removes dummy SMBIOS table form systab. + */ + r = boottime->install_configuration_table(&smbios_guid, orig_smbios_table); + if (r != EFI_SUCCESS) { + efi_st_error("Failed to restore SMBOIS table\n"); + return EFI_ST_FAILURE; + } + + if (dmi_addr) { + r = boottime->free_pages(dmi_addr, 1); + if (r != EFI_SUCCESS) { + efi_st_error("Failed to free dummy smbios table\n"); + return EFI_ST_FAILURE; + } + } + + return r; +} + EFI_UNIT_TEST(tcg2) = { .name = "tcg2", .phase = EFI_EXECUTE_BEFORE_BOOTTIME_EXIT, .execute = efi_st_tcg2_execute, .setup = efi_st_tcg2_setup, + .teardown = efi_st_tcg2_teardown, + .on_request = true, }; From 34f2577e926da818b95837a742323874ece5245f Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Sat, 14 Aug 2021 21:07:47 +0200 Subject: [PATCH 16/17] ARM: renesas: reduce rcar3_salvator-x image size rcar3_salvator-x u-boot.img is very close to the 0x100000 size limit. Disable support for Unicode capitalization. Signed-off-by: Heinrich Schuchardt --- configs/rcar3_salvator-x_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/configs/rcar3_salvator-x_defconfig b/configs/rcar3_salvator-x_defconfig index c82cee93f2..2b2c273f6a 100644 --- a/configs/rcar3_salvator-x_defconfig +++ b/configs/rcar3_salvator-x_defconfig @@ -96,3 +96,4 @@ CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_GENERIC=y CONFIG_USB_STORAGE=y CONFIG_OF_LIBFDT_OVERLAY=y +# CONFIG_EFI_UNICODE_CAPITALIZATION is not set From f8d7e6e941321e40c4afa39635116ca4144c4f29 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Fri, 5 Mar 2021 18:36:37 +0100 Subject: [PATCH 17/17] dfu: newline after updating Currently output of dfu commands ends on a line with leading hash signs ('#'). The succeeding output should be placed on a new line. After writing updates via dfu print a new line. Signed-off-by: Heinrich Schuchardt Signed-off-by: Heinrich Schuchardt --- drivers/dfu/dfu.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c index ff1859d946..af3975925a 100644 --- a/drivers/dfu/dfu.c +++ b/drivers/dfu/dfu.c @@ -735,6 +735,7 @@ int dfu_write_from_mem_addr(struct dfu_entity *dfu, void *buf, int size) ret = dfu_flush(dfu, NULL, 0, i); if (ret) pr_err("DFU flush failed!"); + puts("\n"); return ret; }