From patchwork Fri Feb 3 18:08:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9554879 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5B518604A7 for ; Fri, 3 Feb 2017 18:08:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4371827F81 for ; Fri, 3 Feb 2017 18:08:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 37F8028173; Fri, 3 Feb 2017 18:08:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B377427F81 for ; Fri, 3 Feb 2017 18:08:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7DC0A6E130; Fri, 3 Feb 2017 18:08:32 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id B848A6E130 for ; Fri, 3 Feb 2017 18:08:31 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id r18so5987796wmd.3 for ; Fri, 03 Feb 2017 10:08:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id; bh=tmq7I2PGjnaY8eHNaZ0B9SqfmJFwkYfsa3bKFoR976g=; b=Mbq8r84/4AGrvQKukkY0U+i/n57SkTVIbiYFk4xnyLMhaxUwfysEcTjnxjJK83x3C5 IBFi0UfmOCzd3Fa1ogGaDyAlae07WJBjcbzg4d1/aF9xSCBGQnnD7BUvlF+ZrgtXfNXH XkZt6GunIqgXJ8M655kps9vTgwGWTbFZtYj3S5UKXfGNoRy3gvSuuaYIU6MVVeoV8i80 vKxKk/x+dhpSlQNULQLuV8NxcJQ2IFHVqfAVGw0QrB4C/okRs47+Rf9KIrSVHV4ZX7S6 0HLXCBmEpQB8SpZC+gFz81iZ2UJIDZjCSE/vhfBwemis6Q7eZwbkBhLwgL2JY2UXq8dg 9t3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id; bh=tmq7I2PGjnaY8eHNaZ0B9SqfmJFwkYfsa3bKFoR976g=; b=r3PSVmfmfM2tPaww7LfTV2CuNyiKqksjXGC6BiDlvjwYrXpiH1Ek/4Tbz+SFDL+qYU 8z+hW7MqCMR51na7N61GhGyq7qGVDTFnmPxXoSbk5SLeWxTLEPhu/8N6aybcvtyJpnds XjuCdVSz/nV0aUgjJWs3Zk5/MzC/cAv4p2+STCCCUxSMf3jw+8TdI4sgqMpFl10QZdrE uF3Iy9to+XtxpvL6R4jod63hH0yiV8A4vHkgc7tIjt9KEQQK5B/jJW4cq4hjmRyneSjJ c2Kjghv0wFaaLcrFq8DafQrsUxnEa680CxxdtvOatltqrnKT1HNyZi4y3f98kge1Kxn+ H1EQ== X-Gm-Message-State: AIkVDXKf5MnbozR1BF9sOS/l1ZSD5vBylMPJIb3H9LGyawvQvkzmAs0r3NzzOhLHr3DRfQ== X-Received: by 10.223.175.36 with SMTP id z33mr13319734wrc.25.1486145310367; Fri, 03 Feb 2017 10:08:30 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id y30sm46364313wrc.23.2017.02.03.10.08.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Feb 2017 10:08:29 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Fri, 3 Feb 2017 18:08:28 +0000 Message-Id: <20170203180828.14215-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 Subject: [Intel-gfx] [PATCH] drm/i915: Sanity check inputs to i915_gem_evict_for_node() X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Assert that the node is correctly aligned and that we are within the bounds of the VM. Signed-off-by: Chris Wilson Cc: Joonas Lahtinen Reviewed-by: Matthew Auld --- drivers/gpu/drm/i915/i915_gem_evict.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index c181b1bb3d2c..e3f9d377c8c9 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c @@ -258,6 +258,9 @@ int i915_gem_evict_for_node(struct i915_address_space *vm, int ret = 0; lockdep_assert_held(&vm->i915->drm.struct_mutex); + GEM_BUG_ON(!IS_ALIGNED(start, I915_GTT_PAGE_SIZE)); + GEM_BUG_ON(!IS_ALIGNED(end, I915_GTT_PAGE_SIZE)); + trace_i915_gem_evict_node(vm, target, flags); /* Retire before we search the active list. Although we have @@ -276,8 +279,13 @@ int i915_gem_evict_for_node(struct i915_address_space *vm, if (end < vm->start + vm->total) end += I915_GTT_PAGE_SIZE; } + GEM_BUG_ON(start < vm->start); + GEM_BUG_ON(end > vm->start + vm->total); + GEM_BUG_ON(start >= end); drm_mm_for_each_node_in_range(node, &vm->mm, start, end) { + GEM_BUG_ON(!node->allocated); + /* If we find any non-objects (!vma), we cannot evict them */ if (node->color == I915_COLOR_UNEVICTABLE) { ret = -ENOSPC;