Commit Graph

501 Commits

Author SHA1 Message Date
ragge bc830a1980 Do not use the builtins for the mem* functions on vax, the compiler gets
confused with the static inline functions vax uses.
2003-08-13 11:34:24 +00:00
ragge f69577d50c Include the C versions of the string instructions.
Replace blkcpy() with a version that can handle overlapping data areas.
2003-08-13 11:32:23 +00:00
matt f70606090a Add a memset.S (does not use dcbz; to be added later). It does both bzero
and memset.
2003-08-10 21:17:08 +00:00
martin 785cae7ed0 Sync with userland version. 2003-08-10 14:20:03 +00:00
agc aad01611e7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22364, verified by myself.
2003-08-07 16:26:28 +00:00
dsl f92748a3e8 Add xlat_mbr_fstype - converts mbr type to disklabel type 2003-07-07 13:20:17 +00:00
briggs b2566d8735 Provide a strtoul() implementation based on the one in libc instead of the
totally different version that was here.  This version, of course, has an
BSD license on it while the old one did not.  This one also compiles down
to tighter code--the smaller the better for libkern & libsa.
2003-06-07 02:52:33 +00:00
itojun da3884cbf4 latest copyright notice (more loose). noted by wiz 2003-05-15 15:02:52 +00:00
itojun 99c5869d56 add strl{cpy,cat} to libkern. code from lib/libc/string (originally from openbsd). 2003-05-15 13:50:35 +00:00
christos abfff333c3 don't define TRUE and FALSE locally. 2003-04-22 15:10:04 +00:00
dsl c327a133c6 Significantly faster memcpy/memmove/bcopy and memset/bzero 2003-04-15 22:49:50 +00:00
scw bfc4be13a6 When MEMCOPY is defined, don't bother checking if a backwards-copy is
required. That's what memmove() is for.

This should fix port-powerpc/16889. The backwards copyin can confuse
uiomove/genfs_getpages, resulting in corruption of files written over NFS.
2003-04-07 21:04:19 +00:00
bjh21 f34ba16c9c NetBSD/acorn26 has used APCS-32 for years, so unifdef -U__APCS_26__. 2003-04-05 23:27:14 +00:00
matt cc005c66db Switch back to generic bzero/memset until new one is shown to work. 2003-02-25 20:15:02 +00:00
matt 97d38cdec2 Actually use bzero.S. Also fix bzero to use GET_CPUINFO 2003-02-24 07:14:17 +00:00
matt 05a4c83a70 Don't make memset.c since bzero.o has memset in addition to bzero. 2003-02-24 07:09:18 +00:00
thorpej 4245ee1663 Wrap this file in "#ifndef _STANDALONE". 2002-12-05 17:12:06 +00:00
fvdl 144469b350 Add strtoul.c 2002-11-25 00:55:22 +00:00
fvdl a186add0a8 If LIBKERN_ARCH is defined, use that as the architecture-specific
subdirectory. Needed for the x86_64 32bit compile case.
2002-11-23 23:35:50 +00:00
chris f86ab1a63e Sync arm asm libkern files with libc's asm files. 2002-11-23 14:29:29 +00:00
itohy 6e73936f81 Use assembly version of bzero() and memset(). 2002-11-20 09:52:53 +00:00
itohy 5d1c87f395 Assembly version of bzero()/memset().
Written by SHIMIZU Ryo.
2002-11-20 09:51:52 +00:00
itohy 766d863c42 memcpy() and memmove() must return the first parameter.
Problem found by itohy, fixed by SHIMIZU Ryo.
2002-11-20 09:50:37 +00:00
rearnsha 6576c49b48 Add an assembler version of strcmp, based on example code from the ARM
ARM.  As an example of the performance difference that this provides
a Dhrystone score on my Shark goes from 213k to 261k.
2002-11-16 18:27:40 +00:00
thorpej 7f74df5ef3 ABICALLS -> __ABICALLS__ 2002-11-10 18:10:25 +00:00
perry efd79c70c9 Add lint infrastructure 2002-11-02 07:48:17 +00:00
perry 6448ffbdfe set LLIBS= so we don't try to check the lint lib against llib-lc.ln 2002-11-02 07:46:42 +00:00
chs cab484e445 move includes to the top so that this builds in libc context too. 2002-10-29 04:40:55 +00:00
chs c04f87a03e remove setjmp/longjmp from libkern, they're not used. 2002-10-27 18:45:11 +00:00
chs c5a350ef59 use %g5 instead of %g7 (since we want to use %g7 for the cpu_info pointer
in the kernel).  resync libc and libkern versions of this file.
2002-10-27 18:41:27 +00:00
christos 07dca24022 make offsetof lint friendlier. 2002-10-24 20:53:50 +00:00
scw 03c573236d Replace the SuperH memcpy() with homebrewed code. The former seems to have
a subtle failure mode which can result in corruption of memory outside the
bounds of the destination buffer.
2002-10-22 12:25:18 +00:00
scw ac76a83a5c Sync with libc/quad:
As discussed (briefly) on tech-userlevel, fix our quad support to work
correctly on LP64 platforms. This is mostly just s/long/int/ in the
appropriate places.
2002-10-20 10:17:14 +00:00
scw 921743eed1 Fix a sign-extension botch for ILP32. 2002-10-19 08:54:23 +00:00
scw 0e1af8ca62 Doh. Bail out early if we're passed a zero-length buffer. 2002-10-19 08:53:45 +00:00
scw 99ad3a762b Add native optimised assembler versions of some libkern routines.
The memcpy routine is courtesy of SuperH, with some tweaks by me.

XXX: There is room for further optimisation in some of these routines.
2002-10-17 11:53:32 +00:00
jdolecek d32bd396f2 #undef ffs before the ffs() function definition, so that the name
isn't rewrote to __builtin_ffs() on gcc 2.95+; this fixes compilation
on sun2
also change the comment for function
2002-10-10 10:51:56 +00:00
jdolecek aaccb8dc2b need to include <sys/param.h> to get inline strlen() on vax; found
with help of Matt Thomas
2002-10-08 21:45:36 +00:00
simonb a30355b57a Add RCS ids. 2002-10-08 11:58:54 +00:00
dan 73390e7e36 let this compile in the non KERNEL case without NRND. 2002-10-06 13:42:36 +00:00
tls 0f95ec4fd5 ESP output was drawing down the entropy pool at a ferocious rate, a
particular problem on hosts with only wireless interfaces that are
definitely not safe to use as entropy sources.

Add arc4randbytes() which hands out bytes from the same source used
by arc4random().  This is intended to be a _temporary_ interface
until we can design and implement a better general PRNG interface
that is decoupled from the entropy-pool implementation.

Modify key_randomfill() (used only for initialization vectors on
SA creation and via key_sa_stir_iv(), which does not "stir",
despite its name) to use arc4randbytes() instead of pulling bits
directly from the entropy pool.  It is my hope that this change
will pose minimal integration problems for the KAME folks as the
random-pool interface is *already* different between each BSD
variant; this just simplifies the NetBSD case and solves a
fairly serious problem.

Note that it is generally considered acceptable cryptographic
practice to use a fast stream cipher to generate IVs for encryption
with stronger block ciphers.  For example, the use of "non-Approved"
PRNGs to generate IVs for "Approved" block ciphers is explicitly
sanctioned by FIPS 140-2.
2002-10-06 08:51:44 +00:00
tls cd114adca5 This commit includes two major changes:
1) Speed up arc4random().  We make arc4randbyte() inline, which makes this
   not much slower than, say, the other arc4 implementation in our kernel.

   We also replace four calls to arc4randbyte() with a loop, saving about
   20% on some processors where the "unrolled" arc4randbyte() calls would
   needlessly stomp the cache.

2) Address various problems with the initialization/"stirring" code,
   primarily in the area of handling of the source data from the kernel
   entropy pool.  We used to:

	a) Ask the entropy pool for 32 bytes

	b) If we got zero bytes, key with junk from the stack (ouch!)
	   which has some nasty implications, to say the least.  For
	   example, we're most likely to get zero bytes at boot time,
	   when the stack contents are even more predictable than usual.

	c) If we got less than 32 bytes but more than zero bytes, use
	   however many bytes we got as the arc4 key, copying it
	   repeatedly as per usual arc4 key setup.

	   Because of the way NetBSD's entropy pool works, this was
	   mostly harmless, because if you ask for RND_EXTRACT_ANY,
	   you always get as many bytes as you ask for.  However,
	   this is probably a security hole in the original FreeBSD
	   code, where AFAICT you might end up using an 8-bit arc4
	   key -- not good, much worse than using the output of the
	   entropy pool hash function even when it thinks it only
	   has 8 bits of entropy to give you.

	   One thing this code could do on NetBSD that was not so
	   good was to replace a key with a lot of entropy with
	   one with less entropy.  That's clearly counterproductive.

   The new code, instead:

	a) Asks for 32 good bytes.  If it gets them, use them as the
	   arc4 key in the usual way.

	b) Tracks how many entropy bytes the key it's replacing had.
	   If the new entropy request got less bytes, leave the old
	   key in place.  Note that the first time through, the "old
	   key" had zero bytes, so we'll always replace it.

	c) If we get less then 32 bytes but more than we had, request
	   EXTRACT_ANY bytes from the entropy pool, padding the key
	   out to 32 bytes which we then use as the arc4 key in the
	   usual way.

This is still really all rather backwards.  Instead of this generator
deciding to rekey itself using a basically arbitrary metric, it should
register a callback so that the entropy pool code could rekey it when
a lot of bits were available.  Details at 11.

Finally, rename the "stir" function (which did not stir) to "rekey",
which is what it actually does.
2002-10-06 06:47:40 +00:00
junyoung 2a1b344158 Unconditionally add strstr.c. Bill Studenmund. 2002-10-04 20:00:00 +00:00
junyoung 26737526db Add strstr() to libkern. For now, it's only used in i386 (for processor
identification).
2002-10-04 18:39:52 +00:00
itojun df6ef6d0d3 include rnd.h only under kernel build.
caveat: arc4random() will not get stirred in bootstrap code.
2002-10-04 07:33:26 +00:00
itojun dfea6e4344 add missing "rnd.h" include - noted by simonb 2002-10-04 02:37:23 +00:00
matt 44bc4ef4a9 Ansify's (use prototypes). 2002-10-04 00:50:15 +00:00
scw 42ca361622 Preserve and restore the caller's FP status register, and ensure
it contains a sane value while we're doing FP ops.
2002-09-28 10:33:59 +00:00
provos 0f09ed48a5 remove trailing \n in panic(). approved perry. 2002-09-27 15:35:29 +00:00
chs 2841e1341c add strtoul.c, it's now used in MI code. 2002-09-21 17:45:16 +00:00