History log of /openbsd-current/sys/arch/amd64/stand/boot/Makefile
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.49 17-Apr-2023 deraadt

The bootblocks are 32-bit binaries which use the ENTRY() macros which now
include endbr64 macros. That's not going to work, so use the simple method
of -Dendbr64= to remove them from the instruction stream.
ok kettenis guenther


Revision tags: OPENBSD_7_0_BASE OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE
# 1.48 08-Jul-2021 deraadt

sys/lib/libz isn't configured for lazy optimizations to save space because
those options are incompatible with the kernel anymore. Set DYNAMIC_CRC_TABLE
and BUILDFIXED for these bootblocks, to save space on the media
ok tb mlarkin


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.47 02-Aug-2020 deraadt

additional files from libkern will be needed by clang10
from mortimer


# 1.46 14-Jun-2020 deraadt

rewrite mdrandom() in C. previously this XOR'd against rdrand if available,
and alternatively XOR'd against TSC. now always run both sequences, and
also support rdseed as a third procedure.
ok kettenis naddy


Revision tags: OPENBSD_6_7_BASE
# 1.45 05-Mar-2020 otto

Allow amd64 boot(8) and friends to read from an ffs2 filesystem.
Also enable ffs2 for floppy, so that its kernel kan access ffs2. ok deraadt@


# 1.44 28-Nov-2019 bluhm

Implement a hexdump command in the boot loader. This helps to
inspect the memory layout that the firmware has created. It is
especially useful for UEFI debugging.
OK deraadt@ kettenis@


# 1.43 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
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


Revision tags: OPENBSD_6_6_BASE
# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.48 08-Jul-2021 deraadt

sys/lib/libz isn't configured for lazy optimizations to save space because
those options are incompatible with the kernel anymore. Set DYNAMIC_CRC_TABLE
and BUILDFIXED for these bootblocks, to save space on the media
ok tb mlarkin


Revision tags: OPENBSD_6_8_BASE OPENBSD_6_9_BASE
# 1.47 02-Aug-2020 deraadt

additional files from libkern will be needed by clang10
from mortimer


# 1.46 14-Jun-2020 deraadt

rewrite mdrandom() in C. previously this XOR'd against rdrand if available,
and alternatively XOR'd against TSC. now always run both sequences, and
also support rdseed as a third procedure.
ok kettenis naddy


Revision tags: OPENBSD_6_7_BASE
# 1.45 05-Mar-2020 otto

Allow amd64 boot(8) and friends to read from an ffs2 filesystem.
Also enable ffs2 for floppy, so that its kernel kan access ffs2. ok deraadt@


# 1.44 28-Nov-2019 bluhm

Implement a hexdump command in the boot loader. This helps to
inspect the memory layout that the firmware has created. It is
especially useful for UEFI debugging.
OK deraadt@ kettenis@


# 1.43 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
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


Revision tags: OPENBSD_6_6_BASE
# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.47 02-Aug-2020 deraadt

additional files from libkern will be needed by clang10
from mortimer


# 1.46 14-Jun-2020 deraadt

rewrite mdrandom() in C. previously this XOR'd against rdrand if available,
and alternatively XOR'd against TSC. now always run both sequences, and
also support rdseed as a third procedure.
ok kettenis naddy


Revision tags: OPENBSD_6_7_BASE
# 1.45 05-Mar-2020 otto

Allow amd64 boot(8) and friends to read from an ffs2 filesystem.
Also enable ffs2 for floppy, so that its kernel kan access ffs2. ok deraadt@


# 1.44 28-Nov-2019 bluhm

Implement a hexdump command in the boot loader. This helps to
inspect the memory layout that the firmware has created. It is
especially useful for UEFI debugging.
OK deraadt@ kettenis@


# 1.43 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
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


Revision tags: OPENBSD_6_6_BASE
# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.46 14-Jun-2020 deraadt

rewrite mdrandom() in C. previously this XOR'd against rdrand if available,
and alternatively XOR'd against TSC. now always run both sequences, and
also support rdseed as a third procedure.
ok kettenis naddy


Revision tags: OPENBSD_6_7_BASE
# 1.45 05-Mar-2020 otto

Allow amd64 boot(8) and friends to read from an ffs2 filesystem.
Also enable ffs2 for floppy, so that its kernel kan access ffs2. ok deraadt@


# 1.44 28-Nov-2019 bluhm

Implement a hexdump command in the boot loader. This helps to
inspect the memory layout that the firmware has created. It is
especially useful for UEFI debugging.
OK deraadt@ kettenis@


# 1.43 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
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


Revision tags: OPENBSD_6_6_BASE
# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.45 05-Mar-2020 otto

Allow amd64 boot(8) and friends to read from an ffs2 filesystem.
Also enable ffs2 for floppy, so that its kernel kan access ffs2. ok deraadt@


# 1.44 28-Nov-2019 bluhm

Implement a hexdump command in the boot loader. This helps to
inspect the memory layout that the firmware has created. It is
especially useful for UEFI debugging.
OK deraadt@ kettenis@


# 1.43 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
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


Revision tags: OPENBSD_6_6_BASE
# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.44 28-Nov-2019 bluhm

Implement a hexdump command in the boot loader. This helps to
inspect the memory layout that the firmware has created. It is
especially useful for UEFI debugging.
OK deraadt@ kettenis@


# 1.43 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
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


Revision tags: OPENBSD_6_6_BASE
# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.43 29-Oct-2019 deraadt

Use arc4 to bit-spread the 512-byte random buffer over the .openbsd.randomdata
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


Revision tags: OPENBSD_6_6_BASE
# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.42 03-Aug-2019 deraadt

In the bootblocks, after discovering and opening /bsd.upgrade, fchmod -x
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


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.41 15-May-2019 mlarkin

Add support to the BIOS bootloader for random kernel base VA

This diff adds support to be able to load a randomly linked kernel VA
(subject to some range restrictions). This change has been in snaps for
a few days without any fallout.

ok deraadt@


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.40 20-Apr-2019 deraadt

libsa's memcpy() is actually memmove(). make a proper memmove(), and give
memcpy() correct behaviour. This also brings the bcopy() macro into line.


Revision tags: OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386


# 1.39 17-Oct-2017 naddy

remove the remaining references to .depend files since nothing creates them
any longer; ok espie@ deraadt@


Revision tags: OPENBSD_6_2_BASE
# 1.38 19-Jun-2017 deraadt

As early as possible, create a link /bsd.booted to the /bsd kernel we
presume we booted from. If you boot from another kernel, we cannot help
you later with hibernate, sorry -- The kernel does not get a useable
filename from the bootblocks.

In the bootblocks, detect a live hibernate signature and boot from
/bsd.booted instead.

with yasuoka, lots of discussion with mlarkin, ok tom


# 1.37 30-May-2017 naddy

Allow building the bootstrap with clang:
* skip the integrated assembler for assym.h
* use as(1) to build biosboot.S and the various versions of srt0.S
ok deraadt@


Revision tags: OPENBSD_6_1_BASE
# 1.36 18-Sep-2016 jsing

Add bcrypt pbkdf support to the softraid crypto boot loader code.

Based on a diff from djm@


# 1.35 11-Sep-2016 jsing

Switch amd64 to libsa MI softraid.


# 1.34 11-Sep-2016 jsing

Rename softraid boot files, which are currently in an MD location. This
will allow us to bring in a MI softraid.{c,h} in lib/libsa.


# 1.33 10-Sep-2016 jsing

Rename libsa pbkdf2.c to pkcs5_pbkdf2.c so that we match libutil.


# 1.32 30-Jul-2016 guenther

Prep for relro: make sure it's off for any non-PIE stand/ program

ok millert@ kettenis@


Revision tags: OPENBSD_6_0_BASE
# 1.31 30-Mar-2016 jmc

for some time now mandoc has not required MLINKS to function
correctly - logically complete that now by removing MLINKS from base;

authors need only to ensure there is an entry in NAME for any function/
util being added. MLINKS will still work, and remain for perl to ease
upgrades;

ok nicm (curses) bcook (ssl)
ok schwarze, who provided a lot of feedback and assistance
ok tb natano jung


Revision tags: OPENBSD_5_9_BASE
# 1.30 02-Sep-2015 yasuoka

Initial commit of uefi boot loader of OpenBSD.

ok deraadt yuo


Revision tags: OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.29 13-Jul-2014 jasper

fix even more trailing tabs


# 1.28 13-Jul-2014 jasper

move putchar() into libsa

"sure" miod@


# 1.27 12-Jul-2014 jasper

move getchar() into libsa where applicable

ok miod@


Revision tags: OPENBSD_5_5_BASE
# 1.26 28-Dec-2013 jsing

Further clean up and unification of the amd64 and i386 boot(8) makefiles.


# 1.25 28-Dec-2013 deraadt

Try to load entropy data from disk:/etc/random.seed, and additionally
use a MD-supplied random function. Then, insert this into the ELF
openbsd.randomdata of the kernel, so that it has entropy right from
the start. Some help from jsing for the softraid aspects.
Also tested by phessler


Revision tags: OPENBSD_5_4_BASE
# 1.24 02-Jun-2013 guenther

Revert previous: libsa/ufs.c was fixed to not use big types when not
necessary. If something crawls in again that needs these we want to know

ok deraadt@


# 1.23 23-Apr-2013 jsing

Include udivdi3/umoddi3 when compiling the amd64/i386 boot blocks - they
are needed for the upcoming type changes.

ok deraadt@


# 1.22 23-Apr-2013 jsing

Remove softraid boot support from fdboot (again).


Revision tags: OPENBSD_5_3_BASE
# 1.21 18-Jan-2013 espie

fix bogus dependencies, and allow mkdep to run
checked on amd64 by rpe@
okay jsing@


# 1.20 18-Jan-2013 jsing

Fix the makefile so it works on other architectures.

Found the hard way by bluhm@


# 1.19 17-Jan-2013 jsing

Generate assym.h where we need it, instead of reaching around into other
object directories.

Discussed with deraadt@


# 1.18 17-Jan-2013 jsing

Clean up/standardise makefiles for amd64/stand.


# 1.17 27-Oct-2012 jsing

Move the code for softraid boot into separate files, leaving only minimal
hooks that are called from the normal code path. This allows softraid boot
support to be completely enabled or disabled at compile time. For boot(8)
all softraid boot support is now enabled by default, including support for
booting from crypto volumes. Disable softraid boot support for fdboot,
which further shrinks the binary.


# 1.16 13-Oct-2012 jsing

Only build fdboot on the appropriate architectures. Also fix the path to
check-boot.pl so that it works with both boot and fdboot.


# 1.15 12-Oct-2012 jsing

Add a script that checks the file offsets for boot(8)'s .text and .data
sections match up with their LMAs. This is necessary since biosboot does
not perform relocation.

Discussed with deraadt@


# 1.14 12-Oct-2012 jsing

Build a 'fdboot' that will be used for floppy disk media. This can be made
smaller than the normal 'boot', however for now it is identical.

ok deraadt@


# 1.13 09-Oct-2012 jsing

Teach amd64 boot(8) how to access a softraid crypto volume. This allows for
full disk encryption since the kernel can now be loaded directly from the
crypto volume, instead of needing to be on FFS.

This is currently disabled by default, however can be enabled by compiling
with boot(8) 'make -DBOOT_CRYPTO'.


# 1.12 09-Oct-2012 jsing

Remove -noinhibit-exec now that we no longer have to deal with
"relocation truncated" linker errors.


# 1.11 25-Sep-2012 pascal

Reduce the diff between amd64/stand and i386/stand, requested by deraadt@.
These create essentially the same bootblocks, so the build system should not be
diverging too much, or at least easily diffable.
There is still a lot of work to be done here, but this is the low-hanging fruit.

ok jsing@


# 1.10 29-Aug-2012 pascal

Get rid of all NOPIE and NOPIE_FLAGS in amd64/stand and use -fno-pie and -nopie
directly instead. This will be the approach taken by every other arch too
in the near future. It is easier than relying on bsd.own.mk to set these
correctly.

discussed with and ok deraadt@


# 1.9 21-Aug-2012 pascal

Add NOPIE= bits for sys/arch/*/stand to ensure that bootblocks will always be
built with -fno-pie. This gets the hairiest part of PIE out of the way ...

ok deraadt@


Revision tags: OPENBSD_4_3_BASE OPENBSD_4_4_BASE OPENBSD_4_5_BASE OPENBSD_4_6_BASE OPENBSD_4_7_BASE OPENBSD_4_8_BASE OPENBSD_4_9_BASE OPENBSD_5_0_BASE OPENBSD_5_1_BASE OPENBSD_5_2_BASE
# 1.8 25-Nov-2007 deraadt

libkern, begone. Move to a new mechanism where config(8)'s "file"
directive can select between MI and MD versions of these files. At
the same time, adjust the boot programs to pick exactly what they need,
instead of the 7 or 8 mechanisms previously used.

There will be some fallout from this, but testing it all by myself is a
ridiculously slow process; it will be finished in-tree.

Various developers were very nice and avoided making fun of me when I
was gibbering in the corner..


Revision tags: OPENBSD_4_2_BASE
# 1.7 30-May-2007 tom

Pull out the ELF loadfile pieces from the standalone libraries, so that
both 32- and 64-bit versions can be created (previously only one or the
other could be built for a given boot loader).

Use this to allow the i386 and amd64 boot blocks to boot both ELF32 and
ELF64 kernels (i.e. amd64 boot blocks can now load i386 kernels, and
vice versa). Obviously the system must support LONG mode in order to
successfully run the amd64 kernel once it is loaded.

Advice and discussions from/with dale@ (going back three years). Much
testing nick@ and todd@; thanks.


Revision tags: OPENBSD_4_1_BASE
# 1.6 30-Oct-2006 jmc

install boot.conf as a section 5 page, not section 8;

from mikolaj kucharski;
ok mk deraadt krw


# 1.5 18-Sep-2006 mpf

boot(8) ``machine memory'' support for > 4G.
Convert parser to strtoll(3) and use 64bit printf.
With help from mickey@
i386 and amd64 tests by me, alpha test by mickey@
OK mickey@, miod@, deraadt@


Revision tags: OPENBSD_3_8_BASE OPENBSD_3_9_BASE OPENBSD_4_0_BASE
# 1.4 30-Jul-2005 millert

Need moddi3.c qdivrem.c for libz


# 1.3 03-May-2005 tom

The return value from getEBDAaddr() (info) is not used in bios_E820(),
so nuke it. amd64 no longer needs biosprobe.c listed in SRCS. Trims
100 bytes from the boot blocks.

Bump versions on boot, cdboot and pxeboot, as I'm getting cautious in
my old age.

ok weingart@


Revision tags: OPENBSD_3_6_BASE OPENBSD_3_7_BASE SMP_SYNC_A SMP_SYNC_B
# 1.2 17-May-2004 drahn

Work arounda behaviour change in binutils-2.14, now -m<...> -nostdlib
removes /usr/libdata from the script search path. add it back with a -L


Revision tags: OPENBSD_3_5_BASE
# 1.1 03-Feb-2004 mickey

branches: 1.1.2;
das boot; das cloned das from das i386