add x86 acceptance test for the "host" cpu bug
cover add x86 acceptance test for the "host" cpu bug
This is a new acceptance test that verifies the ability to boot the OVMF "sec" binaries, that were previously broken by the i386 refactoring, due to improper ordering of x86_64 cpu initialization and realization.
Claudio Fontana (2):
tests/acceptance: move pkg extraction to avocado_qemu/ tests/acceptance: add OVMF firmware test to cover x86_64 "host" cpu bug
tests/acceptance/avocado_qemu/__init__.py | 38 ++++++++ tests/acceptance/boot_linux_console.py | 104 +++++++--------------- tests/acceptance/boot_ovmf_fc33.py | 75 ++++++++++++++++ tests/acceptance/boot_xen.py | 7 +- tests/acceptance/replay_kernel.py | 23 ++--- tests/acceptance/tcg_plugins.py | 5 +- 6 files changed, 166 insertions(+), 86 deletions(-) create mode 100644 tests/acceptance/boot_ovmf_fc33.py
Signature · 1 line
2.26.2
PATCH 1/2 tests/acceptance: move pkg extraction to avocado_qemu/
currently these utility functions are present only in boot_linux_console.py, but they are useful in general, not just for linux.
In order to reuse them for a firmware test with OVMF, make these functions general utility functions inside avocado_qemu/ , from where we will punctually import them.
--- tests/acceptance/avocado_qemu/__init__.py | 38 ++++++++ tests/acceptance/boot_linux_console.py | 104 +++++++--------------- tests/acceptance/boot_xen.py | 7 +- tests/acceptance/replay_kernel.py | 23 ++--- tests/acceptance/tcg_plugins.py | 5 +- 5 files changed, 91 insertions(+), 86 deletions(-)
tests/acceptance/avocado_qemu/__init__.py +38 -0
@@ -21,6 +21,7 @@ from avocado.utils import datadrainer from avocado.utils import network from avocado.utils import vmimage +from avocado.utils import process from avocado.utils.path import find_command
@@ -140,6 +141,43 @@ def wait_for_console_pattern(test, success_message, failure_message=None, """ _console_interaction(test, success_message, failure_message, None, vm=vm) +def extract_from_deb(test, deb, path): + """ + Extracts a file from a deb package into the test workdir + + :param deb: path to the deb archive + :param path: path within the deb archive of the file to be extracted + :returns: path of the extracted file + """ + cwd = os.getcwd() + os.chdir(test.workdir) + file_path = process.run("ar t %s" % deb).stdout_text.split()[2] + process.run("ar x %s %s" % (deb, file_path)) + archive.extract(file_path, test.workdir) + os.chdir(cwd) + # Return complete path to extracted file. Because callers to + # extract_from_deb() specify 'path' with a leading slash, it is + # necessary to use os.path.relpath() as otherwise os.path.join() + # interprets it as an absolute path and drops the test.workdir part. + return os.path.normpath(os.path.join(test.workdir, + os.path.relpath(path, '/'))) + +def extract_from_rpm(test, rpm, path): + """ + Extracts a file from an RPM package into the test workdir. + + :param rpm: path to the rpm archive + :param path: path within the rpm archive of the file to be extracted + needs to be a relative path (starting with './') because + cpio(1), which is used to extract the file, expects that. + :returns: path of the extracted file + """ + cwd = os.getcwd() + os.chdir(test.workdir) + process.run("rpm2cpio %s | cpio -id %s" % (rpm, path), shell=True) + os.chdir(cwd) + return os.path.normpath(os.path.join(test.workdir, path)) + def exec_command(test, command): """ Send a command to a console (appending CRLF characters), while logging
tests/acceptance/boot_linux_console.py +34 -70
206 lines not on this page · raw message
tests/acceptance/boot_xen.py +4 -3
@@ -15,6 +15,7 @@ from avocado import skipIf from avocado_qemu import wait_for_console_pattern +from avocado_qemu import extract_from_deb from boot_linux_console import LinuxKernelTest
@@ -78,7 +79,7 @@ def test_arm64_xen_411_and_dom0(self): 'xen-hypervisor-4.11-arm64_4.11.4%2B37-g3263f257ca-1_arm64.deb') xen_sha1 = '034e634d4416adbad1212d59b62bccdcda63e62a' xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1) - xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.11-arm64") + xen_path = extract_from_deb(xen_deb, "/boot/xen-4.11-arm64") self.launch_xen(xen_path)
@@ -96,7 +97,7 @@ def test_arm64_xen_414_and_dom0(self): 'xen-hypervisor-4.14-arm64_4.14.0%2B80-gd101b417b7-1_arm64.deb') xen_sha1 = 'b9d209dd689ed2b393e625303a225badefec1160' xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1) - xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.14-arm64") + xen_path = extract_from_deb(xen_deb, "/boot/xen-4.14-arm64") self.launch_xen(xen_path)
@@ -113,6 +114,6 @@ def test_arm64_xen_415_and_dom0(self): '?path=%2F&files=xen-upstream-4.15-unstable.deb') xen_sha1 = 'fc191172b85cf355abb95d275a24cc0f6d6579d8' xen_deb = self.fetch_asset(xen_url, asset_hash=xen_sha1) - xen_path = self.extract_from_deb(xen_deb, "/boot/xen-4.15-unstable") + xen_path = extract_from_deb(xen_deb, "/boot/xen-4.15-unstable") self.launch_xen(xen_path)
tests/acceptance/replay_kernel.py +12 -11
@@ -18,6 +18,7 @@ from avocado import skipIf from avocado import skipUnless from avocado_qemu import wait_for_console_pattern +from avocado_qemu import extract_from_deb from avocado.utils import archive from avocado.utils import process from boot_linux_console import LinuxKernelTest
@@ -106,8 +107,8 @@ def test_mips_malta(self): 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb') deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) - kernel_path = self.extract_from_deb(deb_path, - '/boot/vmlinux-2.6.32-5-4kc-malta') + kernel_path = extract_from_deb(deb_path, + '/boot/vmlinux-2.6.32-5-4kc-malta') kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' console_pattern = 'Kernel command line: %s' % kernel_command_line
@@ -134,8 +135,8 @@ def test_mips64el_malta(self): 'linux-image-2.6.32-5-5kc-malta_2.6.32-48_mipsel.deb') deb_hash = '1aaec92083bf22fda31e0d27fa8d9a388e5fc3d5' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) - kernel_path = self.extract_from_deb(deb_path, - '/boot/vmlinux-2.6.32-5-5kc-malta') + kernel_path = extract_from_deb(deb_path, + '/boot/vmlinux-2.6.32-5-5kc-malta') kernel_command_line = self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0' console_pattern = 'Kernel command line: %s' % kernel_command_line self.run_rr(kernel_path, kernel_command_line, console_pattern, shift=5)
@@ -186,10 +187,10 @@ def test_arm_cubieboard_initrd(self): 'linux-5.10.16-sunxi/linux-image-current-sunxi_21.02.2_armhf.deb') deb_hash = '9fa84beda245cabf0b4fa84cf6eaa7738ead1da0' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) - kernel_path = self.extract_from_deb(deb_path, - '/boot/vmlinuz-5.10.16-sunxi') + kernel_path = extract_from_deb(deb_path, + '/boot/vmlinuz-5.10.16-sunxi') dtb_path = '/usr/lib/linux-image-current-sunxi/sun4i-a10-cubieboard.dtb' - dtb_path = self.extract_from_deb(deb_path, dtb_path) + dtb_path = extract_from_deb(deb_path, dtb_path) initrd_url = ('https://github.com/groeck/linux-build-test/raw/' '2eb0a73b5d5a28df3170c546ddaaa9757e1e0848/rootfs/' 'arm/rootfs-armv5.cpio.gz')
@@ -234,8 +235,8 @@ def test_m68k_q800(self): '/l/linux/kernel-image-5.3.0-1-m68k-di_5.3.7-1_m68k.udeb') deb_hash = '044954bb9be4160a3ce81f8bc1b5e856b75cccd1' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) - kernel_path = self.extract_from_deb(deb_path, - '/boot/vmlinux-5.3.0-1-m68k') + kernel_path = extract_from_deb(deb_path, + '/boot/vmlinux-5.3.0-1-m68k') kernel_command_line = (self.KERNEL_COMMON_COMMAND_LINE + 'console=ttyS0 vga=off')
@@ -370,8 +371,8 @@ def test_mips_malta_cpio(self): 'linux-image-4.5.0-2-4kc-malta_4.5.5-1_mips.deb') deb_hash = 'a3c84f3e88b54e06107d65a410d1d1e8e0f340f8' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) - kernel_path = self.extract_from_deb(deb_path, - '/boot/vmlinux-4.5.0-2-4kc-malta') + kernel_path = extract_from_deb(deb_path, + '/boot/vmlinux-4.5.0-2-4kc-malta') initrd_url = ('https://github.com/groeck/linux-build-test/raw/' '8584a59ed9e5eb5ee7ca91f6d74bbb06619205b8/rootfs/' 'mips/rootfs.cpio.gz')
tests/acceptance/tcg_plugins.py +3 -2
@@ -14,6 +14,7 @@ import re from boot_linux_console import LinuxKernelTest +from avocado_qemu import extract_from_deb class PluginKernelBase(LinuxKernelTest):
@@ -59,8 +60,8 @@ def _grab_aarch64_kernel(self): 'linux-image-4.19.0-12-arm64_4.19.152-1_arm64.deb') kernel_sha1 = '2036c2792f80ac9c4ccaae742b2e0a28385b6010' kernel_deb = self.fetch_asset(kernel_url, asset_hash=kernel_sha1) - kernel_path = self.extract_from_deb(kernel_deb, - "/boot/vmlinuz-4.19.0-12-arm64") + kernel_path = extract_from_deb(kernel_deb, + "/boot/vmlinuz-4.19.0-12-arm64") return kernel_path def test_aarch64_virt_insn(self):
Signature · 1 line
2.26.2
Re: [PATCH v1 1/2] tests/acceptance: move pkg extraction to avocado_qemu/
Quoted 21 lines · Claudio Fontana
currently these utility functions are present only in
boot_linux_console.py, but they are useful in general, not just for linux.In order to reuse them for a firmware test with OVMF, make these functions general utility functions inside avocado_qemu/ , from where we will punctually import them.
Signed-off-by Claudio Fontana <[email protected]>--- tests/acceptance/avocado_qemu/__init__.py | 38 ++++++++ tests/acceptance/boot_linux_console.py | 104 +++++++--------------- tests/acceptance/boot_xen.py | 7 +- tests/acceptance/replay_kernel.py | 23 ++--- tests/acceptance/tcg_plugins.py | 5 +- 5 files changed, 91 insertions(+), 86 deletions(-)tests/acceptance/avocado_qemu/__init__.py +0
-0
tests/acceptance/avocado_qemu/__init__.py line 24
Quoted 4 lines
tests/acceptance/avocado_qemu/__init__.py +1
-0@@ -21,6 +21,7 @@ from avocado.utils import datadrainer from avocado.utils import network from avocado.utils import vmimage +from avocado.utils import process
It's also missing:
from avocado.utils import archive
Because it's used...
Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +3
-0from avocado.utils.path import find_command@@ -140,6 +141,43 @@ def wait_for_console_pattern(test, success_message, failure_message=None, """ _console_interaction(test, success_message, failure_message, None, vm=vm) +def extract_from_deb(test, deb, path): + """ + Extracts a file from a deb package into the test workdir
tests/acceptance/avocado_qemu/__init__.py def wait_for_console_pattern(test, success_message, failure_message=None, · line 156
Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +10
-0+ + :param deb: path to the deb archive + :param path: path within the deb archive of the file to be extracted + :returns: path of the extracted file + """ + cwd = os.getcwd() + os.chdir(test.workdir) + file_path = process.run("ar t %s" % deb).stdout_text.split()[2] + process.run("ar x %s %s" % (deb, file_path)) + archive.extract(file_path, test.workdir)
... here.
Also there are some missing changes for other tests using extract_from_(deb|rpm), such as:
tests/acceptance/boot_linux_console.py +1 -1
@@ -92,7 +92,7 @@ def test_mips_malta(self): 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb') deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) - kernel_path = extract_from_deb(deb_path, + kernel_path = extract_from_deb(self, deb_path, '/boot/vmlinux-2.6.32-5-4kc-malta') self.vm.set_console()
I've seen the same or similar problems for other tests:
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_malta: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips64el_malta: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips64el_fuloong2e: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_malta_cpio: ERROR: extract_from_deb() missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd:
ERROR: 'BootLinuxConsole' object has no attribute 'extract_from_deb'
(0.03 s)
Having said that, since Avocado 89.0[1] there is a new API[2] that should be able to handle both deb and rpm extractions.
I'll try to post a suggestion based on that API here... unless you beat me to it. :)
Thanks,
- Cleber.
[1] - https://avocado-framework.readthedocs.io/en/89.0/releases/89_0.html#utility-apis
[2] - https://avocado-framework.readthedocs.io/en/89.0/api/utils/avocado.utils.software_manager.html#avocado.utils.software_manager.SoftwareManager.extract_from_package
Re: [PATCH v1 1/2] tests/acceptance: move pkg extraction to avocado_qemu/
Quoted 86 lines · Cleber Rosa
Quoted 21 lines · Claudio Fontana
currently these utility functions are present only in
boot_linux_console.py, but they are useful in general, not just for linux.In order to reuse them for a firmware test with OVMF, make these functions general utility functions inside avocado_qemu/ , from where we will punctually import them.
Signed-off-by Claudio Fontana <[email protected]>--- tests/acceptance/avocado_qemu/__init__.py | 38 ++++++++ tests/acceptance/boot_linux_console.py | 104 +++++++--------------- tests/acceptance/boot_xen.py | 7 +- tests/acceptance/replay_kernel.py | 23 ++--- tests/acceptance/tcg_plugins.py | 5 +- 5 files changed, 91 insertions(+), 86 deletions(-)tests/acceptance/avocado_qemu/__init__.py +0
-0tests/acceptance/avocado_qemu/__init__.py line 24
Quoted 4 lines
tests/acceptance/avocado_qemu/__init__.py +1
-0@@ -21,6 +21,7 @@ from avocado.utils import datadrainer from avocado.utils import network from avocado.utils import vmimage +from avocado.utils import processIt's also missing:
from avocado.utils import archive
Because it's used...
Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +3
-0from avocado.utils.path import find_command@@ -140,6 +141,43 @@ def wait_for_console_pattern(test, success_message, failure_message=None, """ _console_interaction(test, success_message, failure_message, None, vm=vm) +def extract_from_deb(test, deb, path): + """ + Extracts a file from a deb package into the test workdirtests/acceptance/avocado_qemu/__init__.py def wait_for_console_pattern(test, success_message, failure_message=None, · line 156
Quoted 10 lines
tests/acceptance/avocado_qemu/__init__.py +10
-0+ + :param deb: path to the deb archive + :param path: path within the deb archive of the file to be extracted + :returns: path of the extracted file + """ + cwd = os.getcwd() + os.chdir(test.workdir) + file_path = process.run("ar t %s" % deb).stdout_text.split()[2] + process.run("ar x %s %s" % (deb, file_path)) + archive.extract(file_path, test.workdir)... here.
Also there are some missing changes for other tests using
extract_from_(deb|rpm), such as:tests/acceptance/boot_linux_console.py +1
-1@@ -92,7 +92,7 @@ def test_mips_malta(self): 'linux-image-2.6.32-5-4kc-malta_2.6.32-48_mips.deb') deb_hash = 'a8cfc28ad8f45f54811fc6cf74fc43ffcfe0ba04' deb_path = self.fetch_asset(deb_url, asset_hash=deb_hash) - kernel_path = extract_from_deb(deb_path, + kernel_path = extract_from_deb(self, deb_path, '/boot/vmlinux-2.6.32-5-4kc-malta') self.vm.set_console()I've seen the same or similar problems for other tests:
tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_malta: ERROR:
extract_from_deb()missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips64el_malta: ERROR:extract_from_deb()missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips64el_fuloong2e: ERROR:extract_from_deb()missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_mips_malta_cpio: ERROR:extract_from_deb()missing 1 required positional argument: 'path' (0.03 s) tests/acceptance/boot_linux_console.py:BootLinuxConsole.test_arm_raspi2_initrd:
ERROR: 'BootLinuxConsole' object has no attribute 'extract_from_deb'
(0.03 s)
Quoted 5 lines
Having said that, since Avocado 89.0[1] there is a new API[2] that should be able to handle both deb and rpm extractions.
I'll try to post a suggestion based on that API here... unless you beat me to it. :)
Go ahead, I am very unlikely to be able to beat you to it :-)
Ciao,
Claudio
PATCH 2/2 tests/acceptance: add OVMF firmware test to cover x86_64 "host" cpu bug
In reply to Claudio Fontanarecent refactoring of i386 broke OVMF firmware with a wrong initialization order for host cpu. This test covers this issue for potential regressions.
For the actual fixes, see:
commit ("i386: run accel_cpu_instance_init as post_init"), commit ("i386: reorder call to cpu_exec_realizefn"),
--- tests/acceptance/boot_ovmf_fc33.py | 75 ++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/acceptance/boot_ovmf_fc33.py
tests/acceptance/boot_ovmf_fc33.py new file +75 -0
@@ -0,0 +1,75 @@ +# Functional test that boots OVMF firmware with cpu host. +# +# This test was added to capture x86 "host" cpu initialization and realization +# ordering problems. +# +# Copyright (c) 2021 SUSE LLC +# +# Author: +# Claudio Fontana <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import os +import time + +from avocado_qemu import Test +from avocado_qemu import extract_from_rpm +from avocado_qemu import wait_for_console_pattern +from avocado.utils import process +from avocado.utils.path import find_command, CmdNotFoundError + +class FirmwareTest(Test): + def wait_for_firmware_message(self, success_message): + wait_for_console_pattern(self, success_message, failure_message=None) + +class BootOVMF(FirmwareTest): + """ + Boots OVMF secureboot and checks for a specific message. + If we do not see the message, it's an ERROR that we express via a timeout. + """ + timeout = 10 + + def test_cpu_host_x86(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:q35 + :avocado: tags=cpu:host + :avocado: tags=accel:kvm + """ + self.require_accelerator("kvm") + + rpm_url = ('https://download-ib01.fedoraproject.org/' + 'pub/fedora/linux/updates/33/Everything/x86_64/Packages/e/' + 'edk2-ovmf-20200801stable-3.fc33.noarch.rpm') + rpm_hash = '45e1001313dc2deed9b41a532ef090682a11ccd1' + rpm_path = self.fetch_asset(rpm_url, asset_hash=rpm_hash) + + # Note the use of "./" at the beginning of the paths in the rpm, + # it is not an accident, see extract_from_rpm in avocado_qemu/ + + ovmf_code_sec = extract_from_rpm(self, rpm_path, + './usr/share/edk2/ovmf/OVMF_CODE.secboot.fd') + ovmf_vars_sec = extract_from_rpm(self, rpm_path, + './usr/share/edk2/ovmf/OVMF_VARS.secboot.fd') + + # at this point the ovmf code should be reachable in the tmp dir; we + # can use this sleep to debug issues with the extraction above. + #time.sleep(3600) + + self.vm.set_console() + self.vm.add_args( + '-accel', 'kvm', + '-cpu', 'host', + '-machine', 'q35,smm=on', + '-m', '4G', + '-drive', + 'if=pflash,format=raw,readonly=on,unit=0,file=' + ovmf_code_sec, + '-drive', + 'if=pflash,format=raw,unit=1,file=' + ovmf_vars_sec, + '-display', 'none', + '-serial', 'stdio') + self.vm.launch() + console_pattern = 'BdsDxe: failed to load Boot0001' + self.wait_for_firmware_message(success_message=console_pattern);
Signature · 1 line
2.26.2
Re: [PATCH v1 2/2] tests/acceptance: add OVMF firmware test to cover x86_64 "host" cpu bug
Quoted 11 lines · Claudio Fontana
recent refactoring of i386 broke OVMF firmware with a wrong initialization order for host cpu. This test covers this issue for potential regressions.
For the actual fixes, see:
commit ("i386: runaccel_cpu_instance_initaspost_init"), commit ("i386: reorder call tocpu_exec_realizefn"),Cc Eduardo Habkost <[email protected]>Cc Vitaly Kuznetsov <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Claudio Fontana <[email protected]>
I think basic OVMF boot regression testing is still welcome, but would we be able to detect this specific bug more quickly and easily by just looking at the VCPU CPUID data?
We could use the proposed query-kvm-cpuid command for that:
https://lore.kernel.org/qemu-devel/[email protected]
Quoted 89 lines
--- tests/acceptance/boot_ovmf_fc33.py | 75 ++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/acceptance/boot_ovmf_fc33.pytests/acceptance/boot_ovmf_fc33.py new file +75
-0@@ -0,0 +1,75 @@ +# Functional test that boots OVMF firmware with cpu host. +# +# This test was added to capture x86 "host" cpu initialization and realization +# ordering problems. +# +# Copyright (c) 2021 SUSE LLC +# +# Author: +# Claudio Fontana <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import os +import time + +from avocado_qemu import Test +from avocado_qemu import extract_from_rpm +from avocado_qemu import wait_for_console_pattern +from avocado.utils import process +from avocado.utils.path import find_command, CmdNotFoundError + +class FirmwareTest(Test): + def wait_for_firmware_message(self, success_message): + wait_for_console_pattern(self, success_message, failure_message=None) + +class BootOVMF(FirmwareTest): + """ + Boots OVMF secureboot and checks for a specific message. + If we do not see the message, it's an ERROR that we express via a timeout. + """ + timeout = 10 + + def test_cpu_host_x86(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:q35 + :avocado: tags=cpu:host + :avocado: tags=accel:kvm + """ + self.require_accelerator("kvm") + + rpm_url = ('https://download-ib01.fedoraproject.org/' + 'pub/fedora/linux/updates/33/Everything/x86_64/Packages/e/' + 'edk2-ovmf-20200801stable-3.fc33.noarch.rpm') + rpm_hash = '45e1001313dc2deed9b41a532ef090682a11ccd1' + rpm_path = self.fetch_asset(rpm_url, asset_hash=rpm_hash) + + # Note the use of "./" at the beginning of the paths in the rpm, + # it is not an accident, see extract_from_rpm in avocado_qemu/ + + ovmf_code_sec = extract_from_rpm(self, rpm_path, + './usr/share/edk2/ovmf/OVMF_CODE.secboot.fd') + ovmf_vars_sec = extract_from_rpm(self, rpm_path, + './usr/share/edk2/ovmf/OVMF_VARS.secboot.fd') + + # at this point the ovmf code should be reachable in the tmp dir; we + # can use this sleep to debug issues with the extraction above. + #time.sleep(3600) + + self.vm.set_console() + self.vm.add_args( + '-accel', 'kvm', + '-cpu', 'host', + '-machine', 'q35,smm=on', + '-m', '4G', + '-drive', + 'if=pflash,format=raw,readonly=on,unit=0,file=' + ovmf_code_sec, + '-drive', + 'if=pflash,format=raw,unit=1,file=' + ovmf_vars_sec, + '-display', 'none', + '-serial', 'stdio') + self.vm.launch() + console_pattern = 'BdsDxe: failed to load Boot0001' + self.wait_for_firmware_message(success_message=console_pattern);Signature · 1 line
2.26.2
Signature · 1 line
Eduardo
Re: [PATCH v1 2/2] tests/acceptance: add OVMF firmware test to cover x86_64 "host" cpu bug
Quoted 8 lines · Eduardo Habkost
Quoted 7 lines · Claudio Fontana
recent refactoring of i386 broke OVMF firmware with a wrong initialization order for host cpu. This test covers this issue for potential regressions.
For the actual fixes, see:
commit ("i386: runaccel_cpu_instance_initaspost_init"), commit ("i386: reorder call tocpu_exec_realizefn"),
Quoted 8 lines
Quoted 4 lines
Cc Eduardo Habkost <[email protected]>Cc Vitaly Kuznetsov <[email protected]>Cc Paolo Bonzini <[email protected]>Signed-off-by Claudio Fontana <[email protected]>I think basic OVMF boot regression testing is still welcome, but would we be able to detect this specific bug more quickly and easily by just looking at the VCPU CPUID data?
The current proposal to get the cpuid as seen by the guest would detect the wrong order of features expansion for sure, but I am not sure about the other issues.
Should we add this basic OVMF boot regression testing still? I would say it is simple and useful.
Thanks,
Claudio
Quoted 95 lines
We could use the proposed query-kvm-cpuid command for that:
https://lore.kernel.org/qemu-devel/[email protected]Quoted 89 lines
--- tests/acceptance/boot_ovmf_fc33.py | 75 ++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 tests/acceptance/boot_ovmf_fc33.pytests/acceptance/boot_ovmf_fc33.py new file +75
-0@@ -0,0 +1,75 @@ +# Functional test that boots OVMF firmware with cpu host. +# +# This test was added to capture x86 "host" cpu initialization and realization +# ordering problems. +# +# Copyright (c) 2021 SUSE LLC +# +# Author: +# Claudio Fontana <[email protected]> +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +import os +import time + +from avocado_qemu import Test +from avocado_qemu import extract_from_rpm +from avocado_qemu import wait_for_console_pattern +from avocado.utils import process +from avocado.utils.path import find_command, CmdNotFoundError + +class FirmwareTest(Test): + def wait_for_firmware_message(self, success_message): + wait_for_console_pattern(self, success_message, failure_message=None) + +class BootOVMF(FirmwareTest): + """ + Boots OVMF secureboot and checks for a specific message. + If we do not see the message, it's an ERROR that we express via a timeout. + """ + timeout = 10 + + def test_cpu_host_x86(self): + """ + :avocado: tags=arch:x86_64 + :avocado: tags=machine:q35 + :avocado: tags=cpu:host + :avocado: tags=accel:kvm + """ + self.require_accelerator("kvm") + + rpm_url = ('https://download-ib01.fedoraproject.org/' + 'pub/fedora/linux/updates/33/Everything/x86_64/Packages/e/' + 'edk2-ovmf-20200801stable-3.fc33.noarch.rpm') + rpm_hash = '45e1001313dc2deed9b41a532ef090682a11ccd1' + rpm_path = self.fetch_asset(rpm_url, asset_hash=rpm_hash) + + # Note the use of "./" at the beginning of the paths in the rpm, + # it is not an accident, see extract_from_rpm in avocado_qemu/ + + ovmf_code_sec = extract_from_rpm(self, rpm_path, + './usr/share/edk2/ovmf/OVMF_CODE.secboot.fd') + ovmf_vars_sec = extract_from_rpm(self, rpm_path, + './usr/share/edk2/ovmf/OVMF_VARS.secboot.fd') + + # at this point the ovmf code should be reachable in the tmp dir; we + # can use this sleep to debug issues with the extraction above. + #time.sleep(3600) + + self.vm.set_console() + self.vm.add_args( + '-accel', 'kvm', + '-cpu', 'host', + '-machine', 'q35,smm=on', + '-m', '4G', + '-drive', + 'if=pflash,format=raw,readonly=on,unit=0,file=' + ovmf_code_sec, + '-drive', + 'if=pflash,format=raw,unit=1,file=' + ovmf_vars_sec, + '-display', 'none', + '-serial', 'stdio') + self.vm.launch() + console_pattern = 'BdsDxe: failed to load Boot0001' + self.wait_for_firmware_message(success_message=console_pattern);Signature · 1 line
2.26.2