Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 22 Mar 2010 11:57:01 +0200
From:      Kostik Belousov <kostikbel@gmail.com>
To:        arch@freebsd.org, amd64@freebsd.org
Subject:   XMM register usage in the kernel
Message-ID:  <20100322095701.GE2415@deviant.kiev.zoral.com.ua>

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

--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--



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