Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp812741ybf; Wed, 26 Feb 2020 23:53:51 -0800 (PST) X-Google-Smtp-Source: APXvYqxeGP/VpDjR58IbYyUjshOs5L/lDkDCoheVLLazN9JRrbIOHYxK/Mq/c304t1kZ04ebqFty X-Received: by 2002:a05:6830:c9:: with SMTP id x9mr2241144oto.345.1582790031414; Wed, 26 Feb 2020 23:53:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582790031; cv=none; d=google.com; s=arc-20160816; b=I7PqIPa7QDHLIbY4dsY0dgl2N87SXtXHcT4LNFuJlq8mzzNVTu5AC1p0MEE8QH4lII P3EEXSHT4vLTSse0vdu7H7A7HcKZWW6IRPgGHu7JwECb/6wTPe+WXKu3Y+1UkQ6vyEqO ghT4wl0lQlti11FbVSReFjMeJS8yHn/XuvJAF2f7+L40zr3N/aAY9RjFhbxoDl83Fuof CIHbAotfom2yPlb4GbPK9iPhUMY3pEIoVvoiQHCEaC3pCl48srczWvBILQzdis2aJjWI 2iFy/6kMk5mtMSszvNYo8qtTPuFfawQhfdfQViIKt9yeFKy8mfAE1r1XrmpyxTYsLQr3 oWug== 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:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=QdZSZmeTi2IR4EjFeqNNXbBpQhhR9pgfAjrS+j97XLk=; b=VQAn8pgyNHhL7bkWbxQQRa+fJQQVN/Wvf9FbiiVtSp5QLlZ5E7d54eLW7MKFnksTP2 8ZQPtDslNfL0V+h1QMpMw4WLOTfWKZPElsIFvQLHKBAwbNMzSqJP2wt/YtE/DaRyb/b7 D3Fy0/RYXM9OiPcieWGRL9sb81Wln+9spW2FK9uCuDrli0SnMwuybJ+jNruKbfRU9epx PeqAPSfx+woyPNYdv7/kuUXVzkgzMEHu7eD0XnsU4avvfZZHcE1QZo4WE/xvfeAls6XX lVNjqieiNUZeDOHINYwi62Mv4B9/9WT3YkVuboFgoIbpUzriG3YlgoahHTAJGNK80b/5 48Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Li4JLTNf; 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 z21si1063509oti.199.2020.02.26.23.53.39; Wed, 26 Feb 2020 23:53:51 -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=Li4JLTNf; 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 S1728476AbgB0Hx2 (ORCPT + 99 others); Thu, 27 Feb 2020 02:53:28 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:33023 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727702AbgB0Hx2 (ORCPT ); Thu, 27 Feb 2020 02:53:28 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1582790007; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QdZSZmeTi2IR4EjFeqNNXbBpQhhR9pgfAjrS+j97XLk=; b=Li4JLTNf/qFaP6bjyZYJ8lNWvdtzd/mK/bhswLIT6pzlT9h/IixeoubKxdHd1yZVW5QKWy F6UqjEklHWam+By/PNRvTiY9PzxjDUKYrtTQw+5muTwEm47wPyw9GGibbWyG9EEvzAKvpj gal12sMYOjTJrIuvqj0WouRSgAG5OYo= 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-452-bVGe7fi4PHm8nrUFOfsItw-1; Thu, 27 Feb 2020 02:53:24 -0500 X-MC-Unique: bVGe7fi4PHm8nrUFOfsItw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 69614802561; Thu, 27 Feb 2020 07:53:23 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-150.ams2.redhat.com [10.36.116.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B10F19C58; Thu, 27 Feb 2020 07:53:22 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id B2A621744A; Thu, 27 Feb 2020 08:53:21 +0100 (CET) Date: Thu, 27 Feb 2020 08:53:21 +0100 From: Gerd Hoffmann To: Thomas =?utf-8?Q?Hellstr=C3=B6m_=28VMware=29?= Cc: dri-devel@lists.freedesktop.org, Guillaume.Gardet@arm.com, David Airlie , open list , stable@vger.kernel.org, gurchetansingh@chromium.org, tzimmermann@suse.de Subject: Re: [PATCH v5 1/3] drm/shmem: add support for per object caching flags. Message-ID: <20200227075321.ki74hfjpnsqv2yx2@sirius.home.kraxel.org> References: <20200226154752.24328-1-kraxel@redhat.com> <20200226154752.24328-2-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, > > + if (!shmem->map_cached) > > + prot =3D pgprot_writecombine(prot); > > shmem->vaddr =3D vmap(shmem->pages, obj->size >> PAGE_SHIFT, > > - VM_MAP, pgprot_writecombine(PAGE_KERNEL)); > > + VM_MAP, prot) >=20 >=20 > Wouldn't a vmap with pgprot_writecombine() create conflicting mappings = with > the linear kernel map which is not write-combined? I think so, yes. > Or do you change the linear kernel map of the shmem pages somewhere? Havn't seen anything doing so while browsing the code. > vmap bypassess at least the > x86 PAT core mapping consistency check and this could potentially cause > spuriously overwritten memory. Well, I don't think the linear kernel map is ever used to access the shmem gem objects. So while this isn't exactly clean it shouldn't cause problems in practice. Suggestions how to fix that? The reason I need cachable gem object mappings for virtio-gpu is because we have a inconsistency between host (cached) and guest (wc) otherwise. > > + } > > if (!shmem->vaddr) { > > DRM_DEBUG_KMS("Failed to vmap pages\n"); > > @@ -540,7 +545,9 @@ int drm_gem_shmem_mmap(struct drm_gem_object *obj= , struct vm_area_struct *vma) > > } > > vma->vm_flags |=3D VM_MIXEDMAP | VM_DONTEXPAND; > > - vma->vm_page_prot =3D pgprot_writecombine(vm_get_page_prot(vma->vm_= flags)); > > + vma->vm_page_prot =3D vm_get_page_prot(vma->vm_flags); > > + if (!shmem->map_cached) > > + vma->vm_page_prot =3D pgprot_writecombine(vma->vm_page_prot); >=20 > Same thing here. Note that vmf_insert_page() which is used by the fault > handler also bypasses the x86 PAT=A0 consistency check, whereas > vmf_insert_mixed() doesn't. vmap + mmap are consistent though, so this likewise shouldn't cause issues in practice. > > vma->vm_page_prot =3D pgprot_decrypted(vma->vm_page_prot); >=20 > At least with SME or SEV encryption, where shmem memory has its kernel = map > set to encrypted, creating conflicting mappings is explicitly disallowe= d. > BTW, why is mmap mapping decrypted while vmap isn't? Ok, that sounds like a real problem. Have to check. cheers, Gerd PS: Given we are discussing pre-existing issues in the code I think the series can be merged nevertheless.