Page MenuHomeFreeBSD

Abstract UIO allocation and deallocation.
ClosedPublic

Authored by alfredo.mazzinghi_cl.cam.ac.uk on Feb 2 2024, 3:10 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 27, 9:35 AM
Unknown Object (File)
Sat, Apr 27, 9:35 AM
Unknown Object (File)
Sat, Apr 27, 9:35 AM
Unknown Object (File)
Sat, Apr 27, 9:35 AM
Unknown Object (File)
Sat, Apr 27, 8:13 AM
Unknown Object (File)
Mar 16 2024, 1:50 PM
Unknown Object (File)
Mar 16 2024, 1:49 PM
Unknown Object (File)
Mar 16 2024, 1:49 PM
Subscribers

Details

Summary

Introduce the allocuio() and freeuio() functions to allocate and deallocate
struct uio. This hides the actual allocator interface, so it is easier to modify
the sub-allocation layout of struct uio and the corresponding iovec array.

Diff Detail

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

Event Timeline

I do not have much objections against this change, but I wonder what do you mean by 'changing the sub-allocation layout'. Note that uio->uio_iov is often modified during uio life, resulting in the pointer no longer pointing to the initial iov vector at the time of uio allocation.

In D43711#996954, @kib wrote:

I do not have much objections against this change, but I wonder what do you mean by 'changing the sub-allocation layout'. Note that uio->uio_iov is often modified during uio life, resulting in the pointer no longer pointing to the initial iov vector at the time of uio allocation.

This is originally motivated by a change in CheriBSD, where I modify the way struct uio is allocated. This specific patch reduces our diff.
In particular, the problem is the fact that the uio_iov sub-allocation may not be aligned enough and I don't think it can be solved with padding. The proper way to handle this in CheriBSD would be to use multiple allocations, which ensure that no overflow can occur between the struct uio fields and the iovec array. I have a separate patch where the cost of the double allocation is amortized by embedding a small iovec array into struct uio, which should cover most use-cases and satisfy the alignment/size requirements for a CHERI architecture. There I also handle the issue of changing uio->uio_iov during the uio life.

kib added inline comments.
sys/kern/subr_uio.c
403
This revision is now accepted and ready to land.Feb 2 2024, 5:53 PM

Fix additional freeuio() calls in compat/freebsd32.

This revision now requires review to proceed.Feb 6 2024, 5:42 PM

Do you have somebody to commit this for you?

If not, please mail me git-format-patches.

This revision is now accepted and ready to land.Feb 6 2024, 10:23 PM
In D43711#998275, @kib wrote:

Do you have somebody to commit this for you?

If not, please mail me git-format-patches.

markj offered to commit. Thanks!

This revision was automatically updated to reflect the committed changes.