Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10434181ybi; Wed, 24 Jul 2019 23:08:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPce2XCQZoiX+iROeq4qWi2AIJLOXvckjBU7vBgN7tk3VEcPI0nFqWtpwrdUAotpBhIOX3 X-Received: by 2002:a17:902:28e9:: with SMTP id f96mr85835369plb.114.1564034917327; Wed, 24 Jul 2019 23:08:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564034917; cv=none; d=google.com; s=arc-20160816; b=IgRsuI/DMg1bBmX67G33kAY3MWfBkSMLhdXgo3UCJaAwvIAfY+RrjLM3tLRooZtywD 6F9uNXbyCFu6laWzDTn7EovAASkqRIywKuXuhCTp6Vkk44S3JW02XVzfe+MNir7q5pE5 jkQtafpJz8EJYeylXIDkRCwHQGIIFXhk8gU8PYK0jacPlwM5mHiGa31XQDw6v11EwQ0h CYVc9lXCUEtEPMCyMUDJU4P/YN5n/rSHrimmw4gVNoJG+o9wwF+Qq8zJUcPnZ2BLKNlg Q51ILx7EDdZniTCH0NwWfdfl3gRVNxW2uPdUM8oV35teLMinu+dXMIyEwWpFYiSrrFao 7Bug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vlYL3R6l0Ddf2X1+tWCJwbUsj0b66XGRlq3YZLJdVHE=; b=FK4738STOB241bXoxXxYysZwj20H04GYhgbNjffMjvjFuB8h0iBYOg2BpftzjPlJg1 w0EiYv62J1oyzuifCb1k5BGr31bsvgZokDlIR7C0XCbl5NY7hgITKEMAD/16GciqqrvT mHwymKEV4CWKw3PCn7UBaIVGhuaOGBVEroZtGoaqR1ph8vGEeWMfjoWbT9Aa892kjftI eH36cRdbp8T8K+0KiwzfWuzcEpv4ncK0Mt83Bwyg6ugOBTLsG2h3PZajEcnYMLp1NB+o 90je+lyBHpKfrBl007ldHMfR0oXhmqS6bPcn/RBpGHe6aDUESfvLDnosXOYbzfbF/Sek yUJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Bd+3J5DW; 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 w18si14033322pll.132.2019.07.24.23.08.22; Wed, 24 Jul 2019 23:08:37 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Bd+3J5DW; 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 S2387488AbfGYFod (ORCPT + 99 others); Thu, 25 Jul 2019 01:44:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:59672 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404947AbfGYFoc (ORCPT ); Thu, 25 Jul 2019 01:44:32 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B28E21880; Thu, 25 Jul 2019 05:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564033471; bh=eO0h03KlQJOXUAo5ZXToyNf4OaRQbcRRIWCrBWlHd+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Bd+3J5DWjFb4QWRTtF+DJp9QsJHJDqTRFvCHvR3+pitJdn5LXT3HN0ui4GBG/OZ9Z rPp9qz8CpL7WpyPUWHRYOVrQRXP9LRVrfZ0Xavv5uQ2CYfQH0d6N0/hZxBzY3FHkIr SzeruKsMb0gUjkmZRXfVecYcdZ0Gsh+6r9Z0LQoc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Boris Ostrovsky Subject: [PATCH 4.19 220/271] xen/events: fix binding user event channels to cpus Date: Wed, 24 Jul 2019 21:21:29 +0200 Message-Id: <20190724191713.982577975@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190724191655.268628197@linuxfoundation.org> References: <20190724191655.268628197@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit bce5963bcb4f9934faa52be323994511d59fd13c upstream. 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 Reviewed-by: Boris Ostrovsky Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/events/events_base.c | 12 ++++++++++-- drivers/xen/evtchn.c | 2 +- include/xen/events.h | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -1293,7 +1293,7 @@ void rebind_evtchn_irq(int evtchn, int i } /* 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; @@ -1327,7 +1327,6 @@ int xen_rebind_evtchn_to_cpu(int evtchn, 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) @@ -1341,6 +1340,15 @@ static int set_affinity_irq(struct irq_d 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); --- a/drivers/xen/evtchn.c +++ b/drivers/xen/evtchn.c @@ -447,7 +447,7 @@ static void evtchn_bind_interdom_next_vc 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); } --- 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) {