Re: [PATCH 2/2] virtio_ring: Use DMA API if memory is encrypted

2019-10-16 Thread Jason Wang
On 2019/10/15 下午3:35, Christoph Hellwig wrote: On Fri, Oct 11, 2019 at 06:25:19PM -0700, Ram Pai wrote: From: Thiago Jung Bauermann Normally, virtio enables DMA API with VIRTIO_F_IOMMU_PLATFORM, which must be set by both device and guest driver. However, as a hack, when DMA API returns

[PATCH] drivers: iommu: hyperv: Make HYPERV_IOMMU only available on x86

2019-10-16 Thread Boqun Feng
Currently hyperv-iommu is implemented in a x86 specific way, for example, apic is used. So make the HYPERV_IOMMU Kconfig depend on X86 as a preparation for enabling HyperV on architecture other than x86. Cc: Lan Tianyu Cc: Michael Kelley Cc: linux-hyp...@vger.kernel.org Signed-off-by: Boqun

Re: [PATCH -next] iommu/amd: fix a warning in increase_address_space

2019-10-16 Thread Jerry Snitselaar
On Wed Oct 16 19, Jerry Snitselaar wrote: On Wed Oct 16 19, Qian Cai wrote: BTW, Joerg, this line from the commit "iommu/amd: Remove domain->updated" looks suspicious. Not sure what the purpose of it. *updated = increase_address_space(domain, gfp) || *updated; Looking at it again I think

Re: [PATCH -next] iommu/amd: fix a warning in increase_address_space

2019-10-16 Thread Jerry Snitselaar
On Wed Oct 16 19, Qian Cai wrote: After the commit 754265bcab78 ("iommu/amd: Fix race in increase_address_space()"), it could still possible trigger a race condition under some heavy memory pressure below. The race to trigger a warning is, CPU0: CPU1: in alloc_pte():

[PATCH -next] iommu/amd: fix a warning in increase_address_space

2019-10-16 Thread Qian Cai
After the commit 754265bcab78 ("iommu/amd: Fix race in increase_address_space()"), it could still possible trigger a race condition under some heavy memory pressure below. The race to trigger a warning is, CPU0: CPU1: in alloc_pte(): in increase_address_space():

[bug report] iommu/amd: Pass gfp-flags to iommu_map_page()

2019-10-16 Thread Dan Carpenter
Hello Joerg Roedel, The patch b911b89b6d01: "iommu/amd: Pass gfp-flags to iommu_map_page()" from Jul 5, 2016, leads to the following static checker warning: drivers/iommu/amd_iommu.c:2545 amd_iommu_map() warn: use 'gfp' here instead of GFP_XXX? drivers/iommu/amd_iommu.c 2529

[linux-next:master 4470/4908] drivers/iommu/iommu.c:1857:5: sparse: sparse: symbol '__iommu_map' was not declared. Should it be static?

2019-10-16 Thread kbuild test robot
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 78662bffde37ccbb66ac3311fa709d8960435e98 commit: 781ca2de89bae1b1d2c96df9ef33e9a324415995 [4470/4908] iommu: Add gfp parameter to iommu_ops::map reproduce: # apt-get install sparse # sparse

[RFC PATCH linux-next] iommu: Add gfp parameter to iommu_ops:: __iommu_map() can be static

2019-10-16 Thread kbuild test robot
Fixes: 781ca2de89ba ("iommu: Add gfp parameter to iommu_ops::map") Signed-off-by: kbuild test robot --- iommu.c |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index f8853dbf1c4eb..89bfdbbfaa11b 100644 ---

Re: [PATCH] iommu/vt-d: Check VT-d RMRR region in BIOS is reported as reserved

2019-10-16 Thread Chen, Yian
On 10/16/2019 12:51 AM, Joerg Roedel wrote: Hi, On Tue, Oct 15, 2019 at 09:49:32AM -0700, Yian Chen wrote: VT-d RMRR (Reserved Memory Region Reporting) regions are reserved for device use only and should not be part of allocable memory pool of OS. BIOS e820_table reports complete memory

Re: [PATCH 1/2] iommu/dmar: collect fault statistics

2019-10-16 Thread Bjorn Helgaas
Hi Yuri, On Tue, Oct 15, 2019 at 05:11:11PM +0200, Yuri Volchkov wrote: > Currently dmar_fault handler only prints a message in the dmesg. This > commit introduces counters - how many faults have happened, and > exposes them via sysfs. Each pci device will have an entry > 'dmar_faults' reading

[PATCH] iommu/dma: Relax locking in iommu_dma_prepare_msi()

2019-10-16 Thread Robin Murphy
Since commit ece6e6f0218b ("iommu/dma-iommu: Split iommu_dma_map_msi_msg() in two parts"), iommu_dma_prepare_msi() should no longer have to worry about preempting itself, nor being called in atomic context at all. Thus we can downgrade the IRQ-safe locking to a simple mutex to avoid angering the

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Julien Grall
Hi Robin, On 16/10/2019 17:09, Robin Murphy wrote: On 16/10/2019 17:03, Joerg Roedel wrote: On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote: On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote: The x86 one might just be a mistake. diff --git a/drivers/iommu/amd_iommu.c

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Robin Murphy
On 16/10/2019 17:11, Qian Cai wrote: On Wed, 2019-10-16 at 18:03 +0200, Joerg Roedel wrote: On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote: On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote: The x86 one might just be a mistake. diff --git a/drivers/iommu/amd_iommu.c

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Qian Cai
On Wed, 2019-10-16 at 18:03 +0200, Joerg Roedel wrote: > On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote: > > On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote: > > The x86 one might just be a mistake. > > > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > >

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Robin Murphy
On 16/10/2019 17:03, Joerg Roedel wrote: On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote: On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote: The x86 one might just be a mistake. diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index ad05484d0c80..63c4b894751d

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Joerg Roedel
On Wed, Oct 16, 2019 at 11:53:33AM -0400, Qian Cai wrote: > On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote: > The x86 one might just be a mistake. > > diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c > index ad05484d0c80..63c4b894751d 100644 > ---

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Qian Cai
On Wed, 2019-10-16 at 17:31 +0200, Joerg Roedel wrote: > Hi Qian, > > thanks for the report! > > On Wed, Oct 16, 2019 at 10:59:42AM -0400, Qian Cai wrote: > > On Wed, 2019-10-16 at 10:55 -0400, Qian Cai wrote: > > > Today's linux-next generates a lot of warnings on multiple servers during > > >

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Joerg Roedel
On Wed, Oct 16, 2019 at 10:59:42AM -0400, Qian Cai wrote: > BTW, the previous x86 warning was from only reverted one patch "iommu: Add gfp > parameter to iommu_ops::map" where proved to be insufficient. Now, pasting the > correct warning. Can you please test this small fix: diff --git

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Joerg Roedel
Hi Qian, thanks for the report! On Wed, Oct 16, 2019 at 10:59:42AM -0400, Qian Cai wrote: > On Wed, 2019-10-16 at 10:55 -0400, Qian Cai wrote: > > Today's linux-next generates a lot of warnings on multiple servers during > > boot > > due to the series "iommu/amd: Convert the AMD iommu driver to

Re: "Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Qian Cai
ping function called from invalid context at mm/page_alloc.c:4692 [  564.374447][ T6222] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 6222, name: git [  564.382969][ T6222] INFO: lockdep is turned off. [  564.387644][ T6222] CPU: 25 PID: 6222 Comm: git Tainted: GW 5.4.0-r

"Convert the AMD iommu driver to the dma-iommu api" is buggy

2019-10-16 Thread Qian Cai
Tainted: GW 5.4.0-rc3-next-20191016+ #7 [  257.818035][ T6184] Hardware name: HPE ProLiant DL385 Gen10/ProLiant DL385 Gen10, BIOS A40 07/10/2019 [  257.827313][ T6184] Call Trace: [  257.830487][ T6184]  dump_stack+0x86/0xca [  257.834530][ T6184]  ___might_sleep.cold.92+0xd2/0x122 [  

Re: [PATCH 1/5] iommu: Implement iommu_put_resv_regions_simple()

2019-10-16 Thread Thierry Reding
On Wed, Sep 18, 2019 at 04:37:38PM +0100, Will Deacon wrote: > On Thu, Aug 29, 2019 at 01:17:48PM +0200, Thierry Reding wrote: > > From: Thierry Reding > > > > Implement a generic function for removing reserved regions. This can be > > used by drivers that don't do anything fancy with these

Re: [RFC PATCH 0/6] SMMUv3 PMCG IMP DEF event support

2019-10-16 Thread John Garry
Hi Robin, Two significant concerns right off the bat: - It seems more common than not for silicon designers to fail to implement IIDR correctly, so it's only a matter of time before inevitably needing to bring back some firmware-level identifier abstraction (if not already - does Hi161x have

[PATCH 1/3] iommu/tegra-smmu: Use non-secure register for flushing

2019-10-16 Thread Thierry Reding
From: Navneet Kumar Use PTB_ASID instead of SMMU_CONFIG to flush smmu. PTB_ASID can be accessed from non-secure mode, SMMU_CONFIG cannot be. Using SMMU_CONFIG could pose a problem when kernel doesn't have secure mode access enabled from boot. Signed-off-by: Navneet Kumar Reviewed-by: Dmitry

[PATCH 3/3] iommu/tegra-smmu: Fix page tables in > 4 GiB memory

2019-10-16 Thread Thierry Reding
From: Thierry Reding Page tables that reside in physical memory beyond the 4 GiB boundary are currently not working properly. The reason is that when the physical address for page directory entries is read, it gets truncated at 32 bits and can cause crashes when passing that address to the DMA

[PATCH 2/3] iommu/tegra-smmu: Fix client enablement order

2019-10-16 Thread Thierry Reding
From: Navneet Kumar Enable clients' translation only after setting up the swgroups. Signed-off-by: Navneet Kumar Signed-off-by: Thierry Reding --- drivers/iommu/tegra-smmu.c | 23 ++- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git

Re: [RFC PATCH 0/6] SMMUv3 PMCG IMP DEF event support

2019-10-16 Thread Robin Murphy
On 2019-10-16 9:47 am, John Garry wrote: On 15/10/2019 19:00, Robin Murphy wrote: Hi John, On 30/09/2019 15:33, John Garry wrote: This patchset adds IMP DEF event support for the SMMUv3 PMCG. It is marked as an RFC as the method to identify the PMCG implementation may be a quite disliked.

Re: [PATCH] kernel: dma: Make CMA boot parameters __ro_after_init

2019-10-16 Thread Shyam Saini
Hi Nathan, On Mon, Oct 14, 2019 at 7:55 AM Nathan Chancellor wrote: > > On Sat, Oct 12, 2019 at 05:59:18PM +0530, Shyam Saini wrote: > > This parameters are not changed after early boot. > > By making them __ro_after_init will reduce any attack surface in the > > kernel. > > > > Link:

Re: [RFC PATCH 0/6] SMMUv3 PMCG IMP DEF event support

2019-10-16 Thread John Garry
On 15/10/2019 19:00, Robin Murphy wrote: Hi John, On 30/09/2019 15:33, John Garry wrote: This patchset adds IMP DEF event support for the SMMUv3 PMCG. It is marked as an RFC as the method to identify the PMCG implementation may be a quite disliked. And, in general, the series is somewhat

RE: [PATCH 2/2] virtio_ring: Use DMA API if memory is encrypted

2019-10-16 Thread Ram Pai
On Tue, Oct 15, 2019 at 09:35:01AM +0200, Christoph Hellwig wrote: > On Fri, Oct 11, 2019 at 06:25:19PM -0700, Ram Pai wrote: > > From: Thiago Jung Bauermann > > > > Normally, virtio enables DMA API with VIRTIO_F_IOMMU_PLATFORM, which must > > be set by both device and guest driver. However, as

Re: [PATCH] iommu/vt-d: Check VT-d RMRR region in BIOS is reported as reserved

2019-10-16 Thread Joerg Roedel
Hi, On Tue, Oct 15, 2019 at 09:49:32AM -0700, Yian Chen wrote: > VT-d RMRR (Reserved Memory Region Reporting) regions are reserved > for device use only and should not be part of allocable memory pool of OS. > > BIOS e820_table reports complete memory map to OS, including OS usable > memory

Re: [PATCH] iommu: rockchip: Free domain on .domain_free

2019-10-16 Thread Joerg Roedel
On Wed, Oct 02, 2019 at 02:29:23PM -0300, Ezequiel Garcia wrote: > IOMMU domain resource life is well-defined, managed > by .domain_alloc and .domain_free. > > Therefore, domain-specific resources shouldn't be tied to > the device life, but instead to its domain. > > Signed-off-by: Ezequiel

Re: [PATCH v2 5/6] iommu/ipmmu-vmsa: Add helper functions for "uTLB" registers

2019-10-16 Thread Geert Uytterhoeven
On Tue, Oct 15, 2019 at 2:10 PM Yoshihiro Shimoda wrote: > Since we will have changed memory mapping of the IPMMU in the future, > This patch adds helper functions ipmmu_utlb_reg() and > ipmmu_imu{asid,ctr}_write() for "uTLB" registers. No behavior change. > > Signed-off-by: Yoshihiro Shimoda

Re: [PATCH v2 4/6] iommu/ipmmu-vmsa: Calculate context registers' offset instead of a macro

2019-10-16 Thread Geert Uytterhoeven
On Tue, Oct 15, 2019 at 2:10 PM Yoshihiro Shimoda wrote: > Since we will have changed memory mapping of the IPMMU in the future, > this patch uses ipmmu_features values instead of a macro to > calculate context registers offset. No behavior change. > > Signed-off-by: Yoshihiro Shimoda

Re: [PATCH v2 3/6] iommu/ipmmu-vmsa: Add helper functions for MMU "context" registers

2019-10-16 Thread Geert Uytterhoeven
On Tue, Oct 15, 2019 at 2:10 PM Yoshihiro Shimoda wrote: > Since we will have changed memory mapping of the IPMMU in the future, > This patch adds helper functions ipmmu_ctx_{reg,read,write}() > for MMU "context" registers. No behavior change. > > Signed-off-by: Yoshihiro Shimoda Reviewed-by: