summaryrefslogtreecommitdiff
path: root/sys/libkern
Commit message (Collapse)AuthorAgeFilesLines
...
* sys: Replace zero with NULL for pointers.Pedro F. Giffuni2017-02-221-1/+1
| | | | | | | | | Found with: devel/coccinelle MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D9694 Notes: svn path=/head/; revision=314068
* Remove inet_ntoa() from the kernelEric van Gyzen2017-02-161-14/+0
| | | | | | | | | | | | | | inet_ntoa() cannot be used safely in a multithreaded environment because it uses a static local buffer. Remove it from the kernel. Suggested by: glebius, emaste Reviewed by: gnn MFC after: never Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D9625 Notes: svn path=/head/; revision=313822
* calculate_crc32c: Add SSE4.2 implementation on x86Conrad Meyer2017-01-312-0/+299
| | | | | | | | | | | | | | | | | | | | | | | | | Derived from an implementation by Mark Adler. The fast loop performs three simultaneous CRCs over subsets of the data before composing them. This takes advantage of certain properties of the CRC32 implementation in Intel hardware. (The CRC instruction takes 1 cycle but has 2-3 cycles of latency.) The CRC32 instruction does not manipulate FPU state. i386 does not have the crc32q instruction, so avoid it there. Otherwise the implementation is identical to amd64. Add basic userland tests to verify correctness on a variety of inputs. PR: 216467 Reported by: Ben RUBSON <ben.rubson at gmail.com> Reviewed by: kib@, markj@ (earlier version) Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D9342 Notes: svn path=/head/; revision=313006
* Use time_t for intermediate values to avoid overflow in clock_ts_to_ctConrad Meyer2017-01-241-0/+4
| | | | | | | | | | | | | | | | | | | Add additionally safety and overflow checks to clock_ts_to_ct and the BCD routines while we're here. Perform a safety check in sys_clock_settime() first to avoid easy local root panic, without having to propagate an error value back through dozens of APIs currently lacking error returns. PR: 211960, 214300 Submitted by: Justin McOmie <justin.mcomie at gmail.com>, kib@ Reported by: Tim Newsham <tim.newsham at nccgroup.trust> Reviewed by: kib@ Sponsored by: Dell EMC Isilon, FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D9279 Notes: svn path=/head/; revision=312702
* libkern: Remove obsolete 'register' keywordConrad Meyer2017-01-1211-29/+29
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=311989
* Update r309143 to prevent false sharing.Fabien Thomas2016-11-251-2/+2
| | | | | | | | | Reported by: mjg Approved by: so MFC after: 1 month Notes: svn path=/head/; revision=309146
* In a dual processor system (2*6 cores) during IPSec throughput tests,Fabien Thomas2016-11-251-37/+80
| | | | | | | | | | | | | | | | | | we see a lot of contention on the arc4 lock, used to generate the IV of the ESP output packets. The idea of this patch is to split this mutex in order to reduce the contention on this lock. Reviewed by: delphij, markm, ache Approved by: so Obtained from: emeric.poupon@stormshield.eu MFC after: 1 month Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D8130 Notes: svn path=/head/; revision=309143
* sys: Make use of our rounddown() macro when sys/param.h is available.Pedro F. Giffuni2016-04-301-1/+1
| | | | | | | No functional change. Notes: svn path=/head/; revision=298848
* Merge ACPICA 20160422.Jung-uk Kim2016-04-271-0/+63
| | | | Notes: svn path=/head/; revision=298714
* kern: for pointers replace 0 with NULL.Pedro F. Giffuni2016-04-154-4/+4
| | | | | | | | | These are mostly cosmetical, no functional change. Found with devel/coccinelle. Notes: svn path=/head/; revision=298069
* libkern: ffs, fls: s/4/3/ the 3rd BSD clauseConrad Meyer2015-10-226-6/+6
| | | | | | | | Approved by: emaste Sponsored by: EMC / Isilon Storage Division Notes: svn path=/head/; revision=289766
* Add libkern ffsll() for parity with flsll()Conrad Meyer2015-10-221-0/+48
| | | | | | | | Sponsored by: EMC / Isilon Storage Division Differential Revision: https://reviews.freebsd.org/D3962 Notes: svn path=/head/; revision=289765
* Add the __aeabi_memclr8 symbol, clang 3.7 uses this.Andrew Turner2015-09-211-0/+2
| | | | | | | | MFC after: 1 week Sponsored by: ABT Systems Lts Notes: svn path=/head/; revision=288073
* Remove checks for __ARM_EABI__, we only build for EABI now.Andrew Turner2015-07-096-30/+0
| | | | | | | Sponsored by: ABT Systems Ltd Notes: svn path=/head/; revision=285338
* Add support for __aeabi_memclr4, clang 3.7 calls it.Andrew Turner2015-07-091-0/+40
| | | | | | | Sponsored by: ABT Systems Ltd Notes: svn path=/head/; revision=285337
* Huge cleanup of random(4) code.Mark Murray2015-06-302-16/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * GENERAL - Update copyright. - Make kernel options for RANDOM_YARROW and RANDOM_DUMMY. Set neither to ON, which means we want Fortuna - If there is no 'device random' in the kernel, there will be NO random(4) device in the kernel, and the KERN_ARND sysctl will return nothing. With RANDOM_DUMMY there will be a random(4) that always blocks. - Repair kern.arandom (KERN_ARND sysctl). The old version went through arc4random(9) and was a bit weird. - Adjust arc4random stirring a bit - the existing code looks a little suspect. - Fix the nasty pre- and post-read overloading by providing explictit functions to do these tasks. - Redo read_random(9) so as to duplicate random(4)'s read internals. This makes it a first-class citizen rather than a hack. - Move stuff out of locked regions when it does not need to be there. - Trim RANDOM_DEBUG printfs. Some are excess to requirement, some behind boot verbose. - Use SYSINIT to sequence the startup. - Fix init/deinit sysctl stuff. - Make relevant sysctls also tunables. - Add different harvesting "styles" to allow for different requirements (direct, queue, fast). - Add harvesting of FFS atime events. This needs to be checked for weighing down the FS code. - Add harvesting of slab allocator events. This needs to be checked for weighing down the allocator code. - Fix the random(9) manpage. - Loadable modules are not present for now. These will be re-engineered when the dust settles. - Use macros for locks. - Fix comments. * src/share/man/... - Update the man pages. * src/etc/... - The startup/shutdown work is done in D2924. * src/UPDATING - Add UPDATING announcement. * src/sys/dev/random/build.sh - Add copyright. - Add libz for unit tests. * src/sys/dev/random/dummy.c - Remove; no longer needed. Functionality incorporated into randomdev.*. * live_entropy_sources.c live_entropy_sources.h - Remove; content moved. - move content to randomdev.[ch] and optimise. * src/sys/dev/random/random_adaptors.c src/sys/dev/random/random_adaptors.h - Remove; plugability is no longer used. Compile-time algorithm selection is the way to go. * src/sys/dev/random/random_harvestq.c src/sys/dev/random/random_harvestq.h - Add early (re)boot-time randomness caching. * src/sys/dev/random/randomdev_soft.c src/sys/dev/random/randomdev_soft.h - Remove; no longer needed. * src/sys/dev/random/uint128.h - Provide a fake uint128_t; if a real one ever arrived, we can use that instead. All that is needed here is N=0, N++, N==0, and some localised trickery is used to manufacture a 128-bit 0ULLL. * src/sys/dev/random/unit_test.c src/sys/dev/random/unit_test.h - Improve unit tests; previously the testing human needed clairvoyance; now the test will do a basic check of compressibility. Clairvoyant talent is still a good idea. - This is still a long way off a proper unit test. * src/sys/dev/random/fortuna.c src/sys/dev/random/fortuna.h - Improve messy union to just uint128_t. - Remove unneeded 'static struct fortuna_start_cache'. - Tighten up up arithmetic. - Provide a method to allow eternal junk to be introduced; harden it against blatant by compress/hashing. - Assert that locks are held correctly. - Fix the nasty pre- and post-read overloading by providing explictit functions to do these tasks. - Turn into self-sufficient module (no longer requires randomdev_soft.[ch]) * src/sys/dev/random/yarrow.c src/sys/dev/random/yarrow.h - Improve messy union to just uint128_t. - Remove unneeded 'staic struct start_cache'. - Tighten up up arithmetic. - Provide a method to allow eternal junk to be introduced; harden it against blatant by compress/hashing. - Assert that locks are held correctly. - Fix the nasty pre- and post-read overloading by providing explictit functions to do these tasks. - Turn into self-sufficient module (no longer requires randomdev_soft.[ch]) - Fix some magic numbers elsewhere used as FAST and SLOW. Differential Revision: https://reviews.freebsd.org/D2025 Reviewed by: vsevolod,delphij,rwatson,trasz,jmg Approved by: so (delphij) Notes: svn path=/head/; revision=284959
* Add more __aeabi_memcpy functions, later versions of clang generate callsAndrew Turner2015-05-311-0/+4
| | | | | | | to these functions. Notes: svn path=/head/; revision=283805
* Move zlib.c from net to libkern.Craig Rodrigues2015-04-221-0/+5414
| | | | | | | | | | | | | | | It is not network-specific code and would be better as part of libkern instead. Move zlib.h and zutil.h from net/ to sys/ Update includes to use sys/zlib.h and sys/zutil.h instead of net/ Submitted by: Steve Kiernan stevek@juniper.net Obtained from: Juniper Networks, Inc. GitHub Pull Request: https://github.com/freebsd/freebsd/pull/28 Relnotes: yes Notes: svn path=/head/; revision=281855
* Implement asprintf in libkernRyan Stone2015-03-011-0/+77
| | | | | | | | | | Differential Revision: https://reviews.freebsd.org/D1877 Reviewed by: pjd, jfv MFC After: 1 month Sponsored by: Sandvine Inc. Notes: svn path=/head/; revision=279433
* Similar to r277901, fix more -Wcast-qual warnings in libkern's strtoq(),Dimitry Andric2015-01-293-3/+3
| | | | | | | | | strtoul() and strtouq(), by using __DECONST. No functional change. MFC after: 3 days Notes: svn path=/head/; revision=277903
* Fix a -Wcast-qual warning in libkern's strtol(), by using __DECONST. NoDimitry Andric2015-01-291-1/+1
| | | | | | | | | functional change. MFC after: 3 days Notes: svn path=/head/; revision=277901
* Add some new modes to OpenCrypto. These modes are AES-ICM (can be usedJohn-Mark Gurney2014-12-121-0/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for counter mode), and AES-GCM. Both of these modes have been added to the aesni module. Included is a set of tests to validate that the software and aesni module calculate the correct values. These use the NIST KAT test vectors. To run the test, you will need to install a soon to be committed port, nist-kat that will install the vectors. Using a port is necessary as the test vectors are around 25MB. All the man pages were updated. I have added a new man page, crypto.7, which includes a description of how to use each mode. All the new modes and some other AES modes are present. It would be good for someone else to go through and document the other modes. A new ioctl was added to support AEAD modes which AES-GCM is one of them. Without this ioctl, it is not possible to test AEAD modes from userland. Add a timing safe bcmp for use to compare MACs. Previously we were using bcmp which could leak timing info and result in the ability to forge messages. Add a minor optimization to the aesni module so that single segment mbufs don't get copied and instead are updated in place. The aesni module needs to be updated to support blocked IO so segmented mbufs don't have to be copied. We require that the IV be specified for all calls for both GCM and ICM. This is to ensure proper use of these functions. Obtained from: p4: //depot/projects/opencrypto Relnotes: yes Sponsored by: FreeBSD Foundation Sponsored by: NetGate Notes: svn path=/head/; revision=275732
* Use the unified syntax in a few more assembly filesAndrew Turner2014-12-051-1/+2
| | | | | | | | MFC after: 1 week Sponsored by: ABT Systems Ltd Notes: svn path=/head/; revision=275520
* Sync with userland variant.Xin LI2014-11-171-5/+3
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=274636
* Add a complete implementation of MurmurHash3. Tweak both implementationsDag-Erling Smørgrav2014-10-181-12/+70
| | | | | | | | | | so they match the established idiom. Document them in hash(9). MFC after: 1 month MFC with: r272906 Notes: svn path=/head/; revision=273268
* Remove duplicated code.Xin LI2014-10-161-0/+4
| | | | | | | Suggested by: jmg Notes: svn path=/head/; revision=273189
* Change the PF hash from Jenkins to Murmur3. In forwarding testsGeorge V. Neville-Neil2014-10-101-0/+74
| | | | | | | | | | | | this showed a conservative 3% incrase in PPS. Differential Revision: https://reviews.freebsd.org/D461 Submitted by: des Reviewed by: emaste MFC after: 1 month Notes: svn path=/head/; revision=272906
* Add explicit_bzero(3) and its kernel counterpart.Xin LI2014-10-071-0/+24
| | | | | | | | Obtained from: OpenBSD MFC after: 2 weeks Notes: svn path=/head/; revision=272673
* Use __DECONST to avoid compiler warnings (and thus build failures)Bjoern A. Zeeb2014-09-081-2/+2
| | | | | | | with gcc on sparc64, mips, and powerpc after r271173. Notes: svn path=/head/; revision=271251
* Add support for gdb's memory searching capabilities to our in-kernel gdbBenno Rice2014-09-051-0/+62
| | | | | | | | | | | server. Submitted by: Daniel O'Connor <daniel.oconnor@isilon.com> Reviewed by: jhb Sponsored by: EMC Isilon Storage Division Notes: svn path=/head/; revision=271173
* Bring in the new automounter, similar to what's provided in most otherEdward Tomasz Napierala2014-08-171-0/+51
| | | | | | | | | | | | | | | | UNIX systems, eg. MacOS X and Solaris. It uses Sun-compatible map format, has proper kernel support, and LDAP integration. There are still a few outstanding problems; they will be fixed shortly. Reviewed by: allanjude@, emaste@, kib@, wblock@ (earlier versions) Phabric: D523 MFC after: 2 weeks Relnotes: yes Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=270096
* Fix unwind-info errors in our hand-written arm assembler code.Ian Lepore2014-08-011-10/+10
| | | | | | | | | | | | | | | | | | | | | | We have functions nested within functions, and places where we start a function then never end it, we just jump to the middle of something else. We tried to express this with nested ENTRY()/END() macros (which result in .fnstart and .fnend directives), but it turns out there's no way to express that nesting in ARM EHABI unwind info, and newer tools treat multiple .fnstart directives without an intervening .fnend as an error. These changes introduce two new macros, EENTRY() and EEND(). EENTRY() creates a global label you can call/jump to just like ENTRY(), but it doesn't emit a .fnstart. EEND() is a no-op that just documents the conceptual endpoint that matches up with the same-named EENTRY(). This is based on patches submitted by Stepan Dyatkovskiy, but I made some changes and added the EEND() stuff, so blame any problems on me. Submitted by: Stepan Dyatkovskiy <stpworld@narod.ru> Notes: svn path=/head/; revision=269390
* Remove ia64.Marcel Moolenaar2014-07-0712-1273/+0
| | | | | | | | | | | | | | | | | | | | This includes: o All directories named *ia64* o All files named *ia64* o All ia64-specific code guarded by __ia64__ o All ia64-specific makefile logic o Mention of ia64 in comments and documentation This excludes: o Everything under contrib/ o Everything under crypto/ o sys/xen/interface o sys/sys/elf_common.h Discussed at: BSDcan Notes: svn path=/head/; revision=268351
* Use strcasecmp() instead of strcmp() when checking user-supplied encodingJohn Baldwin2014-06-092-4/+4
| | | | | | | | | | | | | names so that encoding names are treated as case-insensitive. This allows the use of 'utf-8' instead of 'UTF-8' for example and matches the behavior of iconv(1). PR: 167977 Submitted by: buganini@gmail.com MFC after: 1 week Notes: svn path=/head/; revision=267291
* Fix typoEitan Adler2013-11-291-1/+1
| | | | | | | Reported by: emaste Notes: svn path=/head/; revision=258752
* Fix typoEitan Adler2013-11-291-1/+1
| | | | | | | Reported by: swildner@DragonFlyBSD.org Notes: svn path=/head/; revision=258751
* Fix ixp425 boot2 with ARM EABI:Andrew Turner2013-09-292-0/+14
| | | | | | | | | | | - libkern is missing __aeabi_llsl, implement this by calling __ashldi3. - Because of how the asm entry macros are defined the boot2 code requires the unwind symbols to exist, include them in boot2. Approved by: re (marius) Notes: svn path=/head/; revision=255939
* Fix watchdog pretimeout.Alfred Perlstein2013-07-271-0/+47
| | | | | | | | | | | The original API calls for pow2ns, however the new APIs from Linux call for seconds. We need to be able to convert to/from 2^Nns to seconds in both userland and kernel to fix this and properly compare units. Notes: svn path=/head/; revision=253719
* Attempt to mitigate poor initialization of arc4 by one-shotAndrey A. Chernov2013-04-191-1/+4
| | | | | | | | | | reinitialization from yarrow right after good entropy is harvested. Approved by: secteam (delphij) MFC after: 1 week Notes: svn path=/head/; revision=249631
* Add __aeabi_memset to libkern, implemented using memset, as clang mayAndrew Turner2013-03-161-0/+49
| | | | | | | generate calls to it. Notes: svn path=/head/; revision=248395
* Add END to ARM libkern assembly functionsAndrew Turner2013-03-164-1/+19
| | | | Notes: svn path=/head/; revision=248367
* Move the __aeabi_unwind_cpp_pr{0,1,2} functions to libkern so they can beAndrew Turner2013-03-161-0/+58
| | | | | | | referenced in a non-debug kernel. Notes: svn path=/head/; revision=248366
* Add __aeabi_memcpy to libkern as clang may generate calls to it.Andrew Turner2013-03-101-0/+37
| | | | Notes: svn path=/head/; revision=248128
* Add __aeabi_ulcmp to allow building of the LINT kernel.Andrew Turner2013-01-232-0/+17
| | | | Notes: svn path=/head/; revision=245840
* Add the required __aeabi_* functions the kernel uses when built for ARM EABIAndrew Turner2013-01-173-0/+128
| | | | Notes: svn path=/head/; revision=245548
* Sync strlcpy with userland version.Xin LI2012-11-031-33/+17
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=242507
* Sync strlen with userland implementation.Xin LI2012-11-031-13/+98
| | | | | | | MFC after: 1 month Notes: svn path=/head/; revision=242506
* s/ is is / is /gEitan Adler2012-09-141-1/+1
| | | | | | | | | | s/ a a / a /g Approved by: cperciva MFC after: 3 days Notes: svn path=/head/; revision=240521
* - Move jenkins.h to jenkins_hash.cGleb Smirnoff2012-09-042-185/+463
| | | | | | | | | | | | | - Provide missing function that can do hashing of arbitrary sized buffer. - Refetch lookup3.c and do only minimal edits to it, so that diff between our jenkins_hash.c and lookup3.c is minimal. - Add declarations for jenkins_hash(), jenkins_hash32() to sys/hash.h. - Document these functions in hash(9) Obtained from: http://burtleburtle.net/bob/c/lookup3.c Notes: svn path=/head/; revision=240086
* Fix unloading of libiconv module.Mateusz Guzik2012-06-111-2/+4
| | | | | | | | | | | Previously it would either loop infinitely or exit with error leaking a lock. Reported by: Will DeVries Approved by: trasz (mentor) MFC after: 1 week Notes: svn path=/head/; revision=236899