mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Matlack <dmatlack@google.com>
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 <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>,
	 Alex Williamson <alex@shazbot.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	 David Matlack <dmatlack@google.com>,
	Jacob Pan <jacob.pan@linux.microsoft.com>,
	 Jason Gunthorpe <jgg@nvidia.com>,
	Josh Hilke <jrhilke@google.com>, Lukas Wunner <lukas@wunner.de>,
	 Mike Rapoport <rppt@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Parav Pandit <parav@nvidia.com>,
	 Pasha Tatashin <pasha.tatashin@soleen.com>,
	Paul Walmsley <pjw@kernel.org>,
	 Pranjal Shrivastava <praan@google.com>,
	Pratyush Yadav <pratyush@kernel.org>,
	 Samiullah Khawaja <skhawaja@google.com>,
	Shuah Khan <shuah@kernel.org>,  Vipin Sharma <vipinsh@google.com>
Subject: [PATCH 00/18] selftests/liveupdate: Add PCI Live Update selftests
Date: Wed,  2 Dec 2026 00:39:37 +0000	[thread overview]
Message-ID: <20261202003955.3607156-1-dmatlack@google.com> (raw)

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
     <test>.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


             reply	other threads:[~2026-12-02  0:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  0:39 David Matlack [this message]
2026-12-02  0:39 ` [PATCH 01/18] liveupdate: Export symbols needed by modules David Matlack
2026-12-02  0:39 ` [PATCH 02/18] selftests/liveupdate: Exit with KSFT_SKIP when vmtest.sh skips a test David Matlack
2026-12-02  0:39 ` [PATCH 03/18] selftests/liveupdate: Build objects in $(OUTPUT) David Matlack
2026-12-02  0:39 ` [PATCH 04/18] selftests/liveupdate: Support building the kexec tests against nolibc David Matlack
2026-12-02  0:39 ` [PATCH 05/18] selftests/liveupdate: Build vmtest.sh's binaries with the Makefile David Matlack
2026-12-02  0:39 ` [PATCH 06/18] selftests/liveupdate: Support test definitions in vmtest.sh David Matlack
2026-12-02  0:39 ` [PATCH 07/18] selftests/liveupdate: Support kernel modules " David Matlack
2026-12-02  0:39 ` [PATCH 08/18] selftests/liveupdate: Support a different command line for each kernel David Matlack
2026-12-02  0:39 ` [PATCH 09/18] selftests/liveupdate: Run tests in subdirectories from run-vmtests.sh David Matlack
2026-12-02  0:39 ` [PATCH 10/18] selftests/liveupdate: Add a test driver for PCI Live Update David Matlack
2026-12-02  0:39 ` [PATCH 11/18] selftests/liveupdate: pci: Add a test with an endpoint below a root port David Matlack
2026-12-02  0:39 ` [PATCH 12/18] selftests/liveupdate: pci: Check PCI config writes with QEMU tracing David Matlack
2026-12-02  0:39 ` [PATCH 13/18] selftests/liveupdate: pci: Add a test with an endpoint on the root bus David Matlack
2026-12-02  0:39 ` [PATCH 14/18] selftests/liveupdate: pci: Add a test with an endpoint below a switch David Matlack
2026-12-02  0:39 ` [PATCH 15/18] selftests/liveupdate: pci: Test bus numbers with pci=assign-busses David Matlack
2026-12-02  0:39 ` [PATCH 16/18] selftests/liveupdate: pci: Test bus numbers with pci=hpbussize David Matlack
2026-12-02  0:39 ` [PATCH 17/18] selftests/liveupdate: pci: Test ARI Forwarding with pci=noari David Matlack
2026-12-02  0:39 ` [PATCH 18/18] selftests/liveupdate: pci: Test ACS with pci=config_acs David Matlack

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261202003955.3607156-1-dmatlack@google.com \
    --to=dmatlack@google.com \
    --cc=alex@ghiti.fr \
    --cc=alex@shazbot.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=bhelgaas@google.com \
    --cc=jacob.pan@linux.microsoft.com \
    --cc=jgg@nvidia.com \
    --cc=jrhilke@google.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=lukas@wunner.de \
    --cc=palmer@dabbelt.com \
    --cc=parav@nvidia.com \
    --cc=pasha.tatashin@soleen.com \
    --cc=pjw@kernel.org \
    --cc=praan@google.com \
    --cc=pratyush@kernel.org \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=skhawaja@google.com \
    --cc=vipinsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®