Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Nov 2010 11:43:30 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        Mike Tancsa <mike@sentex.net>
Cc:        stable@freebsd.org
Subject:   Re: Call for testers: FPU changes
Message-ID:  <20101116094330.GH2392@deviant.kiev.zoral.com.ua>
In-Reply-To: <4CE1FDBA.9030403@sentex.net>
References:  <20101115211350.GE2392@deviant.kiev.zoral.com.ua> <4CE1FDBA.9030403@sentex.net>

next in thread | previous in thread | raw e-mail | index | archive | help

--o+NaKOy/ZgNfbXd2
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Mon, Nov 15, 2010 at 10:42:50PM -0500, Mike Tancsa wrote:
> On 11/15/2010 4:13 PM, Kostik Belousov wrote:
> >=20
> > Patch is at
> > http://people.freebsd.org/~kib/misc/releng_8_fpu.1.patch
>=20
>=20
> Hi,
> 	One small failure on the patch
>=20
> The text leading up to this was:
> --------------------------
> |Index: pc98/include/npx.h
> |=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> |--- 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".

>=20
>=20
> I tested with openssl and openvpn and all seems to work great on the via
> board and my i5 board!!  Simple test details at
>=20
> http://www.tancsa.com/fpu.html
>=20
> I will try out geli and some more extensive tests tomorrow
>=20
> 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;
=20
 	td =3D curthread;
-	error =3D fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
+	if (!is_fpu_kern_thread(0)) {
+		error =3D fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
+		saved_ctx =3D 1;
+	} else {
+		error =3D 0;
+		saved_ctx =3D 0;
+	}
 	if (error =3D=3D 0) {
 		error =3D 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, struc=
t cryptodesc *enccrd,
 {
 	struct thread *td;
 	uint8_t *buf;
-	int error, allocated;
+	int error, allocated, saved_ctx;
=20
 	buf =3D aesni_cipher_alloc(enccrd, crp, &allocated);
 	if (buf =3D=3D NULL)
 		return (ENOMEM);
=20
 	td =3D curthread;
-	error =3D fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
-	if (error !=3D 0)
-		goto out;
+	if (!is_fpu_kern_thread(0)) {
+		error =3D fpu_kern_enter(td, &ses->fpu_ctx, FPU_KERN_NORMAL);
+		if (error !=3D 0)
+			goto out;
+		saved_ctx =3D 1;
+	} else {
+		saved_ctx =3D 0;
+		error =3D 0;
+	}
=20
 	if ((enccrd->crd_flags & CRD_F_KEY_EXPLICIT) !=3D 0) {
 		error =3D 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);

--o+NaKOy/ZgNfbXd2
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)

iEYEARECAAYFAkziUkIACgkQC3+MBN1Mb4iI5QCdHlqsjEY2d4IPan9+5EcabUXb
0nIAoMyrnETGquYpttWzQ7lwQhAySMsL
=T1Bt
-----END PGP SIGNATURE-----

--o+NaKOy/ZgNfbXd2--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101116094330.GH2392>