Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp660759pxv; Fri, 9 Jul 2021 06:23:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbuR2FP2Ju7F/zjwbg+CQ299WJVDM1+jbz8UdRdc/GutVCXYN/9JikTUwy4D7WUeHTqZPy X-Received: by 2002:a92:6e07:: with SMTP id j7mr11887951ilc.71.1625837014379; Fri, 09 Jul 2021 06:23:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625837014; cv=none; d=google.com; s=arc-20160816; b=xihd5bGDdqjN2JboIaRc4v87STZcmwn+3xLF8ZXK0LIfaY5GQJFldfWo/Gs8e+G/wx qQeyBDkB3XcR7ZuWZxdb+62zWuAxRdhJE5b6JRn1qXVLIGv8zPshMRze/WVDLTwaU5Qj BssZfeYQul9HQkb23NC50yqY0oDLUyX5s+khHgzkXX8Fn6w5LB94J4X6RKKazVzCBvXL jtUIGaD7TbAj9TxEWgHDvbWVhO7pjv0y71NExi8KZU4DXEgHkEFTzC4aN3d9EghXuSwa DSVSwp0KKfhH12O6miPXPI6unnD76tgUaXK8nuEBEJjhTE+W+YO5frkuegqg9lmVSPO0 BZ0Q== 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=B4k4uDqGZbgnTmIwsoiX4QXcF8wTWYKMY+te4hCHIyE=; b=yvx4pcQX1Vp+aq8SYkzjeFjHH6J2cbuLzqDRgVlE0/UWTe+PN/FL/hT79c3LJOKoqw 3fFutlG82lFrJEoYlULGPynVVEofZv1gGww0TmzuZSFjCszHmIC820qJ3ZrL6to/aoWZ Y57SLzEzWNaKcp4tfvtbFxim1MQbhnQntXgoWZTKmiHj9ZPeJjwjLZgV8cJ/iCglitdQ Iw4ERasNeRolBZtxt3uTO4BreTU1H/GUbdXuHFaW+KFSfe0jh1PQUf1EtzJ7hJnCepSc KCYdVWXOTZOzU2/A6wQwWO7UBoLPAXwYI8tURml5ORbdU8fqIi624SrIe0JozoeP5SeI eZMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Ic+2tf85; 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 c9si7435701ilu.72.2021.07.09.06.23.22; Fri, 09 Jul 2021 06:23:34 -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=Ic+2tf85; 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 S232818AbhGINYx (ORCPT + 99 others); Fri, 9 Jul 2021 09:24:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:56330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232752AbhGINYk (ORCPT ); Fri, 9 Jul 2021 09:24:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id F3631613BC; Fri, 9 Jul 2021 13:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1625836917; bh=PZ6EJcrDKzfN3PJu5a68vxiQpKR6yp/1vj+22G8udRs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ic+2tf85Zq64GdlXAQRs9cNZu+6zhlc2aG99MDzAPyvYWEDHL+Zl3gzXNUAJoexAe /ju7TxDTUR6KSgLZ8nFiP0ctAbYz3lzZuXAVoN8xg3f+iSRH4Ip90GoUmRYLhKf8iP n2ZdEDqi78BQnufCkieLLzaDgkoAvTw/futooagU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Grall , Juergen Gross , Boris Ostrovsky Subject: [PATCH 4.19 29/34] xen/events: reset active flag for lateeoi events later Date: Fri, 9 Jul 2021 15:20:45 +0200 Message-Id: <20210709131700.340627537@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210709131644.969303901@linuxfoundation.org> References: <20210709131644.969303901@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: Juergen Gross commit 3de218ff39b9e3f0d453fe3154f12a174de44b25 upstream. In order to avoid a race condition for user events when changing cpu affinity reset the active flag only when EOI-ing the event. This is working fine as all user events are lateeoi events. Note that lateeoi_ack_mask_dynirq() is not modified as there is no explicit call to xen_irq_lateeoi() expected later. Cc: stable@vger.kernel.org Reported-by: Julien Grall Fixes: b6622798bc50b62 ("xen/events: avoid handling the same event on two cpus at the same time") Tested-by: Julien Grall Signed-off-by: Juergen Gross Reviewed-by: Boris Ostrovsky Link: https://lore.kernel.org/r/20210623130913.9405-1-jgross@suse.com Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/events/events_base.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) --- a/drivers/xen/events/events_base.c +++ b/drivers/xen/events/events_base.c @@ -524,6 +524,9 @@ static void xen_irq_lateeoi_locked(struc } info->eoi_time = 0; + + /* is_active hasn't been reset yet, do it now. */ + smp_store_release(&info->is_active, 0); do_unmask(info, EVT_MASK_REASON_EOI_PENDING); } @@ -1780,10 +1783,22 @@ static void lateeoi_ack_dynirq(struct ir struct irq_info *info = info_for_irq(data->irq); evtchn_port_t evtchn = info ? info->evtchn : 0; - if (VALID_EVTCHN(evtchn)) { - do_mask(info, EVT_MASK_REASON_EOI_PENDING); - ack_dynirq(data); - } + if (!VALID_EVTCHN(evtchn)) + return; + + do_mask(info, EVT_MASK_REASON_EOI_PENDING); + + if (unlikely(irqd_is_setaffinity_pending(data)) && + likely(!irqd_irq_disabled(data))) { + do_mask(info, EVT_MASK_REASON_TEMPORARY); + + clear_evtchn(evtchn); + + irq_move_masked_irq(data); + + do_unmask(info, EVT_MASK_REASON_TEMPORARY); + } else + clear_evtchn(evtchn); } static void lateeoi_mask_ack_dynirq(struct irq_data *data)