From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.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 1D8514C6EF0 for ; Thu, 4 Jun 2026 17:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780593780; cv=none; b=Qyfc0FH0IMcIKyrqpYAQ8yQV1l842lEUT3fDEuk7nFes4+5qHo64wV4+JeudaiIhbvjt2iNKzfPO6zBt6pAYPPWub2PpmJzwDFPtlnJEfpSPH1lv0jtrv13WMCdY6XkNhLXJuj567V1ogww9AB1eWMOrFp/oOiahDs4+BgF6r5U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780593780; c=relaxed/simple; bh=AhQK675Yv/iwPXwqMrmv1Nwu/2jFO4tCsdflTEVyPM8=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=vEd9Otj3mNMQ85YoZ3NcCl/qbcSfBwy8xrWrwdnQD+i8EmcMuGKne9XVlwK2vmR5KN7smhKarY3kEtC3lAyk9BTX1eXBcB3vRBaYnYnP2ADG/PlnwgcNgKoahL/O7abfVfEjdsGoNrrH+xAUClJND7Vt9To9/pKnz/5IB8pcv5Y= 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=rPLQMI5z; arc=none smtp.client-ip=209.85.214.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="rPLQMI5z" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2bf1dece2ecso10071025ad.1 for ; Thu, 04 Jun 2026 10:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780593778; x=1781198578; 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=O64NDjfMzI51Ryen2hmstoyQBHQinBYW+3MlX/bgX8Q=; b=rPLQMI5zDF4BMny1W4G97wV9R0hETyDOjQEmbnQ9eoJvDNAOE5rRfJJu6fFwfE5nP2 ttiLFj6LmaFz8jTnR3/UFXPsQttp2Q+GzfcyJBR1FQAA5Gb0GAbc240na5dV1kr0IY6W 8CdB3+uI963gmxnbuNF3bPfg/KOMfKcq3OtUw8vuNbUbzafTe4iZJjx1uJctssU/DRGu 2KBRMNCwO583d5/dgrke10HS8Q4bnatliawcZH4gFHuiaxN5BC2r5lYFdSLoRZb3qKqn 94trDHXXudYLXBIRIwvYn2T4PjAZ3m495wft4VGDhawEhpKzL1EHgxUzf9e6KHtPm354 uTPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780593778; x=1781198578; 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=O64NDjfMzI51Ryen2hmstoyQBHQinBYW+3MlX/bgX8Q=; b=EEbQDf/APO5NAI9YgvZBT7S4PRvs+o6b/aUqa+QQwDjFf1mYNxf0Qe6ioIGrRLKsJr xAi1ROgD9b8vJ69AQqoKRnvjEHgCeUM2yCNNPILSHMlbPnQq2hXwS49AY/SUseZbDpwX 2/R6cfnErGHYriwi+LJV3CLXRc4HEIt3fHmbuaA0OWH8wjZZyPg3jLdcHzrSfQzCRd6V oC/fB9QnoIpSPC0sjknbyrV+15cMeRHOrFFYUvwt09RY9sOJmx5LkhsFsMiqwj1AEim7 AJZQC4zV8k9rE+QlP/7m0VIVFbNwqNlUHelqp9p1ErZ3KvExvRtWp9IDjqa6jISaYNjv eHKw== X-Forwarded-Encrypted: i=1; AFNElJ9IDqjd+ZabBhjoQJQIABjwP48pmJ0EtS+7Ycayq+qRt7aVx5o9LDa82TnKeyWI86XqTd1c3xqlIAb12sQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yziz5323sWcHDzps8wW7mydDOUGHDT10xzJIzrUdEA3gb9svCRc fPipanj4iLKoXt78J3d81XyKQJh9QetDy3EoSapPjiFW0eFZ/oSL7O4Va7JafBAYjomjrrPCyTY RHQISrw== X-Received: from pgbdo8.prod.google.com ([2002:a05:6a02:e88:b0:c85:82f6:34d4]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:730e:b0:398:b95c:51ed with SMTP id adf61e73a8af0-3b4cd03dd4emr44237637.35.1780593778275; Thu, 04 Jun 2026 10:22:58 -0700 (PDT) Date: Thu, 4 Jun 2026 10:22:57 -0700 In-Reply-To: <20260604020143.748245-15-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> <20260604020143.748245-15-jrhilke@google.com> Message-ID: Subject: Re: [PATCH v5 14/21] KVM: selftests: Verify non-postable IRQ remapping in IRQ test From: Sean Christopherson To: Josh Hilke Cc: Paolo Bonzini , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, David Matlack , Alex Williamson Content-Type: text/plain; charset="us-ascii" On Thu, Jun 04, 2026, Josh Hilke wrote: > From: David Matlack > > Add the -n flag to tools/testing/selftests/kvm/irq_test.c to route a > portion of device interrupts as NMIs (Non-Maskable Interrupts) into the > guest using an alternating pattern of 4 NMIs followed by 4 regular > interrupts. > > While this adds coverage for NMI injection, the primary goal is to > validate KVM's handling of non-postable interrupt delivery. > Specifically, the transitions between posted and remapped modes. NMIs > are used for this purpose because they are a reliable, architectural way > to force these code paths. > > Co-developed-by: Josh Hilke > Signed-off-by: Josh Hilke > Signed-off-by: David Matlack > --- > tools/testing/selftests/kvm/irq_test.c | 44 ++++++++++++++++++++------ > 1 file changed, 35 insertions(+), 9 deletions(-) > > diff --git a/tools/testing/selftests/kvm/irq_test.c b/tools/testing/selftests/kvm/irq_test.c > index de8c29baa2b0..ed48562318bf 100644 > --- a/tools/testing/selftests/kvm/irq_test.c > +++ b/tools/testing/selftests/kvm/irq_test.c > @@ -17,12 +17,15 @@ > static u64 timeout_ns = 2ULL * 1000 * 1000 * 1000; > static bool guest_ready_for_irqs[KVM_MAX_VCPUS]; > static bool guest_received_irq[KVM_MAX_VCPUS]; > +static bool guest_received_nmi[KVM_MAX_VCPUS]; > static bool irq_affinity; > static bool block_vcpus; > static bool done; > > #define GUEST_RECEIVED_IRQ(__vcpu) \ > SYNC_FROM_GUEST_AND_READ((__vcpu)->vm, guest_received_irq[(__vcpu)->id]) > +#define GUEST_RECEIVED_NMI(__vcpu) \ > + SYNC_FROM_GUEST_AND_READ((__vcpu)->vm, guest_received_nmi[(__vcpu)->id]) Add a wrapper macro to simplify/consolidate the core logic: #define GUEST_RECEIVED_INTERRUPT(__vcpu, __nmi) \ ((__nmi) ? GUEST_RECEIVED_NMI(__vcpu) : GUEST_RECEIVED_IRQ(__vcpu))