[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Linux pin_user_pages_fast fails on Xen


  • To: "Stabellini, Stefano" <stefano.stabellini@xxxxxxx>
  • From: "NK, JESHWANTHKUMAR (JESHWANTH KUMAR)" <JESHWANTHKUMAR.NK@xxxxxxx>
  • Date: Tue, 13 Sep 2022 05:35:23 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=qWZip0tRpXcF+5svqmGfGfLAz4B+pwQkh82ZzR/olYE=; b=miHdcRstnJWIGcFx19AnZGrZYHBAwEBybZJX8gP2ECbDEi6SQl8xlYTxeLSRNKEMtsRQyJn0qbPuJqR8wdUZUXLcP2PUcu27YrAl8pWoIm4I6WVbvyU1mk1c46tM2M/9Vg0dUKZehGvvn7jgQ/mfhUD4+7MTi7TUFcC269VOKt8Sr/Zk8CZz4Pldfr2DU6D0b4iJY8uG0Q1U0Je8XXLW3YIXjg7q046xwvnJNaKhPqw5D0xyqGtB2SMwVeOG+j5RSJSD/FzaLVLYZpah5yJn9KGvcB8MKRtzDcuNsemwfCYbRfiTPPZTLsIAi6hNvYdp4xMbQ7KcfjRxnbV9CPqfcw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aOKvTM2qqodYj2tOJW8tHBiGNCyiTdkuyTx/k+XtuMwkKTHozpsmbPE8x109sc/Bb1S49LFh2/rsvy3MVMDz1nqKWvqjsijhe1rw9GTTbkObz4ZxRTnL3VLMImZiHCIWsb8DwsvVuoPXGPcyZQTjlLzxOyAL2aSmLHZf7jK+zg+d+WaX/3K/pxq7JlQlHnE8s21iGT8/vYz5LdMZLFe0cBfLlc6mBx8/scUTCRCTN25RJcR4mgqN7t7/VQr+M0GlTEkylugW9LgXeaPg8haVnAD7qaYBQ0FN+ifFWIZ8V20+pHSaLIEE1s522Bk5Sc49WKAsQ+wH7laOFVjejsA7YQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "Stabellini, Stefano" <stefano.stabellini@xxxxxxx>, "boris.ostrovsky@xxxxxxxxxx" <boris.ostrovsky@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Rangasamy, Devaraj" <Devaraj.Rangasamy@xxxxxxx>, "Pandeshwara krishna, Mythri" <Mythri.Pandeshwarakrishna@xxxxxxx>, "SK, SivaSangeetha (Siva Sangeetha)" <SivaSangeetha.SK@xxxxxxx>, "Thomas, Rijo-john" <Rijo-john.Thomas@xxxxxxx>, "jgross@xxxxxxxx" <jgross@xxxxxxxx>
  • Delivery-date: Tue, 13 Sep 2022 06:08:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_actionid: 994af694-58a0-4771-a281-be81576649a9
  • Msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_contentbits: 0
  • Msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_enabled: true
  • Msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_method: Standard
  • Msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_name: General
  • Msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_setdate: 2022-09-13T05:35:20Z
  • Msip_label_4342314e-0df4-4b58-84bf-38bed6170a0f_siteid: 3dd8961f-e488-4e60-8e11-a82d994e183d
  • Msip_labels: MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Enabled=true; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SetDate=2022-09-13T05:35:20Z; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Method=Standard; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_Name=General; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_SiteId=3dd8961f-e488-4e60-8e11-a82d994e183d; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ActionId=ac6f7c04-2fd4-4892-9f5a-0d147769eed1; MSIP_Label_4342314e-0df4-4b58-84bf-38bed6170a0f_ContentBits=1
  • Thread-index: AQHYw/FtbHk6dXjix0qU8E4gYrQhY63WppaAgADmKYCAAIgNAIAEgvEAgABFGKA=
  • Thread-topic: Linux pin_user_pages_fast fails on Xen

[AMD Official Use Only - General]

Hi Stefano,

https://elixir.bootlin.com/linux/v5.16/source/mm/gup.c#L975 is the -EFAULT 
returning for our current use case.

access_ok is fine.

Regards,
Jeshwanth

-----Original Message-----
From: Stefano Stabellini <stefano.stabellini@xxxxxxx> 
Sent: Tuesday, September 13, 2022 6:56 AM
To: NK, JESHWANTHKUMAR (JESHWANTH KUMAR) <JESHWANTHKUMAR.NK@xxxxxxx>
Cc: Stabellini, Stefano <stefano.stabellini@xxxxxxx>; 
boris.ostrovsky@xxxxxxxxxx; xen-devel@xxxxxxxxxxxxxxxxxxxx; NK, JESHWANTHKUMAR 
(JESHWANTH KUMAR) <JESHWANTHKUMAR.NK@xxxxxxx>; Rangasamy, Devaraj 
<Devaraj.Rangasamy@xxxxxxx>; Pandeshwara krishna, Mythri 
<Mythri.Pandeshwarakrishna@xxxxxxx>; SK, SivaSangeetha (Siva Sangeetha) 
<SivaSangeetha.SK@xxxxxxx>; Thomas, Rijo-john <Rijo-john.Thomas@xxxxxxx>; 
jgross@xxxxxxxx
Subject: Re: Linux pin_user_pages_fast fails on Xen

On Sat, 10 Sep 2022, Juergen Gross wrote:
> On 09.09.22 22:25, Stefano Stabellini wrote:
> > On Fri, 9 Sep 2022, Juergen Gross wrote:
> > > On 09.09.22 04:11, Stefano Stabellini wrote:
> > > > Adding more people in CC
> > > > 
> > > > On Thu, 8 Sep 2022, Stefano Stabellini wrote:
> > > > > Hi Juergen,
> > > > > 
> > > > > A colleague is seeing a failure on x86 in Linux Dom0. The 
> > > > > failure is pin_user_pages_fast with addresses that correspond 
> > > > > to foreign memory
> > > > > pages:
> > > > > 
> > > > > - QEMU maps a domU address using dma_memory_map 
> > > > > (xen_map_cache)
> > > > > - QEMU calls an IOCTL to the TEE subsystem with the Virtual Address
> > > > >     returned by dma_memory_map
> > > > > - Linux tee_shm_register->pin_user_pages_fast Returns -14 - 
> > > > > drivers/tee/tee_shm.c
> > > > > 
> > > > > Once upon a time it used to be the case that 
> > > > > get_user_pages_fast would fail on Xen because we didn't have a 
> > > > > struct page corresponding to foreign memory mappings. But that hasn't 
> > > > > been the case for years now.
> > > > > 
> > > > > Any other ideas why it would fail?
> > > 
> > > I think we can expect that access_ok() isn't failing.
> > > 
> > > I assume the mapping was done allowing writes (sorry for paranoia mode)?
> >   I was told it was verified: QEMU could read and write to the VA 
> > returned by dma_memory_map. From /proc/<qemu-pid>/maps, the VA 
> > assigned after the mapping is pointing to /dev/xen/privcmd.
> > 
> > 
> > > Other than that I'm not having enough memory management skills. It 
> > > might be related to mmap()-ed foreign pages having _PAGE_SPECIAL 
> > > set, though.
> > 
> > Do we still set PAGE_SPECIAL for foreign mapped pages? It looks like 
> > it is not there anymore? If PAGE_SPECIAL is not there, then they 
> > really should look like regular pages?
> 
> See the call of pte_mkspecial() in remap_area_pfn_pte_fn() (mmu_pv.c).

The kernel version is 5.16 and the return code is -EFAULT. Is it the following 
-EFAULT the one that triggers?

mm/gup.c:internal_get_user_pages_fast:

        if (unlikely(!access_ok((void __user *)start, len)))
                return -EFAULT;



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.