|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging-4.20] x86/irq: further gate PIRQ usage for HVM domains
commit 2983a3ecfe5cd2189612d8f5a519f705179591a6
Author: Roger Pau Monné <roger@xxxxxxxxxxxxxx>
AuthorDate: Wed Nov 11 14:27:09 2026 +0100
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Nov 11 14:27:09 2026 +0100
x86/irq: further gate PIRQ usage for HVM domains
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 == 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 == 0 is always processed as a PIRQ. Introduce
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é <roger@xxxxxxxxxxxxxx>
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
master commit: e4956d5e6bdcb7e2e9abfa4474b2dc1160c51a45
master date: 2026-10-29 14:51:07 +0100
---
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 1eab44defc..1f918c54ee 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -19,7 +19,8 @@
bool hvm_domain_use_pirq(const struct domain *d, const struct pirq *pirq)
{
- return is_hvm_domain(d) && pirq && pirq->arch.hvm.emuirq != IRQ_UNBOUND;
+ ASSERT(is_hvm_domain(d));
+ return has_pirq(d) && pirq && pirq->arch.hvm.emuirq != IRQ_UNBOUND;
}
/* Must be called with hvm_domain->irq_lock hold */
@@ -382,7 +383,7 @@ int hvm_inject_msi(struct domain *d, uint64_t addr,
uint32_t data)
>> MSI_DATA_TRIGGER_SHIFT;
uint8_t vector = data & MSI_DATA_VECTOR_MASK;
- if ( !vector )
+ if ( has_pirq(d) && !vector )
{
unsigned int pirq = ((addr >> 32) & 0xffffff00U) | dest;
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index ec8b0976bf..3230c4a05e 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2797,6 +2797,8 @@ int map_domain_emuirq_pirq(struct domain *d, int pirq,
int emuirq)
if ( !is_hvm_domain(d) )
return -EINVAL;
+ ASSERT(has_pirq(d));
+
if ( pirq < 0 || pirq >= d->nr_pirqs ||
emuirq == IRQ_UNBOUND || emuirq >= (int) nr_irqs )
{
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 46281b16ce..ffb23e5a28 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -606,6 +606,9 @@ static int evtchn_bind_pirq(evtchn_bind_pirq_t *bind)
int port = 0, rc;
unsigned int pirq = bind->pirq;
+ if ( is_hvm_domain(d) && !has_pirq(d) )
+ return -EOPNOTSUPP;
+
if ( pirq >= d->nr_pirqs )
return -EINVAL;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.20
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |