[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20260106011636.GQ125261@ziepe.ca>
Date: Mon, 5 Jan 2026 21:16:36 -0400
From: Jason Gunthorpe <jgg@...pe.ca>
To: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@...nel.org>
Cc: linux-kernel@...r.kernel.org, iommu@...ts.linux.dev,
linux-coco@...ts.linux.dev,
Catalin Marinas <catalin.marinas@....com>, will@...nel.org,
maz@...nel.org, tglx@...utronix.de, robin.murphy@....com,
suzuki.poulose@....com, akpm@...ux-foundation.org,
steven.price@....com
Subject: Re: [PATCH v2 1/4] swiotlb: dma: its: Enforce host page-size
alignment for shared buffers
On Sun, Dec 21, 2025 at 09:39:17PM +0530, Aneesh Kumar K.V (Arm) wrote:
> +#define mem_encrypt_align mem_encrypt_align
> +static inline size_t mem_encrypt_align(size_t size)
> +{
> + return size;
> +}
> +
IMHO this is the wrong API.
The issue here is not about alignment, it is about the permitted
granule size for shared/private.
On X86 this will be PAGE_SIZE on ARM64 it is
max(hypervisor_page_size, PAGE_SIZE)
So think the arch helper should simply be
__pure size_T mem_encrypt_granule_size(void);
> + if (WARN_ON(!IS_ALIGNED(addr, mem_encrypt_align(PAGE_SIZE))))
> + return 0;
> +
> + if (WARN_ON(!IS_ALIGNED(numpages << PAGE_SHIFT, mem_encrypt_align(PAGE_SIZE))))
> + return 0;
And then we don't end up with weiro reading stuff like this..
if (WARN_ON(!IS_ALIGNED(addr, mem_encrypt_granule_size())) ||
WARN_ON(!IS_ALIGNED(numpages, mem_encrypt_granule_size() / PAGE_SIZE)))
Is much more readable..
> @@ -319,8 +319,8 @@ static void __init *swiotlb_memblock_alloc(unsigned long nslabs,
> unsigned int flags,
> int (*remap)(void *tlb, unsigned long nslabs))
> {
> - size_t bytes = PAGE_ALIGN(nslabs << IO_TLB_SHIFT);
> void *tlb;
> + size_t bytes = mem_encrypt_align(nslabs << IO_TLB_SHIFT);
The stuff like this is just ALING(nslabs << IO_TLB_SHIFT, mem_encrypt_granule_size())
etc
Jason
Powered by blists - more mailing lists