Re: [RFC PATCH] arm64: swiotlb: dma: its: Ensure shared buffers are properly aligned

Thomas Gleixner
2025-09-05T08:04:46Z

On Fri, Sep 05 2025 at 11:24, Aneesh Kumar K. V. wrote:
> When running with private memory guests, the guest kernel must allocate
> memory with specific constraints when sharing it with the hypervisor.
>
> These shared memory buffers are also accessed by the host kernel, which
> means they must be aligned to the host kernel's page size.
>
> This patch introduces a new helper, arch_shared_mem_alignment(), which

# git grep "This patch" Documentation/process/

> can be used to enforce proper alignment of shared buffers.
>
> The actual implementation of arch_shared_mem_alignment() is deferred
> to a follow-up patch.
>
> Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
> ---
> arch/arm64/include/asm/mem_encrypt.h | 6 ++++++
> arch/arm64/mm/init.c | 4 +++-
> arch/arm64/mm/mem_encrypt.c | 6 ++++++
> drivers/irqchip/irq-gic-v3-its.c | 8 ++++++--
> include/linux/mem_encrypt.h | 7 +++++++
> include/linux/swiotlb.h | 7 ++++---
> kernel/dma/direct.c | 7 +++++++
> kernel/dma/pool.c | 1 +
> kernel/dma/swiotlb.c | 28 +++++++++++++++++-----------

This does too many things at once and breaks all swiotlb users except
arm64. Seriously?

> -void swiotlb_init(bool addressing_limited, unsigned int flags);
> +void swiotlb_init(bool addressing_limited, unsigned int alignment, unsigned int flags);

Why do you need this alignment argument in the first place?

In quite some other places you use arch_shared_mem_alignment(), which
defaults to PAGE_SIZE if the architecture does not implement it's own
variant. What's preventing you from using that in the init functions as
well?

Thanks,

tglx