summaryrefslogtreecommitdiffstats
path: root/sys/boot/common
Commit message (Collapse)AuthorAgeFilesLines
* MFC r322628: Fix BSD label partition end sector calculation.oleg2017-09-151-1/+1
| | | | | | Differential Revision: https://reviews.freebsd.org/D12066 (cherry picked from commit 831e4a7f7244fd9dfed84aa248312cb5f109c6da)
* MFC r316754: loader/multiboot: fix multiboot loadingroyger2017-05-092-0/+17
| | | | Sponsored by: Citrix Systems R&D
* MFC r316108:ngie2017-03-311-2/+1
| | | | | | Remove -Wunused-but-set variable, `tail` in `ls_getdir(..)` This variable has been unused since its inception in r40106.
* MFC r313982, r314068:pfg2017-03-141-1/+1
| | | | | | sys: Replace zero with NULL for pointers. Found with: devel/coccinelle
* MFC r309369,310850,310853:tsoome2017-02-064-40/+26
| | | | | | | | | | 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)
* MFC r311929:dim2017-01-251-1/+0
| | | | | | | | | | | | | | | 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()) ^
* Add WITH_REPRODUCIBLE_BUILD src.conf(5) knobemaste2017-01-252-2/+21
| | | | | | | | | | | | | | | | 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.
* MFC r310267: Deduplicate loader vers.c Makefile rulesemaste2017-01-201-0/+5
| | | | | | | | 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
* MFC r310225: Reduce boot loader version string duplicationemaste2017-01-172-7/+4
| | | | | Instead of repeating "%s, Revision %s" "(%s %s)" in each loader, just create the full version string in vers.c
* Fix EFI self relocation code for rela architecturesemaste2016-12-281-10/+9
| | | | | | | | | | | | | | | | | | | | | | MFC r306812 (andrew): The bootloader self relocation code was slightly wrong for the R_AARCH64_RELATIVE relocation found on arm64. It would try to add the contents of the memory location being relocated to the base address and the relocation addend. This worked when the contents was zero, however this now seems to be set to the value of the addend so we add this twice. Fix this by just setting the memory to the computed value. MFC r309360: EFI loaders: parse rela relocations on amd64 Prior to this change the loader self relocation code interpreted amd64's rela relocations as if they were rel relocations, discarding the addend. This "works" because GNU ld 2.17.50 stores the addend value in both the r_addend field of the relocation (as expected) and at the target of the relocation. Other linkers, and possibly other versions of GNU ld, won't have this behaviour, so interpret the relocations correctly.
* MFC r307238:bapt2016-11-161-17/+0
| | | | | | | | | | | | | | | | | | | | | | | Stop closing the network device when netbooting for loaders using the common dev_net.c code. The NETIF_OPEN_CLOSE_ONCE flag was added in r201932 to prevent that behaviour on some architectures (sparc64 and powerpc64) the default was left to always open and close the device for each open and close of a file by the loader because it was necessary for u-boot on arm. Since it has been added, the flag was turned on for every arches including the u-boot loader for arm. This also fixes netbooting on RPi3 (tested by gonzo@) For the loader.efi it greatly speeds up netbooting Reviewed by: emaste, gonzo, tsoome Approved by: gonzo MFC after: 1 month Sponsored by: Gandi.net Differential Revision: https://reviews.freebsd.org/D8230
* MFC: 304677, 304680, 305125, 305770, 305769bapt2016-10-191-2/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | r304677: Add tftpfs support for the EFI loader Allow netbooting on efi without having to setup any NFS server by rebuilding the loader with LOADER_TFTP_SUPPORT like for the i386 pxeloader r305125: Netboot: allow both tftpfs and nfs in both pxeboot and loader.efi Add a new 'netproto' variable which can be set for now to NET_TFTP or NET_NFS (default to NET_NONE) From the dhcp options if one sets the root-path option to: "ip:path", the loader will consider it is booting over NFS (meaning same behaviour as the default current behaviour) if the dhcp option "tftp server address" is set (option 150) the loader will consider it is booting over tftpfs, it will then consider the root-path options with 2 possible case 1. "path" then the IP of the tftp server will be the one passed by the option 150, and the files will be retrieved under "path" on the tftp server 2. "ip:path" then the IP of the tftp server will be the one passed in the option "overwritting the IP from the option 150. We could not "abuse" the rootpath option in the form or tftp://ip:path because this is already used for other purpose by iPXE preventing any chainload from iPXE to the FreeBSD loader. Given at each open(), the loader loops over all available filesystems and keep the "best" error, we needed to prevent tftpfs to fallback on nfs and vice versa. the tftpfs and nfs implementation in libstand now return EINVAL early if 'netproto' for that purpose. Relnotes: yes Sponsored by: Gandi.net
* Fix typo.imp2016-05-181-1/+1
| | | | Spotted by: Matteo Riondato
* Also add comment about the bug I comments in the forth.imp2016-05-181-0/+8
|
* Fix several instances where the boot loader ignored pager_outputimp2016-05-186-17/+30
| | | | | | | return value when it could return 1 (indicating we should stop). Fix a few instances of pager_open() / pager_close() not being called. Actually use these routines for the environment variable printing code I just committed.
* It sure would be nice to use printf with wide strings. Implement %S toimp2016-05-172-0/+6
| | | | | | | do that. The C_WIDEOUT flag indicates that the console supports it. Mark the EFI console as supporting this. MFC After: 3 days
* sys/boot/common: use of spaces vs. TAB.pfg2016-05-124-51/+51
| | | | No functional change.
* bcache read ahead may attempt to read past end of diskallanjude2016-05-011-8/+39
| | | | | | | | | | The new bcache code does not know the size of the disk, and therefore may attempt to read past the end of the disk while trying to fill its read-ahead cache. This is usually not an issue, it fails gracefully on all of my machines, but some BIOSes seem to retry the reads for up to 30 seconds each, resulting in a long stall during boot Submitted by: Toomas Soome <tsoome@me.com> Reviewed by: jhb, np Differential Revision: https://reviews.freebsd.org/D6109
* sys/boot: make use of the howmany() macro when available.pfg2016-04-261-5/+6
| | | | | We have a howmany() macro in the <sys/param.h> header that is convenient to re-use as it makes things easier to read.
* sys: use our roundup2/rounddown2() macros when param.h is available.pfg2016-04-211-1/+1
| | | | | | | | | | rounddown2 tends to produce longer lines than the original code and when the code has a high indentation level it was not really advantageous to do the replacement. This tries to strike a balance between readability using the macros and flexibility of having the expressions, so not everything is converted.
* sys/boot: use our nitems() macro when it is available through param.h.pfg2016-04-191-1/+1
| | | | | | No functional change, only trivial cases are done in this sweep, Discussed in: freebsd-current
* A new implementation of the loader block cacheallanjude2016-04-185-209/+283
| | | | | | | | | | | | | | | | | 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
* Cleanup unnecessary semicolons from the kernel.pfg2016-04-101-1/+1
| | | | Found with devel/coccinelle.
* Use the ABI-prescribed name for SHT_X86_64_UNWIND in the loader andkib2016-04-081-1/+1
| | | | | | kernel linker, after the r297686. Sponsored by: The FreeBSD Foundation
* If the dhcp server provided an interface-mtu option, transcribe the valueian2016-03-211-0/+6
| | | | | | | | to the boot.netif.mtu env var, which will be picked up by pre-existing code in nfs_mountroot() and used to configure the interface accordingly. This should bring the same functionality when the bootp/dhcp work is done by loader(8) as r297150 does for the in-kernel BOOTP case.
* Implement GELI (AES-XTS and AES-CBC only) in gptboot and gptzfsbootallanjude2016-03-164-3/+4
| | | | | | | | | Allows booting from a GELI encrypted root file system, via UFS or ZFS Reviewed by: gnn, smh (previous version), delphij (previous version) Relnotes: yes Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D4593
* Since kernel modules can now contain sections of type SHT_AMD64_UNWIND,dim2016-03-061-0/+3
| | | | | | | | | | | | | the boot loader should not skip over these anymore while loading images. Otherwise the kernel can still panic when it doesn't find the .eh_frame section belonging to the .rela.eh_frame section. Unfortunately this will require installing boot loaders from sys/boot before attempting to boot with a new kernel. Reviewed by: kib MFC after: 2 weeks X-MFC-With: r296419
* Fix ubldr build failure on mipsn32 and mipsn32el targets.sgalabov2016-03-041-1/+1
| | | | Approved by: adrian (mentor)
* Fix build failure introduced by r296182sgalabov2016-02-291-1/+0
| | | | Approved by: adrian (mentor)
* These changes attempt to put things in order before the introduction of MIPSsgalabov2016-02-292-2/+3
| | | | | | | | | | | | | | | ubldr. The changes are mostly dealing with removing unnecessary casts from the U-Boot API (we're passing only pointers, no obvious reason to cast them to uint32_t), cleaning up some compiler warnings and using the proper printf format specifiers in order to be able to compile cleanly for both 32-bit and 64-bit MIPS targets. Reviewed by: imp Approved by: adrian (mentor) Sponsored by: Smartcom - Bulgaria AD Differential Revision: https://reviews.freebsd.org/D5312
* Don't set the offset when loading the kernel on the arm loader.efi. Theandrew2016-02-091-1/+6
| | | | | | | | copyin and copyout code handle virtual addresses such that they will take a virtual address and convert it into a valid physical address. It may also mean we fail to boot as the elf files load address could be 0. Sponsored by: ABT Systems Ltd
* Fix EFI platform build failuressmh2016-02-061-1/+1
| | | | | | | | | | | With warnings now enabled some plaforms where failing due to warnings. * Fix st_size printed as a size_t when its actually an off_t. * Fix pointer conversion in load_elf for some 32bit platforms due to 64bit off in ef. MFC after: 2 days X-MFC-With: Sponsored by: Multiplay
* Fix mistake when transitioning to the new defines with ZFS loader. Iimp2016-01-271-1/+1
| | | | | | | | hate adding yet another define, but it is the lessor of the evil choices available. Kill another evil by removing PATH_BOOT3 and replacing it with PATH_LOADER or PATH_LOADER_ZFS as appropriate. PR: 206659
* RBX_ defines are in rbx.h, move it there.imp2016-01-261-0/+61
| | | | Differential Revision: https://reviews.freebsd.org/D5038
* Move all the separate copies of the same strings into paths.h. There'simp2016-01-261-0/+39
| | | | | | nothing machine specific about these. Differential Revision: https://reviews.freebsd.org/D5038
* Prevent loader.conf load failure due to unknown console entriessmh2016-01-211-27/+66
| | | | | | | | | | | | | | | | | | | | | | | | | | | When processing loader.conf if console contained an entry for an unsupported console then cons_set would return an error refusing to set any console. This has two side effects: 1. Forth would throw a syntax error and stop processing loader.conf at that point. 2. The value of console is ignored. #1 Means other important loader.conf entries may not be processed, which is clearly undesirable. #2 Means the users preference for console aren't applied even if they did contain valid options. Now we have support for multi boot paths from a single image e.g. bios and efi mode the console preference needs to deal with the need to set preference for more than one source. Fix this by: * Returning CMD_OK where possible from cons_set. * Allowing set with at least one valid console to proceed. Reviewed by: allanjude MFC after: 1 week Sponsored by: Multiplay Differential Revision: https://reviews.freebsd.org/D5018
* Fix EFI UFS cachingsmh2016-01-211-7/+23
| | | | | | | | | | | | | | | | | | | EFI was mixing caching in two separate places causing issues when multiple partitions where tested. Eliminate this by removing fsstat and re-factoring fsread into fsread_size, adding basic parameter validation. Also: * Enhance some error print outs. * Fix compilation under UFS1_ONLY and UFS2_ONLY * Use sizeof on vars instead of structs. * Add basic parameter validation to fsread_size. MFC after: 1 week X-MFC-With: r293268 Sponsored by: Multiplay Differential Revision: https://reviews.freebsd.org/D4989
* Ensure boot fsread correctly probes all partitionssmh2016-01-151-1/+8
| | | | | | | | | | | | | | The boot code fsread was caching the result of meta data request and reusing it even for calls with inode = 0, which is used to partitions trigger a probe. The result was that success was incorrectly returned for all partition probes after the first valid success, even for partitions which are not UFS. MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay
* Make common boot file_loadraw name parameter constsmh2016-01-152-8/+7
| | | | | | | | | | Fix compiler warnings about dropping const qualifier by changing file_loadraw name param to const, and updating method to make that the case (it was abusing the variable). MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay
* Improve non-interactive forth cmd error reportingsmh2016-01-133-11/+37
| | | | | | | | | | | | | | | | | | | Non-interactive forth command errors where silent even for critical issues e.g. failing to load a required kernel module or mfs_root. This resulted in later unexplained and hard to trace errors such as mount root failures. This introduces additional command return codes that are treated appropriately by the non-interactive command processor (bf_command). * CMD_CRIT = print error * CMD_FATAL = panic Also fix minor style(9) issues with command_load return codes. MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay
* Enable warnings in EFI boot codesmh2016-01-127-22/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | Set WARNS if not set for EFI boot code and fix the issues highlighted by setting it. Most components are set to WARNS level 6 with few being left at lower levels due to the amount of changes needed to fix at higher levels. Error types fixed: * Missing / invalid casts * Missing inner structs * Unused vars * Missing static for internal only funcs * Missing prototypes * Alignment changes * Use of uninitialised vars * Unknown pragma (intrinsic) * Missing types etc due to missing includes * printf formatting types Reviewed by: emaste (in part) MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay Differential Revision: https://reviews.freebsd.org/D4839
* Remove hidden "Not ufs" printfs from boot codesmh2016-01-091-1/+0
| | | | | | | | | Remove the printf("Not ufs\n") from the boot code which was hidden by the local printf implementations, allowing these to have that code removed too. MFC after: 2 weeks X-MFC-With: r293268 Sponsored by: Multiplay
* Make detection of GPT a bit more reliable.ae2015-12-101-1/+6
| | | | | | | | | | When we are detecting a partition table and didn't find PMBR, try to read backup GPT header from the last sector and if it is correct, assume that we have GPT. Reviewed by: rpokala MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D4282
* META MODE: Update dependencies with 'the-lot' and add missing directories.bdrewery2015-12-011-0/+11
| | | | | | | | | | | | | | 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
* Implement simple ops for umass_diskzbb2015-11-272-0/+46
| | | | | | | | | | | | The initial IOCTL implementation supports reading disk physical geometry. Two additional functions were added. They allow reading/writing raw data to the disk (default partition). Submitted by: Wojciech Macek <wma@semihalf.com> Obtained from: Semihalf Sponsored by: Juniper Networks Inc. Differential Revision: https://reviews.freebsd.org/D4143
* Document loader(8) dumpdev optionsmh2015-11-181-1/+9
| | | | | | | Add an entry for dumpdev environment variable to loader(8). MFC after: 1 week Sponsored by: Multiplay
* Make vers.c creation atomic by using a temporary file, then movingngie2015-10-241-4/+8
| | | | | | | | | | | | | | | | the temporary file to vers.c at the end of the script The previous logic wrote out to vers.c multiple times, so the file could be incorrectly interpreted as being completely written out after one of the echo calls with recursive make, when in reality it was only partially written. Also, in the event the build was interrupted when creating vers.c (small race window), it would have a leftover file that needed to be cleaned up before resuming the build. MFC after: 3 weeks Sponsored by: EMC / Isilon Storage Division
* Fix a problem which made loader(8) load non-kld files twice.trasz2015-08-031-0/+8
| | | | | | | | | | | | | | | For example, without this patch, the following three lines in /boot/loader.conf would result in /boot/root.img being preloaded twice, and two md(4) devices - md0 and md1 - being created. initmd_load="YES" initmd_type="md_image" initmd_name="/boot/root.img" Reviewed by: marcel@ MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3204
* Document md_root in loader(8). The md(4) manual page mentions it,trasz2015-07-251-3/+9
| | | | | | | | | but it's hard to find and easy to miss. Reviewed by: wblock@ MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D3183
* Install loader(8) and zfsloader(8) only oncebapt2015-06-192-5/+10
| | | | | Differential Revision: https://reviews.freebsd.org/D2841 Reviewed by: imp
OpenPOWER on IntegriCloud