From patchwork Fri Jan 11 15:12:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10758225 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 BCC2791E for ; Fri, 11 Jan 2019 15:08:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A41F829C71 for ; Fri, 11 Jan 2019 15:08:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9892829F93; Fri, 11 Jan 2019 15:08:38 +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 30C2D29C71 for ; Fri, 11 Jan 2019 15:08:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F5AB8E000A; Fri, 11 Jan 2019 10:08:37 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3A3888E0001; Fri, 11 Jan 2019 10:08:37 -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 2BAB48E000A; Fri, 11 Jan 2019 10:08:37 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by kanga.kvack.org (Postfix) with ESMTP id DC6378E0001 for ; Fri, 11 Jan 2019 10:08:36 -0500 (EST) Received: by mail-pg1-f199.google.com with SMTP id o9so8585515pgv.19 for ; Fri, 11 Jan 2019 07:08:36 -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=vHKS//TZxZR6+MbFM/21TvVXK2jPLls5Bm50Y+Ae0UU=; b=O9dvjXcvY07shWRZ5A9BPf4Xz6KuETYML8n0p4A7+TkVOUwdSt09m9KJVK20+Yw7ZY 2pjEuFj5XSOYa6QighKGTNxjpVl2GJ0JocHVJiWuAyR334CG0v46N14neAqTCCr+URq2 2HXWU+RyPyWRFkNLlMBKPFO8eA/BV8Xj0AyerhF0LlL4xBf7+dTtcKV2BfPYLqAA/urK iRqD2D2uOqiT/WR1E+wQIxuNl+edUiBjVgL81fReGtclqFaxs91vZ2gWyju5LGZQJy/i 1PjgifUtA/vBVBsOFAaX6IltCupuxbmyVKFAWxqrzvJzx1dAj6F86kcDB0UB+/iru93X Q3eg== X-Gm-Message-State: AJcUukdvwQUkpduuOftPNYjVuUkRQVlDHUpsEohvoiDZgcaENuCf4fiN PVnFPLo/+nH2ZuNWSUvg17Dv/Dxk0iJENfhIzWlG/de+k2aZW6dQtaHx5Y/RHlCmN4RTFO99/jI Su3/6Lu2jyjJNhHsnlRGwJg7FNWSQawJLhLuJ7hUB08a4kdQ8t27bmJvU9t9hmt2UBqhPtQG73v g+TIDJX2gdLnNORza71A+Bz48YIN1GNznyBHpp0c/zvNzN7B9Wt+jWmTTSydKCnSuUg5TFtbsMv wqy3iN8xNXELFDPAeGNwz3PAtzdGivp1aqlLsf6zPOxd413Ab76mgdqsOQcTXtHwYfvdBgLSAH+ rmPCCn1btYg1nNf8aRDtuem2FsR2JJ6jzSRcJaPVK2726exYSqiPVDDJnuvkl20aD6sqZ69Rv26 6 X-Received: by 2002:a62:5d0c:: with SMTP id r12mr15481436pfb.0.1547219316534; Fri, 11 Jan 2019 07:08:36 -0800 (PST) X-Received: by 2002:a62:5d0c:: with SMTP id r12mr15481384pfb.0.1547219315628; Fri, 11 Jan 2019 07:08:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547219315; cv=none; d=google.com; s=arc-20160816; b=G2rze7XT+BOfRxCwO7quWFLT3pJOll6SjM/DLxudZSzBdw2XPD9v7bQfiwwb+Jsy7Y 44O9ZDiae5IZG3qkUOZbXRGj5u4Hzn7fptzgx28OJf2hjvopfHtsWidsCsG8rEXST/3h UiFC3v6psqL20BChMAq9DtI2wS7RXK+nE24kO9tzpL47DEA5CPTSxdrG1bl8ehO6lRJO AtLOZrFlFnCzeGPl0a92EbSS0vb1Jk9GPZxZ4BEM77MBLEE5BS0T1dujhsGNLI7xWE28 QzdKrE974IG9AZqDK0O3dNmk7TAMZpP1Wh5eTNlf+1QiGZcI/mCByKKDamvPJ3m0/Wae v/iw== 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=vHKS//TZxZR6+MbFM/21TvVXK2jPLls5Bm50Y+Ae0UU=; b=zMQVuOIb6YqfR/VFiAa3VmWNNjKmFLxDaDhLlVX51uONwGGkp6THTYDL1q4cwKYbyz tlZKIQ7CzwijiNdbBlRD85SdjxopRIKPGIDhMXJ7A3+Qj/2L7x+cnwukka++VjxtyCAR J+QAc9blWXPbV0qSTGVX6e11Ln6Orhv82yj495hALuSDH19Cab49oUOqjJ18DzUiAfoa 7BNXjVElzR71DeLVkGpro9DjgmCMpxjbmvSR7SYtFjlXU+gD/HABGjIOjct6z7NKuOnh Xcexd1G3N7h1dV7F1EyVK3t+DQpiSsieN7LTarqne/VzQNn0+xrMrloGpFnTABx+In37 X5eg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=X2l48CPq; 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 s20sor3526226plr.50.2019.01.11.07.08.35 for (Google Transport Security); Fri, 11 Jan 2019 07:08:35 -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=X2l48CPq; 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=vHKS//TZxZR6+MbFM/21TvVXK2jPLls5Bm50Y+Ae0UU=; b=X2l48CPqdu0frS3K3KzOnOT/wmG6wGo1EqRuCPkedTt5YZOuAUEF2j2JuISSDFg3BB +gMBjsDEfs74tgp6sGQktkRbEEwE+4OyUL6m09SMLZ2Zf9fRo4W30YKLfxtg9i3gJ/4n 0z3gaZBnL/DSYiChTec94Kid/dscMX348zoSRjHa9Nb8IzbXGOI5xAu7AgeVwQtDmuFu +AzXD0pz0dIQ5HI5CvA6LVWiieatC5fGrZpEVRmxPXGuzKWRstkm8100YxCMdK8oLi/8 ZtCpQyDhPmYLbeg2MtfFrhJdINQfZmpKjB1GpWLFd3riQDyB7RKNxa3mBG8iqylyBI9v ciEg== X-Google-Smtp-Source: ALg8bN5aDkgg5ldDKHA6yfV1TZQA+qcq0ZDkBcWhCzbgmdJ8IDlZXXhK+dZ6M/q0tbISuC4LhMUrgg== X-Received: by 2002:a17:902:2c83:: with SMTP id n3mr15194441plb.104.1547219314683; Fri, 11 Jan 2019 07:08:34 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([49.207.52.190]) by smtp.gmail.com with ESMTPSA id l22sm132710551pfj.179.2019.01.11.07.08.32 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 11 Jan 2019 07:08:33 -0800 (PST) Date: Fri, 11 Jan 2019 20:42:35 +0530 From: Souptick Joarder To: akpm@linux-foundation.org, willy@infradead.org, mhocko@suse.com, boris.ostrovsky@oracle.com, jgross@suse.com, linux@armlinux.org.uk, robin.murphy@arm.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: <20190111151235.GA2836@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: Boris Ostrovsky --- drivers/xen/gntdev.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c index b0b02a5..ca4acee 100644 --- a/drivers/xen/gntdev.c +++ b/drivers/xen/gntdev.c @@ -1082,18 +1082,17 @@ static int gntdev_mmap(struct file *flip, struct vm_area_struct *vma) { struct gntdev_priv *priv = flip->private_data; 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; pr_debug("map %d+%d at %lx (pgoff %lx)\n", - index, count, vma->vm_start, vma->vm_pgoff); + index, vma_pages(vma), vma->vm_start, vma->vm_pgoff); mutex_lock(&priv->lock); - map = gntdev_find_map_index(priv, index, count); + map = gntdev_find_map_index(priv, index, vma_pages(vma)); if (!map) goto unlock_out; if (use_ptemod && map->vma) @@ -1145,12 +1144,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, map->pages, map->count); + if (err) + goto out_put_map; } else { #ifdef CONFIG_X86 /*