Commit Graph

31 Commits

Author SHA1 Message Date
Konstantin Belousov
3e07b6217f MFaesni r215427:
Only save FPU context when not executing in the context of the crypto
thread.

Tested by:	Mike Tancsa
MFC after:	1 week
2010-11-26 14:35:20 +00:00
Konstantin Belousov
04c49e68de Use the fpu_kern_enter() interface to properly separate usermode FPU
context from in-kernel execution of padlock instructions and to handle
spurious FPUDNA exceptions that sometime are raised when doing padlock
calculations.

Globally mark crypto(9) kthread as using FPU.

Reviewed by:	pjd
Hardware provided by:	Sentex Communications
Tested by:	  pho
PR:    amd64/135014
MFC after:    1 month
2010-06-05 16:00:53 +00:00
VANHULLEBUS Yvan
081b9301bf Changed to M_NOWAIT when reallocing psc_buf in padlock_sha_update(),
as we already hold the non sleepable crypto_driver_mutex.

Approved by:	gnn(mentor)
Obtained from:	NETASQ
MFC after:	2 weeks
2009-05-27 09:52:12 +00:00
Warner Losh
a4958494e8 identify routine takes driver_t *, not device_t *. 2009-02-05 19:30:28 +00:00
Jung-uk Kim
9045c73682 Connect padlock(4) to amd64 build for VIA Nano processors. 2009-01-12 19:23:46 +00:00
Philip Paeps
2bc989be4f Fix a potential NULL-pointer dereference in padlock(4).
Spotted by:	Coverity (via pjd)
MFC after:	1 week
2008-11-17 19:00:36 +00:00
Pawel Jakub Dawidek
b5207ec64a Simplify session selection/allocation. 2008-08-09 20:01:01 +00:00
Pawel Jakub Dawidek
ec7993f8b0 - Fix freeing session on newsession failure.
- Update copyright years.
2008-08-09 19:48:59 +00:00
Pawel Jakub Dawidek
f422e90330 Implify sessions freeing loop. 2008-08-09 19:47:19 +00:00
Pawel Jakub Dawidek
a05071e803 We don't have to drop a lock around malloc(M_NOWAIT). 2008-08-09 19:45:43 +00:00
Pawel Jakub Dawidek
eadca5921d When freeing session, restore its ID after zeroing memory.
Bug tracked down by:	Patrick Lamaiziere <patfbsd@davenulle.org>
2008-08-09 19:43:44 +00:00
Pawel Jakub Dawidek
7d8b54b5b5 Sessions in-use are at the end of the queue, so use TAILQ_FOREACH_REVERSE()
when looking for them.

Idea from:	Patrick Lamaiziere <patfbsd@davenulle.org>
2008-08-09 19:42:37 +00:00
Pawel Jakub Dawidek
48aadb632b Convert lock that protects sessions list from a mutex to a rwlock.
Now we can use read lock in fast path (padlock_process()).
2008-07-20 07:34:00 +00:00
George V. Neville-Neil
b2630c2934 Commit the change from FAST_IPSEC to IPSEC. The FAST_IPSEC
option is now deprecated, as well as the KAME IPsec code.
What was FAST_IPSEC is now IPSEC.

Approved by: re
Sponsored by: Secure Computing
2007-07-03 12:13:45 +00:00
Sam Leffler
6810ad6f2a Overhaul driver/subsystem api's:
o make all crypto drivers have a device_t; pseudo drivers like the s/w
  crypto driver synthesize one
o change the api between the crypto subsystem and drivers to use kobj;
  cryptodev_if.m defines this api
o use the fact that all crypto drivers now have a device_t to add support
  for specifying which of several potential devices to use when doing
  crypto operations
o add new ioctls that allow user apps to select a specific crypto device
  to use (previous ioctls maintained for compatibility)
o overhaul crypto subsystem code to eliminate lots of cruft and hide
  implementation details from drivers
o bring in numerous fixes from Michale Richardson/hifn; mostly for
  795x parts
o add an optional mechanism for mmap'ing the hifn 795x public key h/w
  to user space for use by openssl (not enabled by default)
o update crypto test tools to use new ioctl's and add cmd line options
  to specify a device to use for tests

These changes will also enable much future work on improving the core
crypto subsystem; including proper load balancing and interposing code
between the core and drivers to dispatch small operations to the s/w
driver as appropriate.

These changes were instigated by the work of Michael Richardson.

Reviewed by:	pjd
Approved by:	re
2007-03-21 03:42:51 +00:00
Pawel Jakub Dawidek
ef7c47775f Less magic.
MFC after:	3 days
2006-09-15 10:44:55 +00:00
Pawel Jakub Dawidek
6ea1a6d1ea Remove trailing spaces. 2006-07-28 14:48:30 +00:00
Pawel Jakub Dawidek
d5db4f4fe6 Use existing roundup2() macro.
Suggested by:	njl
2006-07-28 14:46:19 +00:00
Pawel Jakub Dawidek
23acde08e9 Remove redundant check committed by accident. 2006-07-25 20:00:55 +00:00
Pawel Jakub Dawidek
b623eec509 Avoid memory allocations when the given address is already 16 bytes aligned.
Such an address can be used directly in padlock's AES.
This improves speed of geli(8) significantly:

	# sysctl kern.geom.zero.clear=0
	# geli onetime -s 4096 gzero
	# dd if=/dev/gzero.eli of=/dev/null bs=1m count=1000

Before:	113MB/s
After:	203MB/s

BTW. If sector size is set to 128kB, I can read at 276MB/s :)
2006-07-25 19:32:58 +00:00
Pawel Jakub Dawidek
78c344f3da Modify PADLOCK_ALIGN() macro, so when the given address is already 16 bytes
aligned, it will be used directly, not 'address + 16'.
2006-07-25 19:06:54 +00:00
Pawel Jakub Dawidek
1fa760f7a0 Style fixes. 2006-07-25 19:04:26 +00:00
Pawel Jakub Dawidek
5333bd4763 Implement support for HMAC/SHA1 and HMAC/SHA256 acceleration found in
new VIA CPUs.
For older CPUs HMAC/SHA1 and HMAC/SHA256 (and others) will still be done
in software.

Move symmetric cryptography (currently only AES-CBC 128/192/256) to
padlock_cipher.c file. Move HMAC cryptography to padlock_hash.c file.

Hardware from:	Centaur Technologies
2006-07-22 16:18:47 +00:00
Pawel Jakub Dawidek
9f5dc73906 Correct few bzero()s.
MFC after:	3 days
2006-07-22 13:14:11 +00:00
Pawel Jakub Dawidek
5362e27b6d Set ses_ictx and ses_octx to NULL after freeing them, so we won't free
them twice.
This is possible for example in situation when session is used in
authentication context, then freed and then used in encryption context
and freed - in encryption context ses_ictx and ses_octx are not touched
at newsession time, but padlock_freesession could still try to free them
when they are not NULL.
2006-07-22 10:04:47 +00:00
Michael Reifenberger
4fd58e10b2 Use the already stored VIA RNG probe information
instead of probing again.
Adjust style(9) somewhat in probe.c

Reviewed by:	pjd
MFC after:	1 week
2006-07-13 09:15:14 +00:00
Pawel Jakub Dawidek
bb34821048 Fix gratuitous compiler warning.
Reported by:	Rong-en Fan <grafan@gmail.com>
2006-06-08 17:40:02 +00:00
Pawel Jakub Dawidek
64e18040cc - Pretend to accelerate various HMAC algorithms, so padlock(4) can be used
with fast_ipsec(4) and geli(8) authentication (comming soon).
  If consumer requests only for HMAC algorithm (without encryption), return
  EINVAL.
- Add support for the CRD_F_KEY_EXPLICIT flag, for both encryption and
  authentication.
2006-06-05 16:22:04 +00:00
Pawel Jakub Dawidek
eb340a613c padlock(4) doesn't support explicitly provided keys yet.
Return an error instead of encrypting/decrypting data with a wrong key.
2006-04-20 06:31:44 +00:00
Pawel Jakub Dawidek
f3b67db31a On padlock initialization, allocate memory with M_WAITOK. 2006-04-12 12:13:34 +00:00
Pawel Jakub Dawidek
ef0a6e203b Add VIA/ACE "PadLock" support as a crypto(9) driver.
HW donated by:			Mike Tancsa <mike@sentex.net>
Most of the code obtained from:	OpenBSD
MFC after:			3 days
2005-08-18 00:30:22 +00:00