Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp784568ybf; Wed, 26 Feb 2020 23:17:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxdlFC/n4YeGWIc9dS4n4BH4cL4rtmnBzrAUtoTuOjKrG1yg4saYstELVF6WOlHLigLvPTa X-Received: by 2002:a9d:7757:: with SMTP id t23mr2298129otl.315.1582787836793; Wed, 26 Feb 2020 23:17:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582787836; cv=none; d=google.com; s=arc-20160816; b=GgZsYOzOpVNw9yxngtBTti8Hos+ngY2+v3cKxglJo3ytp9jduP+wD/Jh6wci0b3LCC Z5cNPO2MGs0hYuFrHwrtuHd0+Lh13g5tDbHEPllI8sWysZLNHJDgEFx3+m11Oc08iRT/ kaP6WzOjhFaoPVG9LqDewwGRCtcU5pNG7NcJLklQuyRYlJSyRKxUZx0xIXiAO8ohcCYJ 8wxIg05T7qCU1kdes79+pGQT2NbXLM4ec8K06uXqJhPXT4TOcGDcAPXC8Jq8ogeRl/vN 0nWO6uXV577IRsFHKPSbCDww8hSkT7+8JfupSNkFy06bB8dM7WE/A7e6nh7+QUFlRifq DqaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :dkim-signature; bh=nU+/8GmlD/GCH6+QOcAojrASByZ2SvOJf/kDNRU3bX4=; b=CfvpVaOnqfq+uiocSnBRuQq+su0QzenTurXPvK5SintAaVmDHYLELouF8VIZqLF2VH u+tYbK7qbHI86v1DhDhAwLlP/N+FaYT1ggHQ/x8rK9tgpNeL5DQN0q5kpdoSi8KibOjB EtQGqkjnXFL97t8o14zwxa9Ec2Kb2NkWoQc4kpBvL2kRWY2DALW4UOAroO4JLsveDjFw UL9DTV7vRp132EKkRFJyVmG7ll8wzAoXcAJR77ERBhkQrSkGcjzxyfTD6YnCMx+UZF+M QaUFX6jFVY5z9Q4cYc8xW1gjGVFOszfyT2cSB8HL1/i3A0FuP1KAhfHG19URtSo4hxik N3XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@shipmail.org header.s=mail header.b=iJco5cwq; 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 v26si1172419otj.0.2020.02.26.23.17.04; Wed, 26 Feb 2020 23:17:16 -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=fail (test mode) header.i=@shipmail.org header.s=mail header.b=iJco5cwq; 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 S1728273AbgB0HQz (ORCPT + 99 others); Thu, 27 Feb 2020 02:16:55 -0500 Received: from pio-pvt-msa3.bahnhof.se ([79.136.2.42]:55442 "EHLO pio-pvt-msa3.bahnhof.se" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727336AbgB0HQz (ORCPT ); Thu, 27 Feb 2020 02:16:55 -0500 Received: from localhost (localhost [127.0.0.1]) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTP id 0DBF53F619; Thu, 27 Feb 2020 08:16:53 +0100 (CET) Authentication-Results: pio-pvt-msa3.bahnhof.se; dkim=pass (1024-bit key; unprotected) header.d=shipmail.org header.i=@shipmail.org header.b=iJco5cwq; dkim-atps=neutral X-Virus-Scanned: Debian amavisd-new at bahnhof.se X-Spam-Flag: NO X-Spam-Score: -2.099 X-Spam-Level: X-Spam-Status: No, score=-2.099 tagged_above=-999 required=6.31 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no Received: from pio-pvt-msa3.bahnhof.se ([127.0.0.1]) by localhost (pio-pvt-msa3.bahnhof.se [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 9s2FL3lWlzPa; Thu, 27 Feb 2020 08:16:52 +0100 (CET) Received: from mail1.shipmail.org (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) (Authenticated sender: mb878879) by pio-pvt-msa3.bahnhof.se (Postfix) with ESMTPA id ED2B23F56A; Thu, 27 Feb 2020 08:16:49 +0100 (CET) Received: from localhost.localdomain (h-205-35.A357.priv.bahnhof.se [155.4.205.35]) by mail1.shipmail.org (Postfix) with ESMTPSA id 54FBC360161; Thu, 27 Feb 2020 08:16:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=shipmail.org; s=mail; t=1582787809; bh=czSVFr3N8XD20OuzmIfwTeJukmx6qXdkbu8G6D4uGW4=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=iJco5cwq3tifyUhkXULafE2E2SK5e+v+J9B7XYh2qG+7F11JINzsBKZmLzRA9B/2w y2kbglX6cpm9cvR95UVbBEo93uBouanPt0rjIpjhuPqoTbLAvcCHybEOPYpbD0Irog n46IYsNNHpyrXpXirNOiX5dCn1yFly6CK5V20pqU= Subject: Re: [PATCH v5 1/3] drm/shmem: add support for per object caching flags. To: Chia-I Wu Cc: Gerd Hoffmann , ML dri-devel , Guillaume Gardet , David Airlie , open list , stable@vger.kernel.org, Gurchetan Singh , tzimmermann@suse.de References: <20200226154752.24328-1-kraxel@redhat.com> <20200226154752.24328-2-kraxel@redhat.com> From: =?UTF-8?Q?Thomas_Hellstr=c3=b6m_=28VMware=29?= Organization: VMware Inc. Message-ID: <614ed528-8d6d-0179-6149-218566d4af06@shipmail.org> Date: Thu, 27 Feb 2020 08:16:49 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/27/20 1:02 AM, Chia-I Wu wrote: > On Wed, Feb 26, 2020 at 10:25 AM Thomas Hellström (VMware) > wrote: >> Hi, Gerd, >> >> >> >> #define to_drm_gem_shmem_obj(obj) \ >> diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c >> index a421a2eed48a..aad9324dcf4f 100644 >> --- a/drivers/gpu/drm/drm_gem_shmem_helper.c >> +++ b/drivers/gpu/drm/drm_gem_shmem_helper.c >> @@ -254,11 +254,16 @@ static void *drm_gem_shmem_vmap_locked(struct drm_gem_shmem_object *shmem) >> if (ret) >> goto err_zero_use; >> >> - if (obj->import_attach) >> + if (obj->import_attach) { >> shmem->vaddr = dma_buf_vmap(obj->import_attach->dmabuf); >> - else >> + } else { >> + pgprot_t prot = PAGE_KERNEL; >> + >> + if (!shmem->map_cached) >> + prot = pgprot_writecombine(prot); >> shmem->vaddr = vmap(shmem->pages, obj->size >> PAGE_SHIFT, >> - VM_MAP, pgprot_writecombine(PAGE_KERNEL)); >> + VM_MAP, prot) >> >> Wouldn't a vmap with pgprot_writecombine() create conflicting mappings >> with the linear kernel map which is not write-combined? Or do you change >> the linear kernel map of the shmem pages somewhere? vmap bypassess at >> least the x86 PAT core mapping consistency check and this could >> potentially cause spuriously overwritten memory. > Yeah, I think this creates a conflicting alias. It seems a call to > set_pages_array_wc here or changes elsewhere is needed.. > > But this is a pre-existing issue in the shmem helper. There is also > no universal fix (e.g., set_pages_array_wc is x86 only)? I would hope > this series can be merged sooner to fix the regression first. The problem is this isn't doable with shmem, since that would create interesting problems when pages are swapped out. So I would argue that the correct fix is to revert commit 0be895893607f ("drm/shmem: switch shmem helper to &drm_gem_object_funcs.mmap") If some drivers can argue that in their particular environment it's safe to use writecombine in this way, then modifying the page protection should be moved out to those drivers documenting that assumption. Using pgprot_decrypted() in this way could never be safe. But IMO this should never be part of generic helpers. /Thomas