Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp660504ybi; Fri, 2 Aug 2019 02:09:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9GOrVDRtd6i0U8ykQvOyEZDBoyk5dz/3wNCZ+fBS9vPrxxtqliDHQSVL6MZBQORJK4jdq X-Received: by 2002:a62:1456:: with SMTP id 83mr58899801pfu.228.1564736995183; Fri, 02 Aug 2019 02:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564736995; cv=none; d=google.com; s=arc-20160816; b=D6H5wIjd5tJCv3714oE+brm/m449vamaxWMrq3WYkx/wRW2MqQf5VkYTzYajLRV0hY hqSsnc4fQZntWFuTECOPJNPlt2lAoUNtIOsgsvN+LeHxs6ZE9kwoU6q6nNbc8kg2qL4r HItXIpcTW8UyrQ2UDlIypEYSoSPAJQ8gDlw87NAqL7ysBemUlPiUazpy0FrZpPOJtm9L HMrxB8hLbf1lnEdJzRp035/Ge0+r+AV1AUG5I5iioJ5O/B+qh3tfKM+bl7HAiLZcEKTp WuHrWUoHRjE/b+DKNRISJmx1s4F8P1iUWd/59tcEvvnRDOLqCofOUiOXq5vNhX36vd43 Ut6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=OWvjPY2RJnSXiNaT1G8Eyahp8MUAsm98cTkExQmaDUY=; b=M53AEMsu9T8ocCmptQPfAmLDZ5pnPGPi+c7QCM3rftNXU9hU5QgkpE+6HXLgHdbWz4 OySvBu8Pb8yW2YIgII7E5o/ONBaYLYDQghbBUiBbMFksZNAOJNZ1XVtJMeLQ4JXxcouB G5CGuNtDysif7rmvUlY6Q8mLsZ0Rz8mlaclOkDdbNyvFjtjBG81zwWCloZPLvz2qfvDv MQLy+YWcY1zd+PVqs8dQ1I+NQC1BQc/GEWsaYRWCxEwoX9ELcB7wYZBJI+Bv163srEOm kz9Pbolwam+NDJrvdMrgMSIV/VP2tK+cMiezDx9dd0XWmhwEp2z9yVQHjDAWdDMFM01v yszQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=g4+wbBM5; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b38si33142619pla.65.2019.08.02.02.09.40; Fri, 02 Aug 2019 02:09:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@nvidia.com header.s=n1 header.b=g4+wbBM5; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387456AbfHBFt5 (ORCPT + 99 others); Fri, 2 Aug 2019 01:49:57 -0400 Received: from hqemgate14.nvidia.com ([216.228.121.143]:2974 "EHLO hqemgate14.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728714AbfHBFt4 (ORCPT ); Fri, 2 Aug 2019 01:49:56 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate14.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 01 Aug 2019 22:49:55 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 01 Aug 2019 22:49:54 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 01 Aug 2019 22:49:54 -0700 Received: from [10.2.171.217] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Fri, 2 Aug 2019 05:49:53 +0000 Subject: Re: [PATCH 20/34] xen: convert put_page() to put_user_page*() To: Juergen Gross , , Andrew Morton CC: , Dave Chinner , Christoph Hellwig , Dan Williams , Ira Weiny , , , Dave Hansen , , , , , , , , Boris Ostrovsky , , =?UTF-8?B?SsOpcsO0bWUgR2xpc3Nl?= , Jan Kara , , , , , , , LKML , , , , , , , Jason Gunthorpe References: <20190802022005.5117-1-jhubbard@nvidia.com> <20190802022005.5117-21-jhubbard@nvidia.com> <4471e9dc-a315-42c1-0c3c-55ba4eeeb106@suse.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Thu, 1 Aug 2019 22:48:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <4471e9dc-a315-42c1-0c3c-55ba4eeeb106@suse.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL104.nvidia.com (172.18.146.11) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1564724995; bh=OWvjPY2RJnSXiNaT1G8Eyahp8MUAsm98cTkExQmaDUY=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=g4+wbBM5eRNl11+v4FSAl8PrvEnWACjbjTJMUv4Ewv3g+h7PgD8hueH5dPeoF8sW5 c20eFrVi38BUjWugKSUxA2GH7CM3A3OrXQMppFfNCHg/NTgln/g1EuAeIEfsheR70J 47ajhTYRdBziMz0qVCHRjvKDjLN869T+rpjyKMqZQbhfLl80UOF5a6wxQMkyYeuu5C +SnQBQbOJUSigTfdZ2ZjmuC0GsGJhOMqTD72slI2rg2m1d7LKmLad2tBrS2UUN+9aI ixGXEdOyIH0YMQhEWsNGgp8xCyCNq0cOZ0EzzfGMekaZZJReXbXnLe2japHjsnQzSN gxuwPmkfTC8TQ== Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 8/1/19 9:36 PM, Juergen Gross wrote: > On 02.08.19 04:19, john.hubbard@gmail.com wrote: >> From: John Hubbard ... >> diff --git a/drivers/xen/privcmd.c b/drivers/xen/privcmd.c >> index 2f5ce7230a43..29e461dbee2d 100644 >> --- a/drivers/xen/privcmd.c >> +++ b/drivers/xen/privcmd.c >> @@ -611,15 +611,10 @@ static int lock_pages( >> =C2=A0 static void unlock_pages(struct page *pages[], unsigned int nr_pa= ges) >> =C2=A0 { >> -=C2=A0=C2=A0=C2=A0 unsigned int i; >> - >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (!pages) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return; >> -=C2=A0=C2=A0=C2=A0 for (i =3D 0; i < nr_pages; i++) { >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (pages[i]) >> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 put_= page(pages[i]); >> -=C2=A0=C2=A0=C2=A0 } >> +=C2=A0=C2=A0=C2=A0 put_user_pages(pages, nr_pages); >=20 > You are not handling the case where pages[i] is NULL here. Or am I > missing a pending patch to put_user_pages() here? >=20 Hi Juergen, You are correct--this no longer handles the cases where pages[i] is NULL. It's intentional, though possibly wrong. :) I see that I should have added my standard blurb to this commit description. I missed this one, but some of the other patches have it. It makes the following, possibly incorrect claim: "This changes the release code slightly, because each page slot in the page_list[] array is no longer checked for NULL. However, that check was wrong anyway, because the get_user_pages() pattern of usage here never allowed for NULL entries within a range of pinned pages." The way I've seen these page arrays used with get_user_pages(), things are either done single page, or with a contiguous range. So unless I'm missing a case where someone is either a) releasing individual pages within a range (and thus likely messing up their count of pages they have), or b) allocating two gup ranges within the same pages[] array, with a gap between the allocations, ...then it should be correct. If so, then I'll add the above blurb to this patch's commit description. If that's not the case (both here, and in 3 or 4 other patches in this series, then as you said, I should add NULL checks to put_user_pages() and put_user_pages_dirty_lock(). thanks, --=20 John Hubbard NVIDIA