Commit Graph

1806 Commits

Author SHA1 Message Date
Ian Lepore
12b92a343c Save and restore r9 register in arm ubldr. In old gcc 4.2, r9 was a callee-
saved register, but in arm EABI it may be either callee-saved or dedicated
to some special purpose (such as a TLS pointer).  It appears clang does not
treat it as a callee-saved register (instead using it as another work
register, similar to r12).

Another important side effect of these changes is that saving an extra
register in the push/pop statements keeps the stack aligned to an 8-byte
boundary during the self_reloc() call, as it always should have been.

As stated in the PR...

Essentially the important caller-saved registers are pushed (r0, r1, r9, lr)
before the relocation call, and popped after.  Then r8/r9 are saved as usual
for the syscall trampoline, and lr is stored in r8 (now free) as a
callee-saved value before calling into `main`.

The call to `main` can no longer be a tail call because we must restore r9
especially after main returns (although since we have used r8 to hold lr we
must also restore this).

PR:		224008
2017-12-10 21:51:27 +00:00
Warner Losh
29374678a6 This path belongs in ficl/Makefile, not the common defines for users
of ficl.

Sponsored by: Netflix
2017-12-08 22:19:41 +00:00
Warner Losh
f0408ed054 boot1.c needs EFI_ZFS_BOOT too, so add it globally. Otherwise we'll
not be able to actually read ZFS partitions.

Submitted by: kevans@
2017-12-08 19:57:26 +00:00
Warner Losh
fb5af39a82 Create interp class.
Create an interp class. Use it to separate out the different types of
interpreters: forth and simple with function pointers rather than
via #ifdefs.

Obtained from: lua boot loader project
    (via https://bsdimp@github.com/bsdimp/freebsd.git lua-bootloader)
Sponsored by: Netflix
2017-12-08 19:57:16 +00:00
Warner Losh
bd04a914bc Const poison a couple of interfaces.
Obtained from: lua boot project
Sponsored by: Netflix
2017-12-08 19:57:11 +00:00
Warner Losh
c5095910a0 Put the files we're copying over into a few variables and add them to
CLEANDIRS and CLEANFILES so make clean removes any divots.

Sponsored by: Netflix
2017-12-08 19:57:06 +00:00
Warner Losh
6856cf6893 Provide implementations for iscntrl, ispunct and isgraph.
Sponsored by: Netflix
2017-12-08 19:57:02 +00:00
Warner Losh
c008ab0879 Remove _KERNEL hack now that errno.h does the right thing when
_STANDALONE is defined.

Sponsored By: Netflix
2017-12-08 19:56:57 +00:00
Warner Losh
49cb01302c Add partial support signal.h functioanlity. Pull in machine/signal.h
to define sig_atomic_t.

Sponsored by: Netflix
2017-12-08 19:56:35 +00:00
Mark Johnston
2dbeaed483 Avoid setting -Wno-tentative-definition-incomplete-type with gcc.
No version of gcc that I've tried accepts this flag.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13415
2017-12-07 22:11:23 +00:00
Toomas Soome
78fdf7f396 dhcp_try_rfc1048() is not used any more
Remove unused function.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13382
2017-12-06 06:49:53 +00:00
Warner Losh
e294a1269f Fix random() prototype to match the system.
Sponsored by: Netflix
2017-12-06 02:00:09 +00:00
Warner Losh
e8e6a5f920 Make putenv and getenv match the userland definition of these
functions, tweak man page and one variable that shouldn't be const
anymore.

Sponsored by: Netflix
2017-12-06 02:00:00 +00:00
Warner Losh
09d8a81a0c Now that we offer a semi-sane standards-ish set of #include files in
the stand environment that's safe to use (and insulated from whatever
build env you might normally have), stop hacking the bzlib and zlib
sources with sed. There's no longer any need.

Sponsored by: Netflix
2017-12-05 21:38:24 +00:00
Warner Losh
05f37f4d86 Stop building with the standard system headers.
Building with the standard system headers isn't a perfect match to the
stand environment. Instead, copy over the files we know are safe to
use and constrain what else is used. We use -nostdinc to achieve this.

This also fixes issues with building 32-bit libraries on amd64
sometimes pulling in the wrong cpufunc.h giving an error now that we
stop on errors. It will also enable an easier transition to lua boot.

Sponsored by: Netflix
2017-12-05 21:38:19 +00:00
Warner Losh
253d60eecc Don't inherit CFLAGS. This a specialized test program, and can be
built with mostly default flags. Do so in anticipation of the rest of
stand not building with system headers.

Sponsored by: Netflix
2017-12-05 21:38:14 +00:00
Warner Losh
f38658e140 Prefer stdint.h to inttypes.h since the added prototypes form the
latter aren't used. Prefer sys/link_elf.h to link.h so we're only
dependent on the kernel tree. The default installation of link.h just
includes this file, and any benefit from that is outweighed by the
hassle it causes. This reduces the footprint of files needed from the
system includes (or sysroot in buildworld).

Sponsored by: Netflix
2017-12-05 21:38:04 +00:00
Warner Losh
6fd96c93c1 Make sure we include the right path for skein.h, as well only include
the ZFS flags for zfs_modules.c. This keeps us from pulling from the
system or sysroot during buildworld.
2017-12-05 21:37:59 +00:00
Warner Losh
92a2b8900e Need to include skein in the include path so we don't get this from
the "system" headers (though in buildworld, it's from the recently
built sysroot).

Sponsored by: Netflix
2017-12-05 21:37:55 +00:00
Warner Losh
b3e16b02b6 Use the kernel relative paths, rather than the userland relative paths
for the iso9660 header files.

Sponsored by: Netflix
2017-12-05 21:37:50 +00:00
Warner Losh
939971a289 No need to include the userland md5.h, the kernel one is just fine.
Sponsored by: Netflix
2017-12-05 21:37:45 +00:00
Warner Losh
a4b9cb3abd Include ficl.h before anything else and avoid including anything at
all if we're not building float.

Sponsored by: Netflix
2017-12-05 21:37:41 +00:00
Toomas Soome
61da91207d loader.efi: add note about iPXE into the efipart.c
Commant update.
2017-12-04 08:50:00 +00:00
Allan Jude
6f3d4ec84d increase maximum size of zfsboot
Previous to the switch from sys/boot to stand/ zfsboot (used for MBR) did
not support GELI. Now that it is compiled with GELI, it is running out of
space.

zfsldr (which loads zfsboot) was modified to load 256kb in r304321
2017-12-04 02:42:00 +00:00
Warner Losh
4d32c2211e Switch to proper MK_LOADER_GELI tests.
Submitted by: peter@
2017-12-04 01:14:12 +00:00
Warner Losh
a9839149fd Now it's safe to bump WARNS to 1.
Sponsored by: Netflix
2017-12-03 04:55:38 +00:00
Warner Losh
f5b24e1c9f Mark two things as unused (since they are only sometimes used) and
toss in a DECONST to remove a const in some tricky code that would
require too extensive a change to unwind otherwise.

Sponsored by: Netflix
2017-12-03 04:55:33 +00:00
Warner Losh
f8bb886226 Provide a md_load64 prototype.
Sponsored by: Netflix
2017-12-03 04:55:28 +00:00
Warner Losh
6f1066fa3c Cast void * pointer to char * so the arg matches the %s format.
Sponsored by: Netflix
2017-12-03 04:55:23 +00:00
Warner Losh
b21ed88a41 Disconnet ps3 from the build. There's too many warnings to fix. Also,
it's going to be removed soon anyway once the final lingering issues
with kboot are resolved. Go ahead and disconnect it from the build a
little early.

Sponsored by: Netflix
OK'd by: nathanw@
2017-12-03 04:55:19 +00:00
Warner Losh
afb769e9f8 Declare our strange brand of main().
Sponsored by: Netflix
2017-12-03 04:55:14 +00:00
Warner Losh
0a34fc542c e_entry can be smaller than a pointer. Cast it to an intptr_t before
casting it to a uint64_t *.
2017-12-03 04:55:04 +00:00
Warner Losh
2d35a371fc Cast mdp (a vm_offset_t) to void * to match prototype.
Sponsored by: Netflix
2017-12-03 04:54:59 +00:00
Warner Losh
a76b2d3d57 Include machine/md_var to pick up __syncicache prototype.
Sponsored by: Netflix
2017-12-03 04:54:54 +00:00
Warner Losh
7287ae743c Delcare md_load in libofw.h. Make all prototypes match for ofw
provided md_load functions.

Sponsored by: Netflix
2017-12-03 04:54:49 +00:00
Warner Losh
6df214c520 Const poison the propname. It's never set and we often pass it const
char *.

Sponsored by: Netflix
2017-12-03 04:54:18 +00:00
Warner Losh
1227a4f4ea Fix all warnings related to geli and ZFS support on x86.
Default WARNS to 0 still, since there's still some warnings on other
architectures.

Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D13301
2017-12-02 00:07:37 +00:00
Warner Losh
0979948fe2 Tweaks to the beri boot loader so that it builds w/o warnings.
Sponsored by: Netflix
2017-12-02 00:07:31 +00:00
Warner Losh
59d395e062 Undefine _STANDALONE since this is test code. This is unsastifying,
but since we sadly only have one test, put this in as a stopgap.

Sponsored by: Netflix
2017-12-02 00:07:25 +00:00
Warner Losh
dcaa2d76dc Fix random() and srandom() prototypes to match the standard.
These prototypes were needlessly different from the standard. Fix them
to be the same, and fix the surrounding code after the changes.

Sponsored by: Netflix
2017-12-02 00:07:19 +00:00
Warner Losh
9462787dba Move geli to common DO32 stuff
define DO32 since this is only build in amd64/i386
Remove files not needed.

Sponsored by: Netflix
2017-12-02 00:07:14 +00:00
Warner Losh
3a7d67e741 We don't need both _STAND and _STANDALONE. There's more places that
use _STANDALONE, so change the former to the latter.

Sponsored by: Netflix
2017-12-02 00:07:09 +00:00
Warner Losh
b65d776328 Cleanup CFALGS usage here
Only define the CFLAGS we need.
SSP_CFLAGS is now defined globally, no need to define it here.
Define -D_STANDALONE globally for src/stand builds.

Sponsored by: Netflix
2017-12-02 00:07:04 +00:00
Warner Losh
4f6b287494 Minor flags cleanup
Move kernel includes and libsa includes together at the top of defs.mk
Move all machine specific defines from Makefile.inc to their friends
in defs.mk.
Add comments and remove now useless junk after the move.

Sponsored by: Netflix
2017-12-02 00:06:58 +00:00
Warner Losh
4291beb51b Remove stale dependency on ufsread.c
Remove the now-useless dependency on ufsread.c. In some cases, it was
on the wrong file. But in all cases, we now automatically generate
.depend files, so we don't need it explicitly.

Sponsored by: Netflix
2017-12-02 00:06:52 +00:00
Toomas Soome
e4f6a1bfa3 loader.efi: efipart should exclude iPXE stub block protocol
iPXE does insert stub  BLOCK IO protocol handle to rework other issues,
this handle is not usable as it does not provide actual implementation.

We can detect this situation by checking and validating the BlockSize
property, so this update does make sure we have BlockSize at least 512B
and its value is power of 2.

PR:		223969
Reported by:	Jeff Pieper
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13297
2017-12-01 06:37:12 +00:00
Warner Losh
f02a303122 Use const pointers to avoid casting away constness.
The host_open interface was a legitimate mismatch to the userboot
function, while the other pointers didn't need to be non-const.

This makes the powerpc warning free again.

Sponsored by: Netflix
2017-11-30 05:01:56 +00:00
Nathan Whitehorn
28b2cf37b9 Modify all FreeBSD bootloaders on PowerPC AIM (Book-S) systems to pass a
magic number to the kernel in r7 rather than the (currently unused and
irrelevant) width of the metadata pointer, which I believe was intended
for a never-used approach to the 64-bit port. This enables the kernel,
in a future commit, to switch on the cookie to distinguish a real
metadata pointer from loader(8) from garbage left in r6 by some other
boot loader.

MFC after:	3 weeks
2017-11-24 23:41:04 +00:00
Warner Losh
d927d443e1 Mark the func pointer as __dead2. It looks up loader_main, which
either aborts or exits, but never returns. Tag it as a non-returning
function rather than supply a bogus return(0) at the end of main.

CID: 1382885
Sponsored by: Netflix
2017-11-24 05:01:00 +00:00
Warner Losh
db71174436 Fix theoretical integer overflow issues. If the product here is
greater than 2^31-1, then the result will be huge. This is unlikely,
as we don't support that many sections, but out of an abundace of
caution cast to size_t so the multiplication won't overflow
mysteriously when size_t is larger than 32-bits. The resulting code
may be a smidge larger, but this isn't super-space critical code.

CID: 1194216, 1194217, 1194222, 1194223, 1265018, 1265019,1265020,
     1265021
Sponsored by: Netflix
2017-11-24 05:00:25 +00:00
Toomas Soome
a9abb85906 net_parse_rootpath() has no parameters
Add void for parameter list.
2017-11-22 10:04:09 +00:00
Toomas Soome
cdadbf0971 loader.efi: efipart does not recognize partitionless disks
Rework the block device handle check to allow more robust device
classification. This is mostly usability issue - it can be quite confusing
for user when no disks are listed with lsdev.

Add more comments about what and why is done.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D13026
2017-11-22 08:48:00 +00:00
Warner Losh
063e16324b Unbreak riscv build in universe.
riscv doesn't have -msoft-float. For the moment, just don't add
anything. There's no /boot/loader or other bootstrap contained in the
tree for riscv*. However, with real hardware coming next year, there
are plans for one, so keep building at least a minimal libsa and
ficl to prevent bitrot.

Sponsored by: Netflix
2017-11-21 19:23:20 +00:00
Warner Losh
01dd1497ec Fix gptzfsboot for cases with GELI.
HAVE_GPT isn't currently a thing, but HAVE_GELI is. Replace the former
with the latter and remove util.o from the build list (it's picked up
from libsa/libsa32, and that's OK).

Sponsored by: Netflix
2017-11-21 18:03:47 +00:00
Warner Losh
8a4217aacf Move some more common stuff up to Makefile.inc. In particular, the no
simd / no float stuff is centeralized here. Also centralise
-ffreestanding since it is specified everywhere.

This, along with a change to share/mk/bsd.cpu.mk to include -mno-avx2
in CFLAGS_NO_SIMD should fix building for newer machines (eg with
CPUTYPE=haswell) where clang was generating avx2 instructions.

Sponsored by: Netflix
2017-11-20 22:42:17 +00:00
Warner Losh
ca987d4641 Move sys/boot to stand. Fix all references to new location
Sponsored by:	Netflix
2017-11-14 23:02:19 +00:00