Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4121118imw; Thu, 7 Jul 2022 13:08:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vOsr5lzg0gYouzjnrvjMF7AcnrgD/0DIXt5D/kgoRtywZR0HAjTjCOk+F4ryZh6NkOmVI2 X-Received: by 2002:a17:902:ab8a:b0:16a:7cf2:a394 with SMTP id f10-20020a170902ab8a00b0016a7cf2a394mr53515587plr.26.1657224512752; Thu, 07 Jul 2022 13:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1657224512; cv=none; d=google.com; s=arc-20160816; b=WyiyjtGD40Zot82XQhokYmuGIqXJ5+hSzpZWDoP/SVdt5OtTyvGx7K8CBZWPP3pTno mRuHL0n+p1L9pkWqEdHVUTbcGaC0Aj/yau6o3CQx5NqC6+k4+QDDoYdxcZvRFP4IQtHs /hVtg7wDwSLgR1GXEahTUy3bZm0GX1QUk/6gPgFe/QbXgkPqkUdrkH/gaRF5fuh1xtRO YpNaaRNBdHruLsJjbIoS/wye3wVw2v1nSK1YR10xEgRtXb4dGa9pYgaRcH+4yfGJ2TNL YkAPUTnQayrNebdul+12D4vkIw6DpYTd4O/lXzKeT2eZpo9wqhuUdaDD3zuw8/O8Z9dL BnRw== 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=hnoebSM+fHAc5drDsQoxcrocx/U2ULws/WT71rhGQtrMqNQje3zFYv93z047La3ZOC YGyyyOHawyvuxpT/dvbvof9lPSwX1gc9mcPrtBg4LXxwhUqDqqs0rHkOjb3OP+lAu8lJ nXPjy2FwsLhCU8sSaKkJH4zSVwJ8FV2MRpt+2TwCkVBm4Lq+kT/6mNxObgTDW0dFABu1 6pSipaPO6B0T2OQqS5vlQV15h2tOAG1hZpjCqhqnqqCc4SriBEww4n+gQLfJ4ejtIrac CXSUtLJLw/2cW7Mj1ZhBcA/Kzyp5dFDrZSYYBED9EUXT3X+1sVt+KctOSLHrRTD3N84G z4fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=c3A3YQU4; 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 j14-20020aa78dce000000b00525b6206e22si32601536pfr.163.2022.07.07.13.08.19; Thu, 07 Jul 2022 13:08:32 -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=c3A3YQU4; 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 S236602AbiGGUDB (ORCPT + 99 others); Thu, 7 Jul 2022 16:03:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236609AbiGGUCt (ORCPT ); Thu, 7 Jul 2022 16:02:49 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 664BF1EADF for ; Thu, 7 Jul 2022 13:02: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 0FB3E66019CA; Thu, 7 Jul 2022 21:02:47 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1657224167; bh=AgP5Riz/FHb587iBL1vYiW/g4qmDc92BtRCaR0jjFGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3A3YQU43mD8tHoWDu6hmqoZ0rPpWu01rTbGnvF4TSgJEBEs96Y3CPDjSXrDMcPWp 37wFTItIVXgx7iJ7Uu+rr4dNvNaqWjNqGIaHkvjsb7N6Tum3qOAQgo7oRsPruywZdi O/uzPKUQLt4w8PEuN+iIZHlnBxKXtgDdj8JEYd7zjzZgnltAXlLSXKK81era0eVTUz deeUuVlLP6ly6deQeqRczfX2LlfwqLtnwGl3a1RtbHDTmVxFl1TJn8exIgRhq8Jn4n KG9ZiNne4MMdXmVhXXC19GMzBCKqciKV1DRtknRjHvaVVPeyMLYGtUJgqEpNcI6L4H FQ4IGo4dW6zeg== 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 v10 06/11] drm/i915: sanitize mem_flags for stolen buffers Date: Thu, 7 Jul 2022 20:02:24 +0000 Message-Id: <20220707200230.1657555-7-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707200230.1657555-1-bob.beckett@collabora.com> References: <20220707200230.1657555-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