From nobody Mon Feb 9 06:24:13 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (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 4CA4F21C16E for ; Tue, 13 Jan 2026 17:46:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768326378; cv=none; b=dZmrYdD/gAq7F+2YMvkuX8Y0EcoiUgV/VfGcOxOe/gS0v6wN9ux3TICw4OzoNAe4yyd/N9gtk8/KpW4Ohn1+VXRTGeej+sLwBeQcJFugGOISe4W5T0jVF2yb/h+O9JgByq41gGQvt0LH5xQNUsXGyzRkdcUIFvRLF4tjxlPLUjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768326378; c=relaxed/simple; bh=s5qcLLCVA2jY5aqc6PFjcFhBKKWoGxB3OeqfS/8L/6Y=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=Vb/8KswMi1Keklku0qWH5656mXgXkf0muXOcVhxrvfZxQe53iD9rb7T9ZDFgye83QH/dqVTYRa7quEJKxdYZVn7rnAtZX0tS7QrnyC8zTMNQdgflsWUufuvZRaOrd8QAFF+UUCoLzJCjG84AHzKNdTWiXBVSfQxd2sfv8uMUH8U= 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=SpRKCRan; arc=none smtp.client-ip=209.85.216.74 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="SpRKCRan" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-34abd303b4aso15663379a91.1 for ; Tue, 13 Jan 2026 09:46:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768326373; x=1768931173; 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=4CraqsN8zUJ5wBwG4fLZa6cryGuFuoNdJFyZA+YKRFU=; b=SpRKCRanEHotWFCcqHWl2eyBDcwEKGMSL6NQ3y6VlkwNt4Ax3J7rTKdEl8zTZpkbi9 beI5ieytXaJE7RNb7FJ7dlQvSdcUFK8+j2fJdAc+QVrs+qfqf9Rvm3pL61VcyXcqb1Vb fLg+bfJB0W7cS34VHf6sCVevMCBSGo5LmaKjxKnX8a5Y3wxt8nbEs0T6PVhOecN/p90m JQzOu+FKP9q/+wjcIBus08Sx/t9qd3GB5MafqNU8vb2EtktTJpuveIN7OqMCGZyP2ENf UyP644FMxiAMskUcYV6I5SJumqXtbTFeA3Yr42cNPnZASFpdVQsH421XWwzWZHgINpsC OIDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768326373; x=1768931173; 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=4CraqsN8zUJ5wBwG4fLZa6cryGuFuoNdJFyZA+YKRFU=; b=q/TAUdgbgNvnqd2Xt235I4Csr36VxRBKi4TO+1RnY2VN1B8fUgu9x0heT/DaaNGHvc xmmK5XNHWE0ZKW8b1VDF3IQKOg23o9LtYkDedawfMqFXA+JU52CyAg3FCLQyAKibpok1 8jmUux0+MHi9YLcu/vrgN6sytuzYBa6GIBabbblLacOcuCDvmem72fCa/0t/B3uzF17Q 4aF3SAqd7T5vpO+7Dkw9jOGk0MZEXbXDFo3WU+C2MCTW9NCe+y3gIBHV/l+RbMWf8dpZ Jbd5lq/HR0OM32RcIVA9J7g/AWXcgRkvGrLKCeUZpBEbEpHxLbD2L0sS25tOpNhK9D07 WdMQ== X-Forwarded-Encrypted: i=1; AJvYcCXimRFea8zqwhbMI+ZdmJBiE/vcgNX8xLreKy4/C1nd/uNZe8Sn7kh/4RIXTASuQROVc7wuxaVUllYuWrs=@vger.kernel.org X-Gm-Message-State: AOJu0YyH/TLxgZ0hO0xSplywrG+X646EbrtlcjPqpCOfjgbeR7fsHi/g YwYGCqZN5lBOhpVgtCOHdgZIIaVokD7MAYgJNUz6aaEoQVA4o4xMHRDQvMHGTJ2OrvMboUZJiuq ZpaBuDw== X-Google-Smtp-Source: AGHT+IEjY7ADT1ZxCtwPjnM/2bCNCF/Z7AnwYEw5eULnlRYie/qAccGeg6dWSK+Wosg2sEorAm0VWPbWFKQ= X-Received: from pjty24.prod.google.com ([2002:a17:90a:ca98:b0:34a:6f9f:4531]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90b:568d:b0:34a:a65e:e6ad with SMTP id 98e67ed59e1d1-34f68c32ae0mr19229737a91.1.1768326372671; Tue, 13 Jan 2026 09:46:12 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 13 Jan 2026 09:46:06 -0800 In-Reply-To: <20260113174606.104978-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: <20260113174606.104978-1-seanjc@google.com> X-Mailer: git-send-email 2.52.0.457.g6b5491de43-goog Message-ID: <20260113174606.104978-3-seanjc@google.com> Subject: [PATCH 2/2] KVM: x86: Assert that non-MSI doesn't have bypass vCPU when deleting producer From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Marc Zyngier , Oliver Upton Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When disconnecting a non-MSI irqfd from an IRQ bypass producer, WARN if the irqfd is configured for IRQ bypass and set its IRTE back to remapped mode to harden against kernel/KVM bugs (keeping the irqfd in bypass mode is often fatal to the host). Deactivating an irqfd (removing it from the list of irqfds), updating irqfd routes, and the code in question are all mutually exclusive (all run under irqfds.lock). If an irqfd is configured for bypass, and the irqfd is deassigned at the same time IRQ routing is updated (to change the routing to non-MSI), then either kvm_arch_update_irqfd_routing() should process the irqfd routing change and put the IRTE into remapped mode (routing update "wins"), or kvm_arch_irq_bypass_del_producer() should see the MSI routing info (deactivation "wins"). Signed-off-by: Sean Christopherson --- arch/x86/kvm/irq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/irq.c b/arch/x86/kvm/irq.c index a52115441c07..9519fec09ee6 100644 --- a/arch/x86/kvm/irq.c +++ b/arch/x86/kvm/irq.c @@ -514,7 +514,8 @@ void kvm_arch_irq_bypass_del_producer(struct irq_bypass= _consumer *cons, */ spin_lock_irq(&kvm->irqfds.lock); =20 - if (irqfd->irq_entry.type =3D=3D KVM_IRQ_ROUTING_MSI) { + if (irqfd->irq_entry.type =3D=3D KVM_IRQ_ROUTING_MSI || + WARN_ON_ONCE(irqfd->irq_bypass_vcpu)) { ret =3D kvm_pi_update_irte(irqfd, NULL); if (ret) pr_info("irq bypass consumer (eventfd %p) unregistration fails: %d\n", --=20 2.52.0.457.g6b5491de43-goog