From patchwork Mon Dec 17 20:26:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10734277 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 D495F1399 for ; Mon, 17 Dec 2018 20:22:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C77882A2DB for ; Mon, 17 Dec 2018 20:22:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BB91F2A2E3; Mon, 17 Dec 2018 20:22:22 +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 60FA12A2DB for ; Mon, 17 Dec 2018 20:22:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6E13F8E0054; Mon, 17 Dec 2018 15:22:21 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 68ED78E0033; Mon, 17 Dec 2018 15:22:21 -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 558798E0054; Mon, 17 Dec 2018 15:22:21 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by kanga.kvack.org (Postfix) with ESMTP id 148CF8E0033 for ; Mon, 17 Dec 2018 15:22:21 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id 12so9960899plb.18 for ; Mon, 17 Dec 2018 12:22:21 -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=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=tExc3HPBzaZWIfeouIiYijFXaHEb+/lE+iXk8SFzw+Tb4BmiUYCqxEtwxqiHeNrVPu m0d6N8iiaEEEOwGcNQkDJ00H0jywhXOFeBQhqdQ+4MS3TIPMT8siBwaW0iTHn8/3Ukdt 7k6FBkgIBuO+ypd7bOg0dxynmDcrvGGYqTQgOF80jxe4Z3JiFjKyWvMlRhU00ZB/HB08 CxkMt6L4plOhZOQ3sGGrHUnNkzb7eyR1dp1PNZtrTiWHI5yacxObivuz1XIofE8hwY35 G5DeSsOiNZG/mZWZPiJ46DgTV2iu0RdwBclKkjnU7pD4/GD6dtrVJIBdyAxzbZ1V5Eh0 TZJw== X-Gm-Message-State: AA+aEWYdJT8av0UGEUlSJWq+q8QvD5O0u3tQKDvHoDHA7gbLTvIUbLiz cdDvLf0SXdd9ejT51g4Z/b1j6cYp1mnrAXe1GAP6UlP8KcjBGd7d9yTB97JxpkqEObBUeiv4bJZ dksxXxEwcJAaeM2NFbTEZCrgNS2qqxT3wbCDv74y5bqAt4wJ3o1lbjjhABeIkecXtAyUG65WuwE Z3/yeSg5Egt20iMcsd0jIWXrsmJytV891v/HQ3diJekLHrWsOZDcryI84kll3jKkoQ4HjFeVBQP QTu3PZdb116gVkJnr8PjvhwZy0sAgB3pbrbS6uK0W96utcDqe1/RWvdlrBqsbRBZkIUOi7b2WXp bsF0LIr6URKoQMyAvOAORDRAtZvt3Q9tgu9GNX/4Xp7TSpUPurQlxHTvM2fWn+TELFz9+PsyJwE / X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr13685825ply.4.1545078140762; Mon, 17 Dec 2018 12:22:20 -0800 (PST) X-Received: by 2002:a17:902:d68c:: with SMTP id v12mr13685795ply.4.1545078140074; Mon, 17 Dec 2018 12:22:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545078140; cv=none; d=google.com; s=arc-20160816; b=Io+JiGjJXeaLutGh6vTmglODhJZ0Gk5ptu92pOWtxoRtWt693sCBa610D32BSd+yau F0voQ8KJxKbTHDs4yla19o6jCPORAE9NqWJSBgVEzF5n058Hqg0+KAhnRw2jbyvhQaJD ZIedxhONKp+CkNMiPIFvncTrq8Jm+AscUsoBhKhIklpQ6CWAwYD+YZeXEVk2NGefDz2c k/fniUjrg93Y8nCRiWhUiOp8kt+jSrCzlJsHr4FTZrg9QYzmU+nB1BXNeAP9B0Ni4CQS iWbCUoLe4GkkOCF9k49Yhfzn/8F/EgVz1rve6OptrQJJ3P7x/zMaqlMCiWQveqGkh7Zo ANrA== 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=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=JaOb7iQaleCYHDzNyoycbNr95sItL23jfJ+W3cnXrDXoMpszKDcZPjQa2BWHdCeXaD elHHDXPNaVDreQNXegTZb//nKL4mFRgdPAHHUOSFK+qwU41WP3KpIywbL+oC1dXeUbaP TRjaxuhgVAaXjxbPeo1TEs1r1BugndtNAFSM2cS74sVqnrxXV8v7GE3NBYAFRNOSgqJo 4ZO/BSJJciVXpRC4Q6Ix2EYcupBF6iRIekwvicEfeYhLPVIhFekIBMY4SUKEt5VviqEF hS7e+4qXKAu44IdJU024turQCy4U+TN/X3duFBO9EypgWRo4YqlyPRS6R7+lFueYCqeQ 50yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YSZkZtXB; 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 j6sor21681597pgq.46.2018.12.17.12.22.19 for (Google Transport Security); Mon, 17 Dec 2018 12:22:20 -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=YSZkZtXB; 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=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=YSZkZtXBTHutf0Vc6xE9hpWLdTQiV0LBpPh7E+tGHV4rn+ag0zPdwRG7EhkmCvu5/6 yTflbIXQRwtDKRjaheKdvZczHREL9dDm0/E0PPXryDAWVQ1dDjNVkODJXONGFs+RsHmZ 9HNE6lVp8ggq9J6oHg936hoELYz6z8wtqRf81Vvy/bMDI8ExoKDF7l1o68npz7cPk2Sy YC9Ch92Pwljml8KoQEwsMqimggKvRDSIjrVepRbxWARIW1NHzU1UMUrU/n5ktuoTHkdV BQryqdLvLjclBgcR19werYAe9q9hfgE3vV0axOgnsZFNEWZaRjI5QsFda/Y7dZWG1030 9uvA== X-Google-Smtp-Source: AFSGD/X+TrNR9f9V81XBDJgY79N2l38Sd7IjU/SS/fpnE4vfFVwlgbpFPPLma7Xyy+Ak6jm6z2ZBzw== X-Received: by 2002:a63:62c4:: with SMTP id w187mr9217308pgb.230.1545078139265; Mon, 17 Dec 2018 12:22:19 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.98.208]) by smtp.gmail.com with ESMTPSA id h79sm24507341pfj.186.2018.12.17.12.22.17 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 17 Dec 2018 12:22:18 -0800 (PST) Date: Tue, 18 Dec 2018 01:56:11 +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 v4 8/9] xen/gntdev.c: Convert to use vm_insert_range Message-ID: <20181217202611.GA18060@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 Reviewed-by: Boris Ostrovsky --- 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 /*