From patchwork Sun Dec 2 06:27:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Souptick Joarder X-Patchwork-Id: 10707871 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 35CB413AD for ; Sun, 2 Dec 2018 06:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2249728708 for ; Sun, 2 Dec 2018 06:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0FBA82874F; Sun, 2 Dec 2018 06:23:56 +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 9DBE928708 for ; Sun, 2 Dec 2018 06:23:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D93196B61FE; Sun, 2 Dec 2018 01:23:54 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D41FE6B6201; Sun, 2 Dec 2018 01:23:54 -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 C58D86B6202; Sun, 2 Dec 2018 01:23:54 -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 883406B61FE for ; Sun, 2 Dec 2018 01:23:54 -0500 (EST) Received: by mail-pl1-f197.google.com with SMTP id 4so7528415plc.5 for ; Sat, 01 Dec 2018 22:23:54 -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=M3N/f38Tbl2yRteXToDvDYSdPb9qPQX7r0E5O0V4AbMZfvu1BtaLOvmDxI5TqoWCwx jMwANTJ0h3H5IZQUrV7vjGJkNO/XZkhfVKsFDBCUKoGJTQOmakG/yCFx6i3xQ0oK4Oo/ nOYIAKFrTgwsyn+BP+4QWtvj9oqhQHXyDUj8lOqwMG5SxjbhHYcRASthuybDNR8qUl9G eDD38DvLwMeYy1NP4K6H08oNsPCUHsbZq7WowmhMz0wI6aHsC08Udjdrrx72GTJfr5r3 ngrecL34cxHjJzzYC6jOERZXxDz5WgI4SC4C8lzZKTPgoEuCJz80+/A7mPP04756shGj o6Yw== X-Gm-Message-State: AA+aEWat8kBbmIbu0C0AhW6i33WXl6DTsm6CJcYIovJPKnpvNozMNS7r 3L7UUXugCSWFEQojzcHBe3SiODwpfFNkc1xpFVeGEEQjU1uwG0ImIvUF2RLson6WpYiuRj7Uubk KwkBdgbmxIRJZTjU4Ps9xCRkJSD8oAdXxdzVkyWr5vmMvTlYVYU6D/eWOi0TVqIK7oPkN4xr7Aw bBICklMXr4ubwQSv7eFdCaio7ATrdiKx+HhVO7ctMHe41vBGKFSGuv4wLscHUXVfZPbuH1kYtkT tpsrVtADiA5NDR2vPUB5btN8q+sKTsa5YOXIBsvO+rIa4vA21cduVxeS5L1jhRv/zyiDlmZNRa7 amgzCAlxYTn4KEHmy4awwBgdjpX7YVtjohG/fN/+5haupyKDrFxc34pXDYwDA7DCSBs8hQqSQz0 Y X-Received: by 2002:a63:790e:: with SMTP id u14mr8394977pgc.452.1543731834238; Sat, 01 Dec 2018 22:23:54 -0800 (PST) X-Received: by 2002:a63:790e:: with SMTP id u14mr8394969pgc.452.1543731833634; Sat, 01 Dec 2018 22:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543731833; cv=none; d=google.com; s=arc-20160816; b=izRIW4+dP+2b6SrjqJau2qQ1y0Dme0iYYuOaVrJ+41kVIFQi4Ewo+aH0IkFvJaRvOk Pt53ANk6UZHzViqTCCGoC++O982/BFFAQDQhXQgHVYF+uKHi0Jpf+4D7u9iDrfLDEYPK OVo/EZMg26CzZZiTb7XyZ26UQNfg9OPpBTNTzt2CTXTYyhFGqg/xVW1GUH6ilHbPxwht q08YIcPsvgL5XpmVm5VGfmqjKE5+l1wNDhoPt8gSQ/QLlyUPJ/wLaBlRNoEHZKgaSINu kVxk9gH/ooa9sb4nrn2QNmFUungC16izWU5AEeyVnhgmGYsysITnxAeLY6G/LNjBw6Lk JjbA== 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=q2T/wn7CLU7qPiBf0I8fc46XTeIDDe65ErQU8AEJTC2cmWAW92qydOr1D5vfHCp+cE wpa58XsBgdAXmR1G5bzVfMKynssOC9IlKOHTLYxGxkIHAUdD7tAiGSm7aEm6Hm08q0K5 48bpHzIBHGUPuEkhBANvcsDUunZ3mzeddFKT2k2yREH+dxFLXgx+VA4ZgB52tQgAcKif X2Q9g2fYuptDvbRyeytd+FJ5ahX67pPwv4z20AhG9TRrMvhyr3mt9xJ2T0LlODzzASp8 kqXjNfIMnkc2AavwSsLgtRe9RwRP2oYYuBU+0mZLS4OFjjFfWmhzysNcVzmIzUZ+Q1QG HQKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jBK5v4eT; 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 a4sor13596898plm.47.2018.12.01.22.23.53 for (Google Transport Security); Sat, 01 Dec 2018 22:23:53 -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=jBK5v4eT; 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=jBK5v4eTeFUcYgaR+VLRi9deC6Tupa9Mqh0p6nmBGPzYYWw2U743+twg2EQuBBpceD JgfOJYhqiH2frDarCFg4yosdUP8Xn8XfB7jh+RN4O4NCn0/1yE8FMtJTK4kKjq7rZ2U6 lSqGXiLyfwYVjNi4wZpH78wgwZSNG/TubSbCzTjLT+KR2qhliCcWtIGI3i6GjVtqSwKT u/uayvqLwk1peAvdSgMWAIXxqOFTN34B+E2B8iZOpQUKwxGGlU1LqYAo7YfQ6v06V9Qa EaWl8geGVUvW8EQsIRoYf9dYnZUrBrH+U8j+P9IvAKaM99rd1ol8BrbajXXKBYukaQpz Z12g== X-Google-Smtp-Source: AFSGD/U5NpFo3BqmiepkzNLs4Uga3ZdburK9tg+IUhPNMqIBo3/fxHs2QepB5StkiSWDXo/iRcM3xw== X-Received: by 2002:a17:902:8ec8:: with SMTP id x8mr11611998plo.210.1543731832939; Sat, 01 Dec 2018 22:23:52 -0800 (PST) Received: from jordon-HP-15-Notebook-PC ([103.227.99.148]) by smtp.gmail.com with ESMTPSA id n70sm12795687pfi.185.2018.12.01.22.23.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 01 Dec 2018 22:23:51 -0800 (PST) Date: Sun, 2 Dec 2018 11:57:37 +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 v2 8/9] xen/gntdev.c: Convert to use vm_insert_range Message-ID: <20181202062736.GA3240@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 /*