Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3525238pxf; Mon, 15 Mar 2021 11:29:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD/wwnZFWiPBYfY4CEyfzga9GAs27ZZtD2Rdu5ScaorzTzIezBauWDQJU1FJAGqCTcN0yF X-Received: by 2002:a17:907:9863:: with SMTP id ko3mr25067920ejc.543.1615832987086; Mon, 15 Mar 2021 11:29:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1615832987; cv=none; d=google.com; s=arc-20160816; b=ibAaNTogyfxkUFhTFL37RRjh7zbzz+CI4cM6HeRFy8i+o+Vga6LdarGVshQqqOSRCD EakVL8AfM603w9AVDAU3TYFoFQriMMwZnDeFXuqH9nGrle+5f98U9PSYwlmoKO3M/IIB mBuZzHSz4CVGrzwOZ90TcnFu756ocZEG7pErbPPGpe9tsYx2fvMCftOdK70Bt5xUKGD6 kvTouXhmI4/iEy4ew2NfsXwXc+l6/pDS860wdIa8NJlHp36H9+00+PXKsYQCeGPzMmr8 +C9JrTEttTqMfyOI1bLa1XHKquMIKZPiiJzqstokn8RN1t50DsB4ytJTSiVj/1qynWuH daxg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4+X2bTLOXVVnbmTVLCHHs6WIIQYxyy8R3kCCjg+IQj0=; b=XzFvWHbvhIT/ge/D32Xa9O4CESYwR4+DIBiitQ9gg5EjaC7pq/KJBwyaY3dK1uUaZg NJFIztSsaNGdVI4IK1JXzZ19T5bZzBAXWX6IQPLdWG6amZGZ9PCHmnUDCFEV9GwwVSWZ FO3A2zrNGFmhXfcRKsreXmMId9pF/0EJHVOkhzbIt6pJZHsJaRmHJFTwVL5jike4RUtG U5wviSEqO4F2Uad2yoiDczDpFVHyBd+VKimJo20Gfd7hrKn4NCY4qNQgUrlHKY5NUXOf 9dsO7ZQ9hm+dmghiPZE9WQtnt98ZJwAY3EUpKYjFp7Rv08SV6AotkEDKsCaIUE+wG1QY E48A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wfE2YPox; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u27si11163470ejj.726.2021.03.15.11.29.21; Mon, 15 Mar 2021 11:29:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wfE2YPox; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231972AbhCOOe1 (ORCPT + 99 others); Mon, 15 Mar 2021 10:34:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:36622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233422AbhCOOBk (ORCPT ); Mon, 15 Mar 2021 10:01:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id A93B864EF0; Mon, 15 Mar 2021 14:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1615816878; bh=n3FtlREOVVzRH53tiaO0kZzH93lD160lJblRxHLW9bE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfE2YPox2LPlnoK/8n0oenYlyiTJr8GzZGryWFIhJfvMK4iRLqUQNu7EdYNkXb5mO H2O/3nAGaPahw28Dhr5IB2AaSzyBkBMEkD57E25+Msd17v3gB5tj18g6dYFY0BimzD N7BLt6pA9FWLJnarrUcyWgohDrCkmvFL8F6Mbr1A= From: gregkh@linuxfoundation.org To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Grall , Juergen Gross , Julien Grall , Boris Ostrovsky Subject: [PATCH 5.4 166/168] xen/events: reset affinity of 2-level event when tearing it down Date: Mon, 15 Mar 2021 14:56:38 +0100 Message-Id: <20210315135555.819614796@linuxfoundation.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210315135550.333963635@linuxfoundation.org> References: <20210315135550.333963635@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Greg Kroah-Hartman From: Juergen Gross commit 9e77d96b8e2724ed00380189f7b0ded61113b39f upstream. When creating a new event channel with 2-level events the affinity needs to be reset initially in order to avoid using an old affinity from earlier usage of the event channel port. So when tearing an event channel down reset all affinity bits. The same applies to the affinity when onlining a vcpu: all old affinity settings for this vcpu must be reset. As percpu events get initialized before the percpu event channel hook is called, resetting of the affinities happens after offlining a vcpu (this is working, as initial percpu memory is zeroed out). Cc: stable@vger.kernel.org Reported-by: Julien Grall Signed-off-by: Juergen Gross Reviewed-by: Julien Grall Link: https://lore.kernel.org/r/20210306161833.4552-2-jgross@suse.com Signed-off-by: Boris Ostrovsky Signed-off-by: Greg Kroah-Hartman --- drivers/xen/events/events_2l.c | 15 +++++++++++++++ drivers/xen/events/events_base.c | 1 + drivers/xen/events/events_internal.h | 8 ++++++++ 3 files changed, 24 insertions(+) --- a/drivers/xen/events/events_2l.c +++ b/drivers/xen/events/events_2l.c @@ -47,6 +47,11 @@ static unsigned evtchn_2l_max_channels(v return EVTCHN_2L_NR_CHANNELS; } +static void evtchn_2l_remove(evtchn_port_t evtchn, unsigned int cpu) +{ + clear_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, cpu))); +} + static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned cpu) { clear_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, info->cpu))); @@ -354,9 +359,18 @@ static void evtchn_2l_resume(void) EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD); } +static int evtchn_2l_percpu_deinit(unsigned int cpu) +{ + memset(per_cpu(cpu_evtchn_mask, cpu), 0, sizeof(xen_ulong_t) * + EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD); + + return 0; +} + static const struct evtchn_ops evtchn_ops_2l = { .max_channels = evtchn_2l_max_channels, .nr_channels = evtchn_2l_max_channels, + .remove = evtchn_2l_remove, .bind_to_cpu = evtchn_2l_bind_to_cpu, .clear_pending = evtchn_2l_clear_pending, .set_pending = evtchn_2l_set_pending, @@ -366,6 +380,7 @@ static const struct evtchn_ops evtchn_op .unmask = evtchn_2l_unmask, .handle_events = evtchn_2l_handle_events, .resume = evtchn_2l_resume, + .percpu_deinit = evtchn_2l_percpu_deinit, }; void __init xen_evtchn_2l_init(void) --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -286,6 +286,7 @@ static int xen_irq_info_pirq_setup(unsig static void xen_irq_info_cleanup(struct irq_info *info) { set_evtchn_to_irq(info->evtchn, -1); + xen_evtchn_port_remove(info->evtchn, info->cpu); info->evtchn = 0; } --- a/drivers/xen/events/events_internal.h +++ b/drivers/xen/events/events_internal.h @@ -65,6 +65,7 @@ struct evtchn_ops { unsigned (*nr_channels)(void); int (*setup)(struct irq_info *info); + void (*remove)(evtchn_port_t port, unsigned int cpu); void (*bind_to_cpu)(struct irq_info *info, unsigned cpu); void (*clear_pending)(unsigned port); @@ -107,6 +108,13 @@ static inline int xen_evtchn_port_setup( return 0; } +static inline void xen_evtchn_port_remove(evtchn_port_t evtchn, + unsigned int cpu) +{ + if (evtchn_ops->remove) + evtchn_ops->remove(evtchn, cpu); +} + static inline void xen_evtchn_port_bind_to_cpu(struct irq_info *info, unsigned cpu) {