From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f201.google.com (mail-pf1-f201.google.com [209.85.210.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24BE223370F for ; Sat, 13 Jun 2026 00:20:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781310053; cv=none; b=hnEhu4zh88IYTYW/t2p9FYiyFs63pSkNwH/qx1uoIoC5FzwH2ByabGgHDzYk74pxAC/jSSBxTAM9MKGUbsvptXzANvsQUEs7esTr3nyI6E5UIfWMo8ZTu+W50xPqkVWcAamBroQAKPy5EPlBwkT/7DTHOlCVSChqNxb7nsxi75E= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781310053; c=relaxed/simple; bh=M/n+s2ScTJoVUw7uG6hi9PjTyqlDpaI5PqGjdNus3Rg=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=pAE5fuXESXoHuTj+X8bueCsnYkueqIOeQzh/98uwfelaWIyg09HxkrQjZQkNVntCc0KowbehWKhuwysphv2Tu4dWuOCW3cTZ+H9gTq9D7+icPAOLKIO7dfnZuWy002pFKjlyrybHMSO+B10FWcKVOUWQUS1xe16abZ+Fg2pdZoo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=SN2Rs8rT; arc=none smtp.client-ip=209.85.210.201 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--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="SN2Rs8rT" Received: by mail-pf1-f201.google.com with SMTP id d2e1a72fcca58-8428384f31fso1184395b3a.3 for ; Fri, 12 Jun 2026 17:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1781310050; x=1781914850; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=rIJ8Uf8PcJidyyeBqiFcFwTrdNm0vIWb+NN/Ok5zc0s=; b=SN2Rs8rTXwMHDyrUXHNfefJxos7FcpiIZC5wehp1q7Bl+/1mi3GbBBq5QkupY+Jt20 NY7l7l/dypSpJrdP/rxTAQkHwHL4A5ncwaCx1LTiZjzGg6+LYkMde26MmqY9uQFzk7WK Xj+g+Q04R+yqIR+FjUG08xHAuScmVEV3F93ko3itY2ycaukqSxEYuVDt5FKJ7LJd5EdL rx5H26MGe1c/7eG5JKpZ1CoWbbwSeMMsgPhjlhoRb8nMELwt06KKltHUykTZqcHIARyL koHloXyGsNSMspVi82TKwMhm4e42HTKG59ebyMu3uY92F5TsmBB6VPuBeQjmjbgUCNtz ar/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781310050; x=1781914850; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=rIJ8Uf8PcJidyyeBqiFcFwTrdNm0vIWb+NN/Ok5zc0s=; b=VbIDW0TLrKWLj79m+zk67oyIpSUaC3TlcsomhLOjis2/bvSOC47rA/pC47aMHtuYk6 eBVdaRxqTe8QRxSuqdPfJO8+EVTr1MJ547+nxJIDMuFSV5AUnoNUNeAPzUO2ZGzPUFr6 omq5Ba5FpG7zV6rZH5TcWULPgZt8Xz6x2j2jClGvwKmBjIU/FCEAPFh9f5UyCpDRhmeN zZe+8JsYsXW/RfVHAftCYYjBOYK06KrLIpQauR7FZyyPWfRbJPe0FHeaJlFfWPu69m+I g63sNIHsEBAFXtRfkt4U5CadXEbIx75oc0PCil27f1JeeQa8K44eXCxeGWvCz1teCzFS PfNA== X-Forwarded-Encrypted: i=1; AFNElJ9tVETDavr8cyfEB/ZIEX3LWWvYO9igd3NS5hkiN1bFBNVOPEddFu9zheOwu+BgxVHWTfuebX4A8X8VJLM=@vger.kernel.org X-Gm-Message-State: AOJu0Yyz/ku7PL7Wa7dsdFJLRrGRo/nKswz72N24TlfDjjkDSCbsXXQe uwLfHrpyzKQ/9YTVdsZpVBXre5c+YbxGPQu6vN5j7SXqXXNSxa5iuQvHAybkeVh4xsc+fTe5DEA tNlcvMQ== X-Received: from pghm14.prod.google.com ([2002:a63:f60e:0:b0:c79:87d6:650a]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:486:b0:39f:a8fb:3354 with SMTP id adf61e73a8af0-3b783b9cceemr6105295637.17.1781310050361; Fri, 12 Jun 2026 17:20:50 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 12 Jun 2026 17:20:23 -0700 In-Reply-To: <20260613002031.745413-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260613002031.745413-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.1136.gdb2ca164c4-goog Message-ID: <20260613002031.745413-13-seanjc@google.com> Subject: [PATCH v7 12/20] KVM: selftests: Add option to set empty routing between IRQs in eventfd IRQ test From: Sean Christopherson To: Paolo Bonzini , Marc Zyngier , Oliver Upton , Sean Christopherson Cc: Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, linux-kernel@vger.kernel.org, David Matlack , Josh Hilke Content-Type: text/plain; charset="UTF-8" From: David Matlack Extend the eventfd IRQ test with an '-e' flag to set empty GSI routing between interrupts. Clobbering the GSI routing table verifies that KVM correctly handles CPUx => NULL => CPUy transitions, not just CPUx => CPUy transitions, and verifies that KVM can "rebuild" an entire routing setup. Signed-off-by: David Matlack Co-developed-by: Josh Hilke Signed-off-by: Josh Hilke [sean: '-e' for "empty" instead of '-c' for "clear", massage changelog] Signed-off-by: Sean Christopherson --- tools/testing/selftests/kvm/irq_test.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/kvm/irq_test.c b/tools/testing/selftests/kvm/irq_test.c index c01aa313f719..2356912e2272 100644 --- a/tools/testing/selftests/kvm/irq_test.c +++ b/tools/testing/selftests/kvm/irq_test.c @@ -109,6 +109,13 @@ static void kvm_route_msi(struct kvm_vm *vm, u32 gsi, struct kvm_vcpu *vcpu, vm_ioctl(vm, KVM_SET_GSI_ROUTING, &routing.header); } +static void kvm_set_empty_gsi_routing(struct kvm_vm *vm) +{ + struct kvm_irq_routing routing = {}; + + vm_ioctl(vm, KVM_SET_GSI_ROUTING, &routing); +} + static const char *probe_iommu_type(void) { int io_fd; @@ -127,11 +134,12 @@ static const char *probe_iommu_type(void) static void help(const char *name) { - printf("Usage: %s [-a] [-d ] [-h] [-t iommu_type]\n", name); + printf("Usage: %s [-a] [-d ] [-e] [-h] [-t iommu_type]\n", name); printf("\n"); printf("Tests KVM interrupt routing and delivery via irqfd.\n"); printf("-a Affine the device's host IRQ to a random physical CPU\n"); printf("-d Use a VFIO device to send MSI-X interrupts instead of manually signaling the eventfd\n"); + printf("-e Set empty GSI routing in-between some interrupts\n"); printf("-t Override the IOMMU type to use (vfio_type1_iommu or iommufd)\n"); printf("\n"); exit(KSFT_FAIL); @@ -158,6 +166,7 @@ int main(int argc, char **argv) struct kvm_vcpu *vcpus[KVM_MAX_VCPUS]; struct vfio_pci_device *device = NULL; int nr_irqs = 1000, nr_vcpus = 1; + bool set_empty_routing = false; const char *device_bdf = NULL; const char *iommu_type = NULL; int i, j, c, msix, eventfd; @@ -165,7 +174,7 @@ int main(int argc, char **argv) struct kvm_vm *vm; int irq, irq_cpu; - while ((c = getopt(argc, argv, "ad:ht:")) != -1) { + while ((c = getopt(argc, argv, "ad:eht:")) != -1) { switch (c) { case 'a': irq_affinity = true; @@ -173,6 +182,9 @@ int main(int argc, char **argv) case 'd': device_bdf = optarg; break; + case 'e': + set_empty_routing = true; + break; case 't': iommu_type = optarg; break; @@ -223,9 +235,13 @@ int main(int argc, char **argv) irq_cpu = -1; for (i = 0; i < nr_irqs; i++) { + const bool do_set_empty_routing = set_empty_routing && (i & BIT(3)); struct kvm_vcpu *vcpu = vcpus[i % nr_vcpus]; struct timespec start; + if (do_set_empty_routing) + kvm_set_empty_gsi_routing(vm); + kvm_route_msi(vm, gsi, vcpu, vector); if (irq_affinity) { -- 2.54.0.1136.gdb2ca164c4-goog