Call for testers: FPU changes

Kostik Belousov kostikbel at gmail.com
Tue Nov 16 09:43:36 UTC 2010


On Mon, Nov 15, 2010 at 10:42:50PM -0500, Mike Tancsa wrote:
> On 11/15/2010 4:13 PM, Kostik Belousov wrote:
> > 
> > Patch is at
> > http://people.freebsd.org/~kib/misc/releng_8_fpu.1.patch
> 
> 
> Hi,
> 	One small failure on the patch
> 
> The text leading up to this was:
> --------------------------
> |Index: pc98/include/npx.h
> |===================================================================
> |--- pc98/include/npx.h (revision 215253)
> |+++ pc98/include/npx.h (working copy)
> --------------------------
> Patching file pc98/include/npx.h using Plan A...
> Hunk #1 failed at 1.
> 1 out of 1 hunks failed--saving rejects to pc98/include/npx.h.rej
This is because our patch(1) in base is somewhat old, I believe.
The diff was generated by svn diff from the up to date stable/8
checkout, and the reason for failure is expanded $FreeBSD$ tags.

Newer gnu patch, available in ports, handless this correctly,
reporting about patches applied with "fuzz".

> 
> 
> I tested with openssl and openvpn and all seems to work great on the via
> board and my i5 board!!  Simple test details at
> 
> http://www.tancsa.com/fpu.html
> 
> I will try out geli and some more extensive tests tomorrow
> 
> Thanks for porting this back to RELENG_8 !
This is actually somewhat puzzling. Does openssl in base automatically
use crypto(4) ?

Also, could you, please redo the speed tests for aesni(4) with the
following patch applied over the driver sources ?

Thank you !

diff --git a/sys/crypto/aesni/aesni_wrap.c b/sys/crypto/aesni/aesni_wrap.c
index 36c66ea..3fd397c 100644
--- a/sys/crypto/aesni/aesni_wrap.c
+++ b/sys/crypto/aesni/aesni_wrap.c
@@ -246,14 +246,21 @@ int
 aesni_cipher_setup(struct aesni_session *ses, struct cryptoini *encini)
 {
 	struct thread *td;
-	int error;
+	int error, saved_ctx;
 
 	td = curthread;
-	error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
+	if (!is_fpu_kern_thread(0)) {
+		error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
+		saved_ctx = 1;
+	} else {
+		error = 0;
+		saved_ctx = 0;
+	}
 	if (error == 0) {
 		error = aesni_cipher_setup_common(ses, encini->cri_key,
 		    encini->cri_klen);
-		fpu_kern_leave(td, &ses->fpu_ctx);
+		if (saved_ctx)
+			fpu_kern_leave(td, &ses->fpu_ctx);
 	}
 	return (error);
 }
@@ -264,16 +271,22 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd,
 {
 	struct thread *td;
 	uint8_t *buf;
-	int error, allocated;
+	int error, allocated, saved_ctx;
 
 	buf = aesni_cipher_alloc(enccrd, crp, &allocated);
 	if (buf == NULL)
 		return (ENOMEM);
 
 	td = curthread;
-	error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
-	if (error != 0)
-		goto out;
+	if (!is_fpu_kern_thread(0)) {
+		error = fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
+		if (error != 0)
+			goto out;
+		saved_ctx = 1;
+	} else {
+		saved_ctx = 0;
+		error = 0;
+	}
 
 	if ((enccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0) {
 		error = aesni_cipher_setup_common(ses, enccrd->crd_key,
@@ -311,7 +324,8 @@ aesni_cipher_process(struct aesni_session *ses, struct cryptodesc *enccrd,
 			    ses->iv);
 		}
 	}
-	fpu_kern_leave(td, &ses->fpu_ctx);
+	if (saved_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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-stable/attachments/20101116/b06defa5/attachment.pgp


More information about the freebsd-stable mailing list