HomeFreeBSD

arm64: Clamp segment sizes properly in bounce_bus_dmamap_load_buffer()

Description

arm64: Clamp segment sizes properly in bounce_bus_dmamap_load_buffer()

Commit 099b59515499 ("Improve loading of multipage aligned buffers.")
modified bounce_bus_dmamap_load_buffer() with the assumption that busdma
memory allocations are physically contiguous, which is not always true:
bounce_bus_dmamem_alloc() will allocate memory with
kmem_alloc_attr_domainset() in some cases, and this function is not
guaranteed to return contiguous memory.

The damage seems to have been mitigated for most consumers by clamping
the segment size to maxsegsz, but this was removed in commit
a77e1f0f81df ("busdma: better handling of small segment bouncing"); in
practice, it seems busdma memory is often allocated with maxsegsz ==
PAGE_SIZE. In particular, after commit a77e1f0f81df I see occasional
random kernel memory corruption when benchmarking TCP through mlx5
interfaces.

Fix the problem by using separate flags for contiguous and
non-contiguous busdma memory allocations, and using that to decide
whether to clamp.

Fixes: 099b59515499 ("Improve loading of multipage aligned buffers.")
Fixes: a77e1f0f81df ("busdma: better handling of small segment bouncing")
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D46238

Details

Provenance
markjAuthored on Aug 15 2024, 2:17 PM
Differential Revision
D46238: arm64: Clamp segment sizes properly in bounce_bus_dmamap_load_buffer()
Parents
rG8cc528c682d7: tcp cc: clean up some un-used cc_var flags
Branches
Unknown
Tags
Unknown