From patchwork Thu Dec 22 10:56:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 9484679 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 DD3A0601D3 for ; Thu, 22 Dec 2016 10:56:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D77252818E for ; Thu, 22 Dec 2016 10:56:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB1A928324; Thu, 22 Dec 2016 10:56:39 +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 76A782818E for ; Thu, 22 Dec 2016 10:56:39 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C782F6E188; Thu, 22 Dec 2016 10:56:35 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wj0-x243.google.com (mail-wj0-x243.google.com [IPv6:2a00:1450:400c:c01::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id C8436899A3 for ; Thu, 22 Dec 2016 10:56:32 +0000 (UTC) Received: by mail-wj0-x243.google.com with SMTP id ez4so1183430wjd.1 for ; Thu, 22 Dec 2016 02:56:32 -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=FkHBUPKzBZVTV2ygNgqOFJu/yot3zD3eKpe3IfvJFNg=; b=knOF6WqUbreVJZLWuvmXP7LTvDWsdHAts1YFhaA7yaYmXhnwjRAPJlndDCESB/EfPS y3pI9bsdPO9fF619Ql7z2bNXFrkfUms1Yb/I2hhncsQ0cKUmWGux+QT7JmC0VIzl9E56 XjmeHmbX6CwlLyoQ3v6QkWd16k793eDF42wQs0yzJ0z03KxD82fgEzBQwSJwxl7fe6Kq whRtoDvC1GQUAwLT4r8+9JKXKvBFTtr5Nuc/kS0ZuUPiCBTdevh3zmb3y5ElAbUPIghK TJJbERb/HNMh/ZH9kYsA4y3w4l/yCnr4WEThgjagP34zoO2UlJ7H/SbAlmh+Am8oHIg4 ma+w== 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=FkHBUPKzBZVTV2ygNgqOFJu/yot3zD3eKpe3IfvJFNg=; b=gq5qmfdYigr3OXSXw7yK6ctxYNskg6SIhxHA0xygoeXaAO83u9cnqqdTZGoiWjUUT3 RGylHA/HeW3dTGf6T1bR05d6vx+yxwqWMw6tdDXmUBRrbMDNcN0CWmpoe95DhIYdkJE3 643dmcQujRO7Pmlbdylsi0DWg+kdvnABvXXfyAVVnZrFqWAFGuqK0esQAwa43ihXOPyL pyaY+B7cfNIeXFm2PnOq8ctitujrHIcU/CDxb9muVr00GuDXCQQIFlqBeyuEW16DV2kW +eroQ7U5Nn/RfwzeOTVCPaj/TolyeBtzHwIiFlM6/f3Nkpa5BQrpd/FcZGXmy7byCV/P MepQ== X-Gm-Message-State: AIkVDXK32BrW2UmKrLJI3nb3yHuR5YOAqoQiN9/enheTNJhcUnEarfPqwGzM0DlF3Tf1UA== X-Received: by 10.194.21.35 with SMTP id s3mr8498076wje.192.1482404190360; Thu, 22 Dec 2016 02:56:30 -0800 (PST) Received: from haswell.alporthouse.com ([78.156.65.138]) by smtp.gmail.com with ESMTPSA id u78sm31553040wma.11.2016.12.22.02.56.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Dec 2016 02:56:29 -0800 (PST) From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 22 Dec 2016 10:56:21 +0000 Message-Id: <20161222105625.10832-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.11.0 Subject: [Intel-gfx] [PATCH 1/5] drm/i915: Assert that the partial VMA fits within the object 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 When creating a partial VMA assert that it first fits with the parent object, and that if it covers the whole of the parent a normal view was created instead. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen --- drivers/gpu/drm/i915/i915_vma.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c index cfec4222b04e..3229f37eabea 100644 --- a/drivers/gpu/drm/i915/i915_vma.c +++ b/drivers/gpu/drm/i915/i915_vma.c @@ -95,8 +95,13 @@ __i915_vma_create(struct drm_i915_gem_object *obj, if (view) { vma->ggtt_view = *view; if (view->type == I915_GGTT_VIEW_PARTIAL) { + GEM_BUG_ON(range_overflows_t(u64, + view->params.partial.offset, + view->params.partial.size, + obj->base.size >> PAGE_SHIFT)); vma->size = view->params.partial.size; vma->size <<= PAGE_SHIFT; + GEM_BUG_ON(vma->size >= obj->base.size); } else if (view->type == I915_GGTT_VIEW_ROTATED) { vma->size = intel_rotation_info_size(&view->params.rotated);