[PATCH v2 3/5] irqchip: Allow QCOM_PDC to be loadable as a permanent module

2020-06-24 Thread John Stultz
Allows qcom-pdc driver to be loaded as a permanent module 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 on pointing out the IRQCHIP_DECLARE issue and guidance on a

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

2020-06-24 Thread John Stultz
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: Maulik Shah Cc: Lina Iyer Cc: Saravana Kannan Cc: Todd Kjos Cc: Greg Kroah-Hartman Cc:

[PATCH v2 1/5] irq: irqdomain: Export irq_domain_update_bus_token

2020-06-24 Thread John Stultz
Add export for irq_domain_update_bus_token() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier Cc: Linus Walleij Cc: Maulik Shah Cc: Lina Iyer Cc:

[PATCH v2 4/5] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module

2020-06-24 Thread John Stultz
Tweaks to allow pinctrl-msm code to be loadable as a module. This is needed in order to support having the qcom-scm driver, which pinctrl-msm calls into, configured as a module. This requires that we tweak Kconfigs selecting PINCTRL_MSM to also depend on QCOM_SCM || QCOM_SCM=n so that we match

[PATCH v2 2/5] irq: irqchip: Export irq_chip_retrigger_hierarchy and irq_chip_set_vcpu_affinity_parent

2020-06-24 Thread John Stultz
Add EXPORT_SYMBOL_GPL entries for irq_chip_retrigger_hierarchy() and irq_chip_set_vcpu_affinity_parent() so that we can allow drivers like the qcom-pdc driver to be loadable as a module. Cc: Andy Gross Cc: Bjorn Andersson Cc: Joerg Roedel Cc: Thomas Gleixner Cc: Jason Cooper Cc: Marc Zyngier

[PATCH v2 0/5] Allow for qcom-pdc, pinctrl-msm and qcom-scm drivers to be loadable as modules

2020-06-24 Thread John Stultz
This patch series provides exports and config tweaks to allow the qcom-pdc, pinctrl-msm and qcom-scm drivers to be able to be configured as permement modules (particularlly useful for the Android Generic Kernel Image efforts). Feedback would be appreciated! New in v2: * Fix up MSM_PINCTRL

Re: [RFC][PATCH 4/5] pinctrl: qcom: Allow pinctrl-msm code to be loadable as a module

2020-06-24 Thread John Stultz
On Sat, Jun 20, 2020 at 11:03 PM Bjorn Andersson wrote: > > On Mon 15 Jun 23:13 PDT 2020, John Stultz wrote: > > > Tweaks to allow pinctrl-msm code to be loadable as a module. > > This is needed in order to support having the qcom-scm driver, > > which pinctrl-msm calls into, configured as a

Re: [PATCH] xen: introduce xen_vring_use_dma

2020-06-24 Thread Michael S. Tsirkin
On Wed, Jun 24, 2020 at 02:53:54PM -0700, Stefano Stabellini wrote: > On Wed, 24 Jun 2020, Michael S. Tsirkin wrote: > > On Wed, Jun 24, 2020 at 10:59:47AM -0700, Stefano Stabellini wrote: > > > On Wed, 24 Jun 2020, Michael S. Tsirkin wrote: > > > > On Wed, Jun 24, 2020 at 05:17:32PM +0800, Peng

Re: [PATCH] xen: introduce xen_vring_use_dma

2020-06-24 Thread Stefano Stabellini
On Wed, 24 Jun 2020, Michael S. Tsirkin wrote: > On Wed, Jun 24, 2020 at 10:59:47AM -0700, Stefano Stabellini wrote: > > On Wed, 24 Jun 2020, Michael S. Tsirkin wrote: > > > On Wed, Jun 24, 2020 at 05:17:32PM +0800, Peng Fan wrote: > > > > Export xen_swiotlb for all platforms using xen swiotlb > >

Re: [PATCH v2] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-06-24 Thread Konrad Rzeszutek Wilk
.snip.. > > Actually as per the boot flow : > > > > setup_arch() calls reserve_crashkernel() and pci_iommu_alloc() is > > invoked through mm_init()/mem_init() and not via initmem_init(). > > > > start_kernel: > > ... > > setup_arch() > > reserve_crashkernel > >

Re: [PATCH] xen: introduce xen_vring_use_dma

2020-06-24 Thread Michael S. Tsirkin
On Wed, Jun 24, 2020 at 10:59:47AM -0700, Stefano Stabellini wrote: > On Wed, 24 Jun 2020, Michael S. Tsirkin wrote: > > On Wed, Jun 24, 2020 at 05:17:32PM +0800, Peng Fan wrote: > > > Export xen_swiotlb for all platforms using xen swiotlb > > > > > > Use xen_swiotlb to determine when vring

Re: [PATCH] xen: introduce xen_vring_use_dma

2020-06-24 Thread Stefano Stabellini
On Wed, 24 Jun 2020, Michael S. Tsirkin wrote: > On Wed, Jun 24, 2020 at 05:17:32PM +0800, Peng Fan wrote: > > Export xen_swiotlb for all platforms using xen swiotlb > > > > Use xen_swiotlb to determine when vring should use dma APIs to map the > > ring: when xen_swiotlb is enabled the dma API is

Re: [PATCH v3 4/5] iommu/uapi: Handle data and argsz filled by users

2020-06-24 Thread Jacob Pan
On Wed, 24 Jun 2020 14:54:49 +0800 Lu Baolu wrote: > Hi Jacob, > > On 2020/6/24 1:03, Jacob Pan wrote: > > IOMMU UAPI data has a user filled argsz field which indicates the > > data length comes with the API call. User data is not trusted, > > argsz must be validated based on the current kernel

Re: [PATCH v2] dma-pool: Fix too large DMA pools on medium systems

2020-06-24 Thread Guenter Roeck
On Wed, Jun 24, 2020 at 09:38:15AM +0200, Christoph Hellwig wrote: > Hi Guenter, > > can you try the patch below? This just converts the huge allocations > in mptbase to use GFP_KERNEL. Christophe (added to Cc) actually has > a scripted conversion for the rest that he hasn't posted yet, so I'll

Re: [PATCH 0/3] iommu/amd: I/O VA address limits

2020-06-24 Thread Sebastian Ott via iommu
Hello Joerg, On 2020-06-05 16:56, Sebastian Ott wrote: The IVRS ACPI table specifies maximum address sizes for I/O virtual addresses that can be handled by the IOMMUs in the system. Parse that data from the IVRS header to provide aperture information for DMA mappings and users of the iommu API.

Re: [PATCH v3 3/5] iommu/uapi: Use named union for user data

2020-06-24 Thread Jacob Pan
On Wed, 24 Jun 2020 14:29:57 +0800 Lu Baolu wrote: > > case IOMMU_CACHE_INV_TYPE_IOTLB: > > /* HW will ignore LSB bits based on > > address mask */ if (inv_info->granularity == IOMMU_INV_GRANU_ADDR && > > size && > > -

Re: [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow

2020-06-24 Thread Joerg Roedel
Hi Greg, On Wed, Jun 24, 2020 at 11:09:06AM +0200, Greg KH wrote: > So what exact stable kernel version(s) do you want to see this patch > applied to? It is needed in kernels <= v5.4. Linux v5.5 has replaced the code with the bug. Joerg ___

Re: [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow

2020-06-24 Thread Joerg Roedel
On Wed, Jun 24, 2020 at 08:41:21AM +, Suravee Suthikulpanit wrote: > Currently, an integer is used to specify the size in unmap_sg(). > With 2GB worth of pages (512k 4k pages), it requires 31 bits > (i.e. (1 << 19) << 12), which overflows the integer, and ends up > unmapping more pages than

[PATCH] iommu/arm-smmu: Update impl quirks comment

2020-06-24 Thread Robin Murphy
The comment about implementation and integration quirks being mutually-exclusive is out of date, and in fact the code is already structured for the case it anticipates, so document that properly. Signed-off-by: Robin Murphy --- drivers/iommu/arm-smmu-impl.c | 8 1 file changed, 4

[PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow

2020-06-24 Thread Suravee Suthikulpanit
Currently, an integer is used to specify the size in unmap_sg(). With 2GB worth of pages (512k 4k pages), it requires 31 bits (i.e. (1 << 19) << 12), which overflows the integer, and ends up unmapping more pages than intended. Subsequently, this results in IO_PAGE_FAULT. Uses size_t instead of

Re: [PATCH v2] iommu: amd: Fix IO_PAGE_FAULT due to __unmap_single() size overflow

2020-06-24 Thread Greg KH
On Wed, Jun 24, 2020 at 08:41:21AM +, Suravee Suthikulpanit wrote: > Currently, an integer is used to specify the size in unmap_sg(). > With 2GB worth of pages (512k 4k pages), it requires 31 bits > (i.e. (1 << 19) << 12), which overflows the integer, and ends up > unmapping more pages than

Re: [PATCH] xen: introduce xen_vring_use_dma

2020-06-24 Thread Michael S. Tsirkin
On Wed, Jun 24, 2020 at 05:17:32PM +0800, Peng Fan wrote: > Export xen_swiotlb for all platforms using xen swiotlb > > Use xen_swiotlb to determine when vring should use dma APIs to map the > ring: when xen_swiotlb is enabled the dma API is required. When it is > disabled, it is not required. >

[PATCH] xen: introduce xen_vring_use_dma

2020-06-24 Thread Peng Fan
Export xen_swiotlb for all platforms using xen swiotlb Use xen_swiotlb to determine when vring should use dma APIs to map the ring: when xen_swiotlb is enabled the dma API is required. When it is disabled, it is not required. Signed-off-by: Peng Fan --- V2: This is a modified version from

[PATCH v3 09/14] vfio/type1: Support binding guest page tables to PASID

2020-06-24 Thread Liu Yi L
Nesting translation allows two-levels/stages page tables, with 1st level for guest translations (e.g. GVA->GPA), 2nd level for host translations (e.g. GPA->HPA). This patch adds interface for binding guest page tables to a PASID. This PASID must have been allocated to user space before the binding

[PATCH v3 12/14] vfio/pci: Expose PCIe PASID capability to guest

2020-06-24 Thread Liu Yi L
This patch exposes PCIe PASID capability to guest for assigned devices. Existing vfio_pci driver hides it from guest by setting the capability length as 0 in pci_ext_cap_length[]. And this patch only exposes PASID capability for devices which has PCIe PASID extended struture in its configuration

[PATCH v3 06/14] vfio/type1: Add VFIO_IOMMU_PASID_REQUEST (alloc/free)

2020-06-24 Thread Liu Yi L
This patch allows user space to request PASID allocation/free, e.g. when serving the request from the guest. PASIDs that are not freed by userspace are automatically freed when the IOASID set is destroyed when process exits. Cc: Kevin Tian CC: Jacob Pan Cc: Alex Williamson Cc: Eric Auger Cc:

[PATCH v3 13/14] vfio: Document dual stage control

2020-06-24 Thread Liu Yi L
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 follow to set up nested mode. Cc: Kevin Tian CC: Jacob Pan Cc: Alex Williamson Cc: Eric Auger Cc: Jean-Philippe Brucker Cc: Joerg Roedel

[PATCH v3 03/14] vfio/type1: Report iommu nesting info to userspace

2020-06-24 Thread Liu Yi L
This patch exports iommu nesting capability info to user space through VFIO. User space is expected to check this info for supported uAPIs (e.g. PASID alloc/free, bind page table, and cache invalidation) and the vendor specific format information for first level/stage page table that will be bound

[PATCH v3 02/14] iommu: Report domain nesting info

2020-06-24 Thread Liu Yi L
IOMMUs that support nesting translation needs report the capability info to userspace, e.g. the format of first level/stage paging structures. This patch reports nesting info by DOMAIN_ATTR_NESTING. Caller can get nesting info after setting DOMAIN_ATTR_NESTING. v2 -> v3: *) remvoe cap/ecap_mask

[PATCH v3 07/14] iommu: Pass domain to sva_unbind_gpasid()

2020-06-24 Thread Liu Yi L
From: Yi Sun Current interface is good enough for SVA virtualization on an assigned physical PCI device, but when it comes to mediated devices, a physical device may attached with multiple aux-domains. Also, for guest unbind, the PASID to be unbind should be allocated to the VM. This check

[PATCH v3 11/14] vfio/type1: Add vSVA support for IOMMU-backed mdevs

2020-06-24 Thread Liu Yi L
Recent years, mediated device pass-through framework (e.g. vfio-mdev) is used to achieve flexible device sharing across domains (e.g. VMs). Also there are hardware assisted mediated pass-through solutions from platform vendors. e.g. Intel VT-d scalable mode which supports Intel Scalable I/O

[PATCH v3 01/14] vfio/type1: Refactor vfio_iommu_type1_ioctl()

2020-06-24 Thread Liu Yi L
This patch refactors the vfio_iommu_type1_ioctl() to use switch instead of if-else, and each cmd got a helper function. Cc: Kevin Tian CC: Jacob Pan Cc: Alex Williamson Cc: Eric Auger Cc: Jean-Philippe Brucker Cc: Joerg Roedel Cc: Lu Baolu Suggested-by: Christoph Hellwig Signed-off-by:

[PATCH v3 00/14] vfio: expose virtual Shared Virtual Addressing to VMs

2020-06-24 Thread Liu Yi L
Shared Virtual Addressing (SVA), a.k.a, Shared Virtual Memory (SVM) on Intel platforms allows address space sharing between device DMA and applications. SVA can reduce programming complexity and enhance security. This VFIO series is intended to expose SVA usage to VMs. i.e. Sharing guest

[PATCH v3 04/14] vfio: Add PASID allocation/free support

2020-06-24 Thread Liu Yi L
Shared Virtual Addressing (a.k.a Shared Virtual Memory) allows sharing multiple process virtual address spaces with the device for simplified programming model. PASID is used to tag an virtual address space in DMA requests and to identify the related translation structure in IOMMU. When a

[PATCH v3 14/14] iommu/vt-d: Support reporting nesting capability info

2020-06-24 Thread Liu Yi L
Cc: Kevin Tian CC: Jacob Pan Cc: Alex Williamson Cc: Eric Auger Cc: Jean-Philippe Brucker Cc: Joerg Roedel Cc: Lu Baolu Signed-off-by: Liu Yi L Signed-off-by: Jacob Pan --- v2 -> v3: *) remove cap/ecap_mask in iommu_nesting_info. --- drivers/iommu/intel/iommu.c | 79

[PATCH v3 08/14] iommu/vt-d: Check ownership for PASIDs from user-space

2020-06-24 Thread Liu Yi L
When an IOMMU domain with nesting attribute is used for guest SVA, a system-wide PASID is allocated for binding with the device and the domain. For security reason, we need to check the PASID passsed from user-space. e.g. page table bind/unbind and PASID related cache invalidation. Cc: Kevin Tian

[PATCH v3 10/14] vfio/type1: Allow invalidating first-level/stage IOMMU cache

2020-06-24 Thread Liu Yi L
This patch provides an interface allowing the userspace to invalidate IOMMU cache for first-level page table. It is required when the first level IOMMU page table is not managed by the host kernel in the nested translation setup. Cc: Kevin Tian CC: Jacob Pan Cc: Alex Williamson Cc: Eric Auger

[PATCH v3 05/14] iommu/vt-d: Support setting ioasid set to domain

2020-06-24 Thread Liu Yi L
>From IOMMU p.o.v., PASIDs allocated and managed by external components (e.g. VFIO) will be passed in for gpasid_bind/unbind operation. IOMMU needs some knowledge to check the PASID ownership, hence add an interface for those components to tell the PASID owner. In latest kernel design, PASID

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

2020-06-24 Thread John Garry
I'd say that GENMASK_INPUT_CHECK() should be able to handle a l=0 and h=unsigned value, so I doubt this warn. Using GENMASK((int)cmdq->q.llq.max_n_shift, 0) resolves it, but it looks like GENMASK_INPUT_CHECK() could be improved. That said, I think this particular case might be even better off

Re: [PATCH v3 5/5] iommu/uapi: Support both kernel and user unbind guest PASID

2020-06-24 Thread Lu Baolu
Hi Jacob, On 2020/6/24 1:03, Jacob Pan wrote: Guest SVA unbind data can come from either kernel and user space, if a either kernel or user space user pointer is passed in, IOMMU driver must copy from data from user. copy data from user If the unbind data is assembled in kernel, data can

Re: [PATCH v2] dma-pool: Fix too large DMA pools on medium systems

2020-06-24 Thread Christoph Hellwig
Hi Guenter, can you try the patch below? This just converts the huge allocations in mptbase to use GFP_KERNEL. Christophe (added to Cc) actually has a scripted conversion for the rest that he hasn't posted yet, so I'll aim for the minimal version here. diff --git

Re: [PATCH v2] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-06-24 Thread Ashish Kalra
On Wed, Jun 24, 2020 at 12:23:57AM +, Ashish Kalra wrote: > Hello Konrad, > > On Tue, Jun 23, 2020 at 09:38:43AM -0400, Konrad Rzeszutek Wilk wrote: > > On Mon, Apr 27, 2020 at 06:53:18PM +, Ashish Kalra wrote: > > > Hello Konrad, > > > > > > On Mon, Mar 30, 2020 at 10:25:51PM +,

Re: [PATCH v3 4/5] iommu/uapi: Handle data and argsz filled by users

2020-06-24 Thread Lu Baolu
Hi Jacob, On 2020/6/24 1:03, Jacob Pan wrote: IOMMU UAPI data has a user filled argsz field which indicates the data length comes with the API call. User data is not trusted, argsz must be validated based on the current kernel data size, mandatory data size, and feature flags. User data may

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

2020-06-24 Thread chao hao
On Sat, 2020-06-20 at 10:03 +0800, Yong Wu wrote: > Hi Chao, > > On Thu, 2020-06-18 at 19:49 +0800, chao hao wrote: > > On Wed, 2020-06-17 at 11:34 +0200, Matthias Brugger wrote: > > [snip] > > > > > > > > > #define REG_MMU_MISC_CTRL 0x048 > > > > +#define

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

2020-06-24 Thread chao hao
On Sun, 2020-06-21 at 13:01 +0200, Matthias Brugger wrote: > > On 19/06/2020 12:56, chao hao wrote: > > On Wed, 2020-06-17 at 11:22 +0200, Matthias Brugger wrote: > >> > >> On 17/06/2020 05:00, Chao Hao wrote: > >>> Some platforms(ex: mt6779) have a new register called by REG_MMU_WR_LEN > >>> to

Re: [PATCH v3 3/5] iommu/uapi: Use named union for user data

2020-06-24 Thread Lu Baolu
Hi Jacob, On 2020/6/24 1:03, Jacob Pan wrote: IOMMU UAPI data size is filled by the user space which must be validated by ther kernel. To ensure backward compatibility, user data can only be extended by either re-purpose padding bytes or extend the variable sized union at the end. No size