summaryrefslogtreecommitdiffstats
path: root/sys/boot/common
Commit message (Collapse)AuthorAgeFilesLines
...
* Refactor net_getparams() to make it easier to get params from sources otherian2015-05-182-28/+51
| | | | | | | | | | | | | | | | | than bootp and rarp. The code which splits a serverip:/rootpath string into rootip and a plain pathname is now a separate net_parse_rootpath() function that can be called by others. The code that sets the kernel env vars needed for nfs_diskless is moved into net_open() so that the variables get set no matter where the params came from. There was already code in net_open() that allowed for the possibility that some other entity has set up the network-related global variables. It uses the rootip variable as the key, assuming that if it is set all the other required variables are set too. These changes don't alter the existing behavior, they just make it easier to actually write some new code to get the params from another source (such as the U-Boot environment).
* An ARM kernel can be loaded at any 2MB boundary, make ubldr aware of that.ian2015-05-171-16/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, ubldr would use the virtual addresses in the elf headers by masking off the high bits and assuming the result was a physical address where the kernel should be loaded. That would sometimes discard significant bits of the physical address, but the effects of that were undone by archsw copy code that would find a large block of memory and apply an offset to the source/dest copy addresses. The result was that things were loaded at a different physical address than requested by the higher code layers, but that worked because other adjustments were applied later (such as when jumping to the entry point). Very confusing, and somewhat fragile. Now the archsw copy routines are just simple copies, and instead archsw.arch_loadaddr is implemented to choose a load address. The new routine uses some of the code from the old offset-translation routine to find the largest block of ram, but it excludes ubldr itself from that range, and also excludes If ubldr splits the largest block of ram in two, the kernel is loaded into the bottom of whichever resulting block is larger. As part of eliminating ubldr itself from the ram ranges, export the heap start/end addresses in a pair of new global variables. This change means that the virtual addresses in the arm kernel elf headers now have no meaning at all, except for the entry point address. There is an implicit assumption that the entry point is in the first text page, and that the address in the the header can be turned into an offset by masking it with PAGE_MASK. In the future we can link all arm kernels at a virtual address of 0xC0000000 with no need to use any low-order part of the address to influence where in ram the kernel gets loaded.
* The self-relocation code is not efi-specific, move it to boot/common.ian2015-05-101-0/+123
| | | | | | | | | | | | | | | | The function was defined as taking 4 parameters and returning EFI_STATUS, but all existing callers (in asm code) passed only two parameters and don't use the return value. The function signature now matches that usage, and doesn't refer to efi-specific types. Parameters and variables now use the cannonical typenames set up by elf.h (Elf_Word, Elf_Addr, etc) instead of raw C types. Hopefully this will prevent suprises as new platforms come along and use this code. The function was renamed from _reloc() to self_reloc() to emphasize its difference from the other elf relocation code found in boot/common. Differential Revision: https://reviews.freebsd.org/D2490
* Small change in header order to allow this to compile.scottl2015-04-271-1/+1
| | | | | Obtained from: Netflix, Inc. MFC after: 3 days
* Add support for arm64 to loader.efi and boot1.efiandrew2015-04-141-0/+2
| | | | | Reviewed by: emaste Sponsored by: The FreeBSD Foundation
* Make sure forth manpages are only installed once.bapt2015-04-041-10/+0
| | | | | Differential Revision: https://reviews.freebsd.org/D2224 Reviewed by: imp
* Add code to support loading relocatable kernels at offsets that are notnwhitehorn2015-01-311-5/+8
| | | | zero.
* Add support for booting relocatable kernels on PowerPC.nwhitehorn2015-01-311-19/+27
|
* loader: use correct types for parse_modmetadataroyger2015-01-171-4/+4
| | | | | | | | Use the proper types in parse_modmetadata for the p_start and p_end parameters. This was causing problems in the ARM 32bit loader. Sponsored by: Citrix Systems R&D Reported and Tested by: ian
* loader: implement multiboot support for Xen Dom0royger2015-01-154-66/+226
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement a subset of the multiboot specification in order to boot Xen and a FreeBSD Dom0 from the FreeBSD bootloader. This multiboot implementation is tailored to boot Xen and FreeBSD Dom0, and it will most surely fail to boot any other multiboot compilant kernel. In order to detect and boot the Xen microkernel, two new file formats are added to the bootloader, multiboot and multiboot_obj. Multiboot support must be tested before regular ELF support, since Xen is a multiboot kernel that also uses ELF. After a multiboot kernel is detected, all the other loaded kernels/modules are parsed by the multiboot_obj format. The layout of the loaded objects in memory is the following; first the Xen kernel is loaded as a 32bit ELF into memory (Xen will switch to long mode by itself), after that the FreeBSD kernel is loaded as a RAW file (Xen will parse and load it using it's internal ELF loader), and finally the metadata and the modules are loaded using the native FreeBSD way. After everything is loaded we jump into Xen's entry point using a small trampoline. The order of the multiboot modules passed to Xen is the following, the first module is the RAW FreeBSD kernel, and the second module is the metadata and the FreeBSD modules. Since Xen will relocate the memory position of the second multiboot module (the one that contains the metadata and native FreeBSD modules), we need to stash the original modulep address inside of the metadata itself in order to recalculate its position once booted. This also means the metadata must come before the loaded modules, so after loading the FreeBSD kernel a portion of memory is reserved in order to place the metadata before booting. In order to tell the loader to boot Xen and then the FreeBSD kernel the following has to be added to the /boot/loader.conf file: xen_cmdline="dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga" xen_kernel="/boot/xen" The first argument contains the command line that will be passed to the Xen kernel, while the second argument is the path to the Xen kernel itself. This can also be done manually from the loader command line, by for example typing the following set of commands: OK unload OK load /boot/xen dom0_mem=1024M dom0_max_vcpus=2 dom0pvh=1 console=com1,vga OK load kernel OK load zfs OK load if_tap OK load ... OK boot Sponsored by: Citrix Systems R&D Reviewed by: jhb Differential Revision: https://reviews.freebsd.org/D517 For the Forth bits: Submitted by: Julien Grall <julien.grall AT citrix.com>
* Reserve and ignore the a new module metadata type MDT_PNP_INFO forimp2015-01-151-0/+1
| | | | | | | | | | associating an optional PNP hint table with this module. In the future, when these are added, these changes will silently ignore the new type they would otherwise warn about. It will always be safe to ignore this data. Get this into the builds today for some future proofing. MFC After: 3 days
* mdoc: remove EOL whitespace.joel2014-12-291-1/+1
|
* Use the proper markup for single quotes.ian2014-12-271-2/+3
|
* Add a new loader(8) variable, twiddle_divisor, allowing control over theian2014-12-222-1/+36
| | | | | | | output frequency of the "twiddle" IO progress indicator. The default value is 1. For larger values N, the next stage of the animation is only output on every Nth call to the output routine. A sufficiently large N effectively disables the animation completely.
* The current limit of 100k for the linker hints file is getting a bitimp2014-11-291-1/+1
| | | | | | | | crowded as we now are at about 70k. Bump the limit to 1MB instead which is still quite a reasonable limit and allows for future growth of this file and possible future expansion to additional data. MFC After: 2 weeks
* Misc mdoc fixes:joel2014-11-231-3/+0
| | | | | | | | - Remove superfluous paragraph macros. - Remove/fix empty or incorrect macros. - Sort sections into conventional order. - Terminate quoted strings properly. - Remove EOL whitespace.
* Fix incorrect reading of 32-bit modinfo by 64-bit loaders.grehan2014-11-111-0/+22
| | | | | | | | | | | | | The various structures in the mod_metadata set of a FreeBSD kernel and modules contain pointers. The FreeBSD loader correctly deals with a mismatch in loader and kernel pointer size (e.g. 32-bit i386/ppc loader, loading 64-bit amd64/ppc64 kernels), but wasn't dealing with the inverse case where a 64-bit loader was loading a 32-bit kernel. Reported by: ktcallbox@gmail.com with a bhyve/i386 and ZFS root install Differential Revision: https://reviews.freebsd.org/D1129 Reviewed by: neel, jhb MFC after: 1 week
* In alloc_pread() and kern_pread(), print errors only when DEBUG ismarcel2014-11-051-0/+10
| | | | | | | defined. An error is not fatal and is supposed to be handled by the caller. Obtained from: Juniper Networks, Inc.
* Change the order of the arguments to file_loadraw(). They were swappedmarcel2014-11-011-1/+1
| | | | | | | as of r262345 when file_loadraw() was made public and this little detail got overlooked during porting. Obtained from: Juniper Networks, Inc.
* Fully support constructors for the purpose of code coverage analysis.marcel2014-10-201-4/+34
| | | | | | | | | | | | | | | | | This involves: 1. Have the loader pass the start and size of the .ctors section to the kernel in 2 new metadata elements. 2. Have the linker backends look for and record the start and size of the .ctors section in dynamically loaded modules. 3. Have the linker backends call the constructors as part of the final work of initializing preloaded or dynamically loaded modules. Note that LLVM appends the priority of the constructors to the name of the .ctors section. Not so when compiling with GCC. The code currently works for GCC and not for LLVM. Submitted by: Dmitry Mikulin <dmitrym@juniper.net> Obtained from: Juniper Networks, Inc.
* Fix comment.ae2014-10-081-3/+3
| | | | MFC after: 1 week
* Rework bootparttest to use more code from sys/boot.ae2014-10-051-2/+2
| | | | Use disk_open() call to emulate loader behavior.
* Add a bit more debug messages.ae2014-10-051-0/+5
|
* Add GUID of FreeBSD slice to GPT scheme.ae2014-10-031-0/+3
| | | | MFC after: 1 week
* add gptzfsboot.8, zfsboot.8 and zfsloader.8 manual pagesavg2014-09-152-0/+112
| | | | | | | Many thanks to Warren Block for his reviews, corrections and additions. Reviewed by: Warren Block <wblock@FreeBSD.org> MFC after: 1 week
* When built with FDT support, add /boot/dtb to the list of search directories.ian2014-09-031-0/+5
|
* Since the size of GPT entry may differ from the sizeof(struct gpt_ent),ae2014-08-251-4/+4
| | | | | | | use the size from GPT header to iterate entries. Suggested by: marcel@ MFC after: 1 week
* The size of the GPT table can not be less than one sector.ae2014-08-241-4/+5
| | | | | Reported by: rodrigc@ MFC after: 1 week
* Optionally include the install command as found on Juniper productsmarcel2014-08-062-0/+344
| | | | | | | | | | | | | | | like EX and SRX. The install command uses pkgfs to extract a kernel, zero or more modules and a root file system from the specified package and boots the kernel. The name of the kernel, the list of modules and the name of the root file system can be specified by putting a file called "metatags in the package. The package to use is given by an URL. The schemes supported are tftp and file. For the file scheme, the disk is currently hardcoded but that should really look for the package on all devices and partititions. Obtained from: Juniper Networks, Inc.
* Rename command_unload() to unload() and re-implement command_unload()marcel2014-08-062-6/+13
| | | | | | | in terms of unload() This allows unloading all files by the loader itself. Obtained from: Juniper Networks, Inc.
* In command_lsmod() prevent overrunning lbuf due to long pathmarcel2014-08-051-2/+4
| | | | | | names. Call pager_output() separately for the module name. Obtained from: Juniper Networks, Inc.
* In file_loadraw() print the name of the file as well as its sizemarcel2014-08-051-1/+6
| | | | | | so that we know what file is being loaded and how big the file is once complete. This has ELF modules and disk images emit the same output.
* Give loaders more control over the Forth initialization process. Inmarcel2014-07-273-14/+24
| | | | | | | | | | | | | | | | | | | 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.
* Remove ia64.marcel2014-07-071-2/+0
| | | | | | | | | | | | | | | | | 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
* Apparently some of the i386 boot blocks are so close to full that addingnwhitehorn2014-04-131-2/+0
| | | | | | single lines to ufsread.c spills them over. Duplicate a whole bunch of code to get file sizes into boot1.efi/boot1.c rather than modifying ufsread.c.
* Add a simple EFI stub loader. This is a quick and dirty of boot1.chrp fromnwhitehorn2014-04-131-0/+2
| | | | | | | | | | | | | the PowerPC port with all the Open Firmware bits removed and replaced by their EFI counterparts. On the whole, I think I prefer Open Firmware. This code is supposed to be an immutable shim that sits on the EFI system partition, loads /boot/loader.efi from UFS and tells the real loader what disk/partition to look at. It finds the UFS root partition by the somewhat braindead approach of picking the first UFS partition it can find. Better approaches are called for, but this works for now. This shim loader will also be useful for secure boot in the future, which will require some rearchitecture.
* When loader(8) inspects MBR, it chooses GPT as main partition table,ae2014-03-211-8/+5
| | | | | | | | | | | | when MBR contains only PMBR entry or it is bootcamp-compatible. If MBR has PMBR entry and some other, the loader rejects it. Make these checks to be less strict. If loader decided that PMBR isn't suitable for GPT, it will use MBR. Reported by: Paul Thornton Tested by: Paul Thornton MFC after: 1 week
* Build 64-bit ELF support into little-endian 64-bit MIPS boot-loaderrwatson2014-02-241-1/+1
| | | | | | | | fragments; while this won't actually be used for anything (yet), it doesn't hurt to ensure it is exposed to the tinderbox. Requested by: imp, jmallett MFC after: 3 weeks
* On mips64, built 64-bit ELF support.rwatson2014-02-231-0/+2
| | | | | MFC after: 3 weeks Sponsored by: DARPA, AFRL
* Change file_loadraw() from static to public. Change the order of itsian2014-02-222-10/+10
| | | | | | arguments from type,filename to filename,type to be consistant with other public file_whatever() functions, and change it to return a pointer to the preloaded_file struct describing the file. Adjust existing callers.
* Add support for FreeBSD/i386 guests under bhyve.jhb2014-02-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Similar to the hack for bootinfo32.c in userboot, define _MACHINE_ELF_WANT_32BIT in the load_elf32 file handlers in userboot. This allows userboot to load 32-bit kernels and modules. - Copy the SMAP generation code out of bootinfo64.c and into its own file so it can be shared with bootinfo32.c to pass an SMAP to the i386 kernel. - Use uint32_t instead of u_long when aligning module metadata in bootinfo32.c in userboot, as otherwise the metadata used 64-bit alignment which corrupted the layout. - Populate the basemem and extmem members of the bootinfo struct passed to 32-bit kernels. - Fix the 32-bit stack in userboot to start at the top of the stack instead of the bottom so that there is room to grow before the kernel switches to its own stack. - Push a fake return address onto the 32-bit stack in addition to the arguments normally passed to exec() in the loader. This return address is needed to convince recover_bootinfo() in the 32-bit locore code that it is being invoked from a "new" boot block. - Add a routine to libvmmapi to setup a 32-bit flat mode register state including a GDT and TSS that is able to start the i386 kernel and update bhyveload to use it when booting an i386 kernel. - Use the guest register state to determine the CPU's current instruction mode (32-bit vs 64-bit) and paging mode (flat, 32-bit, PAE, or long mode) in the instruction emulation code. Update the gla2gpa() routine used when fetching instructions to handle flat mode, 32-bit paging, and PAE paging in addition to long mode paging. Don't look for a REX prefix when the CPU is in 32-bit mode, and use the detected mode to enable the existing 32-bit mode code when decoding the mod r/m byte. Reviewed by: grehan, neel MFC after: 1 month
* Sweep man pages replacing ad -> ada.pluknet2013-10-011-2/+2
| | | | | | Approved by: re (blackend) MFC after: 1 week X-MFC note: stable/9 only
* Make the check for number of entries less strict.ae2013-08-081-6/+9
| | | | | | | Some partitioning tools can create GPT with number of entries less than 128. MFC after: 1 week
* Since we didn't break the loop, we should set i to -1 to start from theae2013-04-211-1/+2
| | | | | | | beginning. Submitted by: Steven Hartland MFC after: 1 week
* strncmp for boot code: fix an off by one erroravg2013-04-051-2/+2
| | | | | | | Before this change strncmp would access and _compare_ n+1 characters in the case where the first n characters match. MFC after: 5 days
* Attach the elf section headers to the loaded kernel as metadata, soian2013-03-101-0/+2
| | | | | | | | | | | they can easily be used by later post-processing. When searching for a compiled-in fdt blob, use the section headers to get the size and location of the .dynsym section to do a symbol search. This fixes a problem where the search could overshoot the symbol table and wander into the string table. Sometimes that was harmless and sometimes it lead to spurious panic messages about an offset bigger than the module size.
* Since ubldr doesn't necessarily load a kernel at the physical address in theian2013-03-091-5/+6
| | | | | | | | | | elf headers, mask out the high nibble of that address. This effectly makes the entry point the offset from the load address, and it gets adjusted for the actual load address before jumping to it. Masking the high nibble makes assumptions about memory layout that are true for all the arm platforms we support right now, but it makes me uneasy. This needs to be revisited.
* Fix a typo that prevented booting a kernel that had virtual addresses inian2013-02-271-1/+1
| | | | the elf headers.
* Adjust the arm kernel entry point address properly regardless of whether theian2013-02-261-6/+17
| | | | | e_entry field holds a physical or a virtual address. Add a comment block that explains the assumptions being made by the adjustment code.
* Fix the bug I introduced in r247045.kientzle2013-02-252-38/+0
| | | | | | | | | | | | | | | | After digging through more carefully, it looks like there's no real need to have the DTB in the module directory. So we can simplify a lot: Just copy DTB into local heap for "fdt addr" and U-Boot integration, drop all the extra COPYIN() calls. I've left one final COPYIN() to update the in-kernel DTB for consistency with how this code used to work, but I'm no longer convinced it's appropriate here. I've also remove the mem_load_raw() utility that I added to boot/common/module.c with r247045 since it's no longer necessary.
OpenPOWER on IntegriCloud