From nobody Mon Nov 23 22:23:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1793268507; cv=none; d=zohomail.com; s=zohoarc; b=esrngwVc/O7rANJB3pR7RTJOo93tRNIA6AUXq9SazchdtDDjfuhs/hj7TRFDqsZBeA/2904Vk+yW6leHcdakDXkZ3berSlcek2oQvRVewYD39QvALM0z8pk5SmpUTakgtvFNeF0NY90rXBjq34ZQTIjpcZkk+Cs84cOjwSaB7Xo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1793268507; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JWt7RjLtDFAj1Twt2mVWYcZJUcmbBZY2oIoGpwJlSWc=; b=lFhMJV9AMujxGagtQ9wDWWLMPjhhcrrvP9hBzzgfi7rnlqvK43VRn1z6Mg0zsIOI88vRrEozSKl/CTwD/UWJWMIGvuGllRvofqH7NCyoWeZIjMxyzCpzF24ipXA1SM+v2xdjX6MigzgKIwgISY8x08YwIDDHbwuUUVdOxjq/PPk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1793268507467514.2230206447717; Thu, 29 Oct 2026 03:08:27 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1464358.1675050 (Exim 4.92) (envelope-from ) id 1xMN3E-0006sW-Pk; Thu, 29 Oct 2026 10:08:04 +0000 Received: by outflank-mailman (output) from mailman id 1464358.1675050; Thu, 29 Oct 2026 10:08:04 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xMN3E-0006sP-N0; Thu, 29 Oct 2026 10:08:04 +0000 Received: by outflank-mailman (input) for mailman id 1464358; Thu, 29 Oct 2026 10:08:03 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1xMN3D-0006sJ-ON for xen-devel@lists.xenproject.org; Thu, 29 Oct 2026 10:08:03 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xMN3D-00000002PB4-2FGS; Thu, 29 Oct 2026 10:08:03 +0000 Received: from 224.pool85-54-217.dynamic.orange.es ([85.54.217.224] helo=localhost) by xenbits.xenproject.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xMN3C-000000012kX-46yx; Thu, 29 Oct 2026 10:08:03 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xenproject.org; s=20200302mail; h=Content-Transfer-Encoding:Content-Type: MIME-Version:Message-ID:Date:Subject:Cc:To:From; bh=JWt7RjLtDFAj1Twt2mVWYcZJUcmbBZY2oIoGpwJlSWc=; b=z06qXT2uuI8qN98a0dJqjk9a37 fHnz6Vv5OF34HmZlS2JhkXrG+VumPJetdYbm2W5pN7IvJOc0+9ed3NMHbnlaQIJq04EkBcV9FKjUL a/6lyovM6vq6qlmR24S1AjvYLxJgiNBMPJSN8HEn2eEBi0lyeSrHtHKoxMFfm/VinLqg=; From: Roger Pau Monne To: xen-devel@lists.xenproject.org Cc: Roger Pau Monne , Jan Beulich , Andrew Cooper , Teddy Astie , Anthony PERARD , Michal Orzel , Julien Grall , Stefano Stabellini Subject: [PATCH] x86/irq: further gate PIRQ usage for HVM domains Date: Thu, 29 Oct 2026 11:07:41 +0100 Message-ID: <20261029100741.42711-1-roger@xenproject.org> X-Mailer: git-send-email 2.55.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xenproject.org) X-ZM-MESSAGEID: 1793268512098154100 Further restrict PIRQ usage for HVM domains not having the ability to route device interrupts over event channels. It's still possible for HVM domains without PIRQ support to exercise the vector =3D=3D 0 path in hvm_inject_msi(), which is intended to be used only when the guest has PIRQ support. Taking the PIRQ path in hvm_inject_msi() inhibits the local APIC from raising an ESR error when the MSI vector is 0, since an MSI with vector =3D=3D 0 is always processed as a PIRQ. Introd= uce a has_pirq() check in hvm_inject_msi(). EVTCHNOP_bind_pirq is also not outright blocked for HVM domains without PIRQ support, so guests could attempt to bind device interrupts to event channels. Short-circuit evtchn_bind_pirq() early if the domain has no PIRQ support. Additionally introduce an assert in map_domain_emuirq_pirq() to ensure it's never called from HVM domains without PIRQ support. Finally add an extra check in hvm_domain_use_pirq() so it returns false unconditionally if the domain has no PIRQ support. Also convert the is_hvm_domain() check into an ASSERT(); this helper is never called against a PV domain. Fixes: b96b50004804 ("x86: remove XENFEAT_hvm_pirqs for PVHv2 guests") Signed-off-by: Roger Pau Monn=C3=A9 Reviewed-by: Jan Beulich --- xen/arch/x86/hvm/irq.c | 5 +++-- xen/arch/x86/irq.c | 2 ++ xen/common/event_channel.c | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c index 5f643611130f..50a43143149b 100644 --- a/xen/arch/x86/hvm/irq.c +++ b/xen/arch/x86/hvm/irq.c @@ -19,7 +19,8 @@ =20 bool hvm_domain_use_pirq(const struct domain *d, const struct pirq *pirq) { - return is_hvm_domain(d) && pirq && pirq->arch.hvm.emuirq !=3D IRQ_UNBO= UND; + ASSERT(is_hvm_domain(d)); + return has_pirq(d) && pirq && pirq->arch.hvm.emuirq !=3D IRQ_UNBOUND; } =20 /* Must be called with hvm_domain->irq_lock hold */ @@ -382,7 +383,7 @@ int hvm_inject_msi(struct domain *d, uint64_t addr, uin= t32_t data) >> MSI_DATA_TRIGGER_SHIFT; uint8_t vector =3D data & MSI_DATA_VECTOR_MASK; =20 - if ( !vector ) + if ( has_pirq(d) && !vector ) { unsigned int pirq =3D ((addr >> 32) & 0xffffff00U) | dest; =20 diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index c58d2eb9227c..32a75f77a46d 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -2814,6 +2814,8 @@ int map_domain_emuirq_pirq(struct domain *d, int pirq= , int emuirq) if ( !is_hvm_domain(d) ) return -EINVAL; =20 + ASSERT(has_pirq(d)); + if ( pirq < 0 || pirq >=3D d->nr_pirqs || emuirq =3D=3D IRQ_UNBOUND || emuirq >=3D (int) nr_irqs ) { diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index bd03e094d096..97104bea15fc 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -681,6 +681,9 @@ static int evtchn_bind_pirq(evtchn_bind_pirq_t *bind) int port =3D 0, rc; unsigned int pirq =3D bind->pirq; =20 + if ( is_hvm_domain(d) && !has_pirq(d) ) + return -EOPNOTSUPP; + if ( pirq >=3D d->nr_pirqs ) return -EINVAL; =20 --=20 2.55.0