Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3797425ybi; Mon, 29 Jul 2019 12:49:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqxA3uTYc5XFVjzx+05NCx5JOdJmJkh6zPddXpVnLlsVz0/OXcU5T0Ykm0IoaO3qNRYZcyYV X-Received: by 2002:a17:90a:b394:: with SMTP id e20mr112647198pjr.76.1564429771449; Mon, 29 Jul 2019 12:49:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429771; cv=none; d=google.com; s=arc-20160816; b=W7EmOFl0yjhTK1HT9j0GyrSmvKVQ8ID4wB43IpvJ8Y9HJpLUrsAqZ4NLv6i3Za1Ze4 dYoMiPVBRmrd+YEvFiEQD7yra2D2fTkKL6v5CzQ+8FyTteyvs91x1i7bSD+F3f8EK45Y AcENr1csVxTpNjADrsmu1X6viEI/78BfHJEFiRW6734exCZ/WpBsH8n48Kl68xlhmuT3 xhPsuoJDVwDeSCUQpOJwmb7H0vvpR90WYU4/3kCMM20dbY0ZSwtpGjEHgAIpCWPUx20Q HlPix+2kaCq+/GbLG+WO7HGypKHdXkGIYUBGCrEw82kg/guQ0zUGMOP06BMvtFwTkaJc QOBw== 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=0f0s6iLVfdfJufTxD0GTwrWISfrO5NOD5tI9y9MEliI=; b=B3uaFl3rM1aaBRUDI4nzReU1xnwmQxddKJS9NiFKSEfLKqhH+lv/hhzTIXCI+dXsu/ 4ptSU713QCUReIuNiW/NoX26ncxdRAUJTiXQkCtD+vkz4FDp7gnDRevlFm9h6wsw9S3M L0NIkiX0Ge8GWygiXq/0Udg8Hm05Jn3yanzZ//s9jYevLBtRk+3vxwG/JJZu4EvHkMEr rhtV+q6uo/fdt4PEpGb7Zgs8T+fniDS55rbFxwlEmVDVYQc6OWu0bvQo6vfshtPskEY1 fj5UIJ0vtPNjyAis3zyMATnt6db5l0QOkv0fs7k2kL2Zbnxqy0L+lZOvOWwV8oG1wbWh wyrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=OH4KhzE7; 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 g11si27995930plo.433.2019.07.29.12.49.16; Mon, 29 Jul 2019 12:49:31 -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=OH4KhzE7; 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 S2389831AbfG2Trv (ORCPT + 99 others); Mon, 29 Jul 2019 15:47:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:37626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390380AbfG2Trr (ORCPT ); Mon, 29 Jul 2019 15:47:47 -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 EBC8C2054F; Mon, 29 Jul 2019 19:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429667; bh=+q4NSSOLfFejeKgjm+a4Zt1g+dMeLao8no5g7S/GTkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OH4KhzE7YFQgBNtBmHrGZr3SZ0USh7Gwi41qyaBSjtCOkCyVSIXh9sH0CHsfvdaY/ xIaTYgG6FClex71Zmk35qZfGakFIJ0tfbWY9t9qTt9ANne9pm9SLMlJ7rz9dyWueSU xDMflESRVKNoBySD0yySxHXL+RCCXZE2i3KqXFK8= 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 5.2 056/215] drm/virtio: Add memory barriers for capset cache. Date: Mon, 29 Jul 2019 21:20:52 +0200 Message-Id: <20190729190750.215529932@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 949a264985fc..19fbffd0f7a3 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -542,6 +542,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 5bb0f0a084e9..a7684f9c80db 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -583,6 +583,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