diff options
Diffstat (limited to 'sys/crypto/aesni')
-rw-r--r-- | sys/crypto/aesni/aesni.c | 13 | ||||
-rw-r--r-- | sys/crypto/aesni/aesni.h | 2 | ||||
-rw-r--r-- | sys/crypto/aesni/aesni_wrap.c | 8 |
3 files changed, 16 insertions, 7 deletions
diff --git a/sys/crypto/aesni/aesni.c b/sys/crypto/aesni/aesni.c index ed12f28..ca00a57 100644 --- a/sys/crypto/aesni/aesni.c +++ b/sys/crypto/aesni/aesni.c @@ -116,6 +116,7 @@ aesni_detach(device_t dev) } while ((ses = TAILQ_FIRST(&sc->sessions)) != NULL) { TAILQ_REMOVE(&sc->sessions, ses, next); + fpu_kern_free_ctx(ses->fpu_ctx); free(ses, M_AESNI); } rw_wunlock(&sc->lock); @@ -165,8 +166,13 @@ aesni_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri) rw_wunlock(&sc->lock); return (ENOMEM); } - KASSERT(((uintptr_t)ses) % 0x10 == 0, - ("malloc returned unaligned pointer")); + ses->fpu_ctx = fpu_kern_alloc_ctx(FPU_KERN_NORMAL | + FPU_KERN_NOWAIT); + if (ses->fpu_ctx == NULL) { + free(ses, M_AESNI); + rw_wunlock(&sc->lock); + return (ENOMEM); + } ses->id = sc->sid++; } else { TAILQ_REMOVE(&sc->sessions, ses, next); @@ -191,12 +197,15 @@ aesni_newsession(device_t dev, uint32_t *sidp, struct cryptoini *cri) static void aesni_freesession_locked(struct aesni_softc *sc, struct aesni_session *ses) { + struct fpu_kern_ctx *ctx; uint32_t sid; sid = ses->id; TAILQ_REMOVE(&sc->sessions, ses, next); + ctx = ses->fpu_ctx; bzero(ses, sizeof(*ses)); ses->id = sid; + ses->fpu_ctx = ctx; TAILQ_INSERT_HEAD(&sc->sessions, ses, next); } diff --git a/sys/crypto/aesni/aesni.h b/sys/crypto/aesni/aesni.h index b07ec8b..78255b7 100644 --- a/sys/crypto/aesni/aesni.h +++ b/sys/crypto/aesni/aesni.h @@ -65,7 +65,7 @@ struct aesni_session { int used; uint32_t id; TAILQ_ENTRY(aesni_session) next; - struct fpu_kern_ctx fpu_ctx; + struct fpu_kern_ctx *fpu_ctx; }; /* diff --git a/sys/crypto/aesni/aesni_wrap.c b/sys/crypto/aesni/aesni_wrap.c index 1492640..787c1a9 100644 --- a/sys/crypto/aesni/aesni_wrap.c +++ b/sys/crypto/aesni/aesni_wrap.c @@ -227,7 +227,7 @@ aesni_cipher_setup(struct aesni_session *ses, struct cryptoini *encini) td = curthread; if (!is_fpu_kern_thread(0)) { - error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL); + error = fpu_kern_enter(td, ses->fpu_ctx, FPU_KERN_NORMAL); saved_ctx = 1; } else { error = 0; @@ -237,7 +237,7 @@ aesni_cipher_setup(struct aesni_session *ses, struct cryptoini *encini) error = aesni_cipher_setup_common(ses, encini->cri_key, encini->cri_klen); if (saved_ctx) - fpu_kern_leave(td, &ses->fpu_ctx); + fpu_kern_leave(td, ses->fpu_ctx); } return (error); } @@ -256,7 +256,7 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd, td = curthread; if (!is_fpu_kern_thread(0)) { - error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL); + error = fpu_kern_enter(td, ses->fpu_ctx, FPU_KERN_NORMAL); if (error != 0) goto out; saved_ctx = 1; @@ -302,7 +302,7 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd, } } if (saved_ctx) - fpu_kern_leave(td, &ses->fpu_ctx); + fpu_kern_leave(td, ses->fpu_ctx); if (allocated) crypto_copyback(crp->crp_flags, crp->crp_buf, enccrd->crd_skip, enccrd->crd_len, buf); |