Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp723059iog; Fri, 17 Jun 2022 12:07:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1spQtkZ339iseyG8TuBLDjk3SyXLvG9R5gd5otsRVf11t9dszMZoiZyG6g1wVinPHzikzr7 X-Received: by 2002:a17:90b:4b49:b0:1e6:8827:aaf1 with SMTP id mi9-20020a17090b4b4900b001e68827aaf1mr12057127pjb.154.1655492841987; Fri, 17 Jun 2022 12:07:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655492841; cv=none; d=google.com; s=arc-20160816; b=DC6WYRVwYWLxT9GORTMs5CRXLP7FmcxpwLKbDHFZ93LI4PWK6CClBA9sH0xmuRAhVP 7LJOurWJzJ00/Wa3CayDOuPmKCG2Rn51dRbO28EzrqlKG4vFIKDirjqW6RAL2m3I3CTW IW51kj5mRJ+pUapCjI/s53d+zBzoevd/tWEBr7k7lWzOKrvNUy2+wFEA66FkMBVDLcQF 5bM5/yOxwKaljWnzRQSlRbTtmSyCmNgRBANdJV8tsea0tqo3YwvDD+Yc4Y47Z/eWkBtC MS2riOeHr2W+y2RXkhqaOmEuD5y6XDDQ6jsI2TG2aUFfJE7aanMxR0ZHKHICLqPbUVWk j8oA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=inrToJYqh+AVbPpVVycxU36yUfofZZHNmSUpH5oeKRo=; b=RiTJr0VJcD3o3uZqmlElFhJjaFWu/aDAvQcEu8DRrnRMaSPnPhHgLm/ZeXQK9JMq3W R50W1RAazujcaWmIhzlty8mnjc/1Vliwe56fHCxmXmjS+twwqzeQRBRCt+2kDoBSj47r tf+YlzrF4fyWlL3SYLjQEtKiJJpajI+sPOdulU5Q8C5yWRgQXWb9f6gwuEp9FPGalycW UlHOIAL022b4OPaV0X85LdgHSZeotQL/rR/ebH5hm1NZzvlQ35Ecyo+Ybxv0shfz3W1A IKj5zN+IM4yqGS1Wbsw29y9pGsQ8c+Ny2wXh1S1pQFABSSvlmIrkInsEELVzOrVvyHWs tGEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i0IJQ4CM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e3-20020a170902ef4300b0016901ea5b20si6676204plx.466.2022.06.17.12.07.10; Fri, 17 Jun 2022 12:07:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=i0IJQ4CM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235797AbiFQTF7 (ORCPT + 99 others); Fri, 17 Jun 2022 15:05:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234889AbiFQTFr (ORCPT ); Fri, 17 Jun 2022 15:05:47 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e5ab]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B7F45795 for ; Fri, 17 Jun 2022 12:05:46 -0700 (PDT) Received: from hermes-devbox.fritz.box (82-71-8-225.dsl.in-addr.zen.co.uk [82.71.8.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: bbeckett) by madras.collabora.co.uk (Postfix) with ESMTPSA id 79CA96601856; Fri, 17 Jun 2022 20:05:44 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655492744; bh=AgP5Riz/FHb587iBL1vYiW/g4qmDc92BtRCaR0jjFGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0IJQ4CM1JVpElwf2AKhAy23FWvVZ30CQEKxXqA/ohJKbUAyoKnY/4qsB3LxifWKl +BUx8fo0BXRnHFUjAKUQJi946Y8wuLAIqKptm63nSm76kDiER5e2QvC5STkDH41aLo jX2tFaizBFg2BUwQ6l9jxS5vEA7tTmpwd93ygXKVhU1qAUH75fCvFa8F+iGZMxj/V7 iVAqDp5jDB1Jv0epMXdgk9KccLklx+jZkjHSbpkHB1BPrLJXi9jbWcaajIPzH8h2T5 N33fcSGQngUR2zdUK9wq6dmvcGeVaAThMuvEK6c1Xyh4cb4oNOm3Z81Thq0zPBlaCt Cz3/npceisA6w== From: Robert Beckett To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter Cc: kernel@collabora.com, Robert Beckett , Matthew Auld , =?UTF-8?q?Thomas=20Hellstr=C3=B6m?= , linux-kernel@vger.kernel.org Subject: [PATCH v6 06/10] drm/i915: sanitize mem_flags for stolen buffers Date: Fri, 17 Jun 2022 19:05:12 +0000 Message-Id: <20220617190516.2805572-7-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220617190516.2805572-1-bob.beckett@collabora.com> References: <20220617190516.2805572-1-bob.beckett@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Stolen regions are not page backed or considered iomem. Prevent flags indicating such. This correctly prevents stolen buffers from attempting to directly map them. See i915_gem_object_has_struct_page() and i915_gem_object_has_iomem() usage for where it would break otherwise. Signed-off-by: Robert Beckett Reviewed-by: Thomas Hellström --- drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c index 675e9ab30396..81c67ca9edda 100644 --- a/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c +++ b/drivers/gpu/drm/i915/gem/i915_gem_ttm_move.c @@ -14,6 +14,7 @@ #include "gem/i915_gem_region.h" #include "gem/i915_gem_ttm.h" #include "gem/i915_gem_ttm_move.h" +#include "gem/i915_gem_stolen.h" #include "gt/intel_engine_pm.h" #include "gt/intel_gt.h" @@ -124,8 +125,9 @@ void i915_ttm_adjust_gem_after_move(struct drm_i915_gem_object *obj) obj->mem_flags &= ~(I915_BO_FLAG_STRUCT_PAGE | I915_BO_FLAG_IOMEM); - obj->mem_flags |= i915_ttm_cpu_maps_iomem(bo->resource) ? I915_BO_FLAG_IOMEM : - I915_BO_FLAG_STRUCT_PAGE; + if (!i915_gem_object_is_stolen(obj)) + obj->mem_flags |= i915_ttm_cpu_maps_iomem(bo->resource) ? I915_BO_FLAG_IOMEM : + I915_BO_FLAG_STRUCT_PAGE; if (!obj->ttm.cache_level_override) { cache_level = i915_ttm_cache_level(to_i915(bo->base.dev), -- 2.25.1