From owner-freebsd-amd64@FreeBSD.ORG Mon Mar 22 10:23:02 2010 Return-Path: Delivered-To: amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A2BB1065672 for ; Mon, 22 Mar 2010 10:23:02 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from mail.zoral.com.ua (mx0.zoral.com.ua [91.193.166.200]) by mx1.freebsd.org (Postfix) with ESMTP id 5D5CF8FC0A for ; Mon, 22 Mar 2010 10:23:00 +0000 (UTC) Received: from deviant.kiev.zoral.com.ua (root@deviant.kiev.zoral.com.ua [10.1.1.148]) by mail.zoral.com.ua (8.14.2/8.14.2) with ESMTP id o2M9v1Ah049053 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Mon, 22 Mar 2010 11:57:01 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: from deviant.kiev.zoral.com.ua (kostik@localhost [127.0.0.1]) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4) with ESMTP id o2M9v1Ln066249; Mon, 22 Mar 2010 11:57:01 +0200 (EET) (envelope-from kostikbel@gmail.com) Received: (from kostik@localhost) by deviant.kiev.zoral.com.ua (8.14.4/8.14.4/Submit) id o2M9v1Qb066248; Mon, 22 Mar 2010 11:57:01 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: deviant.kiev.zoral.com.ua: kostik set sender to kostikbel@gmail.com using -f Date: Mon, 22 Mar 2010 11:57:01 +0200 From: Kostik Belousov To: arch@freebsd.org, amd64@freebsd.org Message-ID: <20100322095701.GE2415@deviant.kiev.zoral.com.ua> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7CZp05NP8/gJM8Cl" Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Virus-Scanned: clamav-milter 0.95.2 at skuns.kiev.zoral.com.ua X-Virus-Status: Clean X-Spam-Status: No, score=-3.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00, DNS_FROM_OPENWHOIS autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on skuns.kiev.zoral.com.ua Cc: Subject: XMM register usage in the kernel X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Mar 2010 10:23:02 -0000 --7CZp05NP8/gJM8Cl Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hello, apparently, my Core i7 930 does not support AES-NI. I read too much about this thing before realizing that I do not have access to supported CPU, so I had a time to prototype support for using XMM registers and, in some degree, a coprocessor features, in the kernel mode for AMD64. The i386 could be done in a similar manner, but would be less clean, it seems. The KPI consists of two functions, fpu_kern_enter() and fpu_kern_leave(). The pair should brace the region of code that intend to use coprocessor. Caller shall provide the context save area, I expect that usually this memory will be allocated as part of larger subsystem data structure. fpu_kern_enter() allows the nesting, assuming fpu_kern_leave() is called proper number of times to pop the context stack. I deliberately ignored the issue of handling the coprocessor exceptions in the kernel mode. My assumption is that this facility is for the things like AES-NI or similar, where exceptions are not generated if proper programming is ensured. Prototyped patch is at http://people.freebsd.org/~kib/misc/amd64_kern_fpu.1.patch Example usage can be seen at http://people.freebsd.org/~kib/misc/kernfpu (note that example does not follow the guidelines above, usermode can easily crash kernel module, but the goal was to give an example of KPI usage). Awaiting for feedback, thanks. --7CZp05NP8/gJM8Cl Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (FreeBSD) iEYEARECAAYFAkunPu0ACgkQC3+MBN1Mb4gFfQCg3o5rkj8YTcDGSLmkblbIzmK/ IUAAn2A35KYd5esZWz92+2yrURfE4sZM =R42e -----END PGP SIGNATURE----- --7CZp05NP8/gJM8Cl--