From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (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 D361032B108 for ; Fri, 24 Jul 2026 17:34:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.197 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784914471; cv=none; b=nIdjzz11xbF3ZrYGC+RGTO7ratab0ZduPS2HFudNEEi+zFFE/umYKdIsqk68Shd74LH5hOlRLDetXGiI29Z/lA9mNTEtarWVA3Ama1oxY1guaZFNfCACtOFQC4K1VV5LhbAS6zqSIO4hQzUPWmt5EayaqSdoffq1zUUcq0bRvJQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784914471; c=relaxed/simple; bh=rLkMc5AOpVKMTLuxHjDhFbknUJV0WEQRy7oPL6tNQKE=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=eLLT+Z8DGIzrtoJsMxZ/016qCsay/G+m09UCIXqt6XB+IZE344XwWj/5gprtiDcFlnHlddxqZJD6AlW2c3tMFIOOdgabH1eTZPOnGcncfOI9e8HggZPgORN8KWd/V/sFLILh0dH4aMs5zt0HP91WfXK77dE7yH0zQeckT77YPJU= 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=Crk8PD5a; arc=none smtp.client-ip=209.85.214.197 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="Crk8PD5a" Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2cce870a060so11424275ad.2 for ; Fri, 24 Jul 2026 10:34:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1784914469; x=1785519269; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:reply-to:from:to:cc:subject:date:message-id :reply-to:content-type; bh=o72EGRo2pvQ3WbX6SzXXg6Q1ixoc9GAPCSAe802AzLg=; b=Crk8PD5auDoxf/+KWPpYZUIrMltPh9A5H+eeFhbaRG79SympiQC2ho13OsX9xLNZ6i /hCtmfEyMjZcO/bWRqjHAhSJU2XXdt9dD4pg3V0CAnPnqQ6hIW8FMO+gL7UvLz+7pqnl QjsGzWgWktYljz2wup/tC7os0K9Pqf5Hnd59lJwrnT4Kl17WWiwD8b3Wp8rrnj/8ylGz S4T7KSLlC88zG7vZlgLdbYRJSj0yTIHTdodL9Nlgv3+AmWNfKPBmKJw2G2YXej2LKAEX diRT0p85RPKfTWWkfKE/f2RtNqmwSQzUcgOCu9dW6AxLTQS+RaIj1vfZWpb+7uw5bgMd rh3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784914469; x=1785519269; h=content-type: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:content-type; bh=o72EGRo2pvQ3WbX6SzXXg6Q1ixoc9GAPCSAe802AzLg=; b=cJaKc8yZ1gk3K/u47D/sAatxoIrpgv8Q72ZiT6GMyxP5R/xIQmX/Xmw890FwPfWhs5 CQRkCrYhUEI/fMMtBmjHyxbLKCGMzj9hCOz5y64QZtUR3uhEukk3PgkPkfHsF+7hkKPx +oEmRZdYG6HJ3/IeCFm9FoCVvIqYH4VpIWfhDI3poFQfiJvHFBx3JK0lxmT0mTyD+7s9 TmsegeFAzGppcDoD+Z3u6mrRBJSCkkc3iCSZgotIynXHSRddwG3PWMq9TmQ1eL5IdqmL D9eMCubeFJgNQEmbUSzE3pJn/Stc8rO7feQQf1yTILfI3RnE+WrVv0fthvWfuXBT3d38 wg8g== X-Forwarded-Encrypted: i=1; AHgh+RqXLNb3zoxNRcX5WiG2OKHa4OvDZ8U7WiUiXiO0BDhe13UxDe/NlzqoK/j7rNpqS/ULnyRVCG6qOKsCE+c=@vger.kernel.org X-Gm-Message-State: AOJu0Yx9YrZ7paz/EY0n/I8ylj0edHW011njspkuxt0AJN4f1HfW5Zju 9y5DC5AW1dSVtFK95RPyVUvyNQO6fyV+MHtaBn/BtClLBtiY3pHkj8NK5YgpcmOAVF+6bLJOuye 8qLK+tQ== X-Received: from plv5.prod.google.com ([2002:a17:903:bc5:b0:2ce:fc90:1592]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:903:2f43:b0:2ce:8551:318c with SMTP id d9443c01a7336-2cfa6d879b6mr98306685ad.40.1784914468877; Fri, 24 Jul 2026 10:34:28 -0700 (PDT) Reply-To: Sean Christopherson Date: Fri, 24 Jul 2026 10:34:25 -0700 In-Reply-To: <20260724173425.278753-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: <20260724173425.278753-1-seanjc@google.com> X-Mailer: git-send-email 2.55.0.229.g6434b31f56-goog Message-ID: <20260724173425.278753-3-seanjc@google.com> Subject: [PATCH v3 2/2] KVM: x86: Don't WARN if IRQ disappears when Xen emulation is enabled. From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+dd769db18693736eee89@syzkaller.appspotmail.com, Sashiko Bot Content-Type: text/plain; charset="UTF-8" When getting a to-be-injected IRQ, don't WARN if the IRQ disappeared and Xen emulation is supported, as a guest could concurrently toggle its evtchn_upcall_pending flag in shared memory and deassert the IRQ. Even more annoyingly, userspace could disable Xen emulation for the entire VM KVM_XEN_HVM_CONFIG. So, suppress WARNs on lost IRQs if Xen emulation is supported to prevent false positives. Alternatively, KVM could track if the VM has ever used Xen emulation, but the added complexity isn't worth carrying given that the vast majority of deployments can and should disable Xen emulation. Fixes: bf672720e83c ("KVM: x86: check the kvm_cpu_get_interrupt result before using it") Reported-by: Sashiko Bot Closes: https://lore.kernel.org/all/20260625212001.3B6561F000E9@smtp.kernel.org Signed-off-by: Sean Christopherson --- arch/x86/kvm/irq.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/irq.h b/arch/x86/kvm/irq.h index eeaf527cecc4..a74f03858004 100644 --- a/arch/x86/kvm/irq.h +++ b/arch/x86/kvm/irq.h @@ -130,8 +130,12 @@ static inline void kvm_warn_on_lost_irq(struct kvm_vcpu *vcpu) * another vCPU grabs the IRQ, or deasserts the interrupt (which is * level-triggered), then it's both expected and "fine" for an IRQ * seemingly be "lost" from this vCPU's perspective. + * + * Similarly, Xen's event channel isn't entirely within KVM's control, + * e.g. Xen emulation can be disabled entirely per-VM, or the guest + * can desassert an IRQ by writing to shared memory. */ - WARN_ON_ONCE(!pic_in_kernel(vcpu->kvm)); + WARN_ON_ONCE(!pic_in_kernel(vcpu->kvm) && !IS_ENABLED(CONFIG_KVM_XEN)); } void kvm_inject_pending_timer_irqs(struct kvm_vcpu *vcpu); -- 2.55.0.229.g6434b31f56-goog