From patchwork Thu Mar 23 08:28:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marcin Juszkiewicz X-Patchwork-Id: 666124 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp562461wrt; Thu, 23 Mar 2023 01:29:21 -0700 (PDT) X-Google-Smtp-Source: AK7set+OeI2djxAlB5kJg3cUFSG9yxPGfxIZeC+XQtBKxu844TxaVa9OJHC92uNQGeowKuykerlS X-Received: by 2002:ac8:7f10:0:b0:3d2:52ad:dff3 with SMTP id f16-20020ac87f10000000b003d252addff3mr11584692qtk.17.1679560161319; Thu, 23 Mar 2023 01:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679560161; cv=none; d=google.com; s=arc-20160816; b=uX8akaNJ5qqwdD82XMZr9W55Pd3ky7VXeEtIu7JOkfJrSooa6lyLLoYb6T5HcC6E1W k77sQp7fnhs9+YcwZO1PsaWUhCvZU52+68wE5+xCV366k+BunaLGSkxA4i4eFMEfMI5V zw/aw1FlcC5PKkPX7IFtDpeub5+u6eFV/ScQaEWdDSiuCDAqSVWQ2yZNtPWVFXi1IS1T DCVk0IjFZU2fI8ozhETLsE3ExdMMlHOxLSC4gdAJ7KqBWyH+dUkDdHqfgefnFIKpU63N R/RsbjGVc2XtTcsz2UTCqxIuwDeUpmLebzMDI2nnqKZ9kW3YInX4lp47muP0gY5goX0m vorw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=GfM8XtHBgMHlaSZhPknm9jZEH28WCiQYpUPFLD5iSHc=; b=BEXkkRPFFRPyhwgWqQM9+CDryE0fcjy0SNpwaFuMdfegtwIRTkrIHoUf4KuJXkYPLb fw0noNLUCGR9P2zRyvVwn3nSb9XD7o0Zc7gxVbDeY+UGwPPGrn+XHOmtw3vnfHt1OPzh KznMrj/KusA+bDfS4ktrFKTnvqPj9Qo/qWOB2fZ9bLr0GLythqgfLwdwY2cfPU931Lqr Cyn3jeG0KHBr7wXfAbmzWOXQKR675SME317XjorW4pqdGFRPRGUHPKmKYABfBmNVTUml 8QT+Sr9uKaAwyHIRZP9zfomzWYzBTDVuxVID7TpSHLfTZTrfcPXvtjdeiz0GaCpVIH1C D7zw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id g14-20020ac8580e000000b003e38e8cb7e2si1943219qtg.91.2023.03.23.01.29.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 23 Mar 2023 01:29:21 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pfGJW-0002wQ-DP; Thu, 23 Mar 2023 04:28:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfGJR-0002vb-Cb; Thu, 23 Mar 2023 04:28:47 -0400 Received: from muminek.juszkiewicz.com.pl ([213.251.184.221]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pfGJP-0004db-BG; Thu, 23 Mar 2023 04:28:45 -0400 Received: from localhost (localhost [127.0.0.1]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTP id 16A7B2606B0; Thu, 23 Mar 2023 09:28:40 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at juszkiewicz.com.pl Received: from muminek.juszkiewicz.com.pl ([127.0.0.1]) by localhost (muminek.juszkiewicz.com.pl [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id aKXTmzFDw0vd; Thu, 23 Mar 2023 09:28:37 +0100 (CET) Received: from puchatek.lan (83.11.21.111.ipv4.supernova.orange.pl [83.11.21.111]) by muminek.juszkiewicz.com.pl (Postfix) with ESMTPSA id 02E8426021A; Thu, 23 Mar 2023 09:28:36 +0100 (CET) From: Marcin Juszkiewicz To: Radoslaw Biernacki , Peter Maydell , Leif Lindholm Cc: qemu-arm@nongnu.org, Richard Henderson , qemu-devel@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Shashi Mallela , =?utf-8?q?Alex_Benn=C3=A9e?= , Marcin Juszkiewicz Subject: [PATCH v2] tests/avocado: Add set of boot tests on SBSA-ref Date: Thu, 23 Mar 2023 09:28:14 +0100 Message-Id: <20230323082813.971535-1-marcin.juszkiewicz@linaro.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Received-SPF: softfail client-ip=213.251.184.221; envelope-from=marcin.juszkiewicz@linaro.org; helo=muminek.juszkiewicz.com.pl X-Spam_score_int: -11 X-Spam_score: -1.2 X-Spam_bar: - X-Spam_report: (-1.2 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_SOFTFAIL=0.665 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Philippe Mathieu-Daudé This change adds set of boot tests on SBSA-ref machine: 1. boot firmware up to the EDK2 banner 2. boot Alpine Linux Prebuilt flash volumes are included, built using upstream documentation. To unify tests for AArch64/virt and AArch64/sbsa-ref we boot the same Alpine Linux image on both. Signed-off-by: Philippe Mathieu-Daudé Signed-off-by: Marcin Juszkiewicz --- MAINTAINERS | 1 + tests/avocado/machine_aarch64_sbsaref.py | 138 +++++++++++++++++++++++ 2 files changed, 139 insertions(+) create mode 100644 tests/avocado/machine_aarch64_sbsaref.py diff --git a/MAINTAINERS b/MAINTAINERS index 9b56ccdd92..4797c30ac8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -928,6 +928,7 @@ L: qemu-arm@nongnu.org S: Maintained F: hw/arm/sbsa-ref.c F: docs/system/arm/sbsa.rst +F: tests/avocado/machine_aarch64_sbsaref.py Sharp SL-5500 (Collie) PDA M: Peter Maydell diff --git a/tests/avocado/machine_aarch64_sbsaref.py b/tests/avocado/machine_aarch64_sbsaref.py new file mode 100644 index 0000000000..52e6991e03 --- /dev/null +++ b/tests/avocado/machine_aarch64_sbsaref.py @@ -0,0 +1,138 @@ +# Functional test that boots a Linux kernel and checks the console +# +# SPDX-FileCopyrightText: 2023 Linaro Ltd. +# SPDX-FileContributor: Philippe Mathieu-Daudé +# SPDX-FileContributor: Marcin Juszkiewicz +# +# SPDX-License-Identifier: GPL-2.0-or-later + +import os + +from avocado.utils import archive + +from avocado_qemu import QemuSystemTest +from avocado_qemu import wait_for_console_pattern +from avocado_qemu import interrupt_interactive_console_until_pattern + + +class Aarch64SbsarefMachine(QemuSystemTest): + """ + :avocado: tags=arch:aarch64 + :avocado: tags=machine:sbsa-ref + """ + + def fetch_firmware(self): + """ + Flash volumes generated using: + + - Fedora GNU Toolchain version 12.2.1 20220819 (Red Hat Cross 12.2.1-2) + + - Trusted Firmware-A + https://github.com/ARM-software/arm-trusted-firmware/tree/5fdb2e54 + + - Tianocore EDK II + https://github.com/tianocore/edk2/tree/494127613b + https://github.com/tianocore/edk2-non-osi/tree/41876073 + https://github.com/tianocore/edk2-platforms/tree/8efa4f42 + """ + + # Secure BootRom (TF-A code) + fs0_xz_url = ('https://fileserver.linaro.org/s/ATnSmq6k8SoXgbH/' + 'download/SBSA_FLASH0.fd.xz') + fs0_xz_hash = 'a210a09692bcbe0a3743ffd0df44e80e0c7ad8ab' + tar_xz_path = self.fetch_asset(fs0_xz_url, asset_hash=fs0_xz_hash) + archive.extract(tar_xz_path, self.workdir) + fs0_path = os.path.join(self.workdir, 'SBSA_FLASH0.fd') + + # Non-secure rom (UEFI and EFI variables) + fs1_xz_url = ('https://fileserver.linaro.org/s/t8foNnMPz74DZZy/' + 'download/SBSA_FLASH1.fd.xz') + fs1_xz_hash = '13a9a262953787c7fc5a9155dfaa26e703631e02' + tar_xz_path = self.fetch_asset(fs1_xz_url, asset_hash=fs1_xz_hash) + archive.extract(tar_xz_path, self.workdir) + fs1_path = os.path.join(self.workdir, 'SBSA_FLASH1.fd') + + for path in [fs0_path, fs1_path]: + with open(path, 'ab+') as fd: + fd.truncate(256 << 20) # Expand volumes to 256MiB + + self.vm.set_console() + self.vm.add_args('-drive', f'if=pflash,file={fs0_path},format=raw', + '-drive', f'if=pflash,file={fs1_path},format=raw', + "-smp", "1", + "-machine", "sbsa-ref") + + def test_sbsaref_edk2_firmware(self): + """ + :avocado: tags=cpu:cortex-a57 + """ + + self.fetch_firmware() + self.vm.launch() + + # TF-A boot sequence: + # + # https://github.com/ARM-software/arm-trusted-firmware/blob/v2.8.0/\ + # docs/design/trusted-board-boot.rst#trusted-board-boot-sequence + # https://trustedfirmware-a.readthedocs.io/en/v2.8/\ + # design/firmware-design.html#cold-boot + + # AP Trusted ROM + wait_for_console_pattern(self, 'Booting Trusted Firmware') + wait_for_console_pattern(self, 'BL1: v2.8(release):v2.8') + wait_for_console_pattern(self, 'BL1: Booting BL2') + + # Trusted Boot Firmware + wait_for_console_pattern(self, 'BL2: v2.8(release)') + wait_for_console_pattern(self, 'Booting BL31') + + # EL3 Runtime Software + wait_for_console_pattern(self, 'BL31: v2.8(release)') + + # Non-trusted Firmware + wait_for_console_pattern(self, 'UEFI firmware (version 1.0') + interrupt_interactive_console_until_pattern(self, + 'QEMU SBSA-REF Machine') + + # This tests the whole boot chain from EFI to Userspace + # We only boot a whole OS for the current top level CPU and GIC + # Other test profiles should use more minimal boots + def boot_alpine_linux(self, cpu): + self.fetch_firmware() + + iso_url = ('https://dl-cdn.alpinelinux.org/' + 'alpine/v3.17/releases/aarch64/' + 'alpine-standard-3.17.2-aarch64.iso') + + # Alpine use sha256 so I recalculated this myself + iso_sha1 = '76284fcd7b41fe899b0c2375ceb8470803eea839' + iso_path = self.fetch_asset(iso_url, asset_hash=iso_sha1) + + self.vm.set_console() + self.vm.add_args("-cpu", cpu, + "-drive", f"file={iso_path},format=raw", + '-device', 'virtio-rng-pci,rng=rng0', + '-object', 'rng-random,id=rng0,filename=/dev/urandom') + + self.vm.launch() + wait_for_console_pattern(self, 'Welcome to Alpine Linux 3.17') + + def test_sbsaref_alpine_linux_cortex_a57(self): + """ + :avocado: tags=cpu:cortex-a57 + """ + self.boot_alpine_linux('cortex-a57') + + def test_sbsaref_alpine_linux_neoverse_n1(self): + """ + :avocado: tags=cpu:max + """ + self.boot_alpine_linux('neoverse-n1') + +# This test requires TF-A update to handle FEAT_FGT +# +# def test_sbsaref_alpine_linux_max(self): +# """ +# :avocado: tags=cpu:max +# """ +# self.boot_alpine_linux('max,pauth-impdef=on')