Commit Graph

78 Commits

Author SHA1 Message Date
Warner Losh
a54409db16 We don't need to build a special ficl for userboot.
Prior to bringing efi into the system, amd64 systems were building
32-bit ficl only, while userboot required the 64-bit one. However,
with efi, we now build both. userboot can and should use the one we
build for the main tree (in fact, it has been for a while, though I
didn't check to see if that was an intentional change before, or an
accidental one in my cleanup). Eliminate the extra copy (and build
time) for userboot.

Sponsored by: Netflix
2017-10-30 23:14:48 +00:00
Warner Losh
c1d8f9bb54 Use defs.mk values for userboot
Sponsored by: Netflix
2017-10-30 23:14:22 +00:00
Warner Losh
a7fa2fb669 LOADER_foo_SUPPORTED 2017-10-16 03:59:52 +00:00
Warner Losh
6b9f688352 Move all the ficl common code into ficl.mk
There's a number of copies of basically identical code to enable
building forth in /boot/loader. Move it all into ficl.mk.
2017-10-16 03:59:44 +00:00
Warner Losh
7f20726e4b Move common/Makefile.inc to sys/boot/loader.mk.
Makefile.inc has a specific meaning in the tree, and
common/Makefile.inc doesn't quite fit into that. Rename it to
loader.mk and it will be a place to collect common things to all
/boot/loader programs there.

Sponsored by: Netflix
2017-10-16 03:59:28 +00:00
Warner Losh
3006b7c8a9 Kill the userboot copy of libstand.
It's not needed (it's now identical to libsa, and seems to have been
for some time).

Sponsored by: Netflix
2017-10-12 14:56:42 +00:00
Warner Losh
4eb1313ff2 Move lib/libstand to sys/boot/libsa
Move the sources to sys/boot. Make adjustments related to the
move. Kill LIBSTAND_SRC since it's no longer needed.

Sponsored by: Netflix
2017-10-12 14:56:28 +00:00
Warner Losh
b9b9a7c3a2 Rather than laying whack-a-mole with including the path to stand.h,
always include it. Remove places where we explicitly include it. This
also helps reduce the 'cut-and-paste' factor of these Makefiles.

Sponsored by: Netflix
2017-10-10 01:31:44 +00:00
Warner Losh
8f409b435a Define LIBSA* and use them instead of overloaded LIBSTAND
LIBSA is the current stand alone library. LIBSA32 is the 32-bit
version of the library. LIBSAU is the userboot version of libsa. Use
the proper define instead of the more generic define.

Sponsored by: Netflix
2017-10-09 22:12:46 +00:00
Warner Losh
eca8b9c449 Define SASRC and use it
Define SASRC to point to the current libstand sources. Include
../Makefile.inc early enough in a few places so we can .include
"${SASRC}/Makefile" and have it work. Create a new pass-up
Makefile.inc in sys/boot/userboot to allow this pattern to work.

Sponsored by: Netflix
2017-10-09 22:12:32 +00:00
Toomas Soome
c9296b3227 loader: F_READ/F_WRITE should be checked against masked flag
The work to make it possible to avoid bcache via using F_NORA modifier did
miss the fact that not all loader platforms are using the bcache, and so
it is possible the modifier is not cleared, as bcache strategy function is
not used.

For fix, we make sure the checks are dont with masked flag.

This patch does fix boot for platforms which do not use bcache.

Reported by:	emaste
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D10422
2017-04-18 18:07:54 +00:00
Toomas Soome
d47b2e96e9 loader: r316585 did miss userboot update
The work to implement zfs reader to inspect all pool label copies did
miss the userboot, this update does correct this issue.

Since userboot is already using common/disk.c API (disk_open() etc),
the fix is quite simple - we only need to make sure the userdisk_iocl()
will call disk_ioctl(). In addition, the diskioctl callback does return
int, not pointer.

Note, the review request is actually addressing the sparc and userboot,
but as testing the fix for sparc will take some more time, I am posting the
userboot fix now.

This patch is part of the implementation presented in review:
https://reviews.freebsd.org/D10302

Once we have the sparc part tested, we will have the complete fix
for the issue.

Reviewed by:	imp
2017-04-09 11:16:16 +00:00
Toomas Soome
1c36b15ace loader: disk_cleanup was left in userboot_disk.c
In r315408, disk_cleanup was removed, which is called at
sys/boot/userboot/userboot/userboot_disk.c:113.
This causes bhyveload to fail.

PR:		217935
Reported by:	Fabian Freyer
Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D10060
2017-03-20 18:03:40 +00:00
Toomas Soome
b91aad35da loader: remove open_disk cache
As we provide the disk size verification and correction via disk_ioctl
and disk state provided by disk_open(), we can not share the partition
state in disk_devdesc structure. Also the sharing does make a lot of sense
with ufs, as only one partition is open at any given time, but zfs pools
do keep the disk devices open.

To make sure we do get the correct information about the open device,
just remove the cache.

Reviewed by:	allanjude, smh
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D9757
2017-03-16 12:04:43 +00:00
Pedro F. Giffuni
8a13944bc7 Split the ficl CFLAGS when they refer to an arch-specific include path.
This is a minimal attempt to keep consistency in the Makefiles so that
moving ficl to somwehere like contrib will be less error prone.

MFC after:	1 week
2017-03-01 19:36:32 +00:00
Pedro F. Giffuni
e099b90b80 sys: Replace zero with NULL for pointers.
Found with:	devel/coccinelle
MFC after:	3 weeks
Differential Revision:	https://reviews.freebsd.org/D9694
2017-02-22 02:35:59 +00:00
Toomas Soome
1ecc859193 dosfs support in libstand is broken since r298230
Apparently the libstand dosfs optimization is a bit too optimistic
and did introduce possible memory corruption.

This patch is backing out the bad part and since this results in
dosfs reading full blocks now, we can also remove extra offset argument
from dv_strategy callback.

The analysis of the issue and the backout patch is provided by Mikhail Kupchik.

PR:		214423
Submitted by:	Mikhail Kupchik
Reported by:	Mikhail Kupchik
Reviewed by:	bapt, allanjude
Approved by:	allanjude (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D8644
2016-12-30 19:06:29 +00:00
Ed Maste
bc814587a9 Deduplicate loader vers.c Makefile rules
The Makefile rule to create vers.c for loader version info was
previously duplicated in each of the various loader Makefiles.
Instead, share a common rule in Makefile.inc.

Reviewed by:	bapt
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8841
2016-12-19 14:40:59 +00:00
Ed Maste
0bf23e313e Reduce boot loader version string duplication
Instead of repeating "%s, Revision %s" "(%s %s)" in each loader, just
create the full version string in vers.c

Reviewed by:	bapt
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D8823
2016-12-18 13:57:23 +00:00
Toomas Soome
77d81a4dab lsdev device name section headers should be printed by dv_print callback.
lsdev command does walk over devsw list, prints list element name and
will use dv_print() callback to print the device list.
Unfortunately this approach will add unneeded noise when there are no
particular devices detected.

To remove "empty" device section headers, the dv_print() callback
should print the header instead.

In addition, fixed dv_print callback for md module.

Reviewed by:	imp
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D8551
2016-11-19 08:54:21 +00:00
Toomas Soome
cbd6713146 Loader paged/pageable data is not always paged.
This change does modify devsw dv_print() to return the int value,
enabling walkers to interrupt the walk on non zero value from dv_print().

This will allow the pager_print actually to stop displaying data on
user input, and additionally pager is used in various *dev_print callbacks,
where it was missing.

For test, lsdev [-v] command should display data by screenfuls and should
stop when the key 'q' is pressed on pager prompt.

Reviewed by:	allanjude
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D5461
2016-11-08 06:50:18 +00:00
Baptiste Daroussin
8ee29e403a Fix build WITHOUT_FORTH
MFC after:	1 week
Sponsored by:	Gandi.net
2016-10-14 11:57:08 +00:00
Allan Jude
3595d72f86 Disable loop unrolling in skein for sys/boot
When tsoome@ added skein support to the ZFS boot code and zfsloader, it
resulted in an explosion in code size, running close to a number of
limits.

The default for the C version of skein is to unroll all loops for
skein-256 and 512

Disabling the loop unrolling saves 20-28kb from each binary
boot1.efi
gptzfsboot
loader.efi
userboot.so
zfsloader

Reviewed by:	emaste, tsoome
Sponsored by:	ScaleEngine Inc.
Differential Revision:	https://reviews.freebsd.org/D7826
2016-10-06 03:32:30 +00:00
Toomas Soome
792ee5d5f2 Bug 212038 - svn commit: r304321 broken bhyve zvol VM bhyveload hang 100% WCPU
As the support for large blocks was enabled in loader zfs code, the
heap in userboot was left not changed, resulting with failure of detecting
and accessing zfs pools for bhyve virtual machines.

This fix does set the heap to use same amount of memory as the zfsloader
is using. To make it possible to test and verify loader functions, bhyve
is providing very useful option, but it also means, we like to keep feature
parity with [zfs]loader as close as possible.

PR:		212038
Reported by:	dfh0522@gmail.com
Reviewed by:	allanjude, grehan
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D7635
2016-08-24 16:40:29 +00:00
Toomas Soome
2c55d0903d Add SHA512, skein, large blocks support for loader zfs.
Updated sha512 from illumos.
Using skein from freebsd crypto tree.
Since loader itself is using 64MB memory for heap, updated zfsboot to
use same, and this also allows to support zfs large blocks.

Note, adding additional features does increate zfsboot code, therefore
this update does increase zfsboot code to 128k, also I have ported gptldr.S
update to zfsldr.S to support 64k+ code.

With this update, boot1.efi has almost reached the current limit of the size
set for it, so one of the future patches for boot1.efi will need to
increase the limit.

Currently known missing zfs features in boot loader are edonr and gzip support.

Reviewed by:	delphij, imp
Approved by:	imp (mentor)
Obtained from:	sha256.c update and skein_zfs.c stub from illumos.
Differential Revision:	https://reviews.freebsd.org/D7418
2016-08-18 00:37:07 +00:00
Allan Jude
3db33b0a8c Link bcache into userboot.so, was not added in r298230
This should help speed up bhyve boots too

Reviewed by:	olivier
2016-04-19 20:56:45 +00:00
Allan Jude
87ed2b7f5a A new implementation of the loader block cache
The block cache implementation in loader has proven to be almost useless, and in worst case even slowing down the disk reads due to insufficient cache size and extra memory copy.
Also the current cache implementation does not cache reads from CDs, or work with zfs built on top of multiple disks.
Instead of an LRU, this code uses a simple hash (O(1) read from cache), and instead of a single global cache, a separate cache per block device.
The cache also implements limited read-ahead to increase performance.
To simplify read ahead management, the read ahead will not wrap over bcache end, so in worst case, single block physical read will be performed to fill the last block in bcache.

Booting from a virtual CD over IPMI:
0ms latency, before: 27 second, after: 7 seconds
60ms latency, before: over 12 minutes, after: under 5 minutes.

Submitted by:	Toomas Soome <tsoome@me.com>
Reviewed by:	delphij (previous version), emaste (previous version)
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D4713
2016-04-18 23:09:22 +00:00
Pedro F. Giffuni
74b8d63dcc Cleanup unnecessary semicolons from the kernel.
Found with devel/coccinelle.
2016-04-10 23:07:00 +00:00
Bryan Drewery
a09f4b4d12 Add more .NOMETA missed in r291320
Sponsored by:	EMC / Isilon Storage Division
2016-03-11 23:45:51 +00:00
Ed Maste
fa078c432f userboot: use MK_CTF=no to disable CTF
The NO_ form (e.g. NO_CTF) is deprecated.
2016-02-29 17:54:55 +00:00
Marcel Moolenaar
7eb9cc0975 Add vm_set_register() and vm_set_desc() callbacks. These callbacks
translate directly into calls to their namesake API functions in
libvmmapi.

It is an improvement over the existing setreg(), setmsr(), setcr()
setgdt() and exec() callbacks in that the new additions give full
control and don't assume we're booting FreeBSD, like exec() and
don't assume one only wants to set the value of RSP, like setreg().
2016-02-26 16:00:16 +00:00
Marcel Moolenaar
8265d91646 Check that the userboot version is at least 3, rather than
3 exactly. The structure may be of a newer version and as
long as it is backward compatible with 3, we can work with
it.

While here: whitespace nits.
2016-02-26 15:52:55 +00:00
Bryan Drewery
bd18fd57db DIRDEPS_BUILD: Regenerate without local dependencies.
These are no longer needed after the recent 'beforebuild: depend' changes
and hooking DIRDEPS_BUILD into a subset of FAST_DEPEND which supports
skipping 'make depend'.

Sponsored by:	EMC / Isilon Storage Division
2016-02-24 17:20:11 +00:00
Allan Jude
fbe958861e Move init_zfs_bootenv to sys/boot/zfs/zfs.c instead of having a copy in each loader
While here, add a filter to ignore special datasets

MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-15 05:45:10 +00:00
Juli Mallett
e83ddf77d4 Make it possible to specify the path to userboot.so with the -b flag.
Reviewed by:	neel
2016-01-14 22:07:35 +00:00
Allan Jude
fce8d0e350 Only call init_zfs_bootenv() when the system was booted with ZFS
Add a few other safeguards to ensure things do not break when the
boot device cannot be determined

Reported by:	flo
MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-09 00:54:08 +00:00
Bryan Drewery
eefa1c373f Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-01-09 00:43:11 +00:00
Ed Maste
873e5b5e14 Reduce libstand Makefile duplication
Userboot's copy of the libstand Makefile had more extensive changes
compared to the one in sys/boot/libstand32, but it turns out these are
not intentional and we can just include lib/libstand/Makefile as done
for libstand32 in r293040.

Reviewed by:	imp, jhb
Tested by:	allanjude
MFC after:	1 month
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D4793
2016-01-08 19:12:26 +00:00
Allan Jude
adff67c988 Add support for ZFS Boot Environments to userboot (for bhyve and others)
While here, also fix a possible null pointer

Reported by:	lattera
MFC after:	3 days
Sponsored by:	ScaleEngine Inc.
2016-01-08 05:09:55 +00:00
Bryan Drewery
e3ebb82118 DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2016-01-07 19:58:23 +00:00
Bryan Drewery
b2fe867a0f DIRDEPS_BUILD: Update dependencies.
Sponsored by:	EMC / Isilon Storage Division
2015-12-07 23:53:01 +00:00
Bryan Drewery
b1f92fa229 META MODE: Update dependencies with 'the-lot' and add missing directories.
This is not properly respecting WITHOUT or ARCH dependencies in target/.
Doing so requires a massive effort to rework targets/ to do so.  A
better approach will be to either include the SUBDIR Makefiles directly
and map to DIRDEPS or just dynamically lookup the SUBDIR.  These lose
the benefit of having a userland/lib, userland/libexec, etc, though and
results in a massive package.  The current implementation of targets/ is
very unmaintainable.

Currently rescue/rescue and sys/modules are still not connected.

Sponsored by:	EMC / Isilon Storage Division
2015-12-01 05:23:19 +00:00
Warner Losh
9d2edd63d4 Use CFLAGS_NO_SIMD in preference to varying lists of -mno-xxxx flags.
Go ahead and defined -D_STANDALONE for all targets (only strictly
needed for some architecture, but harmless on those it isn't required
for). Also add -msoft-float to all architectures uniformly rather
that higgley piggley like it is today.

Differential Revision: https://reviews.freebsd.org/D3496
2015-08-27 23:46:42 +00:00
Andriy Gapon
2ecf70de02 userboot: enable bzipfs support
Additionally, sort all real filesystems before the virtual ones.

Differential Revision:	https://reviews.freebsd.org/D2709
Reviewed by:	grehan
MFC after:	5 days
2015-06-03 10:10:00 +00:00
Ed Maste
15222dc5d6 Reduce diffs between the three copies of libstand's Makefile
This should be a non-functional change.  A future change should
address the functional differences between these three and converge
on a single source.

Differential Revision:	https://reviews.freebsd.org/D2058
Reviewed by:	jhb
Sponsored by:	The FreeBSD Foundation
2015-04-23 14:04:33 +00:00
David E. O'Brien
eda6932911 sys/boot/userboot/libstand/libstand.a should also include strtoul.c;
as lib/libstand/ and sys/boot/libstand32/ already does.
2015-02-27 22:23:35 +00:00
Sean Bruno
45a3069948 Quiesce warning about discarding a const qualifier in assignement.
Phabric:	https://phabric.freebsd.org/D445
Reviewed by:	neel
2014-08-08 21:47:47 +00:00
Marcel Moolenaar
7fe0b4f160 Give loaders more control over the Forth initialization process. In
particular, allow loaders to define the name of the RC script the
interpreter needs to use. Use this new-found control to have the
PXE loader (when compiled with TFTP support and not NFS support)
read from ${bootfile}.4th, where ${bootfile} is the name of the
file fetched by the PXE firmware.

The normal startup process involves reading the following files:
1.  /boot/boot.4th
2.  /boot/loader.rc or alternatively /boot/boot.conf

When these come from a FreeBSD-defined file system, this is all
good. But when we boot over the network, subdirectories and fixed
file names are often painful to administrators and there's really
no way for them to change the behaviour of the loader.

Obtained from:	Juniper Networks, Inc.
2014-07-27 16:12:51 +00:00
Sean Bruno
12857dd1ea copyin/copyout should return 0 if they are truly emulating copyin/copyout behavior.
remove stray %s in printf

rewrite printf to display 64bit type without warning.
2014-07-22 04:47:19 +00:00
Marcel Moolenaar
e7d939bda2 Remove ia64.
This includes:
o   All directories named *ia64*
o   All files named *ia64*
o   All ia64-specific code guarded by __ia64__
o   All ia64-specific makefile logic
o   Mention of ia64 in comments and documentation

This excludes:
o   Everything under contrib/
o   Everything under crypto/
o   sys/xen/interface
o   sys/sys/elf_common.h

Discussed at: BSDcan
2014-07-07 00:27:09 +00:00