[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aLtHNCaMJTulDOw8@arm.com>
Date: Fri, 5 Sep 2025 21:25:24 +0100
From: Catalin Marinas <catalin.marinas@....com>
To: Jason Gunthorpe <jgg@...pe.ca>
Cc: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@...nel.org>,
linux-kernel@...r.kernel.org, iommu@...ts.linux.dev,
linux-coco@...ts.linux.dev, will@...nel.org, maz@...nel.org,
tglx@...utronix.de, robin.murphy@....com, suzuki.poulose@....com,
akpm@...ux-foundation.org, steven.price@....com
Subject: Re: [RFC PATCH] arm64: swiotlb: dma: its: Ensure shared buffers are
properly aligned
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
Powered by blists - more mailing lists