From patchwork Thu Nov 15 15:51:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10684673 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C120C1747 for ; Thu, 15 Nov 2018 15:47:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AED0F2BE0E for ; Thu, 15 Nov 2018 15:47:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A2A332C955; Thu, 15 Nov 2018 15:47:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4470B2BE0E for ; Thu, 15 Nov 2018 15:47:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6FCD96B04A0; Thu, 15 Nov 2018 10:47:51 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 682B76B04A1; Thu, 15 Nov 2018 10:47:51 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 527136B04A2; Thu, 15 Nov 2018 10:47:51 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by kanga.kvack.org (Postfix) with ESMTP id 0B7A96B04A0 for ; Thu, 15 Nov 2018 10:47:51 -0500 (EST) Received: by mail-pl1-f200.google.com with SMTP id v11so9835116ply.4 for ; Thu, 15 Nov 2018 07:47:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:date:from:to:cc:subject :message-id:mime-version:content-disposition:user-agent; bh=io202K/f8USMQZXbIPPlFl1CkxJtDZmQ24ViVn7Bo2M=; b=fjYFSD4zu/I/iev9x5C9/kKuUGnarg4aM49qAsbwrKw/MWyc6dOD4MyXCrfyr4K51A HdSLCq+NoaNkGjlP7EIQ+WgTJNfMnuZL4z4u/+eDbBFvfxLBit/8ONSbUmmL7u3aFWmk 3BChusXwNVK3ZceX+PCfHqmas20IQWSvO5db2jXpm6I8VIS+bintOrCigOg/2VyeTy42 fCu5MiksjLUDd8mKoAwnpNyV+CBEyDhrisUBuvsz4AFM+D03VmV1A/ePpBEJ/Cg14vj4 /SkBskSCoENUeBDy0q8dcKzOn7CoMLvyKfM+gr5EGKXpy3b9jsmvMJHGFbpkcKNdyeR5 qr1w== X-Gm-Message-State: AGRZ1gJu08l3dMqUoFyx5cVeJu66XtYt21aVBfHk/PRa2dtBT3dk2guB HScB8jTvaCByiRaOcOt/JwpMI3A0w33Pkt2476v1ubJsNCDjl71lihPtN+IFpMhSPiY8Uynuh4U uUxwI9xBI70t1ndKm1Zpo2hsNwnBBx6JFhj4bU7/wbbUH4+w0eGCAeWbQ60qEvHe7UHWbWxjF5z GNz4FyHvmwu1OmtqtTdBxqtK+aFRAQhSJyFkmXZZpL8V5MQXeotUbEdYMnCDegeyzWt/U6sknyb MSSHXfuuH73TarFCN57bUYNT5RD7Zbtj/aKU7B9O7I/hVdXWgR0TtLTxjGS54eDseZuYrTxQbpx xgibX4GJdUFWYLhuRZ9D2u2gW4fHxZB+3/s6GeGgcRx+2CtbHyWRfSUQF1n6SCb0U7v4lQMPawk U X-Received: by 2002:a17:902:700b:: with SMTP id y11-v6mr6646898plk.323.1542296870728; Thu, 15 Nov 2018 07:47:50 -0800 (PST) X-Received: by 2002:a17:902:700b:: with SMTP id y11-v6mr6646870plk.323.1542296869850; Thu, 15 Nov 2018 07:47:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542296869; cv=none; d=google.com; s=arc-20160816; b=PvFIqpYBFPlxxFTDsTHSuUKHKAMTaBlYe0sAMbHzMmmZ2oN0ZW1V4MbosHB9ROJzyS sTZ4o+jKjsbCFztQi4H05jYmk4KEUjw+WMJigyG7oXr3kHvtUrZU7a5Kwd3kKFeDqWeB ItaLFYWhksZVaWsjZg8iEcDpcTUu9AwKeXvdTI7jFZBYDIA4h+4VPHZkz9SOA0fGnuOi gA0NH+KX9Gmv+M+nX6p8CiKWFgRSVqe7wwV+bkXvhoIooB+SdPk3vyJGZxB2zs4kemDg nnBuPXz7I0MWUzew82skm6sRSZLyoyYji8sCsWEFXzJclDotvxWK8Cee40GvmEZqJQm6 1fcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:content-disposition:mime-version:message-id:subject:cc :to:from:date:dkim-signature; bh=io202K/f8USMQZXbIPPlFl1CkxJtDZmQ24ViVn7Bo2M=; b=pil045TWNb0eYawT1fdUcs4grEkGl6/xsdd1eDex9FAqVJI4roDH1aLWdddft2dK5s u4x3HJy02Swz0C/YPyUZRLfJ2Umi2qqq7MTPLvjqrLZ2HboEFT3G4Ixv9Rlfgd7DNN+a hf+VNs6IJRz5D9RRyUM36wSSnon3K8GhkLSiI10EBtt/PoQyc5RCD1Nw9uQjDwF1xA2X VkiVCte6cAJ4pt2GBzYulNpla5OSDauuEe+DD9JZNN9Jd6NtD0kxT7jemrYJPAX23iFz 0vea0rN79nqqMD8ljMte6Mc8WZByWCTlAOK7F092A8NgmlYnlkPw2yD2iV62R3O8p+Tf NZYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FqwlFq7R; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id m28-v6sor26021478pfg.39.2018.11.15.07.47.49 for (Google Transport Security); Thu, 15 Nov 2018 07:47:49 -0800 (PST) Received-SPF: pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=FqwlFq7R; spf=pass (google.com: domain of jrdr.linux@gmail.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jrdr.linux@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=io202K/f8USMQZXbIPPlFl1CkxJtDZmQ24ViVn7Bo2M=; b=FqwlFq7RXy+tYLQhDZXhKCbRPAkRmfn2V/LfWtK/qmLG+Vie8Ebzek8qsl9WCGr9QA 0whTVQ3NWdP1mlPPtsMuVS01rpgpSMe39FgSof8wwl3pR3+Mu8h9fpqLlwo4nvV7MW3i NnUIQpSEuDi5MByoCRtFAGmyh5myCCSY5tUKZwPRtnGJLuWOiwzzw4YvpnCNxbj05mQg zZ3xjcfPFTA0ksT6ELqYnwZmGIgzc5iWvPBDTmi3L5l/raDs66ykKER5uzGdLMOX3/Gk 4gjXFN4347PwqkoehvwTeJaAEpJdj2zpJgNtSWxkg8m5Rgrn73DMSuw+0iubNN0vzC6b /qKw== X-Google-Smtp-Source: AJdET5fbf5V0Ydlq8wMOhTyby2SzmuPQM7mnUTR1SsYy9WXPx2SMZDGWG7EF0a46EpXzZq0230Srng== X-Received: by 2002:a62:4886:: with SMTP id q6mr2284395pfi.182.1542296869041; Thu, 15 Nov 2018 07:47:49 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.97.233]) by smtp.gmail.com with ESMTPSA id i88-v6sm59478434pfi.66.2018.11.15.07.47.43 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Nov 2018 07:47:48 -0800 (PST) Date: Thu, 15 Nov 2018 21:21:13 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 8/9] xen/gntdev.c: Convert to use vm_insert_range Message-ID: <20181115155113.GA28021@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Convert to use vm_insert_range() to map range of kernel memory to user vma. Signed-off-by: Souptick Joarder Reviewed-by: Matthew Wilcox --- drivers/xen/gntdev.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index b0b02a5..430d4cb 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1084,7 +1084,7 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) int index = vma->vm_pgoff; int count = vma_pages(vma); struct gntdev_grant_map *map; - int i, err = -EINVAL; + int err = -EINVAL; if ((vma->vm_flags & VM_WRITE) && !(vma->vm_flags & VM_SHARED)) return -EINVAL; @@ -1145,12 +1145,9 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) goto out_put_map; if (!use_ptemod) { - for (i = 0; i < count; i++) { - err = vm_insert_page(vma, vma->vm_start + i*PAGE_SIZE, - map->pages[i]); - if (err) - goto out_put_map; - } + err = vm_insert_range(vma, vma->vm_start, map->pages, count); + if (err) + goto out_put_map; } else { #ifdef CONFIG_X86 /*