[PATCH 17/18] selftests/liveupdate: pci: Test ARI Forwarding with pci=noari

From: David Matlack

Date: Tue Dec 01 2026 - 19:41:15 EST


Add a PCI Live Update test that boots the first kernel with pci=noari,
so that it leaves ARI Forwarding disabled on the root ports. IGB
implements ARI, so the next kernel would normally enable ARI Forwarding
on the root ports above the IGB endpoints, but it must leave it alone
on the root port above the preserved endpoint.

Add a -x option to the test so that it can also check that the next
kernel does enable ARI Forwarding on the root port above the control
endpoint, i.e. that pci=noari took effect.

Signed-off-by: David Matlack <dmatlack@xxxxxxxxxx>
---
.../selftests/liveupdate/pci/luo_pci_test.c | 35 ++++++++++++++++++-
.../selftests/liveupdate/pci/noari.vmtest.sh | 13 +++++++
2 files changed, 47 insertions(+), 1 deletion(-)
create mode 100644 tools/testing/selftests/liveupdate/pci/noari.vmtest.sh

diff --git a/tools/testing/selftests/liveupdate/pci/luo_pci_test.c b/tools/testing/selftests/liveupdate/pci/luo_pci_test.c
index 177562d65e64..4ee6f3a5f307 100644
--- a/tools/testing/selftests/liveupdate/pci/luo_pci_test.c
+++ b/tools/testing/selftests/liveupdate/pci/luo_pci_test.c
@@ -10,6 +10,10 @@
* -p <path> Endpoint to preserve.
* -c <path> Optional. Endpoint to bind to the test driver but not
* preserve.
+ * -x <reg>[,...] Optional. Registers that must change across the Live
+ * Update on bridges above the control endpoint (and not
+ * above the preserved endpoint): "ari" for ARI Forwarding
+ * Enable.
* -m <bdf> Optional device whose config space is written to mark the
* phases of the test in a QEMU trace of config writes.
*
@@ -95,6 +99,7 @@ static int nr_before;
static const char *opt_preserve = "";
static const char *opt_control = "";
static const char *opt_marker = "";
+static const char *opt_control_changes = "";

/* strcspn(), which nolibc lacks. */
static size_t span_until(const char *s, const char *reject)
@@ -112,7 +117,7 @@ static int parse_args(int argc, char *argv[])
int stage = 1;
int opt;

- while ((opt = getopt(argc, argv, "s:p:c:m:")) != -1) {
+ while ((opt = getopt(argc, argv, "s:p:c:x:m:")) != -1) {
switch (opt) {
case 's':
stage = atoi(optarg);
@@ -123,6 +128,9 @@ static int parse_args(int argc, char *argv[])
case 'c':
opt_control = optarg;
break;
+ case 'x':
+ opt_control_changes = optarg;
+ break;
case 'm':
opt_marker = optarg;
break;
@@ -480,6 +488,24 @@ static uint16_t get_status(int fd, const char *bdf)

static int nr_failures;

+/* Whether @reg is listed in -x. */
+static bool control_changes(const char *reg)
+{
+ const char *p = opt_control_changes;
+ size_t len;
+
+ while (*p) {
+ len = span_until(p, ",");
+ if (len == strlen(reg) && !strncmp(p, reg, len))
+ return true;
+ p += len;
+ if (*p == ',')
+ p++;
+ }
+
+ return false;
+}
+
#define check(cond, fmt, ...) do { \
if (!(cond)) { \
ksft_print_msg("FAIL: " fmt "\n", ##__VA_ARGS__); \
@@ -520,6 +546,13 @@ static void check_devices(const char *when, const struct pci_snapshot *taken)
check(!(now.command & PCI_COMMAND_MASTER),
"%s: Bus Master still enabled on control device",
dev->bdf);
+ if (dev->bridge && control_changes("ari")) {
+ check(dev->pcie, "%s: Not a PCIe device", dev->bdf);
+ check(!dev->pcie ||
+ ((now.devctl2 ^ dev->devctl2) & PCI_EXP_DEVCTL2_ARI),
+ "%s: ARI Forwarding Enable did not change (DEVCTL2 0x%04x)",
+ dev->bdf, now.devctl2);
+ }
continue;
}

diff --git a/tools/testing/selftests/liveupdate/pci/noari.vmtest.sh b/tools/testing/selftests/liveupdate/pci/noari.vmtest.sh
new file mode 100644
index 000000000000..f72d8add83be
--- /dev/null
+++ b/tools/testing/selftests/liveupdate/pci/noari.vmtest.sh
@@ -0,0 +1,13 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Disable ARI in the first kernel only. IGB implements ARI, so the next kernel
+# enables ARI Forwarding on the root port above the control endpoint, but must
+# adopt it (i.e. leave it disabled) on the root port above the preserved
+# endpoint.
+
+source "$test_dir/pci/pci_vmtest_lib.sh"
+
+pci_topology_root_ports
+
+TEST_ARGS+=(-x ari)
+TEST_CMDLINE_STAGE1="pci=noari"
--
2.56.1.911.g883d8bcb20-goog