[PATCH V9 10/10] iommu/vt-d: Report PASID format as domain attribute

2020-01-28 Thread Jacob Pan
Report the domain attribute of PASID table format. As multiple formats of PASID table entry are supported, it is important for the guest to know which format to use in virtual IOMMU. The result will be used for binding device with guest PASID. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan

[PATCH V9 02/10] iommu/uapi: Define a mask for bind data

2020-01-28 Thread Jacob Pan
Memory type related guest PASID bind data can be grouped together for one simple check. Link: https://lore.kernel.org/linux-iommu/20200109095123.17ed5e6b@jacob-builder/ Signed-off-by: Jacob Pan --- include/uapi/linux/iommu.h | 5 - 1 file changed, 4 insertions(+), 1 deletion(-) diff --git

[PATCH 2/3] iommu/uapi: Use unified UAPI version

2020-01-28 Thread Jacob Pan
Reuse UAPI version for each UAPI data structure. This is to avoid supporting multiple version combinations, simplify support model as we bump up the versions. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 3 ++- drivers/iommu/intel-svm.c | 2 +-

[PATCH V9 03/10] iommu/vt-d: Add nested translation helper function

2020-01-28 Thread Jacob Pan
Nested translation mode is supported in VT-d 3.0 Spec.CH 3.8. With PASID granular translation type set to 0x11b, translation result from the first level(FL) also subject to a second level(SL) page table translation. This mode is used for SVA virtualization, where FL performs guest virtual to guest

[PATCH V9 09/10] iommu/vt-d: Add custom allocator for IOASID

2020-01-28 Thread Jacob Pan
When VT-d driver runs in the guest, PASID allocation must be performed via virtual command interface. This patch registers a custom IOASID allocator which takes precedence over the default XArray based allocator. The resulting IOASID allocation will always come from the host. This ensures that

[PATCH V9 05/10] iommu/vt-d: Support flushing more translation cache types

2020-01-28 Thread Jacob Pan
When Shared Virtual Memory is exposed to a guest via vIOMMU, scalable IOTLB invalidation may be passed down from outside IOMMU subsystems. This patch adds invalidation functions that can be used for additional translation cache types. Signed-off-by: Jacob Pan --- drivers/iommu/dmar.c|

[PATCH V9 06/10] iommu/vt-d: Add svm/sva invalidate function

2020-01-28 Thread Jacob Pan
When Shared Virtual Address (SVA) is enabled for a guest OS via vIOMMU, we need to provide invalidation support at IOMMU API and driver level. This patch adds Intel VT-d specific function to implement iommu passdown invalidate API for shared virtual address. The use case is for supporting caching

[PATCH V9 01/10] iommu/vt-d: Move domain helper to header

2020-01-28 Thread Jacob Pan
Move domain helper to header to be used by SVA code. Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- drivers/iommu/intel-iommu.c | 6 -- include/linux/intel-iommu.h | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel-iommu.c

[PATCH 3/3] iommu/uapi: Add helper function for size lookup

2020-01-28 Thread Jacob Pan
IOMMU UAPI can be extended in the future by adding new fields at the end of each user data structure. Since we use a unified UAPI version for compatibility checking, a lookup function is needed to find the correct user data size to copy from user. This patch adds a helper function based on a 2D

[PATCH V9 04/10] iommu/vt-d: Add bind guest PASID support

2020-01-28 Thread Jacob Pan
When supporting guest SVA with emulated IOMMU, the guest PASID table is shadowed in VMM. Updates to guest vIOMMU PASID table will result in PASID cache flush which will be passed down to the host as bind guest PASID calls. For the SL page tables, it will be harvested from device's default domain

[PATCH V9 00/10] Nested Shared Virtual Address (SVA) VT-d support

2020-01-28 Thread Jacob Pan
Shared virtual address (SVA), a.k.a, Shared virtual memory (SVM) on Intel platforms allow address space sharing between device DMA and applications. SVA can reduce programming complexity and enhance security. This series is intended to enable SVA virtualization, i.e. enable use of SVA within a

[PATCH 0/3] IOMMU user API enhancement

2020-01-28 Thread Jacob Pan
IOMMU user API header was introduced to support nested DMA translation and related fault handling. The current UAPI data structures consist of three areas that cover the interactions between host kernel and guest: - fault handling - cache invalidation - bind guest page tables, i.e. guest PASID

[PATCH 1/3] iommu/uapi: Define uapi version and capabilities

2020-01-28 Thread Jacob Pan
Define a unified UAPI version to be used for compatibility checks between user and kernel. Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- include/uapi/linux/iommu.h | 48 ++ 1 file changed, 48 insertions(+) diff --git

[PATCH V9 08/10] iommu/vt-d: Enlightened PASID allocation

2020-01-28 Thread Jacob Pan
From: Lu Baolu Enabling IOMMU in a guest requires communication with the host driver for certain aspects. Use of PASID ID to enable Shared Virtual Addressing (SVA) requires managing PASID's in the host. VT-d 3.0 spec provides a Virtual Command Register (VCMD) to facilitate this. Writes to this

[PATCH V9 07/10] iommu/vt-d: Cache virtual command capability register

2020-01-28 Thread Jacob Pan
Virtual command registers are used in the guest only, to prevent vmexit cost, we cache the capability and store it during initialization. Signed-off-by: Jacob Pan --- drivers/iommu/dmar.c| 1 + include/linux/intel-iommu.h | 5 + 2 files changed, 6 insertions(+) diff --git

[RFC PATCH v1] iommu/arm-smmu: Allow domains to choose a context bank

2020-01-28 Thread Jordan Crouse
Domains which are being set up for split pagetables usually want to be on a specific context bank for hardware reasons. Force the context bank for domains with the split-pagetable quirk to context bank 0. If context bank 0 is taken, move that context bank to another unused bank and rewrite the

[PATCH v1 4/6] drm/msm: Add support to create target specific address spaces

2020-01-28 Thread Jordan Crouse
Add support to create a GPU target specific address space for a context. For those targets that support per-instance pagetables they will return a new address space set up for the instance if possible otherwise just use the global device pagetable. Signed-off-by: Jordan Crouse ---

[PATCH v1 1/6] iommu: Add DOMAIN_ATTR_PTBASE

2020-01-28 Thread Jordan Crouse
Add an attribute to return the base address of the pagetable. This is used by auxiliary domains from arm-smmu to return the address of the pagetable to the domain so that it can set the appropriate pagetable through it's own means. Signed-off-by: Jordan Crouse --- include/linux/iommu.h | 2 ++

[PATCH v1 5/6] drm/msm/gpu: Add ttbr0 to the memptrs

2020-01-28 Thread Jordan Crouse
Targets that support per-instance pagetable switching will have to keep track of which pagetable belongs to each instance to be able to recover for preemption. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + 1 file changed, 1 insertion(+) diff --git

[PATCH v1 6/6] drm/msm/a6xx: Support per-instance pagetables

2020-01-28 Thread Jordan Crouse
Add support for per-instance pagetables for a6xx targets. Add support to handle split pagetables and create a new instance if the needed IOMMU support exists and insert the necessary PM4 commands to trigger a pagetable switch at the beginning of a user command. Signed-off-by: Jordan Crouse ---

[PATCH v1 2/6] arm/smmu: Add auxiliary domain support for arm-smmuv2

2020-01-28 Thread Jordan Crouse
Support auxiliary domains for arm-smmu-v2 to initialize and support multiple pagetables for a single SMMU context bank. Since the smmu-v2 hardware doesn't have any built in support for switching the pagetable base it is left as an exercise to the caller to actually use the pagetable. Aux domains

[PATCH v1 0/6] iommu/arm-smmu: Auxiliary domain and per instance pagetables

2020-01-28 Thread Jordan Crouse
Some clients have a requirement to sandbox memory mappings for security and advanced features like SVM. This series adds support to enable per-instance pagetables as auxiliary domains in the arm-smmu driver and adds per-instance support for the Adreno GPU. This patchset builds on the split

[PATCH v5 4/5] drm/msm: Refactor address space initialization

2020-01-28 Thread Jordan Crouse
Refactor how address space initialization works. Instead of having the address space function create the MMU object (and thus require separate but equal functions for gpummu and iommu) use a single function and pass the MMU struct in. Make the generic code cleaner by using target specific

[PATCH v5 3/5] drm/msm: Attach the IOMMU device during initialization

2020-01-28 Thread Jordan Crouse
Everywhere an IOMMU object is created by msm_gpu_create_address_space the IOMMU device is attached immediately after. Instead of carrying around the infrastructure to do the attach from the device specific code do it directly in the msm_iommu_init() function. This gets it out of the way for more

[PATCH v5 0/5] iommu/arm-smmu: Split pagetable support for arm-smmu-v2

2020-01-28 Thread Jordan Crouse
This is another iteration for the split pagetable support based on the suggestions from Robin and Will [1]. Background: In order to support per-context pagetables the GPU needs to enable split tables so that we can store global buffers in the TTBR1 space leaving the GPU free to program the TTBR0

[PATCH v5 1/5] iommu: Add DOMAIN_ATTR_SPLIT_TABLES

2020-01-28 Thread Jordan Crouse
Add a new attribute to enable and query the state of split pagetables for the domain. Acked-by: Will Deacon Signed-off-by: Jordan Crouse --- include/linux/iommu.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index d1b5f4d..b14398b 100644