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

[PATCH v2 3/3] xen/events: Update virq_to_irq on migration


  • To: Juergen Gross <jgross@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Chris Wright <chrisw@xxxxxxxxxxxx>, "Jeremy Fitzhardinge" <jeremy@xxxxxxxxxxxxx>
  • From: Jason Andryuk <jason.andryuk@xxxxxxx>
  • Date: Mon, 25 Aug 2025 20:55:15 -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=vhSEPF8a35m/xTcBty/l8kD6Fit9wlVpONLWs4x9hHc=; b=G26YkfVD81nINmHApXz4ZmP6moCflXuXTcTRFWEFE85quKSoF8RIPPr+N3vhXtGt//Ns1qSKuiHp01TwhZHEdZ+5Pfid2lSutwQl0gg7vOZvO7GbG5mKkf56huNfiAP1BDqp4+SaRb67OkZEw5DPKPBhlBVHSiVvzkc7DhUOOWC7wtzm1poByNeNFKruVvK4rKDR9MpF9X3qBr26+mxvd59qe5Rqdynfs8ZRurR3Nr4pKezYW9H1WPvKaRyg0gf7fMjIMKIfLrvV9Py9HOU3Qr1spfyCoJ4FWmrjdd/fcapJ4Ppv7rkqW8ugr/v79qoJwI/U8usU+r+ZzHm67Flm7Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iyU3wxYGpiISoh/ORueFSlytgk+9QjxHWrrI+iS77I8904KH0bmveF6N9VU+okulfnrkePT4SD1RTIlTsRJRFdqSsnj0EpyUYr1ICpkXCd46C+tG+0ptUNybsT08+kFyDL4l2qOi4/q9i3kuueuodtlNyDtQDABrJLUGuUK8Art/hVD6eiraEXYcx08GmVvMoUIn3EXRXPEOgeRFbcXEBGMPCmiY+I0vTHMxsP+/gre5C+FBhzLoC1bVWRN7eFayeHZpD5+t7wSF2hNHl9XVbAWaKA1do+edtNX6IDiOAyAr+U6aRO0roXycbudLXzcB1PIytZz+gksNnNgbBABi5w==
  • Cc: Jason Andryuk <jason.andryuk@xxxxxxx>, <stable@xxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>
  • Delivery-date: Tue, 26 Aug 2025 00:55:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

VIRQs come in 3 flavors, per-VPU, per-domain, and global, and the VIRQs
are tracked in per-cpu virq_to_irq arrays.

Per-domain and global VIRQs must be bound on CPU 0, and
bind_virq_to_irq() sets the per_cpu virq_to_irq at registration time
Later, the interrupt can migrate, and info->cpu is updated.  When
calling __unbind_from_irq(), the per-cpu virq_to_irq is cleared for a
different cpu.  If bind_virq_to_irq() is called again with CPU 0, the
stale irq is returned.  There won't be any irq_info for the irq, so
things break.

Make xen_rebind_evtchn_to_cpu() update the per_cpu virq_to_irq mappings
to keep them update to date with the current cpu.  This ensures the
correct virq_to_irq is cleared in __unbind_from_irq().

Fixes: e46cdb66c8fc ("xen: event channels")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Jason Andryuk <jason.andryuk@xxxxxxx>
---
V2:
Different approach changing virq_to_irq
---
 drivers/xen/events/events_base.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c
index a85bc43f4344..4e9db7b92dde 100644
--- a/drivers/xen/events/events_base.c
+++ b/drivers/xen/events/events_base.c
@@ -1772,6 +1772,7 @@ static int xen_rebind_evtchn_to_cpu(struct irq_info 
*info, unsigned int tcpu)
 {
        struct evtchn_bind_vcpu bind_vcpu;
        evtchn_port_t evtchn = info ? info->evtchn : 0;
+       int old_cpu = info ? info->cpu : tcpu;
 
        if (!VALID_EVTCHN(evtchn))
                return -1;
@@ -1795,8 +1796,18 @@ static int xen_rebind_evtchn_to_cpu(struct irq_info 
*info, unsigned int tcpu)
         * it, but don't do the xenlinux-level rebind in that case.
         */
        if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0)
+       {
                bind_evtchn_to_cpu(info, tcpu, false);
 
+               if (info->type == IRQT_VIRQ) {
+                       int virq = info->u.virq;
+                       int irq = per_cpu(virq_to_irq, old_cpu)[virq];
+
+                       per_cpu(virq_to_irq, old_cpu)[virq] = -1;
+                       per_cpu(virq_to_irq, tcpu)[virq] = irq;
+               }
+       }
+
        do_unmask(info, EVT_MASK_REASON_TEMPORARY);
 
        return 0;
-- 
2.50.1




 


Rackspace

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