Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3938708ybf; Tue, 3 Mar 2020 16:15:17 -0800 (PST) X-Google-Smtp-Source: ADFU+vsD0ayEZRHSYMK/z9IWAP4xlip3Qxsdg2yaMZFshUzoPfOQ0ExO4K/poJmWgiCvyZl2YS9l X-Received: by 2002:a9d:82e:: with SMTP id 43mr354796oty.101.1583280916881; Tue, 03 Mar 2020 16:15:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583280916; cv=none; d=google.com; s=arc-20160816; b=rUtWw6MpC75wCnP65LsRTAUJ8uAzag6lo+qYZkW6gZ7Im0c3qbIc7B435INHuyab3A tD3Pbx52IDHuioqy8p/d6ssSSyldn9zWXuDj6q8k+MV9VD3+jjr61LJ4TOhemo1XAk90 a2Y1R7UNl7ed1T+iOhVoe062jiUddmg4UqLGnUcUwh2twhk5m+/B5vd6OW3qBjaxCQ1X 3MjSmHpD9xMy880FZ/WsyN8KvDCXU3n1Gfvlmzl5KUGTWOFnQHUIfo+EnOjFkPJvjv3M VgNnEpWFlyFzs2hg1bkR3rHUcZOw5/8ppXFtFGJ6aHDMMkFjzl8iSvpEyqONiVOSAImr +oyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=SQ1eDvDeCWzDB8hOaPPk8mCkrZrA+UiK7QY7KhDn+vA=; b=n/D7pLbuzGqPo6oa9Kqe6JNOQyuwEIx93N5VjLLC7+Km5qn+byVcSOdnKyFB8c/F8w Y9sBeYQ8lqRLF/Go2E0nmc5hkrAZQllFfOyQyxSc5TgV3pJkTJlZ3wY2JnJLVFiHpyP5 9w6gOPL2elqF5sOSZrvNaia3LF8o2rwETfft0axWna7hTKLfUuYhB2ZTHeN7IgE5wml0 tBl9vxWIs/6yvRPZsxrDiU1TP0x8orRXqqiJmZ2fBVbpmPxCpyuu0RoFbXYj6wXgyo3k gwQHCTDnZIVc8BJ65d1KPJ2s1rTv+VhDr6JjhQ+ImzVtbxNIJV7luBmfI0y0sdqHr1mR PfvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=eOE1eePM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c22si110239otr.97.2020.03.03.16.15.05; Tue, 03 Mar 2020 16:15:16 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=eOE1eePM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728079AbgCDAOG (ORCPT + 99 others); Tue, 3 Mar 2020 19:14:06 -0500 Received: from hqnvemgate25.nvidia.com ([216.228.121.64]:14366 "EHLO hqnvemgate25.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727274AbgCDAOF (ORCPT ); Tue, 3 Mar 2020 19:14:05 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate25.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 03 Mar 2020 16:13:24 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Tue, 03 Mar 2020 16:14:05 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Tue, 03 Mar 2020 16:14:05 -0800 Received: from HQMAIL105.nvidia.com (172.20.187.12) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 4 Mar 2020 00:14:02 +0000 Received: from rnnvemgw01.nvidia.com (10.128.109.123) by HQMAIL105.nvidia.com (172.20.187.12) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 4 Mar 2020 00:14:02 +0000 Received: from rcampbell-dev.nvidia.com (Not Verified[10.110.48.66]) by rnnvemgw01.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 03 Mar 2020 16:14:01 -0800 From: Ralph Campbell To: , , , , CC: Jerome Glisse , John Hubbard , Christoph Hellwig , Jason Gunthorpe , "Andrew Morton" , Ben Skeggs , "Ralph Campbell" Subject: [PATCH v3 1/4] nouveau/hmm: fix vma range check for migration Date: Tue, 3 Mar 2020 16:13:36 -0800 Message-ID: <20200304001339.8248-2-rcampbell@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200304001339.8248-1-rcampbell@nvidia.com> References: <20200304001339.8248-1-rcampbell@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1583280804; bh=SQ1eDvDeCWzDB8hOaPPk8mCkrZrA+UiK7QY7KhDn+vA=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=eOE1eePM6U4kNNM329y8Gl5WGeldxDqUGJerZpgExUrCrxqEr4jbbUGTAOhN2xm1o aaNfMgd7ckUMRK8ruFmK+eahQJg0BgPnK9Pn/GlnWvCeCFKox5NGwWHxW4PzAergFs Qm+fdUwKbtmbvSFzOY5UnOyBcUhTh+E+U7M+mTSKAFITuIFO8bZV2f4pKuEPpVlX5g BbgkY2zK0/nvGs+5jxz/qZt8sgEoY3CCQZkLIN1nbYIN2iv7haj++OACEmoFZPfcA5 Kpnn9ffUGAQdJH3Fi8THjVMYgw6LYWRWh9Ri0qW/ciznn9oOQLzh93LFovaetPdvub s4ixUac8AM/DQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org find_vma_intersection(mm, start, end) only guarantees that end is greater than or equal to vma->vm_start but doesn't guarantee that start is greater than or equal to vma->vm_start. The calculation for the intersecting range in nouveau_svmm_bind() isn't accounting for this and can call migrate_vma_setup() with a starting address less than vma->vm_start. This results in migrate_vma_setup() returning -EINVAL for the range instead of nouveau skipping that part of the range and migrating the rest. Signed-off-by: Ralph Campbell --- drivers/gpu/drm/nouveau/nouveau_svm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouvea= u/nouveau_svm.c index df9bf1fd1bc0..169320409286 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -179,6 +179,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data, if (!vma) break; =20 + addr =3D max(addr, vma->vm_start); next =3D min(vma->vm_end, end); /* This is a best effort so we ignore errors */ nouveau_dmem_migrate_vma(cli->drm, vma, addr, next); --=20 2.20.1