Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp726755pxb; Tue, 2 Feb 2021 16:51:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/ACvNoItdQMSAiNoPtW7bxG7JshD55gFBwnFEBZo9XBQp15vz1YZp8b4XbHigTAzdvyKD X-Received: by 2002:a50:d6c1:: with SMTP id l1mr654155edj.336.1612313471623; Tue, 02 Feb 2021 16:51:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612313471; cv=none; d=google.com; s=arc-20160816; b=B1tvJ7t3t8VEHedC9yJWjBmi7F9KoSAehhGhJ91hiKSsemNCX90U7P7fjUTvExFm6e u5rxUIEwhFr1+FH7Kemrdwo/K0WrWEXpn01b0qIO6TCpVVIGY3jKZ8wgclFnI/WmqmQJ 0SQyVjhrjkCix2yVAmH8ZWlSHRBKqK/Dp0Yx/BZnIj80EdYxSLNyfJN4q7JcoM3+GNk3 ACTVq86qcWH76KBTkyuZszymB7IwyOIm5VNnKmtKXRk7z+4n8TuBGv8eC6UE+vjzIdOF C5McNtZ9JA6XEito862n4jPTJK8uha26LDWVToAvZIB27W2i0Gck1/Vi5TyavkhpXlAy gZ2g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=58BO3qC4rPhsEh74hw8i2ZzD/6b+DSr7Xap/dxuf/Jk=; b=zO43I2kvH2kuG1CwumdhwtkPA5xOjHEPcrG2JV53oSh24HZOrL8lkCKOomxtwhwM1W /uvZVUEsVh26s/slzoqyQKzlJxx2bpaQR5tnWxfRhj8yH80mJHlzCEZZ3M3TGBYnrDpy pEqfzw0qesdFFmZKAztZYbsm6H3lCnbzWQ//Pq0vLTgZsKsaEcbpwW2VXrXZigVzL/ax YCNirZXVkkj+dE3+5jBHvXcVdZR9ZRiob/aS3V8lPQbXSrPrDph9CYkChNdt2FDePFE5 UlZTErbHYvyJfjCM0rP2NU3m3q4ChrW1e2bmKNv5sPGPVUS6n91P6OjfoMmZHAeBV7Uc +Jew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xlFnz2g5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si292899ejy.32.2021.02.02.16.50.47; Tue, 02 Feb 2021 16:51:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xlFnz2g5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232978AbhBBUFO (ORCPT + 99 others); Tue, 2 Feb 2021 15:05:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:36548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232371AbhBBNnP (ORCPT ); Tue, 2 Feb 2021 08:43:15 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 76E3B64F70; Tue, 2 Feb 2021 13:40:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612273222; bh=l6D115tAnUcADOdU7I7PmsLHAnuCKBGlaNAlrBXia8Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xlFnz2g5W/8NasdurP/Mo4mwJlFyOxBQ8kU1G7UaB2zVVP8SQMIwFTd2iB4n8nXTc y6Zpt4h9QjUHhN/CCGPO8ian0fS5XXZe0tRhJFM/fpC0AQm1SrTumk6hZnvjFTvZr4 23He5BvKqeBIqglPhQlb34m6rZr15zCpkRKOFZz8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Chris Wilson , Matthew Auld , Jani Nikula Subject: [PATCH 5.10 025/142] drm/i915/gt: Always try to reserve GGTT address 0x0 Date: Tue, 2 Feb 2021 14:36:28 +0100 Message-Id: <20210202132958.749710625@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210202132957.692094111@linuxfoundation.org> References: <20210202132957.692094111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chris Wilson commit 489140b5ba2e7cc4b853c29e0591895ddb462a82 upstream. Since writing to address 0 is a very common mistake, let's try to avoid putting anything sensitive there. Signed-off-by: Chris Wilson Reviewed-by: Matthew Auld Link: https://patchwork.freedesktop.org/patch/msgid/20210125125033.23656-1-chris@chris-wilson.co.uk Cc: stable@vger.kernel.org (cherry picked from commit 56b429cc584c6ed8b895d8d8540959655db1ff73) Signed-off-by: Jani Nikula Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/i915/gt/intel_ggtt.c | 47 ++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 12 deletions(-) --- a/drivers/gpu/drm/i915/gt/intel_ggtt.c +++ b/drivers/gpu/drm/i915/gt/intel_ggtt.c @@ -526,16 +526,39 @@ static int init_ggtt(struct i915_ggtt *g mutex_init(&ggtt->error_mutex); if (ggtt->mappable_end) { - /* Reserve a mappable slot for our lockless error capture */ - ret = drm_mm_insert_node_in_range(&ggtt->vm.mm, - &ggtt->error_capture, - PAGE_SIZE, 0, - I915_COLOR_UNEVICTABLE, - 0, ggtt->mappable_end, - DRM_MM_INSERT_LOW); - if (ret) - return ret; + /* + * Reserve a mappable slot for our lockless error capture. + * + * We strongly prefer taking address 0x0 in order to protect + * other critical buffers against accidental overwrites, + * as writing to address 0 is a very common mistake. + * + * Since 0 may already be in use by the system (e.g. the BIOS + * framebuffer), we let the reservation fail quietly and hope + * 0 remains reserved always. + * + * If we fail to reserve 0, and then fail to find any space + * for an error-capture, remain silent. We can afford not + * to reserve an error_capture node as we have fallback + * paths, and we trust that 0 will remain reserved. However, + * the only likely reason for failure to insert is a driver + * bug, which we expect to cause other failures... + */ + ggtt->error_capture.size = I915_GTT_PAGE_SIZE; + ggtt->error_capture.color = I915_COLOR_UNEVICTABLE; + if (drm_mm_reserve_node(&ggtt->vm.mm, &ggtt->error_capture)) + drm_mm_insert_node_in_range(&ggtt->vm.mm, + &ggtt->error_capture, + ggtt->error_capture.size, 0, + ggtt->error_capture.color, + 0, ggtt->mappable_end, + DRM_MM_INSERT_LOW); } + if (drm_mm_node_allocated(&ggtt->error_capture)) + drm_dbg(&ggtt->vm.i915->drm, + "Reserved GGTT:[%llx, %llx] for use by error capture\n", + ggtt->error_capture.start, + ggtt->error_capture.start + ggtt->error_capture.size); /* * The upper portion of the GuC address space has a sizeable hole @@ -548,9 +571,9 @@ static int init_ggtt(struct i915_ggtt *g /* Clear any non-preallocated blocks */ drm_mm_for_each_hole(entry, &ggtt->vm.mm, hole_start, hole_end) { - drm_dbg_kms(&ggtt->vm.i915->drm, - "clearing unused GTT space: [%lx, %lx]\n", - hole_start, hole_end); + drm_dbg(&ggtt->vm.i915->drm, + "clearing unused GTT space: [%lx, %lx]\n", + hole_start, hole_end); ggtt->vm.clear_range(&ggtt->vm, hole_start, hole_end - hole_start); }