Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3609268imu; Mon, 24 Dec 2018 05:26:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN4GTtEVAzEcb7lJTuoFZa++CuZNHvyAia0yGvEniDPyt2N3SHVxlFpBRJumawy7eoVP2fOk X-Received: by 2002:a17:902:7296:: with SMTP id d22mr13215684pll.265.1545658003170; Mon, 24 Dec 2018 05:26:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545658003; cv=none; d=google.com; s=arc-20160816; b=Bhp0CrrA9virRapGv8YuaOJIivR49o8ElDhd6h8TfXSmCCiXimSjlxlISEFvF6VI7E RjhSRx23eDhLJdePbx6PGcE8cx9xFJG8bF+U5K18KtygZCJ4b8hD2NkLoxgU39J6Ps2L Pb2iqmXKKY3bFQ2hNzXopzOAPLd3MbNubvLRBt0o2Feraa7OHu0k7S9NRzQZ++XeTJEF dYJkqbHnZzuWu991YhVxjhvWwuTmrgQjsgQ4wcWspHpRS+r2Im1j/BGNVyBL7kdi0tMR K32DHhSbvLR0bai3wPz6L6pj/WznZtW3/uSirYD1UELrcGW1txfyFJJtLJufyRF1qU6I zGEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=ci/IbQ/xy9ATJNJsweFDE+Gu5glbK2RBJTtcBcnIiD5VcarVnXEa6IBoIzVPsapnVg gBChDGic3tFEAX+uVmYOEcOSyVqClL2PKKAH+sozVYbH0lGp9ZBq9huuG3JjfPfsz0tW A2SPG5+TY9gJHTdjeQwo2x6tSjc4Idy1BW/V4V3pB81j2sOuLLrrL1vELcf4Q5ArmmPq //U6NRIi/+JjWkoBlZpsSxAZ5lK/s+4NZgrkUjAoEt9+Ayl4rESevxkPdIcVztI8+eMC qcFFGIH/Nl6uSc1NoNeLsoFZKZLmJeTZ+9QaJNKoyey2ZtBHWaLSwc+Gg/u7UT8zT0XL QFPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=TRR1LFZv; 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 j2si26066682plt.93.2018.12.24.05.26.27; Mon, 24 Dec 2018 05:26:43 -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=@gmail.com header.s=20161025 header.b=TRR1LFZv; 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 S1726026AbeLXNX5 (ORCPT + 99 others); Mon, 24 Dec 2018 08:23:57 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44301 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725385AbeLXNX4 (ORCPT ); Mon, 24 Dec 2018 08:23:56 -0500 Received: by mail-pf1-f193.google.com with SMTP id u6so5796787pfh.11 for ; Mon, 24 Dec 2018 05:23:56 -0800 (PST) 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=TRR1LFZv4DfYv/CLFab1H5gXj9FSE49ggM9pEjq+0mbLtB24XCJVWTEVNxu0Jr9jfP aXbKP2W1rQImrZhnsPScKg7NvHRhWsdijVauyLC8/q8oJt9aXNkvOTG+GaQHcE5pxbm6 /59fC4l6pTS+IZajcvb/jzZViGymmogxlrCI16XH1zhfCvxeCGty+kKPo3aHKl8+RdZo MI2IYw/aF6aDHfPUint+1oUR14/QseDL4JSYv2rWDOEAubkmzlmurj4Ur7Z3MVCx04V/ XZkEMqDeY8uT1l/YnM82QqZIRuKbwbzLb81ZIRdTXIFOWwGOvoUNEOBI/XET/IrHk1B6 9I5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=w2N1lFnP7lwgyibZCv3zxC5CB8Y6AOTQeCb4v428osI=; b=gAcmpKcWOtqHN73RTog+N2x0pfYiyqRJ+rFA++REuHO1QzKfd+b48xb59TGL3hAJZG Fl+6stItTt7aBXVD3LPi4rDw7+OdZt0PvWFb5l/QSpgWeABs0qQLf29hOUuXv22nmh9C 4kW6Del6485Gx4qYtwJdAAsIZz2HD2d9y5ZMVkJ9+3cFrS4m+gqwkbepn9uPrOw7vJWn GVQ62XO1JOoGNljYAtE7VYfDifay+7OKF73m+KaNsfwCerVfl7ZYZH9BZmy2EllUa1wP d8taNc3LPFUyMesyAYriE6HqXtV5iemdaM5CXcDtelNGBMsQQg7kmtpGUlXq37hJ6iO3 zOog== X-Gm-Message-State: AA+aEWb9Mc9iHB1mcKv4MrrnCY1byyV85Ytl4YBgoGknfVm/64TmP8Gt gT9Wz2u6NEe1e8UD4vha1oY= X-Received: by 2002:a62:11c7:: with SMTP id 68mr13037815pfr.21.1545657836303; Mon, 24 Dec 2018 05:23:56 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([106.51.18.181]) by smtp.gmail.com with ESMTPSA id b26sm71332999pfe.91.2018.12.24.05.23.54 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 24 Dec 2018 05:23:55 -0800 (PST) Date: Mon, 24 Dec 2018 18:57:52 +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 v5 8/9] xen/gntdev.c: Convert to use vm_insert_range Message-ID: <20181224132751.GA22184@jordon-HP-15-Notebook-PC> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 /* -- 1.9.1