Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp996431ybi; Fri, 21 Jun 2019 11:47:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2kjKGoR5aTzrRChu4Rl0xYgsdUVo9t9tLpPhoG+AWvuVmw4BxTFYuGCBl4/IQqMNtyrGa X-Received: by 2002:a17:90a:208e:: with SMTP id f14mr8612403pjg.57.1561142847316; Fri, 21 Jun 2019 11:47:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561142847; cv=none; d=google.com; s=arc-20160816; b=Sa5U+KG0EzSpCM3j/QmLodSVkKVjm8fa8Ik86HeuG9apUXDO/oDcPzQUzvgQhcqqgZ vADbJXLpAlIgDH8GT2LRAk1dhO/L99+XqMAQzBbTyxE4YBnE3PLwyJyBLvHuYPNJnJcU dmc7+x+ZHLtWjIbxSS4MM0Ga9EC2qaEYSgEOxrMLxvB9kVnPG333rdGptJ1SbGj1oPRt MDeVDfC83Q0mpu3bhFStEGFAwql85dQqL4P7tltunpJqGRZ4hiyB2nV613ZkoN50ucTA BEhQV0YSUd1ssqZ5jakukwCg2PO2TiJCCByKwJzjglgTwoCeq4smoWoNra+bHEUoVgbH OQEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=ifkKzwAl9AoX4NqwM1RhSnBK12ynmZYnCw6XCVqAoPY=; b=YvOh6KVTjCji0d3OjGI+D3SIESo9dIzqfFzSy9WtGZJoFUqI5FBetqK1Zmn6rCsgiI DR5XK4y2OVGIAhG7l2DCFcSygVqP8VmEopXuAW3BTWt131p1iSYlsNB9FnjRyBl83B2p /lDHamUUEDlkEmPhGd8YsbO9fltsKXfF4jlcUaHyPrcFF8uLGGCU+DE+R60dEDQ9BAFA 7uTNNEkj3xqyIMnXtbXdIjj/RnmUewQo38tbNOfKT8bedplGmG04XskoDvpG2QX8x+k9 etggk585/d8oDMV7WXqvQ4PIqYByApAzwbqZLUgBnRVObo0UwhcBO80qxXl41j4qDK5R Yq2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l9si3482346plb.317.2019.06.21.11.47.11; Fri, 21 Jun 2019 11:47:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726189AbfFUSrH (ORCPT + 99 others); Fri, 21 Jun 2019 14:47:07 -0400 Received: from mx2.suse.de ([195.135.220.15]:53452 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726066AbfFUSrH (ORCPT ); Fri, 21 Jun 2019 14:47:07 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 03377AEE0; Fri, 21 Jun 2019 18:47:06 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org Subject: [PATCH] xen/events: fix binding user event channels to cpus Date: Fri, 21 Jun 2019 20:47:03 +0200 Message-Id: <20190621184703.17108-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When binding an interdomain event channel to a vcpu via IOCTL_EVTCHN_BIND_INTERDOMAIN not only the event channel needs to be bound, but the affinity of the associated IRQi must be changed, too. Otherwise the IRQ and the event channel won't be moved to another vcpu in case the original vcpu they were bound to is going offline. Cc: # 4.13 Fixes: c48f64ab472389df ("xen-evtchn: Bind dyn evtchn:qemu-dm interrupt to next online VCPU") Signed-off-by: Juergen Gross --- drivers/xen/events/events_base.c | 12 ++++++++++-- drivers/xen/evtchn.c | 2 +- include/xen/events.h | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c index ff9b51055b14..e718c8fea18b 100644 --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -1294,7 +1294,7 @@ void rebind_evtchn_irq(int evtchn, int irq) } /* Rebind an evtchn so that it gets delivered to a specific cpu */ -int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu) +static int xen_rebind_evtchn_to_cpu(int evtchn, unsigned int tcpu) { struct evtchn_bind_vcpu bind_vcpu; int masked; @@ -1328,7 +1328,6 @@ int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu) return 0; } -EXPORT_SYMBOL_GPL(xen_rebind_evtchn_to_cpu); static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest, bool force) @@ -1342,6 +1341,15 @@ static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest, return ret; } +/* To be called with desc->lock held. */ +int xen_set_affinity_evtchn(struct irq_desc *desc, unsigned int tcpu) +{ + struct irq_data *d = irq_desc_get_irq_data(desc); + + return set_affinity_irq(d, cpumask_of(tcpu), false); +} +EXPORT_SYMBOL_GPL(xen_set_affinity_evtchn); + static void enable_dynirq(struct irq_data *data) { int evtchn = evtchn_from_irq(data->irq); diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c index f341b016672f..052b55a14ebc 100644 --- a/drivers/xen/evtchn.c +++ b/drivers/xen/evtchn.c @@ -447,7 +447,7 @@ static void evtchn_bind_interdom_next_vcpu(int evtchn) this_cpu_write(bind_last_selected_cpu, selected_cpu); /* unmask expects irqs to be disabled */ - xen_rebind_evtchn_to_cpu(evtchn, selected_cpu); + xen_set_affinity_evtchn(desc, selected_cpu); raw_spin_unlock_irqrestore(&desc->lock, flags); } diff --git a/include/xen/events.h b/include/xen/events.h index a48897199975..c0e6a0598397 100644 --- a/include/xen/events.h +++ b/include/xen/events.h @@ -3,6 +3,7 @@ #define _XEN_EVENTS_H #include +#include #ifdef CONFIG_PCI_MSI #include #endif @@ -59,7 +60,7 @@ void evtchn_put(unsigned int evtchn); void xen_send_IPI_one(unsigned int cpu, enum ipi_vector vector); void rebind_evtchn_irq(int evtchn, int irq); -int xen_rebind_evtchn_to_cpu(int evtchn, unsigned tcpu); +int xen_set_affinity_evtchn(struct irq_desc *desc, unsigned int tcpu); static inline void notify_remote_via_evtchn(int port) { -- 2.16.4