From: Catalin Marinas <catalin.marinas@arm.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>,
linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
linux-coco@lists.linux.dev, will@kernel.org, maz@kernel.org,
tglx@linutronix.de, robin.murphy@arm.com, suzuki.poulose@arm.com,
akpm@linux-foundation.org, steven.price@arm.com
Subject: Re: [RFC PATCH] arm64: swiotlb: dma: its: Ensure shared buffers are properly aligned
Date: Fri, 5 Sep 2025 21:25:24 +0100 [thread overview]
Message-ID: <aLtHNCaMJTulDOw8@arm.com> (raw)
In-Reply-To: <20250905162258.GA483339@ziepe.ca>
On Fri, Sep 05, 2025 at 01:22:58PM -0300, Jason Gunthorpe wrote:
> On Fri, Sep 05, 2025 at 02:13:34PM +0100, Catalin Marinas wrote:
> > > @@ -213,16 +213,20 @@ static gfp_t gfp_flags_quirk;
> > > static struct page *its_alloc_pages_node(int node, gfp_t gfp,
> > > unsigned int order)
> > > {
> > > + long new_order;
> > > struct page *page;
> > > int ret = 0;
> > >
> > > - page = alloc_pages_node(node, gfp | gfp_flags_quirk, order);
> > > + /* align things to hypervisor page size */
> > > + new_order = get_order(ALIGN((PAGE_SIZE << order), arch_shared_mem_alignment()));
> > > +
> > > + page = alloc_pages_node(node, gfp | gfp_flags_quirk, new_order);
> > >
> > > if (!page)
> > > return NULL;
> > >
> > > ret = set_memory_decrypted((unsigned long)page_address(page),
> > > - 1 << order);
> > > + 1 << new_order);
> >
> > At some point this could move to the DMA API.
>
> I don't think we should be open coding these patterns.
>
> Esepcially given the above, it makes no sense to 'alloc page' and then
> 'decrypt page' on ARM CCA. decryption is not really a OS page level
> operation. I suggest coming with some series to clean these up into a
> more sensible API.
>
> Everything wanting decrypted memory should be going through some more
> general API that has some opportunity to use pools.
I proposed something like GFP_DECRYPTED last year but never got around
to post a proper patch (and also add vmalloc() support):
https://lore.kernel.org/linux-arm-kernel/ZmNJdSxSz-sYpVgI@arm.com/
The GIC ITS code would have been one of the very few users, so we ended
up with open-coding the call to set_memory_decrypted().
--
Catalin
next prev parent reply other threads:[~2025-09-05 20:25 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 5:54 [RFC PATCH] arm64: swiotlb: dma: its: Ensure shared buffers are properly aligned Aneesh Kumar K.V (Arm)
2025-09-05 8:04 ` Thomas Gleixner
2025-09-08 8:44 ` Aneesh Kumar K.V
2025-09-05 13:13 ` Catalin Marinas
2025-09-05 16:22 ` Jason Gunthorpe
2025-09-05 20:25 ` Catalin Marinas [this message]
2025-09-08 9:12 ` Suzuki K Poulose
2025-09-08 9:37 ` Aneesh Kumar K.V
2025-09-08 11:40 ` Catalin Marinas
2025-09-08 13:47 ` Suzuki K Poulose
2025-09-08 14:58 ` Jason Gunthorpe
2025-09-08 15:39 ` Steven Price
2025-09-08 17:25 ` Catalin Marinas
2025-09-10 10:08 ` Steven Price
2025-09-12 14:59 ` Catalin Marinas
2025-09-08 17:55 ` Jason Gunthorpe
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=aLtHNCaMJTulDOw8@arm.com \
--to=catalin.marinas@arm.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=robin.murphy@arm.com \
--cc=steven.price@arm.com \
--cc=suzuki.poulose@arm.com \
--cc=tglx@linutronix.de \
--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.