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

[PATCH v2 2/3] xen/events: Return -EEXIST for bound VIRQs


  • To: Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Mon, 25 Aug 2025 20:55:14 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com 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=/m+tvcvgsOF/8B6DaahRF/VzF29+Oz9jjZk9+yNmhNg=; b=KpL5/56cglfcEMtkYk1tDkbc5fx+xj5j7qOokdW+ISey/i2z6iNjYGXekq5z8XklkuK1pZrV62sKohX4t2Ec+V1Ed6TP0eJyzddYrMpLq6IcBNVardGIB5Fd5C9tCwCukYSx1XB8e6skjlSuewKKnpfKBJq9ldX7AhuZ08KlgjPW0DbDzusNCuhhX87Wnv1Zk+JBAIRtTmcDrqrFAD58TFizPiFzT4EaV6DB/N2vGr7qieakFuxzNZsVhBPGwQ6vD9MUGHBS/zyk3AE0JGBOtrRMoZxx0s30CgMAic2kkMaEkRF4YtziJoFLnfFjEeUcQpg9JRZcHQxlMheARpp1rw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZodWxUddWnEIx7z0b2zX7txpHzAoO3EqhGsUZxTcI4Ago8/T0fGkPFSWbvQ/daYjT6vNi0t9h+ktuWo3r+0okaan42V2JV7ku8i/RZpCUnkphTR/hWGxJUzYJSmAM4sShXkwBcLIKW9UvbvsygoViF/IK1GeuZoP5K7IYMKg0HoIPWuJPGqwIV22In7slGSKum6Uq+LBI9rNSx7xcGjikIjoabZoaVOmfpnFe3QVkG6dzBcyCpZgXuIul7WxkJhVE3hs4ZRqDP8eBMByI4O97OMylqVeH7uUb3WcC8wu4/6m0L1xfoXV8F5a/r0ekZZTaUolo41EsYGVnj4PlEm3qw==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 26 Aug 2025 00:55:37 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Change find_virq() to return -EEXIST when a VIRQ is bound to a
different CPU than the one passed in.  With that, remove the BUG_ON()
from bind_virq_to_irq() to propogate the error upwards.

Some VIRQs are per-cpu, but others are per-domain or global.  Those must
be bound to CPU0 and can then migrate elsewhere.  The lookup for
per-domain and global will probably fail when migrated off CPU 0,
especially when the current CPU is tracked.  This now returns -EEXIST
instead of BUG_ON().

A second call to bind a per-domain or global VIRQ is not expected, but
make it non-fatal to avoid trying to look up the irq, since we don't
know which per_cpu(virq_to_irq) it will be in.

Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
V2:
New
---
 drivers/xen/events/events_base.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index 199afe59f357..a85bc43f4344 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1314,10 +1314,12 @@ int bind_interdomain_evtchn_to_irq_lateeoi(struct 
xenbus_device *dev,
 }
 EXPORT_SYMBOL_GPL(bind_interdomain_evtchn_to_irq_lateeoi);
 
-static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t 
*evtchn)
+static int find_virq(unsigned int virq, unsigned int cpu, evtchn_port_t 
*evtchn,
+                    bool percpu)
 {
        struct evtchn_status status;
        evtchn_port_t port;
+       bool exists = false;
        int rc;
 
        memset(&status, 0, sizeof(status));
@@ -1329,12 +1331,16 @@ static int find_virq(unsigned int virq, unsigned int 
cpu, evtchn_port_t *evtchn)
                        continue;
                if (status.status != EVTCHNSTAT_virq)
                        continue;
-               if (status.u.virq == virq && status.vcpu == xen_vcpu_nr(cpu)) {
+               if (status.u.virq != virq)
+                       continue;
+               if (status.vcpu == xen_vcpu_nr(cpu)) {
                        *evtchn = port;
                        return 0;
+               } else if (!percpu) {
+                       exists = true;
                }
        }
-       return -ENOENT;
+       return exists ? -EEXIST : -ENOENT;
 }
 
 /**
@@ -1381,8 +1387,9 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu, 
bool percpu)
                        evtchn = bind_virq.port;
                else {
                        if (ret == -EEXIST)
-                               ret = find_virq(virq, cpu, &evtchn);
-                       BUG_ON(ret < 0);
+                               ret = find_virq(virq, cpu, &evtchn, percpu);
+                       if (ret)
+                               goto out;
                }
 
                ret = xen_irq_info_virq_setup(info, cpu, evtchn, virq);
-- 
2.50.1




 


Rackspace

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