Re: [RFC PATCH 29/30] vfio: Add support for Shared Virtual Memory

2017-04-26 Thread Tomasz Nowicki
Hi Jean, On 27.02.2017 20:54, Jean-Philippe Brucker wrote: Add two new ioctl for VFIO devices. VFIO_DEVICE_BIND_TASK creates a bond between a device and a process address space, identified by a device-specific ID named PASID. This allows the device to target DMA transactions at the process

Re: [RFC PATCH 30/30] vfio: Allow to bind foreign task

2017-04-26 Thread Tomasz Nowicki
On 27.02.2017 20:54, Jean-Philippe Brucker wrote: Let the process that owns the device create an address space bond on behalf of another process. We add a pid argument to the BIND_TASK ioctl, allowing the caller to bind a foreign task. The expected program flow in this case is: * Process A

Re: [PATCH v2] iommu/arm-smmu: Return IOVA in iova_to_phys when SMMU is bypassed

2017-04-26 Thread Sunil Kovvuri
On Tue, Apr 25, 2017 at 3:27 PM, wrote: > From: Sunil Goutham > > For software initiated address translation, when domain type is > IOMMU_DOMAIN_IDENTITY i.e SMMU is bypassed, mimic HW behavior > i.e return the same IOVA as translated address. > >

Re: [PATCH v2] iommu/arm-smmu: Return IOVA in iova_to_phys when SMMU is bypassed

2017-04-26 Thread Will Deacon
Hi Sunil, On Tue, Apr 25, 2017 at 03:27:52PM +0530, sunil.kovv...@gmail.com wrote: > From: Sunil Goutham > > For software initiated address translation, when domain type is > IOMMU_DOMAIN_IDENTITY i.e SMMU is bypassed, mimic HW behavior > i.e return the same IOVA as

Re: [PATCH] iommu/arm-smmu-v3: Increase SMMU CMD queue poll timeout

2017-04-26 Thread Will Deacon
On Wed, Apr 26, 2017 at 02:50:04PM +0530, Sunil Kovvuri wrote: > On Mon, Apr 24, 2017 at 10:35 PM, Will Deacon wrote: > > On Mon, Apr 24, 2017 at 10:26:53PM +0530, Sunil Kovvuri wrote: > >> On Mon, Apr 24, 2017 at 9:38 PM, Will Deacon wrote: > >> > On

Re: [RFC PATCH 30/30] vfio: Allow to bind foreign task

2017-04-26 Thread Jean-Philippe Brucker
Hi Tomasz, Thanks for looking at this. On 26/04/17 08:25, Tomasz Nowicki wrote: > On 27.02.2017 20:54, Jean-Philippe Brucker wrote: >> Let the process that owns the device create an address space bond on >> behalf of another process. We add a pid argument to the BIND_TASK ioctl, >> allowing the

Re: [RFC PATCH 29/30] vfio: Add support for Shared Virtual Memory

2017-04-26 Thread Jean-Philippe Brucker
On 26/04/17 07:53, Tomasz Nowicki wrote: >> +mutex_lock(>tasks_lock); >> +list_for_each_entry(vfio_task, >tasks, list) { >> +if (vfio_task->pasid != svm.pasid) >> +continue; >> + >> +ret = iommu_unbind_task(device->dev, svm.pasid, flags); >>

[RFC PATCH 07/20] VFIO: check notifier flag in region_del()

2017-04-26 Thread Liu, Yi L
This patch adds flag check when unregistering MAP/UNMAP notifier in region_del. MAP/UNMAP notifier would be unregistered when iommu memory region is deleted. This is to avoid unregistering other notifiers. Peter Xu's intel_iommu enhancement series has introduced dynamic switch of IOMMU region. If

[RFC PATCH 02/20] intel_iommu: exposed extended-context mode to guest

2017-04-26 Thread Liu, Yi L
VT-d implementations reporting PASID or PRS fields as "Set", must also report ecap.ECS as "Set". Extended-Context is required for SVM. When ECS is reported, intel iommu driver would initiate extended root entry and extended context entry, and also PASID table if there is any SVM capable device.

[RFC PATCH 16/20] VFIO: Add notifier for propagating IOMMU TLB invalidate

2017-04-26 Thread Liu, Yi L
This patch adds the following items: * add new notifier flag IOMMU_NOTIFIER_IOMMU_TLB_INV = 0x8 * add new IOCTL cmd VFIO_IOMMU_TLB_INVALIDATE attached on container->fd * add vfio_iommu_tlb_invalidate_notify() to propagate IOMMU TLB invalidate to host This new notifier is originated from the

[RFC PATCH 09/20] Memory: introduce iommu_ops->record_device

2017-04-26 Thread Liu, Yi L
With vIOMMU exposed to guest, vIOMMU emulator needs to do translation between host and guest. e.g. a device-selective TLB flush, vIOMMU emulator needs to replace guest SID with host SID so that to limit the invalidation. This patch introduces a new callback iommu_ops->record_device() to notify

[RFC PATCH 11/20] intel_iommu: provide iommu_ops->record_device

2017-04-26 Thread Liu, Yi L
This patch provides iommu_ops->record_device implementation for intel_iommu. It records the host sid in the IntelIOMMUNotifierNode for further virtualization usage. e.g. guest sid -> host sid translation during propagating 1st level cache invalidation from guest to host. Signed-off-by: Liu, Yi L

Re: [PATCH v2] iommu/arm-smmu: Return IOVA in iova_to_phys when SMMU is bypassed

2017-04-26 Thread Will Deacon
On Wed, Apr 26, 2017 at 04:13:29PM +0530, Sunil Kovvuri wrote: > On Wed, Apr 26, 2017 at 3:31 PM, Will Deacon wrote: > > Hi Sunil, > > > > On Tue, Apr 25, 2017 at 03:27:52PM +0530, sunil.kovv...@gmail.com wrote: > >> From: Sunil Goutham > >> > >> For

[RFC PATCH 05/20] VFIO: add new IOCTL for svm bind tasks

2017-04-26 Thread Liu, Yi L
Add a new IOCTL cmd VFIO_IOMMU_SVM_BIND_TASK attached on container->fd. On VT-d, this IOCTL cmd would be used to link the guest PASID page table to host. While for other vendors, it may also be used to support other kind of SVM bind request. Previously, there is a discussion on it with ARM

[RFC PATCH 13/20] IOMMU: add pasid_table_info for guest pasid table

2017-04-26 Thread Liu, Yi L
This patch adds iommu.h to define some generic definition for IOMMU. Here defines "struct pasid_table_info" for guest pasid table bind. Signed-off-by: Liu, Yi L --- linux-headers/linux/iommu.h | 30 ++ 1 file changed, 30 insertions(+)

[RFC PATCH 8/8] VFIO: do IOMMU TLB invalidation from guest

2017-04-26 Thread Liu, Yi L
From: "Liu, Yi L" This patch adds support for VFIO_IOMMU_TLB_INVALIDATE cmd in vfio_iommu_type1. For SVM virtualization on VT-d, for VFIO_IOMMU_TLB_INVALIDATE, it calls iommu_ops->do_invalidate() to submit the guest iommu cache invalidation to pIOMMU. Signed-off-by:

[RFC PATCH 7/8] VFIO: Add new IOCTL for IOMMU TLB invalidate propagation

2017-04-26 Thread Liu, Yi L
From: "Liu, Yi L" This patch adds VFIO_IOMMU_TLB_INVALIDATE to propagate IOMMU TLB invalidate request from guest to host. In the case of SVM virtualization on VT-d, host IOMMU driver has no knowledge of caching structure updates unless the guest invalidation activities

[RFC PATCH 18/20] intel_iommu: propagate Extended-IOTLB invalidate to host

2017-04-26 Thread Liu, Yi L
The invalidation of Extended-IOTLB invalidates first-level and nested mappings from the IOTLB and the paging-structure-caches. For SVM virtualization, iommu tlb invalidate notifier is added. The reason is as below: * On VT-d, MAP/UNMAP notifier would be used to shadow the changes of the guest

[RFC PATCH 20/20] intel_iommu: propagate Ext-Device-TLB invalidate to host

2017-04-26 Thread Liu, Yi L
For Extended-Device-TLB invalidation, intel_iommu emulator needs to check all the assigned device and find the affected device. Replace the guest SID with the host SID in the invalidate descriptor and pass the request to host. Host may just submit the request to corresponding invalidation queue

[RFC PATCH 01/20] intel_iommu: add "ecs" option

2017-04-26 Thread Liu, Yi L
Report ecap.ECS=1 to guest by "-deivce intel-iommu, ecs=on" in QEMU Cmd Signed-off-by: Liu, Yi L --- hw/i386/intel_iommu.c | 5 + hw/i386/intel_iommu_internal.h | 1 + include/hw/i386/intel_iommu.h | 1 + 3 files changed, 7 insertions(+) diff --git

[RFC PATCH 03/20] intel_iommu: add "svm" option

2017-04-26 Thread Liu, Yi L
Expose "Shared Virtual Memory" to guest by using "svm" option. Also use "svm" to expose SVM related capabilities to guest. e.g. "-device intel-iommu, svm=on" Signed-off-by: Liu, Yi L --- hw/i386/intel_iommu.c | 10 ++ hw/i386/intel_iommu_internal.h |

[RFC PATCH 0/8] Shared Virtual Memory virtualization for VT-d

2017-04-26 Thread Liu, Yi L
Hi, This patchset introduces SVM virtualization for intel_iommu in IOMMU/VFIO. The total SVM virtualization for intel_iommu touched Qemu/IOMMU/VFIO. Another patchset would change the Qemu. It is "[RFC PATCH 0/20] Qemu: Extend intel_iommu emulator to support Shared Virtual Memory" In this

[RFC PATCH 3/8] iommu: Introduce iommu do invalidate API function

2017-04-26 Thread Liu, Yi L
From: "Liu, Yi L" When a SVM capable device is assigned to a guest, the first level page tables are owned by the guest and the guest PASID table pointer is linked to the device context entry of the physical IOMMU. Host IOMMU driver has no knowledge of caching structure

[RFC PATCH 5/8] VFIO: Add new IOTCL for PASID Table bind propagation

2017-04-26 Thread Liu, Yi L
From: "Liu, Yi L" This patch adds VFIO_IOMMU_SVM_BIND_TASK for potential PASID table binding requests. On VT-d, this IOCTL cmd would be used to link the guest PASID page table to host. While for other vendors, it may also be used to support other kind of SVM bind

[RFC PATCH 2/8] iommu/vt-d: add bind_pasid_table function

2017-04-26 Thread Liu, Yi L
From: Jacob Pan Add Intel VT-d ops to the generic iommu_bind_pasid_table API functions. The primary use case is for direct assignment of SVM capable device. Originated from emulated IOMMU in the guest, the request goes through many layers (e.g. VFIO). Upon calling

[RFC PATCH 4/8] iommu/vt-d: Add iommu do invalidate function

2017-04-26 Thread Liu, Yi L
From: Jacob Pan This patch adds Intel VT-d specific function to implement iommu_do_invalidate API. The use case is for supporting caching structure invalidation of assigned SVM capable devices. Emulated IOMMU exposes queue invalidation capability and passes down

[RFC PATCH 19/20] intel_iommu: propagate PASID-Cache invalidate to host

2017-04-26 Thread Liu, Yi L
This patch adds support for propagating PASID-Cache invalidation to host. Similar with Extended-IOTLB invalidation, intel_iommu emulator would also check all the assigned devices and do sanity check, then pass it to host. Host pIOMMU driver would replace some fields in the raw data before

[RFC PATCH 1/8] iommu: Introduce bind_pasid_table API function

2017-04-26 Thread Liu, Yi L
From: Jacob Pan Virtual IOMMU was proposed to support Shared Virtual Memory (SVM) use case in the guest: https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg05311.html As part of the proposed architecture, when a SVM capable PCI device is assigned to a guest,

Re: [PATCH v2] iommu/arm-smmu: Return IOVA in iova_to_phys when SMMU is bypassed

2017-04-26 Thread Sunil Kovvuri
On Wed, Apr 26, 2017 at 3:31 PM, Will Deacon wrote: > Hi Sunil, > > On Tue, Apr 25, 2017 at 03:27:52PM +0530, sunil.kovv...@gmail.com wrote: >> From: Sunil Goutham >> >> For software initiated address translation, when domain type is >>

Re: [RFC PATCH 29/30] vfio: Add support for Shared Virtual Memory

2017-04-26 Thread Tomasz Nowicki
On 26.04.2017 12:08, Jean-Philippe Brucker wrote: On 26/04/17 07:53, Tomasz Nowicki wrote: +mutex_lock(>tasks_lock); +list_for_each_entry(vfio_task, >tasks, list) { +if (vfio_task->pasid != svm.pasid) +continue; + +ret =

[RFC PATCH 00/20] Qemu: Extend intel_iommu emulator to support Shared Virtual Memory

2017-04-26 Thread Liu, Yi L
Hi, This patchset is proposing a solution to extend the current Intel IOMMU emulator in QEMU to support Shared Virtual Memory usage in guest. The whole SVM virtualization for intel_iommu has two series which introduces changes in Qemu and VFIO/IOMMU. This patchset mainly changes Qemu. For

Re: [PATCH v2] iommu/arm-smmu: Return IOVA in iova_to_phys when SMMU is bypassed

2017-04-26 Thread Joerg Roedel
On Wed, Apr 26, 2017 at 11:01:50AM +0100, Will Deacon wrote: > Joerg: sorry, this is another one for you to pick up if possible. Applied. ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v2] iommu/arm-smmu: Return IOVA in iova_to_phys when SMMU is bypassed

2017-04-26 Thread Sunil Kovvuri
On Wed, Apr 26, 2017 at 5:06 PM, Will Deacon wrote: > On Wed, Apr 26, 2017 at 04:13:29PM +0530, Sunil Kovvuri wrote: >> On Wed, Apr 26, 2017 at 3:31 PM, Will Deacon wrote: >> > Hi Sunil, >> > >> > On Tue, Apr 25, 2017 at 03:27:52PM +0530,

[RFC PATCH 04/20] Memory: modify parameter in IOMMUNotifier func

2017-04-26 Thread Liu, Yi L
This patch modifies parameter of IOMMUNotifier, use "void *data" instead of "IOMMUTLBEntry*". This is to extend it to support notifiers other than MAP/UNMAP. Signed-off-by: Liu, Yi L --- hw/vfio/common.c | 3 ++- hw/virtio/vhost.c | 3 ++-

[RFC PATCH 12/20] Memory: Add func to fire pasidt_bind notifier

2017-04-26 Thread Liu, Yi L
Add a separate function to fire pasid table bind notifier. In future there may be more pasid bind type with different granularity. e.g. binding pasid entry instead of binding pasid table. It can be supported by adding bind_type, check bind_type in fire func and trigger correct notifier.

[RFC PATCH 10/20] VFIO: notify vIOMMU emulator when device is assigned

2017-04-26 Thread Liu, Yi L
With vIOMMU exposed to guest, notify vIOMMU emulator to record information of this assigned device. This patch adds iommu_ops->record_device to record the host bus/slot/function for this device. In future, it can be extended to other info which is needed. Signed-off-by: Liu, Yi L

[RFC PATCH 15/20] intel_iommu: link whole guest pasid table to host

2017-04-26 Thread Liu, Yi L
VT-d has a nested mode which allows SVM virtualization. Link the whole guest PASID table to host context entry and enable nested mode, pIOMMU would do nested translation for DMA request. Thus achieve GVA->HPA translation. When extended-context-entry is modified in guest, intel_iommu emulator

[RFC PATCH 08/20] Memory: add notifier flag check in memory_replay()

2017-04-26 Thread Liu, Yi L
memory_region_iommu_replay is used to do replay with MAP/UNMAP notifier. However, other notifiers may be passed in, so add a check against notifier flag to avoid potential error. e.g. memory_region_iommu_replay_all loops all registered notifiers, may just pass in wrong notifier. Signed-off-by:

[RFC PATCH 17/20] Memory: Add func to fire TLB invalidate notifier

2017-04-26 Thread Liu, Yi L
This patch adds a separate function to fire IOMMU TLB invalidate notifier. Signed-off-by: Liu, Yi L --- include/exec/memory.h | 9 + memory.c | 18 ++ 2 files changed, 27 insertions(+) diff --git a/include/exec/memory.h

[RFC PATCH 06/20] VFIO: add new notifier for binding PASID table

2017-04-26 Thread Liu, Yi L
This patch includes the following items: * add vfio_register_notifier() for vfio notifier initialization * add new notifier flag IOMMU_NOTIFIER_SVM_PASIDT_BIND = 0x4 * add vfio_iommu_bind_pasid_tbl_notify() to link guest pasid table to host This patch doesn't register new notifier in vfio

Re: [RFC PATCH 12/20] Memory: Add func to fire pasidt_bind notifier

2017-04-26 Thread Paolo Bonzini
On 26/04/2017 12:06, Liu, Yi L wrote: > +void memory_region_notify_iommu_svm_bind(MemoryRegion *mr, > + void *data) > +{ > +IOMMUNotifier *iommu_notifier; > +IOMMUNotifierFlag request_flags; > + > +assert(memory_region_is_iommu(mr)); > + > +

[PATCH 4/4] iommu: Remove trace-events include from iommu.h

2017-04-26 Thread Joerg Roedel
From: Joerg Roedel It is not needed there anymore. All places needing it are fixed. Signed-off-by: Joerg Roedel --- drivers/media/platform/mtk-vpu/mtk_vpu.c | 1 + include/linux/iommu.h| 2 -- 2 files changed, 1 insertion(+), 2

[PATCH 3/4] iommu: Remove pci.h include from trace/events/iommu.h

2017-04-26 Thread Joerg Roedel
From: Joerg Roedel The include file does not need any PCI specifics, so remove that include. Also fix the places that relied on it. Signed-off-by: Joerg Roedel --- arch/arm64/mm/dma-mapping.c| 1 + drivers/iommu/fsl_pamu.h | 1 +

[PATCH 0/4] iommu: Header file cleanups

2017-04-26 Thread Joerg Roedel
Hi, here is a small patch-set to remove some header dependencies from the IOMMU header files. The linux/iommu.h file does not include linux/pci.h and the iommu trace-event headers anymore. For this the report_iommu_fault function was moved to iommu.c and the place relying on above includes were

[PATCH] iommu: Print a message with the default domain type created

2017-04-26 Thread Robert Richter
There are several ways the bypass mode can be enabled. With commit fccb4e3b8ab0 iommu: Allow default domain type to be set on the kernel command line there is the option to switch into bypass mode. And, depending on devicetree options, bypass mode can be also enabled. This makes it hard to

Re: [RFC PATCH 1/8] iommu: Introduce bind_pasid_table API function

2017-04-26 Thread jacob pan
On Wed, 26 Apr 2017 17:56:45 +0100 Jean-Philippe Brucker wrote: > Hi Yi, Jacob, > > On 26/04/17 11:11, Liu, Yi L wrote: > > From: Jacob Pan > > > > Virtual IOMMU was proposed to support Shared Virtual Memory (SVM) > > use case in

Re: [PATCH] iommu: Print a message with the default domain type created

2017-04-26 Thread Joerg Roedel
Hi Robert, On Wed, Apr 26, 2017 at 04:38:13PM +0200, Robert Richter wrote: > - pr_info("Adding device %s to group %d\n", dev_name(dev), group->id); > + pr_info("Adding device %s to group %d, default domain type %d\n", > + dev_name(dev), group->id, > +

Re: [RFC 3/3] virtio-iommu: future work

2017-04-26 Thread Michael S. Tsirkin
On Fri, Apr 07, 2017 at 08:17:47PM +0100, Jean-Philippe Brucker wrote: > Here I propose a few ideas for extensions and optimizations. This is all > very exploratory, feel free to correct mistakes and suggest more things. > > I. Linux host >1. vhost-iommu A qemu based

Re: [RFC PATCH 5/8] VFIO: Add new IOTCL for PASID Table bind propagation

2017-04-26 Thread Jean-Philippe Brucker
On 26/04/17 11:12, Liu, Yi L wrote: > From: "Liu, Yi L" > > This patch adds VFIO_IOMMU_SVM_BIND_TASK for potential PASID table > binding requests. > > On VT-d, this IOCTL cmd would be used to link the guest PASID page table > to host. While for other vendors, it may

Re: [RFC PATCH 1/8] iommu: Introduce bind_pasid_table API function

2017-04-26 Thread Jean-Philippe Brucker
Hi Yi, Jacob, On 26/04/17 11:11, Liu, Yi L wrote: > From: Jacob Pan > > Virtual IOMMU was proposed to support Shared Virtual Memory (SVM) use > case in the guest: > https://lists.gnu.org/archive/html/qemu-devel/2016-11/msg05311.html > > As part of the proposed

Re: [PATCH] iommu/arm-smmu-v3: Increase SMMU CMD queue poll timeout

2017-04-26 Thread Sunil Kovvuri
On Mon, Apr 24, 2017 at 10:35 PM, Will Deacon wrote: > On Mon, Apr 24, 2017 at 10:26:53PM +0530, Sunil Kovvuri wrote: >> On Mon, Apr 24, 2017 at 9:38 PM, Will Deacon wrote: >> > On Mon, Apr 24, 2017 at 05:29:36PM +0530, Geetha sowjanya wrote: >> >> From:

Re: [RFC PATCH 1/8] iommu: Introduce bind_pasid_table API function

2017-04-26 Thread Jean-Philippe Brucker
On 26/04/17 19:29, jacob pan wrote: > On Wed, 26 Apr 2017 17:56:45 +0100 > Jean-Philippe Brucker wrote: > >> Hi Yi, Jacob, >> >> On 26/04/17 11:11, Liu, Yi L wrote: >>> From: Jacob Pan >>> >>> Virtual IOMMU was proposed to support

Re: [Qemu-devel] [RFC PATCH 12/20] Memory: Add func to fire pasidt_bind notifier

2017-04-26 Thread Liu, Yi L
On Wed, Apr 26, 2017 at 03:50:16PM +0200, Paolo Bonzini wrote: > > > On 26/04/2017 12:06, Liu, Yi L wrote: > > +void memory_region_notify_iommu_svm_bind(MemoryRegion *mr, > > + void *data) > > +{ > > +IOMMUNotifier *iommu_notifier; > > +

Re: [Qemu-devel] [RFC PATCH 5/8] VFIO: Add new IOTCL for PASID Table bind propagation

2017-04-26 Thread Liu, Yi L
On Wed, Apr 26, 2017 at 05:56:50PM +0100, Jean-Philippe Brucker wrote: > On 26/04/17 11:12, Liu, Yi L wrote: > > From: "Liu, Yi L" > > > > This patch adds VFIO_IOMMU_SVM_BIND_TASK for potential PASID table > > binding requests. > > > > On VT-d, this IOCTL cmd would be