Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3816407ybi; Mon, 29 Jul 2019 13:11:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqx+EHaF5NbKzNVdI4BLxafruB0KXCmn0FYCqCp06pe/Sc+aXNuCaNoixYuNnI/LV4zmEQaU X-Received: by 2002:a17:902:5ac4:: with SMTP id g4mr114391065plm.80.1564431078363; Mon, 29 Jul 2019 13:11:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431078; cv=none; d=google.com; s=arc-20160816; b=RoanzuB6pUM/8Aw7U1uko3xHM0ke/O7JBON8clM4LbWFBuDjSxTDAzMA5E1Caf8gfD unML1Uzl/KFEGfnCdcYGH5sGiOiHafD9D0GQChaw7bPJT0NvDnADzU8dv7Qzhl6sG4iE +6+YA8s1XX/OqsR2qCPtpFDJWSnyX3L1KteB1LyTNgLrJWdaYahk8QHgkW1RUONsT8VI kYUiM1v7opPRFYCYlJZJefe+/k2M/Na/uwNmQOZ52Yv6XUKrxWHot7tKxZv3XUyjGmY6 Aryu8PH+hT8TqtzK47Rwng1zfoCqNfzTaHdK4HLjhHmb6xhSeOJL8MDIuhQLq2Wktjre tBKw== 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=ppDRTrFklT/YhBOOxL/wHqvYgUYb/PHl1c7+L+/TC7g=; b=hhQG4vDl8kgYc7G42lzYklVhKJwvqq4R0LmflruTSUWNcIwo8Y83Dib0SK6KCBj9mC Q0hXgnZWtd+NuBOb9b6Y6PCCY6PN2/fZL8zlh7w5/AnBzS44ZRvAlydynxfGxsdNM44F JF/+nsoyUcwxXzF2PPb46CTnEnORIYHnnMW+sOIckNa5tzpa24fjaMq1UczYJz4lbEiH pVtuA/rX5XWs9kyPSlYX2bzMPoFnaTQaxLSHkgi6RsPabR8WGyTgvCkaEGTAgUW1iLqK k8CY7K/UZvgfl9G6j9c2vYLhS9aakxel/e3W/2sB6tmmG/hh203LB9A0A0SUN4uwgP2t Dmow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=V5i5i2i0; 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 z1si28322350plb.41.2019.07.29.13.11.03; Mon, 29 Jul 2019 13:11:18 -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=V5i5i2i0; 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 S1730145AbfG2UJv (ORCPT + 99 others); Mon, 29 Jul 2019 16:09:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:50064 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729794AbfG2Tfn (ORCPT ); Mon, 29 Jul 2019 15:35:43 -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 CCA3A217D4; Mon, 29 Jul 2019 19:35:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428943; bh=ZGWD3sUV9uHaEwmTx4a0VLY6cZXDAmvPWcFM/D4w6YY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V5i5i2i0fEWv/G/6K3NhQdsdlqW7iUTehHXyDkQAEUN7mlDEp4vQ/3WX31LTae1rd GBWOlwDt9TgpKIRA0+OHiAeU/wHfBxMWx8bTqxncsGpmrTM2iDs3DZJ5Wfg8i5+Brq 5GRuUdybzOft9wInMXPWSKZY6Sza/QLrNaHpfSbM= 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.14 236/293] drm/virtio: Add memory barriers for capset cache. Date: Mon, 29 Jul 2019 21:22:07 +0200 Message-Id: <20190729190842.535102914@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 ed9c443bb8a1..40cc2f6707cf 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -523,6 +523,9 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, ret = wait_event_timeout(vgdev->resp_wq, atomic_read(&cache_ent->is_valid), 5 * HZ); + /* 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 26a2da1f712d..21c2de81f3e3 100644 --- a/drivers/gpu/drm/virtio/virtgpu_vq.c +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c @@ -585,6 +585,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