Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3780642pxf; Mon, 29 Mar 2021 11:10:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyipT6pdTp2QQ33bH8nANNE9l04sQPdwnUi934fkXtrNH19pKzVHTNEkZbWX2jIxLugTJN5 X-Received: by 2002:a05:6402:c88:: with SMTP id cm8mr29603591edb.62.1617041440644; Mon, 29 Mar 2021 11:10:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617041440; cv=none; d=google.com; s=arc-20160816; b=IVZlBan3uriWLQdxs+1lDxa1iJLjE34eJ2zUQVAr9RRwjA9oHCqdZeZBJLtNNIeJkG OHbQFCOqaCLv3AIO9XxlEf2OeB7F186bQfW9qdIbK3Su2t1SI+fN8DgQqLELfnMGqLRY YbQn7fkfqmNIa7aeHyRWZIhOCpH+pFHUD8glpYOtp3pGjFvEchvu7l2AeV/RqmIMOKrc W3qmFSEiVt8y0JjJzfGMCFHJqfhPcetU/x0bPZottDpbjCPAuI0wpFpJ/8s6p8fSRqm2 JgO3rOP6wDzhKwQJYVN/tyMxG4zHFvGjsqy96h3clif6d8C2emydkzGff2n+fiuzwvZD iWkw== 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=DnbFnwZ0/NuIMzB/7EbnclRu37Hg7RRrTWRMFouAYiY=; b=tFGt8EoGf1FeCMOj07PTio38BfC4iW/erG6CadUFP4mB7W8S4NAl54tVC+yvbWhdyu ibJ/SeFnyQlNzZnKcDJnl7HAVYqPlAUL/eqV3s7GwMhAufNunr81vRAwV21QYk67Q7Ju 64W3Gi+rPZEK3YjqomlZN12EjDh27HCTmMb1aVceAFy1Z+/lLLNGmycfM0RbUVXkqUo+ zihrWtyw+gwYL45KlA++64U3FcDPPaaqfYAQfIocMvy/daSNJQequvs6sxJdXQLElTUr 1PfRCdRiFbmjbhY3uNcAPnZ8tfMWV1BKkwXKlpWOyJiMvIOG4gxjprDwj1AEGE46HNIY WvsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mengyan1223.wang header.s=mail header.b=eud4UHFm; 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 dj16si12690410edb.143.2021.03.29.11.10.17; Mon, 29 Mar 2021 11:10:40 -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=eud4UHFm; 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 S230220AbhC2SJS (ORCPT + 99 others); Mon, 29 Mar 2021 14:09:18 -0400 Received: from mengyan1223.wang ([89.208.246.23]:52800 "EHLO mengyan1223.wang" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbhC2SIz (ORCPT ); Mon, 29 Mar 2021 14:08:55 -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 8E86265B2D; Mon, 29 Mar 2021 14:08:46 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mengyan1223.wang; s=mail; t=1617041334; bh=DnbFnwZ0/NuIMzB/7EbnclRu37Hg7RRrTWRMFouAYiY=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=eud4UHFmqGdkogF/vnhMCKl190X1Lx65bFaTgdfl+MlbTUpeY7mcQy4Vbmpjtc95J PMqWWNP7RQ75jB/WpJ3wr3rkXC9baOSQyJPRpYIp20wzuZYlkBZtwHVFr/UkHKLl37 dnaSp+ZX2lG0dIZeqmglsLk0cEQC9LzZ1f9CfhEh/GQL0/MvG1MxssMrKQpNZWiZUf hJJbRSc+mafXGpbfgbeOKZOnQDG0QVHPiOoc6Liu3sf4khCbQ6/gf/876E4QCouvFk 0ZtsKsl1RlGA0ursq/pLBvT4uoIc2edOlSRAd8iCn5wo2bUCJKZO7codNKxm6NAAiS +2HbmYpCJKk9g== 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:08:36 +0800 In-Reply-To: References: <20210329175348.26859-1-xry111@mengyan1223.wang> 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:04 +0200, Christian König wrote: > Am 29.03.21 um 19:53 schrieb Xℹ Ruoyao: > > If the initial value of `num_entires` (calculated at line 1654) is not > > an integral multiple of `AMDGPU_GPU_PAGES_IN_CPU_PAGE`, in line 1681 a > > value greater than the initial value will be assigned to it.  That causes > > `start > last + 1` after line 1708.  Then in the next iteration an > > underflow happens at line 1654.  It causes message > > > >      *ERROR* Couldn't update BO_VA (-12) > > > > printed in kernel log, and GPU hanging. > > > > Fortify the criteria of the loop to fix this issue. > > NAK the value of num_entries must always be a multiple of > AMDGPU_GPU_PAGES_IN_CPU_PAGE or otherwise we corrupt the page tables. > > How do you trigger that? Simply run "OpenGL area" from gtk3-demo (which just renders a triangle with GL) under Xorg, on MIPS64. See the BugLink. > Christian. > > > > > 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