Add support for testing firmware handoff on qemu_arm64, includes: 1. helper_setup hook and clean-up for swtpm; 2. Assembling flash image in flash.fiptool; 3. TF-A/legacy mode switch depends on the coexistence of bl1 and fip.
Signed-off-by: Raymond Mao <[email protected]> --- bin/flash.fiptool | 4 ++++ bin/qemu.swtpm | 7 +++++++ bin/travis-ci/conf.qemu_arm64 | 17 ++++++++++++++--- 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/bin/flash.fiptool b/bin/flash.fiptool index 23014f2..45c644b 100644 --- a/bin/flash.fiptool +++ b/bin/flash.fiptool @@ -20,3 +20,7 @@ # Call fiptool to update an existing fip.bin file fiptool update --nt-fw="${U_BOOT_BUILD_DIR}/u-boot.bin" ${fip} + +# Create a flash image +dd if=${bl1} of=${U_BOOT_BUILD_DIR}/flash.bin bs=4096 conv=notrunc +dd if=${fip} of=${U_BOOT_BUILD_DIR}/flash.bin seek=64 bs=4096 conv=notrunc diff --git a/bin/qemu.swtpm b/bin/qemu.swtpm index c40c537..9cf4f1a 100755 --- a/bin/qemu.swtpm +++ b/bin/qemu.swtpm @@ -18,6 +18,13 @@ # # U-Boot must be built with CONFIG_TPM2_MMIO=y. +set -e + +rm -rf /tmp/tpm mkdir -p /tmp/tpm + +if [ -n "${helper_setup}" ]; then + eval "${helper_setup}" +fi swtpm socket -d -t --tpmstate dir=/tmp/tpm --tpm2 \ --ctrl type=unixio,path=/tmp/tpm/swtpm-sock diff --git a/bin/travis-ci/conf.qemu_arm64 b/bin/travis-ci/conf.qemu_arm64 index bd55ea8..690c2a6 100644 --- a/bin/travis-ci/conf.qemu_arm64 +++ b/bin/travis-ci/conf.qemu_arm64 @@ -20,14 +20,25 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. +set -e + +if [ -n "${fip}" ] && [ -n "${bl1}" ]; then + echo "Both fip and bl1 exist - TF-A mode" + helper_setup="swtpm_setup --tpmstate /tmp/tpm --tpm2 --pcr-banks sha256" + qemu_machine="virt,secure=on" + qemu_kernel_args="-bios ${U_BOOT_BUILD_DIR}/flash.bin" + flash_impl=fiptool +else + qemu_machine="virt" + qemu_kernel_args="-bios ${U_BOOT_BUILD_DIR}/u-boot.bin" + flash_impl=none +fi + console_impl=qemu -qemu_machine="virt" qemu_helper_script="swtpm" qemu_binary="qemu-system-aarch64" qemu_net_args="-netdev user,id=net0,tftp=${UBOOT_TRAVIS_BUILD_DIR} -device e1000,netdev=net0" qemu_host_args="-semihosting-config enable=on,target=native" qemu_tpm_args="-chardev socket,id=chrtpm,path=/tmp/tpm/swtpm-sock -tpmdev emulator,id=tpm0,chardev=chrtpm -device tpm-tis-device,tpmdev=tpm0" qemu_extra_args="-m 4G -cpu cortex-a57 -nographic -device virtio-rng-pci -d unimp ${qemu_host_args} ${qemu_net_args} ${qemu_tpm_args}" -qemu_kernel_args="-bios ${U_BOOT_BUILD_DIR}/u-boot.bin" reset_impl=none -flash_impl=none -- 2.25.1

