Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3788491pxf; Mon, 29 Mar 2021 11:24:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwM3Zft1VVsNJCtx6KGvaGkaaLz5+vESLlQl6+vksxGlVRH13DjKVXX1gS3aAoO1Itu1/y X-Received: by 2002:a05:6402:1051:: with SMTP id e17mr29850367edu.42.1617042241565; Mon, 29 Mar 2021 11:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617042241; cv=none; d=google.com; s=arc-20160816; b=wOnam6dsl5jCeb54ztrj1z34LQwTOIPXjDH7u9RWjE/VVczAxJR2FQdQc0UW16Da3d 3Vz2/qZHUphqGZTFg6+5qbNlRT0zamxcWLQkRcwitVePr0dI9F3uMfKCcGas+OxyqNOV QPZBqXI0+FaZbBdSbe8LR6d+/R/6HexqMExRjicDFxaAU9/1r4eCcMGC2DoYwv0FGenL PHwghEn9KOv7Wt/DWPzaqzGArBzzFTQRysnVX+crgOE3hbgvzMBgtZfWFNVBjq3pZD0D YzOQRt+5aukUlkDKQjNLkpI2jEyF/p4L2KPAxB2pc47MDyKjD8/hK05BUTh+ZLeRMkQ6 a1QA== 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=YHCTLOQji1TU6PObSe0lzPj8T+Fg3PTAYM1EeyxrTnQ=; b=ShHjAa1+KwFvTp42aOmZv5pE2RnEQS9ORK4W5kll0YEk8a35Ow/lWabIqtgARhW2Dq 31emg29pCeISp3BNBh3yccDHj4pW60R1WBQ/txVqqh/UXeqMWhRhx9F70/b0QmiLv74M 8zkdgPXhROcF13SV08hnXxjiGcbvfLidhpZ29eFHgcBFDZEEpjpSAOh+ZlL217GT5p6G ajOnGOnWWkLA5Ul/x3AqiG43aOZVlaLSYhGK1NdPZolH8ZpcSAaoCHNEZlcTZyDdXLP8 GB2ecd+74kFxuR0FDjVWqLllerO5o8qnlNHxOEbEBQzDFl8TAriOqZJMWVpvGBmFs7pm QcTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mengyan1223.wang header.s=mail header.b=kScrJxKt; 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 k12si13530369edq.82.2021.03.29.11.23.38; Mon, 29 Mar 2021 11:24:01 -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=kScrJxKt; 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 S231610AbhC2SWO (ORCPT + 99 others); Mon, 29 Mar 2021 14:22:14 -0400 Received: from mengyan1223.wang ([89.208.246.23]:53502 "EHLO mengyan1223.wang" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbhC2SWH (ORCPT ); Mon, 29 Mar 2021 14:22:07 -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)) (Client did not present a certificate) (Authenticated sender: xry111@mengyan1223.wang) by mengyan1223.wang (Postfix) with ESMTPSA id 5A69D65B2D; Mon, 29 Mar 2021 14:21:54 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mengyan1223.wang; s=mail; t=1617042124; bh=YHCTLOQji1TU6PObSe0lzPj8T+Fg3PTAYM1EeyxrTnQ=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=kScrJxKtrzkjmZaqBTvC/q0aDm55v4zy0NZzfmG1WADUs+/bOimqcylR6UIgZT6SS EanGcnOGHOVoE/bcwylAs+rVAUNfdVW1cYCIGQ9vtGj71+VktU83WHF25EicmM1e8G 7L9YszFJY7ltQ3BJrox9JozuLhrRzg1u5esLN5q6fKWbE57ClR9jwhbZ0eBEVrjHCh 2/AA5SlkSqjTx1VMFYdYN2hNc75l1rAfwtNY8/9t6xbL3LkpcMgcHv3Di4RLnf6DpO eyHR5K/btD0GZXcMaMzxGvaNScXHXcmTQWNfdUhTOUI4JJXSxSoHLIb5W8Q2ljbuI0 w1zbYPYaij3uw== Message-ID: 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:21:48 +0800 In-Reply-To: <9a11c873-a362-b5d1-6d9c-e937034e267d@gmail.com> 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-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. > > > > 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