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
F97765536: D46238.diff
Tue, Oct 1, 4:26 AM
Unknown Object (File)
Tue, Sep 24, 3:23 AM
Unknown Object (File)
Thu, Sep 19, 9:21 PM
Unknown Object (File)
Thu, Sep 19, 5:03 PM
Unknown Object (File)
Wed, Sep 18, 7:31 PM
Unknown Object (File)
Wed, Sep 18, 9:52 AM
Unknown Object (File)
Tue, Sep 17, 8:44 AM
Unknown Object (File)
Tue, Sep 10, 7:59 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 58957
Build 55844: arc lint + arc unit

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.