Re: cleanup swiotlb initialization v8

2022-04-06 Thread Konrad Rzeszutek Wilk
1 > - better document the lower bound swiotlb size for xen-swiotlb > - improve the nslabs calculation for the retry case in >swiotlb_init_remap and swiotlb_init_late Hey Christoph, Feel free to tack on Reviewed-by: Konrad Rzeszutek Wilk on them if you would lik

Re: [PATCH 10/15] swiotlb: add a SWIOTLB_ANY flag to lift the low memory restriction

2022-04-06 Thread Konrad Rzeszutek Wilk
nder why the '|=' instead of just '=' ? Either way: Reviewed-by: Konrad Rzeszutek Wilk Thank you! ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 07/15] x86: remove the IOMMU table infrastructure

2022-04-06 Thread Konrad Rzeszutek Wilk
more 'structured' way with dependencies. Hence this creation... But as Christoph points out - it has gotten out of hand. So smashing it back to a more simplistic mechanism is good. Reviewed-by: Konrad Rzeszutek Wilk Thank you! > --- > arch/ia64/include/asm/iommu_table.h| 7 -- > arch

Re: [PATCH 07/11] x86: remove the IOMMU table infrastructure

2022-03-01 Thread Konrad Rzeszutek Wilk
> -#include > - > -/* > - * History lesson: > - * The execution chain of IOMMUs in 2.6.36 looks as so: > - * > - *[xen-swiotlb] > - * | > - * +[swiotlb *]--+ > - */ | \ > - * / | \ > - *[GART]

Re: [PATCH] swiotlb: allocate memory in a cache-friendly way

2021-09-16 Thread Konrad Rzeszutek Wilk
On Wed, Sep 01, 2021 at 12:21:35PM +0800, Chao Gao wrote: > Currently, swiotlb uses a global index to indicate the starting point > of next search. The index increases from 0 to the number of slots - 1 > and then wraps around. It is straightforward but not cache-friendly > because the "oldest"

Re: [PATCH] swiotlb: use depends on for DMA_RESTRICTED_POOL

2021-08-31 Thread Konrad Rzeszutek Wilk
On Tue, Aug 31, 2021 at 04:17:47PM +0100, Will Deacon wrote: > On Fri, Aug 27, 2021 at 11:48:02AM +0800, Claire Chang wrote: > > Use depends on instead of select for DMA_RESTRICTED_POOL; otherwise it > > will make SWIOTLB user configurable and cause compile errors for some > > arch (e.g. mips). >

Re: [PATCH v2 0/2] Don't fail device probing due to of_dma_set_restricted_buffer()

2021-08-23 Thread Konrad Rzeszutek Wilk
fer() into of/device.c (Rob) > * Use IS_ENABLED() instead of 'static inline' stub (Rob) > > This applies on Konrad's devel/for-linus-5.15 branch in swiotlb.git It should show up later today. Thanks! > > Cheers, > > Will > > Cc: Claire Chang > Cc: Konrad Rzeszutek Wilk

Re: [PATCH v2 4/4] swiotlb: Free tbl memory in swiotlb_exit()

2021-07-31 Thread Konrad Rzeszutek Wilk
, and should therefore be gated by mem_encrypt_active() to mirror the x86 implementation. Cc: Konrad Rzeszutek Wilk Cc: Claire Chang Cc: Christoph Hellwig Cc: Robin Murphy Fixes: ad6c00283163 ("swiotlb: Free tbl memory in swiotlb_exit()") Suggested-by: Nicholas Piggin Reported-

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

2021-07-29 Thread Konrad Rzeszutek Wilk
On Thu, Jul 29, 2021 at 05:13:36PM +0100, Will Deacon wrote: > On Wed, Jul 28, 2021 at 10:35:34AM -0700, Nathan Chancellor wrote: > > On Wed, Jul 28, 2021 at 01:31:06PM +0530, Sachin Sant wrote: > > > next-20210723 was good. The boot failure seems to have been introduced > > > with next-20210726.

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

2021-07-29 Thread Konrad Rzeszutek Wilk
On Wed, Jul 28, 2021 at 10:52:25AM -0400, Tianyu Lan wrote: > 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

Re: [PATCH v2 0/4] Fix restricted DMA vs swiotlb_exit()

2021-07-23 Thread Konrad Rzeszutek Wilk
On Tue, Jul 20, 2021 at 02:38:22PM +0100, Will Deacon wrote: > Hi again, folks, > > This is version two of the patch series I posted yesterday: > > https://lore.kernel.org/r/20210719123054.6844-1-w...@kernel.org > > The only changes since v1 are: > > * Squash patches 2 and 3, amending the

Re: [PATCH v2 1/1] s390/pv: fix the forcing of the swiotlb

2021-07-23 Thread Konrad Rzeszutek Wilk
On Sat, Jul 24, 2021 at 01:17:46AM +0200, Halil Pasic wrote: > Since commit 903cd0f315fe ("swiotlb: Use is_swiotlb_force_bounce for > swiotlb data bouncing") if code sets swiotlb_force it needs to do so > before the swiotlb is initialised. Otherwise > io_tlb_default_mem->force_bounce will not get

Re: [PATCH v2 0/4] Fix restricted DMA vs swiotlb_exit()

2021-07-23 Thread Konrad Rzeszutek Wilk
On Fri, Jul 23, 2021 at 10:50:57AM +0200, Christian Borntraeger wrote: > > > On 23.07.21 10:47, Halil Pasic wrote: > > On Fri, 23 Jul 2021 08:14:19 +0200 > > Christian Borntraeger wrote: > > > > > Resending with the correct email of Heiko > > > > > > On 23.07.21 03:12, Halil Pasic wrote:

Re: [PATCH v2] dma-mapping: use vmalloc_to_page for vmalloc addresses

2021-07-13 Thread Konrad Rzeszutek Wilk
On Tue, Jun 22, 2021 at 04:34:14PM +0300, Roman Skakun wrote: > This commit is dedicated to fix incorrect conversion from > cpu_addr to page address in cases when we get virtual > address which allocated in the vmalloc range. > As the result, virt_to_page() cannot convert this address > properly

Re: [PATCH v15 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-07-13 Thread Konrad Rzeszutek Wilk
..snip.. > > > I think the main question I have is how would you like to see patches for > > > 5.15? i.e. as patches on top of devel/for-linus-5.14 or something else? > > > > Yes that would be perfect. If there are any dependencies on the rc1, I > > can rebase it on top of that. > > Yes, please,

Re: [PATCH] iommu/amd: Enable swiotlb if any device supports iommu v2 and uses identity mapping

2021-07-13 Thread Konrad Rzeszutek Wilk
On Thu, Jul 08, 2021 at 03:43:42PM +0100, Robin Murphy wrote: > On 2021-07-08 14:57, Kai-Heng Feng wrote: > > On Thu, Jul 8, 2021 at 6:18 PM Robin Murphy wrote: > > > > > > On 2021-07-08 10:28, Joerg Roedel wrote: > > > > On Thu, Jul 08, 2021 at 03:42:32PM +0800, Kai-Heng Feng wrote: > > > > >

Re: [PATCH] swiotlb: add overflow checks to swiotlb_bounce

2021-07-13 Thread Konrad Rzeszutek Wilk
_addr > > Both should never happen so print a warning and bail out without trying > to adjust the sizes/offsets: the first one could try to sync from > orig_addr to whatever is left of the requested size, but the later > really has nothing to sync there... > > Signed-off-by: Dominique

Re: [PATCH v15 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-07-06 Thread Konrad Rzeszutek Wilk
On Tue, Jul 06, 2021 at 05:57:21PM +0100, Will Deacon wrote: > On Tue, Jul 06, 2021 at 10:46:07AM -0400, Konrad Rzeszutek Wilk wrote: > > On Tue, Jul 06, 2021 at 04:05:13PM +0200, Christoph Hellwig wrote: > > > On Tue, Jul 06, 2021 at 03:01:04PM +0100, Robin Murphy wro

Re: [PATCH v15 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-07-06 Thread Konrad Rzeszutek Wilk
On Tue, Jul 06, 2021 at 04:05:13PM +0200, Christoph Hellwig wrote: > On Tue, Jul 06, 2021 at 03:01:04PM +0100, Robin Murphy wrote: > > FWIW I was pondering the question of whether to do something along those > > lines or just scrap the default assignment entirely, so since I hadn't got > > round

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Konrad Rzeszutek Wilk
On Thu, Jun 24, 2021 at 11:58:57PM +0800, Claire Chang wrote: > On Thu, Jun 24, 2021 at 11:56 PM Konrad Rzeszutek Wilk > wrote: > > > > On Thu, Jun 24, 2021 at 10:10:51AM -0400, Qian Cai wrote: > > > > > > > > > On 6/24/2021 7:48 AM, Will Deacon

Re: [PATCH v15 00/12] Restricted DMA

2021-06-24 Thread Konrad Rzeszutek Wilk
On Thu, Jun 24, 2021 at 11:55:14PM +0800, Claire Chang wrote: > This series implements mitigations for lack of DMA access control on > systems without an IOMMU, which could result in the DMA accessing the > system memory at unexpected times and/or unexpected addresses, possibly > leading to data

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Konrad Rzeszutek Wilk
On Thu, Jun 24, 2021 at 10:10:51AM -0400, Qian Cai wrote: > > > On 6/24/2021 7:48 AM, Will Deacon wrote: > > Ok, diff below which attempts to tackle the offset issue I mentioned as > > well. Qian Cai -- please can you try with these changes? > > This works fine. Cool. Let me squash this patch

Re: [PATCH v14 00/12] Restricted DMA

2021-06-23 Thread Konrad Rzeszutek Wilk
On Sat, Jun 19, 2021 at 11:40:31AM +0800, Claire Chang wrote: > This series implements mitigations for lack of DMA access control on > systems without an IOMMU, which could result in the DMA accessing the > system memory at unexpected times and/or unexpected addresses, possibly > leading to data

[GIT PULL] (stable) stable/for-linus-5.14

2021-06-22 Thread Konrad Rzeszutek Wilk
Hey Linus, Please git pull the following branch: git pull git://git.kernel.org/pub/scm/linux/kernel/git/konrad/swiotlb.git stable/for-linus-5.14 which has the regression for the DMA operations where the offset was ignored and corruptions would appear. Going forward there will be a cleanups to

Re: swiotlb/caamjr regression (Was: [GIT PULL] (swiotlb) stable/for-linus-5.12)

2021-06-22 Thread Konrad Rzeszutek Wilk
On Tue, Jun 22, 2021 at 04:48:24PM +0900, 'Dominique MARTINET' wrote: > Konrad Rzeszutek Wilk wrote on Mon, Jun 21, 2021 at 09:16:43AM -0400: > > The beaty of 'devel' and 'linux-next' is that they can be reshuffled and > > mangled. I pushed them original patch from Bumyong the

Re: swiotlb/caamjr regression (Was: [GIT PULL] (swiotlb) stable/for-linus-5.12)

2021-06-21 Thread Konrad Rzeszutek Wilk
On Mon, Jun 21, 2021 at 01:14:48PM +0900, 'Dominique MARTINET' wrote: > Chanho Park wrote on Mon, Jun 21, 2021 at 11:55:22AM +0900: > > Sure. No problem. But, the patch was already stacked on Konrad's tree > > and linux-next as well. > > > >

Re: swiotlb/caamjr regression (Was: [GIT PULL] (swiotlb) stable/for-linus-5.12)

2021-06-16 Thread Konrad Rzeszutek Wilk
On Wed, Jun 16, 2021 at 01:49:54PM -0700, Jianxiong Gao wrote: > On Fri, Jun 11, 2021 at 3:35 AM Konrad Rzeszutek Wilk > wrote: > > > > On Fri, Jun 11, 2021 at 08:21:53AM +0200, Christoph Hellwig wrote: > > > On Thu, Jun 10, 2021 at 05:52:07PM +0300, Horia Geantă

Re: [PATCH v10 03/12] swiotlb: Set dev->dma_io_tlb_mem to the swiotlb pool used

2021-06-15 Thread Konrad Rzeszutek Wilk
On Tue, Jun 15, 2021 at 09:27:02PM +0800, Claire Chang wrote: > Always have the pointer to the swiotlb pool used in struct device. This > could help simplify the code for other pools. Applying: swiotlb: Set dev->dma_io_tlb_mem to the swiotlb pool used error: patch failed: kernel/dma/swiotlb.c:339

Re: swiotlb/caamjr regression (Was: [GIT PULL] (swiotlb) stable/for-linus-5.12)

2021-06-11 Thread Konrad Rzeszutek Wilk
Linus's, so incorporating his text] Fixes: 16fc3cef33a0 ("swiotlb: don't modify orig_addr in swiotlb_tbl_sync_single") Signed-off-by: Bumyong Lee Signed-off-by: Chanho Park Reviewed-by: Christoph Hellwig Reported-by: Dominique MARTINET Reported-by: Horia Geantă Tested-by: Horia G

Re: [PATCH v1 5/8] dma: Use size for swiotlb boundary checks

2021-06-02 Thread Konrad Rzeszutek Wilk
On Wed, Jun 02, 2021 at 05:41:30PM -0700, Andi Kleen wrote: > swiotlb currently only uses the start address of a DMA to check if something > is in the swiotlb or not. But with virtio and untrusted hosts the host > could give some DMA mapping that crosses the swiotlb boundaries, > potentially

Re: [PATCH v7 01/15] swiotlb: Refactor swiotlb init functions

2021-05-24 Thread Konrad Rzeszutek Wilk
> > do the set_memory_decrypted()+memset(). Is this okay or should > > swiotlb_init_io_tlb_mem() add an additional argument to do this > > conditionally? > > I'm actually not sure if this it okay. If not, will add an additional > argument for it. Any observations discovered? (Want to make sure

Re: [PATCH v7 05/15] swiotlb: Add a new get_io_tlb_mem getter

2021-05-24 Thread Konrad Rzeszutek Wilk
On Tue, May 18, 2021 at 02:51:52PM +0800, Claire Chang wrote: > Still keep this function because directly using dev->dma_io_tlb_mem > will cause issues for memory allocation for existing devices. The pool > can't support atomic coherent allocation so we need to distinguish the > per device pool

Re: [PATCH v7 04/15] swiotlb: Add restricted DMA pool initialization

2021-05-24 Thread Konrad Rzeszutek Wilk
On Tue, May 18, 2021 at 02:48:35PM +0800, Claire Chang wrote: > I didn't move this to a separate file because I feel it might be > confusing for swiotlb_alloc/free (and need more functions to be > non-static). > Maybe instead of moving to a separate file, we can try to come up with > a better

Re: i915 and swiotlb_max_segment

2021-05-20 Thread Konrad Rzeszutek Wilk
On Mon, May 10, 2021 at 05:25:25PM +0200, Christoph Hellwig wrote: > Hi all, > > swiotlb_max_segment is a rather strange "API" export by swiotlb.c, > and i915 is the only (remaining) user. > > swiotlb_max_segment returns 0 if swiotlb is not in use, 1 if > SWIOTLB_FORCE is set or swiotlb-zen is

Re: [PATCH] swiotlb: don't override user specified size in swiotlb_adjust_size

2021-04-29 Thread Konrad Rzeszutek Wilk
On Thu, Apr 29, 2021 at 08:45:51AM -0500, Tom Lendacky wrote: > On 4/29/21 1:28 AM, Christoph Hellwig wrote: > > If the user already specified a swiotlb size on the command line, > > swiotlb_adjust_size shoul not overwrite it. > > > > Fixes: 2cbc2776efe4 ("swiotlb: remove swiotlb_nr_tbl") > >

Re: [Resend RFC PATCH V2 09/12] swiotlb: Add bounce buffer remap address setting function

2021-04-15 Thread Konrad Rzeszutek Wilk
On Wed, Apr 14, 2021 at 10:49:42AM -0400, Tianyu Lan wrote: > From: Tianyu Lan > > For Hyper-V isolation VM with AMD SEV SNP, the bounce buffer(shared memory) > needs to be accessed via extra address space(e.g address above bit39). > Hyper-V code may remap extra address space outside of swiotlb.

Re: [Resend RFC PATCH V2 07/12] HV/Vmbus: Initialize VMbus ring buffer for Isolation VM

2021-04-15 Thread Konrad Rzeszutek Wilk
On Wed, Apr 14, 2021 at 10:49:40AM -0400, Tianyu Lan wrote: > 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

Re: [Resend RFC PATCH V2 06/12] HV/Vmbus: Add SNP support for VMbus channel initiate message

2021-04-15 Thread Konrad Rzeszutek Wilk
On Wed, Apr 14, 2021 at 10:49:39AM -0400, Tianyu Lan wrote: > From: Tianyu Lan > > The physical address of monitor pages in the CHANNELMSG_INITIATE_CONTACT > msg should be in the extra address space for SNP support and these What is this 'extra address space'? Is that just normal virtual

Re: [Resend RFC PATCH V2 04/12] HV: Add Write/Read MSR registers via ghcb

2021-04-15 Thread Konrad Rzeszutek Wilk
On Wed, Apr 14, 2021 at 10:49:37AM -0400, Tianyu Lan wrote: > From: Tianyu Lan > > Hyper-V provides GHCB protocol to write Synthetic Interrupt > Controller MSR registers and these registers are emulated by > Hypervisor rather than paravisor. What is paravisor? Is that the VMPL0 to borrow AMD

Re: [PATCH v3] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation

2021-04-09 Thread Konrad Rzeszutek Wilk
On Thu, Apr 08, 2021 at 08:13:07PM -0700, Florian Fainelli wrote: > > > On 3/24/2021 1:42 AM, Christoph Hellwig wrote: > > On Mon, Mar 22, 2021 at 06:53:49PM -0700, Florian Fainelli wrote: > >> When SWIOTLB_NO_FORCE is used, there should really be no allocations of > >> default_nslabs to occur

Re: [PATCH] ARM: Qualify enabling of swiotlb_init()

2021-04-01 Thread Konrad Rzeszutek Wilk
On Tue, Mar 30, 2021 at 07:36:07AM +0200, Christoph Hellwig wrote: > On Mon, Mar 29, 2021 at 12:30:42PM -0700, Florian Fainelli wrote: > > Should I toss this in Russell's patch tracker or do you need me to make > > some changes to the patch? > > Due to all the other changes in this area I don't

Re: [PATCH] ARM: Qualify enabling of swiotlb_init()

2021-03-19 Thread Konrad Rzeszutek Wilk
On Fri, Mar 19, 2021 at 02:07:31PM +0100, Christoph Hellwig wrote: > On Thu, Mar 18, 2021 at 09:03:33PM -0700, Florian Fainelli wrote: > > #ifdef CONFIG_ARM_LPAE > > + if (swiotlb_force == SWIOTLB_FORCE || > > + max_pfn > arm_dma_pfn_limit) > > Does arm_dma_pfn_limit do the right thing

Re: [PATCH] swiotlb: Make SWIOTLB_NO_FORCE perform no allocation

2021-03-18 Thread Konrad Rzeszutek Wilk
On Thu, Mar 18, 2021 at 09:00:54PM -0700, Florian Fainelli wrote: > When SWIOTLB_NO_FORCE is used, there should really be no allocations of > io_tlb_nslabs to occur since we are not going to use those slabs. If a > platform was somehow setting swiotlb_no_force and a later call to > swiotlb_init()

Re: [PATCH] swiotlb: Add swiotlb=off to disable SWIOTLB

2021-03-18 Thread Konrad Rzeszutek Wilk
> > > > In fact I should have looked more closely at that myself - checking > > debugfs on my 4GB arm64 board actually shows io_tlb_nslabs = 0, and > > indeed we are bypassing initialisation completely and (ab)using > > SWIOTLB_NO_FORCE to cover it up, so I guess it probably *is* safe now > > for

Re: [PATCH 12/14] swiotlb: move global variables into a new io_tlb_mem structure

2021-03-17 Thread Konrad Rzeszutek Wilk
On Wed, Mar 17, 2021 at 06:57:42PM +0100, Christoph Hellwig wrote: > On Wed, Mar 17, 2021 at 01:51:56PM -0400, Konrad Rzeszutek Wilk wrote: > > On Wed, Mar 17, 2021 at 02:53:27PM +0100, Christoph Hellwig wrote: > > > On Wed, Mar 17, 2021 at 01:42:07PM +, Konrad Rz

Re: [PATCH 12/14] swiotlb: move global variables into a new io_tlb_mem structure

2021-03-17 Thread Konrad Rzeszutek Wilk
On Wed, Mar 17, 2021 at 02:53:27PM +0100, Christoph Hellwig wrote: > On Wed, Mar 17, 2021 at 01:42:07PM +0000, Konrad Rzeszutek Wilk wrote: > > > - alloc_size = PAGE_ALIGN(io_tlb_nslabs * sizeof(size_t)); > > > - io_tlb_alloc_size = memblock_alloc(

Re: [PATCH 12/14] swiotlb: move global variables into a new io_tlb_mem structure

2021-03-17 Thread Konrad Rzeszutek Wilk
..snip.. > int __init swiotlb_init_with_tbl(char *tlb, unsigned long nslabs, int > verbose) > { ..snip.. > /* >* Allocate and initialize the free list array. This array is used >* to find contiguous free memory regions of size up to IO_TLB_SEGSIZE > - * between

Re: [PATCH 03/14] swiotlb: move orig addr and size validation into swiotlb_bounce

2021-03-16 Thread Konrad Rzeszutek Wilk
gt; a better code structure. Reviewed-by: Konrad Rzeszutek Wilk ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH 02/14] swiotlb: remove the alloc_size parameter to swiotlb_tbl_unmap_single

2021-03-16 Thread Konrad Rzeszutek Wilk
On Mon, Mar 01, 2021 at 08:44:24AM +0100, Christoph Hellwig wrote: > Now that swiotlb remembers the allocation size there is no need to pass > it back to swiotlb_tbl_unmap_single. Reviewed-by: Konrad Rzeszutek Wilk ___ iommu mailing list

Re: [PATCH] swiotlb: Fix type of max_slot

2021-03-02 Thread Konrad Rzeszutek Wilk
On 3/2/21 12:21 PM, Kunihiko Hayashi wrote: After the refactoring phase, the type of max_slot has changed from unsigned long to unsigned int. The return type of the function get_max_slots() and the 4th argument type of iommu_is_span_boundary() are different from the type of max_slot. Finally,

Re: [PATCH] swiotlb: swiotlb_tbl_map_single() kernel BUG in iommu-helper.h:30

2021-02-26 Thread Konrad Rzeszutek Wilk
On Fri, Feb 26, 2021 at 01:18:14PM -0800, Brad Larson wrote: > On Fri, Feb 26, 2021 at 12:43:07PM -0800, Brad Larson wrote: > > Kernel Oops introduced in next-20210222 due to get_max_slots return arg > size. > > In the function find_slots() variable max_slots is zero when >

Re: [PATCH] swiotlb: swiotlb_tbl_map_single() kernel BUG in iommu-helper.h:30

2021-02-26 Thread Konrad Rzeszutek Wilk
On Fri, Feb 26, 2021 at 12:43:07PM -0800, Brad Larson wrote: > Kernel Oops introduced in next-20210222 due to get_max_slots return arg size. > In the function find_slots() variable max_slots is zero when boundary_mask is > 0x. I am looking at the stable/for-linus-5.12 and what I

Re: [PATCH 6/9] swiotlb: refactor swiotlb_tbl_map_single

2021-02-22 Thread Konrad Rzeszutek Wilk
> > +static int find_slots(struct device *dev, size_t alloc_size) > > +{ > > + unsigned long boundary_mask = dma_get_seg_boundary(dev); > > + dma_addr_t tbl_dma_addr = > > + phys_to_dma_unencrypted(dev, io_tlb_start) & boundary_mask; > > + unsigned int max_slots =

Re: [PATCH 3/8] xen-swiotlb: use io_tlb_end in xen_swiotlb_dma_supported

2021-02-19 Thread Konrad Rzeszutek Wilk
> Reviewed-by: Konrad Rzeszutek Wilk > Signed-off-by: Christoph Hellwig > --- > drivers/xen/swiotlb-xen.c | 10 ++ > 1 file changed, 2 insertions(+), 8 deletions(-) > > diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c > index a4026822a889f7..4

Re: [PATCH 2/8] xen-swiotlb: use is_swiotlb_buffer in is_xen_swiotlb_buffer

2021-02-19 Thread Konrad Rzeszutek Wilk
he addresses for it that went through phys_to_virt. > Reviewed-by: Konrad Rzeszutek Wilk > Signed-off-by: Christoph Hellwig > --- > drivers/xen/swiotlb-xen.c | 6 ++ > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swi

Re: [PATCH RFC v1 5/6] xen-swiotlb: convert variables to arrays

2021-02-19 Thread Konrad Rzeszutek Wilk
On Sun, Feb 07, 2021 at 04:56:01PM +0100, Christoph Hellwig wrote: > On Thu, Feb 04, 2021 at 09:40:23AM +0100, Christoph Hellwig wrote: > > So one thing that has been on my mind for a while: I'd really like > > to kill the separate dma ops in Xen swiotlb. If we compare xen-swiotlb > > to swiotlb

Re: preserve DMA offsets when using swiotlb v2

2021-02-19 Thread Konrad Rzeszutek Wilk
On Tue, Feb 09, 2021 at 11:49:40AM -0800, Jianxiong Gao wrote: > > Sorry for being a little pushy, any chance we could get this reviewed > > in time for the 5.12 merge window? > > > Tested and it looks good. Thanks for clearing it up! Let me put it on my regression bucket as last time it was able

Re: [PATCH] swiotlb: Validate bounce size in the sync/unmap path

2021-02-08 Thread Konrad Rzeszutek Wilk
On Fri, Feb 05, 2021 at 06:58:52PM +0100, Christoph Hellwig wrote: > On Wed, Feb 03, 2021 at 02:36:38PM -0500, Konrad Rzeszutek Wilk wrote: > > > So what? If you guys want to provide a new capability you'll have to do > > > work. And designing a new protocol

Re: [PATCH RFC v1 2/6] swiotlb: convert variables to arrays

2021-02-04 Thread Konrad Rzeszutek Wilk
On Thu, Feb 04, 2021 at 11:49:23AM +, Robin Murphy wrote: > On 2021-02-04 07:29, Christoph Hellwig wrote: > > On Wed, Feb 03, 2021 at 03:37:05PM -0800, Dongli Zhang wrote: > > > This patch converts several swiotlb related variables to arrays, in > > > order to maintain stat/status for

Re: [PATCH] swiotlb: Validate bounce size in the sync/unmap path

2021-02-03 Thread Konrad Rzeszutek Wilk
On Wed, Feb 03, 2021 at 01:49:22PM +0100, Christoph Hellwig wrote: > On Mon, Jan 18, 2021 at 12:44:58PM +0100, Martin Radev wrote: > > Your comment makes sense but then that would require the cooperation > > of these vendors and the cloud providers to agree on something meaningful. > > I am also

Re: [PATCH] swiotlb: Validate bounce size in the sync/unmap path

2021-02-02 Thread Konrad Rzeszutek Wilk
On Tue, Feb 02, 2021 at 04:34:09PM -0600, Tom Lendacky wrote: > On 2/2/21 10:37 AM, Konrad Rzeszutek Wilk wrote: > > On Mon, Jan 25, 2021 at 07:33:35PM +0100, Martin Radev wrote: > >> On Mon, Jan 18, 2021 at 10:14:28AM -0500, Konrad Rzeszutek Wilk wrote: > >>> On M

Re: [PATCH] swiotlb: Validate bounce size in the sync/unmap path

2021-02-02 Thread Konrad Rzeszutek Wilk
On Mon, Jan 25, 2021 at 07:33:35PM +0100, Martin Radev wrote: > On Mon, Jan 18, 2021 at 10:14:28AM -0500, Konrad Rzeszutek Wilk wrote: > > On Mon, Jan 18, 2021 at 12:44:58PM +0100, Martin Radev wrote: > > > On Wed, Jan 13, 2021 at 12:30:17PM +0100, Christoph Hellwig wrote: >

Re: [PATCH 2/3] Add swiotlb offset preserving mapping when dma_dma_parameters->page_offset_mask is non zero.

2021-01-28 Thread Konrad Rzeszutek Wilk
On Wed, Jan 27, 2021 at 04:38:28PM -0800, Jianxiong Gao wrote: > For devices that need to preserve address offset on mapping through > swiotlb, this patch adds offset preserving based on page_offset_mask > and keeps the offset if the mask is non zero. This is needed for > device drivers like NVMe.

Re: [PATCH 2/5] kernel/dma: remove unnecessary unmap_kernel_range

2021-01-26 Thread Konrad Rzeszutek Wilk
On Tue, Jan 26, 2021 at 02:54:01PM +1000, Nicholas Piggin wrote: > vunmap will remove ptes. Should there be some ASSERT after the vunmap to make sure that is the case? > > Cc: Christoph Hellwig > Cc: Marek Szyprowski > Cc: Robin Murphy > Cc: iommu@lists.linux-foundation.org > Signed-off-by:

Re: [PATCH] swiotlb: Validate bounce size in the sync/unmap path

2021-01-18 Thread Konrad Rzeszutek Wilk
On Mon, Jan 18, 2021 at 12:44:58PM +0100, Martin Radev wrote: > On Wed, Jan 13, 2021 at 12:30:17PM +0100, Christoph Hellwig wrote: > > On Tue, Jan 12, 2021 at 04:07:29PM +0100, Martin Radev wrote: > > > The size of the buffer being bounced is not checked if it happens > > > to be larger than the

Re: [RFC PATCH v3 2/6] swiotlb: Add restricted DMA pool

2021-01-07 Thread Konrad Rzeszutek Wilk
On Thu, Jan 07, 2021 at 10:09:14AM -0800, Florian Fainelli wrote: > On 1/7/21 9:57 AM, Konrad Rzeszutek Wilk wrote: > > On Fri, Jan 08, 2021 at 01:39:18AM +0800, Claire Chang wrote: > >> Hi Greg and Konrad, > >> > >> This change is intended to be non-ar

Re: [RFC PATCH v3 5/6] dt-bindings: of: Add restricted DMA pool

2021-01-07 Thread Konrad Rzeszutek Wilk
On Fri, Jan 08, 2021 at 01:39:43AM +0800, Claire Chang wrote: > On Thu, Jan 7, 2021 at 2:58 AM Konrad Rzeszutek Wilk > wrote: > > > > On Wed, Jan 06, 2021 at 11:41:23AM +0800, Claire Chang wrote: > > > Introduce the new compatible string, restricted-dma-pool, for re

Re: [RFC PATCH v3 2/6] swiotlb: Add restricted DMA pool

2021-01-07 Thread Konrad Rzeszutek Wilk
On Fri, Jan 08, 2021 at 01:39:18AM +0800, Claire Chang wrote: > Hi Greg and Konrad, > > This change is intended to be non-arch specific. Any arch that lacks DMA > access > control and has devices not behind an IOMMU can make use of it. Could you > share > why you think this should be arch

Re: [RFC PATCH v3 5/6] dt-bindings: of: Add restricted DMA pool

2021-01-06 Thread Konrad Rzeszutek Wilk
On Wed, Jan 06, 2021 at 11:41:23AM +0800, Claire Chang wrote: > Introduce the new compatible string, restricted-dma-pool, for restricted > DMA. One can specify the address and length of the restricted DMA memory > region by restricted-dma-pool in the device tree. > > Signed-off-by: Claire Chang

Re: [RFC PATCH v3 2/6] swiotlb: Add restricted DMA pool

2021-01-06 Thread Konrad Rzeszutek Wilk
Hello! In this file: > diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c > index e4368159f88a..7fb2ac087d23 100644 > --- a/kernel/dma/swiotlb.c > +++ b/kernel/dma/swiotlb.c .. > +static const struct reserved_mem_ops rmem_swiotlb_ops = { > + .device_init= rmem_swiotlb_device_init,

Re: [PATCH] x86/iommu: Fix two minimal issues in check_iommu_entries()

2021-01-04 Thread Konrad Rzeszutek Wilk
On Wed, Dec 23, 2020 at 02:24:12PM +0800, Zhenzhong Duan wrote: > check_iommu_entries() checks for cyclic dependency in iommu entries > and fixes the cyclic dependency by setting x->depend to NULL. But > this repairing isn't correct if q is in front of p, there will be > "EXECUTION ORDER INVALID!"

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-16 Thread Konrad Rzeszutek Wilk
..snip.. >> > > This raises two issues: >> > > 1) swiotlb_tlb_unmap_single fails to check whether the index >generated >> > > from the dma_addr is in range of the io_tlb_orig_addr array. >> > That is fairly simple to implement I would think. That is it can >check >> > that the dma_addr is from the

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-16 Thread Konrad Rzeszutek Wilk
On December 16, 2020 1:41:48 AM EST, Jason Wang wrote: > > >- Original Message - >> >> >> - Original Message - >> > .snip. >> > > > > This raises two issues: >> > > > > 1) swiotlb_tlb_unmap_single fails to check whether the index >> > > > > generated >> > > > > from the dma_addr

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-15 Thread Konrad Rzeszutek Wilk
us to the intel thunder issue that you mentioned? ThunderClap was it! https://lwn.net/Articles/786558/ Cc-ing Lu Baolu .. Hm, this was a year ago and it looks like there are some extra SWIOTLB patches to be done ? > > On 12/15/20 9:47 AM, Ashish Kalra wrote: > > On Mon, Dec 14, 20

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-15 Thread Konrad Rzeszutek Wilk
.snip. > > > This raises two issues: > > > 1) swiotlb_tlb_unmap_single fails to check whether the index generated > > > from the dma_addr is in range of the io_tlb_orig_addr array. > > That is fairly simple to implement I would think. That is it can check > > that the dma_addr is from the PA in

Re: swiotlb/virtio: unchecked device dma address and length

2020-12-14 Thread Konrad Rzeszutek Wilk
On Fri, Dec 11, 2020 at 06:31:21PM +0100, Felicitas Hetzelt wrote: > Hello, Hi! Please see below my responses. > we have been analyzing the Hypervisor-OS interface of Linux > and discovered bugs in the swiotlb/virtio implementation that can be > triggered from a malicious Hypervisor / virtual

Re: [PATCH] [PATCH] Keep offset when mapping data via SWIOTLB.

2020-12-11 Thread Konrad Rzeszutek Wilk
On Mon, Dec 07, 2020 at 01:42:04PM -0800, Jianxiong Gao wrote: > NVMe driver and other applications depend on the data offset > to operate correctly. Currently when unaligned data is mapped via > SWIOTLB, the data is mapped as slab aligned with the SWIOTLB. When > booting with --swiotlb=force

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-08 Thread Konrad Rzeszutek Wilk
On December 8, 2020 6:01:19 PM EST, Borislav Petkov wrote: >On Tue, Dec 08, 2020 at 05:22:20PM -0500, Konrad Rzeszutek Wilk wrote: >> I will fix it up. > >So who's picking this up? If not me then I probably should have a >detailed look at the x86 bits before it goes in... I wa

Re: [PATCH v8] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-08 Thread Konrad Rzeszutek Wilk
On Mon, Dec 07, 2020 at 11:10:57PM +, Ashish Kalra wrote: > From: Ashish Kalra > > For SEV, all DMA to and from guest has to use shared (un-encrypted) pages. > SEV uses SWIOTLB to make this happen without requiring changes to device > drivers. However, depending on workload being run, the

Re: [PATCH] [PATCH] Keep offset when mapping data via SWIOTLB.

2020-12-08 Thread Konrad Rzeszutek Wilk
On Mon, Dec 07, 2020 at 01:42:04PM -0800, Jianxiong Gao wrote: > NVMe driver and other applications depend on the data offset > to operate correctly. Currently when unaligned data is mapped via > SWIOTLB, the data is mapped as slab aligned with the SWIOTLB. When > booting with --swiotlb=force

Re: [PATCH v6] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-12-01 Thread Konrad Rzeszutek Wilk
On Tue, Nov 24, 2020 at 11:46:22PM +, Ashish Kalra wrote: > Hello Konrad, > > On Mon, Nov 23, 2020 at 10:56:31PM +, Ashish Kalra wrote: > > Hello Konrad, > > > > On Mon, Nov 23, 2020 at 12:56:32PM -0500, Konrad Rzeszutek Wilk wrote: > > > On M

Re: [PATCH 1/1] x86/tboot: Don't disable swiotlb when iommu is forced on

2020-11-25 Thread Konrad Rzeszutek Wilk
On Wed, Nov 25, 2020 at 03:51:30PM +, Will Deacon wrote: > Hi Konrad, > > On Wed, Nov 25, 2020 at 10:41:53AM -0500, Konrad Rzeszutek Wilk wrote: > > On Wed, Nov 25, 2020 at 02:05:15PM +, Will Deacon wrote: > > > On Wed, 25 Nov 2020 09:41:24 +0800, Lu Baolu wro

Re: [PATCH 1/1] x86/tboot: Don't disable swiotlb when iommu is forced on

2020-11-25 Thread Konrad Rzeszutek Wilk
On Wed, Nov 25, 2020 at 02:05:15PM +, Will Deacon wrote: > On Wed, 25 Nov 2020 09:41:24 +0800, Lu Baolu wrote: > > After commit 327d5b2fee91c ("iommu/vt-d: Allow 32bit devices to uses DMA > > domain"), swiotbl could also be used for direct memory access if IOMMU > > is enabled but a device is

Re: [PATCH] [PATCH] Adding offset keeping option when mapping data via SWIOTLB.

2020-11-24 Thread Konrad Rzeszutek Wilk
On Mon, Nov 23, 2020 at 02:18:07PM -0800, Jianxiong Gao wrote: > NVMe driver and other applications may depend on the data offset > to operate correctly. Currently when unaligned data is mapped via > SWIOTLB, the data is mapped as slab aligned with the SWIOTLB. When > booting with --swiotlb=force

Re: [PATCH v6] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-23 Thread Konrad Rzeszutek Wilk
On Mon, Nov 23, 2020 at 07:02:15PM +0100, Borislav Petkov wrote: > On Mon, Nov 23, 2020 at 12:56:32PM -0500, Konrad Rzeszutek Wilk wrote: > > This is not going to work for TDX. I think having a registration > > to SWIOTLB to have this function would be bette

Re: [PATCH v6] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-23 Thread Konrad Rzeszutek Wilk
On Mon, Nov 23, 2020 at 06:06:47PM +0100, Borislav Petkov wrote: > On Thu, Nov 19, 2020 at 09:42:05PM +, Ashish Kalra wrote: > > From: Ashish Kalra > > > > For SEV, all DMA to and from guest has to use shared (un-encrypted) pages. > > SEV uses SWIOTLB to make this happen without requiring

Re: [PATCH v3] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-17 Thread Konrad Rzeszutek Wilk
alra, Ashish wrote: > > > > Hello Konrad, > > > >> On Tue, Nov 17, 2020 at 12:00:03PM -0500, Konrad Rzeszutek Wilk wrote: > >> .snip.. > >>>>>> Lets break this down: > >>>>>> > >>>>>> How does t

Re: [PATCH v3] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-17 Thread Konrad Rzeszutek Wilk
.snip.. > > > > Lets break this down: > > > > > > > > How does the performance improve for one single device if you increase > > > > the SWIOTLB? > > > > Is there a specific device/driver that you can talk about that improve > > > > with this patch? > > > > > > > > > > > > > > Yes, these are

Re: [PATCH v3] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-13 Thread Konrad Rzeszutek Wilk
On Thu, Nov 05, 2020 at 09:20:45PM +, Ashish Kalra wrote: > On Thu, Nov 05, 2020 at 03:20:07PM -0500, Konrad Rzeszutek Wilk wrote: > > On Thu, Nov 05, 2020 at 07:38:28PM +, Ashish Kalra wrote: > > > On Thu, Nov 05, 2020 at 02:06:49PM -0500, Konrad Rz

Re: [PATCH for-5.10] swiotlb: remove the tbl_dma_addr argument to swiotlb_tbl_map_single

2020-11-10 Thread Konrad Rzeszutek Wilk
On Tue, Nov 10, 2020 at 10:14:21AM +0100, Christoph Hellwig wrote: > On Wed, Nov 04, 2020 at 09:04:38AM -0500, Konrad Rzeszutek Wilk wrote: > > On Tue, Nov 03, 2020 at 10:46:43AM +0100, Christoph Hellwig wrote: > > > ping? > > > > Hopefully this goes through.

Re: [PATCH v3] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-05 Thread Konrad Rzeszutek Wilk
On Thu, Nov 05, 2020 at 07:38:28PM +, Ashish Kalra wrote: > On Thu, Nov 05, 2020 at 02:06:49PM -0500, Konrad Rzeszutek Wilk wrote: > > . > > > > Right, so I am wondering if we can do this better. > > > > > > > > That is you are never g

Re: [PATCH v3] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-05 Thread Konrad Rzeszutek Wilk
. > > Right, so I am wondering if we can do this better. > > > > That is you are never going to get any 32-bit devices with SEV right? That > > is there is nothing that bounds you to always use the memory below 4GB? > > > > We do support 32-bit PCIe passthrough devices with SEV. Ewww.. Which

Re: [PATCH v3] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-05 Thread Konrad Rzeszutek Wilk
On Wed, Nov 04, 2020 at 10:39:13PM +, Ashish Kalra wrote: > Hello Konrad, > > On Wed, Nov 04, 2020 at 05:14:52PM -0500, Konrad Rzeszutek Wilk wrote: > > On Wed, Nov 04, 2020 at 10:08:04PM +, Ashish Kalra wrote: > > > From: Ashish Kalra > > > > > &

Re: [PATCH v3] swiotlb: Adjust SWIOTBL bounce buffer size for SEV guests.

2020-11-04 Thread Konrad Rzeszutek Wilk
On Wed, Nov 04, 2020 at 10:08:04PM +, Ashish Kalra wrote: > From: Ashish Kalra > > For SEV, all DMA to and from guest has to use shared > (un-encrypted) pages. SEV uses SWIOTLB to make this > happen without requiring changes to device drivers. > However, depending on workload being run, the

Re: [PATCH for-5.10] swiotlb: remove the tbl_dma_addr argument to swiotlb_tbl_map_single

2020-11-04 Thread Konrad Rzeszutek Wilk
On Tue, Nov 03, 2020 at 10:46:43AM +0100, Christoph Hellwig wrote: > ping? Hopefully this goes through. I am in the process of testing it but ran into testing issues that I believe are unrelated. > > On Fri, Oct 23, 2020 at 08:33:09AM +0200, Christoph Hellwig wrote: > > The tbl_dma_addr

Re: [PATCH] fix swiotlb panic on Xen

2020-10-27 Thread Konrad Rzeszutek Wilk
abellini Reviewed-by: Christoph Hellwig CC: sta...@vger.kernel.org Signed-off-by: Konrad Rzeszutek Wilk --- kernel/dma/swiotlb.c | 6 +- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 465a567678d9..e08cac39c0ba 100644 --- a/kerne

Re: [PATCH] fix swiotlb panic on Xen

2020-10-27 Thread Konrad Rzeszutek Wilk
On Mon, Oct 26, 2020 at 05:02:14PM -0700, Stefano Stabellini wrote: > From: Stefano Stabellini > > kernel/dma/swiotlb.c:swiotlb_init gets called first and tries to > allocate a buffer for the swiotlb. It does so by calling > > memblock_alloc_low(PAGE_ALIGN(bytes), PAGE_SIZE); > > If the

Re: [PATCH V2] dma-direct: Fix potential NULL pointer dereference

2020-09-17 Thread Konrad Rzeszutek Wilk
> __do_sys_finit_module+0xbe/0x120 > ? __do_sys_finit_module+0xbe/0x120 > __x64_sys_finit_module+0x1a/0x20 > do_syscall_64+0x38/0x50 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > Signed-off-by: Thomas Tai Reviewed-by: Konrad Rzeszutek Wilk Thank you! > --- >

Re: [PATCH v2 1/3] swiotlb: Use %pa to print phys_addr_t variables

2020-09-09 Thread Konrad Rzeszutek Wilk
On Wed, Sep 09, 2020 at 06:59:13PM +0300, Andy Shevchenko wrote: > On Wed, Sep 02, 2020 at 11:02:46PM -0300, Fabio Estevam wrote: > > On Wed, Sep 2, 2020 at 2:31 PM Andy Shevchenko > > wrote: > > > > > > There is an extension to a %p to print phys_addr_t type of variables. > > > Use it here. > >

Is: virtio_gpu_object_shmem_init issues? Was:Re: upstream boot error: general protection fault in swiotlb_map

2020-08-24 Thread Konrad Rzeszutek Wilk
On Thu, Aug 06, 2020 at 03:46:23AM -0700, syzbot wrote: > Hello, > > syzbot found the following issue on: > > HEAD commit:47ec5303 Merge git://git.kernel.org/pub/scm/linux/kernel/g.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=16fe1dea90 >

  1   2   3   >