Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp4950853ybi; Tue, 30 Jul 2019 11:02:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxVV+h/egdINVHEF5Cq6ZIYoJSGKuZMiMWFYcZp9p7H+IHdMIEh7UY2EMEZuwszxFgdGGUZ X-Received: by 2002:a17:902:296a:: with SMTP id g97mr114012730plb.115.1564509748973; Tue, 30 Jul 2019 11:02:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564509748; cv=none; d=google.com; s=arc-20160816; b=YmWjtByPrm2R4VFYj8NHcpenDb/gCFGBIcMOJSQyl38iTWaXzZxlST5r/IKKQ/yTni neSNMjFJLLIbQxV6+1BhYY4RlLhGZ4IurpcRepc8g3RHBOZvfzboVcfiZt5eZxoO05vr +Mpb6KI65aEJCz8qhbux24DQ0ssxagGeXLYUJVED3maE6v20PGeIJMdQ4+l40bylGhMC GNo344Lh/zWXSMFgfzT5zjJbVHSNDPQIsR8JdOgaKOiWLHCq4mTnh3dJRsqx+8gIrpXn slRF25Y0JL8KmdA9qiUby/XaNn8seWZdxkyAYjtfdLvJj/0trNF4kp0xmpSbbrHuvzwA GQ3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=vLDKuH+/Y6R1wGAQGSCIi/9agKk/j9gR7pNqj2Ro2Ic=; b=DNgorRXGC7a6IjlANYFMrEr6Eeg/idSJv4W4IvZ8w2BH8PIhEKZg10gtao+igEoGkp IqR/7/drEjf/mFWzCx0o788vBYrpsLXyRcHJ6t6oyUd7D0l2Gamtm+d7ENXxPB6fQeI7 9vKRzvW4UzIqQ+uL14s1UAgYodU1R8dIcl+vKZqu8LCe2moNOl/91CGArRGN4kWn/4Vb mmaQJMtLvmoAW3csBwb7el3dHjlghQalZl7vbgNh1UBU+mpm+xYBu5F58UP0nXOfJ+cZ QIQ+OCVRIE07Hju8uNMKTY4ehzy+6V1ti8RbepupXpHiLgD+QLNR7ssxzjVPVgAzLyxB TwjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iuQpUu6a; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si16399532pgv.497.2019.07.30.11.02.13; Tue, 30 Jul 2019 11:02:28 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=iuQpUu6a; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728116AbfG3OwS (ORCPT + 99 others); Tue, 30 Jul 2019 10:52:18 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:40249 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726535AbfG3OwS (ORCPT ); Tue, 30 Jul 2019 10:52:18 -0400 Received: by mail-lf1-f66.google.com with SMTP id b17so44958096lff.7; Tue, 30 Jul 2019 07:52:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=vLDKuH+/Y6R1wGAQGSCIi/9agKk/j9gR7pNqj2Ro2Ic=; b=iuQpUu6a8JnbGLjoBITZrEilnUrTWiH26PXOZvr0eJQhTGXYXPQKMEzNw2wB2Zdhwg O1s79fuH/+qKj9qM+F5N7WUORuY3bi2XPxK5gT8Guf2uZd9D6oyAtYDwhskz/FMsfn6o lKk6nD1IBmzrEbMo1z8fbSNSoKGZUfXjLfcnm5mKawQB8u+vap+bsQ1AUfdjGTiXN2ty tL6eFXIjDfZ571OcOPQwvXVAUX+46G+xpgSdufwNKOjBmDF3XP8A7mx0CfXSR6UXqbUn dguHNLtM+ir+qgid1b0WJ9SI3b8hxcX2P6U5NkAvYIDJKRzUwkVnKHJszs5C7d/SjcoV C0AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=vLDKuH+/Y6R1wGAQGSCIi/9agKk/j9gR7pNqj2Ro2Ic=; b=NGKkLnA3hd2NE4ghB6+4hIJSTtb9cJr6cmxiq2kByYTcHaMMPuXfTna4e9gbFu71KV 0+2i8dk7lLBpKWbif4YO2GlQZDEHSmzC5x/AXN9o1R6D+DA3j16adeONyzHjihQl3Ate vXyUXu/Nk2VT/F9WV0kk5Rx1b3dOBo/b8mQOGnf+KkkfF754NYokhQsrG46G0FsFS6af 5FxhCh10lwiGL7r59EDa4u/OfcxWvWN5XXVhr6S9EgvZzJJK9/2CWxKGXzYs4n+9AIsI VR4Z1TrlLrMbpzCfl8JMkC8D6kAsneqVk+f5H7jzUzH4WDAjJx0bIu48WODzUb193Bjt +YOQ== X-Gm-Message-State: APjAAAURGDLiJx2rt9SaVWaZH/4vSPhunCbqFT8Yw94P4XM0Vxd03yba AK0mT27eiIhOokDDR+0ITTbx7mM9Yt3W/8VirXQQyg== X-Received: by 2002:a19:c1cc:: with SMTP id r195mr53854149lff.95.1564498336043; Tue, 30 Jul 2019 07:52:16 -0700 (PDT) MIME-Version: 1.0 References: <20190215024830.GA26477@jordon-HP-15-Notebook-PC> <20190728180611.GA20589@mail-itl> <20190729133642.GQ1250@mail-itl> <20190730142233.GR1250@mail-itl> In-Reply-To: <20190730142233.GR1250@mail-itl> From: Souptick Joarder Date: Tue, 30 Jul 2019 20:22:02 +0530 Message-ID: Subject: Re: [Xen-devel] [PATCH v4 8/9] xen/gntdev.c: Convert to use vm_map_pages() To: =?UTF-8?Q?Marek_Marczykowski=2DG=C3=B3recki?= Cc: Boris Ostrovsky , Andrew Morton , Matthew Wilcox , Michal Hocko , Juergen Gross , Russell King - ARM Linux , robin.murphy@arm.com, xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Linux-MM , stable@vger.kernel.org, Greg KH Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 30, 2019 at 7:52 PM Marek Marczykowski-G=C3=B3recki wrote: > > On Tue, Jul 30, 2019 at 10:05:42AM -0400, Boris Ostrovsky wrote: > > On 7/30/19 2:03 AM, Souptick Joarder wrote: > > > On Mon, Jul 29, 2019 at 7:06 PM Marek Marczykowski-G=C3=B3recki > > > wrote: > > >> On Mon, Jul 29, 2019 at 02:02:54PM +0530, Souptick Joarder wrote: > > >>> On Mon, Jul 29, 2019 at 1:35 PM Souptick Joarder wrote: > > >>>> On Sun, Jul 28, 2019 at 11:36 PM Marek Marczykowski-G=C3=B3recki > > >>>> wrote: > > >>>>> On Fri, Feb 15, 2019 at 08:18:31AM +0530, Souptick Joarder wrote: > > >>>>>> Convert to use vm_map_pages() to map range of kernel > > >>>>>> memory to user vma. > > >>>>>> > > >>>>>> map->count is passed to vm_map_pages() and internal API > > >>>>>> verify map->count against count ( count =3D vma_pages(vma)) > > >>>>>> for page array boundary overrun condition. > > >>>>> This commit breaks gntdev driver. If vma->vm_pgoff > 0, vm_map_pa= ges > > >>>>> will: > > >>>>> - use map->pages starting at vma->vm_pgoff instead of 0 > > >>>> The actual code ignores vma->vm_pgoff > 0 scenario and mapped > > >>>> the entire map->pages[i]. Why the entire map->pages[i] needs to be= mapped > > >>>> if vma->vm_pgoff > 0 (in original code) ? > > >> vma->vm_pgoff is used as index passed to gntdev_find_map_index. It's > > >> basically (ab)using this parameter for "which grant reference to map= ". > > >> > > >>>> are you referring to set vma->vm_pgoff =3D 0 irrespective of value= passed > > >>>> from user space ? If yes, using vm_map_pages_zero() is an alternat= e > > >>>> option. > > >> Yes, that should work. > > > I prefer to use vm_map_pages_zero() to resolve both the issues. Alter= natively > > > the patch can be reverted as you suggested. Let me know you opinion a= nd wait > > > for feedback from others. > > > > > > Boris, would you like to give any feedback ? > > > > vm_map_pages_zero() looks good to me. Marek, does it work for you? > > Yes, replacing vm_map_pages() with vm_map_pages_zero() fixes the > problem for me. Marek, I can send a patch for the same if you are ok. We need to cc stable as this changes are available in 5.2.4. > > -- > Best Regards, > Marek Marczykowski-G=C3=B3recki > Invisible Things Lab > A: Because it messes up the order in which people normally read text. > Q: Why is top-posting such a bad thing?