From patchwork Thu Apr 27 15:44:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 677524 Delivered-To: patch@linaro.org Received: by 2002:a5d:4a41:0:0:0:0:0 with SMTP id v1csp415133wrs; Thu, 27 Apr 2023 08:47:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4W1SLBti5vFSLPwScCdjat6Sv0y19jIcn6WyLT8PQK9njC/Q9qI2MT0FKBeVUjEJ4Y19RZ X-Received: by 2002:ac8:4e85:0:b0:3ea:65d2:2fd1 with SMTP id 5-20020ac84e85000000b003ea65d22fd1mr3310086qtp.3.1682610429362; Thu, 27 Apr 2023 08:47:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682610429; cv=none; d=google.com; s=arc-20160816; b=w0rGzbKbZAoNZXEvio18wWfSE3TcaLyuOBKlvT4BknRn23yEKNYtJGoEt4UZ4ebHZH NpRUIiejxb5pY1g6RCitCmkjiK5bIfS5TzrMDxD6MFPNflWksKM5uhLwiD9dwYwjlApL vrKVkCQOA6VFS83DMkSuMiw3zDKM8vWNx9kxxzMnN5J0KeHhQA/Z09K4F+GTEwQ56Es4 rF9fnC00o64EivGx/pJHio4ZNyQZkFH+wq12Llj+oGraDm7k3Us4WbI4AALinn/31wgP 1RNL2S3r4ADa/ZV6wymrPCrdqfvOCeQ16/lW0W8OviR++ttwxQUq267L9ui1DK7LKyjK ps3g== 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:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=m3zAanYebbZhFO73oDp9ANAxrPZGnhSnFIhjJ3ZsGEU=; b=G/YNdloXJYjs96tBJVP1rz+fznM2a/7fVeyDal55O6cDYctZoGudKMa5AvKcWU2rkv 9ilupKjOqAmdwAWZ0sfrF5t4fEN80ShoRBbWydbi6uZtyDdKytXfMudYpjhGlQfAoDt6 qKgnQVofG5g9RsV2AyG9F20p269PcqjO6qzIF0lsdCLYo7fkAMcXaYOxxm8rDtTfNoMJ 09/0ZYYXedKcg9Q77iZs/cyvfPr7GB3zU4bz06vuLaSpAOqrW8VmLokAbWHUYSjKGGhH dZcGATAFS/uNyARbpiT83oLL6F5jlngu2HIXEcuofNkEe0v9MgFc3hLfQPV8bjh4qPrW FoXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=k25iDfa8; 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=pass (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 b13-20020a05620a0ccd00b0074dead13b81si11419969qkj.397.2023.04.27.08.47.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Apr 2023 08:47:09 -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; dkim=pass header.i=@linaro.org header.s=google header.b=k25iDfa8; 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=pass (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 1ps3oL-0001vu-6s; Thu, 27 Apr 2023 11:45:34 -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 1ps3o6-0001pH-Lo for qemu-devel@nongnu.org; Thu, 27 Apr 2023 11:45:18 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ps3o2-0004j0-Hh for qemu-devel@nongnu.org; Thu, 27 Apr 2023 11:45:17 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-3f19a80a330so41743735e9.2 for ; Thu, 27 Apr 2023 08:45:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1682610313; x=1685202313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m3zAanYebbZhFO73oDp9ANAxrPZGnhSnFIhjJ3ZsGEU=; b=k25iDfa8qX/wTq6JpIISVl6gD01rxrFSoEX1SnovYzC0SUzx36qrPA0yBzpz7V0Vdt LCAtm0nUdFqXu+ljsWtbYqhRAugGfaNV2Cc2xh4wXY/umI91pXLmDniuVDEimCd7BPmI eZz3nh9ZUPEV/9HU/nyJlxtOQb3eRY39sdVqbAhAwyj5ksWZ33AISqOWFdCgawdgCgRo wGp4MHbzewDP3Vkj3TZhpKHhgLi4J4B7ZpMJXZkK7dujfRzjQ58IWfxdMGvOekFW6aIs wY1M0kGpM4l6fHUl/FX4oszzyt3Kz73977/+2gYhGtHTUAQLxC73diuNphBcBXDS/Joc 6jgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682610313; x=1685202313; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m3zAanYebbZhFO73oDp9ANAxrPZGnhSnFIhjJ3ZsGEU=; b=XM7OnL3RzcB+mqfuqCVJKF+z5udbNqksXyPTz/csUzJBTRPOGFV72axYYfynwo+BNS YUjuYIhvda+vWyrPAhrtry+s8i5I0wvUFNsv3vH3tjPej663YUuJw2UVRbLmKqUmVc42 WucU8OPLwxQznxi/NXBoPQlQ9xaXho/zGcf0baE3n/vaTFQ/T9RpFwq2zOYK0IyfUYbl 0Op15o+Pm3Id01iWc6LNXwU+rdXua7nOBbU1qQBY5erV3YLgKEEszXW+fwNHiUPb9/K2 5ty+L5+mg1r3DbS9z6GF27XTxert2hVh04NmMLR9130uBHbF1vOPu06ahEJh9l3oOJII 12Fg== X-Gm-Message-State: AC+VfDzlTCxpAOwSVSV4gxgM6TqxD9RaHdx0k5Hkq5uAzXXUIaOjGEpP BtiXf5TLM2xL99XHVeRR/4b/Cg== X-Received: by 2002:a05:600c:2155:b0:3ef:df3:1693 with SMTP id v21-20020a05600c215500b003ef0df31693mr1697370wml.32.1682610312892; Thu, 27 Apr 2023 08:45:12 -0700 (PDT) Received: from zen.linaroharston ([85.9.250.243]) by smtp.gmail.com with ESMTPSA id t14-20020a05600c450e00b003f0a6a1f969sm25272355wmo.46.2023.04.27.08.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 08:45:11 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 0C35D1FFBB; Thu, 27 Apr 2023 16:45:11 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Marcin Juszkiewicz , Leif Lindholm , =?utf-8?q?Alex_Benn=C3=A9e?= , Radoslaw Biernacki , Peter Maydell , Cleber Rosa , Wainer dos Santos Moschetta , Beraldo Leal , qemu-arm@nongnu.org (open list:SBSA-REF) Subject: [PULL 03/18] tests/avocado: Add set of boot tests on SBSA-ref Date: Thu, 27 Apr 2023 16:44:55 +0100 Message-Id: <20230427154510.1791273-4-alex.bennee@linaro.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230427154510.1791273-1-alex.bennee@linaro.org> References: <20230427154510.1791273-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=alex.bennee@linaro.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: Marcin Juszkiewicz Signed-off-by: Philippe Mathieu-Daudé Message-Id: <20230323082813.971535-1-marcin.juszkiewicz@linaro.org> Reviewed-by: Leif Lindholm Message-Id: <20230328171426.14258-1-philmd@linaro.org> Signed-off-by: Alex Bennée Message-Id: <20230424092249.58552-4-alex.bennee@linaro.org> diff --git a/MAINTAINERS b/MAINTAINERS index a8b942dea4..214124c84c 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -943,6 +943,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..0a79fa7ab6 --- /dev/null +++ b/tests/avocado/machine_aarch64_sbsaref.py @@ -0,0 +1,158 @@ +# 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 import skip +from avocado import skipUnless +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 + """ + + timeout = 180 + + 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" + ) + + iso_hash = "5a36304ecf039292082d92b48152a9ec21009d3a62f459de623e19c4bd9dc027" + iso_path = self.fetch_asset(iso_url, algorithm="sha256", asset_hash=iso_hash) + + 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") + + @skipUnless(os.getenv("AVOCADO_TIMEOUT_EXPECTED"), "Test might timeout") + def test_sbsaref_alpine_linux_cortex_a57(self): + """ + :avocado: tags=cpu:cortex-a57 + """ + self.boot_alpine_linux("cortex-a57") + + @skipUnless(os.getenv("AVOCADO_TIMEOUT_EXPECTED"), "Test might timeout") + def test_sbsaref_alpine_linux_neoverse_n1(self): + """ + :avocado: tags=cpu:max + """ + self.boot_alpine_linux("neoverse-n1") + + @skip("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")