diff options
author | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-09-07 15:51:01 +0000 |
---|---|---|
committer | Mike Belopuhov <mikeb@cvs.openbsd.org> | 2010-09-07 15:51:01 +0000 |
commit | 06c96fb315950bff13bd7a73d355ebdc21e85191 (patch) | |
tree | 454389d119b861866a733fe99fb0d0d111b59309 /sys/arch | |
parent | 2f79671f1f8e174e8dea4ecbed5496bfcd2198fd (diff) |
shorten fpu critical sections so that all frees and other manipulations
won't interfere with an actual fp code.
reminder from kettenis: fpu_kernel_enter and fpu_kernel_exit should be
thought of as if they were mutex_enter and mutex_leave in regard to the
length of critical section and sleeps.
ok kettenis thib
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/aesni.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/sys/arch/amd64/amd64/aesni.c b/sys/arch/amd64/amd64/aesni.c index bb84d680e54..b698bac4928 100644 --- a/sys/arch/amd64/amd64/aesni.c +++ b/sys/arch/amd64/amd64/aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aesni.c,v 1.8 2010/07/22 12:47:40 thib Exp $ */ +/* $OpenBSD: aesni.c,v 1.9 2010/09/07 15:51:00 mikeb Exp $ */ /*- * Copyright (c) 2003 Jason Wright * Copyright (c) 2003, 2004 Theo de Raadt @@ -160,13 +160,14 @@ aesni_newsession(u_int32_t *sidp, struct cryptoini *cri) ses->ses_used = 1; - fpu_kernel_enter(); for (c = cri; c != NULL; c = c->cri_next) { switch (c->cri_alg) { case CRYPTO_AES_CBC: ses->ses_klen = c->cri_klen / 8; arc4random_buf(ses->ses_iv, 16); + fpu_kernel_enter(); aesni_set_key(ses, c->cri_key, ses->ses_klen); + fpu_kernel_exit(); break; case CRYPTO_AES_CTR: @@ -174,7 +175,9 @@ aesni_newsession(u_int32_t *sidp, struct cryptoini *cri) bcopy(c->cri_key + ses->ses_klen, ses->ses_nonce, AESCTR_NONCESIZE); arc4random_buf(ses->ses_iv, 8); + fpu_kernel_enter(); aesni_set_key(ses, c->cri_key, ses->ses_klen); + fpu_kernel_exit(); break; case CRYPTO_MD5_HMAC: @@ -246,7 +249,6 @@ aesni_newsession(u_int32_t *sidp, struct cryptoini *cri) return (EINVAL); } } - fpu_kernel_exit(); *sidp = ses->ses_sid; return (0); @@ -387,6 +389,7 @@ aesni_encdec(struct cryptop *crp, struct cryptodesc *crd, bcopy(crp->crp_buf + crd->crd_skip, buf, crd->crd_len); /* Apply cipher */ + fpu_kernel_enter(); if (crd->crd_alg == CRYPTO_AES_CBC) { if (crd->crd_flags & CRD_F_ENCRYPT) aesni_cbc_enc(ses, buf, buf, crd->crd_len, iv); @@ -395,6 +398,7 @@ aesni_encdec(struct cryptop *crp, struct cryptodesc *crd, } else if (crd->crd_alg == CRYPTO_AES_CTR) { aesni_ctr_enc(ses, buf, buf, crd->crd_len, iv); } + fpu_kernel_exit(); aesni_ops++; @@ -459,14 +463,13 @@ aesni_process(struct cryptop *crp) goto out; } - fpu_kernel_enter(); for (crd = crp->crp_desc; crd; crd = crd->crd_next) { switch (crd->crd_alg) { case CRYPTO_AES_CBC: case CRYPTO_AES_CTR: err = aesni_encdec(crp, crd, ses); if (err != 0) - goto cleanup; + goto out; break; case CRYPTO_MD5_HMAC: @@ -478,16 +481,15 @@ aesni_process(struct cryptop *crp) err = aesni_swauth(crp, crd, ses->ses_swd, crp->crp_buf); if (err != 0) - goto cleanup; + goto out; break; default: err = EINVAL; - goto cleanup; + goto out; } } -cleanup: - fpu_kernel_exit(); + out: crp->crp_etype = err; crypto_done(crp); |