RE: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Tian, Kevin
> From: David Gibson > Sent: Wednesday, September 29, 2021 12:56 PM > > > > > Unlike vfio, iommufd adopts a device-centric design with all group > > logistics hidden behind the fd. Binding a device to iommufd serves > > as the contract to get security context established (and vice versa > > for

RE: [RFC 03/20] vfio: Add vfio_[un]register_device()

2021-09-28 Thread Tian, Kevin
> From: David Gibson > Sent: Wednesday, September 29, 2021 10:44 AM > > > One alternative option is to arrange device nodes in sub-directories based > > on the device type. But doing so also adds one trouble to userspace. The > > current vfio uAPI is designed to have the user query device type

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread David Gibson
On Sun, Sep 19, 2021 at 02:38:34PM +0800, Liu Yi L wrote: > From: Lu Baolu > > This extends iommu core to manage security context for passthrough > devices. Please bear a long explanation for how we reach this design > instead of managing it solely in iommufd like what vfio does today. > >

RE: [RFC 03/20] vfio: Add vfio_[un]register_device()

2021-09-28 Thread Tian, Kevin
> From: David Gibson > Sent: Wednesday, September 29, 2021 10:44 AM > > > > > One open about how to organize the device nodes under > /dev/vfio/devices/. > > This RFC adopts a simple policy by keeping a flat layout with mixed > devname > > from all kinds of devices. The prerequisite of this

Re: [RFC 03/20] vfio: Add vfio_[un]register_device()

2021-09-28 Thread David Gibson
On Sun, Sep 19, 2021 at 02:38:31PM +0800, Liu Yi L wrote: > With /dev/vfio/devices introduced, now a vfio device driver has three > options to expose its device to userspace: > > a) only legacy group interface, for devices which haven't been moved to > iommufd (e.g. platform devices, sw

Re: [RFC 02/20] vfio: Add device class for /dev/vfio/devices

2021-09-28 Thread David Gibson
On Sun, Sep 19, 2021 at 02:38:30PM +0800, Liu Yi L wrote: > This patch introduces a new interface (/dev/vfio/devices/$DEVICE) for > userspace to directly open a vfio device w/o relying on container/group > (/dev/vfio/$GROUP). Anything related to group is now hidden behind > iommufd (more

Re: [RFC 03/20] vfio: Add vfio_[un]register_device()

2021-09-28 Thread da...@gibson.dropbear.id.au
On Tue, Sep 21, 2021 at 10:00:14PM -0300, Jason Gunthorpe wrote: > On Wed, Sep 22, 2021 at 12:54:02AM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Wednesday, September 22, 2021 12:01 AM > > > > > > > One open about how to organize the device nodes under > > >

Re: [RFC 04/20] iommu: Add iommu_device_get_info interface

2021-09-28 Thread David Gibson
On Sun, Sep 19, 2021 at 02:38:32PM +0800, Liu Yi L wrote: > From: Lu Baolu > > This provides an interface for upper layers to get the per-device iommu > attributes. > > int iommu_device_get_info(struct device *dev, > enum iommu_devattr attr, void *data); That

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Lu Baolu
On 9/29/21 10:29 AM, Tian, Kevin wrote: From: Lu Baolu Sent: Wednesday, September 29, 2021 10:22 AM On 9/28/21 10:07 PM, Jason Gunthorpe wrote: On Tue, Sep 28, 2021 at 09:35:05PM +0800, Lu Baolu wrote: Another issue is, when putting a device into user-dma mode, all devices belonging to the

[PATCH v8 7/7] dma-iommu: account for min_align_mask w/swiotlb

2021-09-28 Thread David Stevens
From: David Stevens Pass the non-aligned size to __iommu_dma_map when using swiotlb bounce buffers in iommu_dma_map_page, to account for min_align_mask. To deal with granule alignment, __iommu_dma_map maps iova_align(size + iova_off) bytes starting at phys - iova_off. If iommu_dma_map_page

[PATCH v8 6/7] swiotlb: support aligned swiotlb buffers

2021-09-28 Thread David Stevens
From: David Stevens Add an argument to swiotlb_tbl_map_single that specifies the desired alignment of the allocated buffer. This is used by dma-iommu to ensure the buffer is aligned to the iova granule size when using swiotlb with untrusted sub-granule mappings. This addresses an issue where

[PATCH v8 5/7] dma-iommu: Check CONFIG_SWIOTLB more broadly

2021-09-28 Thread David Stevens
From: David Stevens Introduce a new dev_use_swiotlb function to guard swiotlb code, instead of overloading dev_is_untrusted. This allows CONFIG_SWIOTLB to be checked more broadly, so the swiotlb related code can be removed more aggressively. Signed-off-by: David Stevens Reviewed-by: Robin

[PATCH v8 4/7] dma-iommu: fold _swiotlb helpers into callers

2021-09-28 Thread David Stevens
From: David Stevens Fold the _swiotlb helper functions into the respective _page functions, since recent fixes have moved all logic from the _page functions to the _swiotlb functions. Signed-off-by: David Stevens Reviewed-by: Christoph Hellwig Reviewed-by: Robin Murphy ---

[PATCH v8 3/7] dma-iommu: skip extra sync during unmap w/swiotlb

2021-09-28 Thread David Stevens
From: David Stevens Calling the iommu_dma_sync_*_for_cpu functions during unmap can cause two copies out of the swiotlb buffer. Do the arch sync directly in __iommu_dma_unmap_swiotlb instead to avoid this. This makes the call to iommu_dma_sync_sg_for_cpu for untrusted devices in

[PATCH v8 2/7] dma-iommu: fix arch_sync_dma for map

2021-09-28 Thread David Stevens
From: David Stevens When calling arch_sync_dma, we need to pass it the memory that's actually being used for dma. When using swiotlb bounce buffers, this is the bounce buffer. Move arch_sync_dma into the __iommu_dma_map_swiotlb helper, so it can use the bounce buffer address if necessary. Now

[PATCH v8 1/7] dma-iommu: fix sync_sg with swiotlb

2021-09-28 Thread David Stevens
From: David Stevens The is_swiotlb_buffer function takes the physical address of the swiotlb buffer, not the physical address of the original buffer. The sglist contains the physical addresses of the original buffer, so for the sync_sg functions to work properly when a bounce buffer might have

[PATCH v8 0/7] Fixes for dma-iommu swiotlb bounce buffers

2021-09-28 Thread David Stevens
From: David Stevens This patch set includes various fixes for dma-iommu's swiotlb bounce buffers for untrusted devices. The min_align_mask issue was found when running fio on an untrusted nvme device with bs=512. The other issues were found via code inspection, so I don't have any specific use

RE: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Tian, Kevin
> From: Lu Baolu > Sent: Wednesday, September 29, 2021 10:22 AM > > On 9/28/21 10:07 PM, Jason Gunthorpe wrote: > > On Tue, Sep 28, 2021 at 09:35:05PM +0800, Lu Baolu wrote: > >> Another issue is, when putting a device into user-dma mode, all devices > >> belonging to the same iommu group

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Lu Baolu
On 9/28/21 10:07 PM, Jason Gunthorpe wrote: On Tue, Sep 28, 2021 at 09:35:05PM +0800, Lu Baolu wrote: Another issue is, when putting a device into user-dma mode, all devices belonging to the same iommu group shouldn't be bound with a kernel-dma driver. Kevin's prototype checks this by

RE: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Luck, Tony
>> if (!(xsave->header.xfeatures & fmask)) { >> xsave->header.xfeatures |= fmask; //< >> xsaves(xsave, fmask); >> } > > I'm not sure why the FPU state is initialized here. > > For updating the PASID state, it's unnecessary to init the PASID state. > >

RE: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Luck, Tony
> But the helpers seem to be generic. They take "task" as a parameter and > handle the task as non-current case. So the helpers are not for PASID only. > They may be used by others to modify a running task's FPU state. But > It's not safe to do so. > > At least need some comments/restriction for

RE: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Yu, Fenghua
Hi, Tony, > void *begin_update_one_xsave_feature(struct task_struct *tsk, >enum xfeature xfeature, bool full) { > struct xregs_state *xsave = >thread.fpu.state.xsave; > struct xregs_state *xinit = _fpstate.xsave; > u64 fmask = 1ull <<

Re: [PATCH v2 9/9] iommu/vt-d: Use pci core's DVSEC functionality

2021-09-28 Thread Lu Baolu
Hi Dan, On 9/29/21 1:54 AM, Dan Williams wrote: On Thu, Sep 23, 2021 at 10:27 AM Ben Widawsky wrote: Reduce maintenance burden of DVSEC query implementation by using the centralized PCI core implementation. Cc: iommu@lists.linux-foundation.org Cc: David Woodhouse Cc: Lu Baolu

[PATCH v8 12/12] arm64: dts: mediatek: Get rid of mediatek, larb for MM nodes

2021-09-28 Thread Yong Wu
After adding device_link between the IOMMU consumer and smi, the mediatek,larb is unnecessary now. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green --- arch/arm64/boot/dts/mediatek/mt8173.dtsi | 16 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 6 -- 2

[PATCH v8 11/12] arm: dts: mediatek: Get rid of mediatek, larb for MM nodes

2021-09-28 Thread Yong Wu
After adding device_link between the IOMMU consumer and smi, the mediatek,larb is unnecessary now. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green Tested-by: Frank Wunderlich # BPI-R2/MT7623 --- arch/arm/boot/dts/mt2701.dtsi | 2 -- arch/arm/boot/dts/mt7623n.dtsi | 5

[PATCH v8 10/12] memory: mtk-smi: Get rid of mtk_smi_larb_get/put

2021-09-28 Thread Yong Wu
After adding device_link between the iommu consumer and smi-larb, the pm_runtime_get(_sync) of smi-larb and smi-common will be called automatically. we can get rid of mtk_smi_larb_get/put. CC: Matthias Brugger Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked-by: Krzysztof Kozlowski

[PATCH v8 09/12] media: mtk-vcodec: Get rid of mtk_smi_larb_get/put

2021-09-28 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the vcodec device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Tiffany Lin CC: Irui Wang Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked-by:

[PATCH v8 08/12] drm/mediatek: Get rid of mtk_smi_larb_get/put

2021-09-28 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the drm device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: CK Hu CC: Philipp Zabel Signed-off-by: Yong Wu Reviewed-by: Evan Green Acked-by:

[PATCH v8 07/12] drm/mediatek: Add pm runtime support for ovl and rdma

2021-09-28 Thread Yong Wu
From: Yongqiang Niu Prepare for smi cleaning up "mediatek,larb". Display use the dispsys device to call pm_rumtime_get_sync before. This patch add pm_runtime_xx with ovl and rdma device whose nodes has "iommus" property, then display could help pm_runtime_get for smi via ovl or rdma device.

[PATCH v8 06/12] media: mtk-mdp: Get rid of mtk_smi_larb_get/put

2021-09-28 Thread Yong Wu
MediaTek IOMMU has already added the device_link between the consumer and smi-larb device. If the mdp device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. CC: Minghsiu Tsai CC: Houlong Wei Signed-off-by: Yong Wu Reviewed-by: Evan Green

[PATCH v8 05/12] media: mtk-jpeg: Get rid of mtk_smi_larb_get/put

2021-09-28 Thread Yong Wu
MediaTek IOMMU has already added device_link between the consumer and smi-larb device. If the jpg device call the pm_runtime_get_sync, the smi-larb's pm_runtime_get_sync also be called automatically. After removing the larb_get operations, then mtk_jpeg_clk_init is also unnecessary. Remove it

[PATCH v8 04/12] iommu/mediatek: Add device_link between the consumer and the larb devices

2021-09-28 Thread Yong Wu
MediaTek IOMMU-SMI diagram is like below. all the consumer connect with smi-larb, then connect with smi-common. M4U | smi-common | - | |... | | larb1 larb2 | | vdec venc When the consumer works, it should

[PATCH v8 03/12] iommu/mediatek: Add probe_defer for smi-larb

2021-09-28 Thread Yong Wu
Prepare for adding device_link. The iommu consumer should use device_link to connect with the smi-larb(supplier). then the smi-larb should run before the iommu consumer. Here we delay the iommu driver until the smi driver is ready, then all the iommu consumers always are after the smi driver.

[PATCH v8 02/12] iommu/mediatek-v1: Free the existed fwspec if the master dev already has

2021-09-28 Thread Yong Wu
When the iommu master device enters of_iommu_xlate, the ops may be NULL(iommu dev is defered), then it will initialize the fwspec here: [] (dev_iommu_fwspec_set) from [] (iommu_fwspec_init+0xbc/0xd4) [] (iommu_fwspec_init) from [] (of_iommu_xlate+0x7c/0x12c) [] (of_iommu_xlate) from []

[PATCH v8 01/12] dt-binding: mediatek: Get rid of mediatek, larb for multimedia HW

2021-09-28 Thread Yong Wu
After adding device_link between the consumer with the smi-larbs, if the consumer call its owner pm_runtime_get(_sync), the pm_runtime_get(_sync) of smi-larb and smi-common will be called automatically. Thus, the consumer don't need the property. And IOMMU also know which larb this consumer

[PATCH v8 00/12] Clean up "mediatek,larb"

2021-09-28 Thread Yong Wu
MediaTek IOMMU block diagram always like below: M4U | smi-common | - | | ... | | larb1 larb2 | | vdec venc All the consumer connect with smi-larb, then connect with smi-common. When the consumer works, it

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Fenghua Yu
Hi, Tony, On Tue, Sep 28, 2021 at 06:06:52PM -0700, Luck, Tony wrote: > >>fpregs_lock(); > > > > I'm afraid we may hit the same locking issue when we send IPI to notify > > another task to modify its > > PASID state. Here the API is called to modify another running task's PASID > > state as

RE: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Luck, Tony
>> fpregs_lock(); > > I'm afraid we may hit the same locking issue when we send IPI to notify > another task to modify its > PASID state. Here the API is called to modify another running task's PASID > state as well without a right lock. > fpregs_lock() is not enough to deal with this, I'm

RE: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, September 28, 2021 10:07 PM > > On Tue, Sep 28, 2021 at 09:35:05PM +0800, Lu Baolu wrote: > > Another issue is, when putting a device into user-dma mode, all devices > > belonging to the same iommu group shouldn't be bound with a kernel-dma > > driver.

RE: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Yu, Fenghua
Hi, Tony, > void *begin_update_one_xsave_feature(struct task_struct *tsk, >enum xfeature xfeature, bool full) { > struct xregs_state *xsave = >thread.fpu.state.xsave; > struct xregs_state *xinit = _fpstate.xsave; > u64 fmask = 1ull <<

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Luck, Tony
On Tue, Sep 28, 2021 at 11:50:37PM +, Fenghua Yu wrote: > If xfeatures's feature bit is 0, xsaves will not write its init value to the > memory due to init optimization. So the xsaves will do nothing and the > state is not initialized and may have random data. > Setting TIF_NEED_FPU_LOAD

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Fenghua Yu
Hi, Tony, On Tue, Sep 28, 2021 at 04:10:39PM -0700, Luck, Tony wrote: > Moving beyond pseudo-code and into compiles-but-probably-broken-code. > > > The intent of the functions below is that Fenghua should be able to > do: > > void fpu__pasid_write(u32 pasid) > { > u64 msr_val = pasid |

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Luck, Tony
Moving beyond pseudo-code and into compiles-but-probably-broken-code. The intent of the functions below is that Fenghua should be able to do: void fpu__pasid_write(u32 pasid) { u64 msr_val = pasid | MSR_IA32_PASID_VALID; struct ia32_pasid_state *addr; addr =

[PATCH][next] iommu/dma: Use kvcalloc() instead of kvzalloc()

2021-09-28 Thread Gustavo A. R. Silva
Use 2-factor argument form kvcalloc() instead of kvzalloc(). Link: https://github.com/KSPP/linux/issues/162 Signed-off-by: Gustavo A. R. Silva --- drivers/iommu/dma-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c

Re: [PATCH v3 4/20] PCI/P2PDMA: introduce helpers for dma_map_sg implementations

2021-09-28 Thread Jason Gunthorpe via iommu
On Thu, Sep 16, 2021 at 05:40:44PM -0600, Logan Gunthorpe wrote: > +enum pci_p2pdma_map_type > +pci_p2pdma_map_segment(struct pci_p2pdma_map_state *state, struct device > *dev, > +struct scatterlist *sg) > +{ > + if (state->pgmap != sg_page(sg)->pgmap) { > +

Re: [PATCH v4 0/8] Implement generic cc_platform_has() helper function

2021-09-28 Thread Borislav Petkov
On Tue, Sep 28, 2021 at 02:01:57PM -0700, Kuppuswamy, Sathyanarayanan wrote: > Yes. But, since the check is related to TDX, I just want to confirm whether > you are fine with naming the function as intel_*(). Why is this such a big of a deal?! There's amd_cc_platform_has() and

Re: [PATCH v4 0/8] Implement generic cc_platform_has() helper function

2021-09-28 Thread Kuppuswamy, Sathyanarayanan
On 9/28/21 1:58 PM, Borislav Petkov wrote: On Tue, Sep 28, 2021 at 01:48:46PM -0700, Kuppuswamy, Sathyanarayanan wrote: Just read it. If you want to use cpuid_has_tdx_guest() directly in cc_platform_has(), then you want to rename intel_cc_platform_has() to tdx_cc_platform_has()? Why? You

Re: [PATCH v4 0/8] Implement generic cc_platform_has() helper function

2021-09-28 Thread Borislav Petkov
On Tue, Sep 28, 2021 at 01:48:46PM -0700, Kuppuswamy, Sathyanarayanan wrote: > Just read it. If you want to use cpuid_has_tdx_guest() directly in > cc_platform_has(), then you want to rename intel_cc_platform_has() to > tdx_cc_platform_has()? Why? You simply do: if

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Dave Hansen
On 9/28/21 1:28 PM, Luck, Tony wrote: > On Tue, Sep 28, 2021 at 12:19:22PM -0700, Dave Hansen wrote: >> On 9/28/21 11:50 AM, Luck, Tony wrote: >>> On Mon, Sep 27, 2021 at 04:51:25PM -0700, Dave Hansen wrote: >> ... 1. Hide whether we need to write to real registers 2. Hide whether we

Re: [PATCH v4 0/8] Implement generic cc_platform_has() helper function

2021-09-28 Thread Kuppuswamy, Sathyanarayanan
On 9/28/21 1:31 PM, Borislav Petkov wrote: On Tue, Sep 28, 2021 at 12:19:49PM -0700, Kuppuswamy, Sathyanarayanan wrote: Intel CC support patch is not included in this series. You want me to address the issue raised by Joerg before merging it? Did you not see my email to you today:

Re: [PATCH v4 0/8] Implement generic cc_platform_has() helper function

2021-09-28 Thread Borislav Petkov
On Tue, Sep 28, 2021 at 12:19:49PM -0700, Kuppuswamy, Sathyanarayanan wrote: > Intel CC support patch is not included in this series. You want me > to address the issue raised by Joerg before merging it? Did you not see my email to you today: https://lkml.kernel.org/r/yvl4zughfsh1q...@zn.tnic ?

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Luck, Tony
On Tue, Sep 28, 2021 at 12:19:22PM -0700, Dave Hansen wrote: > On 9/28/21 11:50 AM, Luck, Tony wrote: > > On Mon, Sep 27, 2021 at 04:51:25PM -0700, Dave Hansen wrote: > ... > >> 1. Hide whether we need to write to real registers > >> 2. Hide whether we need to update the in-memory image > >> 3.

Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p2pmem()

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:59PM -0600, Logan Gunthorpe wrote: > +static void pci_p2pdma_unmap_mappings(void *data) > +{ > + struct pci_dev *pdev = data; > + struct pci_p2pdma *p2pdma = rcu_dereference_protected(pdev->p2pdma, 1); > + > + p2pdma->active = false; > +

Re: [PATCH v3 00/20] Userspace P2PDMA with O_DIRECT NVMe devices

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:40PM -0600, Logan Gunthorpe wrote: > Hi, > > This patchset continues my work to add userspace P2PDMA access using > O_DIRECT NVMe devices. My last posting[1] just included the first 13 > patches in this series, but the early P2PDMA cleanup and map_sg error > changes

Re: [PATCH v3 19/20] PCI/P2PDMA: introduce pci_mmap_p2pmem()

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:59PM -0600, Logan Gunthorpe wrote: > +int pci_mmap_p2pmem(struct pci_dev *pdev, struct vm_area_struct *vma) > +{ > + struct pci_p2pdma_map *pmap; > + struct pci_p2pdma *p2pdma; > + int ret; > + > + /* prevent private mappings from being established */

Re: [PATCH v3 14/20] mm: introduce FOLL_PCI_P2PDMA to gate getting PCI P2PDMA pages

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:54PM -0600, Logan Gunthorpe wrote: > Callers that expect PCI P2PDMA pages can now set FOLL_PCI_P2PDMA to > allow obtaining P2PDMA pages. If a caller does not set this flag > and tries to map P2PDMA pages it will fail. > > This is implemented by adding a flag and a

Re: [PATCH v3 13/20] PCI/P2PDMA: remove pci_p2pdma_[un]map_sg()

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:53PM -0600, Logan Gunthorpe wrote: > This interface is superseded by support in dma_map_sg() which now supports > heterogeneous scatterlists. There are no longer any users, so remove it. > > Signed-off-by: Logan Gunthorpe > --- > drivers/pci/p2pdma.c | 65

Re: [PATCH v3 12/20] RDMA/rw: use dma_map_sgtable()

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:52PM -0600, Logan Gunthorpe wrote: > dma_map_sg() now supports the use of P2PDMA pages so pci_p2pdma_map_sg() > is no longer necessary and may be dropped. > > Switch to the dma_map_sgtable() interface which will allow for better > error reporting if the P2PDMA pages

Re: [PATCH v4 0/8] Implement generic cc_platform_has() helper function

2021-09-28 Thread Kuppuswamy, Sathyanarayanan
On 9/28/21 12:10 PM, Borislav Petkov wrote: From: Borislav Petkov Hi all, here's v4 of the cc_platform_has() patchset with feedback incorporated. I'm going to route this through tip if there are no objections. Intel CC support patch is not included in this series. You want me to address

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Dave Hansen
On 9/28/21 11:50 AM, Luck, Tony wrote: > On Mon, Sep 27, 2021 at 04:51:25PM -0700, Dave Hansen wrote: ... >> 1. Hide whether we need to write to real registers >> 2. Hide whether we need to update the in-memory image >> 3. Hide other FPU infrastructure like the TIF flag. >> 4. Make the users deal

Re: [PATCH v3 11/20] RDMA/core: introduce ib_dma_pci_p2p_dma_supported()

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:51PM -0600, Logan Gunthorpe wrote: > Introduce the helper function ib_dma_pci_p2p_dma_supported() to check > if a given ib_device can be used in P2PDMA transfers. This ensures > the ib_device is not using virt_dma and also that the underlying > dma_device supports

Re: [PATCH v3 08/20] iommu/dma: support PCI P2PDMA pages in dma-iommu map_sg

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:48PM -0600, Logan Gunthorpe wrote: > When a PCI P2PDMA page is seen, set the IOVA length of the segment > to zero so that it is not mapped into the IOVA. Then, in finalise_sg(), > apply the appropriate bus address to the segment. The IOVA is not > created if the

Re: [PATCH v3 07/20] dma-mapping: add flags to dma_map_ops to indicate PCI P2PDMA support

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:47PM -0600, Logan Gunthorpe wrote: > Add a flags member to the dma_map_ops structure with one flag to > indicate support for PCI P2PDMA. > > Also, add a helper to check if a device supports PCI P2PDMA. > > Signed-off-by: Logan Gunthorpe > --- >

[PATCH 8/8] treewide: Replace the use of mem_encrypt_active() with cc_platform_has()

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky Replace uses of mem_encrypt_active() with calls to cc_platform_has() with the CC_ATTR_MEM_ENCRYPT attribute. Remove the implementation of mem_encrypt_active() across all arches. For s390, since the default implementation of the cc_platform_has() matches the s390

[PATCH 7/8] x86/sev: Replace occurrences of sev_es_active() with cc_platform_has()

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky Replace uses of sev_es_active() with the more generic cc_platform_has() using CC_ATTR_GUEST_STATE_ENCRYPT. If future support is added for other memory encyrption techonologies, the use of CC_ATTR_GUEST_STATE_ENCRYPT can be updated, as required. Signed-off-by: Tom Lendacky

[PATCH 1/8] x86/ioremap: Selectively build arch override encryption functions

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky In preparation for other uses of the cc_platform_has() function besides AMD's memory encryption support, selectively build the AMD memory encryption architecture override functions only when CONFIG_AMD_MEM_ENCRYPT=y. These functions are: - early_memremap_pgprot_adjust() -

[PATCH 5/8] x86/sme: Replace occurrences of sme_active() with cc_platform_has()

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky Replace uses of sme_active() with the more generic cc_platform_has() using CC_ATTR_HOST_MEM_ENCRYPT. If future support is added for other memory encryption technologies, the use of CC_ATTR_HOST_MEM_ENCRYPT can be updated, as required. This also replaces two usages of

[PATCH 4/8] powerpc/pseries/svm: Add a powerpc version of cc_platform_has()

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky Introduce a powerpc version of the cc_platform_has() function. This will be used to replace the powerpc mem_encrypt_active() implementation, so the implementation will initially only support the CC_ATTR_MEM_ENCRYPT attribute. Signed-off-by: Tom Lendacky Signed-off-by:

[PATCH 6/8] x86/sev: Replace occurrences of sev_active() with cc_platform_has()

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky Replace uses of sev_active() with the more generic cc_platform_has() using CC_ATTR_GUEST_MEM_ENCRYPT. If future support is added for other memory encryption technologies, the use of CC_ATTR_GUEST_MEM_ENCRYPT can be updated, as required. Signed-off-by: Tom Lendacky

[PATCH 3/8] x86/sev: Add an x86 version of cc_platform_has()

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky Introduce an x86 version of the cc_platform_has() function. This will be used to replace vendor specific calls like sme_active(), sev_active(), etc. Signed-off-by: Tom Lendacky Signed-off-by: Borislav Petkov --- arch/x86/Kconfig | 1 +

[PATCH 2/8] arch/cc: Introduce a function to check for confidential computing features

2021-09-28 Thread Borislav Petkov
From: Tom Lendacky In preparation for other confidential computing technologies, introduce a generic helper function, cc_platform_has(), that can be used to check for specific active confidential computing attributes, like memory encryption. This is intended to eliminate having to add multiple

[PATCH v4 0/8] Implement generic cc_platform_has() helper function

2021-09-28 Thread Borislav Petkov
From: Borislav Petkov Hi all, here's v4 of the cc_platform_has() patchset with feedback incorporated. I'm going to route this through tip if there are no objections. Thx. Tom Lendacky (8): x86/ioremap: Selectively build arch override encryption functions arch/cc: Introduce a function to

Re: [PATCH v3 06/20] dma-direct: support PCI P2PDMA pages in dma-direct map_sg

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:46PM -0600, Logan Gunthorpe wrote: > Add PCI P2PDMA support for dma_direct_map_sg() so that it can map > PCI P2PDMA pages directly without a hack in the callers. This allows > for heterogeneous SGLs that contain both P2PDMA and regular pages. > > A P2PDMA page may

Re: [PATCH v3 05/20] dma-mapping: allow EREMOTEIO return code for P2PDMA transfers

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:45PM -0600, Logan Gunthorpe wrote: > Add EREMOTEIO error return to dma_map_sgtable() which will be used > by .map_sg() implementations that detect P2PDMA pages that the > underlying DMA device cannot access. > > Signed-off-by: Logan Gunthorpe > --- >

Re: [PATCH v3 04/20] PCI/P2PDMA: introduce helpers for dma_map_sg implementations

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:44PM -0600, Logan Gunthorpe wrote: > Add pci_p2pdma_map_segment() as a helper for simple dma_map_sg() > implementations. It takes an scatterlist segment that must point to a > pci_p2pdma struct page and will map it if the mapping requires a bus > address. > > The

Re: [PATCH 4/8] x86/traps: Demand-populate PASID MSR via #GP

2021-09-28 Thread Luck, Tony
On Mon, Sep 27, 2021 at 04:51:25PM -0700, Dave Hansen wrote: > That's close to what we want. > > The size should probably be implicit. If it isn't implicit, it needs to > at least be double-checked against the state sizes. > > Not to get too fancy, but I think we also want to have a "replace" >

Re: [PATCH v3 03/20] PCI/P2PDMA: make pci_p2pdma_map_type() non-static

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:43PM -0600, Logan Gunthorpe wrote: > +enum pci_p2pdma_map_type { > + /* > + * PCI_P2PDMA_MAP_UNKNOWN: Used internally for indicating the mapping > + * type hasn't been calculated yet. Functions that return this enum > + * never return this value. >

Re: [PATCH v3 01/20] lib/scatterlist: add flag for indicating P2PDMA segments in an SGL

2021-09-28 Thread Jason Gunthorpe
On Thu, Sep 16, 2021 at 05:40:41PM -0600, Logan Gunthorpe wrote: > Make use of the third free LSB in scatterlist's page_link on 64bit systems. > > The extra bit will be used by dma_[un]map_sg_p2pdma() to determine when a > given SGL segments dma_address points to a PCI bus address. >

Re: [PATCH v2 9/9] iommu/vt-d: Use pci core's DVSEC functionality

2021-09-28 Thread Dan Williams
On Thu, Sep 23, 2021 at 10:27 AM Ben Widawsky wrote: > > Reduce maintenance burden of DVSEC query implementation by using the > centralized PCI core implementation. > > Cc: iommu@lists.linux-foundation.org > Cc: David Woodhouse > Cc: Lu Baolu > Signed-off-by: Ben Widawsky > --- >

Re: [PATCH v2 7/9] cxl/pci: Use pci core's DVSEC functionality

2021-09-28 Thread Dan Williams
On Thu, Sep 23, 2021 at 10:27 AM Ben Widawsky wrote: > > Reduce maintenance burden of DVSEC query implementation by using the > centralized PCI core implementation. > > Signed-off-by: Ben Widawsky > --- > drivers/cxl/pci.c | 20 +--- > 1 file changed, 1 insertion(+), 19

Re: [PATCH v2 5/9] cxl/pci: Make more use of cxl_register_map

2021-09-28 Thread Dan Williams
On Thu, Sep 23, 2021 at 10:27 AM Ben Widawsky wrote: > > The structure exists to pass around information about register mapping. > Using it more extensively cleans up many existing functions. I would have liked to have seen "add @base to cxl_register_map" and "use @map for @bar and @offset

Re: [PATCH v2 4/9] cxl/pci: Refactor cxl_pci_setup_regs

2021-09-28 Thread Dan Williams
On Thu, Sep 23, 2021 at 10:27 AM Ben Widawsky wrote: > > In preparation for moving parts of register mapping to cxl_core, the > cxl_pci driver is refactored to utilize a new helper to find register > blocks by type. > > cxl_pci scanned through all register blocks and mapping the ones that > the

Re: [PATCH 5/8] x86/mmu: Add mm-based PASID refcounting

2021-09-28 Thread Fenghua Yu
Hi, Thomas, On Sun, Sep 26, 2021 at 01:13:50AM +0200, Thomas Gleixner wrote: > Fenghua, > > On Fri, Sep 24 2021 at 16:12, Fenghua Yu wrote: > > On Fri, Sep 24, 2021 at 03:18:12PM +0200, Thomas Gleixner wrote: > >> But OTOH why do you need a per task reference count on the PASID at all? > >> >

Re: [PATCH v2 3/9] cxl/pci: Remove pci request/release regions

2021-09-28 Thread Dan Williams
On Thu, Sep 23, 2021 at 10:26 AM Ben Widawsky wrote: > > Quoting Dan, "... the request + release regions should probably just be > dropped. It's not like any of the register enumeration would collide > with someone else who already has the registers mapped. The collision > only comes when the

Re: [PATCH v2 2/9] cxl/pci: Remove dev_dbg for unknown register blocks

2021-09-28 Thread Dan Williams
On Thu, Sep 23, 2021 at 10:27 AM Ben Widawsky wrote: > > While interesting to driver developers, the dev_dbg message doesn't do > much except clutter up logs. This information should be attainable > through sysfs, and someday lspci like utilities. This change > additionally helps reduce the LOC

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Jason Gunthorpe via iommu
On Tue, Sep 28, 2021 at 09:35:05PM +0800, Lu Baolu wrote: > Another issue is, when putting a device into user-dma mode, all devices > belonging to the same iommu group shouldn't be bound with a kernel-dma > driver. Kevin's prototype checks this by READ_ONCE(dev->driver). This is > not lock safe as

Re: [PATCH 2/2] [v2] qcom_scm: hide Kconfig symbol

2021-09-28 Thread Alex Elder via iommu
On 9/28/21 2:50 AM, Arnd Bergmann wrote: From: Arnd Bergmann Now that SCM can be a loadable module, we have to add another dependency to avoid link failures when ipa or adreno-gpu are built-in: aarch64-linux-ld: drivers/net/ipa/ipa_main.o: in function `ipa_probe': ipa_main.c:(.text+0xfc4):

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Lu Baolu
Hi Jason, On 2021/9/28 19:57, Jason Gunthorpe wrote: On Tue, Sep 28, 2021 at 07:30:41AM +, Tian, Kevin wrote: Also, don't call it "hint", there is nothing hinty about this, it has definitive functional impacts. possibly dma_mode (too broad?) or dma_usage You just need a flag to

Re: [RFC 06/20] iommu: Add iommu_device_init[exit]_user_dma interfaces

2021-09-28 Thread Jason Gunthorpe via iommu
On Tue, Sep 28, 2021 at 07:30:41AM +, Tian, Kevin wrote: > > Also, don't call it "hint", there is nothing hinty about this, it has > > definitive functional impacts. > > possibly dma_mode (too broad?) or dma_usage You just need a flag to specify if the driver manages DMA ownership itself,

[PATCH v5] iommu/amd: Use report_iommu_fault()

2021-09-28 Thread Lennert Buytenhek
This patch makes iommu/amd call report_iommu_fault() when an I/O page fault occurs, which has two effects: 1) It allows device drivers to register a callback to be notified of I/O page faults, via the iommu_set_fault_handler() API. 2) It triggers the io_page_fault tracepoint in

Re: [PATCH] iommu/dma: Tidy up Kconfig selects

2021-09-28 Thread Marek Szyprowski
On 28.09.2021 11:30, Joerg Roedel wrote: > On Mon, Sep 13, 2021 at 01:41:19PM +0100, Robin Murphy wrote: >> Now that the dust has settled on converting all the x86 drivers to >> iommu-dma, we can punt the Kconfig selection to arch code where it >> was always intended to be. > Can we select

Re: [PATCH] iommu/mediatek: fix out-of-range warning with clang

2021-09-28 Thread Joerg Roedel
On Mon, Sep 27, 2021 at 02:18:44PM +0200, Arnd Bergmann wrote: > drivers/iommu/mtk_iommu.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) Applied, thanks. ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH v4] iommu/amd: Use report_iommu_fault()

2021-09-28 Thread Joerg Roedel
On Sat, Sep 25, 2021 at 05:18:02PM +0300, Lennert Buytenhek wrote: > +#define IS_IOMMU_MEM_TRANSACTION(flags) \ > + (((flags) & EVENT_FLAG_I) == 0) > + > +#define IS_WRITE_REQUEST(flags) \ > + ((flags) & EVENT_FLAG_RW) > + > static void

Re: [PATCH] iommu/dart: Clear sid2group entry when a group is freed

2021-09-28 Thread Joerg Roedel
On Fri, Sep 24, 2021 at 03:45:02PM +0200, Sven Peter wrote: > drivers/iommu/apple-dart.c | 38 +++--- > 1 file changed, 35 insertions(+), 3 deletions(-) Applied for v5.15, thanks. ___ iommu mailing list

Re: [PATCH] iommu/ipmmu-vmsa: Hook up r8a77980 DT matching code

2021-09-28 Thread Joerg Roedel
On Thu, Sep 23, 2021 at 10:11:16PM +0300, Nikita Yushchenko wrote: > drivers/iommu/ipmmu-vmsa.c | 3 +++ > 1 file changed, 3 insertions(+) Applied, thanks. ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH 0/1] iommu/vt-d: A fix for v5.15-rc3

2021-09-28 Thread Joerg Roedel
On Wed, Sep 22, 2021 at 01:47:25PM +0800, Lu Baolu wrote: > Bjorn Helgaas (1): > iommu/vt-d: Drop "0x" prefix from PCI bus & device addresses Applied, thanks. ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH] iommu/dart: Remove iommu_flush_ops

2021-09-28 Thread Joerg Roedel
On Tue, Sep 21, 2021 at 05:39:34PM +0200, Sven Peter wrote: > Fixes: 46d1fb072e76b161 ("iommu/dart: Add DART iommu driver") > Reported-by: Marc Zyngier > Signed-off-by: Sven Peter > --- > drivers/iommu/apple-dart.c | 18 -- > 1 file changed, 18 deletions(-) Applied for v5.15,

Re: [PATCH] iommu/dma: Tidy up Kconfig selects

2021-09-28 Thread Joerg Roedel
On Mon, Sep 13, 2021 at 01:41:19PM +0100, Robin Murphy wrote: > Now that the dust has settled on converting all the x86 drivers to > iommu-dma, we can punt the Kconfig selection to arch code where it > was always intended to be. Can we select IOMMU_DMA under IOMMU_SUPPORT instead? The only

Re: [PATCH V5 12/12] net: netvsc: Add Isolation VM support for netvsc driver

2021-09-28 Thread Tianyu Lan
On 9/28/2021 1:39 PM, Christoph Hellwig wrote: On Mon, Sep 27, 2021 at 10:26:43PM +0800, Tianyu Lan wrote: Hi Christoph: Gentile ping. The swiotlb and shared memory mapping changes in this patchset needs your reivew. Could you have a look? > I'm a little too busy for a review of such a

Re: [PATCH 0/2] iommu: DMA domain epilogue

2021-09-28 Thread Joerg Roedel
Hi Robin, On Mon, Sep 13, 2021 at 01:40:04PM +0100, Robin Murphy wrote: > Robin Murphy (2): > iommu/dart: Clean up IOVA cookie crumbs > iommu/dma: Unexport IOVA cookie management Thanks, all applied now. ___ iommu mailing list

  1   2   >