Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3793133pxf; Mon, 29 Mar 2021 11:32:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxBepTcyc5YcABcYB3akNJ4KwWUKy/HmMbBGpZPDGoTZzPeuzbWtS0bABNSk4WkIl3tTlf+ X-Received: by 2002:a17:906:5d05:: with SMTP id g5mr29442306ejt.489.1617042764017; Mon, 29 Mar 2021 11:32:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617042764; cv=none; d=google.com; s=arc-20160816; b=SQEqp+K6Ht454d3163v0pyfgNV34zTBD7IpRMrGtSoNI24YlnvYlgfXmzg7ubqaAMi XiNB5S/VCLH0A8hNm0J7HNEedBCKpxO35+i6tqreQGxPF6K6+DOUph6uS+M0RZSdFQFp e3hXys2F4CRm9Lf7G0J7tpqAsls50XO0JpHCVf6Q2F3mnAM619PU6GYHkyP7Tn0CqJ/m wmeZCnu/Czyn1uj389AWwAwzu9nWNrbl7+HfAiSV9EeQiEjmd8S6G5titFiOwdGpCung m7zBza7HO7ODiNTvExOQJYos2ZLqwFnBvnPc5cOFFtsDt/vzm3cflCmzr1fxdPvlJsKn bNcw== 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:date:cc:to:from:subject :message-id:dkim-signature; bh=CiLAhcBYdIBxO9trAzmTsXeaetQu3vlDdKujBncqKc8=; b=WFisye4psjZdjl9XqELAoMQQc3BI2wkdHVS96n/Sci2eFiDFKvUJ3evCO4DMLA0qF3 q8LFQ8mk8tbuQmB3pQZT2a/5LU67wenR4rQs1C0TCd/Bdcq5p+yz5mSIpIjOKWCFsTyU 09eRQXrLMUrQOVJXGtV42hyVaJQ2aPM3ocKYq6KENtvobz6M22ahlQNLuEOl7LMcuMkn yMHfEPGqAuLp9sj5zcqbl6WrmhE9qJYMx1C/ReLgoGht4rQPwCseDh5I2pU+aEmMtWDV xrMN+SfQaF5SOjWF0/LJUvV1aK4YZ8uvrH5cM7d08UyR9V7I6rP82mMK7OJhH4Df1ZpO cuQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mengyan1223.wang header.s=mail header.b=qOQg7r7u; 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=mengyan1223.wang Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v5si13136684edr.596.2021.03.29.11.32.21; Mon, 29 Mar 2021 11:32:44 -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=@mengyan1223.wang header.s=mail header.b=qOQg7r7u; 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=mengyan1223.wang Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231699AbhC2SbR (ORCPT + 99 others); Mon, 29 Mar 2021 14:31:17 -0400 Received: from mengyan1223.wang ([89.208.246.23]:53976 "EHLO mengyan1223.wang" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbhC2Sau (ORCPT ); Mon, 29 Mar 2021 14:30:50 -0400 Received: from [IPv6:240e:35a:1037:8a00:70b2:e35d:833c:af3e] (unknown [IPv6:240e:35a:1037:8a00:70b2:e35d:833c:af3e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-384) server-digest SHA384) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id 2C1B065B30; Mon, 29 Mar 2021 14:30:34 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mengyan1223.wang; s=mail; t=1617042649; bh=CiLAhcBYdIBxO9trAzmTsXeaetQu3vlDdKujBncqKc8=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=qOQg7r7unrFpq/RMBtE7nW5QP0kRgD5BV83yIwM/nIcVv8VVcSn5O6BoE+QKAtAVS pl0CfEKV9GMVxuczjH9ah1vbHlxP5Lg/FXopX6u6jetaREHIkwVZ1jMCIoAr3Pc2zM A96jZ+73VyKmx+gWNFVhqKrKU8n5JED9jNcJkjkT7Zqm2ckgWe5sakN0Wjt9h8JWyn 7E7+inKSzV3CFDA5Zu5DTCbl9boge165JDOCMnHsBpVG6ZzoMW3yfG1mjsvwZA1iAz MQ5LkeSKTUv//YFE13S6cx/XWf2FxanCb+dk5vr94jx1TC3L3MoDptqOmX5HwXtWux kOw/gPyVFc2Hg== Message-ID: <84b3911173ad6beb246ba0a77f93d888ee6b393e.camel@mengyan1223.wang> Subject: Re: [PATCH] drm/amdgpu: fix an underflow on non-4KB-page systems From: Xi Ruoyao To: Christian =?ISO-8859-1?Q?K=F6nig?= , Alex Deucher , Christian =?ISO-8859-1?Q?K=F6nig?= Cc: David Airlie , Felix Kuehling , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Dan =?ISO-8859-1?Q?Hor=E1k?= , amd-gfx@lists.freedesktop.org, Daniel Vetter , stable@vger.kernel.org Date: Tue, 30 Mar 2021 02:30:26 +0800 In-Reply-To: References: <20210329175348.26859-1-xry111@mengyan1223.wang> <9a11c873-a362-b5d1-6d9c-e937034e267d@gmail.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-03-30 02:21 +0800, Xi Ruoyao wrote: > On 2021-03-29 20:10 +0200, Christian König wrote: > > You need to identify the root cause of this, most likely start or last > > are not a multiple of AMDGPU_GPU_PAGES_IN_CPU_PAGE. > > I printk'ed the value of start & last, they are all a multiple of 4 > (AMDGPU_GPU_PAGES_IN_CPU_PAGE). > > However... `num_entries = last - start + 1` so it became some irrational > thing...  Either this line is wrong, or someone called > amdgpu_vm_bo_update_mapping with [start, last) instead of [start, last], which > is unexpected. I added BUG_ON(num_entries % AMDGPU_GPU_PAGES_IN_CPU_PAGE != 0), get: > Mar 30 02:28:27 xry111-A1901 kernel: [] > amdgpu_vm_bo_update_mapping.constprop.0+0x218/0xae8 > Mar 30 02:28:27 xry111-A1901 kernel: [] > amdgpu_vm_bo_update+0x270/0x4c0 > Mar 30 02:28:27 xry111-A1901 kernel: [] > amdgpu_gem_va_ioctl+0x40c/0x430 > Mar 30 02:28:27 xry111-A1901 kernel: [] > drm_ioctl_kernel+0xcc/0x120 > Mar 30 02:28:27 xry111-A1901 kernel: [] > drm_ioctl+0x220/0x408 > Mar 30 02:28:27 xry111-A1901 kernel: [] > amdgpu_drm_ioctl+0x58/0x98 > Mar 30 02:28:27 xry111-A1901 kernel: [] sys_ioctl+0xcc/0xe8 > Mar 30 02:28:27 xry111-A1901 kernel: [] > syscall_common+0x34/0x58 > > > > > > BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1549 > > > > > Fixes: a39f2a8d7066 ("drm/amdgpu: nuke amdgpu_vm_bo_split_mapping v2") > > > > > Reported-by: Xi Ruoyao > > > > > Reported-by: Dan Horák > > > > > Cc: stable@vger.kernel.org > > > > > Signed-off-by: Xi Ruoyao > > > > > --- > > > > >    drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 2 +- > > > > >    1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > > > > > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > > > > > b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > > > > > index ad91c0c3c423..cee0cc9c8085 100644 > > > > > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > > > > > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c > > > > > @@ -1707,7 +1707,7 @@ static int amdgpu_vm_bo_update_mapping(struct > > > > > amdgpu_device *adev, > > > > >                  } > > > > >                  start = tmp; > > > > >    > > > > > -       } while (unlikely(start != last + 1)); > > > > > +       } while (unlikely(start < last + 1)); > > > > >    > > > > >          r = vm->update_funcs->commit(¶ms, fence); > > > > >    > > > > > > > > > > base-commit: a5e13c6df0e41702d2b2c77c8ad41677ebb065b3 > > > -- Xi Ruoyao School of Aerospace Science and Technology, Xidian University