[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] x86/irq: Return -EEXIST from map_domain_pirq()


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Mon, 18 May 2026 20:15:59 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=TIziPShW5JvZAXG/Lgmsjf5KGUiDMQxRult1tOt+ci8=; b=Nnw1tD+fY4ONHV61OwzoCO+qJSQy8h+jSCgUkJCP0laMcxheJjaTOzhKdEMp782GT2aFxhVn/UqpClazl1EYXMwHuIkhtUeimF3Y0ummIAVhUo5JrHwpKSgwk1BFiF3hi/iqeJatXyXWPLi8G4fV7lE+L4C3FyW3oU9mo1fs7zTSd/szsF+2Sul6Wiqq0oPvr4Iv0tDdiGwilWgKaAjQHzaVrYTvy6qTGTLf3RsSZ42Mom4Z5AfulfNWIgRHRwZIgIzE9xq+m9mNzkJZAqI98lp9HDDMvoa3mBmqgN1eATgBsIxmNmjIVWgOzWA5ID3pZdRLBw3iL93NdhRP2EpzqA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=eGNNR0WyilJn5pE3+Y35AOEej7vHgO5cRia9Mb9y35uyEPpw6OgFEIN96vAYZzUU3AMfgwBHIr0JRjUL42/OYJQQut81/I6uGF0oeHClTZip3eOCUfHKvOre155otNSTT+M+HbqxTz2yj2e43r1wZ9inzqf2oedTgcEvM7GGIAI24JpkXn1w+M8gfpAQeOMPxw0js7YAEed9JMCOqeno30i2QAqhzTZ/0nugkQXRxHmtLsMRY09CBLk8WhF02AGAS6bxAG2Bp/dtDh/q9UChEo0dmUxBQhoUwPZ2+b7mD6Xa1zmwXtiSXOnXLBD83kuifyxzWCUSw0E0bWRqvf5iMg==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>
  • Delivery-date: Tue, 19 May 2026 00:23:14 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

commit bfc341a65cfb ("x86: Make the hypercall PHYSDEVOP_alloc_irq_vector
hypercall dummy.") modified map_domain_pirq() to return 0 when an irq or
pirq is already mapped, when it previously returned -EINVAL.  This
occured when moving map_domain_pirq()'s call from
PHYSDEVOP_alloc_irq_vector into PHYSDEVOP_apic_write.

However, this means other callers cannot detect when a pirq or irq is
already mapped.  Since success is returned but the pirq is not
connected, it will never fire.

Modify map_domain_pirq() to return -EEXIST.  -EINVAL is already returned
elsewhere in map_domain_pirq(), so -EEXIST allows identifying this case.
With that, squash -EEXIST in ioapic_guest_write() so the behavior does not
change.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
I'm not sure whether or not this warrants a Fixes.  Nothing in tree
today is broken, so I did not add one.

 xen/arch/x86/io_apic.c | 2 ++
 xen/arch/x86/irq.c     | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index 46c2a43dac..2b928fc236 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -2315,6 +2315,8 @@ int ioapic_guest_write(unsigned long physbase, unsigned 
int reg, u32 val)
         ret = map_domain_pirq(hardware_domain, pirq, irq,
                               MAP_PIRQ_TYPE_GSI, NULL);
         write_unlock(&hardware_domain->event_lock);
+        if ( ret == -EEXIST )
+            ret = 0;
         if ( ret < 0 )
             return ret;
     }
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 739fc04bd1..938cca6203 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2210,7 +2210,7 @@ int map_domain_pirq(
         dprintk(XENLOG_G_WARNING,
                 "dom%d: pirq %d or irq %d already mapped (%d,%d)\n",
                 d->domain_id, pirq, irq, old_pirq, old_irq);
-        return 0;
+        return -EEXIST;
     }
 
     ret = xsm_map_domain_irq(XSM_HOOK, d, irq, data);
-- 
2.54.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.