Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3813918ybi; Mon, 29 Jul 2019 13:08:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqzFb6967oXWeiP+1q8yG2MNFS6t4q4QighFdLfsIYxdLfQhzXHrRtM4PlF1RuxBKO/yFe2W X-Received: by 2002:a63:c751:: with SMTP id v17mr90928780pgg.264.1564430906279; Mon, 29 Jul 2019 13:08:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564430906; cv=none; d=google.com; s=arc-20160816; b=F7Yt5cN8Z8TfU3v8EtKOGxVHA9lLvNaOFWZCrprE5yk0IWVrjh0ixivcb/NyxieRuv cr0Ic+9904WiId+nEF0zTFwwj9kJ+lHw2L/60BU91fug/n0xmnC++1lKeusqfTelvfM/ Ue4bjyvb5DI0NKha+HgYYHrKDrZzrpsdQ+WLu3nugHMTcCR3MuShY1Ehqsc3KcICQLUT wyER2seehijaOEpobdgCYbHr1P0HglK+mBiGRteAy+UTZ1vyLVLDV9zdk4BBsgMGKH3i FP0i67sBohg/iQWErIFvICzzjFUlLOAnptxJ63mmmn0yrZ3Eki7D475uOHokkV4+5M7s I3xQ== 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=fNkdpfAlxV9uRmcBui350GsWDVpC0W+sFxTzGQs5P0A=; b=ecIcIGu0IHlm8m02k7BegU8+vJukoIA6O8GKA5dzfUnnih8WLM9PL0+JL3ncOlIL6B PJNkeZWEQqACOqTPZDKw2jDWHJWG3Sf9BDCsTa07Dj7soRtltAUFDqhcecG4CIuS5miq /3st7BIhe06Mak9ELd/yhAuhwAFrQuwdgiN7a2gXxLwLefezTSZ1SOxG/EJwk/liglW5 MKikPkF9Gq6kqFcCHRuUeQivPstrwtR3btbLlIAiS7ABk/00o6tGa7K3uC0Atg6hfoek 7D65eXHHTqW/N1iDZczWZilA2YlpajGFH7fpTag3DXxIl7CdTly3OXi+ilDSdt/jWXMR E+hA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="pZ/NsHOt"; 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 x130si32448971pgx.526.2019.07.29.13.08.11; Mon, 29 Jul 2019 13:08:26 -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="pZ/NsHOt"; 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 S2389137AbfG2TkT (ORCPT + 99 others); Mon, 29 Jul 2019 15:40:19 -0400 Received: from mail.kernel.org ([198.145.29.99]:55540 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388834AbfG2TkP (ORCPT ); Mon, 29 Jul 2019 15:40:15 -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 0031A21773; Mon, 29 Jul 2019 19:40:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429214; bh=L+tRwcr+gkZhY0fZr/oRffdokB2aqA3LwmbU+a2UaPY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pZ/NsHOtpv9gVM/A2QKjBbCT0NVpwn1Ys/9Cih7OesIYZ4DlzQ6MSKOtaGyQh42mg vzfkN1nwipdA5zgcd1/i0Aa5tNDJe2iTS2zHYBlHQBU0VcO7BcpTYj7wtA05cfX1nT Jm88nJjlnBsNZlkHwX84A7lq64geJG9RupeCavMg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, David Riley , Gerd Hoffmann , Sasha Levin Subject: [PATCH 4.19 027/113] drm/virtio: Add memory barriers for capset cache. Date: Mon, 29 Jul 2019 21:21:54 +0200 Message-Id: <20190729190702.363655497@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190655.455345569@linuxfoundation.org> References: <20190729190655.455345569@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 [ Upstream commit 9ff3a5c88e1f1ab17a31402b96d45abe14aab9d7 ] After data is copied to the cache entry, atomic_set is used indicate that the data is the entry is valid without appropriate memory barriers. Similarly the read side was missing the corresponding memory barriers. Signed-off-by: David Riley Link: http://patchwork.freedesktop.org/patch/msgid/20190610211810.253227-5-davidriley@chromium.org Signed-off-by: Gerd Hoffmann Signed-off-by: Sasha Levin --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 3 +++ drivers/gpu/drm/virtio/virtgpu_vq.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index 7bdf6f0e58a5..8d2f5ded86d6 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -528,6 +528,9 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, if (!ret) return -EBUSY; + /* is_valid check must proceed before copy of the cache entry. */ + smp_rmb(); + ptr = cache_ent->caps_cache; copy_exit: diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c index 020070d483d3..c8a581b1f4c4 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -588,6 +588,8 @@ static void virtio_gpu_cmd_capset_cb(struct virtio_gpu_device *vgdev, cache_ent->id == le32_to_cpu(cmd->capset_id)) { memcpy(cache_ent->caps_cache, resp->capset_data, cache_ent->size); + /* Copy must occur before is_valid is signalled. */ + smp_wmb(); atomic_set(&cache_ent->is_valid, 1); break; } -- 2.20.1