From owner-svn-src-all@FreeBSD.ORG Fri Nov 26 14:35:21 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EA362106566C; Fri, 26 Nov 2010 14:35:20 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id D816C8FC15; Fri, 26 Nov 2010 14:35:20 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAQEZKdK047257; Fri, 26 Nov 2010 14:35:20 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAQEZKxk047253; Fri, 26 Nov 2010 14:35:20 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201011261435.oAQEZKxk047253@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 26 Nov 2010 14:35:20 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215864 - head/sys/crypto/via X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 26 Nov 2010 14:35:21 -0000 Author: kib Date: Fri Nov 26 14:35:20 2010 New Revision: 215864 URL: http://svn.freebsd.org/changeset/base/215864 Log: MFaesni r215427: Only save FPU context when not executing in the context of the crypto thread. Tested by: Mike Tancsa MFC after: 1 week Modified: head/sys/crypto/via/padlock.c head/sys/crypto/via/padlock_cipher.c head/sys/crypto/via/padlock_hash.c Modified: head/sys/crypto/via/padlock.c ============================================================================== --- head/sys/crypto/via/padlock.c Fri Nov 26 11:57:45 2010 (r215863) +++ head/sys/crypto/via/padlock.c Fri Nov 26 14:35:20 2010 (r215864) @@ -170,7 +170,7 @@ padlock_newsession(device_t dev, uint32_ struct padlock_session *ses = NULL; struct cryptoini *encini, *macini; struct thread *td; - int error; + int error, saved_ctx; if (sidp == NULL || cri == NULL) return (EINVAL); @@ -238,10 +238,18 @@ padlock_newsession(device_t dev, uint32_ if (macini != NULL) { td = curthread; - error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL); + if (!is_fpu_kern_thread(0)) { + error = fpu_kern_enter(td, &ses->ses_fpu_ctx, + FPU_KERN_NORMAL); + saved_ctx = 1; + } else { + error = 0; + saved_ctx = 0; + } if (error == 0) { error = padlock_hash_setup(ses, macini); - fpu_kern_leave(td, &ses->ses_fpu_ctx); + if (saved_ctx) + fpu_kern_leave(td, &ses->ses_fpu_ctx); } if (error != 0) { padlock_freesession_one(sc, ses, 0); Modified: head/sys/crypto/via/padlock_cipher.c ============================================================================== --- head/sys/crypto/via/padlock_cipher.c Fri Nov 26 11:57:45 2010 (r215863) +++ head/sys/crypto/via/padlock_cipher.c Fri Nov 26 14:35:20 2010 (r215864) @@ -205,7 +205,7 @@ padlock_cipher_process(struct padlock_se struct thread *td; u_char *buf, *abuf; uint32_t *key; - int allocated, error; + int allocated, error, saved_ctx; buf = padlock_cipher_alloc(enccrd, crp, &allocated); if (buf == NULL) @@ -250,14 +250,21 @@ padlock_cipher_process(struct padlock_se } td = curthread; - error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL); + if (!is_fpu_kern_thread(0)) { + error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL); + saved_ctx = 1; + } else { + error = 0; + saved_ctx = 0; + } if (error != 0) goto out; padlock_cbc(abuf, abuf, enccrd->crd_len / AES_BLOCK_LEN, key, cw, ses->ses_iv); - fpu_kern_leave(td, &ses->ses_fpu_ctx); + if (saved_ctx) + fpu_kern_leave(td, &ses->ses_fpu_ctx); if (allocated) { crypto_copyback(crp->crp_flags, crp->crp_buf, enccrd->crd_skip, Modified: head/sys/crypto/via/padlock_hash.c ============================================================================== --- head/sys/crypto/via/padlock_hash.c Fri Nov 26 11:57:45 2010 (r215863) +++ head/sys/crypto/via/padlock_hash.c Fri Nov 26 14:35:20 2010 (r215864) @@ -366,17 +366,24 @@ padlock_hash_process(struct padlock_sess struct cryptop *crp) { struct thread *td; - int error; + int error, saved_ctx; td = curthread; - error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL); + if (!is_fpu_kern_thread(0)) { + error = fpu_kern_enter(td, &ses->ses_fpu_ctx, FPU_KERN_NORMAL); + saved_ctx = 1; + } else { + error = 0; + saved_ctx = 0; + } if (error != 0) return (error); if ((maccrd->crd_flags & CRD_F_KEY_EXPLICIT) != 0) padlock_hash_key_setup(ses, maccrd->crd_key, maccrd->crd_klen); error = padlock_authcompute(ses, maccrd, crp->crp_buf, crp->crp_flags); - fpu_kern_leave(td, &ses->ses_fpu_ctx); + if (saved_ctx) + fpu_kern_leave(td, &ses->ses_fpu_ctx); return (error); }