[PATCH kernel 0/3] vfio/spapr_tce: Reworks for NVIDIA V100 + P9 passthrough (part 3)

2018-10-15 Thread Alexey Kardashevskiy
: Reworks for NVIDIA V100 + P9 passthrough (part 2) [PATCH kernel RFC 3/3] powerpc/pseries/iommu: Use memory@ nodes in max RAM address calculation Please comment. Thanks. Alexey Kardashevskiy (3): vfio_pci: Allow mapping extra regions vfio_pci: Allow regions to add own capabilities vfio_pci

Re: [PATCH kernel 0/5] powerpc/powernv/npu: Reworks for NVIDIA V100 + P9 passthrough (part 2)

2018-10-15 Thread Alexey Kardashevskiy
Strangely Reza is missed by the get_maintainers.pl, adding in cc: :-/ On 15/10/2018 20:32, Alexey Kardashevskiy wrote: > This is a second set of patches required for passing through NVIDIA V100 > with coherent memory. The full patchset is here: > https://github.com/aik/linux/tree/

[PATCH kernel 4/5] powerpc/powernv/npu: Factor out OPAL calls from context manipulation

2018-10-15 Thread Alexey Kardashevskiy
MSR mask which NPU adds to ATS requests so nested MMU knows what translations are permitted; the VFIO/KVM will not set MSR_HV. This removes the check for FW_FEATURE_OPAL as pnv_npu2_init_context/ pnv_npu2_release_context/pnv_npu2_init do not call OPAL anymore. Signed-off-by: Alexey Kardashevskiy

[PATCH kernel 3/5] powerpc/powernv: Detach npu struct from pnv_phb

2018-10-15 Thread Alexey Kardashevskiy
different data structure. This adds a global list of NPUs so each platform can register and use these in the same fashion. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci.h | 16 --- arch/powerpc/platforms/powernv/npu-dma.c | 71 +--- 2

[PATCH kernel 2/5] powerpc/powernv/npu: Collect all static symbols under one struct

2018-10-15 Thread Alexey Kardashevskiy
We are going to add a global list of NPUs in the system which is going to be yet another static symbol. Let's reorganise the code and put all static symbols into one struct for better tracking what is really needed for NPU (this might become a driver data some day). Signed-off-by: A

[PATCH kernel 0/5] powerpc/powernv/npu: Reworks for NVIDIA V100 + P9 passthrough (part 2)

2018-10-15 Thread Alexey Kardashevskiy
symbols are called from the NVIDIA driver so they must be able to work in both powernv and pseries platforms. This depends on skiboot's "npu2: Clear XTS_BDF_MAP when destroying context for next init_context" posted earlier today. Please comment. Thanks. Alexey Kardashevskiy

[PATCH kernel 5/5] powerpc/powernv/npu: Add helper to map GPU to LPAR

2018-10-15 Thread Alexey Kardashevskiy
for ATS checkout requests. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/pci.h | 2 ++ arch/powerpc/platforms/powernv/npu-dma.c | 38 2 files changed, 40 insertions(+) diff --git a/arch/powerpc/include/asm/pci.h b/arch/powerpc

[PATCH kernel 1/5] powerpc/powernv/npu: Add helper to access struct npu for NPU device

2018-10-15 Thread Alexey Kardashevskiy
This step is to help removing the npu struct from pnv_phb so it can be used by pseries as well. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/npu-dma.c | 20 +++- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/arch/powerpc/platforms

[PATCH kernel 2/4] powerpc/mm/iommu/vfio_spapr_tce: Change mm_iommu_get to reference a region

2018-10-15 Thread Alexey Kardashevskiy
changes mm_iommu_get() to reference the region so from now on for every mm_iommu_get() we need a matching mm_iommu_put(). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/mm/mmu_context_iommu.c | 5 + drivers/vfio/vfio_iommu_spapr_tce.c | 33 ++--- 2 files

[PATCH kernel 0/4] vfio/spapr_tce: Reworks for NVIDIA V100 + P9 passthrough (part 1)

2018-10-15 Thread Alexey Kardashevskiy
backed with page structs. Does 4/4 really need splitting? Please comment. Thanks. Alexey Kardashevskiy (4): powerpc/mm/iommu: Rename mm_iommu_get powerpc/mm/iommu/vfio_spapr_tce: Change mm_iommu_get to reference a region powerpc/mm/iommu: Make mm_iommu_new() fail on existing regions

[PATCH kernel 4/4] powerpc/vfio/iommu/kvm: Do not pin device memory

2018-10-15 Thread Alexey Kardashevskiy
e of thise new regions which we must avoid unpinning of. This adds @mm to tce_page_is_contained() and iommu_tce_xchg() to test if the memory is device memory to avoid pfn_to_page(). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h | 5 +- arch/powerpc/include/asm/mmu

[PATCH kernel 3/4] powerpc/mm/iommu: Make mm_iommu_new() fail on existing regions

2018-10-15 Thread Alexey Kardashevskiy
Since we are going to have 2 different preregistering helpers, let's make it clear that mm_iommu_new() is only for the normal (i.e. not device) memory and for existing areas mm_iommu_get() should be used instead. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/mm/mmu_context_iommu.

[PATCH kernel 1/4] powerpc/mm/iommu: Rename mm_iommu_get

2018-10-15 Thread Alexey Kardashevskiy
; - mm_iommu_find to mm_iommu_get. This should cause no behavioural change. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/mmu_context.h | 4 ++-- arch/powerpc/mm/mmu_context_iommu.c| 8 drivers/vfio/vfio_iommu_spapr_tce.c| 6 +++--- 3 files changed, 9 insertions

Re: [PATCH kernel RFC 0/3] powerpc/pseries/iommu: GPU coherent memory pass through

2018-10-15 Thread Alexey Kardashevskiy
Ping? On 17/09/2018 17:05, Alexey Kardashevskiy wrote: > Ping? > > The problem is still there... > > > On 24/08/2018 13:04, Alexey Kardashevskiy wrote: >> >> >> On 09/08/2018 14:41, Alexey Kardashevskiy wrote: >>> >>> >>> On 25

Re: [PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-15 Thread Alexey Kardashevskiy
Ping? On 02/10/2018 13:20, Alexey Kardashevskiy wrote: > The skiboot firmware has a hot reset handler which fences the NVIDIA V100 > GPU RAM on Witherspoons and makes accesses no-op instead of throwing HMIs: > https://github.com/open-power/skiboot/commit/fca2b2b839a67 > > Now

Re: [PATCH 16/33] powerpc/powernv: remove dead npu-dma code

2018-10-14 Thread Alexey Kardashevskiy
On 10/10/2018 00:24, Christoph Hellwig wrote: > This code has been unused since it was merged and is in the way of > cleaning up the DMA code, thus remove it. > > This effectively reverts commit 5d2aa710 ("powerpc/powernv: Add support > for Nvlink NPUs"). This code is heavily used by the NVIDI

Re: [PATCH kernel] cxl: Remove unused include

2018-10-03 Thread Alexey Kardashevskiy
On 28/09/2018 22:46, Michael Ellerman wrote: > Alexey Kardashevskiy writes: >> The included opal.h gives a wrong idea that CXL makes PPC OPAL calls >> while it does not so let's remote it. > > But it does use eg. > > OPAL_PHB_CAPI_MODE_SNOOP_ON > OPAL

[RFC PATCH kernel] vfio/spapr_tce: Get rid of possible infinite loop

2018-10-01 Thread Alexey Kardashevskiy
. Signed-off-by: Alexey Kardashevskiy --- drivers/vfio/vfio_iommu_spapr_tce.c | 10 +++--- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index b1a8ab3..ece0651 100644 --- a/drivers/vfio

[PATCH kernel v2] powerpc/ioda/npu: Call skiboot's hot reset hook when disabling NPU2

2018-10-01 Thread Alexey Kardashevskiy
pci_disable_device() which switches NPU2 to a safe mode and prevents HMIs. Signed-off-by: Alexey Kardashevskiy --- Changes: v2: * updated the commit log --- arch/powerpc/platforms/powernv/pci-ioda.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/arch/powerpc/platforms/powernv/pci

[PATCH kernel] powerpc/powernv/npu: Remove unused headers and a macro.

2018-09-27 Thread Alexey Kardashevskiy
The macro and few headers are not used so remove them. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/npu-dma.c | 14 -- 1 file changed, 14 deletions(-) diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c index

[PATCH kernel] KVM: PPC: Optimize clearing TCEs for sparse tables

2018-09-27 Thread Alexey Kardashevskiy
accessor is used now in virtual mode as well, rename it from IOMMU_TABLE_USERSPACE_ENTRY_RM (real mode) to _RO (read only). Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 2 +- arch/powerpc/kvm/book3s_64_vio.c| 5 ++--- arch/powerpc/kvm/book3s_64_vio_hv.c | 6

[PATCH kernel] powerpc/powernv/ioda: Allocate indirect TCE levels of cached userspace addresses on demand

2018-09-27 Thread Alexey Kardashevskiy
te indirect TCE levels on demand") Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda-tce.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/powernv/pci-ioda-tce.c b/arch/powerpc/platforms/powernv/pci-ioda-tce.c index fe9

[PATCH kernel] cxl: Remove unused include

2018-09-27 Thread Alexey Kardashevskiy
The included opal.h gives a wrong idea that CXL makes PPC OPAL calls while it does not so let's remote it. Signed-off-by: Alexey Kardashevskiy --- drivers/misc/cxl/pci.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/misc/cxl/pci.c b/drivers/misc/cxl/pci.c index b66d832..8c

Re: [PATCH kernel RFC 0/3] powerpc/pseries/iommu: GPU coherent memory pass through

2018-09-17 Thread Alexey Kardashevskiy
Ping? The problem is still there... On 24/08/2018 13:04, Alexey Kardashevskiy wrote: > > > On 09/08/2018 14:41, Alexey Kardashevskiy wrote: >> >> >> On 25/07/2018 19:50, Alexey Kardashevskiy wrote: >>> I am trying to pass through a 3D controller: >>&

[PATCH kernel] powerpc/powernv/ioda2: Reduce upper limit for DMA window size (retry)

2018-09-10 Thread Alexey Kardashevskiy
other words we can create a window as big as 1<<58 but DMA simply won't work. This reduces the upper limit from 59 to 55 bits to let the userspace know about the hardware limits. Fixes: ce57c6610cc2 "Merge branch 'topic/ppc-kvm' into next" Signed-off-by: Alexey Karda

[PATCH kernel v2 6/6] KVM: PPC: Remove redundand permission bits removal

2018-09-10 Thread Alexey Kardashevskiy
. Signed-off-by: Alexey Kardashevskiy --- Changes: v2: * %s/kvmppc_gpa_to_ua/kvmppc_tce_to_ua/g --- arch/powerpc/include/asm/kvm_ppc.h | 2 +- arch/powerpc/kvm/book3s_64_vio.c| 12 arch/powerpc/kvm/book3s_64_vio_hv.c | 22 +- 3 files changed, 14 insertions

[PATCH kernel v2 5/6] KVM: PPC: Propagate errors to the guest when failed instead of ignoring

2018-09-10 Thread Alexey Kardashevskiy
request which cannot be processed. By now the only possible failure must be H_TOO_HARD. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- arch/powerpc/kvm/book3s_64_vio.c| 20 ++-- arch/powerpc/kvm/book3s_64_vio_hv.c | 21 +++-- 2 files

[PATCH kernel v2 4/6] KVM: PPC: Validate TCEs against preregistered memory page sizes

2018-09-10 Thread Alexey Kardashevskiy
This removes EXPORT_SYMBOL_GPL(kvmppc_tce_validate) as the validators are static now. >From now on the attempts on mapping IOMMU pages bigger than allowed will result in KVM exit. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- Changes: v2: * updated commit log --- arch

[PATCH kernel v2 2/6] KVM: PPC: Validate all tces before updating tables

2018-09-10 Thread Alexey Kardashevskiy
so let's valitate TCE beforehand. This should cause no behavioral change. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- Changes: v2: * added a comment for the second get_user() from v1 discussion --- arch/powerpc/kvm/book3s_64_vio.c| 18 ++ arch/po

[PATCH kernel v2 1/6] KVM: PPC: Avoid marking DMA-mapped pages dirty in real mode

2018-09-10 Thread Alexey Kardashevskiy
knowledge across different subsystems. This removes realmode_pfn_to_page() as it is not used anymore. While we at it, remove some EXPORT_SYMBOL_GPL() as that code is for the real mode only and modules cannot call it anyway. Signed-off-by: Alexey Kardashevskiy --- Changes: v2: * only do delaying

[PATCH kernel v2 0/6] KVM: PPC: TCE improvements

2018-09-10 Thread Alexey Kardashevskiy
9-rc3". Please comment. Thanks. Alex, I cc: you to keep you informed that [RFC 1/6] did change drivers/vfio/vfio_iommu_spapr_tce.c but this one does not. Alexey Kardashevskiy (6): KVM: PPC: Avoid marking DMA-mapped pages dirty in real mode KVM: PPC: Validate all tces before updating ta

[PATCH kernel v2 3/6] KVM: PPC: Inform the userspace about TCE update failures

2018-09-10 Thread Alexey Kardashevskiy
handle any request or at least log them all. Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- arch/powerpc/kvm/book3s_64_vio.c| 8 arch/powerpc/kvm/book3s_64_vio_hv.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/power

[PATCH kernel] KVM: PPC: Remove redundand permission bits removal

2018-09-06 Thread Alexey Kardashevskiy
. Signed-off-by: Alexey Kardashevskiy --- This is not related to any bug, just noticed this while doing other things. I can also rename kvmppc_gpa_to_ua() if it makes more sense, does not it? --- arch/powerpc/kvm/book3s_64_vio.c| 10 +++--- arch/powerpc/kvm/book3s_64_vio_hv.c | 16

[RFC PATCH kernel v2] KVM: PPC: Avoid marking DMA-mapped pages dirty in real mode

2018-09-06 Thread Alexey Kardashevskiy
or explicitly marks pages dirty when VFIO_SPAPR_TCE_IOMMU. This removes realmode_pfn_to_page() as it is not used anymore. Signed-off-by: Alexey Kardashevskiy --- v1 was here: https://www.spinics.net/lists/kvm-ppc/msg14218.html This is based on top of (it does not really depend on this but rebase d

[PATCH kernel] KVM: PPC: Avoid mapping compound pages to TCEs in real mode

2018-08-30 Thread Alexey Kardashevskiy
well. Signed-off-by: Alexey Kardashevskiy --- This is made on top of: [PATCH kernel 0/4] KVM: PPC: Some error handling rework KVM: PPC: Validate all tces before updating tables KVM: PPC: Inform the userspace about TCE update failures KVM: PPC: Validate TCEs against preregistered memory page

Re: [PATCH kernel 1/4] KVM: PPC: Validate all tces before updating tables

2018-08-30 Thread Alexey Kardashevskiy
On 30/08/2018 14:01, David Gibson wrote: > On Thu, Aug 30, 2018 at 01:16:44PM +1000, Alexey Kardashevskiy wrote: >> The KVM TCE handlers are written in a way so they fail when either >> something went horribly wrong or the userspace did some obvious mistake >> such as

[PATCH kernel 3/4] KVM: PPC: Validate TCEs against preregistered memory page sizes

2018-08-29 Thread Alexey Kardashevskiy
This removes EXPORT_SYMBOL_GPL(kvmppc_tce_validate) as the validators are static now. >From now on the attempts on mapping IOMMU pages bigger than allowed will result in KVM exit. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/kvm_ppc.h | 2 -- arch/powerpc/kvm/book3s_

[PATCH kernel 2/4] KVM: PPC: Inform the userspace about TCE update failures

2018-08-29 Thread Alexey Kardashevskiy
handle any request or at least log them all. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/kvm/book3s_64_vio.c| 8 arch/powerpc/kvm/book3s_64_vio_hv.c | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/power

[PATCH kernel 1/4] KVM: PPC: Validate all tces before updating tables

2018-08-29 Thread Alexey Kardashevskiy
so let's valitate TCE beforehand. This should cause no behavioral change. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/kvm/book3s_64_vio.c| 8 arch/powerpc/kvm/book3s_64_vio_hv.c | 4 2 files changed, 12 insertions(+) diff --git a/arch/powerpc/kvm/book3s_64_vio.c b

[PATCH kernel 0/4] KVM: PPC: Some error handling rework

2018-08-29 Thread Alexey Kardashevskiy
"powerpc: disable support for relative ksymtab references". Please comment. Thanks. Alexey Kardashevskiy (4): KVM: PPC: Validate all tces before updating tables KVM: PPC: Inform the userspace about TCE update failures KVM: PPC: Validate TCEs against preregistered memory page sizes

[PATCH kernel 4/4] KVM: PPC: Propagate errors to the guest when failed instead of ignoring

2018-08-29 Thread Alexey Kardashevskiy
request which cannot be processed. By now the only possible failure must be H_TOO_HARD. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/kvm/book3s_64_vio.c| 20 ++-- arch/powerpc/kvm/book3s_64_vio_hv.c | 20 ++-- 2 files changed, 12 insertions(+), 28

Re: [PATCH kernel RFC 0/3] powerpc/pseries/iommu: GPU coherent memory pass through

2018-08-23 Thread Alexey Kardashevskiy
On 09/08/2018 14:41, Alexey Kardashevskiy wrote: > > > On 25/07/2018 19:50, Alexey Kardashevskiy wrote: >> I am trying to pass through a 3D controller: >> [0302]: NVIDIA Corporation GV100GL [Tesla V100 SXM2] [10de:1db1] (rev a1) >> >> which has a quite

Re: [PATCH] powerpc/powernv/idle: Fix build error

2018-08-12 Thread Alexey Kardashevskiy
On 10/08/2018 17:10, Michael Ellerman wrote: > "Aneesh Kumar K.V" writes: > >> Fix the below build error using strlcpy instead of strncpy >> >> In function 'pnv_parse_cpuidle_dt', >> inlined from 'pnv_init_idle_states' at >> arch/powerpc/platforms/powernv/idle.c:840:7, >> inlined from

Re: [PATCH kernel RFC 0/3] powerpc/pseries/iommu: GPU coherent memory pass through

2018-08-08 Thread Alexey Kardashevskiy
On 25/07/2018 19:50, Alexey Kardashevskiy wrote: > I am trying to pass through a 3D controller: > [0302]: NVIDIA Corporation GV100GL [Tesla V100 SXM2] [10de:1db1] (rev a1) > > which has a quite unique feature as coherent memory directly accessible > from a POWER9 CPU via an NV

Re: [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100

2018-08-08 Thread Alexey Kardashevskiy
On 08/08/2018 18:39, Alexey Kardashevskiy wrote: > > > On 02/08/2018 02:16, Alex Williamson wrote: >> On Wed, 1 Aug 2018 18:37:35 +1000 >> Alexey Kardashevskiy wrote: >> >>> On 01/08/2018 00:29, Alex Williamson wrote: >>>> On Tue, 31 Jul 2018

Re: [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100

2018-08-08 Thread Alexey Kardashevskiy
On 02/08/2018 02:16, Alex Williamson wrote: > On Wed, 1 Aug 2018 18:37:35 +1000 > Alexey Kardashevskiy wrote: > >> On 01/08/2018 00:29, Alex Williamson wrote: >>> On Tue, 31 Jul 2018 14:03:35 +1000 >>> Alexey Kardashevskiy wrote: >>> >&

Re: [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100

2018-08-01 Thread Alexey Kardashevskiy
On 01/08/2018 00:29, Alex Williamson wrote: > On Tue, 31 Jul 2018 14:03:35 +1000 > Alexey Kardashevskiy wrote: > >> On 31/07/2018 02:29, Alex Williamson wrote: >>> On Mon, 30 Jul 2018 18:58:49 +1000 >>> Alexey Kardashevskiy wrote: >>>> After so

Re: [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100

2018-07-30 Thread Alexey Kardashevskiy
On 31/07/2018 02:29, Alex Williamson wrote: > On Mon, 30 Jul 2018 18:58:49 +1000 > Alexey Kardashevskiy wrote: > >> On 11/07/2018 19:26, Alexey Kardashevskiy wrote: >>> On Tue, 10 Jul 2018 16:37:15 -0600 >>> Alex Williamson wrote: >>> >>&

Re: [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100

2018-07-30 Thread Alexey Kardashevskiy
On 11/07/2018 19:26, Alexey Kardashevskiy wrote: > On Tue, 10 Jul 2018 16:37:15 -0600 > Alex Williamson wrote: > >> On Tue, 10 Jul 2018 14:10:20 +1000 >> Alexey Kardashevskiy wrote: >> >>> On Thu, 7 Jun 2018 23:03:23 -0600 >>> Alex Williamson w

[PATCH kernel RFC 3/3] powerpc/pseries/iommu: Use memory@ nodes in max RAM address calculation

2018-07-25 Thread Alexey Kardashevskiy
he drconf chunk is easily getting bigger that a megabyte. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 43 +- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/pl

[PATCH kernel RFC 0/3] powerpc/pseries/iommu: GPU coherent memory pass through

2018-07-25 Thread Alexey Kardashevskiy
s than 50bits for DMA address space) and cover not just present memory but also this new coherent memory. This is based on sha1 d72e90f3 Linus Torvalds "Linux 4.18-rc6". Please comment. Thanks. Alexey Kardashevskiy (3): powerpc/pseries/iommu: Allow dynamic window to start from zero

[PATCH kernel RFC 2/3] powerpc/pseries/iommu: Force default DMA window removal

2018-07-25 Thread Alexey Kardashevskiy
hat this patch does. This makes use of the latter approach and exploits a new "qemu,dma-force-remove-default" flag in a vPHB. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 26 +++--- 1 file changed, 23 insertions(+), 3 deletions(-) d

[PATCH kernel RFC 1/3] powerpc/pseries/iommu: Allow dynamic window to start from zero

2018-07-25 Thread Alexey Kardashevskiy
only at 1<<59, we will need to be able to create bigger windows starting from zero. This does the initial preparation and should not cause any behavioral changes. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/pseries/iommu.c | 8 +--- 1 file changed, 5 insertions

[PATCH kernel for v4.14 and v4.17 stable] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-23 Thread Alexey Kardashevskiy
# v4.12+ Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson Signed-off-by: Michael Ellerman (cherry picked from commit 76fa4975f3ed12d15762bc979ca44078598ed8ee) Signed-off-by: Alexey Kardashevskiy --- The original patch did not apply because of fad953ce which fixed all vmalloc'

[PATCH kernel v7 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-17 Thread Alexey Kardashevskiy
ed by find_linux_pte() which indicates how the page is mapped to the current userspace - if the page is huge and this is not a zero, then it is a leaf pte and the page is mapped within the range. Signed-off-by: Alexey Kardashevskiy --- v6 got a couple of rb's but since the patch has changed again

[PATCH kernel v7 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-17 Thread Alexey Kardashevskiy
ound pages before calling compound_order() This is based on sha1 9d3cce1 Linus Torvalds "Linux 4.18-rc5". Please comment. Thanks. Alexey Kardashevskiy (2): vfio/spapr: Use IOMMU pageshift rather than pagesize KVM: PPC: Check if IOMMU page is contained in the pinned physical page

[PATCH kernel v7 1/2] vfio/spapr: Use IOMMU pageshift rather than pagesize

2018-07-17 Thread Alexey Kardashevskiy
The size is always equal to 1 page so let's use this. Later on this will be used for other checks which use page shifts to check the granularity of access. This should cause no behavioral change. Reviewed-by: David Gibson Acked-by: Alex Williamson Signed-off-by: Alexey Kardashevskiy --

Re: [PATCH kernel] powerpc/ioda/npu2: Call hot reset skiboot hook when disabling NPU

2018-07-14 Thread Alexey Kardashevskiy
On Thu, 12 Jul 2018 11:38:34 +1000 Alistair Popple wrote: > Hi Alexey, > > On Wednesday, 11 July 2018 7:45:10 PM AEST Alexey Kardashevskiy wrote: > > On Thu, 7 Jun 2018 17:06:07 +1000 > > Alexey Kardashevskiy wrote: > > > > > This brings NPU2 in a saf

Re: [PATCH kernel v3 0/6] powerpc/powernv/iommu: Optimize memory use

2018-07-12 Thread Alexey Kardashevskiy
On Wed, 4 Jul 2018 16:13:43 +1000 Alexey Kardashevskiy wrote: > This patchset aims to reduce actual memory use for guests with > sparse memory. The pseries guest uses dynamic DMA windows to map > the entire guest RAM but it only actually maps onlined memory > which may be not be c

[PATCH kernel] KVM: PPC: Expose userspace mm context id via debugfs

2018-07-12 Thread Alexey Kardashevskiy
This adds a debugfs entry with mm context id of a process which is using KVM. This id is an index in the process table so the userspace can dump that tree provided it is granted access to /dev/mem. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/kvm_host.h | 1 + arch/powerpc

Re: [PATCH kernel] powerpc/powernv/ioda2: Add 256M IOMMU page size to the default POWER8 case

2018-07-11 Thread Alexey Kardashevskiy
On Mon, 2 Jul 2018 17:42:05 +1000 Alexey Kardashevskiy wrote: > The sketchy bypass uses 256M pages so add this page size as well. > > This should cause no behavioral change but will be used later. > > Fixes: 477afd6ea6 "powerpc/ioda: Use ibm,supported-tce-sizes for IOM

[PATCH kernel v6 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-11 Thread Alexey Kardashevskiy
s Torvalds "Linux 4.18-rc4". Please comment. Thanks. Alexey Kardashevskiy (2): vfio/spapr: Use IOMMU pageshift rather than pagesize KVM: PPC: Check if IOMMU page is contained in the pinned physical page arch/powerpc/include/asm/mmu_context.h | 4 ++-- arch/powerpc/kvm/book3s_64_vio.c

[PATCH kernel v6 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-11 Thread Alexey Kardashevskiy
ed by find_linux_pte() which indicates how the page is mapped to the current userspace - if the page is huge and this is not a zero, then it is a leaf pte and the page is mapped within the range. Signed-off-by: Alexey Kardashevskiy --- Changes: v6: * replaced hugetlbfs with pageshift from find_linux_pte(

[PATCH kernel v6 1/2] vfio/spapr: Use IOMMU pageshift rather than pagesize

2018-07-11 Thread Alexey Kardashevskiy
The size is always equal to 1 page so let's use this. Later on this will be used for other checks which use page shifts to check the granularity of access. This should cause no behavioral change. Reviewed-by: David Gibson Acked-by: Alex Williamson Signed-off-by: Alexey Kardashevskiy --

Re: [PATCH kernel] powerpc/ioda/npu2: Call hot reset skiboot hook when disabling NPU

2018-07-11 Thread Alexey Kardashevskiy
On Thu, 7 Jun 2018 17:06:07 +1000 Alexey Kardashevskiy wrote: > This brings NPU2 in a safe mode when it does not throw HMI if GPU > coherent memory is gone. > > Signed-off-by: Alexey Kardashevskiy Anyone, ping? > --- > > The main aim for this is nvlink2 pass

Re: [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100

2018-07-11 Thread Alexey Kardashevskiy
On Tue, 10 Jul 2018 16:37:15 -0600 Alex Williamson wrote: > On Tue, 10 Jul 2018 14:10:20 +1000 > Alexey Kardashevskiy wrote: > > > On Thu, 7 Jun 2018 23:03:23 -0600 > > Alex Williamson wrote: > > > > > On Fri, 8 Jun 2018 14:14:23 +10

Re: [RFC PATCH kernel 0/5] powerpc/P9/vfio: Pass through NVIDIA Tesla V100

2018-07-09 Thread Alexey Kardashevskiy
On Thu, 7 Jun 2018 23:03:23 -0600 Alex Williamson wrote: > On Fri, 8 Jun 2018 14:14:23 +1000 > Alexey Kardashevskiy wrote: > > > On 8/6/18 1:44 pm, Alex Williamson wrote: > > > On Fri, 8 Jun 2018 13:08:54 +1000 > > > Alexey Kardashevskiy wrote: > >

Re: [PATCH kernel v5 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-07 Thread Alexey Kardashevskiy
On Sat, 7 Jul 2018 21:43:03 +1000 Nicholas Piggin wrote: > On Sat, 7 Jul 2018 20:44:10 +1000 > Alexey Kardashevskiy wrote: > > > A VM which has: > > - a DMA capable device passed through to it (eg. network card); > > - running a malicious kernel tha

[PATCH kernel v5 1/2] vfio/spapr: Use IOMMU pageshift rather than pagesize

2018-07-07 Thread Alexey Kardashevskiy
The size is always equal to 1 page so let's use this. Later on this will be used for other checks which use page shifts to check the granularity of access. This should cause no behavioral change. Reviewed-by: David Gibson Acked-by: Alex Williamson Signed-off-by: Alexey Kardashevskiy --

[PATCH kernel v5 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-07 Thread Alexey Kardashevskiy
llest preregistered page size in the preregistered region descriptor and changes the mm_iommu_xxx API to check this against the IOMMU page size. This calculates maximum page size as a minimum of the natural region alignment and hugepagetlb's compound page size. Signed-off-by: Alexey Kardashevskiy -

[PATCH kernel v5 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-07 Thread Alexey Kardashevskiy
ease comment. Thanks. Alexey Kardashevskiy (2): vfio/spapr: Use IOMMU pageshift rather than pagesize KVM: PPC: Check if IOMMU page is contained in the pinned physical page arch/powerpc/include/asm/mmu_context.h | 4 ++-- arch/powerpc/kvm/book3s_64_vio.c | 2 +- arch/powerpc/kv

Re: [PATCH kernel v3 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-05 Thread Alexey Kardashevskiy
On Thu, 5 Jul 2018 15:19:04 +1000 Alexey Kardashevskiy wrote: > On Thu, 5 Jul 2018 12:42:20 +1000 > David Gibson wrote: > > > On Wed, Jul 04, 2018 at 03:00:52PM +1000, Alexey Kardashevskiy wrote: > > > A VM which has: > > > - a DMA capable device passe

[PATCH kernel v4 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-05 Thread Alexey Kardashevskiy
llest preregistered page size in the preregistered region descriptor and changes the mm_iommu_xxx API to check this against the IOMMU page size. This calculates maximum page size as a minimum of the natural region alignment and compound page size. Signed-off-by: Alexey Kardashevskiy --- Change

[PATCH kernel v4 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-05 Thread Alexey Kardashevskiy
v3: * enforced huge pages not to cross preregistered chunk boundaries v2: * 2/2: explicitly check for compound pages before calling compound_order() This is based on sha1 021c917 Linus Torvalds "Linux 4.18-rc3". Please comment. Thanks. Alexey Kardashevskiy (2): vfio/spapr:

[PATCH kernel v4 1/2] vfio/spapr: Use IOMMU pageshift rather than pagesize

2018-07-05 Thread Alexey Kardashevskiy
The size is always equal to 1 page so let's use this. Later on this will be used for other checks which use page shifts to check the granularity of access. This should cause no behavioral change. Reviewed-by: David Gibson Acked-by: Alex Williamson Signed-off-by: Alexey Kardashevskiy --

Re: [PATCH kernel v3 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-04 Thread Alexey Kardashevskiy
On Thu, 5 Jul 2018 12:42:20 +1000 David Gibson wrote: > On Wed, Jul 04, 2018 at 03:00:52PM +1000, Alexey Kardashevskiy wrote: > > A VM which has: > > - a DMA capable device passed through to it (eg. network card); > > - running a malicious kernel that igno

[PATCH kernel v3 3/6] KVM: PPC: Make iommu_table::it_userspace big endian

2018-07-03 Thread Alexey Kardashevskiy
We are going to reuse multilevel TCE code for the userspace copy of the TCE table and since it is big endian, let's make the copy big endian too. Reviewed-by: David Gibson Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/include/asm/iommu.h| 2 +- arch/powerpc/kvm/book3s_64_

[PATCH kernel v3 2/6] powerpc/powernv: Move TCE manupulation code to its own file

2018-07-03 Thread Alexey Kardashevskiy
. Reviewed-by: David Gibson Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/Makefile | 2 +- arch/powerpc/platforms/powernv/pci.h | 41 ++-- arch/powerpc/platforms/powernv/pci-ioda-tce.c | 313 ++ arch/powerpc/platforms/powernv

[PATCH kernel v3 0/6] powerpc/powernv/iommu: Optimize memory use

2018-07-03 Thread Alexey Kardashevskiy
6/6 This is based on sha1 021c917 Linus Torvalds "Linux 4.18-rc3". Please comment. Thanks. Alexey Kardashevskiy (6): powerpc/powernv: Remove useless wrapper powerpc/powernv: Move TCE manupulation code to its own file KVM: PPC: Make iommu_table::it_userspace big endian power

[PATCH kernel v3 6/6] powerpc/powernv/ioda: Allocate indirect TCE levels on demand

2018-07-03 Thread Alexey Kardashevskiy
((0x4 + 0x4) >> 16)*8)>>20 = 4MB (plus some for indirect levels). Signed-off-by: Alexey Kardashevskiy Reviewed-by: David Gibson --- Changes: v2: * fixed bug in cleanup path which forced the entire table to be allocated right before destroying * added memory alloca

[PATCH kernel v3 5/6] powerpc/powernv: Rework TCE level allocation

2018-07-03 Thread Alexey Kardashevskiy
This moves actual pages allocation to a separate function which is going to be reused later in on-demand TCE allocation. While we are at it, remove unnecessary level size round up as the caller does this already. Reviewed-by: David Gibson Signed-off-by: Alexey Kardashevskiy --- arch/powerpc

[PATCH kernel v3 4/6] powerpc/powernv: Add indirect levels to it_userspace

2018-07-03 Thread Alexey Kardashevskiy
hould not change non-KVM handling of TCE tables and it_userspace will not be allocated for non-KVM tables. Reviewed-by: David Gibson Signed-off-by: Alexey Kardashevskiy --- Changes: v2: * fixed compile error by ditching one inline helper --- arch/powerpc/include/asm/iommu.h | 6 +--

[PATCH kernel v3 1/6] powerpc/powernv: Remove useless wrapper

2018-07-03 Thread Alexey Kardashevskiy
This gets rid of a useless wrapper around pnv_pci_ioda2_table_free_pages(). Reviewed-by: David Gibson Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/pci-ioda.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/arch/powerpc/platforms/powernv/pci

[PATCH kernel v3 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-03 Thread Alexey Kardashevskiy
this defaults to PAGE_SIZE. Signed-off-by: Alexey Kardashevskiy --- Changes: v3: * fixed upper limit for the page size * added checks that we don't register parts of a huge page v2: * explicitely check for compound pages before calling compound_order() --- The bug is: run QEMU _without_ hug

[PATCH kernel v3 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-03 Thread Alexey Kardashevskiy
: explicitly check for compound pages before calling compound_order() This is based on sha1 021c917 Linus Torvalds "Linux 4.18-rc3". Please comment. Thanks. Alexey Kardashevskiy (2): vfio/spapr: Use IOMMU pageshift rather than pagesize KVM: PPC: Check if IOMMU page is contai

[PATCH kernel v3 1/2] vfio/spapr: Use IOMMU pageshift rather than pagesize

2018-07-03 Thread Alexey Kardashevskiy
The size is always equal to 1 page so let's use this. Later on this will be used for other checks which use page shifts to check the granularity of access. This should cause no behavioral change. Reviewed-by: David Gibson Acked-by: Alex Williamson Signed-off-by: Alexey Kardashevskiy --

Re: [PATCH kernel 1/2] powerpc/powernv: Reuse existing TCE code for sketchy bypass

2018-07-02 Thread Alexey Kardashevskiy
On Sat, 16 Jun 2018 11:04:32 +1000 Benjamin Herrenschmidt wrote: > On Fri, 2018-06-01 at 18:10 +1000, Alexey Kardashevskiy wrote: > > The existing sketchy bypass ignores the existing default 32bit TCE table > > (created by default for every PE at boot time or after being used by &

Re: [PATCH 2/3] powerpc/powernv: DMA operations for discontiguous allocation

2018-07-02 Thread Alexey Kardashevskiy
On Fri, 29 Jun 2018 17:34:36 +1000 Russell Currey wrote: > DMA pseudo-bypass is a new set of DMA operations that solve some issues for > devices that want to address more than 32 bits but can't address the 59 > bits required to enable direct DMA. > > The previous implementation for POWER8/PHB3 w

[PATCH kernel] powerpc/powernv/ioda2: Add 256M IOMMU page size to the default POWER8 case

2018-07-02 Thread Alexey Kardashevskiy
The sketchy bypass uses 256M pages so add this page size as well. This should cause no behavioral change but will be used later. Fixes: 477afd6ea6 "powerpc/ioda: Use ibm,supported-tce-sizes for IOMMU page size mask" Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/p

Re: [PATCH 1/3] powerpc/powernv/pci: Track largest available TCE order per PHB

2018-07-02 Thread Alexey Kardashevskiy
On Mon, 2 Jul 2018 17:32:56 +1000 Alexey Kardashevskiy wrote: > On Fri, 29 Jun 2018 17:34:35 +1000 > Russell Currey wrote: > > > Knowing the largest possible TCE size of a PHB is useful, so get it > > out of the device tree. This relies on the property being added in >

Re: [PATCH 1/3] powerpc/powernv/pci: Track largest available TCE order per PHB

2018-07-02 Thread Alexey Kardashevskiy
On Fri, 29 Jun 2018 17:34:35 +1000 Russell Currey wrote: > Knowing the largest possible TCE size of a PHB is useful, so get it out > of the device tree. This relies on the property being added in OPAL. > > It is assumed that any PHB4 or later machine would be running firmware > that implemented

Re: [PATCH kernel v2 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-01 Thread Alexey Kardashevskiy
On Mon, 2 Jul 2018 14:52:43 +1000 David Gibson wrote: > On Mon, Jul 02, 2018 at 02:33:30PM +1000, Alexey Kardashevskiy wrote: > > On Mon, 2 Jul 2018 14:08:52 +1000 > > David Gibson wrote: > > > > > On Fri, Jun 29, 2018 at 05:07:47PM +1000, Alexey Kardashevskiy w

Re: [PATCH kernel v2 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-07-01 Thread Alexey Kardashevskiy
On Mon, 2 Jul 2018 14:08:52 +1000 David Gibson wrote: > On Fri, Jun 29, 2018 at 05:07:47PM +1000, Alexey Kardashevskiy wrote: > > On Fri, 29 Jun 2018 15:18:20 +1000 > > Alexey Kardashevskiy wrote: > > > > > On Fri, 29 Jun 2018 14:57:02 +1000 > > > David

Re: [PATCH kernel v2 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-06-29 Thread Alexey Kardashevskiy
On Fri, 29 Jun 2018 15:18:20 +1000 Alexey Kardashevskiy wrote: > On Fri, 29 Jun 2018 14:57:02 +1000 > David Gibson wrote: > > > On Fri, Jun 29, 2018 at 02:51:21PM +1000, Alexey Kardashevskiy wrote: > > > On Fri, 29 Jun 2018 14:12:41 +1000 > > > David Gibson

Re: [PATCH kernel v2 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-06-28 Thread Alexey Kardashevskiy
On Fri, 29 Jun 2018 14:57:02 +1000 David Gibson wrote: > On Fri, Jun 29, 2018 at 02:51:21PM +1000, Alexey Kardashevskiy wrote: > > On Fri, 29 Jun 2018 14:12:41 +1000 > > David Gibson wrote: > > > > > On Tue, Jun 26, 2018 at 03:59:26PM +1000, Alexey Kardashevsk

Re: [PATCH kernel v2 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-06-28 Thread Alexey Kardashevskiy
On Fri, 29 Jun 2018 14:12:41 +1000 David Gibson wrote: > On Tue, Jun 26, 2018 at 03:59:26PM +1000, Alexey Kardashevskiy wrote: > > We already have a check in drivers/vfio/vfio_iommu_spapr_tce.c that > > an IOMMU page is contained in the physical page so the PCI hardware won'

Re: [PATCH kernel v2 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-06-28 Thread Alexey Kardashevskiy
On Fri, 29 Jun 2018 11:55:40 +1000 Michael Ellerman wrote: > Alexey Kardashevskiy writes: > > > This is to improve page boundaries checking and should probably > > be cc:stable. I came accross this while debugging nvlink2 passthrough > > but the lack of checking m

[PATCH kernel v2 2/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-06-25 Thread Alexey Kardashevskiy
fails because of the check in vfio_iommu_spapr_tce.c which is really sustainable solution. This stores the smallest preregistered page size in the preregistered region descriptor and changes the mm_iommu_xxx API to check this against the IOMMU page size. Signed-off-by: Alexey Kardashevskiy --- Change

[PATCH kernel v2 1/2] vfio/spapr: Use IOMMU pageshift rather than pagesize

2018-06-25 Thread Alexey Kardashevskiy
The size is always equal to 1 page so let's use this. Later on this will be used for other checks which use page shifts to check the granularity of access. This should cause no behavioral change. Reviewed-by: David Gibson Signed-off-by: Alexey Kardashevskiy --- drivers

[PATCH kernel v2 0/2] KVM: PPC: Check if IOMMU page is contained in the pinned physical page

2018-06-25 Thread Alexey Kardashevskiy
() Please comment. Thanks. Alexey Kardashevskiy (2): vfio/spapr: Use IOMMU pageshift rather than pagesize KVM: PPC: Check if IOMMU page is contained in the pinned physical page arch/powerpc/include/asm/mmu_context.h | 4 ++-- arch/powerpc/kvm/book3s_64_vio.c | 2 +- arch/powerpc/kvm

<    5   6   7   8   9   10   11   12   13   14   >