Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp4146859iog; Tue, 21 Jun 2022 13:04:01 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uyx65fCwiAWVbKfOLgSOKblLQDDaODhGVRTC+03as5A0r3k2wzW/+U2HqB4Ros9vO9gPBI X-Received: by 2002:a05:6402:5021:b0:435:1e2a:2c83 with SMTP id p33-20020a056402502100b004351e2a2c83mr37189943eda.345.1655841841279; Tue, 21 Jun 2022 13:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655841841; cv=none; d=google.com; s=arc-20160816; b=PubWnATp5AbT3HNlEIxUSE1Rxu53tADLkCG8JZczzV+V49fDrllfqU8bt65luFNQL2 TV7txsDHhewLViO1DpDSHE2x8VEAakGaQmkoW3H9Ln47RlrlFYbxgjg7pzJR7I7WuMig kEEAxFFvpe9rnr19CKKh1z2yw5+Ntyxemjl1OLcBOvmsgY+pqW/AVDYZIBZKeCX+Y/se Vn0KGfr6iYbkjk8KrT1DGn2JYYCf7EI1z2T0IOkP8E/GnSTp4XcMGwmYazaUNmohza+4 ken4KHB7yy/cK7g6hIVSMA20qAD8VivXHugIATc9n+wLM2r6ISsknEAF8sQG623hUcrK jrBw== 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=wsxzMLF/yEeHZB6teNm6fmiy+Fc2nkC+JFGZSnOEHtra6pLydLiXURGuRuqgCloX1j dBxW68oP2/UyQSZ+Nvj1yHDiBUQQylApUersAlmZPka7FtXXj2GuC9EcnICV50XfNLhf DFwpWb4+8StwMNvBrcxqn7pRKo7ePp+gSlQYhHqgq5hFb9cV3aRC0O1e21WvkeyAJ94S 8Zx0ih69OsTwhhTyK2k+gPjW2QTeJ+tkJ051pzFk4Mx1Co4DlwVZ/mtXlm1hkaCMJIyW rwdAS0DYS2t/mcjbbyedHaRq7wZ+V/gf5YKzsf4TWinWKKUgNjutZJebuWJlk97syMKR QWLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YwkkW2sz; 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 qk38-20020a1709077fa600b006efb71530d8si19425253ejc.859.2022.06.21.13.03.34; Tue, 21 Jun 2022 13:04:01 -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=YwkkW2sz; 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 S1354220AbiFUUBn (ORCPT + 99 others); Tue, 21 Jun 2022 16:01:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353374AbiFUUB1 (ORCPT ); Tue, 21 Jun 2022 16:01:27 -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 7E77729806 for ; Tue, 21 Jun 2022 13:01:20 -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 EFB416601853; Tue, 21 Jun 2022 21:01:15 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655841676; bh=AgP5Riz/FHb587iBL1vYiW/g4qmDc92BtRCaR0jjFGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YwkkW2szc59ejHUw0SzvioMn6cHxM/hnFosRAIAUxdZBqOaZ5xFK4f3bghAYG5Cv5 /oZz66OmyTyDo6OAkMSPwMvRPFDdCcW/hmMmwU5c/VoOOkWZm55tErEdl6qyKIV8Es x57ImaiXaBZVEOm9X9PTspSFweFIct4AOtr5+TJKEaongclhvzebIA3wmP7EbNxWyO TPvLRj4tAsTIatSZgI5Gt0RmnMNHVy26p7n/szHR3uG1DN3UNu+AQCwS59i92Gt4c3 kTfkkxtNMjNSxhGHl42M1zKfI+Mka6UW8xXGRMHLexACEGZVX1G/vc+G8h1TjGlUiL VHlAYhHxMBIVw== 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 v8 06/10] drm/i915: sanitize mem_flags for stolen buffers Date: Tue, 21 Jun 2022 20:00:54 +0000 Message-Id: <20220621200058.3536182-7-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220621200058.3536182-1-bob.beckett@collabora.com> References: <20220621200058.3536182-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