Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3098028ybi; Thu, 18 Jul 2019 21:00:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzhjdIIeM+d+mQqKjrxIr7uFhoBz87pdvkbv5+R2OuJaDiN6no9eHGfbr+ULU5Jg1i5x1s6 X-Received: by 2002:a17:902:1e9:: with SMTP id b96mr54733137plb.277.1563508807804; Thu, 18 Jul 2019 21:00:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508807; cv=none; d=google.com; s=arc-20160816; b=OyjgnB6KWXCxDdA9cyqTnMumgLWz5bDS2mFsPI/h7wqdvkx/+IKUbgeG7yME6/H2SS sCn+9AkCqcJ6zKc6DqpIKnk3GloApRkGnZYs4TQbeFdgU3dSWgFK7UUII0XBgXA5l47u MN5notyFKzhpBpI3Liz4rn5r/5v8xtOP1Gu2PDEsme0vtjUPhxA30kFXYTJuw9cdkRNx 9GJB+aHiqf7n2/bMYZR9ptTN0kQwy6Nzf8VIFagThk/TLJvNG3dzZNgFzLFnxdhW7DP1 EDANGUO+ZkEdYTr3/CVKEoObQjtdJDjIFWplJUPcsH/8CIEZorW4WRqkCyVOY6s8cMnU O4HQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=DC+SbhyBZEkXSFveBYr7VYFm59K6RCGAMIGyPCaUns4=; b=Xcs6QdMYBCIzlvq1sT4L7GAsxx7Mn+ITpBGZL6N52KRUw6cDSrEV8MBAXvWVYMpavA qMxbLKvofv8+GFQPSofdPsL21Co0nwW5Ezk/F2XRk4To7u9JgEoBTfaQKALo/Yr+peon XIzCyG4L5mPW6ZaH6jaGS/CDFpZ3pBkOlCEPESnHepOC7pf88TEzxi5rhz+pAtDrTtth GnV2AUzRi9A8+zZBhYdnH2G2Na2FcwCc5JhZA1FJcGA8IRkkwGFlova4aDPq5hEbeT1w +5lLYjN100CndVRetU4E0NV5aRTxDqQ74se9mrPE/ki3kBMPVe5mRS01Q7nHqSPZFBs+ CuFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UNUSlW4L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6si3409789pls.145.2019.07.18.20.59.52; Thu, 18 Jul 2019 21:00:07 -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=UNUSlW4L; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728300AbfGSD6u (ORCPT + 99 others); Thu, 18 Jul 2019 23:58:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:58158 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727016AbfGSD6q (ORCPT ); Thu, 18 Jul 2019 23:58:46 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7064D21873; Fri, 19 Jul 2019 03:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508726; bh=J8yg1JMnlCbaWL6cdq7le4aMJLf01ArsHpijP5jmHeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UNUSlW4LxU7CDYItQ9E9EPQk7r2o+O8PTuEOLFOYtfy8bNNIlRycrlIPdhgePMEq5 I8dsbW46pbhBP+ZmqUveEjwjx9/GwS4kHF5s3lMoluv6OXiqCZkV2ubM07br55MFE3 Qeofr3/vy0HUwG1GDgOjmON793B33uvP/22Iqi30= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: David Riley , Gerd Hoffmann , Sasha Levin , dri-devel@lists.freedesktop.org, virtualization@lists.linux-foundation.org Subject: [PATCH AUTOSEL 5.2 054/171] drm/virtio: Add memory barriers for capset cache. Date: Thu, 18 Jul 2019 23:54:45 -0400 Message-Id: <20190719035643.14300-54-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Riley [ 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