Re: [PATCH 03/12] swiotlb-xen: maintain slab count properly
From: Christoph Hellwig
Date: Wed Sep 08 2021 - 02:54:51 EST
On Tue, Sep 07, 2021 at 02:05:12PM +0200, Jan Beulich wrote:
> Generic swiotlb code makes sure to keep the slab count a multiple of the
> number of slabs per segment. Yet even without checking whether any such
> assumption is made elsewhere, it is easy to see that xen_swiotlb_fixup()
> might alter unrelated memory when calling xen_create_contiguous_region()
> for the last segment, when that's not a full one - the function acts on
> full order-N regions, not individual pages.
>
> Align the slab count suitably when halving it for a retry. Add a build
> time check and a runtime one. Replace the no longer useful local
> variable "slabs" by an "order" one calculated just once, outside of the
> loop. Re-use "order" for calculating "dma_bits", and change the type of
> the latter as well as the one of "i" while touching this anyway.
>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Looks good,
Reviewed-by: Christoph Hellwig <hch@xxxxxx>