summaryrefslogtreecommitdiffstats
path: root/sys/crypto/via/padlock_cipher.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2014-06-23 07:37:54 +0000
committerkib <kib@FreeBSD.org>2014-06-23 07:37:54 +0000
commitfe547198b1973809825a6d6e48d12cf6f1c93741 (patch)
treea51002de5281f8a64709f9e315f0f0337d66108c /sys/crypto/via/padlock_cipher.c
parentc2a4e94982dc22b2ff3eb85b284839f96f217faf (diff)
downloadFreeBSD-src-fe547198b1973809825a6d6e48d12cf6f1c93741.zip
FreeBSD-src-fe547198b1973809825a6d6e48d12cf6f1c93741.tar.gz
Add FPU_KERN_KTHR flag to fpu_kern_enter(9), which avoids saving FPU
context into memory for the kernel threads which called fpu_kern_thread(9). This allows the fpu_kern_enter() callers to not check for is_fpu_kern_thread() to get the optimization. Apply the flag to padlock(4) and aesni(4). In aesni_cipher_process(), do not leak FPU context state on error. Sponsored by: The FreeBSD Foundation MFC after: 1 week
Diffstat (limited to 'sys/crypto/via/padlock_cipher.c')
-rw-r--r--sys/crypto/via/padlock_cipher.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/sys/crypto/via/padlock_cipher.c b/sys/crypto/via/padlock_cipher.c
index 7170211..0e4beb8 100644
--- a/sys/crypto/via/padlock_cipher.c
+++ b/sys/crypto/via/padlock_cipher.c
@@ -205,7 +205,7 @@ padlock_cipher_process(struct padlock_session *ses, struct cryptodesc *enccrd,
struct thread *td;
u_char *buf, *abuf;
uint32_t *key;
- int allocated, error, saved_ctx;
+ int allocated, error;
buf = padlock_cipher_alloc(enccrd, crp, &allocated);
if (buf == NULL)
@@ -250,21 +250,13 @@ padlock_cipher_process(struct padlock_session *ses, struct cryptodesc *enccrd,
}
td = curthread;
- if (!is_fpu_kern_thread(0)) {
- error = fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL);
- saved_ctx = 1;
- } else {
- error = 0;
- saved_ctx = 0;
- }
+ error = fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL |
+ FPU_KERN_KTHR);
if (error != 0)
goto out;
-
padlock_cbc(abuf, abuf, enccrd->crd_len / AES_BLOCK_LEN, key, cw,
ses->ses_iv);
-
- if (saved_ctx)
- fpu_kern_leave(td, ses->ses_fpu_ctx);
+ fpu_kern_leave(td, ses->ses_fpu_ctx);
if (allocated) {
crypto_copyback(crp->crp_flags, crp->crp_buf, enccrd->crd_skip,
OpenPOWER on IntegriCloud