Re: [PATCH 4/4] pci: export untrusted attribute in sysfs

2020-06-16 Thread Christoph Hellwig
On Mon, Jun 15, 2020 at 06:17:42PM -0700, Rajat Jain via iommu wrote: > This is needed to allow the userspace to determine when an untrusted > device has been added, and thus allowing it to bind the driver manually > to it, if it so wishes. This is being done as part of the approach > discussed at

Re: [RFC][PATCH 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module

2020-06-16 Thread Marc Zyngier
Hi John, +Will for the SMMU part. On 2020-06-16 07:13, John Stultz wrote: Allow the qcom_scm driver to be loadable as a permenent module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Lina Iyer Cc: Sarava

Re: [PATCH v2 08/12] mm: Define pasid in mm

2020-06-16 Thread Jean-Philippe Brucker
On Fri, Jun 12, 2020 at 05:41:29PM -0700, Fenghua Yu wrote: > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > index 64ede5f150dc..5778db3aa42d 100644 > --- a/include/linux/mm_types.h > +++ b/include/linux/mm_types.h > @@ -538,6 +538,10 @@ struct mm_struct { > atomic

Re: [PATCH 2/4] pci: set "untrusted" flag for truly external devices only

2020-06-16 Thread Mika Westerberg
On Mon, Jun 15, 2020 at 06:17:40PM -0700, Rajat Jain wrote: > The "ExternalFacing" devices (root ports) are still internal devices > that sit on the internal system fabric and thus trusted. Currently they > were being marked untrusted - likely as an unintended border case. It was actually intentio

Re: [PATCH] iommu/amd: Fix event counter availability check

2020-06-16 Thread Suravee Suthikulpanit
On 6/16/20 3:48 AM, Alexander Monakov wrote: Alexander On 6/1/20 4:01 PM, Alexander Monakov wrote: On Mon, 1 Jun 2020, Suravee Suthikulpanit wrote: Moving init_iommu_perf_ctr just after iommu_flush_all_caches resolves the issue. This is the earliest point in amd_iommu_init_pci where the ca

Re: [PATCH] dma-direct: enable mmap for !CONFIG_MMU

2020-06-16 Thread Vladimir Murzin
On 6/15/20 8:05 AM, Christoph Hellwig wrote: > nommu configfs can trivially map the coherent allocations to user space, > as no actual page table setup is required and the kernel and the user > space programs share the same address space. > > Fixes: 62fcee9a3bd7 ("dma-mapping: remove CONFIG_ARCH_N

[PATCH RFC v2 0/4] iommu/arm-smmu-v3: Improve cmdq lock efficiency

2020-06-16 Thread John Garry
As mentioned in [0], the CPU may consume many cycles processing arm_smmu_cmdq_issue_cmdlist(). One issue we find is the cmpxchg() loop to get space on the queue takes approx 25% of the cycles for this function. This series removes that cmpxchg(). For my NVMe test with 3x NVMe SSDs, I'm getting a

[PATCH v2 1/4] iommu/arm-smmu-v3: Fix trivial typo

2020-06-16 Thread John Garry
Set "cmq" -> "cmdq". Signed-off-by: John Garry --- drivers/iommu/arm-smmu-v3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c index f578677a5c41..a8e814c652fe 100644 --- a/drivers/iommu/arm-smmu-v3.c +++ b/drivers/iom

[PATCH RFC v2 3/4] iommu/arm-smmu-v3: Always issue a CMD_SYNC per batch

2020-06-16 Thread John Garry
To ensure that a CPU does not send more than a permitted amount of commands to the cmdq, ensure that each batch includes a CMD_SYNC. When issuing a CMD_SYNC, we always wait for the consumption of its batch of commands - as such, we guarantee that any CPU will not issue more than its permitted amoun

[PATCH RFC v2 4/4] iommu/arm-smmu-v3: Remove cmpxchg() in arm_smmu_cmdq_issue_cmdlist()

2020-06-16 Thread John Garry
It has been shown that the cmpxchg() for finding space in the cmdq can be a real bottleneck: - for more CPUs contending the cmdq, the cmpxchg() will fail more often - since the software-maintained cons pointer is updated on the same 64b memory region, the chance of cmpxchg() failure increases aga

[PATCH RFC v2 2/4] iommu/arm-smmu-v3: Calculate bits for prod and owner

2020-06-16 Thread John Garry
Since the arm_smmu_ll_queue.prod will be for counting the "owner" value and also HW prod pointer, calculate how many bits are available for and used by each. This is based on the number of possible CPUs in the system. And we require that each CPU can issue a minimum of 2 commands per batch - 1 x C

Re: [RFC][PATCH 3/5] irqchip: Allow QCOM_PDC to be loadable as a perment module

2020-06-16 Thread Maulik Shah
Hi, On 6/16/2020 11:43 AM, John Stultz wrote: Allows qcom-pdc driver to be loaded as a permenent module typo: permanent Also, due to the fact that IRQCHIP_DECLARE becomes a no-op when building as a module, we have to add the platform driver hooks explicitly. Thanks to Saravana for his help

[PATCH] iommu: Allow page responses without PASID

2020-06-16 Thread Jean-Philippe Brucker
Some PCIe devices do not expect a PASID value in PRI Page Responses. If the "PRG Response PASID Required" bit in the PRI capability is zero, then the OS should not set the PASID field. Similarly on Arm SMMU, responses to stall events do not have a PASID. Currently iommu_page_response() systematica

Re: [PATCH v2 08/12] mm: Define pasid in mm

2020-06-16 Thread Fenghua Yu
Hi, Jean, On Tue, Jun 16, 2020 at 10:28:19AM +0200, Jean-Philippe Brucker wrote: > On Fri, Jun 12, 2020 at 05:41:29PM -0700, Fenghua Yu wrote: > > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h > > index 64ede5f150dc..5778db3aa42d 100644 > > --- a/include/linux/mm_types.h > > +++

Re: [PATCH v2 1/3] docs: IOMMU user API

2020-06-16 Thread Jacob Pan
On Thu, 11 Jun 2020 17:27:27 -0700 Jacob Pan wrote: > > > > But then I thought it even better if VFIO leaves the entire > > copy_from_user() to the layer consuming it. > > > OK. Sounds good, that was what Kevin suggested also. I just wasn't > sure how much VFIO wants to inspect, I thought VFI

Re: [PATCH v2 00/15] vfio: expose virtual Shared Virtual Addressing to VMs

2020-06-16 Thread Stefan Hajnoczi
On Mon, Jun 15, 2020 at 12:39:40PM +, Liu, Yi L wrote: > > From: Stefan Hajnoczi > > Sent: Monday, June 15, 2020 6:02 PM > > > > On Thu, Jun 11, 2020 at 05:15:19AM -0700, Liu Yi L wrote: > > > Shared Virtual Addressing (SVA), a.k.a, Shared Virtual Memory (SVM) on > > > Intel platforms allows

Re: [PATCH v2 00/15] vfio: expose virtual Shared Virtual Addressing to VMs

2020-06-16 Thread Stefan Hajnoczi
On Tue, Jun 16, 2020 at 02:26:38AM +, Tian, Kevin wrote: > > From: Stefan Hajnoczi > > Sent: Monday, June 15, 2020 6:02 PM > > > > On Thu, Jun 11, 2020 at 05:15:19AM -0700, Liu Yi L wrote: > > > Shared Virtual Addressing (SVA), a.k.a, Shared Virtual Memory (SVM) on > > > Intel platforms allow

Re: [PATCH v2 00/15] vfio: expose virtual Shared Virtual Addressing to VMs

2020-06-16 Thread Peter Xu
On Tue, Jun 16, 2020 at 04:49:28PM +0100, Stefan Hajnoczi wrote: > Isolation between applications is preserved but there is no isolation > between the device and the application itself. The application needs to > trust the device. > > Examples: > > 1. The device can snoop secret data from readabl

Re: [PATCH v2 00/15] vfio: expose virtual Shared Virtual Addressing to VMs

2020-06-16 Thread Raj, Ashok
On Tue, Jun 16, 2020 at 04:49:28PM +0100, Stefan Hajnoczi wrote: > On Tue, Jun 16, 2020 at 02:26:38AM +, Tian, Kevin wrote: > > > From: Stefan Hajnoczi > > > Sent: Monday, June 15, 2020 6:02 PM > > > > > > On Thu, Jun 11, 2020 at 05:15:19AM -0700, Liu Yi L wrote: > > > > Shared Virtual Addres

Re: [RFC][PATCH 3/5] irqchip: Allow QCOM_PDC to be loadable as a perment module

2020-06-16 Thread Lina Iyer
On Tue, Jun 16 2020 at 05:30 -0600, Maulik Shah wrote: Hi, On 6/16/2020 11:43 AM, John Stultz wrote: Allows qcom-pdc driver to be loaded as a permenent module typo: permanent Also, due to the fact that IRQCHIP_DECLARE becomes a no-op when building as a module, we have to add the platform dr

Re: [PATCH 4/4] pci: export untrusted attribute in sysfs

2020-06-16 Thread Rajat Jain via iommu
On Tue, Jun 16, 2020 at 12:32 AM Christoph Hellwig wrote: > > On Mon, Jun 15, 2020 at 06:17:42PM -0700, Rajat Jain via iommu wrote: > > This is needed to allow the userspace to determine when an untrusted > > device has been added, and thus allowing it to bind the driver manually > > to it, if it

Re: [RFC][PATCH 5/5] firmware: QCOM_SCM: Allow qcom_scm driver to be loadable as a permenent module

2020-06-16 Thread John Stultz
On Tue, Jun 16, 2020 at 12:55 AM Marc Zyngier wrote: > On 2020-06-16 07:13, John Stultz wrote: > > diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig > > index b510f67dfa49..714893535dd2 100644 > > --- a/drivers/iommu/Kconfig > > +++ b/drivers/iommu/Kconfig > > @@ -381,6 +381,7 @@ config S

[PATCH v5 00/12] PCI: brcmstb: enable PCIe for STB chips

2020-06-16 Thread Jim Quinlan via iommu
Patchset Summary: Enhance a PCIe host controller driver. Because of its unusual design we are foced to change dev->dma_pfn_offset into a more general role allowing multiple offsets. v5: Commit "device core: Introduce multiple dma pfn offsets" -- in of/address.c: "map_size = 0" => "*map_

[PATCH v5 08/12] device core: Introduce multiple dma pfn offsets

2020-06-16 Thread Jim Quinlan via iommu
The new field in struct device 'dma_pfn_offset_map' is used to facilitate the use of single or multiple pfn offsets between cpu addrs and dma addrs. It subsumes the role of dev->dma_pfn_offset -- a uniform offset. The function of_dma_get_range() has been modified to take two additional arguments:

Re: [RFC][PATCH 3/5] irqchip: Allow QCOM_PDC to be loadable as a perment module

2020-06-16 Thread John Stultz
On Tue, Jun 16, 2020 at 4:30 AM Maulik Shah wrote: > > Hi, > > On 6/16/2020 11:43 AM, John Stultz wrote: > > Allows qcom-pdc driver to be loaded as a permenent module > > typo: permanent > > > Also, due to the fact that IRQCHIP_DECLARE becomes a no-op when > > building as a module, we have to add

[PATCH] iommu/amd: Print extended features in one line to fix divergent log levels

2020-06-16 Thread Paul Menzel
Currently, Linux logs the two messages below. [0.979142] pci :00:00.2: AMD-Vi: Extended features (0xf77ef22294ada): [0.979546] PPR NX GT IA GA PC GA_vAPIC The log level of these lines differs though. The first one has level *info*, while the second has level *warn*, which is

Re: [PATCH v2 12/12] x86/traps: Fix up invalid PASID

2020-06-16 Thread Fenghua Yu
Hi, Peter, On Mon, Jun 15, 2020 at 09:09:28PM +0200, Peter Zijlstra wrote: > On Mon, Jun 15, 2020 at 11:55:29AM -0700, Fenghua Yu wrote: > > > Or do you suggest to add a random new flag in struct thread_info instead > > of a TIF flag? > > Why thread_info? What's wrong with something simple like

[PATCH v4 3/7] iommu/mediatek: Set MISC_CTRL register

2020-06-16 Thread Chao Hao
Add F_MMU_IN_ORDER_WR_EN definition in MISC_CTRL. In order to improve performance, we always disable STANDARD_AXI_MODE and IN_ORDER_WR_EN in MISC_CTRL. Change since v3: 1. Rename Disable STANDARD_AXI_MODE in MISC_CTRL to Set MISC_CTRL register 2. Add F_MMU_IN_DRDER_WR_EN definition in MISC_CTRL

[PATCH v4 00/07] MT6779 IOMMU SUPPORT

2020-06-16 Thread Chao Hao
This patchset adds mt6779 iommu support. mt6779 has two iommus, they are MM_IOMMU(M4U) and APU_IOMMU which used ARM Short-Descriptor translation format. The mt6779's MM_IOMMU-SMI and APU_IOMMU HW diagram is as below, it is only a brief diagram: EMI

[PATCH v4 2/7] iommu/mediatek: Rename the register STANDARD_AXI_MODE(0x48) to MISC_CTRL

2020-06-16 Thread Chao Hao
For iommu offset=0x48 register, only the previous mt8173/mt8183 use the name STANDARD_AXI_MODE, all the latest SoC extend the register more feature by different bits, for example: axi_mode, in_order_en, coherent_en and so on. So rename REG_MMU_MISC_CTRL may be more proper. This patch only rename t

[PATCH v4 1/7] dt-bindings: mediatek: Add bindings for MT6779

2020-06-16 Thread Chao Hao
This patch adds description for MT6779 IOMMU. MT6779 has two iommus, they are mm_iommu and apu_iommu which both use ARM Short-Descriptor translation format. In addition, mm_iommu and apu_iommu are two independent HW instance , we need to set them separately. The MT6779 IOMMU hardware diagram is

[PATCH v4 4/7] iommu/mediatek: Move inv_sel_reg into the plat_data

2020-06-16 Thread Chao Hao
For mt6779, MMU_INV_SEL register's offset is changed from 0x38 to 0x2c, so we can put inv_sel_reg in the plat_data to use it. In addition, we renamed it to REG_MMU_INV_SEL_GEN1 and use it before mt6779. Change since v3: 1. Fix coding style Cc: Yong Wu Signed-off-by: Chao Hao --- drivers/iommu/

[PATCH v4 5/7] iommu/mediatek: Add sub_comm id in translation fault

2020-06-16 Thread Chao Hao
The max larb number that a iommu HW support is 8(larb0~larb7 in the below diagram). If the larb's number is over 8, we use a sub_common for merging several larbs into one larb. At this case, we will extend larb_id: bit[11:9] means common-id; bit[8:7] means subcommon-id; >From these two variable, we

[PATCH v4 7/7] iommu/mediatek: Add mt6779 basic support

2020-06-16 Thread Chao Hao
1. Start from mt6779, INVLDT_SEL move to offset=0x2c, so we add REG_MMU_INV_SEL_GEN2 definition and mt6779 uses it. 2. Change PROTECT_PA_ALIGN from 128 byte to 256 byte. 3. For REG_MMU_CTRL_REG register, we only need to change bit[2:0], others bits keep default value, ex: enable victim tlb. 4

[PATCH v4 6/7] iommu/mediatek: Add REG_MMU_WR_LEN definition preparing for mt6779

2020-06-16 Thread Chao Hao
Some platforms(ex: mt6779) have a new register called by REG_MMU_WR_LEN to improve performance. This patch add this register definition. Signed-off-by: Chao Hao --- drivers/iommu/mtk_iommu.c | 10 ++ drivers/iommu/mtk_iommu.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/drive

Re: [PATCH v4 01/17] media: dt-binding: mtk-vcodec: Separating mtk-vcodec encode node.

2020-06-16 Thread Tiffany Lin
On Wed, 2020-06-10 at 15:38 +0800, Tiffany Lin wrote: > On Wed, 2020-06-10 at 15:46 +0900, Alexandre Courbot wrote: > > On Wed, Jun 10, 2020 at 6:21 AM Rob Herring wrote: > > > > > > On Sat, May 30, 2020 at 04:10:02PM +0800, Yong Wu wrote: > > > > From: Maoguang Meng > > > > > > > > Update bindin

RE: [PATCH v2 1/3] docs: IOMMU user API

2020-06-16 Thread Liu, Yi L
> From: Jacob Pan > Sent: Tuesday, June 16, 2020 11:22 PM > > On Thu, 11 Jun 2020 17:27:27 -0700 > Jacob Pan wrote: > > > > > > > But then I thought it even better if VFIO leaves the entire > > > copy_from_user() to the layer consuming it. > > > > > OK. Sounds good, that was what Kevin suggeste

RE: [PATCH v2 14/15] vfio: Document dual stage control

2020-06-16 Thread Liu, Yi L
> From: Stefan Hajnoczi > Sent: Monday, June 15, 2020 5:41 PM > On Thu, Jun 11, 2020 at 05:15:33AM -0700, Liu Yi L wrote: > > > From: Eric Auger > > > > The VFIO API was enhanced to support nested stage control: a bunch of > > new iotcls and usage guideline. > > > > Let's document the process to