Re: [PATCH 0/3] iommu/drm/msm: Allow non-coherent masters to use system cache

2021-07-28 Thread Sai Prakash Ranjan
Hi Georgi, On 2021-07-28 19:30, Georgi Djakov wrote: On Mon, Jan 11, 2021 at 07:45:02PM +0530, Sai Prakash Ranjan wrote: commit ecd7274fb4cd ("iommu: Remove unused IOMMU_SYS_CACHE_ONLY flag") removed unused IOMMU_SYS_CACHE_ONLY prot flag and along with it went the memory type setting required

Re: [powerpc][next-20210727] Boot failure - kernel BUG at arch/powerpc/kernel/interrupt.c:98!

2021-07-28 Thread Nicholas Piggin
Excerpts from Nathan Chancellor's message of July 29, 2021 3:35 am: > On Wed, Jul 28, 2021 at 01:31:06PM +0530, Sachin Sant wrote: >> linux-next fails to boot on Power server (POWER8/POWER9). Following traces >> are seen during boot >> >> [0.010799] software IO TLB: tearing down default

Re: [PATCH v2 00/24] iommu: Refactor DMA domain strictness

2021-07-28 Thread chenxiang (M)
Hi Robin, 在 2021/7/28 23:58, Robin Murphy 写道: Hi all, Here's v2 where things start to look more realistic, hence the expanded CC list. The patches are now based on the current iommu/core branch to take John's iommu_set_dma_strict() cleanup into account. The series remiains in two (or

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

2021-07-28 Thread Suthikulpanit, Suravee via iommu
Lennert, On 7/26/2021 11:31 AM, Lennert Buytenhek wrote: 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.

Re: [powerpc][next-20210727] Boot failure - kernel BUG at arch/powerpc/kernel/interrupt.c:98!

2021-07-28 Thread Nathan Chancellor
On Wed, Jul 28, 2021 at 01:31:06PM +0530, Sachin Sant wrote: > linux-next fails to boot on Power server (POWER8/POWER9). Following traces > are seen during boot > > [0.010799] software IO TLB: tearing down default memory pool > [0.010805] [ cut here ] > [

Re: [PATCH 03/13] x86/HV: Add new hvcall guest address host visibility support

2021-07-28 Thread Dave Hansen
On 7/28/21 7:52 AM, Tianyu Lan wrote: > @@ -1986,7 +1988,9 @@ static int __set_memory_enc_dec(unsigned long addr, int > numpages, bool enc) > int ret; > > /* Nothing to do if memory encryption is not active */ > - if (!mem_encrypt_active()) > + if

Re: [PATCH 01/11] mm: Introduce a function to check for virtualization protection features

2021-07-28 Thread Borislav Petkov
On Wed, Jul 28, 2021 at 02:17:27PM +0100, Christoph Hellwig wrote: > So common checks obviously make sense, but I really hate the stupid > multiplexer. Having one well-documented helper per feature is much > easier to follow. We had that in x86 - it was called cpu_has_ where xxx is the feature

[PATCH v2 24/24] iommu: Only log strictness for DMA domains

2021-07-28 Thread Robin Murphy
When passthrough is enabled, the default strictness policy becomes irrelevant, since any subsequent runtime override to a DMA domain type now embodies an explicit choice of strictness as well. Save on noise by only logging the default policy when it is meaningfully in effect. Signed-off-by: Robin

[PATCH v2 23/24] iommu/arm-smmu: Allow non-strict in pgtable_quirks interface

2021-07-28 Thread Robin Murphy
To make io-pgtable aware of a flush queue being dynamically enabled, allow IO_PGTABLE_QUIRK_NON_STRICT to be set even after a domain has been attached to, and hook up the final piece of the puzzle in iommu-dma. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 15

[PATCH v2 21/24] iommu/dma: Factor out flush queue init

2021-07-28 Thread Robin Murphy
Factor out flush queue setup from the initial domain init so that we can potentially trigger it from sysfs later on in a domain's lifetime. Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 30 -- include/linux/dma-iommu.h | 9 ++--- 2 files changed,

[PATCH v2 22/24] iommu: Allow enabling non-strict mode dynamically

2021-07-28 Thread Robin Murphy
Allocating and enabling a flush queue is in fact something we can reasonably do while a DMA domain is active, without having to rebuild it from scratch. Thus we can allow a strict -> non-strict transition from sysfs without requiring to unbind the device's driver, which is of particular interest

[PATCH v2 20/24] iommu: Merge strictness and domain type configs

2021-07-28 Thread Robin Murphy
To parallel the sysfs behaviour, merge the new build-time option for DMA domain strictness into the default domain type choice. Suggested-by: Joerg Roedel Signed-off-by: Robin Murphy --- drivers/iommu/Kconfig | 80 +-- drivers/iommu/iommu.c | 2 +- 2

[PATCH v2 18/24] iommu: Express DMA strictness via the domain type

2021-07-28 Thread Robin Murphy
Eliminate the iommu_get_dma_strict() indirection and pipe the information through the domain type from the beginning. Besides the flow simplification this also has several nice side-effects: - Automatically implies strict mode for untrusted devices by virtue of their IOMMU_DOMAIN_DMA

[PATCH v2 19/24] iommu: Expose DMA domain strictness via sysfs

2021-07-28 Thread Robin Murphy
The sysfs interface for default domain types exists primarily so users can choose the performance/security tradeoff relevant to their own workload. As such, the choice between the policies for DMA domains fits perfectly as an additional point on that scale - downgrading a particular device from a

[PATCH v2 17/24] iommu/vt-d: Prepare for multiple DMA domain types

2021-07-28 Thread Robin Murphy
In preparation for the strict vs. non-strict decision for DMA domains to be expressed in the domain type, make sure we expose our flush queue awareness by accepting the new domain type, and test the specific feature flag where we want to identify DMA domains in general. The DMA ops reset/setup can

[PATCH v2 16/24] iommu/arm-smmu: Prepare for multiple DMA domain types

2021-07-28 Thread Robin Murphy
In preparation for the strict vs. non-strict decision for DMA domains to be expressed in the domain type, make sure we expose our flush queue awareness by accepting the new domain type. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 1 +

[PATCH v2 15/24] iommu/amd: Prepare for multiple DMA domain types

2021-07-28 Thread Robin Murphy
The DMA ops reset/setup can simply be unconditional, since iommu-dma already knows only to touch DMA domains. Signed-off-by: Robin Murphy --- drivers/iommu/amd/iommu.c | 9 ++--- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/amd/iommu.c

[PATCH v2 13/24] iommu/dma: Remove redundant "!dev" checks

2021-07-28 Thread Robin Murphy
iommu_dma_init_domain() is now only called from iommu_setup_dma_ops(), which has already assumed dev to be non-NULL. Reviewed-by: John Garry Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git

[PATCH v2 14/24] iommu: Introduce explicit type for non-strict DMA domains

2021-07-28 Thread Robin Murphy
Promote the difference between strict and non-strict DMA domains from an internal detail to a distinct domain feature and type, to pave the road for exposing it through the sysfs default domain interface. Signed-off-by: Robin Murphy --- drivers/iommu/dma-iommu.c | 2 +- drivers/iommu/iommu.c

[PATCH v2 12/24] iommu/dma: Unexport IOVA cookie management

2021-07-28 Thread Robin Murphy
IOVA cookies are now got and put by core code, so we no longer need to export these to modular drivers. The export for getting MSI cookies stays, since VFIO can still be a module, but it was already relying on someone else putting them, so that aspect is unaffected. Signed-off-by: Robin Murphy

[PATCH v2 11/24] iommu/virtio: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Jean-Philippe Brucker Signed-off-by: Robin Murphy --- drivers/iommu/virtio-iommu.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/iommu/virtio-iommu.c b/drivers/iommu/virtio-iommu.c index 6abdcab7273b..80930ce04a16 100644 ---

[PATCH v2 10/24] iommu/sun50i: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Maxime Ripard Signed-off-by: Robin Murphy --- drivers/iommu/sun50i-iommu.c | 12 +--- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/drivers/iommu/sun50i-iommu.c b/drivers/iommu/sun50i-iommu.c index 181bb1c3437c..c349a95ec7bd

[PATCH v2 09/24] iommu/sprd: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Chunyan Zhang Signed-off-by: Robin Murphy --- drivers/iommu/sprd-iommu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/iommu/sprd-iommu.c b/drivers/iommu/sprd-iommu.c index 73dfd9946312..2bc1de6e823d 100644 ---

[PATCH v2 08/24] iommu/rockchip: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Heiko Stuebner Signed-off-by: Robin Murphy --- drivers/iommu/rockchip-iommu.c | 11 +-- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index

[PATCH v2 07/24] iommu/mtk: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Yong Wu Signed-off-by: Robin Murphy --- drivers/iommu/mtk_iommu.c | 6 -- 1 file changed, 6 deletions(-) diff --git a/drivers/iommu/mtk_iommu.c b/drivers/iommu/mtk_iommu.c index 6f7c69688ce2..e39a6d1da28d 100644 --- a/drivers/iommu/mtk_iommu.c

[PATCH v2 06/24] iommu/ipmmu-vmsa: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Yoshihiro Shimoda CC: Geert Uytterhoeven Signed-off-by: Robin Murphy --- drivers/iommu/ipmmu-vmsa.c | 27 --- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/drivers/iommu/ipmmu-vmsa.c

[PATCH v2 05/24] iommu/exynos: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. CC: Marek Szyprowski Signed-off-by: Robin Murphy --- drivers/iommu/exynos-iommu.c | 18 -- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c index

[PATCH v2 04/24] iommu/vt-d: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/intel/iommu.c | 8 1 file changed, 8 deletions(-) diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index c12cc955389a..7e168634c433 100644 --- a/drivers/iommu/intel/iommu.c +++

[PATCH v2 02/24] iommu/amd: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/amd/iommu.c | 12 1 file changed, 12 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 52fe2326042a..0fd98d35d73b 100644 --- a/drivers/iommu/amd/iommu.c +++

[PATCH v2 03/24] iommu/arm-smmu: Drop IOVA cookie management

2021-07-28 Thread Robin Murphy
The core code bakes its own cookies now. Signed-off-by: Robin Murphy --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 --- drivers/iommu/arm/arm-smmu/arm-smmu.c | 15 --- drivers/iommu/arm/arm-smmu/qcom_iommu.c | 8 3 files changed, 4 insertions(+), 26

[PATCH v2 01/24] iommu: Pull IOVA cookie management into the core

2021-07-28 Thread Robin Murphy
Now that everyone has converged on iommu-dma for IOMMU_DOMAIN_DMA support, we can abandon the notion of drivers being responsible for the cookie type, and consolidate all the management into the core code. CC: Marek Szyprowski CC: Yoshihiro Shimoda CC: Geert Uytterhoeven CC: Yong Wu CC: Heiko

[PATCH v2 00/24] iommu: Refactor DMA domain strictness

2021-07-28 Thread Robin Murphy
Hi all, Here's v2 where things start to look more realistic, hence the expanded CC list. The patches are now based on the current iommu/core branch to take John's iommu_set_dma_strict() cleanup into account. The series remiains in two (or possibly 3) logical parts - for people CC'd on cookie

Re: [bug report] iommu_dma_unmap_sg() is very slow then running IO from remote numa node

2021-07-28 Thread Robin Murphy
On 2021-07-28 16:17, Ming Lei wrote: On Wed, Jul 28, 2021 at 11:38:18AM +0100, John Garry wrote: On 28/07/2021 02:32, Ming Lei wrote: On Mon, Jul 26, 2021 at 3:51 PM John Garry wrote: On 23/07/2021 11:21, Ming Lei wrote: Thanks, I was also going to suggest the latter, since it's what

Re: [PATCH 03/13] x86/HV: Add new hvcall guest address host visibility support

2021-07-28 Thread Dave Hansen
On 7/28/21 7:52 AM, Tianyu Lan wrote: > @@ -1986,7 +1988,9 @@ static int __set_memory_enc_dec(unsigned long addr, int > numpages, bool enc) > int ret; > > /* Nothing to do if memory encryption is not active */ > - if (!mem_encrypt_active()) > + if

Re: [bug report] iommu_dma_unmap_sg() is very slow then running IO from remote numa node

2021-07-28 Thread Ming Lei
On Wed, Jul 28, 2021 at 11:38:18AM +0100, John Garry wrote: > On 28/07/2021 02:32, Ming Lei wrote: > > On Mon, Jul 26, 2021 at 3:51 PM John Garry wrote: > > > On 23/07/2021 11:21, Ming Lei wrote: > > > > > Thanks, I was also going to suggest the latter, since it's what > > > > >

[PATCH 12/13] HV/Netvsc: Add Isolation VM support for netvsc driver

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for netvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ pagebuffer() still need to handle. Use DMA API to map/umap these memory

[PATCH 13/13] HV/Storvsc: Add Isolation VM support for storvsc driver

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM, all shared memory with host needs to mark visible to host via hvcall. vmbus_establish_gpadl() has already done it for storvsc rx/tx ring buffer. The page buffer used by vmbus_sendpacket_ mpb_desc() still need to handle. Use DMA API to map/umap these memory

[PATCH 11/13] HV/IOMMU: Enable swiotlb bounce buffer for Isolation VM

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Hyper-V Isolation VM requires bounce buffer support to copy data from/to encrypted memory and so enable swiotlb force mode to use swiotlb bounce buffer for DMA transaction. In Isolation VM with AMD SEV, the bounce buffer needs to be accessed via extra address space which is

[PATCH 10/13] x86/Swiotlb: Add Swiotlb bounce buffer remap function for HV IVM

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan In Isolation VM with AMD SEV, bounce buffer needs to be accessed via extra address space which is above shared_gpa_boundary (E.G 39 bit address line) reported by Hyper-V CPUID ISOLATION_CONFIG. The access physical address will be original physical address + shared_gpa_boundary.

[PATCH 09/13] DMA: Add dma_map_decrypted/dma_unmap_encrypted() function

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan In Hyper-V Isolation VM with AMD SEV, swiotlb boucne buffer needs to be mapped into address space above vTOM and so introduce dma_map_decrypted/dma_unmap_encrypted() to map/unmap bounce buffer memory. The platform can populate man/unmap callback in the dma memory decrypted ops.

[PATCH 08/13] HV/Vmbus: Initialize VMbus ring buffer for Isolation VM

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan VMbus ring buffer are shared with host and it's need to be accessed via extra address space of Isolation VM with SNP support. This patch is to map the ring buffer address in extra address space via ioremap(). HV host visibility hvcall smears data in the ring buffer and so reset

[PATCH 07/13] HV/Vmbus: Add SNP support for VMbus channel initiate message

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan The monitor pages in the CHANNELMSG_INITIATE_CONTACT msg are shared with host in Isolation VM and so it's necessary to use hvcall to set them visible to host. In Isolation VM with AMD SEV SNP, the access address should be in the extra space which is above shared gpa boundary. So

[PATCH 06/13] HV: Add ghcb hvcall support for SNP VM

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides ghcb hvcall to handle VMBus HVCALL_SIGNAL_EVENT and HVCALL_POST_MESSAGE msg in SNP Isolation VM. Add such support. Signed-off-by: Tianyu Lan --- arch/x86/hyperv/ivm.c | 42 + arch/x86/include/asm/mshyperv.h | 1 +

[PATCH 05/13] HV: Add Write/Read MSR registers via ghcb page

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides GHCB protocol to write Synthetic Interrupt Controller MSR registers in Isolation VM with AMD SEV SNP and these registers are emulated by hypervisor directly. Hyper-V requires to write SINTx MSR registers twice. First writes MSR via GHCB page to communicate with

[PATCH 04/13] HV: Mark vmbus ring buffer visible to host in Isolation VM

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Mark vmbus ring buffer visible with set_memory_decrypted() when establish gpadl handle. Signed-off-by: Tianyu Lan --- drivers/hv/channel.c | 38 -- include/linux/hyperv.h | 10 ++ 2 files changed, 46 insertions(+), 2 deletions(-)

[PATCH 03/13] x86/HV: Add new hvcall guest address host visibility support

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Add new hvcall guest address host visibility support to mark memory visible to host. Call it inside set_memory_decrypted /encrypted(). Signed-off-by: Tianyu Lan --- arch/x86/hyperv/Makefile | 2 +- arch/x86/hyperv/ivm.c | 112

[PATCH 02/13] x86/HV: Initialize shared memory boundary in the Isolation VM.

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Hyper-V exposes shared memory boundary via cpuid HYPERV_CPUID_ISOLATION_CONFIG and store it in the shared_gpa_boundary of ms_hyperv struct. This prepares to share memory with host for SNP guest. Signed-off-by: Tianyu Lan --- arch/x86/kernel/cpu/mshyperv.c | 2 ++

[PATCH 01/13] x86/HV: Initialize GHCB page in Isolation VM

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Hyper-V exposes GHCB page via SEV ES GHCB MSR for SNP guest to communicate with hypervisor. Map GHCB page for all cpus to read/write MSR register and submit hvcall request via GHCB. Signed-off-by: Tianyu Lan --- arch/x86/hyperv/hv_init.c | 73

[PATCH 00/13] x86/Hyper-V: Add Hyper-V Isolation VM support

2021-07-28 Thread Tianyu Lan
From: Tianyu Lan Hyper-V provides two kinds of Isolation VMs. VBS(Virtualization-based security) and AMD SEV-SNP unenlightened Isolation VMs. This patchset is to add support for these Isolation VM support in Linux. The memory of these vms are encrypted and host can't access guest memory

Re: [PATCH 0/3] iommu/drm/msm: Allow non-coherent masters to use system cache

2021-07-28 Thread Georgi Djakov
On Mon, Jan 11, 2021 at 07:45:02PM +0530, Sai Prakash Ranjan wrote: > commit ecd7274fb4cd ("iommu: Remove unused IOMMU_SYS_CACHE_ONLY flag") > removed unused IOMMU_SYS_CACHE_ONLY prot flag and along with it went > the memory type setting required for the non-coherent masters to use > system cache.

Re: [PATCH 02/11] x86/sev: Add an x86 version of prot_guest_has()

2021-07-28 Thread Christoph Hellwig
On Tue, Jul 27, 2021 at 05:26:05PM -0500, Tom Lendacky via iommu wrote: > Introduce an x86 version of the prot_guest_has() function. This will be > used in the more generic x86 code to replace vendor specific calls like > sev_active(), etc. > > While the name suggests this is intended mainly for

Re: [PATCH 01/11] mm: Introduce a function to check for virtualization protection features

2021-07-28 Thread Christoph Hellwig
On Tue, Jul 27, 2021 at 05:26:04PM -0500, Tom Lendacky via iommu wrote: > In prep for other protected virtualization technologies, introduce a > generic helper function, prot_guest_has(), that can be used to check > for specific protection attributes, like memory encryption. This is > intended to

Re: [PATCH 00/11] Implement generic prot_guest_has() helper function

2021-07-28 Thread Christian König
Am 28.07.21 um 00:26 schrieb Tom Lendacky: This patch series provides a generic helper function, prot_guest_has(), to replace the sme_active(), sev_active(), sev_es_active() and mem_encrypt_active() functions. It is expected that as new protected virtualization technologies are added to the

Re: [PATCH] iommu: check if group is NULL before remove device

2021-07-28 Thread Frank Wunderlich
Hi Joerg, Sorry for late reply, somehow i marked message as read without answering it. Am 15. Juli 2021 09:20:04 MESZ schrieb Joerg Roedel : >On Thu, Jul 15, 2021 at 09:11:50AM +0200, Frank Wunderlich wrote: >> From: Frank Wunderlich >> >> if probe is failing, iommu_group may be not

Re: [bug report] iommu_dma_unmap_sg() is very slow then running IO from remote numa node

2021-07-28 Thread John Garry
On 28/07/2021 02:32, Ming Lei wrote: On Mon, Jul 26, 2021 at 3:51 PM John Garry wrote: On 23/07/2021 11:21, Ming Lei wrote: Thanks, I was also going to suggest the latter, since it's what arm_smmu_cmdq_issue_cmdlist() does with IRQs masked that should be most indicative of where the slowness

[PATCH v2 0/7] sections: Unify kernel sections range check and use

2021-07-28 Thread Kefeng Wang
There are three head files(kallsyms.h, kernel.h and sections.h) which include the kernel sections range check, let's make some cleanup and unify them. 1. cleanup arch specific text/data check and fix address boundary check in kallsyms.h 2. make all the basic/core kernel range check function