Re: panic in dmar_remove_one_dev_info

2019-12-16 Thread Jerry Snitselaar
On Mon Dec 16 19, Jerry Snitselaar wrote: HP is seeing a panic on gen9 dl360 and dl560 while testing these other changes we've been eorking on. I just took an initial look, but have to run to a dentist appointment so couldn't dig too deep. It looks like the device sets dev->archdata.iommu to

Re: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level

2019-12-16 Thread Lu Baolu
Hi, On 2019/12/17 10:36, Liu, Yi L wrote: From: Liu, Yi L Sent: Tuesday, December 17, 2019 10:26 AM To: Lu Baolu ; Joerg Roedel ; David Woodhouse ; Alex Williamson Subject: RE: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level From: Lu Baolu

RE: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level

2019-12-16 Thread Liu, Yi L
> From: Lu Baolu [mailto:baolu...@linux.intel.com] > Sent: Tuesday, December 17, 2019 9:39 AM > To: Liu, Yi L ; Joerg Roedel ; David > Woodhouse ; Alex Williamson > > Subject: Re: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over > first > level > > Hi, > > On 12/17/19 9:37 AM,

RE: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level

2019-12-16 Thread Liu, Yi L
> From: Liu, Yi L > Sent: Tuesday, December 17, 2019 10:26 AM > To: Lu Baolu ; Joerg Roedel ; David > Woodhouse ; Alex Williamson > > Subject: RE: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over > first > level > > > From: Lu Baolu [mailto:baolu...@linux.intel.com] > > Sent:

RE: [PATCH v3 4/6] iommu/vt-d: Setup pasid entries for iova over first level

2019-12-16 Thread Liu, Yi L
> From: Lu Baolu < baolu...@linux.intel.com > > Sent: Tuesday, December 17, 2019 10:04 AM > To: Liu, Yi L ; Joerg Roedel ; David > Woodhouse ; Alex Williamson > > Subject: Re: [PATCH v3 4/6] iommu/vt-d: Setup pasid entries for iova over > first level > > Hi Yi, > > On 12/15/19 5:37 PM, Liu, Yi

RE: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level

2019-12-16 Thread Liu, Yi L
> From: Lu Baolu [mailto:baolu...@linux.intel.com] > Sent: Tuesday, December 17, 2019 9:37 AM > To: Liu, Yi L ; Joerg Roedel ; David > Woodhouse ; Alex Williamson > > Subject: Re: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over > first > level > > Hi again, > > On 12/17/19

Re: [PATCH v3 4/6] iommu/vt-d: Setup pasid entries for iova over first level

2019-12-16 Thread Lu Baolu
Hi Yi, On 12/15/19 5:37 PM, Liu, Yi L wrote: XD (bit 63) is only for the first level, and SNP (bit 11) is only for second level, right? I think we need to always set XD bit for IOVA over FL case. thoughts? Oops, I made a mistake here. Please forget SNP bit, there is no way to control SNP

Re: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level

2019-12-16 Thread Lu Baolu
Hi, On 12/17/19 9:37 AM, Lu Baolu wrote: You are right. I will change it accordingly. The logic should look like: if (domain attached to physical device) flush_piotlb_with_RID2PASID() else if (domain_attached_to_mdev_device) flush_piotlb_with_default_pasid() Both! so no "else"

Re: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level

2019-12-16 Thread Lu Baolu
Hi again, On 12/17/19 9:19 AM, Lu Baolu wrote: Hi Yi, On 12/15/19 5:22 PM, Liu, Yi L wrote: Ok, let me explain more... default pasid is meaningful only when the domain has been attached to a device as an aux-domain. right? No exactly. Each domain has a specific default pasid, no matter

Re: [PATCH v3 5/6] iommu/vt-d: Flush PASID-based iotlb for iova over first level

2019-12-16 Thread Lu Baolu
Hi Yi, On 12/15/19 5:22 PM, Liu, Yi L wrote: Ok, let me explain more... default pasid is meaningful only when the domain has been attached to a device as an aux-domain. right? No exactly. Each domain has a specific default pasid, no matter normal domain (RID based) or aux-domain (PASID

panic in dmar_remove_one_dev_info

2019-12-16 Thread Jerry Snitselaar
HP is seeing a panic on gen9 dl360 and dl560 while testing these other changes we've been eorking on. I just took an initial look, but have to run to a dentist appointment so couldn't dig too deep. It looks like the device sets dev->archdata.iommu to DEFER_DEVICE_DOMAIN_INFO in

Re: [PATCH 1/3] iommu/vt-d: skip RMRR entries that fail the sanity check

2019-12-16 Thread Barret Rhoden via iommu
On 12/16/19 2:07 PM, Chen, Yian wrote: On 12/11/2019 11:46 AM, Barret Rhoden wrote: RMRR entries describe memory regions that are DMA targets for devices outside the kernel's control. RMRR entries that fail the sanity check are pointing to regions of memory that the firmware did not tell the

[PATCH v8 03/10] iommu/vt-d: Add bind guest PASID support

2019-12-16 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 v8 02/10] iommu/vt-d: Add nested translation helper function

2019-12-16 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 v8 05/10] iommu/vt-d: Add svm/sva invalidate function

2019-12-16 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 v8 00/10] Nested Shared Virtual Address (SVA) VT-d support

2019-12-16 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 v8 06/10] iommu/vt-d: Cache virtual command capability register

2019-12-16 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 | 4 2 files changed, 5 insertions(+) diff --git

[PATCH v8 07/10] iommu/vt-d: Enlightened PASID allocation

2019-12-16 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 v8 01/10] iommu/vt-d: Move domain helper to header

2019-12-16 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 v8 08/10] iommu/vt-d: Add custom allocator for IOASID

2019-12-16 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 v8 04/10] iommu/vt-d: Support flushing more translation cache types

2019-12-16 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 v8 09/10] iommu/ioasid: Add notifier for status change

2019-12-16 Thread Jacob Pan
IOASIDs are system resources that can be shared by multiple drivers or subsystems. When status of an IOASID changes at runtime, there is need to notify all current users such that proper actions can be taken. For example, an IOASID can be used by IOMMU subsystem for guest SVM as well as KVM. When

[PATCH v8 10/10] iommu/vt-d: Handle IOASID notifications

2019-12-16 Thread Jacob Pan
IOASID/PASID are shared system resources that can be freed by software components outside IOMMU subsystem. When status of an IOASID changes, e.g. freed or suspended, notifications will be available to its users to take proper action. This patch adds a notification block such that when IOASID is

Re: [PATCH 0/3] iommu/vt-d bad RMRR workarounds

2019-12-16 Thread Chen, Yian
On 12/13/2019 5:52 PM, Lu Baolu wrote: On 12/13/19 10:31 PM, Barret Rhoden wrote: On 12/11/19 9:43 PM, Lu Baolu wrote: The VT-d spec defines the BIOS considerations about RMRR in section 8.4: " BIOS must report the RMRR reported memory addresses as reserved (or as EFI runtime) in the

Re: [PATCH 1/3] iommu/vt-d: skip RMRR entries that fail the sanity check

2019-12-16 Thread Chen, Yian
On 12/11/2019 11:46 AM, Barret Rhoden wrote: RMRR entries describe memory regions that are DMA targets for devices outside the kernel's control. RMRR entries that fail the sanity check are pointing to regions of memory that the firmware did not tell the kernel are reserved or otherwise should

Re: [PATCH v3 5/5] drm/msm/a6xx: Support split pagetables

2019-12-16 Thread Rob Clark
On Mon, Dec 16, 2019 at 8:38 AM Jordan Crouse wrote: > > Attempt to enable split pagetables if the arm-smmu driver supports it. > This will move the default address space from the default region to > the address range assigned to TTBR1. The behavior should be transparent > to the driver for now

Re: [PATCH v3] iommu: fix KASAN use-after-free in iommu_insert_resv_region

2019-12-16 Thread Linus Torvalds
On Mon, Dec 16, 2019 at 6:36 AM Auger Eric wrote: >On 12/16/19 3:24 PM, Qian Cai wrote: > > > > Looks like Joerg is away for a few weeks. Could Andrew or Linus pick up this > > use-after-free? I've taken it. > Note the right version to pick up is the v4, reviewed by Jerry: >

[PATCH v3 5/5] drm/msm/a6xx: Support split pagetables

2019-12-16 Thread Jordan Crouse
Attempt to enable split pagetables if the arm-smmu driver supports it. This will move the default address space from the default region to the address range assigned to TTBR1. The behavior should be transparent to the driver for now but it gets the default buffers out of the way when we want to

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

2019-12-16 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. Make the generic code cleaner by using target specific functions

[PATCH v3 2/5] iommu/arm-smmu: Add support for split pagetables

2019-12-16 Thread Jordan Crouse
Add support to enable split pagetables (TTBR1) if the supporting driver requests it via the DOMAIN_ATTR_SPLIT_TABLES flag. When enabled, the driver will set up the TTBR0 and TTBR1 regions and program the default domain pagetable on TTBR1. After attaching the device, the value of he domain

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

2019-12-16 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 v3 1/5] iommu: Add DOMAIN_ATTR_SPLIT_TABLES

2019-12-16 Thread Jordan Crouse
Add a new attribute to enable and query the state of split pagetables for the domain. Signed-off-by: Jordan Crouse --- include/linux/iommu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index f2223cb..18c861e 100644 ---

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

2019-12-16 Thread Jordan Crouse
address space for the TTBR1 range. These patches are on based on top of linux-next-20191216 with [1], [2], and [3] from Robin on the iommu list. Change log: v3: Remove the implementation specific and make split pagetable support part of the generic configuration [1] https://lists.linuxfoundation.org

Re: [PATCH v3] iommu: fix KASAN use-after-free in iommu_insert_resv_region

2019-12-16 Thread Auger Eric
Hi, On 12/16/19 3:24 PM, Qian Cai wrote: > > >> On Nov 26, 2019, at 5:27 AM, Eric Auger wrote: >> >> In case the new region gets merged into another one, the nr >> list node is freed. Checking its type while completing the >> merge algorithm leads to a use-after-free. Use new->type >> instead.

Re: [PATCH v3] iommu: fix KASAN use-after-free in iommu_insert_resv_region

2019-12-16 Thread Qian Cai
> On Nov 26, 2019, at 5:27 AM, Eric Auger wrote: > > In case the new region gets merged into another one, the nr > list node is freed. Checking its type while completing the > merge algorithm leads to a use-after-free. Use new->type > instead. > > Fixes: 4dbd258ff63e ("iommu: Revisit

Re: [RESEND,PATCH 02/13] iommu/mediatek: Add mt6779 IOMMU basic support

2019-12-16 Thread Yong Wu
On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > 1. Add mt6779 registers define for iommu. > 2. Add mt6779_data define to support mt6779 iommu HW init. > 3. There are two iommus, one is mm_iommu, the other is vpu_iommu. > MM_IOMMU is connected smi_larb to support multimedia engine to > access

Re: [RESEND,PATCH 03/13] iommu/mediatek: Add mtk_iommu_pgtable structure

2019-12-16 Thread Yong Wu
On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > Start with this patch, we will change the SW architecture > to support multiple domains. SW architecture will has a big change, > so we need to modify a little bit by more than one patch. > The new SW overall architecture is as below: > >

Re: [RESEND,PATCH 01/13] dt-bindings: mediatek: Add bindings for MT6779

2019-12-16 Thread Yong Wu
On Mon, 2019-11-04 at 19:52 +0800, Chao Hao wrote: > This patch adds description for MT6779 IOMMU. > > MT6779 has two iommus, they are MM_IOMMU and APU_IOMMU which > use ARM Short-Descriptor translation format. > > The MT6779 IOMMU hardware diagram is as below, it is only a brief > diagram about