From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f202.google.com (mail-pf1-f202.google.com [209.85.210.202]) (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 4B54830E828 for ; Thu, 4 Jun 2026 02:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.202 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780538564; cv=none; b=JB6Oe7DZzKC/N0VbJezm3wbp39D8Po0aAa0uF19M/tLxTH261SBKqsgOcHUBs3tq7f8TLpz097ileG+y5ykeMJBSBGMstwmVRF6exxjZgbCmNRyVMdwYbtyljMSXyZ3Mr+9gbeSi7egVbqqQl+KutKZgH2+xvAvyV7W84vjMaoY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780538564; c=relaxed/simple; bh=6pY+TjgfgssKaHsPAOt61oAMqoFK8eMNXVXJ63J4T+A=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=gV2mipIFneS1kzBIXFPvCzji8KNAfOF1AptEWogtNsexXjfCW4/XCmf0aR0aBeIJF8umZqavvYoL2M8y9JnOgWiEfqHbzr9WI84jInfzDCPaGTn9x9bAiij9NhRAmW4DmoE8spAS6fSub9KMGGwMHfmzXjBWxL1Q0muVeKKSs4U= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--jrhilke.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=L+kq6P/u; arc=none smtp.client-ip=209.85.210.202 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--jrhilke.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="L+kq6P/u" Received: by mail-pf1-f202.google.com with SMTP id d2e1a72fcca58-8422f987f2eso300444b3a.3 for ; Wed, 03 Jun 2026 19:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780538561; x=1781143361; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=sb3P0p4SrvcVWMWS5X9HlHDW6xjjIovVXgKDqrW/UJ8=; b=L+kq6P/ul9t3/T1vEFDF1tC1db1NknDpmANfE5sEOENDrKMVC5tCp1ax2yhkk4H63T Mo9zOAnQ9EE5ZXfQ6flPRKoYKgj33brZy6R1GazM0wWttepp7CcI0UY0KamitexCi/Tp XbId1VUpEOb2ArJlQJlAuFLWCqm8zAAcUA329rZxqQCXNRCTL2YA7j/QGlRc6uUYuBx2 yZPHw2BcqeOX/M9YDP2bGPCixsNGZJhNOgap7hin5aYaLt2rfTcar3KVnYMjTanJgPTL kqxHmSnqdIfLNpu/3nJL0pPblrMLXDfYGV7VJUlJIOZwpzaiTy69RqnFoU/p2ycmgKtc rnPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780538561; x=1781143361; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=sb3P0p4SrvcVWMWS5X9HlHDW6xjjIovVXgKDqrW/UJ8=; b=VBEmeRIXXFjr+X/zfX9V4pUgSXk1RWMCjYxunnvkVmy7ZUva/e1uiWISxpIjhdPAWL 1d9LNitj+dLUTa5ZqbZDwF4Fr22oOPN2+IZw9w2KQaleBiQPa/7G1rA51F+nWTuDJia4 YjV4E90YHW9FFza1yV7E+nb6IhQf7cVNhunjGnK95liGVMWK7CKrOHl29MsvvHwkCe+w n87IIOrb9Qid8tzlEzbEg4rGZfRuKeo0dSgdykG0lNzKBk2wb21KrwNR3GEFusGMphV4 EnHbN1OH9RF4drNGCm3/833LpzFbbpza8ojvTXLABRY9p0c6QPH2/Y6SDkDlBGlCpbXa VPRA== X-Forwarded-Encrypted: i=1; AFNElJ/fzsCySNWiecgxm4pVxvdM8lY/4vCl/nErK/OSZTrkwYQGxGAthRgIVbKN7FVd9LRDxd7vc4xfVahPpvY=@vger.kernel.org X-Gm-Message-State: AOJu0YzH7aXCUzuWs1ItoPQOL/rrFJpjoRvDeJthS22RKJY/AWaHVRUn dE3z/cOj25pBuSh4Cw3ByZ+pmYwX6TXBchTC9nDHGzYWtTb9sJ2SoBfbqKUBJr/4u7EN5xInKY5 Bop4diyTC X-Received: from pfaz8.prod.google.com ([2002:aa7:91c8:0:b0:842:4d1f:7750]) (user=jrhilke job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a00:3288:b0:839:44c5:c321 with SMTP id d2e1a72fcca58-84284f128e3mr5571143b3a.44.1780538561215; Wed, 03 Jun 2026 19:02:41 -0700 (PDT) Date: Thu, 4 Jun 2026 02:01:34 +0000 In-Reply-To: <20260604020143.748245-1-jrhilke@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260604020143.748245-1-jrhilke@google.com> X-Mailer: git-send-email 2.54.0.1032.g2f8565e1d1-goog Message-ID: <20260604020143.748245-13-jrhilke@google.com> Subject: [PATCH v5 12/21] KVM: selftests: Verify interrupts are received after modifying IRQ routes in IRQ test From: Josh Hilke To: Paolo Bonzini , Sean Christopherson Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Alex Williamson , Josh Hilke Content-Type: text/plain; charset="UTF-8" From: David Matlack Add the '-c' flag to tools/testing/selftests/kvm/irq_test.c to destroy and recreate KVM's GSI routing table between interrupts. This ensures that KVM correctly handles dynamic updates to the interrupt routing table while interrupts are actively being signaled by assigned devices. Co-developed-by: Josh Hilke Signed-off-by: Josh Hilke Signed-off-by: David Matlack --- 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 671338f0e612..b0c4547a7f14 100644 --- a/tools/testing/selftests/kvm/irq_test.c +++ b/tools/testing/selftests/kvm/irq_test.c @@ -114,13 +114,21 @@ static void kvm_route_msi(struct kvm_vm *vm, u32 gsi, struct kvm_vcpu *vcpu, vm_ioctl(vm, KVM_SET_GSI_ROUTING, routes); } +static void kvm_clear_gsi_routes(struct kvm_vm *vm) +{ + struct kvm_irq_routing routes = {}; + + vm_ioctl(vm, KVM_SET_GSI_ROUTING, &routes); +} + static void help(const char *name) { - printf("Usage: %s [-a] [-b] [-d ] [-h]\n", name); + printf("Usage: %s [-a] [-b] [-c] [-d ] [-h]\n", name); printf("\n"); printf("Tests KVM IRQ injection via irqfd using an emulated eventfd.\n"); printf("-a Randomly affinitize the device's host IRQ to different physical CPUs throughout the test\n"); printf("-b Block vCPUs (e.g. HLT) instead of spinning in guest-mode\n"); + printf("-c Destroy and recreate KVM's GSI routing table in between some interrupts\n"); printf("-d Use a VFIO device to send MSI-X interrupts instead of using an emulated eventfd\n"); printf("\n"); exit(KSFT_FAIL); @@ -150,12 +158,13 @@ int main(int argc, char **argv) const char *device_bdf = NULL; FILE *irq_affinity_fp = NULL; int i, j, c, msix, eventfd; + bool clear_routes = false; struct iommu *iommu; struct kvm_vm *vm; unsigned int irq; int irq_cpu; - while ((c = getopt(argc, argv, "abd:h")) != -1) { + while ((c = getopt(argc, argv, "abcd:h")) != -1) { switch (c) { case 'a': irq_affinity = true; @@ -166,6 +175,9 @@ int main(int argc, char **argv) case 'd': device_bdf = optarg; break; + case 'c': + clear_routes = true; + break; case 'h': default: help(argv[0]); @@ -217,9 +229,13 @@ int main(int argc, char **argv) irq_cpu = -1; for (i = 0; i < nr_irqs; i++) { + const bool do_clear_routes = clear_routes && (i & BIT(3)); struct kvm_vcpu *vcpu = vcpus[i % nr_vcpus]; struct timespec start; + if (do_clear_routes) + kvm_clear_gsi_routes(vm); + kvm_route_msi(vm, gsi, vcpu, vector); if (irq_affinity_fp) { -- 2.54.0.1032.g2f8565e1d1-goog