[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree

zrouter-src-freebsd at zrouter.org zrouter-src-freebsd at zrouter.org
Wed Feb 1 10:56:33 UTC 2012


details:   http://zrouter.org/hg/FreeBSD/head//rev/7f838fc4de58
changeset: 308:7f838fc4de58
user:      ray at terran.dlink.ua
date:      Wed Feb 01 11:31:56 2012 +0200
description:
Update sys/crypto

diffstat:

 head/sys/crypto/aesni/aesni.c        |  15 ++++++++++++---
 head/sys/crypto/aesni/aesni.h        |   4 ++--
 head/sys/crypto/aesni/aesni_wrap.c   |  10 +++++-----
 head/sys/crypto/via/padlock.c        |  17 ++++++++++++++---
 head/sys/crypto/via/padlock.h        |   4 ++--
 head/sys/crypto/via/padlock_cipher.c |   6 +++---
 head/sys/crypto/via/padlock_hash.c   |   6 +++---
 7 files changed, 41 insertions(+), 21 deletions(-)

diffs (273 lines):

diff -r f683213c97d4 -r 7f838fc4de58 head/sys/crypto/aesni/aesni.c
--- a/head/sys/crypto/aesni/aesni.c	Wed Feb 01 11:31:34 2012 +0200
+++ b/head/sys/crypto/aesni/aesni.c	Wed Feb 01 11:31:56 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/crypto/aesni/aesni.c 230426 2012-01-21 17:45:27Z kib $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -116,6 +116,7 @@
 	}
 	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 @@
 			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 @@
 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 -r f683213c97d4 -r 7f838fc4de58 head/sys/crypto/aesni/aesni.h
--- a/head/sys/crypto/aesni/aesni.h	Wed Feb 01 11:31:34 2012 +0200
+++ b/head/sys/crypto/aesni/aesni.h	Wed Feb 01 11:31:56 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/sys/crypto/aesni/aesni.h 230426 2012-01-21 17:45:27Z kib $
  */
 
 #ifndef _AESNI_H_
@@ -65,7 +65,7 @@
 	int used;
 	uint32_t id;
 	TAILQ_ENTRY(aesni_session) next;
-	struct fpu_kern_ctx fpu_ctx;
+	struct fpu_kern_ctx *fpu_ctx;
 };
 
 /*
diff -r f683213c97d4 -r 7f838fc4de58 head/sys/crypto/aesni/aesni_wrap.c
--- a/head/sys/crypto/aesni/aesni_wrap.c	Wed Feb 01 11:31:34 2012 +0200
+++ b/head/sys/crypto/aesni/aesni_wrap.c	Wed Feb 01 11:31:56 2012 +0200
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: head/sys/crypto/aesni/aesni_wrap.c 226839 2011-10-27 14:15:26Z pjd $");
+__FBSDID("$FreeBSD: head/sys/crypto/aesni/aesni_wrap.c 230426 2012-01-21 17:45:27Z kib $");
 
 #include <sys/param.h>
 #include <sys/libkern.h>
@@ -227,7 +227,7 @@
 
 	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 @@
 		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 @@
 
 	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 @@
 		}
 	}
 	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);
diff -r f683213c97d4 -r 7f838fc4de58 head/sys/crypto/via/padlock.c
--- a/head/sys/crypto/via/padlock.c	Wed Feb 01 11:31:34 2012 +0200
+++ b/head/sys/crypto/via/padlock.c	Wed Feb 01 11:31:56 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/crypto/via/padlock.c 230426 2012-01-21 17:45:27Z kib $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -156,6 +156,7 @@
 	}
 	while ((ses = TAILQ_FIRST(&sc->sc_sessions)) != NULL) {
 		TAILQ_REMOVE(&sc->sc_sessions, ses, ses_next);
+		fpu_kern_free_ctx(ses->ses_fpu_ctx);
 		free(ses, M_PADLOCK);
 	}
 	rw_destroy(&sc->sc_sessions_lock);
@@ -222,6 +223,13 @@
 			rw_wunlock(&sc->sc_sessions_lock);
 			return (ENOMEM);
 		}
+		ses->ses_fpu_ctx = fpu_kern_alloc_ctx(FPU_KERN_NORMAL |
+		    FPU_KERN_NOWAIT);
+		if (ses->ses_fpu_ctx == NULL) {
+			free(ses, M_PADLOCK);
+			rw_wunlock(&sc->sc_sessions_lock);
+			return (ENOMEM);
+		}
 		ses->ses_id = sc->sc_sid++;
 	} else {
 		TAILQ_REMOVE(&sc->sc_sessions, ses, ses_next);
@@ -239,7 +247,7 @@
 	if (macini != NULL) {
 		td = curthread;
 		if (!is_fpu_kern_thread(0)) {
-			error = fpu_kern_enter(td, &ses->ses_fpu_ctx,
+			error = fpu_kern_enter(td, ses->ses_fpu_ctx,
 			    FPU_KERN_NORMAL);
 			saved_ctx = 1;
 		} else {
@@ -249,7 +257,7 @@
 		if (error == 0) {
 			error = padlock_hash_setup(ses, macini);
 			if (saved_ctx)
-				fpu_kern_leave(td, &ses->ses_fpu_ctx);
+				fpu_kern_leave(td, ses->ses_fpu_ctx);
 		}
 		if (error != 0) {
 			padlock_freesession_one(sc, ses, 0);
@@ -265,15 +273,18 @@
 padlock_freesession_one(struct padlock_softc *sc, struct padlock_session *ses,
     int locked)
 {
+	struct fpu_kern_ctx *ctx;
 	uint32_t sid = ses->ses_id;
 
 	if (!locked)
 		rw_wlock(&sc->sc_sessions_lock);
 	TAILQ_REMOVE(&sc->sc_sessions, ses, ses_next);
 	padlock_hash_free(ses);
+	ctx = ses->ses_fpu_ctx;
 	bzero(ses, sizeof(*ses));
 	ses->ses_used = 0;
 	ses->ses_id = sid;
+	ses->ses_fpu_ctx = ctx;
 	TAILQ_INSERT_HEAD(&sc->sc_sessions, ses, ses_next);
 	if (!locked)
 		rw_wunlock(&sc->sc_sessions_lock);
diff -r f683213c97d4 -r 7f838fc4de58 head/sys/crypto/via/padlock.h
--- a/head/sys/crypto/via/padlock.h	Wed Feb 01 11:31:34 2012 +0200
+++ b/head/sys/crypto/via/padlock.h	Wed Feb 01 11:31:56 2012 +0200
@@ -23,7 +23,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD$
+ * $FreeBSD: head/sys/crypto/via/padlock.h 230426 2012-01-21 17:45:27Z kib $
  */
 
 #ifndef _PADLOCK_H_
@@ -76,7 +76,7 @@
 	int		ses_used;
 	uint32_t	ses_id;
 	TAILQ_ENTRY(padlock_session) ses_next;
-	struct fpu_kern_ctx ses_fpu_ctx;
+	struct fpu_kern_ctx *ses_fpu_ctx;
 };
 
 #define	PADLOCK_ALIGN(p)	(void *)(roundup2((uintptr_t)(p), 16))
diff -r f683213c97d4 -r 7f838fc4de58 head/sys/crypto/via/padlock_cipher.c
--- a/head/sys/crypto/via/padlock_cipher.c	Wed Feb 01 11:31:34 2012 +0200
+++ b/head/sys/crypto/via/padlock_cipher.c	Wed Feb 01 11:31:56 2012 +0200
@@ -45,7 +45,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/crypto/via/padlock_cipher.c 230426 2012-01-21 17:45:27Z kib $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -251,7 +251,7 @@
 
 	td = curthread;
 	if (!is_fpu_kern_thread(0)) {
-		error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+		error = fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL);
 		saved_ctx = 1;
 	} else {
 		error = 0;
@@ -264,7 +264,7 @@
 	    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,
diff -r f683213c97d4 -r 7f838fc4de58 head/sys/crypto/via/padlock_hash.c
--- a/head/sys/crypto/via/padlock_hash.c	Wed Feb 01 11:31:34 2012 +0200
+++ b/head/sys/crypto/via/padlock_hash.c	Wed Feb 01 11:31:56 2012 +0200
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: head/sys/crypto/via/padlock_hash.c 230426 2012-01-21 17:45:27Z kib $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -370,7 +370,7 @@
 
 	td = curthread;
 	if (!is_fpu_kern_thread(0)) {
-		error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL);
+		error = fpu_kern_enter(td, ses->ses_fpu_ctx, FPU_KERN_NORMAL);
 		saved_ctx = 1;
 	} else {
 		error = 0;
@@ -383,7 +383,7 @@
 
 	error = padlock_authcompute(ses, maccrd, crp->crp_buf, crp->crp_flags);
 	if (saved_ctx)
-		fpu_kern_leave(td, &ses->ses_fpu_ctx);
+		fpu_kern_leave(td, ses->ses_fpu_ctx);
 	return (error);
 }
 


More information about the Zrouter-src-freebsd mailing list