christos
8bbf9e0cc7
- acquire lock
...
- use c99 loop indexes
- initialize featp
2017-06-06 18:08:23 +00:00
knakahara
2c01b23ab6
apply the same fix as crypto.c:r1.83 for crypto_dispatch to crypto_kdispatch.
2017-06-06 04:11:41 +00:00
knakahara
239ae8baa7
avoid crp_q reordering as hardware interrupts.
...
crypto_{,k}invoke() can be called with holding crp_q_mtx now.
2017-06-06 01:51:39 +00:00
knakahara
15bd7242d4
add locking notes.
2017-06-06 01:48:33 +00:00
knakahara
3fe5189186
restructure locks(2/2): crypto_q_mtx can be adaptive now.
2017-06-06 01:47:23 +00:00
knakahara
bd79c5ac85
restructure locks(1/2): make relation between lock and data explicit.
...
+ crypto_drv_mtx protects
- whole crypto_drivers
+ crypto_drivers[i].cc_lock (new) protects
- crypto_drivers[i] itself
- member of crypto_drivers[i]
+ crypto_q_mtx protects
- crp_q
- crp_kq
+ crypto_ret_q_mtx protects
- crp_ret_q
- crp_ret_kq
- crypto_exit_flag
I will add locking note later.
2017-06-06 01:45:57 +00:00
knakahara
039014ebf0
fix reading crp_q without holding crypto_q_mtx
2017-06-05 09:09:13 +00:00
knakahara
54c9a772b6
use crypto_checkdriver_uninit() when it may touch uninitialized crypto_drivers.
2017-06-05 09:07:46 +00:00
knakahara
6623cb2c35
rename crypto_mtx to cryptodev_mtx
...
It is used by cryptodev.c and ocryptodev.c only.
2017-06-02 09:46:57 +00:00
knakahara
993fdeeca1
swcrypto0 was initialized twice. Fix like pseudo network interfaces.
...
ok by pgoyette@n.o.
2017-06-01 08:49:35 +00:00
knakahara
a54dc18f22
fix: crypto_unregister didn't work.
2017-05-31 02:17:49 +00:00
knakahara
a3f2d30d8e
strictly use crypto_checkdriver(i) instead of using crypto_drivers[i] directly.
2017-05-29 09:02:46 +00:00
knakahara
ecc8a11166
add cryptkop alloc/free KPI instead of manipulating cryptkop_pool directly.
2017-05-25 05:24:57 +00:00
knakahara
cce0fc1eef
remove obsoleted declarations.
2017-05-25 05:22:55 +00:00
knakahara
c7023dc150
make the default values of q_maxlen build parameters.
2017-05-24 10:05:09 +00:00
knakahara
48886aaf2c
implement crypto_ret_q limitation. original code is implemented by hsuenaga@IIJ.
2017-05-24 09:57:36 +00:00
knakahara
6b65b884b0
add crypto_ret_{,k}q length sysctl entries and statistics codes.
2017-05-24 09:54:35 +00:00
knakahara
e8e1213ba4
initialize sysctl in the same way regardless of module or not.
2017-05-24 05:11:29 +00:00
knakahara
e8378c51a8
decrease the priority of batch crp even if there are more than one batch crp.
2017-05-17 12:11:41 +00:00
knakahara
b83761f2b5
refactor cryptointr(), no functional changes.
2017-05-17 11:04:38 +00:00
knakahara
4cc846107d
fix cryptointr() can process unexpected request.
...
If migrate crp is linked after batch crp, "submit" is already set to
the batch crp. So, cryptointr() can process the batch crp instead of
the target migrate crp.
2017-05-17 11:03:42 +00:00
knakahara
3e6db4b451
refactor crypto_kdispatch() in a similar way as crypto_dispatch().
2017-05-17 07:12:50 +00:00
knakahara
e309e6bf6a
refactor crypto_dispatch (3/3): do "blocked" operation previously
2017-05-17 06:53:02 +00:00
knakahara
c42317cfcb
refactor crypto_dispatch (2/3): divide migrate operation
2017-05-17 06:52:08 +00:00
knakahara
818d6afe60
refactor crypto_dispatch (1/3): divide batch operation
...
Processing batch operation at first, crypto_q_mtx's lock region is reduced
because crp does not require crypto_q_mtx.
2017-05-17 06:50:12 +00:00
knakahara
c4e549c723
opencrypto: cleanup debug messages.
2017-05-17 06:33:04 +00:00
knakahara
6168db0fda
fix: crypto_drivers[hid].cc_process() could be called even if it was null.
...
If a crypto driver is unregistered before calling cyrptointr(),
the crypto_drivers[hid].cc_process is null in spite of the hid
is less than crypto_drivers_num.
reffered to FreeBSD code.
2017-05-10 09:45:51 +00:00
knakahara
408cf9521a
unify implementation of crypto_unregister() and crypto_unregister_all()
2017-05-10 03:26:33 +00:00
knakahara
f7fc02af1d
refactor crypto_unregister()
...
- separate logic to crypto_unregister_locked()
- refactor cryptocap cleanup condition
2017-05-10 03:23:26 +00:00
knakahara
0ab4de07a8
use macro instead of immediate value
2017-05-10 03:15:32 +00:00
knakahara
108266a58a
add some assertion. tested by ATF net/ipsec/ and crypto/.
2017-05-02 03:17:43 +00:00
knakahara
039bae6fac
When crypto request is deferred processing, opencrypto should not return error.
...
When the crypto device blocks a crypto request, opnecrypto enqueues the request,
that is, the request is just deferred and no error occurs.
The pseudo error causes problems, e.g. ipsec can send wrong ICMP host unreach.
contributed by hsuenaga@IIJ, thanks.
2017-04-26 03:29:36 +00:00
knakahara
396579fb7a
separate crypto_drv_mtx from crypto_mtx.
...
crypto_mtx is used only for cryptodev.c and ocryptodev.c now.
2017-04-24 03:29:37 +00:00
knakahara
240ce9665a
reduce crypto_q_mtx lock regions.
2017-04-24 02:04:55 +00:00
knakahara
3cc51cb9ba
refactor crypto_unblock(). No functional change.
2017-04-24 01:42:00 +00:00
maya
99104d1158
Remove duplicate assignment.
...
We assign the same value unconditionally just before.
from clang static analyzer
XXX surrounding code seems fishy
2017-04-18 17:05:05 +00:00
ozaki-r
7654585ce6
Fix usage of MD5Final/SHA1Final
...
Passing NULL as the digest parameter is wrong.
2017-04-13 01:24:34 +00:00
knakahara
b12a9cd69d
the processing said "ghastly hacks" is unnecessary now.
2017-04-07 12:17:57 +00:00
knakahara
7c4d1f974f
fix race among crypto_done(), cryptoret(), and {cryptodev_op(), cryptodev_key()}.
...
crypto_op() waited to be set CRYPTO_F_DONE with crp->crp_cv.
However, there is context switch chances between being set CRYPTO_F_DONE in
crypto_done() and done cv_signal(crp->crp_cv) in cryptodev_cb(), that is,
cryptodev_op() thread can run to cv_destroy(crp->crp_cv) before cryptoret()
thread is waken up. As a result, cryptodev_cb() can call invalid(destroyed)
cv_signal(crp->crp_cv).
Furthermore, below two implementations cause other races.
- waiting CRYPTO_F_DONE with crp->crp_cv
- context witch chances between set CRYPTO_F_DONE and cv_signal(crp->crp_cv)
So, use other flag(CRYPTO_F_DQRETQ) for cryptodev_op() and cryptodev_key(),
and then call cv_signal(crp->crp_cv) immediately after set CRYPTO_F_DQRETQ.
Tested concurrent over 20 processes with software and hardware drivers.
2017-04-07 12:15:51 +00:00
knakahara
c85f49ff91
fix build failure ALL
2017-04-06 09:39:12 +00:00
knakahara
e8a4523663
fix processes accessing /dev/crypto stall when over three processes run with a hardware encryption driver
...
The process has stalled at cv_wait(&crp->crp_cv) because cryptodev_cb()
is not called as cryptoret() kthread keep waiting at cv_wait(&cryptoret_cv).
Previous opencrypto implementation assumes the thread from cryptodev.c
does all processing in the same context, so skips enqueueing and sending
cryptoret_cv. However, the context can be switched, e.g. when we use
a hardware encryption driver.
And add debug messages.
2017-04-05 08:51:04 +00:00
knakahara
26c3616f87
fix missing mutex_exit() in crypto_destroy().
...
crypto_destroy() is called only in error case or unloading module.
2017-03-29 23:02:43 +00:00
knakahara
e2a9a464f1
fix: remove unmatched mutex_exit/enter. must be forgetting to remove at crypto.c:r1.41
2017-03-16 05:23:56 +00:00
knakahara
7e207e7bba
add sysctl to select software/hardware encryption driver. can enable CRYPTO_DEBUG.
2017-03-06 09:59:05 +00:00
knakahara
3ef7c45eeb
make some locks and condvar static
2017-02-09 06:03:29 +00:00
christos
3ee5c00a54
From Alexander Nasonov:
...
- Make constants static: Shrinks code and data size.
- Avoid overflow in limit calculation.
- Use uint8_t instead of u_char to match types
While here:
- Remove unnecessary casts
- s/u_int8_t/uint8_t/g
2016-09-26 14:50:54 +00:00
msaitoh
8bc54e5be6
KNF. Remove extra spaces. No functional change.
2016-07-07 06:55:38 +00:00
dholland
99c0175780
Needs sys/time.h for struct timespec.
2016-01-22 22:35:27 +00:00
christos
df2b8d0369
fix the build
2015-11-28 03:40:43 +00:00
pgoyette
aa36e9a178
Re-work the module init and destroy code to allow it to be unloaded and
...
then reloaded.
Should fix PR kern/49842
2015-11-28 03:06:45 +00:00