From 82959c8a2efb36a9726037cb6e15238ac7b554ca Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 1 Oct 2026 10:00:15 +0200 Subject: [PATCH] x86/pass-through: use simpler locking primitives in pt_irq_{create,destroy}_bind() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both functions already assume IRQs to be enabled upon entry, by e.g. their acquiring of the domain's event channel lock. Hence like e.g. hvm_migrate_pirq() (also called from here) does, saving/restoring of EFLAGS.IF isn't necessary (because of the functions called, we can't really avoid the saving there). Signed-off-by: Jan Beulich Acked-by: Roger Pau Monné --- xen/drivers/passthrough/x86/hvm.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/x86/hvm.c b/xen/drivers/passthrough/x86/hvm.c index aa3bcd4cf4..9f8e6c8cd5 100644 --- a/xen/drivers/passthrough/x86/hvm.c +++ b/xen/drivers/passthrough/x86/hvm.c @@ -228,6 +228,8 @@ int pt_irq_create_bind( if ( pirq < 0 || pirq >= d->nr_pirqs ) return -EINVAL; + ASSERT(local_irq_is_enabled()); + restart: write_lock(&d->event_lock); @@ -400,8 +402,7 @@ int pt_irq_create_bind( if ( pt_irq_bind->u.msi.gflags & XEN_DOMCTL_VMSI_X86_UNMASKED ) { - unsigned long flags; - struct irq_desc *desc = pirq_spin_lock_irq_desc(info, &flags); + struct irq_desc *desc = pirq_spin_lock_irq_desc(info, NULL); if ( !desc ) { @@ -411,7 +412,7 @@ int pt_irq_create_bind( } guest_mask_msi_irq(desc, false); - spin_unlock_irqrestore(&desc->lock, flags); + spin_unlock_irq(&desc->lock); } write_unlock(&d->event_lock); @@ -588,6 +589,8 @@ int pt_irq_destroy_bind( struct pirq *pirq; const char *what = NULL; + ASSERT(local_irq_is_enabled()); + switch ( pt_irq_bind->irq_type ) { case PT_IRQ_TYPE_PCI: @@ -606,9 +609,7 @@ int pt_irq_destroy_bind( break; case PT_IRQ_TYPE_MSI: { - unsigned long flags; - struct irq_desc *desc = domain_spin_lock_irq_desc(d, machine_gsi, - &flags); + struct irq_desc *desc = domain_spin_lock_irq_desc(d, machine_gsi, NULL); if ( !desc ) return -EINVAL; @@ -617,7 +618,7 @@ int pt_irq_destroy_bind( * pt_irq_create_bind is consistent across bind/unbinds. */ guest_mask_msi_irq(desc, true); - spin_unlock_irqrestore(&desc->lock, flags); + spin_unlock_irq(&desc->lock); break; }