Page MenuHomeFreeBSD

opencrypto: Add a routine to copy a crypto buffer cursor
ClosedPublic

Authored by markj on Feb 26 2021, 6:31 PM.
Tags
None
Referenced Files
F102429256: D28949.diff
Tue, Nov 12, 3:55 AM
Unknown Object (File)
Fri, Nov 1, 9:21 PM
Unknown Object (File)
Oct 3 2024, 1:32 AM
Unknown Object (File)
Oct 3 2024, 12:33 AM
Unknown Object (File)
Oct 2 2024, 7:07 PM
Unknown Object (File)
Sep 25 2024, 10:24 PM
Unknown Object (File)
Sep 24 2024, 5:22 AM
Unknown Object (File)
Sep 22 2024, 7:19 PM

Details

Summary

This was useful in converting armv8crypto to use buffer cursors. There
are some cases where you want to make two passes over data, so you want
a way to "reset" a cursor.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No Test Coverage
Build Status
Buildable 37551
Build 34440: arc lint + arc unit

Event Timeline

markj requested review of this revision.Feb 26 2021, 6:31 PM

I think I've just used direct structure copies for this in other places, but an API call is fine. I'd be tempted to make it an inline so the compiler can inline it perhaps. I think you should also add it to crypto_buffer.9?

Apply reviewer suggestions

pauamma_gundo.com added inline comments.
share/man/man9/crypto_buffer.9
33 ↗(On Diff #102665)
325 ↗(On Diff #102665)

May be belaboring the obvious - I don't know the audience well enough to say.

326–327 ↗(On Diff #102665)

Looking at the struct definition in sys/opencrypto/cryptodev.h, I see

	union {
		char *cc_buf;
		struct mbuf *cc_mbuf;
		struct iovec *cc_iov;
		vm_page_t *cc_vmpage;
	};

Is that part of the state (it may well not be - my code-reading skills are past their prime)?

jhb added inline comments.
share/man/man9/crypto_buffer.9
326–327 ↗(On Diff #102665)

It is part of the state, but once the you've copied the cursor, changes to fromc don't affect toc and vice versa. In particular, this part of the state is duplicated in each cursor. They point to a shared buffer, but the buffer isn't part of the state. Rather, a cursor is an offset into a buffer and state necessary to iterate over a buffer.

This revision is now accepted and ready to land.Feb 15 2022, 12:42 AM
share/man/man9/crypto_buffer.9
326–327 ↗(On Diff #102665)

If I read your implication right that the shared buffer is never written into through one while the other reads from it, that language works.