Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3254361iog; Mon, 20 Jun 2022 15:19:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1srQ/dVfbBOqZAixgGfN4B3NRK03RWQQC89wq34ee7N2SEjmxGROBj8DpV5yJX/oWk/3wXB X-Received: by 2002:a17:907:3e1d:b0:711:dc92:e308 with SMTP id hp29-20020a1709073e1d00b00711dc92e308mr22718335ejc.235.1655763588650; Mon, 20 Jun 2022 15:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655763588; cv=none; d=google.com; s=arc-20160816; b=BIeneoX91I5vyrRdQU7/+U9/toRMZQiGbourR4T1pnWqgVv//0Zura5aMQfCFZ+bTb pry2CeKXKJ0g3drkEivCBqFCUUBpQnTmFtOzt0ZNuTOP0X/0kOBrrq2O7XRuMZUS5VAm tSXDDjvHFgKSgB5KCP4XI7VXVKBQRKKs3LfYNuH/Db+Ruehy6VPUKxN59SUaj2jcsHYa /EpNoLSd1v+pvI8YzEa5Eog5ghigk2yyVBZb8lX2GXEh+WvC4rTsang+hXm5xS+2aHac qsiDWrKtglgxOjIbGc0VejARa8lbhfopQGTzWjbEv0Ex2Pb/DmpevCcUpJBa44rk3Hzo 7f2w== 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=rl6w/cQMs/cfgDaaOudeSHMyCAanQYWVGqECHU8Jvk6RxzZTenFRCkQcS81HRJab5p 7MWhvJ74NlA+uTLj0JGZx/zOn1MLk+1gCWHRS+GQKh7swxV6U7XczKSrhqSefP0tn27o 3iWSNoqviyB4iDkevq6HmGwoKxufsJaQXd0qZLvWZCnUFEghKO3poAjfZJTZj1gUW0Bt Dg+OBKVcOTAmEm2SWIVC6zDGo1PHwZO53MGM1pcMj3FNt4VUdmtZt2jR0q5sTUiOwkyT hjR7+O8FWTjz8sQqqVly6b58kRywl1M3xolzVepGcjp01YbQdK1Yztb6HeU/nxLJa11r f1Vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=Y5CiKSbp; 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 j18-20020a056402239200b0043583f0f23bsi3538573eda.495.2022.06.20.15.19.24; Mon, 20 Jun 2022 15:19:48 -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=Y5CiKSbp; 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 S244798AbiFTVed (ORCPT + 99 others); Mon, 20 Jun 2022 17:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242433AbiFTVeR (ORCPT ); Mon, 20 Jun 2022 17:34:17 -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 A2C171572E for ; Mon, 20 Jun 2022 14:34:15 -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 3D9B0660179B; Mon, 20 Jun 2022 22:34:14 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1655760854; bh=AgP5Riz/FHb587iBL1vYiW/g4qmDc92BtRCaR0jjFGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y5CiKSbpQG/ukWpxDeRwljhigdQFYdoAJSwyeexJRVo+fpjvj1Zc6/LSVcgzyn2/M K0EbZX7/4wK8/5rgT1qzIKPCp8dtLp5Wt7JyPocBJbnJ8+TPqNSWUAV/qkDKdiwF0h 9d84dMkrklTXF+mh8r2qmDeG1/Rn51mq45q3KD1pdyC/1x7Wdp/KNL1f7foBfv6h4y B5uplaYowW+oAX04sqqlbIkwMPRkGCyy52HubDILqPGKGFyRYjF1WRZdJtYq4ZRBxA mP2Lu3nSfSMfggPzGHczfAecQO2vnx1yvrcqlPi0lFHgU3zQZ7CvQsSOLuOAh4EiRQ pCy6gb5Gz3jbA== 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 v7 06/10] drm/i915: sanitize mem_flags for stolen buffers Date: Mon, 20 Jun 2022 21:33:36 +0000 Message-Id: <20220620213340.3199605-7-bob.beckett@collabora.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220620213340.3199605-1-bob.beckett@collabora.com> References: <20220620213340.3199605-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