Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Jacob Pan
Hi Barry, On Thu, 7 Oct 2021 18:43:33 +1300, Barry Song <21cn...@gmail.com> wrote: > > > Security-wise, KVA respects kernel mapping. So permissions are better > > > enforced than pass-through and identity mapping. > > > > Is this meaningful? Isn't the entire physical map still in the KVA and >

Re: [PATCH v6 6/6] iommu/tegra-smmu: Add pagetable mappings to debugfs

2021-10-07 Thread Nicolin Chen
On Thu, Oct 07, 2021 at 07:13:25PM +0200, Thierry Reding wrote: > > @@ -496,6 +506,8 @@ static void tegra_smmu_as_unprepare(struct tegra_smmu > > *smmu, > > mutex_unlock(>lock); > > } > > > > +static const struct file_operations tegra_smmu_debugfs_mappings_fops; > > Could the

Re: [PATCH v6 2/6] iommu/tegra-smmu: Rename struct tegra_smmu_group_soc *soc to *group_soc

2021-10-07 Thread Nicolin Chen
On Thu, Oct 07, 2021 at 06:50:52PM +0200, Thierry Reding wrote: > > static const struct tegra_smmu_group_soc * > > -tegra_smmu_find_group(struct tegra_smmu *smmu, unsigned int swgroup) > > +tegra_smmu_find_group_soc(struct tegra_smmu *smmu, unsigned int swgroup) > > This one might be okay to

Re: [PATCH v6 3/6] iommu/tegra-smmu: Rename struct tegra_smmu_swgroup *group to *swgrp

2021-10-07 Thread Nicolin Chen
On Thu, Oct 07, 2021 at 06:57:31PM +0200, Thierry Reding wrote: > On Mon, Sep 13, 2021 at 06:38:55PM -0700, Nicolin Chen wrote: > > There are both tegra_smmu_swgroup and tegra_smmu_group structs > > using "group" for their pointer instances. This gets confusing > > to read the driver sometimes. >

Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Jason Gunthorpe via iommu
On Thu, Oct 07, 2021 at 12:11:27PM -0700, Jacob Pan wrote: > Hi Barry, > > On Thu, 7 Oct 2021 18:43:33 +1300, Barry Song <21cn...@gmail.com> wrote: > > > > > Security-wise, KVA respects kernel mapping. So permissions are better > > > > enforced than pass-through and identity mapping. > > > > >

[PATCH v3 2/2] iommu/vt-d: avoid duplicated removing in __domain_mapping

2021-10-07 Thread Longpeng(Mike)
__domain_mapping() always removes the pages in the range from 'iov_pfn' to 'end_pfn', but the 'end_pfn' is always the last pfn of the range that the caller wants to map. This would introduce too many duplicated removing and leads the map operation take too long, for example: Map

[PATCH v3 1/2] iommu/vt-d: convert the return type of first_pte_in_page to bool

2021-10-07 Thread Longpeng(Mike)
first_pte_in_page() returns boolean value, so let's convert its return type to bool. In addition, use 'IS_ALIGNED' to make the code more readable and neater. Signed-off-by: Longpeng(Mike) --- include/linux/intel-iommu.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git

[PATCH v3 0/2] iommu/vt-d: boost the mapping process

2021-10-07 Thread Longpeng(Mike)
Hi guys, We found that the __domain_mapping() would take too long when the memory region is too large, we try to make it faster in this patchset. The performance number can be found in PATCH 2, please review when you free, thanks. Changes v2 -> v3: - make first_pte_in_page() neater [Baolu] -

Re: [PATCH v3 2/2] iommu/vt-d: avoid duplicated removing in __domain_mapping

2021-10-07 Thread Lu Baolu
On 10/8/21 8:04 AM, Longpeng(Mike) wrote: __domain_mapping() always removes the pages in the range from 'iov_pfn' to 'end_pfn', but the 'end_pfn' is always the last pfn of the range that the caller wants to map. This would introduce too many duplicated removing and leads the map operation take

Re: [PATCH v1 1/2] iommu/vt-d: Move intel_iommu_ops to header file

2021-10-07 Thread Lu Baolu
Hi Andy, On 10/7/21 12:14 AM, Andy Shevchenko wrote: On Fri, Jul 30, 2021 at 10:20:08AM +0800, Lu Baolu wrote: Hi Andy, On 7/30/21 12:35 AM, Andy Shevchenko wrote: Compiler is not happy about hidden declaration of intel_iommu_ops. .../drivers/iommu/intel/iommu.c:414:24: warning: symbol

Re: [PATCH v3 2/2] iommu/vt-d: avoid duplicated removing in __domain_mapping

2021-10-07 Thread Lu Baolu
On 10/8/21 10:07 AM, Lu Baolu wrote: On 10/8/21 8:04 AM, Longpeng(Mike) wrote: __domain_mapping() always removes the pages in the range from 'iov_pfn' to 'end_pfn', but the 'end_pfn' is always the last pfn of the range that the caller wants to map. This would introduce too many duplicated

Re: [PATCH] iommu: intel: remove flooding of non-error logs, when new-DMA-PTE is the same as old-DMA-PTE.

2021-10-07 Thread Ajay Garg
Thanks Alex for the reply. Lu, Alex : I got my diagnosis regarding the host-driver wrong, my apologies. There is no issue with the pci-device's host-driver (confirmed by preventing the loading of host-driver at host-bootup). Thus, nothing to be fixed at the host-driver side. Rather seems some

Re: [PATCH v2 1/2] iommu/vt-d: convert the return type of first_pte_in_page to bool

2021-10-07 Thread Lu Baolu
On 2021/10/5 23:23, Longpeng(Mike) wrote: first_pte_in_page() returns boolean value, so let's convert its return type to bool. Signed-off-by: Longpeng(Mike) --- include/linux/intel-iommu.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/intel-iommu.h

Re: DPAA2 triggers, [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-10-07 Thread Karsten Graul
On 06/10/2021 16:23, Robin Murphy wrote: > On 2021-10-06 14:10, Gerald Schaefer wrote: >> On Fri, 1 Oct 2021 14:52:56 +0200 >> Gerald Schaefer wrote: >> >>> On Thu, 30 Sep 2021 15:37:33 +0200 >>> Karsten Graul wrote: >>> On 14/09/2021 17:45, Ioana Ciornei wrote: > On Wed, Sep 08, 2021

Re: [RFC 07/20] iommu/iommufd: Add iommufd_[un]bind_device()

2021-10-07 Thread Jason Gunthorpe via iommu
On Thu, Oct 07, 2021 at 12:23:13PM +1100, David Gibson wrote: > On Fri, Oct 01, 2021 at 09:43:22AM -0300, Jason Gunthorpe wrote: > > On Thu, Sep 30, 2021 at 01:10:29PM +1000, David Gibson wrote: > > > On Wed, Sep 29, 2021 at 09:24:57AM -0300, Jason Gunthorpe wrote: > > > > On Wed, Sep 29, 2021 at

Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Barry Song
On Fri, Oct 8, 2021 at 12:32 AM Jason Gunthorpe wrote: > > On Thu, Oct 07, 2021 at 06:43:33PM +1300, Barry Song wrote: > > > So do we have a case where devices can directly access the kernel's data > > structure such as a list/graph/tree with pointers to a kernel virtual > > address? > > then

Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Jason Gunthorpe via iommu
On Fri, Oct 08, 2021 at 12:54:52AM +1300, Barry Song wrote: > On Fri, Oct 8, 2021 at 12:32 AM Jason Gunthorpe wrote: > > > > On Thu, Oct 07, 2021 at 06:43:33PM +1300, Barry Song wrote: > > > > > So do we have a case where devices can directly access the kernel's data > > > structure such as a

Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Jason Gunthorpe via iommu
On Thu, Oct 07, 2021 at 06:43:33PM +1300, Barry Song wrote: > So do we have a case where devices can directly access the kernel's data > structure such as a list/graph/tree with pointers to a kernel virtual address? > then devices don't need to translate the address of pointers in a structure. >

RE: [PATCH v2 1/2] iommu/vt-d: convert the return type of first_pte_in_page to bool

2021-10-07 Thread Longpeng (Mike, Cloud Infrastructure Service Product Dept.)
> -Original Message- > From: Lu Baolu [mailto:baolu...@linux.intel.com] > Sent: Thursday, October 7, 2021 2:18 PM > To: Longpeng (Mike, Cloud Infrastructure Service Product Dept.) > ; dw...@infradead.org; w...@kernel.org; > j...@8bytes.org > Cc: baolu...@linux.intel.com;

[PATCH v2 1/2] firmware: include drivers/firmware/Kconfig unconditionally

2021-10-07 Thread Arnd Bergmann
From: Arnd Bergmann Compile-testing drivers that require access to a firmware layer fails when that firmware symbol is unavailable. This happened twice this week: - My proposed to change to rework the QCOM_SCM firmware symbol broke on ppc64 and others. - The cs_dsp firmware patch added

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

2021-10-07 Thread Arnd Bergmann
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): undefined reference to

Re: DPAA2 triggers, [PATCH] dma debug: report -EEXIST errors in add_dma_entry

2021-10-07 Thread Gerald Schaefer
On Thu, 7 Oct 2021 12:59:32 +0200 Karsten Graul wrote: [...] > > > >>> BTW, there is already a WARN in the add_dma_entry() path, related > >>> to cachlline overlap and -EEXIST: > >>> > >>> add_dma_entry() -> active_cacheline_insert() -> -EEXIST -> > >>> active_cacheline_inc_overlap() > >>> >

Re: [PATCH v6 3/6] iommu/tegra-smmu: Rename struct tegra_smmu_swgroup *group to *swgrp

2021-10-07 Thread Thierry Reding
On Mon, Sep 13, 2021 at 06:38:55PM -0700, Nicolin Chen wrote: > There are both tegra_smmu_swgroup and tegra_smmu_group structs > using "group" for their pointer instances. This gets confusing > to read the driver sometimes. > > So this patch renames "group" of struct tegra_smmu_swgroup to >

Re: [PATCH v6 5/6] iommu/tegra-smmu: Attach as pointer to tegra_smmu_group

2021-10-07 Thread Thierry Reding
On Mon, Sep 13, 2021 at 06:38:57PM -0700, Nicolin Chen wrote: > This could ease driver to access corresponding as pointer > when having tegra_smmu_group pointer only, which can help > new mappings debugfs nodes. > > Also moving tegra_smmu_find_group_soc() upward, for using > it in new

Re: [PATCH v6 6/6] iommu/tegra-smmu: Add pagetable mappings to debugfs

2021-10-07 Thread Thierry Reding
On Mon, Sep 13, 2021 at 06:38:58PM -0700, Nicolin Chen wrote: > This patch dumps all active mapping entries from pagetable > to a debugfs directory named "mappings". > > Attaching an example: > > SWGROUP: hc > as->id: 0 > as->attr: R|W|N > as->pd_dma: 0x80c03000 > { > [index:

Re: [PATCH v6 1/6] iommu/tegra-smmu: Rename struct iommu_group *group to *grp

2021-10-07 Thread Thierry Reding
On Mon, Sep 13, 2021 at 06:38:53PM -0700, Nicolin Chen wrote: > There are a few structs using "group" for their pointer instances. > This gets confusing sometimes. The instance of struct iommu_group > is used in local function with an alias "grp", which can separate > it from others. > > So this

Re: [PATCH v6 2/6] iommu/tegra-smmu: Rename struct tegra_smmu_group_soc *soc to *group_soc

2021-10-07 Thread Thierry Reding
On Mon, Sep 13, 2021 at 06:38:54PM -0700, Nicolin Chen wrote: > There are both tegra_smmu_soc and tegra_smmu_group_soc using "soc" > for their pointer instances. This patch renames the one of struct > tegra_smmu_group_soc from "soc" to "group_soc" to distinguish it. > > Signed-off-by: Nicolin

Re: [PATCH v6 4/6] iommu/tegra-smmu: Use swgrp pointer instead of swgroup id

2021-10-07 Thread Thierry Reding
On Mon, Sep 13, 2021 at 06:38:56PM -0700, Nicolin Chen wrote: > This patch changes in struct tegra_smmu_group to use swgrp > pointer instead of swgroup, as a preparational change for > the "mappings" debugfs feature. > > Signed-off-by: Nicolin Chen > --- > drivers/iommu/tegra-smmu.c | 12

Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Jacob Pan
Hi Jason, On Thu, 7 Oct 2021 08:59:18 -0300, Jason Gunthorpe wrote: > On Fri, Oct 08, 2021 at 12:54:52AM +1300, Barry Song wrote: > > On Fri, Oct 8, 2021 at 12:32 AM Jason Gunthorpe wrote: > > > > > > > > On Thu, Oct 07, 2021 at 06:43:33PM +1300, Barry Song wrote: > > > > > > > So do we

Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Jason Gunthorpe via iommu
On Thu, Oct 07, 2021 at 10:50:10AM -0700, Jacob Pan wrote: > On platforms that are DMA snooped, this barrier is not needed. But I think > your point is that once we convert to DMA API, the sync/barrier is covered > by DMA APIs if !dev_is_dma_coherent(dev). Then all archs are good. No.. my point

Re: [PATCH] iommu/tegra-smmu: Use devm_bitmap_zalloc when applicable

2021-10-07 Thread Thierry Reding
On Sun, Sep 26, 2021 at 03:07:18PM +0200, Christophe JAILLET wrote: > 'smmu->asids' is a bitmap. So use 'devm_kzalloc()' to simplify code, > improve the semantic of the code and avoid some open-coded arithmetic in > allocator arguments. > > Signed-off-by: Christophe JAILLET > --- >

Re: [RFC 0/7] Support in-kernel DMA with PASID and SVA

2021-10-07 Thread Jacob Pan
Hi Jason, On Thu, 7 Oct 2021 14:48:22 -0300, Jason Gunthorpe wrote: > On Thu, Oct 07, 2021 at 10:50:10AM -0700, Jacob Pan wrote: > > > On platforms that are DMA snooped, this barrier is not needed. But I > > think your point is that once we convert to DMA API, the sync/barrier > > is covered

Re: [RFC] iommu: Use put_pages_list

2021-10-07 Thread Matthew Wilcox
ping? On Thu, Sep 30, 2021 at 05:20:42PM +0100, Matthew Wilcox (Oracle) wrote: > page->freelist is for the use of slab. We already have the ability > to free a list of pages in the core mm, but it requires the use of a > list_head and for the pages to be chained together through page->lru. >