All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mostafa Saleh <smostafa@google.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	robin.murphy@arm.com, m.szyprowski@samsung.com, will@kernel.org,
	maz@kernel.org, suzuki.poulose@arm.com, catalin.marinas@arm.com,
	jiri@resnulli.us, aneesh.kumar@kernel.org
Subject: Re: [RFC PATCH v3 2/5] dma-mapping: Move encryption in __dma_direct_free_pages()
Date: Wed, 15 Apr 2026 20:49:08 +0000	[thread overview]
Message-ID: <ad_5xGkg_3XbkN9b@google.com> (raw)
In-Reply-To: <20260410174553.GD2551565@ziepe.ca>

On Fri, Apr 10, 2026 at 02:45:53PM -0300, Jason Gunthorpe wrote:
> On Wed, Apr 08, 2026 at 07:47:39PM +0000, Mostafa Saleh wrote:
> > In the next patches, we will need to avoid encrypting memory allocated
> > from SWIOTLB, so instead of calling dma_set_encrypted() before
> > __dma_direct_free_pages(), call it inside, conditional on the memory
> > state passed to the function.
> > 
> > Signed-off-by: Mostafa Saleh <smostafa@google.com>
> > ---
> >  kernel/dma/direct.c | 22 +++++++++++-----------
> >  1 file changed, 11 insertions(+), 11 deletions(-)
> > 
> > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
> > index 6efb5973fbd3..ce74f213ec40 100644
> > --- a/kernel/dma/direct.c
> > +++ b/kernel/dma/direct.c
> > @@ -97,8 +97,11 @@ static int dma_set_encrypted(struct device *dev, void *vaddr, size_t size)
> >  }
> >  
> >  static void __dma_direct_free_pages(struct device *dev, struct page *page,
> > -				    size_t size)
> > +				    size_t size, bool encrypt)
> >  {
> 
> This feels like it would be nicer if it could be the
> swiotlb_page_state instead of a bool, maybe the enum needs a different
> name.

I am not sure I get this, at this point the swiotlb stuff is not
introduced yet, I try to refactor the free path to make is easier
to modify next, the bool encrypt here is typically set to false
from the error path.
I can replace that with a wrapper doing the encryption and calling
the free function.

Thanks,
Mostafa




> 
> Jason

  reply	other threads:[~2026-04-15 20:49 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-08 19:47 [RFC PATCH v3 0/5] dma-mapping: Fixes for memory encryption Mostafa Saleh
2026-04-08 19:47 ` [RFC PATCH v3 1/5] swiotlb: Return state of memory from swiotlb_alloc() Mostafa Saleh
2026-04-14  9:25   ` Aneesh Kumar K.V
2026-04-15 20:43     ` Mostafa Saleh
2026-04-16  8:53       ` Aneesh Kumar K.V
2026-04-17 15:05         ` Mostafa Saleh
2026-04-08 19:47 ` [RFC PATCH v3 2/5] dma-mapping: Move encryption in __dma_direct_free_pages() Mostafa Saleh
2026-04-10 17:45   ` Jason Gunthorpe
2026-04-15 20:49     ` Mostafa Saleh [this message]
2026-04-16  0:11       ` Jason Gunthorpe
2026-04-17 15:07         ` Mostafa Saleh
2026-04-08 19:47 ` [RFC PATCH v3 3/5] dma-mapping: Decrypt memory on remap Mostafa Saleh
2026-04-14  9:31   ` Aneesh Kumar K.V
2026-04-14 12:22     ` Jason Gunthorpe
2026-04-14 13:13       ` Aneesh Kumar K.V
2026-04-14 13:53         ` Jason Gunthorpe
2026-05-07 17:18     ` Catalin Marinas
2026-05-08  4:03       ` Aneesh Kumar K.V
2026-04-08 19:47 ` [RFC PATCH v3 4/5] dma-mapping: Encapsulate memory state during allocation Mostafa Saleh
2026-04-10 18:05   ` Jason Gunthorpe
2026-04-15  9:38     ` Aneesh Kumar K.V
2026-04-17 15:45     ` Mostafa Saleh
2026-05-07 17:36       ` Catalin Marinas
2026-05-11 10:48         ` Mostafa Saleh
2026-04-08 19:47 ` [RFC PATCH v3 5/5] dma-mapping: Fix memory decryption issues Mostafa Saleh
2026-04-13  7:19   ` Aneesh Kumar K.V
2026-04-13 12:42     ` Jason Gunthorpe
2026-04-15 12:43       ` Aneesh Kumar K.V
2026-04-15 13:53         ` Jason Gunthorpe
2026-04-14  9:37   ` Aneesh Kumar K.V
2026-04-10 17:43 ` [RFC PATCH v3 0/5] dma-mapping: Fixes for memory encryption Jason Gunthorpe
2026-04-15 20:25   ` Mostafa Saleh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad_5xGkg_3XbkN9b@google.com \
    --to=smostafa@google.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=maz@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.