aboutsummaryrefslogtreecommitdiff
path: root/sys/boot/common
Commit message (Collapse)AuthorAgeFilesLines
* Move sys/boot to stand. Fix all references to new locationWarner Losh2017-11-1440-10756/+0
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=325834
* loader ptblread() is broken with >512B sectorsToomas Soome2017-10-311-0/+6
| | | | | | | | | | | The loader strategy() function is assuming 512B blocks, so we need to adjust ptblread() for other sector sizes. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D12847 Notes: svn path=/head/; revision=325248
* loader: initialize dv_cleanup in md.c to eliminate clang warningEd Maste2017-10-171-1/+2
| | | | | | | | Submitted by: Zakary Nafziger <worldofzak@gmail.com> Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=324700
* Move common/Makefile.inc to sys/boot/loader.mk.Warner Losh2017-10-161-83/+0
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=324649
* Rename top level Makefile.ficl to ficl.mk.Warner Losh2017-10-161-1/+1
| | | | Notes: svn path=/head/; revision=324648
* Move orphaned man pages into new man directory from common. This helpsWarner Losh2017-10-163-1217/+0
| | | | | | | | | | keep cleaer that common is just for the MI files for /boot/loader programs. Sponsored by: Netflix Notes: svn path=/head/; revision=324647
* Move panic back into libsa. It's documented in libstand(3) to belongWarner Losh2017-10-122-60/+1
| | | | | | | | | there. Sponsored by: Netflix Notes: svn path=/head/; revision=324559
* Move ufsread.cWarner Losh2017-10-121-326/+0
| | | | | | | | | | | Move ufsread.c from sys/boot/common (which used to be all the common files for /boot/loader, but grew to be all the common files for sys/boot, but that's now sys/boot/libsa's job) to sys/boot/libsa. Sponsored by: Netflix Notes: svn path=/head/; revision=324556
* Move crc32.c, util.c and gpt.c over to libsa.Warner Losh2017-10-127-777/+2
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=324554
* Rather than laying whack-a-mole with including the path to stand.h,Warner Losh2017-10-101-1/+0
| | | | | | | | | | 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 Notes: svn path=/head/; revision=324460
* Define SASRC and use itWarner Losh2017-10-091-1/+1
| | | | | | | | | | | | 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 Notes: svn path=/head/; revision=324450
* It's been pointed out that init_script at least is useful w/oWarner Losh2017-09-091-6/+2
| | | | | | | | re-rooting. Remove deprecation notice for it. init_chroot likely is still better served with reroot. Notes: svn path=/head/; revision=323379
* Mark init_chroot and init_script variables as deprecated.Warner Losh2017-09-091-0/+14
| | | | Notes: svn path=/head/; revision=323367
* Fix BSD label partition end sector calculation.Oleg Bulyzhin2017-08-171-1/+1
| | | | | | | | | Reviewed by: ae MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D12066 Notes: svn path=/head/; revision=322628
* Small cleanup in dev_net.cToomas Soome2017-05-281-3/+2
| | | | | | | | | | The variable servip is unused. One leftover printf and small cstyle nit. Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10980 Notes: svn path=/head/; revision=319084
* Update the comments concerning net_parse_rootpath to reflect what it is nowBaptiste Daroussin2017-05-271-2/+14
| | | | | | | | | | | really doing Reported by: rgrimes Reviewed by: rgrimes Differential Revision: https://reviews.freebsd.org/D10959 Notes: svn path=/head/; revision=318999
* Partially revert r314948Baptiste Daroussin2017-05-271-21/+2
| | | | | | | | | | | | | | | | While it sounds like a good idea to extract the RFC1048 data from PXE, in the end it is not and it is causing lots of issues. Our pxeloader might need options which are incompatible with other pxe servers (for example iPXE, but not only). Our pxe loaders are also now settings their own user class, so it is useful to issue our own pxe request at startup Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D10953 Notes: svn path=/head/; revision=318990
* Always issue the pxe requestBaptiste Daroussin2017-05-271-1/+1
| | | | | | | | | | | | | | | | | All the code are now only issueing one single dhcp request at startup of the loader meaning we can always request a the PXE informations from the dhcp server. Previous code lost that information, meaning no option 55 anymore (meaning not working with the kea dhcp server) and no request for rootpath etc, no user class Remove the flags from the bootp function which is not needed anymore Reviewed by: tsoome Differential Revision: https://reviews.freebsd.org/D10952 Notes: svn path=/head/; revision=318989
* Support URI scheme for root-path in netbootingBaptiste Daroussin2017-05-271-10/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Rather that previous attempts to add tftpfs support at the same time as NFS support. This time decide on a proper URI parser rather than hacks. root-path can now be define the following way: For tftpfs: tftp://ip/path tftp:/path (this one will consider the tftp server is the same as the one where the pxeboot file was fetched from) For nfs: nfs:/path nfs://ip/path The historical ip:/path /path are kept on NFS Reviewed by: tsoom, rgrimes Differential Revision: https://reviews.freebsd.org/D10947 Notes: svn path=/head/; revision=318987
* Replacing iterating over rootpath by strsep(3).Mariusz Zaborski2017-05-221-8/+6
| | | | | | | | | | | Submitted by: kczekirda Reviewed by: tsoome, bapt, jhb, oshogbo MFC after: 3 weeks Sponsored by: Oktawave Differential Revision: https://reviews.freebsd.org/D10726 Notes: svn path=/head/; revision=318678
* loader: network read reworkToomas Soome2017-05-061-4/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current read from network is working from up to down - we have some protocol needing the data from the network, so we build the buffer space for that protocol, add the extra space for headers and pass this buffer down to be filled by nif get call in hope, we have guessed the incoming packet size right. Amazingly enough this approach mostly does work, but not always... So, this update does work from down to up - we allocate buffer (based on MTU or frame size info), fill it up, and pass on for upper layers. The obvious problem is that when we should free the buffer - if at all. In the current implementation the upper layer will free the packet on error or when the packet is no longer needed. While working on the issue, the additional issue did pop up - the bios implementation does not have generic get/put interface but is using pxe udpsend/udpreceive instead. So the udp calls are gone and undi interface is implemented instead. Which in turn means slight other changes as we do not need to have duplicated pxe implementation and can just use dev_net. To align packet content, the actual read from nic is using shifted buffer by ETHER_ALIGN (2). Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D10232 Notes: svn path=/head/; revision=317887
* distinguish NFS versus TFTP boot by rootpathBaptiste Daroussin2017-05-061-8/+4
| | | | | | | | | | | | | | | | | Don't use DHCP 150 option to decide which protocol use to netboot. When root-path includes ip address - go thru NFS, if ip address not exists in root-path - go thru TFTP from server which ip address is in next-server. But there is one limitation - only one tftp server in network to provide loader and everything else. Does enybody use more than only one? Submitted by: kczekirda Sponsored by: Oktawave MFC after: 3 weeks Relnote: Yes Differential Revision: https://reviews.freebsd.org/D8740 Notes: svn path=/head/; revision=317886
* loader: F_READ/F_WRITE should be checked against masked flagToomas Soome2017-04-181-1/+1
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=317097
* loader: Avoid possible overflow via environment variableConrad Meyer2017-04-131-1/+1
| | | | | | | | | Reported by: Coverity (CWE-120) CID: 1006704 Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316771
* loader/multiboot: fix multiboot loadingRoger Pau Monné2017-04-132-0/+17
| | | | | | | | | | | | | | | | | | | | The current multiboot loader code doesn't clean the metadata added to the kernel after the bi_load64 dry run, which breaks accounting of the required memory for the metadata. This issue didn't show itself before because all the metadata items where small (8bytes), but after r316343 there's a big blob in the metadata, which triggers this. Fix it by cleaning the metadata added to the kernel after the bi_load64 dry run. Also add a comment describing the memory layout when booting using multiboot (Xen Dom0). This unbreaks booting a FreeBSD/Xen Dom0 after r316343. MFC after: 3 weeks Sponsored by: Citrix Systems R&D Notes: svn path=/head/; revision=316754
* loader: want mechanism to avoid RA with bcacheToomas Soome2017-04-062-4/+15
| | | | | | | | | | | | | | | | | While we have mechanisms in place to protect ourselves against the read behind the disk end, there is still one corner case. As the GPT partition table has backup table at the end of the disk, and we yet do not know the size of the disk (if the wrong size is provided by the firmware/bios), we need to limit the reads to avoid read ahead in such case. Note: this update does add constant into stand.h, so the incremental build will need to get local stand.h updated first. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D10187 Notes: svn path=/head/; revision=316578
* loader: part.c cstyle cleanupToomas Soome2017-04-061-22/+22
| | | | | | | | | | | | The description tells it all, as an side note, I am using uint8_t instead of u_char as the partition table data really is handled as byte stream, not char array. Reviewed by: allanjude, imp Differential Revision: https://reviews.freebsd.org/D10180 Notes: svn path=/head/; revision=316577
* loader: ls command should display file types properlyToomas Soome2017-03-281-18/+43
| | | | | | | | | | | With some file system the ls is unable to display file types. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D10066 Notes: svn path=/head/; revision=316112
* Remove -Wunused-but-set variable, `tail` in `ls_getdir(..)`Enji Cooper2017-03-281-2/+1
| | | | | | | | | | | This variable has been unused since its inception in r40106. MFC after: 3 days Reported by: amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316108
* Wrap bootcamp DEBUG statement with curly bracesEnji Cooper2017-03-281-1/+2
| | | | | | | | | | | | This fixes a -Wempty-body warning with gcc 6.3.0 when PART_DEBUG is undefined. MFC after: 3 days Reported by: Jenkins (FreeBSD-head-amd64-gcc job) Tested with: amd64-gcc-6.3.0 (devel/amd64-xtoolchain-gcc) Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316102
* sys/boot/common: Make geli(4) support optional in MI sourcesEnji Cooper2017-03-282-0/+5
| | | | | | | | | | | This saves a negligible amount of memory for non-geli enabled bootloaders. MFC after: 1 week Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=316076
* loader: verify the value from dhcp.interface-mtu and use snprintf to set mtuToomas Soome2017-03-201-1/+1
| | | | | | | | | | | | | | | Since the uset can set dhcp.interface-mtu, we need to try to validate the value. So we verify if the conversion to int is successful and we will not allow to set value greater than max IPv4 packet size. Also use snprintf for safety. Reviewed by: allanjude, bapt Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8492 Notes: svn path=/head/; revision=315653
* loader: remove open_disk cacheToomas Soome2017-03-162-190/+46
| | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=315408
* ufsread: Use appropriate UFS_MAXNAMLEN constantConrad Meyer2017-03-071-2/+2
| | | | | | | | | | A follow-up to r313475. Submitted by: Gaurav Gangalwar <Gaurav.Gangalwar at emc.com> Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314882
* sys: Replace zero with NULL for pointers.Pedro F. Giffuni2017-02-221-1/+1
| | | | | | | | | Found with: devel/coccinelle MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D9694 Notes: svn path=/head/; revision=314068
* prefix UFS symbols with UFS_ to reduce namespace pollutionEd Maste2017-02-151-5/+5
| | | | | | | | | | | | | | | | | | | | | Specifically: ROOTINO -> UFS_ROOTINO WINO -> UFS_WINO NXADDR -> UFS_NXADDR NDADDR -> UFS_NDADDR NIADDR -> UFS_NIADDR MAXSYMLINKLEN_UFS[12] -> UFS[12]_MAXSYMLINKLEN (for consistency) Also prefix ext2's and nandfs's NDADDR and NIADDR with EXT2_ and NANDFS_ Reviewed by: kib, mckusick Obtained from: NetBSD MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D9536 Notes: svn path=/head/; revision=313780
* loader: possible NULL pointer dereference in bcache.cToomas Soome2017-02-081-6/+5
| | | | | | | | | | | | | | Coverity detected the possible NULL pointer dereference case. Also updated comment as was suggested in illumos review. CID: 1371008 Reported by: Coverity Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D9496 Notes: svn path=/head/; revision=313451
* loader: bcache read ahead block count should take account the large sectorsToomas Soome2017-02-062-9/+51
| | | | | | | | | | | | | | | | | | | | | | | | | | | The loader bcache is implementing simple read-ahead to boost the cache. The bcache is built based on 512B block sizes, and the read ahead is attempting to read number of cache blocks, based on amount of the free bcache space. However, there are devices using larger sector sizes than 512B, most obviously the CD media is based on 2k sectors. This means the read-ahead can not be just random number of blocks, but we should use value suitable also for use with larger sectors, as for example, with CD devices, we should read multiple of 2KB. Since the sector size from disk interface is not too reliable, i guess we can just use "good enough" value, so the implementation is rounding down the read ahead block count to be multiple of 16. This means we have covered sector sizes to 8k. In addition, the update does implement the end of cache marker, to help to detect the possible memory corruption - I have not seen it happening so far, but it does not hurt to have the detection mechanism in place. Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D9179 Notes: svn path=/head/; revision=313332
* loader: Implement disk_ioctl() to support DIOCGSECTORSIZE and DIOCGMEDIASIZE.Toomas Soome2017-02-063-6/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Need interface to extract information about disk abstraction, to read disk or partition size depending on the provided argument and adjust disk size based on information in partition table. The disk handle from disk_open() has d_offset field to point to partition start. So we can use this fact to return either whole disk size or partition size. For this we only need to record partition size we get from disk_open() anyhow. In addition, this will also make it possible to adjust the disk media size based on information from partition table. The problem with disk size is about some BIOS systems reporting bogus disk size for 2+TB disks, but since such disks are using GPT partitioning, and GPT does have information about disk size (alternate LBA + 1), we can use this fact to record disk size based on partition table. This patch does exactly this: implements DIOCGSECTORSIZE and DIOCGMEDIASIZE ioctl, and DIOCGMEDIASIZE will report either disk media size or partition size. Adds ptable_getsize() call to read partition size in bytes from ptable pointer. Updates disk_open() to use ptable_getsize() to update mediasize value. Implements GPT detection function to update ptable size (used by ptable_getsize()) according to alternate lba (which is location of backup copy of GPT header table). Reviewed by: allanjude Approved by: allanjude (mentor) Differential Revision: https://reviews.freebsd.org/D8594 Notes: svn path=/head/; revision=313328
* loader: disk/part api needs to use uint64_t offsetsToomas Soome2017-02-014-14/+14
| | | | | | | | | | | | | | | | | | | | The disk_* and part_* api is using 64bit values for media size and offsets. However, the current api is using off_t type, which is signed 64-bit int. In this context the signed media size does not make any sense, and the offsets are used to mark absolute, not relative locations. Also, the data from GPT partition table and some other sources is already using uint64_t data type, so using signed off_t can cause sign issues. Reviewed by: imp Approved by: imp (mentor) Differential Revision: https://reviews.freebsd.org/D8710 Notes: svn path=/head/; revision=313047
* Remove pc98 support completely.Yoshihiro Takahashi2017-01-282-8/+0
| | | | | | | | | I thank all developers and contributors for pc98. Relnotes: yes Notes: svn path=/head/; revision=312910
* Don't include <errno.h> in reloc_elf.c, as it includes <stand.h> justDimitry Andric2017-01-111-1/+0
| | | | | | | | | | | | | | | | | | | 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()) ^ MFC after: 3 days Notes: svn path=/head/; revision=311929
* dosfs support in libstand is broken since r298230Toomas Soome2016-12-304-40/+26
| | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=310850
* Build loaders reproducibly when WITH_REPRODUCIBLE_BUILDEd Maste2016-12-192-2/+21
| | | | | | | | | | | | | | | 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. Reviewed by: bapt MFC after: 1 month Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8842 Notes: svn path=/head/; revision=310268
* Deduplicate loader vers.c Makefile rulesEd Maste2016-12-191-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. Reviewed by: bapt MFC after: 1 month Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8841 Notes: svn path=/head/; revision=310267
* Renumber license clauses to avoid skipping #3Ed Maste2016-12-181-1/+1
| | | | Notes: svn path=/head/; revision=310236
* Reduce boot loader version string duplicationEd Maste2016-12-182-7/+4
| | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=310225
* EFI loaders: parse rela relocations on amd64Ed Maste2016-12-011-12/+5
| | | | | | | | | | | | | | | | | | | | 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. Reported by: George Rimar Reviewed by: andrew MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D8681 Notes: svn path=/head/; revision=309360
* lsdev device name section headers should be printed by dv_print callback.Toomas Soome2016-11-193-8/+18
| | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=308827
* Add support for LOADER_RC setting in the pkgfs manifest (defaults toStephen J. Kiernan2016-11-111-1/+17
| | | | | | | | | | | | | | | | | /loader.rc) to specify a Forth file to read from the pkgfs tarball and process by Ficl. This allows for the tarball to do runtime things like load a platform-specific FDT blob, among other things. Reviewed by: imp Approved by: sjg (mentor) MFC after: 2 weeks Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D8494 Notes: svn path=/head/; revision=308535