summaryrefslogtreecommitdiff
path: root/sys/lib
AgeCommit message (Collapse)Author
2021-12-01Fix booting from an IDE block device on the Sun Blade 100. ApparentlyMark Kettenis
writing to disk using the Open Firmware interfaces is buggy and causes corruption of the disk. While it isn't entirely clear what versions of Open Firmware are affected, but it seems to only affect IDE drives. So if we detect an IDE drive, disable writing to it. This results in a small lose of bootloader functionality (bsd.upgrade loop prevention and flagging /etc/random.seed re-use) but that is better than losing the ability to run OpenBSD at all. Based on a diff by Ted Bullock (who did all the hard work of debugging this and coming up with a viable fix). ok deraadt@
2021-11-29Niels agreed to remove the advertising clause; switching theseDamien Miller
to 3-term BSD license.
2021-11-01Add CRC-16 implementation. From NetBSD.Mark Kettenis
ok krw@, deraadt@
2021-10-25Remove unused variables to silence clang.Patrick Wildt
ok kettenis@
2021-10-24#define open O_* flags in libsa/stand.h, so that bootblocks can useTheo de Raadt
O_RDONLY rather using 0 ok beck
2021-07-28Fix previous: In one spot I incorrectly used Pos (unsigned short) whereTheo Buehler
I should have used Byte (unsigned char) which led to passing twice the correct size to free. Found & tested by bluhm with the sys/netinet/ipsec tests on i386.
2021-07-22Add sizes for free() in zlibTheo Buehler
Rebased version of a diff from miod who described it as follows: This tries to keep diffability against upstream, hence a questionable choice of the size type for zcfree() - but all sizes should fit in 32 bits anyway. Since all zcfree routines used in the tree cope with NULL arguments (including the various alloc.c used by the boot blocks), I have simplified TRY_FREE to compensate for the growth. Reminded by and ok mpi
2021-07-20Remove unneeded __sync_* library functions from the kernel.Visa Hankala
These library functions were added as stopgaps because GCC 4.2.1 lacks the corresponding __sync_* builtins on mips64. However, the builtins are now provided by Clang.
2021-07-08In recent libz update, tb@ overzealously attempted codesize reduction withTheo de Raadt
option BUILDFIXED -- which is incompatible with kernel hibernate unpack since it places side-effects into BSS, rather than inside z_streamp or using the private allocator. While here DYNAMIC_CRC_TABLE could cause similar problems, so disable this also. Space savings for the media is best done with bootblock-specific libz compile options, coming in the following commit. ok tb mlarkin
2021-07-04tb notices i did not add a copyright in 2011Theo de Raadt
2021-07-04Add missing RCS tagsTheo Buehler
2021-07-04Update libz to zlib 1.2.11 and reapply local patches as far as thisTheo Buehler
made sense. Tested in snaps for a few days. deraadt helped with fitting things on floppies and jmatthew found a bug I introduced. ok deraadt
2021-05-16ansiJonathan Gray
2021-05-16deregisterJonathan Gray
2021-05-16ansiJonathan Gray
2021-03-12spellingJonathan Gray
2021-03-06ansiJonathan Gray
2020-12-09Use daddr_t and not daddr32_t in boot media.Kenneth R Westerback
At a minimum, amd64/i386 should now boot from 4TB GPT formatted disks. More daddr32_t terminations with extreme prejudice to follow. Tested by various, in snaps for a few days. ok deraadt@
2020-11-28Add retguard to macppc kernel locore.S, ofwreal.S, setjmp.Sgkoehler
This changes RETGUARD_SETUP(ffs) to RETGUARD_SETUP(ffs, %r11, %r12) and RETGUARD_CHECK(ffs) to RETGUARD_CHECK(ffs, %r11, %r12) to show that r11 and r12 are in use between setup and check, and to pick registers other than r11 and r12 in some kernel functions. ok mortimer@ deraadt@
2020-10-27Retguared asm macros for powerpc libkerngkoehler
This was in the macppc snap, but I forgot to include it in my last commit "Retguard asm macros for powerpc libc, ld.so"
2020-10-26Remove an unneeded variable.Visa Hankala
OK kettenis@
2020-10-16Use the retguard macros from asm.h to protect the function.Theo de Raadt
ok mortimer kettenis
2020-08-13Add __multi3 from compiler_rt-8.xJeremie Courreges-Anglas
Needed to build a sparc64 kernel with clang 10. ok kettenis@
2020-08-13Move compiler_rt type definitions to a separate headerJeremie Courreges-Anglas
so that we can reuse them in other compiler_rt routines. ok kettenis@
2020-08-03add aliases for arm eabi long long shift functionsJonathan Gray
clang 10 on armv7 references these when building RAMDISK (-Oz) but not GENERIC (-O2). feedback and ok guenther@
2020-07-20__main() is no longer used by any of our toolchainsTheo de Raadt
this fell out of a discussion with mortimer ok kettenis
2020-07-18The kernel and bootblocks never reference this file...Theo de Raadt
2020-07-09Fix a warning false positive from clang 10.Todd C. Miller
blf_enc() takes a number of 64-bit blocks to encrypt, but using sizeof(uint64_t) in the calculation triggers a warning from clang 10 because the actual data type is uint32_t. Pass BCRYPT_WORDS / 2 for the number of blocks like libc bcrypt(3) does. OK kettenis@
2020-06-10Provide an optimized implementation of ffs(3) in the kernel onChristian Weisgerber
arm64/powerpc/powerpc64, making use of the count leading zeros instruction. powerpc testing by cwen@; ok kettenis@ deraadt@
2020-05-19If we pass a packet length larger than 2^16, we should panic() insteadPatrick Wildt
of returning -1. With a return type of u_int16_t, -1 is not different to a valid checksum. For incoming packets, the header lengths don't exceed that size anyway, but for outgoing packets it's better to see if our bootloader crafts a broken one. Discussed with gerhard@ ok deraadt@ procter@
2020-05-18Sync in_cksum.c to the same version ospfd has. This fixes problemsPatrick Wildt
with odd packet lengths, which can happen when using TFTP to load a file with an odd length. ospfd actually took dvmrpd's version in 2006 to fix the same issue, and both daemons implementations are the same. For the bootloader we keep the consts from the previous version and replace the fatal with a print and return. ok deraadt@
2020-04-02Add __lshrti3 to libkern and use it on sparc64Jeremie Courreges-Anglas
With this it's possible to build the kernel using clang. Discussed with claudio@, ok deraadt@
2020-02-29Next step in prepping for ffs2 installs: introduce a new install script varOtto Moerbeek
MDFSOPT and add a missing prototype.
2020-02-26Remove non-__STDC__ assert macros from <lib/libkern/libkern.h>.Visa Hankala
The macros are defined in a part of the header where a C compiler is required. In addition, the macros expand to C code, so it looks unnecessary to define the asserts with traditional cpp in mind. OK cheloha@, mpi@
2019-11-29Add an element to the marks array to store the virtual address of theMark Kettenis
entry point. ok mlarkin@, deraadt@
2019-11-28Implement a hexdump command in the boot loader. This helps toAlexander Bluhm
inspect the memory layout that the firmware has created. It is especially useful for UEFI debugging. OK deraadt@ kettenis@
2019-11-05Give some END()s to assembly symbols.Martin Pieuchot
ok kettenis@, jca@
2019-11-01Reduce BOOTRANDOM_MAX to 256. naddy pointed out there's no point havingTheo de Raadt
it larger than RC4STATE. A long discussion ensued. In conclusion all entropy inputs are either satisfactory enough, or just as shitty at 512.
2019-10-29Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdataTheo de Raadt
section, which has grown a fair bit with the introduction of retguard. Mortimer discovered the repeated 512-byte sequence as retguard keys, and this resolves the issue. (Chacha does not fit on the media, so 1.5K early drop RC4 is hopefully sufficient in our KARL link universe) Version crank the bootblocks. sysupgrade -s will install new bootblocks. ok djm mortimer
2019-10-29add arc4 cipher to the bootblocksTheo de Raadt
ok djm mortimer
2019-08-03In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -xTheo de Raadt
so the file cannot be re-executed upon the next boot. This provides a stronger one-shot-upgrade model than the upgrade script's rm /bsd.upgrade. Now various forms of upgrade failure will reboot into /bsd, which is probably more recoverable. Performing fchmod -x depends on (1) use of MI boot.c (not alpha/macppc/sparc64/sgi/octeon) and (2) "can write blocks" functionality in the IO layer. Most architectures have this support now. Two diagnostics "fchmod a-x %s: failed" and "/bsd.upgrade is not u+x" will remain in the tree while refinements happen for some of the laggard architectures. based upon a discussion florian tested in snapshots for more than a week without any complaints
2019-06-01Fix warnings when building zlib with ZLIB_CONST definedJeremie Courreges-Anglas
Probably not very useful (given the lack of feedback) but feels more correct. Kernel part tested with option ZLIB_CONST.
2019-05-12Add ZLIB_CONSTJeremie Courreges-Anglas
Introduced in zlib-1.2.5.2, used by a few ports. ok deraadt@
2019-05-11we have never built without %b supportTheo de Raadt
2019-04-25Add movstrSI12_i4 for linking -Os/-Oz kernels. Sadly however itTheo de Raadt
fails and locks early in boot.
2019-04-20libsa's memcpy() is actually memmove(). make a proper memmove(), and giveTheo de Raadt
memcpy() correct behaviour. This also brings the bcopy() macro into line.
2019-04-10change marks[] array to uint64_t, so the code can track full 64-bitTheo de Raadt
details from the ELF header instead of faking it. Proposal from mlarkin, tested on most architectures already
2019-01-25I am retiring my old email address; replace it with my OpenBSD one.Todd C. Miller
2018-12-16Make the freelist best fit code a tiny bit smarter to not use a block ifOtto Moerbeek
half or more would be wasted. Causes more effective re-use of blocks. ok jsing@
2018-08-10Retry on incorrect passphrase for softraid crypto boot.Joel Sing
Historically, the softraid crypto support in the boot loaders has only given one attempt to provide the correct passphrase. There were a few reasons for this, including the fact that pkcs5_pbkdf2() allows an empty passphrase and that returning EPERM allowed for another attempt. With the event of KARL and the need for bsd.booted with hibernate resumption, this becomes much more of an issue - if you get the passphrase wrong you fail to resume. There are also other situations like using /etc/boot.conf to switch serial console, but an incorrect passphrase results in the config not being read. Also, bcrypt_pbkdf() does not permit empty passphrases. This reworks the softraid crypto support in the boot loaders so that it loops requesting a valid passphrase until one is provided, or an empty passphrase is entered (at which point it will abort). ok mortimer@ tb@