Commit Graph
3545 Commits
Author SHA1 Message Date
Ryan Libby 638b0e9acf MFC r316119 (by ngie):
self_reloc.c: Pass -Wno-error=maybe-uninitialized to gcc versions
  greater than 4.2.1
2017-09-12 06:21:43 +00:00
Ryan Libby 6b287fcd3a MFC r303723 (by markj):
Fix a few cosmetic issues in boot1.efi.
2017-09-12 06:19:19 +00:00
Ian Lepore ec1c764be8 MFC r316374, r316377:
Preserve the registers containing argc, argv, and return address values
passed in from u-boot across the call to self_reloc and any other early-init
code, and restore them before calling main().

Correct a comment... the stack used by ubldr is the same stack u-boot was
running on when it jumped to the ubldr entry point.  None of the arches
that use this code set up a different stack in their start.S routines.
2017-09-11 00:55:18 +00:00
Ian Lepore 22a662a249 MFC r315574, r315576, r315577:
Convert the imx5 interrupt controller driver to INTRNG.

Add INTRNG option to EFIKA_MX config, it is an imx5-based platform.

Delete our local imx53-qsb.dts file; the code now runs fine using the
standard vendor-supplied file in sys/gnu/dts/arm.
2017-09-10 23:41:23 +00:00
Ryan Libby c8b051ccf4 MFC r322329:
i386/boot2: -fno-asynchronous-unwind-tables for gcc
2017-09-07 05:41:13 +00:00
Oleg Bulyzhin fbeeae9841 MFC r322628: Fix BSD label partition end sector calculation.
Differential Revision:	https://reviews.freebsd.org/D12066
2017-08-31 12:36:09 +00:00
Enji Cooper a1e8f3baf2 MFC r321851:
Standardize paths on SRCTOP instead of .CURDIR-relative paths
2017-08-08 05:19:45 +00:00
Edward Tomasz Napierala 62a65aa027 MFC r319798:
Switch the example name for variables controlling loading memory images
in /boot/defaults/loader.conf to something that's actually commonly used,
"mdroot".  It's arbitrary, but it's easier to find this way.
2017-08-05 09:40:56 +00:00
Alexander Motin 9c39053b1c MFC r314504 (by tsoome):
loader: r314112 did introduce dereference freed pointer entry

CID:		1371675
Reported by:    Coverity
Differential Revision:  https://reviews.freebsd.org/D9846
2017-07-29 11:27:54 +00:00
Alexander Motin e917fec4ea MFC r307865 (by tsoome): loader should boot pre-feature flags pools.
The feature flags chek is missing the corner case where we have valid pool
version, but feature flags are not enabled - as for example plain v28 pool.

This update does fix the boot support for such pools.

Differential Revision:  https://reviews.freebsd.org/D8331

PR:		221084
2017-07-29 09:56:07 +00:00
Dimitry Andric fffbca89b0 MFC r321305:
Fix printf format warning in zfs_module.c

Clang 5.0.0 got better warnings about print format strings using %zd,
and this leads to the following -Werror warning on e.g. arm:

    sys/boot/efi/boot1/zfs_module.c:186:18: error: format specifies type 'ssize_t' (aka 'int') but the argument has type 'off_t' (aka 'long long') [-Werror,-Wformat]
                        "(%lu)\n", st.st_size, spa->spa_name, filepath, EFI_ERROR_CODE(status));
                                   ^~~~~~~~~~

Fix this by casting off_t arguments to intmax_t, and using %jd instead.

Reviewed by:	tsoome
Differential Revision:	https://reviews.freebsd.org/D11678
2017-07-28 18:35:29 +00:00
Alexander Motin 1d98d973e1 Fix mismerge in r321525. 2017-07-26 15:52:51 +00:00
Alexander Motin 960dc157ed MFC r314112 (by tsoome): loader: update symlink support in zfs reader
As the current zfs file system is providing symlink via system attributes,
need to update the code accordingly.

Note, as the zfsboot code does not free the memory at this time, the
object list will put some stress on the boot2 heap, eventually we should
address the issue.

Differential Revision:  https://reviews.freebsd.org/D9706
2017-07-26 15:29:56 +00:00
Alexander Motin f5e9c86a73 MFC r303630 (by allanjude):
Make boot code and loader check for unsupported ZFS feature flags

OpenZFS uses feature flags instead of a zpool version number to track
features since the split from Oracle. In addition to avoiding confusion
on ZFS vs OpenZFS version numbers, this also allows features to be added
to different operating systems that use OpenZFS in different order.

The previous zfs boot code (gptzfsboot) and loader (zfsloader) blindly
tries to read the pool, and if failed provided only a vague error message.

With this change, both the boot code and loader check the MOS features
list in the ZFS label and compare it against the list of features that
the loader supports. If any unsupported feature is active, the pool is
not considered as a candidate for booting, and a helpful diagnostic
message is printed to the screen. Features that are merely enabled via
zpool upgrade, but not in use, do not block booting from the pool.

Submitted by:   Toomas Soome <[email protected]>
Reviewed by:    delphij, mav
Relnotes:       yes
Differential Revision:  https://reviews.freebsd.org/D6857
2017-07-26 14:55:47 +00:00
Enji Cooper 16eceea368 MFC r316102:
Wrap bootcamp DEBUG statement with curly braces

This fixes a -Wempty-body warning with gcc 6.3.0 when PART_DEBUG is undefined.

Tested with:	amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc)
2017-07-20 00:47:50 +00:00
Enji Cooper 202712db28 MFC r316076:
sys/boot/common: Make geli(4) support optional in MI sources

This saves a negligible amount of memory for non-geli enabled
bootloaders.
2017-07-19 19:06:19 +00:00
Enji Cooper b5b1120e71 MFC r309412,r316109,r316132:
r309412 (by imp):

dd is currently a bootstrap tool. It really doesn't have any business
being a bootstrap tool. However, for reproducible build output,
FreeBSD added dd status=none because it was otherwise difficult to
suppress the status information, but retain any errors that might
happen. There's no real reason that dd has to be a build tool, other
than we use status=none unconditional. Remove dd from a bootstrap tool
entirely by only using status=none when available. This may also help
efforts to build the system on non-FreeBSD hosts as well.

r316109:

Don't hardcode input files for stage 1/2 bootloaders; use .ALLSRC instead

This is a better pattern to follow when creating the bootloaders and doing
the relevant space checks to make sure that the sizes aren't exceeded (and
thus, copy-pasting is a bit less error prone).

r316132:

Parameterize out 7680 (15 * 512) as BOOT2SIZE, similar to sys/boot/i386/zfsboot/...

This is being done to make it easier to change in the future--this action might be
needed sooner rather than later because of gcc 6.3.0 bailing, stating that there
is negative free space left (deficit) in the boot2 bootloader.
2017-05-28 01:08:46 +00:00
Enji Cooper 1ad99ec5d9 MFC r316103:
Remove redundant declarations

They're already defined in libstand.h
2017-05-22 06:26:22 +00:00
Konstantin Belousov 39345e967b MFC efivar(8) (by imp):
List of revisions merged:
r307070
r307071
r307072
r307074
r307189
r307224
r307339
r307390
r307391
r309776
r314231
r314232
r314615
r314616
r314617
r314618
r314619
r314620
r314621
r314623
r314890
r314925
r314926
r314927
r314928
r315770
r315771

Discussed with:	gjb (re), imp
Sponsored by:	The FreeBSD Foundation
2017-05-20 16:12:44 +00:00
Mark Johnston 6bc79c6013 MFC r318193:
Set the right variable when overriding the default console speed.
2017-05-18 18:39:23 +00:00
Roger Pau Monné 55d0a26754 MFC r316754: loader/multiboot: fix multiboot loading
Sponsored by: Citrix Systems R&D
2017-05-09 09:53:18 +00:00
Oleksandr Tymoshenko b722325baf MFC r315019:
[loader][fdt] Fix applying overlays without __local_fixups__ node

Do not return error if __local_fixups__ node is missing in DTB overlay
because local fixup data is optional.

Reported by:	Manuel Stuhn
2017-05-09 00:29:29 +00:00
Ed Maste cc3d88dbfb MFC r303442, r305343: remove CONSTRUCTORS from linker scripts
r303442: remove CONSTRUCTORS from kernel linker scripts

r305343: remove CONSTRUCTORS from MIPS uboot linker script

The linker script CONSTRUCTORS keyword is only meaningful "when linking
object file formats which do not support arbitrary sections, such as
ECOFF and XCOFF"[1] and is ignored for other object file formats.

LLVM's lld does not yet accept (and ignore) CONSTRUCTORS, so just remove
CONSTRUCTORS from the linker script as it has no effect.

[1] https://sourceware.org/binutils/docs/ld/Output-Section-Keywords.html

Reported by:	andrew
Sponsored by:	The FreeBSD Foundation
2017-04-19 15:33:24 +00:00
Andrew Turner 6763890c69 Fix the arm64 userland building with lld:
MFC 308124:
 On arm64 build the efi loader with -fPIC. Without this clang 3.9 will
 generate relocation in the self relocation code.

MFC 316608:
 Add -fPIC to the standalone build flags on arm64. This is needed as
 loader.efi is position independend, however we were not building it as
 such causing a build failure when building with lld.

MFC 315452:
 Mark the EFI PE header as allocated. While ld.bfd doesn't seem to care
 about not having this flag ld.lld fails to link without it.
2017-04-19 14:07:35 +00:00
Enji Cooper c0de4dee33 MFC r316106:
Don't shadow read(2) definition with `read` argument in vdev_{create,probe}

This fixes several -Wshadow warnings introduced in r192194, but now errors
with gcc 6.3.0.
2017-03-31 04:51:03 +00:00
Enji Cooper cd479507a4 MFC r316107:
Remove redundant declaration for `zfs_crc64_table`

zfssubr.c already defines this statically. Besides, zfsimpl.c defined it, but
didn't use it.

This fixes a -Wredundant-decls warning.
2017-03-31 04:44:35 +00:00
Enji Cooper 7ff7342172 MFC r316108:
Remove -Wunused-but-set variable, `tail` in `ls_getdir(..)`

This variable has been unused since its inception in r40106.
2017-03-31 04:43:21 +00:00
Toomas Soome 649dec0078 boot1.efi: can't boot from ZFS on 4kn HDD
The boot1.efi immediate issue from PR216964 is that we are reading into
too small buffer, from UEFI spec 2.6:

The size of the Buffer in bytes. This must be a multiple of the intrinsic block size of the device.

The secondary issue is that LBA calculation does not check reminder from
division.

This fix does check the provided buffer size and if we read less than
media sector size or the read offset is not aligned to sector boundary,
we allocate bounce buffer and perform the read by single sector.

PR:		216964
Reported by:	Sergey Kozlov
Reviewed by:	allanjude, Sergey Kozlov
Approved by:	allanjude (mentor)
Differential Revision:	https://reviews.freebsd.org/D9870
2017-03-30 17:23:40 +00:00
Dexuan Cui 9349937d70 MFC: 314547, 314770, 314828, 314891, 314956, 314962, 315235
r314547
    loader.efi: reduce the size of the staging area if necessary

    The loader assumes physical memory in [2MB, 2MB + EFI_STAGING_SIZE)
    is Conventional Memory, but actually it may not, e.g. in the case
    of Hyper-V Generation-2 VM (i.e. UEFI VM) running on Windows
    Server 2012 R2 host, there is a BootServiceData memory block at
    the address 47.449MB and the memory is not writable.

    Without the patch, the loader will crash in efi_copy_finish():
    see PR 211746.

    The patch verifies the end of the staging area, and reduces its
    size if necessary. This way, the loader will not try to write into
    the BootServiceData memory any longer.

    Thank Marcel Moolenaar for helping me on this issue!

    The patch also allocates the staging area in the first 1GB memory.
    See the comment in the patch for this.

    PR:		211746
    Reviewed by:	marcel, kib, sephe
    Approved by:	sephe (mentor)
    Sponsored by:	Microsoft
    Differential Revision:	https://reviews.freebsd.org/D9686

r314770
    loader.efi: fix recent UEFI-boot regression on physical machines

    This patch fixes my recent patch
    "loader.efi: reduce the size of the staging area if necessary", which
    causes EFI-boot failure on physical machines since Mar 2:
    on the host there is a 1MB LoaderData memory range, which splits
    the big Conventional Memory range into a small one (15MB) and a
    big one: the small one is too small to hold the staging area.

    We can actually use the LoaderData range safely, because when
    amd64_tramp -> efi_copy_finish() starts to run, we're almost at
    the very end of the efi loader code and we're going to "return"
    to the kernel entry, so we're pretty sure we won't access any loader
    data any more.

    For people who are interested in the details: please see
    https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211746#c22

    PS, some people also reported the regression happened to FreeBSD VM
    running on Bhyve in EFI mode. This patch should resolve it too,
    though I don't have such a setup to test.

    Reviewed by:	sephe
    Approved by:	sephe (mentor)
    Sponsored by:	Microsoft
    Differential Revision:	https://reviews.freebsd.org/D9904

r314828
    loader.efi: fix an off-by-one bug in efi_verify_staging_size()

    Also remove the warning message: it may not be unusual to see
    the memory range containing 2MB is not of EfiConventionalMemory.

    Sponsored by:	Microsoft

r314891
    loader.efi: finally fix the off-by-one bug in efi_verify_staging_size()

    r314828(loader.efi: fix an off-by-one bug in efi_verify_staging_size())
    doesn't really fix the bug and this patch adds the missing part.

    It's a shame that I didn't make everything correct at the very beginning...

    Sponsored by:	Microsoft

r314956
    loader.efi: only reduce the size of the staging area on Hyper-V

    Doing this on physical hosts turns out to be problematic, e.g. see comment
    24 and 28 in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=211746.

    To fix the real underlying issue correctly & thoroughly, IMO we need
    a relocatable kernel, but that would require a lot of complicated long
    term work:  https://reviews.freebsd.org/D9686?id=25414#inline-56969

    For now, let's only apply efi_verify_staging_size() to VMs running on
    Hyper-V, and restore the old behavior on physical machines since that
    has been working for people for a long period of time, though that's
    potentially unsafe...

    Sponsored by:	Microsoft

r314962
    loader.efi: only include the machine/ header files on x86

    The 2 files may not exist on other archs like aarch64 and hence we
    can have a build failure there.

    Reported by:	lwhsu
    Sponsored by:	Microsoft

r315235
    loader.efi: use stricter check for Hyper-V

    Some other hypervisors like Xen can pretend to be Hyper-V but obviously
    they can't implement all Hyper-V features. Let's make sure we're genuine
    Hyper-V here.

    Also fix some minor coding style issues.

    PR:		211746
    Sponsored by:	Microsoft

PR:		211746
2017-03-30 12:41:21 +00:00
Enji Cooper 2533a198ec MFC r315738:
Document some more 10GbE+ network drivers in loader.conf

- if_cxgbe
- if_ixl
- if_ixlv
- sfxge
2017-03-29 08:01:38 +00:00
Pedro F. Giffuni bd0faecc93 MFC r313982, r314068:
sys: Replace zero with NULL for pointers.

Found with:	devel/coccinelle
2017-03-14 02:06:03 +00:00
Pedro F. Giffuni cdb54e1307 MFC r314505:
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.
2017-03-08 22:38:40 +00:00
Ian Lepore 15c864fdcc MFC r309195:
Add an ethernet0 alias pointing to the /aix/usb/hub/ethernet node.  This
  is required for u-boot to locate the ethernet node when it's doing fixup
  of the mac-address property when the user has overridden the default addr.
2017-03-01 21:48:15 +00:00
Toomas Soome f8a52fbaab MFC r309369,310850,310853:
libstand: dosfs cstyle cleanup for return keyword.
dosfs support in libstand is broken since r298230

PR:		214423
Submitted by:	Mikhail Kupchik
Reported by:	Mikhail Kupchik
Approved by:	imp (mentor)
2017-02-06 22:03:07 +00:00
Toomas Soome ff56fa62d3 MFC r310845: boot2 will deadlock if extended keys are used on text input
Approved by:	imp (mentor)
Differential Revision:	https://reviews.freebsd.org/D8608
2017-02-06 20:57:17 +00:00
Oleksandr Tymoshenko b7d186a322 MFC r310124 (by andrew):
Add -fPIC to the ubldr build. Without this the self relocation code will
try to use an absolute address in a switch statement, jumping to an invalid
memory location.

Sponsored by:	ABT Systems Ltd

PR:		216504
2017-02-04 01:24:21 +00:00
Dimitry Andric d82121e4b5 MFC r311932:
Make EFI_RESERVED_SERVICE a proper prototype

With clang 4.0.0, the EFI API header causes the following warning:

In file included from sys/boot/efi/loader/bootinfo.c:43:
In file included from sys/boot/efi/loader/../include/efi.h:52:
sys/boot/efi/include/efiapi.h:534:32: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
(EFIAPI *EFI_RESERVED_SERVICE) (
                               ^

Add VOID to make it into a real prototype.

Reviewed by:	imp, emaste, tsoome
Differential Revision:	https://reviews.freebsd.org/D9132
2017-01-25 19:55:35 +00:00
Dimitry Andric f653ed5e4f MFC r311929:
Don't include <errno.h> in reloc_elf.c, as it includes <stand.h> just
after it, which has a conflicting definition of errno.  This leads to
the following warning with clang 4.0.0:

    In file included from sys/boot/common/reloc_elf32.c:6:
    In file included from sys/boot/common/reloc_elf.c:37:
    /usr/obj/usr/src/tmp/usr/include/stand.h:155:12: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
    extern int errno;
               ^
    sys/sys/errno.h:46:26: note: expanded from macro 'errno'
    #define errno           (* __error())
                                      ^
2017-01-25 19:16:24 +00:00
Dimitry Andric dd70cdaffe MFC r311933:
Use proper prototypes in struct boot_module_t

With clang 4.0.0, we are getting the following warnings about struct
boot_module_t in efi's boot_module.h:

In file included from sys/boot/efi/boot1/ufs_module.c:41:
sys/boot/efi/boot1/boot_module.h:67:14: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
        void (*init)();
                    ^
                     void
sys/boot/efi/boot1/boot_module.h:92:16: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
        void (*status)();
                      ^
                       void
sys/boot/efi/boot1/boot_module.h:95:24: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
        dev_info_t *(*devices)();
                              ^
                               void
3 errors generated.

Fix this by adding 'void' to the parameter lists.  No functional change.

Reviewed by:	emaste, imp, smh
Differential Revision:	https://reviews.freebsd.org/D9144
2017-01-25 18:31:51 +00:00
Luiz Otavio O Souza c175029aa1 MFC r308458, r311157 and r312347:
Add the DTS for the Netgate SG-1000 (micro-Firewall).

Remove a GPL licensed DTS.

The micro-Firewall DTS is now a single BSD licensed file.

The write-protect is not wired on uFW, disable it to allow writes to SD
card.

Obtained from:	pfSense
Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-01-25 14:49:42 +00:00
Ed Maste f8547eedc9 Add WITH_REPRODUCIBLE_BUILD src.conf(5) knob
MFC r310128: Add WITH_REPRODUCIBLE_BUILD src.conf(5) knob to disable kernel
  metadata

The kernel builds reproducibly, except for the time, date, user, and
hostname baked into the kernel (reported at startup and via the
kern.version sysctl for uname).  Add a build knob to disable the
inclusion of this metadata.

MFC r310268: Build loaders reproducibly when WITH_REPRODUCIBLE_BUILD

When WITH_REPRODUCIBLE_BUILD=yes is set in src.conf(5), eliminate the
time, user, and host from the loader's version information.  This allows
builds to produce bit-for-bit identical output.
2017-01-25 01:04:51 +00:00
Jared McNeill 723091f5c7 MFC r310854, r310972
r310854:
Add missing reg property to usbphy node.

r310972:
Fix a typo in the third address of the reg property for the usbphy node.
2017-01-22 13:21:19 +00:00
Ed Maste 2b862983b0 MFC r310267: 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.

Sponsored by:	The FreeBSD Foundation
2017-01-20 21:10:37 +00:00
Alan Somers e589ff0026 MFC r310417
Add a dumpdev example to /boot/defaults/loader.conf
2017-01-19 16:07:52 +00:00
Oleksandr Tymoshenko 744086de57 MFC r311888, r311890-r311891
r311888:
[efi] Fix off-by-one error in ARM .bss zeroing code in loader's _start

__bss_end should not be included in .bss zeroing code. Otherwise first 4
bytes of the section that follows .bss (in loader's case it's .sdata) are
overwritten by zero.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D9108

r311890:
[efi] Fix .rel.data.* being erroneously merged into .data on ARM

Fix section pattern code to exclude .rel.data.* sections from being
merged into .data. Otherwise relocations in those sections are lost
in final binary

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D9108

r311891:
[efi] Build EFI bits with -fPIC on ARM

clang 3.9.0 without -fPIC generates absolute jump table for
switch/case statement which trips boot1.efi and loader.efi
on ARM platform.

Reviewed by:	andrew
Differential Revision:	https://reviews.freebsd.org/D9108
2017-01-17 19:19:29 +00:00
Ed Maste 5ebc601ec0 MFC r310225: 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
2017-01-17 01:29:03 +00:00
Ed Maste f9f5a25beb MFC r310702: btxldr: process all PT_LOAD segments, not just the first two
With default settings GNU ld generates two PT_LOADs for loader.sym while
LLD generates three, because it creates a rodata segment. Previously
btxldr terminated phdr processing after two PT_LOADs. Remove the early
termination to process all PT_LOADs.

Sponsored by:	The FreeBSD Foundation
2017-01-11 00:50:19 +00:00
Ed Maste 4c4eaf4c96 MFC r310661: loader: use strip -o instead of cp and strip in place
It is simpler and cleaner to have strip produce the stripped output
directly than copying the input to the output first.
2017-01-04 01:23:15 +00:00
Ed Maste 2303ecd8b7 MFC r306264: Use 32-bit value for .text padding, for linker portability
GNU ld interprets the padding value as a variable-length byte string,
while GNU gold and LLVM lld interpret it as a 32-bit value.
2016-12-30 16:23:13 +00:00
Ed Maste 0f5dd9a978 MFC r305854: Use arch-specific .text padding fill value in EFI loaders
The fill pattern was previously an ia64 instruction sequence. Presumably
ia64's linker script was copied as a starting point.
2016-12-30 16:19:19 +00:00