Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3363358pxf; Mon, 5 Apr 2021 10:03:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHRQz554lHNI5soove/aQplTfeyh7P8g2Viv7bWb/fbvFHRpd9i1szFiQfFt5B2KQPDrkF X-Received: by 2002:a17:906:524f:: with SMTP id y15mr29072066ejm.65.1617642231122; Mon, 05 Apr 2021 10:03:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617642231; cv=none; d=google.com; s=arc-20160816; b=CLd/g5O/l/THLu2nK4wSERnMlOrdKp+5K+AproE+UvI5nebJNA3g4bPSLKd2tE5pfj Hn3OnE4vPdxLNSRV7iJrYPjC+mFwrBzOoN5f90HjExqSamsB4bTlSu97rmoo2VbpNRU1 Ow/COG/8AJcVRIH9D5EiOfe+Ud7fyBp5XLYTXkBQRbyz8MuumboUQLr/OER6hAQrKxye cQaEP6Rmp/Pi5v2sa5LwarnKf3YH1ff1MpUTHQh78674/SL35zwX5AemAvU6tWF9bvxe 5REPvbrL+erixWJoUWdsjIwcOlyzPIIy2CV58lo9Uf7V/gz8hXLGpF8TRNAZy3dCLYXa sbRA== 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=QSqSksOz+mm5yjH986fmnxpSd1n5Jt4AI2Mw+sduM9Y=; b=zN88CoH+wsouAHbqtpVuwHKoStIcAmHmov3S0lJL6Zs+Pj3envLxypZiDsFgE6QuD3 /qX4x1cKN2eVnSwLlw/iBh2k7fuMmDjVRyS+/jppk4ZXbAf4VfCHCLECBuQygXSi8DIM ZToztFztDJJDBYd2l5jZa3AyZbhpYsG3CLuFOLdeSGX3woHW7k19NkS6CMV4sfrDrMNN xiDJA5hosdSQJjDLoiOBsVHTq04NHbP8z3ATSC+iPsXClaSeQe5ZjD/V+XKmM56FLQXN 0UBed4iBOZWVnifkBxj1f7MQysM3aCpiNoZnLc7BfEFnoSikuA2QuK3fvO1wtrhotq/g Z06A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uUfPbBAD; 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 a10si14754023edf.499.2021.04.05.10.03.16; Mon, 05 Apr 2021 10:03:51 -0700 (PDT) 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=uUfPbBAD; 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 S239973AbhDEJSX (ORCPT + 99 others); Mon, 5 Apr 2021 05:18:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:34130 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240004AbhDEJOf (ORCPT ); Mon, 5 Apr 2021 05:14:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 82086611C1; Mon, 5 Apr 2021 09:14:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617614067; bh=nrYPgSlh1MX6DNy97a1bWl/b0r03TbP9jp2zLQMAbqo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUfPbBADzBZf9PIE6b0orQdvu8GRJUNI3G4Fbdl7t0dVVEo5jeig18Btwiy1B0jCX 8YrLpLYHg7GXtvFWMD0CLhxrqdh/AF+Jq9sVmC744mr9Z7rFmN1Y5AUIbg/1NWdt39 K1NTMMLF0JSQut4IYz56J9M+YVfKwXOojKoIAHxs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tobias Klausmann , Dave Airlie , Sasha Levin Subject: [PATCH 5.11 036/152] nouveau: Skip unvailable ttm page entries Date: Mon, 5 Apr 2021 10:53:05 +0200 Message-Id: <20210405085035.438087894@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210405085034.233917714@linuxfoundation.org> References: <20210405085034.233917714@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: Tobias Klausmann [ Upstream commit e94c55b8e0a0bbe9a026250cf31e2fa45957d776 ] Starting with commit f295c8cfec833c2707ff1512da10d65386dde7af ("drm/nouveau: fix dma syncing warning with debugging on.") the following oops occures: BUG: kernel NULL pointer dereference, address: 0000000000000000 #PF: supervisor read access in kernel mode #PF: error_code(0x0000) - not-present page PGD 0 P4D 0 Oops: 0000 [#1] PREEMPT SMP PTI CPU: 6 PID: 1013 Comm: Xorg.bin Tainted: G E 5.11.0-desktop-rc0+ #2 Hardware name: Acer Aspire VN7-593G/Pluto_KLS, BIOS V1.11 08/01/2018 RIP: 0010:nouveau_bo_sync_for_device+0x40/0xb0 [nouveau] Call Trace: nouveau_bo_validate+0x5d/0x80 [nouveau] nouveau_gem_ioctl_pushbuf+0x662/0x1120 [nouveau] ? nouveau_gem_ioctl_new+0xf0/0xf0 [nouveau] drm_ioctl_kernel+0xa6/0xf0 [drm] drm_ioctl+0x1f4/0x3a0 [drm] ? nouveau_gem_ioctl_new+0xf0/0xf0 [nouveau] nouveau_drm_ioctl+0x50/0xa0 [nouveau] __x64_sys_ioctl+0x7e/0xb0 do_syscall_64+0x33/0x80 entry_SYSCALL_64_after_hwframe+0x44/0xae ---[ end trace ccfb1e7f4064374f ]--- RIP: 0010:nouveau_bo_sync_for_device+0x40/0xb0 [nouveau] The underlying problem is not introduced by the commit, yet it uncovered the underlying issue. The cited commit relies on valid pages. This is not given for due to some bugs. For now, just warn and work around the issue by just ignoring the bad ttm objects. Below is some debug info gathered while debugging this issue: nouveau 0000:01:00.0: DRM: ttm_dma->num_pages: 2048 nouveau 0000:01:00.0: DRM: ttm_dma->pages is NULL nouveau 0000:01:00.0: DRM: ttm_dma: 00000000e96058e7 nouveau 0000:01:00.0: DRM: ttm_dma->page_flags: nouveau 0000:01:00.0: DRM: ttm_dma: Populated: 1 nouveau 0000:01:00.0: DRM: ttm_dma: No Retry: 0 nouveau 0000:01:00.0: DRM: ttm_dma: SG: 256 nouveau 0000:01:00.0: DRM: ttm_dma: Zero Alloc: 0 nouveau 0000:01:00.0: DRM: ttm_dma: Swapped: 0 Signed-off-by: Tobias Klausmann Signed-off-by: Dave Airlie Link: https://patchwork.freedesktop.org/patch/msgid/20210313222159.3346-1-tobias.klausmann@freenet.de Signed-off-by: Sasha Levin --- drivers/gpu/drm/nouveau/nouveau_bo.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c b/drivers/gpu/drm/nouveau/nouveau_bo.c index f1c9a22083be..e05565f284dc 100644 --- a/drivers/gpu/drm/nouveau/nouveau_bo.c +++ b/drivers/gpu/drm/nouveau/nouveau_bo.c @@ -551,6 +551,10 @@ nouveau_bo_sync_for_device(struct nouveau_bo *nvbo) if (!ttm_dma) return; + if (!ttm_dma->pages) { + NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma); + return; + } /* Don't waste time looping if the object is coherent */ if (nvbo->force_coherent) @@ -583,6 +587,10 @@ nouveau_bo_sync_for_cpu(struct nouveau_bo *nvbo) if (!ttm_dma) return; + if (!ttm_dma->pages) { + NV_DEBUG(drm, "ttm_dma 0x%p: pages NULL\n", ttm_dma); + return; + } /* Don't waste time looping if the object is coherent */ if (nvbo->force_coherent) -- 2.30.1