Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3849243pxb; Tue, 17 Nov 2020 05:20:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJwxW3T9/uguErOlfmyiKjOWAGPXoKJLdNAZIJKuTj0afZkeNDYlIAEfyRQ45VXMfTqrMWiJ X-Received: by 2002:a17:907:4186:: with SMTP id mz6mr20098819ejb.175.1605619223611; Tue, 17 Nov 2020 05:20:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605619223; cv=none; d=google.com; s=arc-20160816; b=QRE2s6T649POMQOwyB6ACk8oS538X4X/V5dgQjLoV8wvtCFNqQKaD/15uOiBh2MfaB hdUvG9qfO5aShJdzCOgDcA1pm0D90dn6Z29DKzaj1qsL00xhZfcTgfjUprr9GzAHxcQ0 ShwvWfF+b96CrM8iJUWp0fbzqW+aqQRTzqSc+QI+x6roJXHdyztjQ/XwBKM4tjBWHn0W wAAS9IllgKjAjEyqw28WEO3IctQN4qss3DNVtcI5VCYYoj1I1ADOqoNtwBHBrvMl9TyN xQZk8xhR2wAZtLKjTjpNlf58KhDNJSpU16dQrLb6BXt6bx8IB4oow64cQDf7o84evOMs 8aPg== 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=3uFtNMqvQ6PvoAR8EN0Pfod/sy8iBIn1fxBv6nIWNo8=; b=ceauQJuu/O5Lb447EYnVeg+/qq9iwrGs8dsek0njXdCc8VmvgTrTU3/oqInmblxoxK Z5LOUVEpaTJCdQydS13XU2Os6LrigFr84vtuvfY82rymuwR1EpoS1jwzIfuBAGEa5Fy6 mFGU/C8YjB5qcGC0aMABq+RFebbEOrjPT1izEO3uWA91a0p5+ILuI4DAKQvmD78Lg8g7 oRe9a0jd4FimSTJx4h25tN9pmcY2v78dZ6GS9Vbyxk8h9+Jw2yG70ZEaZd+r/Yt+Efhf qOUccwdBvPVF7phLbbUF/L2RP7pHju0OMQI35d37c+YkAoTqWSzCI6j0HzrFUiV/TM1b /qZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=O8Ho6Lik; 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=fail (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 f4si13866935edq.363.2020.11.17.05.20.00; Tue, 17 Nov 2020 05:20:23 -0800 (PST) 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=@kernel.org header.s=default header.b=O8Ho6Lik; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730545AbgKQNRV (ORCPT + 99 others); Tue, 17 Nov 2020 08:17:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:49248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729704AbgKQNRF (ORCPT ); Tue, 17 Nov 2020 08:17:05 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 48DAD2225B; Tue, 17 Nov 2020 13:17:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605619024; bh=aCmNFqxGqjg0MaIKn3bMohrVDuuo7zL289AJAp+FoPo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O8Ho6LikQejU8kz85n8uZaMyOzajJY0wX32yrO6iKOR6Rof7iHbo2HnquHl7AtbcV i1XFIEVXZuzQ8May8K8Yd6wdbR0c5zkzzzDGu/7graF7M5FjJZN+PP5ZMIZBDPomJX 9qjkbVVw9MHJE3zla/Ku2LEEt1o3bs6sD1vsTsV0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Julien Grall , Juergen Gross , Julien Grall , Wei Liu Subject: [PATCH 4.14 70/85] xen/events: add a proper barrier to 2-level uevent unmasking Date: Tue, 17 Nov 2020 14:05:39 +0100 Message-Id: <20201117122114.467288437@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201117122111.018425544@linuxfoundation.org> References: <20201117122111.018425544@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 4d3fe31bd993ef504350989786858aefdb877daa upstream. A follow-up patch will require certain write to happen before an event channel is unmasked. While the memory barrier is not strictly necessary for all the callers, the main one will need it. In order to avoid an extra memory barrier when using fifo event channels, mandate evtchn_unmask() to provide write ordering. The 2-level event handling unmask operation is missing an appropriate barrier, so add it. Fifo event channels are fine in this regard due to using sync_cmpxchg(). This is part of XSA-332. Cc: stable@vger.kernel.org Suggested-by: Julien Grall Signed-off-by: Juergen Gross Reviewed-by: Julien Grall Reviewed-by: Wei Liu Signed-off-by: Greg Kroah-Hartman --- drivers/xen/events/events_2l.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/xen/events/events_2l.c +++ b/drivers/xen/events/events_2l.c @@ -91,6 +91,8 @@ static void evtchn_2l_unmask(unsigned po BUG_ON(!irqs_disabled()); + smp_wmb(); /* All writes before unmask must be visible. */ + if (unlikely((cpu != cpu_from_evtchn(port)))) do_hypercall = 1; else {