#
68f6800c |
| 08-Feb-2021 |
Mark Johnston <markj@FreeBSD.org> |
opencrypto: Introduce crypto_dispatch_async()
Currently, OpenCrypto consumers can request asynchronous dispatch by setting a flag in the cryptop. (Currently only IPSec may do this.) I think this
opencrypto: Introduce crypto_dispatch_async()
Currently, OpenCrypto consumers can request asynchronous dispatch by setting a flag in the cryptop. (Currently only IPSec may do this.) I think this is a bit confusing: we (conditionally) set cryptop flags to request async dispatch, and then crypto_dispatch() immediately examines those flags to see if the consumer wants async dispatch. The flag names are also confusing since they don't specify what "async" applies to: dispatch or completion.
Add a new KPI, crypto_dispatch_async(), rather than encoding the requested dispatch type in each cryptop. crypto_dispatch_async() falls back to crypto_dispatch() if the session's driver provides asynchronous dispatch. Get rid of CRYPTOP_ASYNC() and CRYPTOP_ASYNC_KEEPORDER().
Similarly, add crypto_dispatch_batch() to request processing of a tailq of cryptops, rather than encoding the scheduling policy using cryptop flags. Convert GELI, the only user of this interface (disabled by default) to use the new interface.
Add CRYPTO_SESS_SYNC(), which can be used by consumers to determine whether crypto requests will be dispatched synchronously. This is just a helper macro. Use it instead of looking at cap flags directly.
Fix style in crypto_done(). Also get rid of CRYPTO_RETW_EMPTY() and just check the relevant queues directly. This could result in some unnecessary wakeups but I think it's very uncommon to be using more than one queue per worker in a given workload, so checking all three queues is a waste of cycles.
Reviewed by: jhb Sponsored by: Ampere Computing Submitted by: Klara, Inc. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D28194
show more ...
|
#
8adcc757 |
| 20-Jan-2021 |
Mark Johnston <markj@FreeBSD.org> |
opencrypto: Add comments describing the new crypto_session layout
Requested by: rpokala
|
#
98d788c8 |
| 20-Jan-2021 |
Mark Johnston <markj@FreeBSD.org> |
opencrypto: Fix assignment of crypto completions to worker threads
Since r336439 we simply take the session pointer value mod the number of worker threads (ncpu by default). On small systems this e
opencrypto: Fix assignment of crypto completions to worker threads
Since r336439 we simply take the session pointer value mod the number of worker threads (ncpu by default). On small systems this ends up funneling all completion work through a single thread, which becomes a bottleneck when processing IPSec traffic using hardware crypto drivers. (Software drivers such as aesni(4) are unaffected since they invoke completion handlers synchonously.)
Instead, maintain an incrementing counter with a unique value per session, and use that to distribute work to completion threads.
Reviewed by: cem, jhb MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D28159
show more ...
|
#
d1816248 |
| 20-Jan-2021 |
Mark Johnston <markj@FreeBSD.org> |
opencrypto: Embed the driver softc in the session structure
Store the driver softc below the fields owned by opencrypto. This is a bit simpler and saves a pointer dereference when fetching the driv
opencrypto: Embed the driver softc in the session structure
Store the driver softc below the fields owned by opencrypto. This is a bit simpler and saves a pointer dereference when fetching the driver softc when processing a request.
Get rid of the crypto session UMA zone. Session allocations are frequent or performance-critical enough to warrant a dedicated zone.
No functional change intended.
Reviewed by: cem, jhb Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D28158
show more ...
|
#
5973f492 |
| 06-Nov-2020 |
John Baldwin <jhb@FreeBSD.org> |
Style fixes for function prototypes and definitions.
Reviewed by: markj Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D27066
|
#
d3d79e96 |
| 03-Nov-2020 |
John Baldwin <jhb@FreeBSD.org> |
Consistently use C99 fixed-width types in the in-kernel crypto code.
Reviewed by: markj Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D27061
|
#
d588dc7d |
| 30-Oct-2020 |
Mark Johnston <markj@FreeBSD.org> |
opencrypto: Annotate hmac_init_(i|o)pad() to make auth_hash const
This makes them friendlier to drivers that try to use const pointers whenever possible in their internal structures.
Reviewed by: j
opencrypto: Annotate hmac_init_(i|o)pad() to make auth_hash const
This makes them friendlier to drivers that try to use const pointers whenever possible in their internal structures.
Reviewed by: jhb Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D26901
show more ...
|
Revision tags: release/12.2.0 |
|
#
e7f6b6cf |
| 19-Oct-2020 |
John Baldwin <jhb@FreeBSD.org> |
Fix a couple of bugs for asym crypto introduced in r359374.
- Check for null pointers in the crypto_drivers[] array when checking for empty slots in crypto_select_kdriver().
- Handle the case whe
Fix a couple of bugs for asym crypto introduced in r359374.
- Check for null pointers in the crypto_drivers[] array when checking for empty slots in crypto_select_kdriver().
- Handle the case where crypto_kdone() is invoked on a request where krq_cap is NULL due to not finding a matching driver.
Reviewed by: markj Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D26811
show more ...
|
#
ecedef53 |
| 19-Oct-2020 |
John Baldwin <jhb@FreeBSD.org> |
Mark asymmetric cryptography via OCF deprecated for 14.0.
Only one MIPS-specific driver implements support for one of the asymmetric operations. There are no in-kernel users besides /dev/crypto. T
Mark asymmetric cryptography via OCF deprecated for 14.0.
Only one MIPS-specific driver implements support for one of the asymmetric operations. There are no in-kernel users besides /dev/crypto. The only known user of the /dev/crypto interface was the engine in OpenSSL releases before 1.1.0. 1.1.0 includes a rewritten engine that does not use the asymmetric operations due to lack of documentation.
Reviewed by: cem, markj MFC after: 1 week Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D26810
show more ...
|
#
7e89ae49 |
| 16-Oct-2020 |
Marcin Wojtas <mw@FreeBSD.org> |
Prepare crypto framework for IPsec ESN support
This permits requests (netipsec ESP and AH protocol) to provide the IPsec ESN (Extended Sequence Numbers) in a separate buffer.
As with separate outpu
Prepare crypto framework for IPsec ESN support
This permits requests (netipsec ESP and AH protocol) to provide the IPsec ESN (Extended Sequence Numbers) in a separate buffer.
As with separate output buffer and separate AAD buffer not all drivers support this feature. Consumer must request use of this feature via new session flag.
Submitted by: Grzegorz Jaszczyk <jaz@semihalf.com> Patryk Duda <pdk@semihalf.com> Reviewed by: jhb Differential revision: https://reviews.freebsd.org/D24838 Obtained from: Semihalf Sponsored by: Stormshield
show more ...
|
#
e2515283 |
| 27-Aug-2020 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: Rubicon Communications, LLC (netgate.com)
|
#
e6f6d0c9 |
| 26-Aug-2020 |
Alan Somers <asomers@FreeBSD.org> |
crypto(9): add CRYPTO_BUF_VMPAGE
crypto(9) functions can now be used on buffers composed of an array of vm_page_t structures, such as those stored in an unmapped struct bio. It requires the running
crypto(9): add CRYPTO_BUF_VMPAGE
crypto(9) functions can now be used on buffers composed of an array of vm_page_t structures, such as those stored in an unmapped struct bio. It requires the running to kernel to support the direct memory map, so not all architectures can use it.
Reviewed by: markj, kib, jhb, mjg, mat, bcr (manpages) MFC after: 1 week Sponsored by: Axcient Differential Revision: https://reviews.freebsd.org/D25671
show more ...
|
#
c7aa572c |
| 31-Jul-2020 |
Glen Barber <gjb@FreeBSD.org> |
MFH
Sponsored by: Rubicon Communications, LLC (netgate.com)
|
#
e5587cbb |
| 17-Jul-2020 |
Mark Johnston <markj@FreeBSD.org> |
Clean up crypto_init().
The function is called from a KLD load handler, so it may sleep.
- Stop checking for errors from uma_zcreate(), they don't happen. - Convert M_NOWAIT allocations to M_WAITOK
Clean up crypto_init().
The function is called from a KLD load handler, so it may sleep.
- Stop checking for errors from uma_zcreate(), they don't happen. - Convert M_NOWAIT allocations to M_WAITOK. - Remove error handling for existing M_WAITOK allocations. - Fix style.
Reviewed by: cem, delphij, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D25696
show more ...
|
#
946b8f6f |
| 16-Jul-2020 |
John Baldwin <jhb@FreeBSD.org> |
Add crypto_initreq() and crypto_destroyreq().
These routines are similar to crypto_getreq() and crypto_freereq() but operate on caller-supplied storage instead of allocating crypto requests from a U
Add crypto_initreq() and crypto_destroyreq().
These routines are similar to crypto_getreq() and crypto_freereq() but operate on caller-supplied storage instead of allocating crypto requests from a UMA zone.
Reviewed by: markj Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D25691
show more ...
|
#
7290cb47 |
| 01-Jul-2020 |
Mark Johnston <markj@FreeBSD.org> |
Convert cryptostats to a counter_u64 array.
The global counters were not SMP-friendly. Use per-CPU counters instead.
Reviewed by: jhb Sponsored by: Rubicon Communications, LLC (Netgate) Differenti
Convert cryptostats to a counter_u64 array.
The global counters were not SMP-friendly. Use per-CPU counters instead.
Reviewed by: jhb Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D25466
show more ...
|
#
a5c053f5 |
| 30-Jun-2020 |
Mark Johnston <markj@FreeBSD.org> |
Remove CRYPTO_TIMING.
It was added a very long time ago. It is single-threaded, so only really useful for basic measurements, and in the meantime we've gotten some more sophisticated profiling tool
Remove CRYPTO_TIMING.
It was added a very long time ago. It is single-threaded, so only really useful for basic measurements, and in the meantime we've gotten some more sophisticated profiling tools.
Reviewed by: cem, delphij, jhb Sponsored by: Rubicon Communications, LLC (Netgate) Differential Revision: https://reviews.freebsd.org/D25464
show more ...
|
#
17a831ea |
| 25-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Zero the temporary HMAC key in hmac_init_pad().
Reviewed by: delphij Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25436
|
#
4a711b8d |
| 25-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Use zfree() instead of explicit_bzero() and free().
In addition to reducing lines of code, this also ensures that the full allocation is always zeroed avoiding possible bugs with incorrect lengths p
Use zfree() instead of explicit_bzero() and free().
In addition to reducing lines of code, this also ensures that the full allocation is always zeroed avoiding possible bugs with incorrect lengths passed to explicit_bzero().
Suggested by: cem Reviewed by: cem, delphij Approved by: csprng (cem) Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25435
show more ...
|
#
9b774dc0 |
| 23-Jun-2020 |
John Baldwin <jhb@FreeBSD.org> |
Add support to the crypto framework for separate AAD buffers.
This permits requests to provide the AAD in a separate side buffer instead of as a region in the crypto request input buffer. This is u
Add support to the crypto framework for separate AAD buffers.
This permits requests to provide the AAD in a separate side buffer instead of as a region in the crypto request input buffer. This is useful when the main data buffer might not contain the full AAD (e.g. for TLS or IPsec with ESN).
Unlike separate IVs which are constrained in size and stored in an array in struct cryptop, separate AAD is provided by the caller setting a new crp_aad pointer to the buffer. The caller must ensure the pointer remains valid and the buffer contents static until the request is completed (e.g. when the callback routine is invoked).
As with separate output buffers, not all drivers support this feature. Consumers must request use of this feature via a new session flag.
To aid in driver testing, kern.crypto.cryptodev_separate_aad can be set to force /dev/crypto requests to use a separate AAD buffer.
Discussed with: cem Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D25288
show more ...
|
Revision tags: release/11.4.0 |
|
#
33f3bad3 |
| 26-May-2020 |
John Baldwin <jhb@FreeBSD.org> |
Export the _kern_crypto sysctl node from crypto.c.
Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D24545
|
#
9c0e3d3a |
| 26-May-2020 |
John Baldwin <jhb@FreeBSD.org> |
Add support for optional separate output buffers to in-kernel crypto.
Some crypto consumers such as GELI and KTLS for file-backed sendfile need to store their output in a separate buffer from the in
Add support for optional separate output buffers to in-kernel crypto.
Some crypto consumers such as GELI and KTLS for file-backed sendfile need to store their output in a separate buffer from the input. Currently these consumers copy the contents of the input buffer into the output buffer and queue an in-place crypto operation on the output buffer. Using a separate output buffer avoids this copy.
- Create a new 'struct crypto_buffer' describing a crypto buffer containing a type and type-specific fields. crp_ilen is gone, instead buffers that use a flat kernel buffer have a cb_buf_len field for their length. The length of other buffer types is inferred from the backing store (e.g. uio_resid for a uio). Requests now have two such structures: crp_buf for the input buffer, and crp_obuf for the output buffer.
- Consumers now use helper functions (crypto_use_*, e.g. crypto_use_mbuf()) to configure the input buffer. If an output buffer is not configured, the request still modifies the input buffer in-place. A consumer uses a second set of helper functions (crypto_use_output_*) to configure an output buffer.
- Consumers must request support for separate output buffers when creating a crypto session via the CSP_F_SEPARATE_OUTPUT flag and are only permitted to queue a request with a separate output buffer on sessions with this flag set. Existing drivers already reject sessions with unknown flags, so this permits drivers to be modified to support this extension without requiring all drivers to change.
- Several data-related functions now have matching versions that operate on an explicit buffer (e.g. crypto_apply_buf, crypto_contiguous_subsegment_buf, bus_dma_load_crp_buf).
- Most of the existing data-related functions operate on the input buffer. However crypto_copyback always writes to the output buffer if a request uses a separate output buffer.
- For the regions in input/output buffers, the following conventions are followed: - AAD and IV are always present in input only and their fields are offsets into the input buffer. - payload is always present in both buffers. If a request uses a separate output buffer, it must set a new crp_payload_start_output field to the offset of the payload in the output buffer. - digest is in the input buffer for verify operations, and in the output buffer for compute operations. crp_digest_start is relative to the appropriate buffer.
- Add a crypto buffer cursor abstraction. This is a more general form of some bits in the cryptosoft driver that tried to always use uio's. However, compared to the original code, this avoids rewalking the uio iovec array for requests with multiple vectors. It also avoids allocate an iovec array for mbufs and populating it by instead walking the mbuf chain directly.
- Update the cryptosoft(4) driver to support separate output buffers making use of the cursor abstraction.
Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D24545
show more ...
|
#
63823cac |
| 12-May-2020 |
John Baldwin <jhb@FreeBSD.org> |
Remove MD5 HMAC from OCF.
There are no in-kernel consumers.
Reviewed by: cem Relnotes: yes Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D24775
|
#
0e00c709 |
| 11-May-2020 |
John Baldwin <jhb@FreeBSD.org> |
Remove support for DES and Triple DES from OCF.
It no longer has any in-kernel consumers via OCF. smbfs still uses single DES directly, so sys/crypto/des remains for that use case.
Reviewed by: ce
Remove support for DES and Triple DES from OCF.
It no longer has any in-kernel consumers via OCF. smbfs still uses single DES directly, so sys/crypto/des remains for that use case.
Reviewed by: cem Relnotes: yes Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D24773
show more ...
|
#
32075647 |
| 11-May-2020 |
John Baldwin <jhb@FreeBSD.org> |
Remove support for the Blowfish algorithm from OCF.
It no longer has any in-kernel consumers.
Reviewed by: cem Relnotes: yes Sponsored by: Chelsio Communications Differential Revision: https://revi
Remove support for the Blowfish algorithm from OCF.
It no longer has any in-kernel consumers.
Reviewed by: cem Relnotes: yes Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D24772
show more ...
|