From nobody Sun May 5 11:56:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1594524718; cv=none; d=zohomail.com; s=zohoarc; b=XCod0CzefYEkKlQV7TQNDmvfPmMGyvfsvY30Wod9N0QZ4E77z0RUGD3IoxE/wFVzdqo5/pzknnQipxQ1b/fVi7iyjF2H7KjChr2rceeG0wtpXf6H+66iWcafP0/XeHzD9slGrUk1RbOsFxs9cKJqrF2k1w8POgWbBmDJi7WZhbs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594524718; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=aJSWgi0xiDq2TEjOwzrr33u9Kob9ua2/jtyaxeBw01I=; b=IXSR9Y6TcEc9BNzfvLj83oUdNmtsLJHR1ZdVRibJTqtBu4OzM8zZqynn1IPfPrKsWXI8C5TbjmkrgofDw166LQVVeNUtfuIEmtz30knUcrOuSpGoalBx96oKXmn+eBQa015raAbqXcSC/rqHUsXphyRt5dKawHzevqizOOGNMks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1594524718200235.2477599136522; Sat, 11 Jul 2020 20:31:58 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1juSiH-0001nv-6n; Sun, 12 Jul 2020 03:31:37 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1juSiF-0001nG-3n for xen-devel@lists.xenproject.org; Sun, 12 Jul 2020 03:31:35 +0000 Received: from mail-pf1-x441.google.com (unknown [2607:f8b0:4864:20::441]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 2f373f0a-c3f0-11ea-8496-bc764e2007e4; Sun, 12 Jul 2020 03:31:34 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id m9so4487595pfh.0 for ; Sat, 11 Jul 2020 20:31:34 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.167.224.89]) by smtp.gmail.com with ESMTPSA id s89sm9750271pjj.28.2020.07.11.20.31.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jul 2020 20:31:32 -0700 (PDT) X-Inumbo-ID: 2f373f0a-c3f0-11ea-8496-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=aJSWgi0xiDq2TEjOwzrr33u9Kob9ua2/jtyaxeBw01I=; b=BJXHKUnEMD8COwDxple2uc80bG5s+/UbetrM7wV8qMA4W1AeaRkA1dUyAA+qm438vT Gy00Mc+YrUQxaq/DmQnTK1DFyC3H+fK0aLz6QNB/mvbhx4hZHMLc+AM+rAPjoq2VGf4k sTWacxWoTe8csdNCUsjNqLRQyLsgRh+itgowLckdvIv4Nqt2ooHoxOl3UtBKHxwHkPGa jgH0sN/FUstxj6s1MRpaEihCKLF7llJxium2YMebgjk+qKe3lORUerU1ZbCR0fNoAocG koPDJjKw+JGN2l7JqMyjXe2+sP64iRvf3HrcuZhNGqf+POiictvmNBqs9fI9orDMVJFq 7KEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=aJSWgi0xiDq2TEjOwzrr33u9Kob9ua2/jtyaxeBw01I=; b=ElqGhu3LePqe7f8xqa8bJ413NRB3lMIILWu+bNM4+mzKv2sHz0jqq9GjD9Z4awW41B ejtQsCrPxgBCRU/cQHTzUkcRmmKFPlhJjeohOIMjLTYd/2j2D0MLmpzXBP3lwsDyGIyE aAqpDWHQ/c0YmJtcrVJhYRPBjDq8r6STQYmr2+50tn+9QXB9e8ZBuyWrHuKCJc7zSFIJ hSsfkidYNrrFtZ+3pnznbeFuRd47Qq6fnx7GoiP+fFsMJzbSlz5jGGtJJJoK/I29KY/K CQmBtERSRPevryidq6Z71ZDlQ6lC2017I9p846g+pRnIF8gwex+9EPOHiMWrWAzmEg+J vYlg== X-Gm-Message-State: AOAM530Sl4h9ivQFa932WGkXZdPVMLOvtk7lsHRVP59PIRzlZ1QwK14w o5/wuwwx8dSH88VIl9aosBQ= X-Google-Smtp-Source: ABdhPJzGcosdIsNjTLJCw8K3Nj8FTvzS0ofcadybPbfYsTh6uAimwx5dECsp1E5FMwZE8E+TEIqYmw== X-Received: by 2002:a63:dd4d:: with SMTP id g13mr63445998pgj.179.1594524693521; Sat, 11 Jul 2020 20:31:33 -0700 (PDT) From: Souptick Joarder To: boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org Subject: [PATCH v3 1/3] xen/privcmd: Corrected error handling path Date: Sun, 12 Jul 2020 09:09:53 +0530 Message-Id: <1594525195-28345-2-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1594525195-28345-1-git-send-email-jrdr.linux@gmail.com> References: <1594525195-28345-1-git-send-email-jrdr.linux@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Paul Durrant , linux-kernel@vger.kernel.org, John Hubbard , Souptick Joarder Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Previously, if lock_pages() end up partially mapping pages, it used to return -ERRNO due to which unlock_pages() have to go through each pages[i] till *nr_pages* to validate them. This can be avoided by passing correct number of partially mapped pages & -ERRNO separately, while returning from lock_pages() due to error. With this fix unlock_pages() doesn't need to validate pages[i] till *nr_pages* for error scenario and few condition checks can be ignored. Signed-off-by: Souptick Joarder Reviewed-by: Juergen Gross Cc: John Hubbard Cc: Boris Ostrovsky Cc: Paul Durrant Reviewed-by: Paul Durrant --- drivers/xen/privcmd.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 5dfc59f..b001673 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -579,13 +579,13 @@ static long privcmd_ioctl_mmap_batch( =20 static int lock_pages( struct privcmd_dm_op_buf kbufs[], unsigned int num, - struct page *pages[], unsigned int nr_pages) + struct page *pages[], unsigned int nr_pages, unsigned int *pinned) { unsigned int i; =20 for (i =3D 0; i < num; i++) { unsigned int requested; - int pinned; + int page_count; =20 requested =3D DIV_ROUND_UP( offset_in_page(kbufs[i].uptr) + kbufs[i].size, @@ -593,14 +593,15 @@ static int lock_pages( if (requested > nr_pages) return -ENOSPC; =20 - pinned =3D get_user_pages_fast( + page_count =3D get_user_pages_fast( (unsigned long) kbufs[i].uptr, requested, FOLL_WRITE, pages); - if (pinned < 0) - return pinned; + if (page_count < 0) + return page_count; =20 - nr_pages -=3D pinned; - pages +=3D pinned; + *pinned +=3D page_count; + nr_pages -=3D page_count; + pages +=3D page_count; } =20 return 0; @@ -610,13 +611,8 @@ static void unlock_pages(struct page *pages[], unsigne= d int nr_pages) { unsigned int i; =20 - if (!pages) - return; - - for (i =3D 0; i < nr_pages; i++) { - if (pages[i]) - put_page(pages[i]); - } + for (i =3D 0; i < nr_pages; i++) + put_page(pages[i]); } =20 static long privcmd_ioctl_dm_op(struct file *file, void __user *udata) @@ -629,6 +625,7 @@ static long privcmd_ioctl_dm_op(struct file *file, void= __user *udata) struct xen_dm_op_buf *xbufs =3D NULL; unsigned int i; long rc; + unsigned int pinned =3D 0; =20 if (copy_from_user(&kdata, udata, sizeof(kdata))) return -EFAULT; @@ -682,9 +679,11 @@ static long privcmd_ioctl_dm_op(struct file *file, voi= d __user *udata) goto out; } =20 - rc =3D lock_pages(kbufs, kdata.num, pages, nr_pages); - if (rc) + rc =3D lock_pages(kbufs, kdata.num, pages, nr_pages, &pinned); + if (rc < 0) { + nr_pages =3D pinned; goto out; + } =20 for (i =3D 0; i < kdata.num; i++) { set_xen_guest_handle(xbufs[i].h, kbufs[i].uptr); --=20 1.9.1 From nobody Sun May 5 11:56:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1594524718; cv=none; d=zohomail.com; s=zohoarc; b=AGmsAJyhjAS5+KRyqPH7LEp2dgPDXgEemObrofpLbBoaZM8TWM+vCEhbhjeDTMrpQfQAOe+Qdce1N3PjrggkenGqT9os/SZB96XC3b1LeJPezijaH1xZV27OTWP5wnV4FjAcRObAYU0zvoOrtGGr+Y/AKbxZZcXgksDiPg4ATaw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594524718; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Z3iLvmsALgpeKkdpuNL17/HM7clfrVNQ9KU9ARLG1y0=; b=VJsEI1+4gEoOwoNVhwTYDMhO/sIdQa+gKnS0dAeDc5nToKGvINweIRdfXxVh+9bWBCGojQ3NuOrp4hOJceml3R0NIWlvANAFVtSNumMYIwuPeJh+iI+XDjZ3+cvnusdqEfZRYPDeB4E09wioyDS9FJNCFLrDIKLqkfL8BNV8Ldo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1594524718267562.1776708391444; Sat, 11 Jul 2020 20:31:58 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1juSiO-0001pG-Fg; Sun, 12 Jul 2020 03:31:44 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1juSiN-0001ot-5r for xen-devel@lists.xenproject.org; Sun, 12 Jul 2020 03:31:43 +0000 Received: from mail-pf1-x443.google.com (unknown [2607:f8b0:4864:20::443]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 342b6aea-c3f0-11ea-b7bb-bc764e2007e4; Sun, 12 Jul 2020 03:31:42 +0000 (UTC) Received: by mail-pf1-x443.google.com with SMTP id 207so4482629pfu.3 for ; Sat, 11 Jul 2020 20:31:42 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.167.224.89]) by smtp.gmail.com with ESMTPSA id s89sm9750271pjj.28.2020.07.11.20.31.39 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jul 2020 20:31:41 -0700 (PDT) X-Inumbo-ID: 342b6aea-c3f0-11ea-b7bb-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Z3iLvmsALgpeKkdpuNL17/HM7clfrVNQ9KU9ARLG1y0=; b=V4JjtjKfiTieITrJU1+IsNVyCXTofXiYb1IBwVWUF0NhkJZwo2pn4KSii2ojXEDJUI 66oIhsD0yr8miUbgs/hnkZguouIlQFh57D8QELabHjbdW1UxLxGLLNBkzNIsKUoO8gQJ hI8vluoROpyGtD3WEqXuxsbWXfeiLkK/6UD16CPnJbJHi0BlLgXvWM25njV3H3Hm/6s+ NwUxqQK575Tft3dW74YgxV38tHrMXyq+M4eIrmalxNhNHumwd5n531ub6o9lXtqZWAhu qqUOfZZHNjqwmn+xR0U4aefx1Joq7fTfTsBq4TT7aT6Qe32Y3aocPzm27rqmGh1kc35U jGSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Z3iLvmsALgpeKkdpuNL17/HM7clfrVNQ9KU9ARLG1y0=; b=mr6DK1W7A/9UuVVUnVuFmM6h9gwR6GD1t8oeV1ZMOs1x0lajc4+tBc7uFsYNXJIyeo B7S1QRriuiCZgkoa+vzW7rA/VscBQe7AcJa9kFZefUpXsdmSVqZWPlwJR3EZmZbmmWEG fa7e6UXeUpSFr9EVrYXapFZn9NDL2bbcvdDRedBNjW0RRv7BnvpA2rIcmC5LI8aExwn8 MFRBM2TD7MG/zm++2EqOvUyLB/q6t2ympaItx4AeTuUKC32pNJPgbasMXd3TF3G6A/bN 4mVT83xoDHV0xGLNbQT5rCqbbl14uQKO0WYxKjLeK31bA+V0sncjLeI+1n+ocuVOdG12 JX+A== X-Gm-Message-State: AOAM5307iRvgL7zxHhGRAeZDc+IetzkECHCnD62CKKwm9+H7rFVImSZn ACOMxu6PEltAbTHGNVBU1yI= X-Google-Smtp-Source: ABdhPJxXbi9KSZF/o0irOMdLPlhjV3pV92Mf5shXsy1/+Fp0VJiHmbskE4DYeA/T1f3pXWChiRQDSA== X-Received: by 2002:a62:3583:: with SMTP id c125mr21856884pfa.158.1594524701949; Sat, 11 Jul 2020 20:31:41 -0700 (PDT) From: Souptick Joarder To: boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org Subject: [PATCH v3 2/3] xen/privcmd: Mark pages as dirty Date: Sun, 12 Jul 2020 09:09:54 +0530 Message-Id: <1594525195-28345-3-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1594525195-28345-1-git-send-email-jrdr.linux@gmail.com> References: <1594525195-28345-1-git-send-email-jrdr.linux@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Paul Durrant , linux-kernel@vger.kernel.org, John Hubbard , Souptick Joarder Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" pages need to be marked as dirty before unpinned it in unlock_pages() which was oversight. This is fixed now. Signed-off-by: Souptick Joarder Suggested-by: John Hubbard Reviewed-by: Juergen Gross Cc: John Hubbard Cc: Boris Ostrovsky Cc: Paul Durrant Reviewed-by: Paul Durrant --- drivers/xen/privcmd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index b001673..079d35b 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -611,8 +611,11 @@ static void unlock_pages(struct page *pages[], unsigne= d int nr_pages) { unsigned int i; =20 - for (i =3D 0; i < nr_pages; i++) + for (i =3D 0; i < nr_pages; i++) { + if (!PageDirty(pages[i])) + set_page_dirty_lock(pages[i]); put_page(pages[i]); + } } =20 static long privcmd_ioctl_dm_op(struct file *file, void __user *udata) --=20 1.9.1 From nobody Sun May 5 11:56:45 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1594524726; cv=none; d=zohomail.com; s=zohoarc; b=bCX8n8ap3hCkMpgsax+QqkGhUplKbPO4D0oDc2E0TE58oc71W9AO8jd+4QlIqAP7Alxx+/ocKM9mtiHfEdH8mONG0DsgfBzX/W3H3u+/HErNsozBPYLKOGYbzAOGrY4OqC70NUAyeAIStkP7pGyUxuU/aqCYPHJWmI14F01qfBY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594524726; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=CSSDnsVzCbm4HJvWsVbXXkGEs9xedyGKl/Rt6nKFdOE=; b=Pn5rwbAuAj157JqmZM3u7wEb3egwFf7DQcf75TZtPgTmbZ5+TjdtIZtTpcbHb0xmEqzV2cFkLXGZeAvAGcQWj/uQnPkhKydcSzXaYUSUR24nxIpg/xSx5m7CDJlgSLWdu5C9l2ijIBmoHTl8EuXBj6G2kul8lACu5TLfSz0bTLo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1594524726045578.1573638812745; Sat, 11 Jul 2020 20:32:06 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1juSiT-0001qw-PR; Sun, 12 Jul 2020 03:31:49 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1juSiS-0001ot-8w for xen-devel@lists.xenproject.org; Sun, 12 Jul 2020 03:31:48 +0000 Received: from mail-pj1-x1041.google.com (unknown [2607:f8b0:4864:20::1041]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 373492d4-c3f0-11ea-bca7-bc764e2007e4; Sun, 12 Jul 2020 03:31:47 +0000 (UTC) Received: by mail-pj1-x1041.google.com with SMTP id gc9so4521787pjb.2 for ; Sat, 11 Jul 2020 20:31:47 -0700 (PDT) Received: from jordon-HP-15-Notebook-PC.domain.name ([122.167.224.89]) by smtp.gmail.com with ESMTPSA id s89sm9750271pjj.28.2020.07.11.20.31.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 11 Jul 2020 20:31:46 -0700 (PDT) X-Inumbo-ID: 373492d4-c3f0-11ea-bca7-bc764e2007e4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=CSSDnsVzCbm4HJvWsVbXXkGEs9xedyGKl/Rt6nKFdOE=; b=dbumPayO/fDTRmwmbfWoGMopnkBa2rTRRdhdRZxImMg+IAEJ4iJ8xxqnf4pNPHIBg1 Twl174xM19B2sWzwefd5I9eq27cj5l4WVLLgvH8RrIDAYsmA5AKM/GXypd5+wBM+d3m0 b34IyrConj/4kSOSkZLRoYbZzX/ILotrFvuLHy95osDmsX2ON1+iwKFO8738TKSReZYJ 2C7jOsaov4l/WQlCt1iLyoWVRE7qOPoZ20O3E9H/PPRrrQd7alB/0C/ybSJlCGcI7Ou3 aoh4/zO9wrDfQLZg6SgO+lQTHtcB2q2Xm6GAxchCvbsre8RS+cGwptniFoffEJI5O9D6 h6OA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=CSSDnsVzCbm4HJvWsVbXXkGEs9xedyGKl/Rt6nKFdOE=; b=SXsGadSeoX1Z9tsDe5i/OO9+Y+xDSSjO8sFg4ma8QBW+qnNjdwYYjm/OcaB2QdNLDi LE0zVsn2kPCDGNZ7+Dp+b//lC2lV9APp6nZnpFqMwnbpEtUotOLAMcGoVig5ntjakHG5 Zwh7Exl9bE6eWLyw009w1UjhJFZuzOP2KA0AZJQGnBYwT31fTJ4nhgYRbyxeg7Ixue9n VtzLP1BBR8UlnXZc/cZWrFmk7mQQRD56sAJmhuqRrE/abg4DuzFXesndL/9gEbpZqWL3 6Kg8KFf69ymclqmIAtUKu8V5eWpMqd6xSyGVNF4xuH2UijBN5vkJcAf1t+jqF4LuYKmP f1dA== X-Gm-Message-State: AOAM530sSl2F+04TDIrq8agun/xqwVDHPhsn9tccmbmJYAfVcNJ22KWu Q3cqcpGYLFaWyHrqzjUTuJs= X-Google-Smtp-Source: ABdhPJxjvGahtoyXNSccUhl0AeaffkZO4kJLPbsRyYmRclGhUYpFdroi35MHWOJWvCcdaQoqJ6BZFw== X-Received: by 2002:a17:902:904c:: with SMTP id w12mr22660155plz.147.1594524707025; Sat, 11 Jul 2020 20:31:47 -0700 (PDT) From: Souptick Joarder To: boris.ostrovsky@oracle.com, jgross@suse.com, sstabellini@kernel.org Subject: [PATCH v3 3/3] xen/privcmd: Convert get_user_pages*() to pin_user_pages*() Date: Sun, 12 Jul 2020 09:09:55 +0530 Message-Id: <1594525195-28345-4-git-send-email-jrdr.linux@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1594525195-28345-1-git-send-email-jrdr.linux@gmail.com> References: <1594525195-28345-1-git-send-email-jrdr.linux@gmail.com> X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: xen-devel@lists.xenproject.org, Paul Durrant , linux-kernel@vger.kernel.org, John Hubbard , Souptick Joarder Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In 2019, we introduced pin_user_pages*() and now we are converting get_user_pages*() to the new API as appropriate. [1] & [2] could be referred for more information. This is case 5 as per document [1]. [1] Documentation/core-api/pin_user_pages.rst [2] "Explicit pinning of user-space pages": https://lwn.net/Articles/807108/ Signed-off-by: Souptick Joarder Reviewed-by: Juergen Gross Cc: John Hubbard Cc: Boris Ostrovsky Cc: Paul Durrant Reviewed-by: Paul Durrant --- drivers/xen/privcmd.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c index 079d35b..63abe6c 100644 --- a/drivers/xen/privcmd.c +++ b/drivers/xen/privcmd.c @@ -593,7 +593,7 @@ static int lock_pages( if (requested > nr_pages) return -ENOSPC; =20 - page_count =3D get_user_pages_fast( + page_count =3D pin_user_pages_fast( (unsigned long) kbufs[i].uptr, requested, FOLL_WRITE, pages); if (page_count < 0) @@ -609,13 +609,7 @@ static int lock_pages( =20 static void unlock_pages(struct page *pages[], unsigned int nr_pages) { - unsigned int i; - - for (i =3D 0; i < nr_pages; i++) { - if (!PageDirty(pages[i])) - set_page_dirty_lock(pages[i]); - put_page(pages[i]); - } + unpin_user_pages_dirty_lock(pages, nr_pages, true); } =20 static long privcmd_ioctl_dm_op(struct file *file, void __user *udata) --=20 1.9.1