Re: [PATCH 2/2] swiotlb: Enforce page alignment in swiotlb_alloc()

From: Christoph Hellwig
Date: Mon Jan 29 2024 - 02:50:56 EST


On Mon, Jan 29, 2024 at 08:43:26AM +0100, Petr Tesařík wrote:
> > So PFN_DOWN aligns the address and thus per se converting the unaligned
> > address isn't a problem. That being said swiotlb obviously should never
> > allocate unaligned addresses, but the placement of this check feels
> > odd to me. Also because it only catches swiotlb_alloc and not the
> > map side.
>
> We may have to rethink how alignment constraints are interpreted. See
> also my reply to PATCH 1/2.
>
> > Maybe just throw a WARN_ON_ONCE into slot_addr() ?
>
> Yes.
>
> Or, what if I write a KUnit test suite for swiotlb to combat this
> constant stream of various regressions?

Both sounds good to me.