From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EEBF7606A6BD for ; Wed, 2 Dec 2026 00:40:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=oYPylDCP; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=Vu7/nlXm DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:Cc:To:From: Subject:Message-ID:Mime-Version:Date:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Unsubscribe-Post:List-Owner; bh=p40IMI+e0IQd793mK6XLEFB/ZUvojA05bSZyhZ5dKCA=; b=oYPylDCPau5e+OP5iUGO+kx1Mb XVkZTFtIKjO92sryJ+Wx9foFtSTkkM31O2EKyzwch7VDbHiGqUwvyStpG4HSmlH7i8AnpQucr+4g/ ala7S3bOAi1J3Y0+8t5C5l2Cs2OMjQj893aAoheTQt3IHfL6n4AnjUyrfbHplFWNQYbyUD7iw48nt oUnViGZOyXqjWb6FxuVXnsMfcuxfNfcRi773OXUU/CUmRMq3nqz5I2SjzNTpIE+KuCVPfWevl7Et3 oE2MmkrJ6EWzgizR30cdrGdOhZLdC9Y+2C+Z47l22PrgD0S/hvxdJA2NfgOqF7KZgrJnYrSHkMJHy 9vZhDiXg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYYOC-00000009lt3-10ZA; Wed, 02 Dec 2026 00:40:04 +0000 Received: from mail-oi1-x247.google.com ([2607:f8b0:4864:20::247]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYYO8-00000009lqJ-279G for kexec@lists.infradead.org; Wed, 02 Dec 2026 00:40:03 +0000 Received: by mail-oi1-x247.google.com with SMTP id 5614622812f47-4c7f887ac6bso20855270b6e.3 for ; Tue, 01 Dec 2026 16:39:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796171999; x=1796776799; darn=lists.infradead.org; h=content-type:cc:to:from:subject:message-id:mime-version:date:from :to:cc:subject:date:message-id:reply-to:content-type; bh=p40IMI+e0IQd793mK6XLEFB/ZUvojA05bSZyhZ5dKCA=; b=Vu7/nlXmKgkdTjip1WeZKTCkiny8KynPJ3FI5KISQHB9cUwI72v8AKhHjv/igMpqt8 MhVNcwAwjA6RM4ubqwJnmDA05jQudWf4u855DXfo8IOjt/3cML5iOlQf/oAo3WfQrnHe UroLkXNYY2bKTI3eiPd/QDOrRo/Z+JhKViA2J35QsWdaVKbCfVdh0YrSWDb6eNUjZISx WwQtniipRBJIu/UrQ+n+GqfFMMHvge1IdZL3G+gC7DbHOt1XSFoqBd3M8i1+TVCvEd3r C8znL9ChLG+2lQogJncKonra5R3dfHHr77+STVMa8cSOja/zvnwqjoRhp4acgWkv4A+c tYVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796171999; x=1796776799; h=content-type:cc:to:from:subject:message-id:mime-version:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=p40IMI+e0IQd793mK6XLEFB/ZUvojA05bSZyhZ5dKCA=; b=w9H+GIDWUkQb6oj5XpJhDponrckWFVa874nRGrVzDXVSiZ5F1b6hnMTl68c7+ggHmz 9ZQClWY4S4EPlmqOQ+7UmyejpbQDm5zpZDpdfL4xQXLLYg+ljs+MwdAPs9uGZrXUMhsH 2o2dVIQYtcK/fIvp7vECDGd8ACSnTI2NdqWSsNP7aRt/Ts4Fh43V7W8XWM5adV5AZ3vZ +O0pDY959WDs18ZR7FLTSEpWsjpIFIRlrnq2iJQJsz8ClT7Cr52GTrdbm7GOdYKsb7/L rcKTHgo9LWf5yYk/Y403mWqNyIUz23ZXwLfWqXNPUd1BnrHnu8zbaN7ALBzxz1v1U6tp PSsQ== X-Gm-Message-State: APuU4Z+xA+65LEKKzXCaYwdc5C+txH02HwUU16sDB/4z4OVtcu/9LQWZ 3N1M8Xxfbhg19f7bDvPNL5LFvqdHb9xtmYYTjruB3jnRp/D7h3TydXJYh1WqBPp4yEZhBD1e4TP ZW5YISyMNOgYnlThBpVq1lg/CsaAzJ1ruFOxPCKg8dNTyw55CdMrZzu1NGntj6v4+clILlIv1me 5kMkOFA3E1fkHX9bo44I0HVJo8W2MK2Fkz4AOJouMFaJ2QNbQbO8w= X-Received: from jafr8-n1.prod.google.com ([2002:a05:6638:afc8:10b0:620:19a3:e949]) (user=dmatlack job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6808:c1d3:b0:573:1dfa:f0c8 with SMTP id 5614622812f47-57a09503753mr40794566b6e.11.1796171998402; Tue, 01 Dec 2026 16:39:58 -0800 (PST) Date: Wed, 2 Dec 2026 00:39:37 +0000 X-Archived-By: Mime-Version: 1.0 X-Mailer: git-send-email 2.56.1.911.g883d8bcb20-goog Message-ID: <20261202003955.3607156-1-dmatlack@google.com> Subject: [PATCH 00/18] selftests/liveupdate: Add PCI Live Update selftests From: David Matlack To: kexec@lists.infradead.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-pci@vger.kernel.org, linux-riscv@lists.infradead.org Cc: Albert Ou , Alexandre Ghiti , Alex Williamson , Bjorn Helgaas , David Matlack , Jacob Pan , Jason Gunthorpe , Josh Hilke , Lukas Wunner , Mike Rapoport , Palmer Dabbelt , Parav Pandit , Pasha Tatashin , Paul Walmsley , Pranjal Shrivastava , Pratyush Yadav , Samiullah Khawaja , Shuah Khan , Vipin Sharma Content-Type: text/plain; charset="UTF-8" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261201_164000_566165_33FBBE7D X-CRM114-Status: GOOD ( 34.82 ) X-Spam-Score: -9.5 (---------) X-BeenThere: kexec@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "kexec" X-Spam-Status: No, score=-26.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIMWL_WL_MED,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 This series can be found on GitHub: https://github.com/dmatlack/linux/tree/liveupdate/pci/base/selftests/v1 This series adds selftests for the PCI core support for Live Update, which is now in liveupdate.git's next branch [1]. Each test preserves a PCI device across a Live Update in a QEMU VM and checks that the PCI core keeps the device, and every bridge above it, running: same BDF and bus numbers, Bus Master Enable left set, and ARI Forwarding Enable and ACS controls adopted from the previous kernel. The tests run on x86_64 (q35), arm64 (virt) and riscv64 (virt) as part of tools/testing/selftests/liveupdate/run-vmtests.sh. [1] https://git.kernel.org/pub/scm/linux/kernel/git/liveupdate/linux.git/log/?h=next Why PCI-specific tests? ----------------------- The PCI core support for Live Update is also exercised by the VFIO selftests (vfio_pci_liveupdate_uapi_test and vfio_pci_liveupdate_kexec_test). Those tests check that VFIO works across a Live Update. These tests check that the PCI core does, and both are needed. In the short term: - The PCI core support is queued in liveupdate.git ahead of the drivers that use it. These tests let it be tested in-tree, and by anyone reviewing or changing it, without the rest of the VFIO and iommufd Live Update support. - Changes to the PCI core need fast, focused feedback. These tests run on x86_64, arm64 and riscv64 in a few minutes, without any host hardware, IOMMU setup, or VFIO userspace. In the long term: - The guarantees for preserved devices belong to the PCI core, not to any one driver: a preserved device and the bridges above it keep their bus numbers, Bus Master Enable, ARI Forwarding Enable and ACS controls. VFIO is only the first user of the PCI Live Update APIs, and the guarantees must hold for every driver that preserves a device. They should be tested at the layer that provides them, with a driver that does nothing but call those APIs. - Driver tests cannot isolate the PCI core. A failure could be in the driver, iommufd, LUO, or the PCI core, and a pass only shows that the driver did not notice a problem. A driver might even hide one, e.g. by reprogramming the device after it is retrieved. - The cases that matter to the PCI core depend on the topology and on the next kernel's configuration, not on the device: endpoints on the root bus or below root ports and switches, bridges shared with non-preserved devices, and command lines that would renumber buses or change ARI and ACS. Driver tests run on whatever hardware is at hand, whereas these tests build each topology and configuration in QEMU. - Checking the end state is not enough. A device that loses Bus Master Enable or gets reset partway through the Live Update can look fine afterwards, but its DMA was interrupted. Tracing every config write in QEMU catches these transient disruptions. - The PCI core support will grow (e.g. preserving BARs and bridge windows for P2PDMA, and preserving VFs), and changes to enumeration, resource assignment, ACS, ARI, or the shutdown path can break Live Update without touching drivers/pci/liveupdate.c. These tests give PCI developers regression tests to run, and to extend with each new guarantee. Series Overview --------------- 1. Cherry-pick "liveupdate: Export symbols needed by modules" from the VFIO series [2] so that the test-only driver can be built as a module (patch 1). 2. Fix vmtest.sh to report skipped tests to run-vmtests.sh as skipped rather than passed (patch 2). 3. Make the liveupdate selftests Makefile build objects in $(OUTPUT) rather than the source directory, and add a NOLIBC=1 mode that builds the kexec tests and vmtest.sh's init process as static binaries against nolibc. Use it to build vmtest.sh's binaries, so that the Makefile is the only description of how the tests are built (patches 3-5). 4. Extend vmtest.sh so that tests can be described by a .vmtest.sh file, which can set the test binary and its arguments, kernel modules to build and load, extra QEMU arguments, separate command lines for each kernel, and a host-side check to run after the test passes in the VM. Make run-vmtests.sh run every test defined in a subdirectory (patches 6-9). 5. Add a test-only driver, luo_pci_test_driver.ko, that binds to IGB devices and hands out files that can be preserved in a Live Update session. It lives in tools/testing/selftests/liveupdate/modules/ and is built through TEST_GEN_MODS_DIR (patch 10). 6. Add the test binary and the first test, which preserves an IGB endpoint below a root port and binds another (the control) to the test driver without preserving it. Add the Kconfig options that the PCI tests need to the Live Update selftests' config files (patch 11). 7. Trace PCI config writes in QEMU and check that none of them disrupts a preserved device or a bridge above it between the end of stage 1 and the end of stage 2. As a positive control, the trace must show Bus Master Enable getting cleared on the control endpoint during kexec (patch 12). 8. Add tests with an endpoint on the root bus and below a switch, one per patch (patches 13-14). 9. Add tests that boot the next kernel with a configuration that would change preserved devices if the PCI core did not adopt their state, one per patch: pci=assign-busses, pci=hpbussize=16, pci=noari in the first kernel only, and different pci=config_acs= in each kernel. The ARI and ACS tests also check that the bridge above the control endpoint does change, i.e. that the command line takes effect (patches 15-18). [2] https://lore.kernel.org/kvm/20260714151505.3466855-1-vipinsh@google.com/ Building -------- make -C tools/testing/selftests/liveupdate builds the PCI test binary and the test driver along with the other Live Update tests. Like other selftests modules, the test driver is built against the running kernel by default, or against the kernel build directory given with KDIR=. vmtest.sh builds the test binaries with the same Makefile in NOLIBC=1 mode, and builds the test driver against the kernel it boots. Merge Plan ---------- This series applies on top of liveupdate.git's next branch [1], and should be merged through liveupdate.git, matching the agreed-upon tree in the MAINTAINERS entry for PCI LIVE UPDATE. Patch 1 is also part of the VFIO series [2], with a commit message here that doesn't refer to vfio-pci. It can be dropped from whichever series is merged second. Testing ------- All tests pass on x86_64, arm64 and riscv64 with run-vmtests.sh (assign_busses is skipped on arm64 and riscv64, where the generic host bridge driver used by QEMU's virt machine reassigns all bus numbers), along with the existing LUO tests: SUMMARY: PASS=31 SKIP=2 FAIL=0 Each new test was also run on x86_64 and arm64 at the patch that adds it, and every patch builds without warnings with and without NOLIBC=1. To check that the tests detect breakage, they were also run against deliberately broken kernels: - Clearing Bus Master Enable on preserved devices during kexec makes pci/root_port fail on all three architectures, both in the next kernel and in the trace check. - Not preserving bus numbers in the next kernel makes pci/switch fail on arm64 and riscv64, and pci/hpbussize fail on x86_64, both in the next kernel and in the trace check, which shows the root port's bus numbers being reset. Future Work ----------- Please see the PCI core Live Update Roadmap: https://lore.kernel.org/linux-pci/20261001232133.560284-1-dmatlack@google.com/ Possible extensions to these tests include preserving multiple devices, keeping the IGB device performing DMA throughout the Live Update, and checking BARs and bridge windows once they are preserved. David Matlack (17): selftests/liveupdate: Exit with KSFT_SKIP when vmtest.sh skips a test selftests/liveupdate: Build objects in $(OUTPUT) selftests/liveupdate: Support building the kexec tests against nolibc selftests/liveupdate: Build vmtest.sh's binaries with the Makefile selftests/liveupdate: Support test definitions in vmtest.sh selftests/liveupdate: Support kernel modules in vmtest.sh selftests/liveupdate: Support a different command line for each kernel selftests/liveupdate: Run tests in subdirectories from run-vmtests.sh selftests/liveupdate: Add a test driver for PCI Live Update selftests/liveupdate: pci: Add a test with an endpoint below a root port selftests/liveupdate: pci: Check PCI config writes with QEMU tracing selftests/liveupdate: pci: Add a test with an endpoint on the root bus selftests/liveupdate: pci: Add a test with an endpoint below a switch selftests/liveupdate: pci: Test bus numbers with pci=assign-busses selftests/liveupdate: pci: Test bus numbers with pci=hpbussize selftests/liveupdate: pci: Test ARI Forwarding with pci=noari selftests/liveupdate: pci: Test ACS with pci=config_acs Vipin Sharma (1): liveupdate: Export symbols needed by modules MAINTAINERS | 2 + kernel/liveupdate/luo_file.c | 2 + tools/testing/selftests/liveupdate/.gitignore | 4 + tools/testing/selftests/liveupdate/Makefile | 22 +- tools/testing/selftests/liveupdate/config | 4 + .../selftests/liveupdate/config.aarch64 | 1 + .../selftests/liveupdate/config.riscv64 | 1 + tools/testing/selftests/liveupdate/init.c | 86 +- .../selftests/liveupdate/modules/Makefile | 20 + .../liveupdate/modules/luo_pci_test_driver.c | 279 ++++++ .../selftests/liveupdate/pci/acs.vmtest.sh | 14 + .../liveupdate/pci/assign_busses.vmtest.sh | 16 + .../liveupdate/pci/check_cfg_trace.py | 238 ++++++ .../liveupdate/pci/hpbussize.vmtest.sh | 17 + .../selftests/liveupdate/pci/luo_pci_test.c | 794 ++++++++++++++++++ .../liveupdate/pci/luo_pci_test_driver.h | 52 ++ .../selftests/liveupdate/pci/noari.vmtest.sh | 13 + .../liveupdate/pci/pci_vmtest_lib.sh | 115 +++ .../liveupdate/pci/root_bus.vmtest.sh | 13 + .../liveupdate/pci/root_port.vmtest.sh | 7 + .../selftests/liveupdate/pci/switch.vmtest.sh | 8 + .../selftests/liveupdate/run-vmtests.sh | 9 +- tools/testing/selftests/liveupdate/vmtest.sh | 128 ++- 23 files changed, 1803 insertions(+), 42 deletions(-) create mode 100644 tools/testing/selftests/liveupdate/modules/Makefile create mode 100644 tools/testing/selftests/liveupdate/modules/luo_pci_test_driver.c create mode 100644 tools/testing/selftests/liveupdate/pci/acs.vmtest.sh create mode 100644 tools/testing/selftests/liveupdate/pci/assign_busses.vmtest.sh create mode 100755 tools/testing/selftests/liveupdate/pci/check_cfg_trace.py create mode 100644 tools/testing/selftests/liveupdate/pci/hpbussize.vmtest.sh create mode 100644 tools/testing/selftests/liveupdate/pci/luo_pci_test.c create mode 100644 tools/testing/selftests/liveupdate/pci/luo_pci_test_driver.h create mode 100644 tools/testing/selftests/liveupdate/pci/noari.vmtest.sh create mode 100644 tools/testing/selftests/liveupdate/pci/pci_vmtest_lib.sh create mode 100644 tools/testing/selftests/liveupdate/pci/root_bus.vmtest.sh create mode 100644 tools/testing/selftests/liveupdate/pci/root_port.vmtest.sh create mode 100644 tools/testing/selftests/liveupdate/pci/switch.vmtest.sh base-commit: ec459d99ed222228b3d601818fd1e24822a450d6 -- 2.56.1.911.g883d8bcb20-goog