svn commit: r216155 - stable/8/sys/crypto/via
Konstantin Belousov
kib at FreeBSD.org
Fri Dec 3 16:40:48 UTC 2010
Author: kib
Date: Fri Dec 3 16:40:47 2010
New Revision: 216155
URL: http://svn.freebsd.org/changeset/base/216155
Log:
MFC r215864:
MFaesni r215427:
Only save FPU context when not executing in the context of the crypto
thread.
Approved by: re (bz)
Modified:
stable/8/sys/crypto/via/padlock.c
stable/8/sys/crypto/via/padlock_cipher.c
stable/8/sys/crypto/via/padlock_hash.c
Directory Properties:
stable/8/sys/ (props changed)
stable/8/sys/amd64/include/xen/ (props changed)
stable/8/sys/cddl/contrib/opensolaris/ (props changed)
stable/8/sys/contrib/dev/acpica/ (props changed)
stable/8/sys/contrib/pf/ (props changed)
Modified: stable/8/sys/crypto/via/padlock.c
==============================================================================
--- stable/8/sys/crypto/via/padlock.c Fri Dec 3 16:37:37 2010 (r216154)
+++ stable/8/sys/crypto/via/padlock.c Fri Dec 3 16:40:47 2010 (r216155)
@@ -170,7 +170,7 @@ padlock_newsession(device_t dev, uint32_
struct padlock_session *ses = NULL;
struct cryptoini *encini, *macini;
struct thread *td;
- int error;
+ int error, saved_ctx;
if (sidp == NULL || cri == NULL)
return (EINVAL);
@@ -238,10 +238,18 @@ padlock_newsession(device_t dev, uint32_
if (macini != NULL) {
td = curthread;
- error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ 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;
+ }
if (error == 0) {
error = padlock_hash_setup(ses, macini);
- fpu_kern_leave(td, &ses->ses_fpu_ctx);
+ if (saved_ctx)
+ fpu_kern_leave(td, &ses->ses_fpu_ctx);
}
if (error != 0) {
padlock_freesession_one(sc, ses, 0);
Modified: stable/8/sys/crypto/via/padlock_cipher.c
==============================================================================
--- stable/8/sys/crypto/via/padlock_cipher.c Fri Dec 3 16:37:37 2010 (r216154)
+++ stable/8/sys/crypto/via/padlock_cipher.c Fri Dec 3 16:40:47 2010 (r216155)
@@ -205,7 +205,7 @@ padlock_cipher_process(struct padlock_se
struct thread *td;
u_char *buf, *abuf;
uint32_t *key;
- int allocated, error;
+ int allocated, error, saved_ctx;
buf = padlock_cipher_alloc(enccrd, crp, &allocated);
if (buf == NULL)
@@ -250,14 +250,21 @@ padlock_cipher_process(struct padlock_se
}
td = curthread;
- error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ 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;
+ }
if (error != 0)
goto out;
padlock_cbc(abuf, abuf, enccrd->crd_len / AES_BLOCK_LEN, key, cw,
ses->ses_iv);
- fpu_kern_leave(td, &ses->ses_fpu_ctx);
+ if (saved_ctx)
+ fpu_kern_leave(td, &ses->ses_fpu_ctx);
if (allocated) {
crypto_copyback(crp->crp_flags, crp->crp_buf, enccrd->crd_skip,
Modified: stable/8/sys/crypto/via/padlock_hash.c
==============================================================================
--- stable/8/sys/crypto/via/padlock_hash.c Fri Dec 3 16:37:37 2010 (r216154)
+++ stable/8/sys/crypto/via/padlock_hash.c Fri Dec 3 16:40:47 2010 (r216155)
@@ -366,17 +366,24 @@ padlock_hash_process(struct padlock_sess
struct cryptop *crp)
{
struct thread *td;
- int error;
+ int error, saved_ctx;
td = curthread;
- error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+ 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;
+ }
if (error != 0)
return (error);
if ((maccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0)
padlock_hash_key_setup(ses, maccrd->crd_key, maccrd->crd_klen);
error = padlock_authcompute(ses, maccrd, crp->crp_buf, crp->crp_flags);
- fpu_kern_leave(td, &ses->ses_fpu_ctx);
+ if (saved_ctx)
+ fpu_kern_leave(td, &ses->ses_fpu_ctx);
return (error);
}
More information about the svn-src-stable
mailing list