summaryrefslogtreecommitdiff
path: root/usr.sbin/bhyveload
Commit message (Collapse)AuthorAgeFilesLines
* bhyveload(8): Implement loader_callbacks::diskwriteConrad Meyer2020-10-071-2/+18
| | | | | | | | | | | | | | | The method was optional prior to r365938, which made it mandatory but did add any test that an implementation provides the method nor implement it for bhyveload. The code path might not be hit unless the user's loader was configured to write to a file on disk, such as with nextboot(8). Reviewed by: grehan, tsoome Approved by: bhyve X-MFC-With: r365938 Differential Revision: https://reviews.freebsd.org/D26710 Notes: svn path=/head/; revision=366521
* Fix pkgfs stat so it satisfies libsecurebootSimon J. Gerraty2020-03-251-5/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We need a valid st_dev, st_ino and st_mtime to correctly track which files have been verified and to update our notion of time. ve_utc_set(): ignore utc if it would jump our current time by more than VE_UTC_MAX_JUMP (20 years). Allow testing of install command via userboot. Need to fix its stat implementation too. bhyveload also needs stat fixed - due to change to userboot.h Call ve_error_get() from vectx_close() when hash is wrong. Track the names of files we have hashed into pcr For the purposes of measured boot, it is important to be able to reproduce the hash reflected in loader.ve.pcr so loader.ve.hashed provides a list of names in the order they were added. Reviewed by: imp MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org//D24027 Notes: svn path=/head/; revision=359307
* usr.sbin/bhyveload: don't leak an fd if a device can't be openedSean Chittenden2019-07-121-8/+6
| | | | | | | | | Coverity CID: 1194167 Approved by: markj, jhb Differential Revision: https://reviews.freebsd.org/D20935 Notes: svn path=/head/; revision=349949
* userboot: handle guest interpreter mismatches more intelligentlyKyle Evans2018-09-011-9/+50
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The switch to lualoader creates a problem with userboot: the host is inclined to build userboot with Lua, but the host userboot's interpreter must match what's available on the guest. For almost all FreeBSD guests in the wild, Lua is not yet available and a Lua-based userboot will fail. This revision updates userboot protocol to version 5, which adds a swap_interpreter callback to request a different interpreter, and tries to determine the proper interpreter to be used based on how the guest /boot/loader is compiled. This is still a bit of a guess, but it's likely the best possible guess we can make in order to get it right. The interpreter is now embedded in the resulting executable, so we can open /boot/loader on the guest and hunt that down to derive the interpreter it was built with. Using -l with bhyveload will not allow an intepreter swap, even if the loader specified happens to be a userboot with the wrong interpreter. We'll simply complain about the mismatch and bail out. For legacy guests without the interpreter marker, we assume they're 4th. For new guests with the interpreter marker, we'll read it and swap over to the proper interpreter if it doesn't match what the userboot we're using was compiled with. Both flavors of userboot are installed by default, userboot_4th.so and userboot_lua.so. This fixes the build WITHOUT_FORTH as a coincidence, which was broken by userboot being forced to 4th. Reviewed by: imp, jhb, araujo (earlier version) Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D16945 Notes: svn path=/head/; revision=338418
* style(9) remove unnecessary blank tabs.Marcelo Araujo2018-06-131-1/+1
| | | | | | | | | Obtained from: TrueOS MFC after: 4 weeks. Sponsored by: iXsystems Inc. Notes: svn path=/head/; revision=335026
* De-const to match changes in userboot.hWarner Losh2017-12-061-2/+2
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=326615
* Make putenv and getenv match the userland definition of theseWarner Losh2017-12-061-1/+1
| | | | | | | | | | functions, tweak man page and one variable that shouldn't be const anymore. Sponsored by: Netflix Notes: svn path=/head/; revision=326609
* various: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326276
* Move sys/boot to stand. Fix all references to new locationWarner Losh2017-11-141-1/+1
| | | | | | | Sponsored by: Netflix Notes: svn path=/head/; revision=325834
* DIRDEPS_BUILD: Update dependencies.Bryan Drewery2017-10-311-1/+0
| | | | | | | Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=325188
* bhyveload: correctly query size of disksAndriy Gapon2017-06-211-3/+5
| | | | | | | | | | | | | | On FreeBSD fstat(2) works fine for querying sizes of plain files, but not so much for character devices. So, use DIOCGMEDIASIZE to try to get the correct size for disks and disk-like devices (e.g. zvols). PR: 220186 Reviewed by: tsoome, grehan MFC after: 1 week Notes: svn path=/head/; revision=320195
* usr.sbin: normalize paths using SRCTOP-relative paths or :H when possibleEnji Cooper2017-03-041-1/+1
| | | | | | | | | | This simplifies make logic/output MFC after: 1 month Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=314659
* bhyve: improve memory size documentationRoman Bogorodskiy2016-06-262-13/+8
| | | | | | | | | | | | | | | | | | | A couple of minor memory size option related nits: - use common name 'memsize' (instead of 'max-size' or just 'size') - bhyve: update usage with memsize unit suffix, drop legacy "MB" unit - bhyveload: update usage with memsize unit suffix - bhyve(8): document default size - bhyveload(8): use memsize formatting like it's done in bhyve(8) Reviewed by: wblock, grehan Approved by: re (kib), wblock, grehan Differential Revision: https://reviews.freebsd.org/D6952 Notes: svn path=/head/; revision=302211
* MFHGlen Barber2016-04-061-2/+1
|\ | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=297605
| * bhyveload: fix from loading undefined size.Pedro F. Giffuni2016-04-061-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | We were setting an incorrect/undefined size and as it came out the st struct was not really being used at all. This was actually a bug but by sheer luck it had no visual effect. CID: 1194320 Reviewed by: grehan Notes: svn path=/head/; revision=297599
* | MFHGlen Barber2016-03-022-3/+32
|\| | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=296318
| * Add option -C to have the guest memory included in core files.Marcel Moolenaar2016-02-262-2/+12
| | | | | | | | | | | | | | This aids in debugging OS loaders. Notes: svn path=/head/; revision=296102
| * Support version 4 of the userboot structure by implementing theMarcel Moolenaar2016-02-261-1/+20
| | | | | | | | | | | | | | vm_set_register() and vm_set_desc() callbacks. Notes: svn path=/head/; revision=296101
* | MFH r289384-r293170Glen Barber2016-01-041-0/+20
|\| | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=293172
| * META MODE: Update dependencies with 'the-lot' and add missing directories.Bryan Drewery2015-12-011-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=291563
* | Merge from headBaptiste Daroussin2015-10-092-11/+45
|\| | | | | | | Notes: svn path=/projects/release-pkg/; revision=289092
| * Add option -l for specifying which OS loader to dlopen(3). By defaultMarcel Moolenaar2015-10-082-11/+45
| | | | | | | | | | | | | | | | this is /boot/userboot.so. This option allows for the development and use of other OS loaders. Notes: svn path=/head/; revision=289001
* | Merge from headBaptiste Daroussin2015-09-121-1/+1
|\| | | | | | | Notes: svn path=/projects/release-pkg/; revision=287708
| * Fix issues detected by 'mandoc -Tlint bhyveload.8'Neel Natu2015-06-271-1/+1
| | | | | | | | | | | | | | | | Pointed out by: wblock Differential Revision: https://reviews.freebsd.org/D2762 Notes: svn path=/head/; revision=284892
* | Merge from head @274131Baptiste Daroussin2015-06-202-4/+12
|\| | | | | | | Notes: svn path=/projects/release-pkg/; revision=284621
| * Restructure memory allocation in bhyve to support "devmem".Neel Natu2015-06-182-4/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | devmem is used to represent MMIO devices like the boot ROM or a VESA framebuffer where doing a trap-and-emulate for every access is impractical. devmem is a hybrid of system memory (sysmem) and emulated device models. devmem is mapped in the guest address space via nested page tables similar to sysmem. However the address range where devmem is mapped may be changed by the guest at runtime (e.g. by reprogramming a PCI BAR). Also devmem is usually mapped RO or RW as compared to RWX mappings for sysmem. Each devmem segment is named (e.g. "bootrom") and this name is used to create a device node for the devmem segment (e.g. /dev/vmm/testvm.bootrom). The device node supports mmap(2) and this decouples the host mapping of devmem from its mapping in the guest address space (which can change). Reviewed by: tychon Discussed with: grehan Differential Revision: https://reviews.freebsd.org/D2762 MFC after: 4 weeks Notes: svn path=/head/; revision=284539
* | MFH: r282615-r283655Glen Barber2015-05-281-1/+1
|\| | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/release-pkg/; revision=283656
| * Fix off-by-one in array index bounds checkAllan Jude2015-05-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | bhyveload would allow you to create 33 entries on an array that only has 32 slots Differential Revision: https://reviews.freebsd.org/D2569 Reviewed by: araujo Approved by: neel MFC after: 1 week Sponsored by: ScaleEngine Inc. Notes: svn path=/head/; revision=283075
* | Merge from headBaptiste Daroussin2015-05-031-1/+1
|\| | | | | | | Notes: svn path=/projects/release-pkg/; revision=282368
| * Fix overlinking in bhyve:Baptiste Daroussin2015-04-091-1/+1
| | | | | | | | | | | | | | libvmmapi is actually needed to be linked to libutil, not bhyve nor bhyveload Notes: svn path=/head/; revision=281338
* | Make FreeBSD-bhyve an indivual packageBaptiste Daroussin2015-03-051-0/+1
|/ | | | Notes: svn path=/projects/release-pkg/; revision=279625
* Convert usr.sbin to LIBADDBaptiste Daroussin2014-11-251-2/+1
| | | | | | | Reduce overlinking Notes: svn path=/head/; revision=275054
* Sort command flags in usage output and the manpages.John Baldwin2014-06-272-31/+31
| | | | Notes: svn path=/head/; revision=267959
* Provide APIs to directly get 'lowmem' and 'highmem' size directly.Neel Natu2014-06-241-2/+2
| | | | | | | | | | | Previously the sizes were inferred indirectly based on the size of the mappings at 0 and 4GB respectively. This works fine as long as size of the allocation is identical to the size of the mapping in the guest's address space. However, if the mapping is disjoint then this assumption falls apart (e.g., due to the legacy BIOS hole between 640KB and 1MB). Notes: svn path=/head/; revision=267811
* use .Mt to mark up email addresses consistently (part2)Baptiste Daroussin2014-06-201-2/+2
| | | | | | | | PR: 191174 Submitted by: Franco Fichtner <franco@lastsummer.de> Notes: svn path=/head/; revision=267668
* Add ioctl(VM_REINIT) to reinitialize the virtual machine state maintainedNeel Natu2014-06-071-5/+16
| | | | | | | | | | by vmm.ko. This allows the virtual machine to be restarted without having to destroy it first. Reviewed by: grehan Notes: svn path=/head/; revision=267216
* ZFS boot support for bhyveload.Peter Grehan2014-02-221-13/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Modelled after the i386 zfsloader. However, with no 2nd stage zfsboot to search for a bootable dataset, attempt a ZFS boot if there is more than one ZFS dataset found during the disk probe. sys/boot/userboot/zfs - build the ZFS boot library sys/boot/userboot/userboot/ conf.c - Add the ZFS pool and filesystem tables devicename.c - correctly format ZFS devices main.c - increase the size of the libstand malloc pool to account for the increased usage from ZFS buffers - probe for a ZFS dataset, and if one is found, attempt to boot from it. usr.sbin/bhyveload/bhyveload.c - allow multiple invocations of the '-d' option to specify multiple disks e.g. a raidz set. Up to 32 disks are supported. Tested with various combinations of GPT, MBR, single and multiple disks, RAID-Z, mirrors. Reviewed by: neel Discussed with: avg Tested by: Michael Dexter and others MFC after: 3 weeks Notes: svn path=/head/; revision=262331
* Add support for FreeBSD/i386 guests under bhyve.John Baldwin2014-02-051-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - 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 Notes: svn path=/head/; revision=261504
* o Fix typo, sort .Xrs.Maxim Konovalov2014-01-281-3/+3
| | | | | | | | | PR: docs/186191 Submitted by: Andrew (typo fix) MFC after: 1 week Notes: svn path=/head/; revision=261229
* mdoc: quote string properly.Joel Dahl2013-12-021-1/+1
| | | | Notes: svn path=/head/; revision=258855
* Don't create an initial value for the host filesystem of "/".Peter Grehan2013-11-271-1/+1
| | | | | | | | | | This has the unintended effect of booting the host kernel if a disk image open fails. Discussed with: neel Notes: svn path=/head/; revision=258673
* Allow bhyve and bhyveload to attach to tty devices.Peter Grehan2013-11-272-10/+77
| | | | | | | | | | | | | | | | | | | | bhyveload: introduce the -c <device> parameter to select a tty for output (or "stdio") bhyve: allow the puc and lpc-com backends to accept a tty in addition to "stdio" When used in conjunction with the null-modem device, nmdm(4), this allows attach/detach to the guest console and multiple concurrent serial ports. kgdb on a serial port is now functional. Reviewed by: neel Requested by: Almost everyone that has used bhyve MFC after: 10.0 Notes: svn path=/head/; revision=258668
* Tidy usage messages for bhyve and bhyveload.Neel Natu2013-10-231-3/+5
| | | | | | | Submitted by: jhb Notes: svn path=/head/; revision=257018
* Add an option to bhyveload(8) that allows setting a loader environment variableNeel Natu2013-10-172-16/+48
| | | | | | | | | | | | | from the command line. The option syntax is "-e <name=value>". It may be used multiple times to set multiple environment variables. Reviewed by: grehan Requested by: alfred Notes: svn path=/head/; revision=256657
* Fix missing .Joel Dahl2013-10-091-1/+1
| | | | | | | Approved by: re (blanket) Notes: svn path=/head/; revision=256237
* Parse the memory size parameter using expand_number() to allow specifyingNeel Natu2013-10-093-9/+28
| | | | | | | | | | | the memory size more intuitively (e.g. 512M, 4G etc). Submitted by: rodrigc Reviewed by: grehan Approved by: re (blanket) Notes: svn path=/head/; revision=256176
* Merge projects/bhyve_npt_pmap into head.Neel Natu2013-10-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make the amd64/pmap code aware of nested page table mappings used by bhyve guests. This allows bhyve to associate each guest with its own vmspace and deal with nested page faults in the context of that vmspace. This also enables features like accessed/dirty bit tracking, swapping to disk and transparent superpage promotions of guest memory. Guest vmspace: Each bhyve guest has a unique vmspace to represent the physical memory allocated to the guest. Each memory segment allocated by the guest is mapped into the guest's address space via the 'vmspace->vm_map' and is backed by an object of type OBJT_DEFAULT. pmap types: The amd64/pmap now understands two types of pmaps: PT_X86 and PT_EPT. The PT_X86 pmap type is used by the vmspace associated with the host kernel as well as user processes executing on the host. The PT_EPT pmap is used by the vmspace associated with a bhyve guest. Page Table Entries: The EPT page table entries as mostly similar in functionality to regular page table entries although there are some differences in terms of what bits are used to express that functionality. For e.g. the dirty bit is represented by bit 9 in the nested PTE as opposed to bit 6 in the regular x86 PTE. Therefore the bitmask representing the dirty bit is now computed at runtime based on the type of the pmap. Thus PG_M that was previously a macro now becomes a local variable that is initialized at runtime using 'pmap_modified_bit(pmap)'. An additional wrinkle associated with EPT mappings is that older Intel processors don't have hardware support for tracking accessed/dirty bits in the PTE. This means that the amd64/pmap code needs to emulate these bits to provide proper accounting to the VM subsystem. This is achieved by using the following mapping for EPT entries that need emulation of A/D bits: Bit Position Interpreted By PG_V 52 software (accessed bit emulation handler) PG_RW 53 software (dirty bit emulation handler) PG_A 0 hardware (aka EPT_PG_RD) PG_M 1 hardware (aka EPT_PG_WR) The idea to use the mapping listed above for A/D bit emulation came from Alan Cox (alc@). The final difference with respect to x86 PTEs is that some EPT implementations do not support superpage mappings. This is recorded in the 'pm_flags' field of the pmap. TLB invalidation: The amd64/pmap code has a number of ways to do invalidation of mappings that may be cached in the TLB: single page, multiple pages in a range or the entire TLB. All of these funnel into a single EPT invalidation routine called 'pmap_invalidate_ept()'. This routine bumps up the EPT generation number and sends an IPI to the host cpus that are executing the guest's vcpus. On a subsequent entry into the guest it will detect that the EPT has changed and invalidate the mappings from the TLB. Guest memory access: Since the guest memory is no longer wired we need to hold the host physical page that backs the guest physical page before we can access it. The helper functions 'vm_gpa_hold()/vm_gpa_release()' are available for this purpose. PCI passthru: Guest's with PCI passthru devices will wire the entire guest physical address space. The MMIO BAR associated with the passthru device is backed by a vm_object of type OBJT_SG. An IOMMU domain is created only for guest's that have one or more PCI passthru devices attached to them. Limitations: There isn't a way to map a guest physical page without execute permissions. This is because the amd64/pmap code interprets the guest physical mappings as user mappings since they are numerically below VM_MAXUSER_ADDRESS. Since PG_U shares the same bit position as EPT_PG_EXECUTE all guest mappings become automatically executable. Thanks to Alan Cox and Konstantin Belousov for their rigorous code reviews as well as their support and encouragement. Thanks for John Baldwin for reviewing the use of OBJT_SG as the backing object for pci passthru mmio regions. Special thanks to Peter Holm for testing the patch on short notice. Approved by: re Discussed with: grehan Reviewed by: alc, kib Tested by: pho Notes: svn path=/head/; revision=256072
* mdoc: remove superfluous paragraph macro.Joel Dahl2013-03-191-1/+0
| | | | Notes: svn path=/head/; revision=248492
* Simplify the assignment of memory to virtual machines by requiring a singleNeel Natu2013-03-182-60/+29
| | | | | | | | | | | | | | | | | | | | | command line option "-m <memsize in MB>" to specify the memory size. Prior to this change the user needed to explicitly specify the amount of memory allocated below 4G (-m <lowmem>) and the amount above 4G (-M <highmem>). The "-M" option is no longer supported by 'bhyveload' and 'bhyve'. The start of the PCI hole is fixed at 3GB and cannot be directly changed using command line options. However it is still possible to change this in special circumstances via the 'vm_set_lowmem_limit()' API provided by libvmmapi. Submitted by: Dinakar Medavaram (initial version) Reviewed by: grehan Obtained from: NetApp Notes: svn path=/head/; revision=248477
* Remove EOL whitespace.Joel Dahl2013-01-191-2/+2
| | | | Notes: svn path=/head/; revision=245667