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
Unknown Object (File)
Mon, May 27, 6:10 PM
Unknown Object (File)
Apr 26 2024, 6:11 PM
Unknown Object (File)
Apr 26 2024, 6:10 PM
Unknown Object (File)
Apr 26 2024, 6:10 PM
Unknown Object (File)
Apr 26 2024, 6:10 PM
Unknown Object (File)
Apr 26 2024, 1:37 PM
Unknown Object (File)
Apr 26 2024, 12:09 PM
Unknown Object (File)
Mar 14 2024, 12:02 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
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

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
325

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

326–327

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

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

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.