Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5143194ybl; Tue, 10 Dec 2019 00:59:59 -0800 (PST) X-Google-Smtp-Source: APXvYqxSy8aqTZ/raOWAQXHz6CnZZERq2VbRdPqomeZ8rGMP7kiO4AcrPMGfkJpGEq2orkjvNKFT X-Received: by 2002:a9d:7b4e:: with SMTP id f14mr25476530oto.355.1575968399711; Tue, 10 Dec 2019 00:59:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575968399; cv=none; d=google.com; s=arc-20160816; b=kbidKkFG6sYmB+6e+fTLeOchhhLJF0p7HGfVrXtn9EXSBsMQIFPmQJcsFQMJgcp3DG pYEyw0FnrMFePpIA7BjS38KS1o5tXYnVViJp0hu2wZ5q55+Gfs7pH5aQ99NZmS4sr1t+ gZRug3vWYMIiyZ7qq7T0RIRbGSK1+pcxM318TnsM8OyX7r7CU1mk7J7F2ZM0kmB66kCD zJE7tBeYod6HiI4lrPYg/jBDZPvI0C6CYyTEfZ0VEd9v5V5IEaT9waJDq9lK2SOYfQna 8XXnJH8D4dcuMh+oWVjBtZetuuv74LJYu201lS3R24lprfUpVBRvjkhnFW6o7RQWSQJ5 c7OQ== 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:message-id:date :subject:cc:to:from:dkim-signature; bh=B3uP/SCLcrRR2RNPhR22qrcwSwHoRfQCsZKJS7KksnQ=; b=k9bRbA7bp2n3fMDZsMKep/HGBs9IyV98HRZhzqsf/USdyg0jH3xmPeda6FOd3hPLL5 cxAJ0mKefkJ5kKxg4sMYKCPT5l1eef06R5F1bDs+ZkUFrqBZZJD1LZuDBDAR6SkBNcO/ J/3M5J4C0awxVhGzfoheQOair+fQH6YioRJ3ZELQmI8qmzgPMkhOrdCiXba35zi84oLe DKPATVN0RBO4vkUgD9zfv00YlHHMtEowsmGmDkyNdWjjvK1Hm9UdBZvrdQWYzE5MH2PR HUO4FH9MHLWGvqe14ldBWjUtGTLplrmPtWg0dBJIM25yw8t4MqoOvKzLha27M+QPTnkr Mjsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VC4m+eGQ; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a197si1495769oii.199.2019.12.10.00.59.47; Tue, 10 Dec 2019 00:59:59 -0800 (PST) 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=@redhat.com header.s=mimecast20190719 header.b=VC4m+eGQ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727061AbfLJI6H (ORCPT + 99 others); Tue, 10 Dec 2019 03:58:07 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:44470 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726847AbfLJI6H (ORCPT ); Tue, 10 Dec 2019 03:58:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575968286; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=B3uP/SCLcrRR2RNPhR22qrcwSwHoRfQCsZKJS7KksnQ=; b=VC4m+eGQ6oH95ORhmLzG8U1x8ML66UTQmCiuTYY/aFW1LCpdj0GithjWaQI5u2ppREvBbN FKovdk90BEwBPeBxROqvWax6TGgXPsbkE7rst4lyoG6kaAHh99UKjjZ/nLZgH2exPL+dxm vR2SJ5xQlW8K7fpSfjJFJm7fuOLzIe4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-227-5yTMreCZOyGtterTydZw-g-1; Tue, 10 Dec 2019 03:58:05 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA41318557E6; Tue, 10 Dec 2019 08:58:03 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-67.ams2.redhat.com [10.36.116.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E04E6F12C; Tue, 10 Dec 2019 08:58:00 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 95C5E16E18; Tue, 10 Dec 2019 09:57:59 +0100 (CET) From: Gerd Hoffmann To: dri-devel@lists.freedesktop.org Cc: gurchetansingh@chromium.org, Gerd Hoffmann , David Airlie , Daniel Vetter , virtualization@lists.linux-foundation.org (open list:VIRTIO GPU DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/virtio: fix mmap page attributes Date: Tue, 10 Dec 2019 09:57:59 +0100 Message-Id: <20191210085759.14763-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: 5yTMreCZOyGtterTydZw-g-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org virtio-gpu uses cached mappings. shmem helpers use writecombine though. So roll our own mmap function, wrapping drm_gem_shmem_mmap(), to tweak vm_page_prot accordingly. Reported-by: Gurchetan Singh Signed-off-by: Gerd Hoffmann --- drivers/gpu/drm/virtio/virtgpu_object.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_object.c b/drivers/gpu/drm/virt= io/virtgpu_object.c index 017a9e0fc3bb..158610902054 100644 --- a/drivers/gpu/drm/virtio/virtgpu_object.c +++ b/drivers/gpu/drm/virtio/virtgpu_object.c @@ -75,6 +75,22 @@ static void virtio_gpu_free_object(struct drm_gem_object= *obj) =09drm_gem_shmem_free_object(obj); } =20 +static int virtio_gpu_gem_mmap(struct drm_gem_object *obj, struct vm_area_= struct *vma) +{ +=09pgprot_t prot; +=09int ret; + +=09ret =3D drm_gem_shmem_mmap(obj, vma); +=09if (ret < 0) +=09=09return ret; + +=09/* virtio-gpu needs normal caching, so clear writecombine */ +=09prot =3D vm_get_page_prot(vma->vm_flags); +=09prot =3D pgprot_decrypted(prot); +=09vma->vm_page_prot =3D prot; +=09return 0; +} + static const struct drm_gem_object_funcs virtio_gpu_gem_funcs =3D { =09.free =3D virtio_gpu_free_object, =09.open =3D virtio_gpu_gem_object_open, @@ -86,7 +102,7 @@ static const struct drm_gem_object_funcs virtio_gpu_gem_= funcs =3D { =09.get_sg_table =3D drm_gem_shmem_get_sg_table, =09.vmap =3D drm_gem_shmem_vmap, =09.vunmap =3D drm_gem_shmem_vunmap, -=09.mmap =3D &drm_gem_shmem_mmap, +=09.mmap =3D &virtio_gpu_gem_mmap, }; =20 struct drm_gem_object *virtio_gpu_create_object(struct drm_device *dev, --=20 2.18.1