From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.167.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796172000; b=3V35X198b1qmcZQE4J/tQV5MpS/jQlN1IPAeDTmL09wBciFYxR3SjS9h6Xe2e92GQEa+ FO+hyeVkhx0+MwIn4xNtCOjLYUSvCLNRgB/yz3xpBnLld4ma3j0fTN61TGnRV6izla1B6 EL3rdonAPbp5igXQ8Y+8AGPew3CeFFrqWPuA4COE8KSaiJOrpAB2vMm4+CXHzdkSLLggr zNHtQb6mRpj488Vu04C243v8Gpi7LdcRDVMy+SYOUsXeECgcwXohBWeOvPqTylkjH+0wT aqVqA5j9Jk7nTeWWoiUovAWPFQ9D1Gsm5DdNmY2980/Chw2sDdb7HcPKVMUtG8n7eHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796172000; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:Mime-Version: X-Mailer:Message-ID:Subject:From:To:Cc:Content-Type; bh=p40IMI+e0IQd793mK6XLEFB/ZUvojA05bSZyhZ5dKCA=; b=sgH1v2hyiT290yKqk9lIqf8vwkMUvz4qXnClZwtx8EX2glBXjpYSm8bDZuNzUo+4J4wH 7GUJB9o6xqVM8NNOSbat2utFrqIFKNWuTdl5FLbvy9WtKILhsKoPSFfMsRnzoQKgyd3LT ZsFbxZOI8cAG8LAf0Gx3CmTuALy2kiF7FsxMsptEZZ2KqjSB4vjHfKqa1p1rlU4K+3sR0 cwW5XX5ggrK2pOyJTMt2WcaoJLzPKvfhjNqWVbmLgKdB00wnQfwdqxk84xxVLYUUQmuOm /4Cs4HliLGuboUlN+W8CP3WT8ATMBF4uchPs/TfJg9ZcLp227HYehOqGLuBiRAapUeg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b="KJX17nR/"; arc=none smtp.remote-ip=209.85.167.200 Received: from mail-oi1-f200.google.com (mail-oi1-f200.google.com [209.85.167.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDE2A606A32E for ; Wed, 2 Dec 2026 00:39:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org EDE2A606A32E Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--dmatlack.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=KJX17nR/ Received: by mail-oi1-f200.google.com with SMTP id 5614622812f47-4b37620eb73so15948223b6e.1 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=vger.kernel.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=KJX17nR/TRkperClYM00BhdU1MVz82Eyn8rvr2ZBsEBtOkJpdYHiPXc22KCne9S+R6 8hDGBIOh/1YVRUTRz+Pl18U4VY4GGLV6Ws+w4DQfG4vD4SLTZfIqnPNHibalpLbP57FB PtpsTaGI4/gk64ecFSPdsMKmXPq7jF0BoZRxqXy+gvmVHM1DF+n7OicvdWsHYtX03B62 2Jgy0IH4+SANwa3DNib7ds2xBKhH5MWT0uDt3xGwVxeQQAJBBwQnmIxsgV55a7MIrXvA NNwlOwsx5BnaOwBJBg6BzBIdNFvymawrrxeWusrI55QBaPd9+Lb4URQP2jcv5SXMxskY I/mg== 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=2dQFx8gWU4CF4xXOSeHm0XaErrwHAqKcYeiUUW2DThlzVVOcu1DhW9Bu7NRQ8b9Kpg /SLq90uaKEZLFs5dtijzNJia3WN+SJBQ8TKqICSNCaisLh61u3YWm0NwnJu4SkIeHcXM DXvcYtBau9M2B6v/lrEHSJWTeEv8xAAzYLRuKSht1K/Hpwf8MtN+oH9ilqTSxS+O5uYs UiFU70MlpgW6Pz1AUs6TZKoHz6JGAqOOrmrLgGYDmWZBo34IzIppligUCSQOI4ygQVrv 11SxHSBs75mRm/l6Bxo9v9nIGsJwp5tr036f05l3SO68nqd7N92lsEnSWJHH2B3vOe7V xbrA== X-Forwarded-Encrypted: i=1; AL+hErHN1QWlAEx7n6J5QKs43WQk0H/QB1tA6Mhz+SkQlLbKWTSqTHSs7k1M2JaIazhugyIrCqjEeI5uhFo=@vger.kernel.org X-Gm-Message-State: APuU4Z/0Uf7mCNHP4H2YbXZGGB9U4Vnn1FrmKzMJO/t3NVjYZ5/ZN/0h 2W7Il0uf/YhHcIDAoxA6sSD4fwtwKaAn7Gle9CW18vENGZseWbZo6BwlXR8sKsakrzDViCxkxm7 jp07L9iLyFP/3Bg== 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-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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" 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