Message ID | TYWP286MB23193621CB443E1E1959A00BCA3E9@TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp415234wru; Wed, 9 Nov 2022 08:00:22 -0800 (PST) X-Google-Smtp-Source: AMsMyM48Wdevw/kWZbO9+6dNU9MGRpXNXyg3UeXxM3XkImfmdgtfBasjt5Jkzo2lTOr7EXcv0xN1 X-Received: by 2002:a05:6a00:1343:b0:56c:5f2:2d8f with SMTP id k3-20020a056a00134300b0056c05f22d8fmr61245290pfu.6.1668009621931; Wed, 09 Nov 2022 08:00:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668009621; cv=pass; d=google.com; s=arc-20160816; b=QE/QriyajVazBsk8OQDMiTH0RZ8BBWvIh9dPgo3wZy1thhAjolY+OfgBmZ+6VuhZxv HlO/PB0+rjDgabTH1KgS0EgfOynUqdkuDP0FLVOrlHt/lQoYXVNWmQmDA0OXQtAdRtBR /qUlKQApeiwaKBRlq5773HaeWvlFDx8S3jfYNxJx73a2syPvGIHkmmD3uKwb+OZxZgPD dfxIfmnXyI+TW+2ps7hKB+sDY4ruhKWkwK2lZAySD8O4y+eLiizZkFBeezzyvQZQ6TdH 8P4RjavLINXZhkXNuaxjWZ7xRw65LtWgZei843oPM5wJwBDpri86lFUUxDzm25e+XPFB qk4Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :message-id:date:subject:cc:to:from:dkim-signature; bh=wViQGHfeKAwQpWV0FZ/IcdzonCQadt8T8lqofGRWorA=; b=HiEUEspIaIUPtXwGWz1a3sHaL3ZsDW9XS2AwoSXtVRxvDljljnyAgQ9NCY2B9n7yQA 7QGu78/lIcUvvX7H7XcVw7391nmEe+Urls2HcafXIf9/oS17DI0S0lGh8vFzqGowdKKL pqEWHwyEtnkkop/HC/x/S3qHUFkXUPXboYKppUsdFdn9vX+dpxnNQ1vC9zRs2Ds0u5FC BWeonm0pSLxK9tDUQRTKhSKvKo4lX1+DNQ3HS4GWfOv7M0Hg2grvP3bGETkH0y+7Q0rZ u+slA62SUkBUAaxMnD94WYXN2BTWWEIjDwSRdGtoxQPRk9w4tL6R+i/LT0iNYnp2pKXr d1rw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=OISu83yO; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e190-20020a621ec7000000b00541c0da3083si16466972pfe.302.2022.11.09.08.00.08; Wed, 09 Nov 2022 08:00:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@outlook.com header.s=selector1 header.b=OISu83yO; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=outlook.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231173AbiKIPiX (ORCPT <rfc822;dexuan.linux@gmail.com> + 99 others); Wed, 9 Nov 2022 10:38:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34270 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230174AbiKIPiU (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 9 Nov 2022 10:38:20 -0500 Received: from JPN01-OS0-obe.outbound.protection.outlook.com (mail-os0jpn01olkn2103.outbound.protection.outlook.com [40.92.98.103]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5051BD1 for <linux-kernel@vger.kernel.org>; Wed, 9 Nov 2022 07:38:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RvkniS11z+X9nsz5XwG+UUYga5lUAJO1oZ4VAmGzFxuLzyV6y4vIWbVqwroAYkL1eiOoHlKckqhrpDPMa3yzU81akd/DPZbKOtxOoxb8G/UeQMayn1SnxBb9dJcAmrdWMpPV8s+GP2+inMY/aGJwg3kzLE5alJnpQQyB7rkwVC+Zir89FjI2r0gA9SyVSN51ZcTw4hY7OLqZVjy8x0iogQb+1tJEl8/LbuMMHTNe6NJ2qiuhLFhZn7zS5mJnhPbmtEBy1nIeSHxNDfI06CKlTs3KYcy6bUxEwnvqVwH6Hi1BoQssqogjnPfpnm/+HKOdRpLuvBf7FKpA4JeumcBGRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wViQGHfeKAwQpWV0FZ/IcdzonCQadt8T8lqofGRWorA=; b=k3SF42vQLuthlugT7DLLTEsWdkg6itBPAGx6Hd18laZQDASH5GIjcSOEDgh4YphL2dRpblnBFCff3Rem1Uv+1UmEjT8oCnGd8Vy344smwBIYk3NAhqLjNNXFU7ZL8IjTnK7I1xuid5lJr3UOEhetk0JARPiLIU0w8Ek8T1sWCP0laK17Rqnjpuxcq1o8UOCLiv/jWLsePmkWc05WL69K0RvlqFWWc5cNxWksNtzK5DKcTDKzcmU6Xikk2TbAZTSFyEjEzPjo4BdepBrpjUWag5NFddr35/HpS5cSouqv+uktBMCIUCYIcXX0GLparAHZqEims73TtcGsJaNftmw/iQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wViQGHfeKAwQpWV0FZ/IcdzonCQadt8T8lqofGRWorA=; b=OISu83yOtxmWZC/JmWhCMy7B0gECwa9kU2mYWbriV6yBYxfEG9vE6N8xeTisSfQSAeIV3rpwxh4+jr2gT9Nvsrjsn3hew88gdPWI2jkey0kdEsxl9rcYfBOpRi1F+oeuKZhGGbMkaCwqR4GZ6XooX/895pF/43XEI81vhT3OEUtDd8G5WF0CKpDi0N6cvyrBtj0f6Yc4q0HjCTZKyx/k8evevFlNk4ud8v02gNw+v7S9cMAozn2s3yhRTIgZMOH81rhhNB1D4y4ISiPLA6c/OgsoAKKdYm87L6M89tbkIO2kiZ8dCEmrjbGgpUvCKSVsRcuZJF/zGKd75jzlQbFYhA== Received: from TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:179::14) by TY3P286MB2674.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:255::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5791.27; Wed, 9 Nov 2022 15:38:17 +0000 Received: from TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM ([fe80::1ceb:6c40:8072:cc20]) by TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM ([fe80::1ceb:6c40:8072:cc20%3]) with mapi id 15.20.5791.027; Wed, 9 Nov 2022 15:38:17 +0000 From: Dawei Li <set_pte_at@outlook.com> To: zackr@vmware.com, airlied@gmail.com, daniel@ffwll.ch Cc: krastevm@vmware.com, linux-graphics-maintainer@vmware.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Dawei Li <set_pte_at@outlook.com> Subject: [PATCH v3] drm/vmwgfx: Fix race issue calling pin_user_pages Date: Wed, 9 Nov 2022 23:37:34 +0800 Message-ID: <TYWP286MB23193621CB443E1E1959A00BCA3E9@TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM> X-Mailer: git-send-email 2.25.1 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-TMN: [g9aQKeVsz2YFGD02l0l6IvPh/+ulB3n0] X-ClientProxiedBy: TY2PR01CA0006.jpnprd01.prod.outlook.com (2603:1096:404:a::18) To TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM (2603:1096:400:179::14) X-Microsoft-Original-Message-ID: <20221109153734.53018-1-set_pte_at@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYWP286MB2319:EE_|TY3P286MB2674:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f16a6eb-efed-478b-72fc-08dac2686bd3 X-MS-Exchange-SLBlob-MailProps: a+H6FLLcF3q7oSzhUd6OsUif7N+k8LGcBGvMemvAeKdWIxz1DK4qv8bSbs9O0yCocqtw0d9zOU0y+5xfSMCi9xvEkWUsi63TNugW0DP8QHj0raHUaHhoJ/rHgEEehlpFqpw7yS3KnHX4hamAvLOfnC0m8rulouFzxLBqGVSqcr5rhdlHRlJvs+C386FhdCRP/orKW0nOJvoIcMqxanmFF2nIfXQmmwSkepCEvIw/a359L4jtxl3oN38VeUlo9m8qXzaiI1mdSKSDT94ndB9cPU0beC7TM6SwvaKrVEO+js/rXRGn5woooGAH1ZLTSVMBJcgbbpqg3DPWDcbEiXdzdCxq2MKS4ADvQM+LpoyK98UixTABfiUl+fnjrjcSB6XXssmmw4Xmchl6FEifVyWYed3oy3W2XzdZR7XOeqygw7aE/A4qXZJViUSMIDHrEbCad/kVC0ZEq/SYeOAfWLXT0SI5hiKGMqYn68D79kDP7+q6NplHG4u5B3pb3tmiUiCBOL3dqtxDk9T9M4d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ug/Ua7fHc3n2ifUTcOKctiGG0jxH9nt/j+ipR5qcnuqQi6m4ZtW92qkAhGg7IqIwrgrPRvn3p8jn8NrXRS5cWfuydKXI+d7If09+5iP6BDg3zzJSspmM8boygXHJzOfHFa10RZPwyA0F9ICDMQcOLr3xITgXjnBsR/54lh+j6cXa6OpM1OZwKAgfYNw4yp7DF40Ix7cglelVXVVrZqzi9oFtl3KMN6N6bJGgX41hzktg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f16a6eb-efed-478b-72fc-08dac2686bd3 X-MS-Exchange-CrossTenant-AuthSource: TYWP286MB2319.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Nov 2022 15:38:17.1502 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY3P286MB2674 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749034857063580568?= X-GMAIL-MSGID: =?utf-8?q?1749034857063580568?= |
Series |
[v3] drm/vmwgfx: Fix race issue calling pin_user_pages
|
|
Commit Message
Dawei Li
Nov. 9, 2022, 3:37 p.m. UTC
pin_user_pages() is unsafe without protection of mmap_lock,
fix it by calling pin_user_pages_fast().
Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats")
Signed-off-by: Dawei Li <set_pte_at@outlook.com>
---
v1:
https://lore.kernel.org/all/TYCP286MB23235C9A9FCF85C045F95EA7CA4F9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/
v1->v2:
Rebased to latest vmwgfx/drm-misc-fixes.
v2->v3
Replace pin_user_pages() with pin_user_pages_fast().
---
drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Comments
From: Martin Krastev <krastevm@vmware.com> Looks great! Reviewed-by: Martin Krastev <krastevm@vmware.com> Regards, Martin On 9.11.22 г. 17:37 ч., Dawei Li wrote: > pin_user_pages() is unsafe without protection of mmap_lock, > fix it by calling pin_user_pages_fast(). > > Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats") > Signed-off-by: Dawei Li <set_pte_at@outlook.com> > --- > v1: > https://lore.kernel.org/all/TYCP286MB23235C9A9FCF85C045F95EA7CA4F9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/ > > v1->v2: > Rebased to latest vmwgfx/drm-misc-fixes. > > v2->v3 > Replace pin_user_pages() with pin_user_pages_fast(). > --- > drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > index 089046fa21be..50fa3df0bc0c 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > @@ -1085,21 +1085,21 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data, > reset_ppn_array(pdesc->strsPPNs, ARRAY_SIZE(pdesc->strsPPNs)); > > /* Pin mksGuestStat user pages and store those in the instance descriptor */ > - nr_pinned_stat = pin_user_pages(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat, NULL); > + nr_pinned_stat = pin_user_pages_fast(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat); > if (num_pages_stat != nr_pinned_stat) > goto err_pin_stat; > > for (i = 0; i < num_pages_stat; ++i) > pdesc->statPPNs[i] = page_to_pfn(pages_stat[i]); > > - nr_pinned_info = pin_user_pages(arg->info, num_pages_info, FOLL_LONGTERM, pages_info, NULL); > + nr_pinned_info = pin_user_pages_fast(arg->info, num_pages_info, FOLL_LONGTERM, pages_info); > if (num_pages_info != nr_pinned_info) > goto err_pin_info; > > for (i = 0; i < num_pages_info; ++i) > pdesc->infoPPNs[i] = page_to_pfn(pages_info[i]); > > - nr_pinned_strs = pin_user_pages(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs, NULL); > + nr_pinned_strs = pin_user_pages_fast(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs); > if (num_pages_strs != nr_pinned_strs) > goto err_pin_strs; >
On Wed, Nov 09, 2022 at 11:37:34PM +0800, Dawei Li wrote: > pin_user_pages() is unsafe without protection of mmap_lock, > fix it by calling pin_user_pages_fast(). > > Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats") > Signed-off-by: Dawei Li <set_pte_at@outlook.com> > --- > v1: > https://lore.kernel.org/all/TYCP286MB23235C9A9FCF85C045F95EA7CA4F9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM/ > > v1->v2: > Rebased to latest vmwgfx/drm-misc-fixes. > > v2->v3 > Replace pin_user_pages() with pin_user_pages_fast(). Gentle ping > --- > drivers/gpu/drm/vmwgfx/vmwgfx_msg.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > index 089046fa21be..50fa3df0bc0c 100644 > --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c > @@ -1085,21 +1085,21 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data, > reset_ppn_array(pdesc->strsPPNs, ARRAY_SIZE(pdesc->strsPPNs)); > > /* Pin mksGuestStat user pages and store those in the instance descriptor */ > - nr_pinned_stat = pin_user_pages(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat, NULL); > + nr_pinned_stat = pin_user_pages_fast(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat); > if (num_pages_stat != nr_pinned_stat) > goto err_pin_stat; > > for (i = 0; i < num_pages_stat; ++i) > pdesc->statPPNs[i] = page_to_pfn(pages_stat[i]); > > - nr_pinned_info = pin_user_pages(arg->info, num_pages_info, FOLL_LONGTERM, pages_info, NULL); > + nr_pinned_info = pin_user_pages_fast(arg->info, num_pages_info, FOLL_LONGTERM, pages_info); > if (num_pages_info != nr_pinned_info) > goto err_pin_info; > > for (i = 0; i < num_pages_info; ++i) > pdesc->infoPPNs[i] = page_to_pfn(pages_info[i]); > > - nr_pinned_strs = pin_user_pages(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs, NULL); > + nr_pinned_strs = pin_user_pages_fast(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs); > if (num_pages_strs != nr_pinned_strs) > goto err_pin_strs; > > -- > 2.25.1 >
On Mon, 2022-11-28 at 22:56 +0800, Dawei Li wrote: > On Wed, Nov 09, 2022 at 11:37:34PM +0800, Dawei Li wrote: > > pin_user_pages() is unsafe without protection of mmap_lock, > > fix it by calling pin_user_pages_fast(). > > > > Fixes: 7a7a933edd6c ("drm/vmwgfx: Introduce VMware mks-guest-stats") > > Signed-off-by: Dawei Li <set_pte_at@outlook.com> > > --- > > v1: > > https://nam04.safelinks.protection.outlook.com/?url=https%3A%2F%2Flore.kernel.org%2Fall%2FTYCP286MB23235C9A9FCF85C045F95EA7CA4F9%40TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM%2F&data=05%7C01%7Czackr%40vmware.com%7C7960fb10f8b443e33e4508dad150af04%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C1%7C638052441759507541%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=N9jdnLfT0kp9KifspFyH2GfmAwnH7NJdQE6255UY5JE%3D&reserved=0 > > > > v1->v2: > > Rebased to latest vmwgfx/drm-misc-fixes. > > > > v2->v3 > > Replace pin_user_pages() with pin_user_pages_fast(). > > Gentle ping Thank you. I've just pushed it to drm-misc-fixes: https://cgit.freedesktop.org/drm/drm-misc/commit/?h=drm-misc-fixes&id=ed14d225cc7c842f6d4d5a3009f71a44f5852d09 so it's going to find its way upstream soon. z
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c index 089046fa21be..50fa3df0bc0c 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c @@ -1085,21 +1085,21 @@ int vmw_mksstat_add_ioctl(struct drm_device *dev, void *data, reset_ppn_array(pdesc->strsPPNs, ARRAY_SIZE(pdesc->strsPPNs)); /* Pin mksGuestStat user pages and store those in the instance descriptor */ - nr_pinned_stat = pin_user_pages(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat, NULL); + nr_pinned_stat = pin_user_pages_fast(arg->stat, num_pages_stat, FOLL_LONGTERM, pages_stat); if (num_pages_stat != nr_pinned_stat) goto err_pin_stat; for (i = 0; i < num_pages_stat; ++i) pdesc->statPPNs[i] = page_to_pfn(pages_stat[i]); - nr_pinned_info = pin_user_pages(arg->info, num_pages_info, FOLL_LONGTERM, pages_info, NULL); + nr_pinned_info = pin_user_pages_fast(arg->info, num_pages_info, FOLL_LONGTERM, pages_info); if (num_pages_info != nr_pinned_info) goto err_pin_info; for (i = 0; i < num_pages_info; ++i) pdesc->infoPPNs[i] = page_to_pfn(pages_info[i]); - nr_pinned_strs = pin_user_pages(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs, NULL); + nr_pinned_strs = pin_user_pages_fast(arg->strs, num_pages_strs, FOLL_LONGTERM, pages_strs); if (num_pages_strs != nr_pinned_strs) goto err_pin_strs;