Page MenuHomeFreeBSD

arm64: Clamp segment sizes properly in bounce_bus_dmamap_load_buffer()
ClosedPublic

Authored by markj on Aug 6 2024, 5:46 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 4, 4:11 PM
Unknown Object (File)
Mon, Nov 4, 11:58 AM
Unknown Object (File)
Mon, Nov 4, 8:09 AM
Unknown Object (File)
Mon, Oct 28, 6:28 AM
Unknown Object (File)
Sun, Oct 27, 7:33 AM
Unknown Object (File)
Tue, Oct 22, 4:58 AM
Unknown Object (File)
Oct 12 2024, 12:45 PM
Unknown Object (File)
Oct 1 2024, 1:45 PM
Subscribers

Details

Summary

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 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")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj requested review of this revision.Aug 6 2024, 5:46 PM

Would anyone like to review this?

seems fine

sys/arm64/arm64/busdma_bounce.c
68

Given there is a single use left, does it really make sense to keep this here rather than doing the (BF_KMEM_ALLOC_PAGES|BF_KMEM_ALLOC_CONTIG) check in bounce_bus_dmamem_free()?
I am game either way ..

sys/arm64/arm64/busdma_bounce.c
68

I don't feel strongly either way. Testing for BF_KMEM_ALLOC is a bit neater.

This revision was not accepted when it landed; it landed in state Needs Review.Aug 15 2024, 2:22 PM
This revision was automatically updated to reflect the committed changes.