Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp3940101imw; Thu, 7 Jul 2022 09:57:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t7EcS8pzWsf3Er3rCgRPuWya7t6S4E82J7Uo4AmzBsvvUMaus02PL2C/8BQzAYYnv/TBE8 X-Received: by 2002:a17:90b:28e:b0:1ef:9a42:d8c with SMTP id az14-20020a17090b028e00b001ef9a420d8cmr6366976pjb.54.1657213056814; Thu, 07 Jul 2022 09:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657213056; cv=none; d=google.com; s=arc-20160816; b=SjILHIx40bVvHi3IRPhdHM+Itug5Dxz4hSoHG6NIgQ0ojne7/FXgy0DNlxuq7XM9qd 5nQQysNrAF4RJEAKtLLh87JN0/TscoO7RK+Ty7nlEET+xZ9OotBlr/HfzG1h1mEsR0mw v9OSeT8XcLEDli/gCGfMxs3Lt0kg8SjhG8At9aqh1iT9ejuaReSGNLg+9vbTRkKMc93I +Krw7BiXtOR0QjKyJDrbnd9HaCqh9u7PBbm3m2goo+KZ8mmIDOMujbVawXTnDaQ3yIbv fd4ellfTiX1AgJqMOO4vIdik/xK7TywUa3zqSLmWAx+n60HHbOtH31FNf+qOz6fXpaxV un8w== 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=byJXkHiXahl3kH7LFsGhd1c0cETN2rfQYX+DSBgMe/B+2a2OuOK1NbOYFSc1JRfzAY WarRmARsafXvtukl+0pig63MhYd0ZnYSRIrnL27TSPz/BnbwLC2oe0lc6iCebAPaf5gB 7digtXlH1oD0OgW6C+11pkka4ozOprQ3ANbUINqO3QpzgvLKTth58EiUZXNaDFel2u2A 0mHUNHEwhkwgRoF0wDu8O9ghpef1BNea8+eaXzRhXAH/B5MToafizND79o94UEPgE+cG jXrM/vIy5wY2SpVhO3X1DtWFdFmd/dGAczgNumyP+T3HuZCSffd2dG+5/pnhYeZmtAHh CFkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=YS9jOYNt; 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 m23-20020a635817000000b00412c36341f0si3745297pgb.766.2022.07.07.09.57.24; Thu, 07 Jul 2022 09:57:36 -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=YS9jOYNt; 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 S236280AbiGGQhG (ORCPT + 99 others); Thu, 7 Jul 2022 12:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45122 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236208AbiGGQgs (ORCPT ); Thu, 7 Jul 2022 12:36:48 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 447A1326E0 for ; Thu, 7 Jul 2022 09:36:48 -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 D2F2F66019BC; Thu, 7 Jul 2022 17:36:46 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657211807; bh=AgP5Riz/FHb587iBL1vYiW/g4qmDc92BtRCaR0jjFGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YS9jOYNtPuzqA95YrPDFVvYrVJBTJd5k9Itt7n8Kq8m+U+ucKnnozKeA0Y/Pbz/w6 kXlUutnOopNomSwTk7zVbDD/9I6oJCm3F03JSgTFy5uhda0WX5OkfUeea4fPnYPDaf b5OX1mTAaS1CuVUdh5T0EMW5JcOn0yQkW4ge00neZq02mv86SidJLTxBg5KfrFrMJs /k2rTxgl1yKkG5a09GiRBe451/BiPYLMURzpYV986jH01u1+OK3oNZNaEv2AGWcPkS DtqFAs5orb8/pH8Q+8lbgXUAYgLz1OrM3uE8YGfF5iSvJSJzNm+QRHPvxnCjbb30Vx TLGzUUlpeoP3Q== 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 v9 06/11] drm/i915: sanitize mem_flags for stolen buffers Date: Thu, 7 Jul 2022 16:36:01 +0000 Message-Id: <20220707163606.1474111-7-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707163606.1474111-1-bob.beckett@collabora.com> References: <20220707163606.1474111-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