From: valmiki <valmikibow@gmail.com>
To: Jean-Philippe Brucker <jean-philippe.brucker@arm.com>,
Alex Williamson <alex.williamson@redhat.com>
Cc: iommu@lists.linux-foundation.org, kvm@vger.kernel.org,
linux-pci@vger.kernel.org, tianyu.lan@intel.com,
kevin.tian@intel.com, jacob.jun.pan@intel.com
Subject: Re: Support SVM without PASID
Date: Sat, 5 Aug 2017 10:44:38 +0530 [thread overview]
Message-ID: <dd3a7852-cd9a-3797-9421-dff97f6d7213@gmail.com> (raw)
In-Reply-To: <c142fb8e-3618-152a-fbe3-521e6c8ff9bf@arm.com>
On 8/2/2017 12:10 AM, Jean-Philippe Brucker wrote:
> On 01/08/17 18:38, valmiki wrote:
> [...]
>>>> So i digged through your patches and i understood that using BIND ioctls
>>>> satge-1 translations are setup in SMMU for an application.
>>>> If we use VFIO_IOMMU_MAP/UNMAP_DMA ioctls they are setting up stage-2
>>>> translations in SMMU.
>>>> So without PASID support we can only work with stage-2 translations ?
>>>
>>> It depends what type you use when registering the IOMMU with
>>> VFIO_SET_IOMMU:
>>>
>>> * If the type is VFIO_TYPE1v2_IOMMU, then VFIO_IOMMU_MAP/UNMAP_DMA
>>> affects the stage-1 non-PASID context (already the case in mainline).
>>> In addition, with my patch the BIND ioctl will affect stage-1 PASID
>>> contexts, and bind process page directories to the device (host SVM).
>>>
>>> * If the type is VFIO_TYPE1_NESTING_IOMMU, then VFIO_IOMMU_MAP/UNMAP_DMA
>>> will affect stage-2 mappings (already in mainline).
>>> With my SMMU patch series, the BIND ioctl is not supported in this mode.
>>> But in the future, BIND would allow to manage stage-1 as well:
>>> - bind a process page directory (host SVM with added stage-2), or
>>> - bind a guest page directory (viommu), or
>>> - bind the full stage-1 context table (viommu).
>>
>> Hi Jean, Thanks a lot for this information.
>> I tried to understand how stage-1 translations are setup if we use
>> VFIO_TYPE1v2_IOMMU & VFIO_IOMMU_MAP/UNMAP_DMA flow, but I'm not
>> successful, I couldn't find when context descriptor details are updated
>> with stage-1 translation table details in this flow.
>> I found that in BIND flow a new context descriptor being created and
>> assigned with required translation tables.
>>
>> Can you please point to piece of code/patch series where and how context
>> descriptor is updated for struct vfio_iommu_type1_dma_map/UNMAP_DMA flow with
>> VFIO_TYPE1v2_IOMMU.
>
> What happens for SMMU is during initialization, the
> VFIO_GROUP_SET_CONTAINER ioctl calls vfio_iommu_type1_attach_group.
> This function creates a new iommu_domain, and then calls
> iommu_attach_group(domain, group), which calls arm_smmu_attach_dev(domain,
> dev) for all devices in the group.
>
> If necessary we detach the existing domain, by clearing the STE (and all
> contexts). Then, since the new domain is only partially initialized, we
> call arm_smmu_domain_finalise, which allocates the page tables, and ends
> up calling arm_smmu_domain_finalise_s1. That function prepares the
> configuration of context descriptor 0, which is used for non-PASID
> mappings. Afterwards, back in arm_smmu_attach_dev, context descriptor 0 is
> written, along with the STE, and then the domain is live.
>
> Then when userspace does VFIO_IOMMU_MAP/UNMAP_DMA, iommu_map/unmap are
> called on that domain. arm_smmu_map/unmap update the page tables attached
> to context descriptor 0 (but they don't modify the CD in any way).
>
Hi Jean, Thanks a lot, now i understood the flow. From vfio kernel
documentation we fill vaddr and iova in struct vfio_iommu_type1_dma_map
and pass them to VFIO. But if we use dynamic allocation in application
(say malloc), do we need to use dma API to get iova and then call
VFIO_IOMMU_MAP ioctl ?
If application needs multiple such dynamic allocations, then it need to
allocate large chunk and program it via VFIO_IOMMU_MAP ioctl and then
manage rest allocations requirements from this buffer ?
Regards,
valmiki
next prev parent reply other threads:[~2017-08-05 5:14 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 17:03 Support SVM without PASID valmiki
[not found] ` <a30962a6-2240-9263-96cc-10da1b179fcc-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-08 20:02 ` Alex Williamson
2017-07-09 3:15 ` valmiki
2017-07-09 9:29 ` Liu, Yi L
2017-07-10 0:14 ` Bob Liu
2017-07-10 19:31 ` Jerome Glisse
[not found] ` <20170710193141.GA3813-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-12 16:23 ` valmiki
[not found] ` <73619426-6fcc-21ce-cfd4-8c66bde63f9a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-07-11 10:56 ` Jean-Philippe Brucker
[not found] ` <eb132dfa-6708-5898-c2ce-ce7ab08809b1-5wv7dgnIgG8@public.gmane.org>
2017-07-12 16:27 ` valmiki
2017-07-12 16:48 ` Jean-Philippe Brucker
2017-07-22 2:05 ` valmiki
[not found] ` <41333a03-bf91-1152-4779-6579845609f6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-08-01 8:26 ` Jean-Philippe Brucker
[not found] ` <564ba70b-db95-7fe0-86bb-bb4eefcd87ec-5wv7dgnIgG8@public.gmane.org>
2017-08-01 17:38 ` valmiki
2017-08-01 18:40 ` Jean-Philippe Brucker
2017-08-05 5:14 ` valmiki [this message]
2017-08-07 10:31 ` Jean-Philippe Brucker
2017-08-07 12:18 ` Bob Liu
2017-08-07 12:52 ` Jean-Philippe Brucker
2017-08-08 0:51 ` Bob Liu
2017-08-09 15:01 ` Jean-Philippe Brucker
2017-08-11 6:41 ` Tian, Kevin
[not found] ` <AADFC41AFE54684AB9EE6CBC0274A5D190D6EDB7-0J0gbvR4kThpB2pF5aRoyrfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2017-08-11 9:25 ` Jean-Philippe Brucker
2017-08-11 9:36 ` Bob Liu
2017-08-12 12:10 ` valmiki
2017-08-14 7:49 ` Tian, Kevin
2017-08-28 13:10 ` Bharat Kumar Gogada
2017-08-29 1:32 ` Tian, Kevin
2017-08-04 1:49 ` Tian, Kevin
2017-08-04 9:42 ` Jean-Philippe Brucker
2017-08-11 6:29 ` Tian, Kevin
2017-08-11 16:25 ` Raj, Ashok
2017-08-14 8:00 ` Tian, Kevin
2017-08-14 9:07 ` Jean-Philippe Brucker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd3a7852-cd9a-3797-9421-dff97f6d7213@gmail.com \
--to=valmikibow@gmail.com \
--cc=alex.williamson@redhat.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jacob.jun.pan@intel.com \
--cc=jean-philippe.brucker@arm.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=tianyu.lan@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox