freebsd-nq/sys
Roger Pau Monné ca49b3342d loader: implement multiboot support for Xen Dom0
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>
2015-01-15 16:27:20 +00:00
..
amd64 loader: implement multiboot support for Xen Dom0 2015-01-15 16:27:20 +00:00
arm Fix cpsw(4) after r277203 which folded 'struct m_hdr' into 'struct mbuf'. 2015-01-15 02:22:52 +00:00
boot loader: implement multiboot support for Xen Dom0 2015-01-15 16:27:20 +00:00
bsm
cam Explain a bit of tricky code dealing with trims and how it prevents 2015-01-13 00:20:35 +00:00
cddl Fix overflow bug from r248577, turning 30s TRIM timeout into ~4s. 2015-01-14 16:22:00 +00:00
compat fcntl F_O{GET,SET}LK take pointer as the arg, handle them properly for 2015-01-15 10:43:58 +00:00
conf Add Altivec/VMX register support to ptrace. 2015-01-14 07:01:21 +00:00
contrib In order to reduce use of M_EXT outside of the mbuf allocator and 2015-01-06 12:59:37 +00:00
crypto Add some new modes to OpenCrypto. These modes are AES-ICM (can be used 2014-12-12 19:56:36 +00:00
ddb ddb: ANSI-fy function declarations. 2014-10-12 18:01:52 +00:00
dev Sound: fix typos in user visible messages etc. 2015-01-15 16:09:35 +00:00
fs Avoid race with "dev_rel()" when using the recently added 2015-01-14 22:07:13 +00:00
gdb Add support for gdb's memory searching capabilities to our in-kernel gdb 2014-09-05 16:40:47 +00:00
geom Add devd(8) notifications for creation and destruction of GEOM devices. 2015-01-14 11:15:57 +00:00
gnu reiserfs: Use signed i_nlink 2014-09-25 19:10:32 +00:00
i386 loader: implement multiboot support for Xen Dom0 2015-01-15 16:27:20 +00:00
isa
kern Major callout subsystem cleanup and rewrite: 2015-01-15 15:32:30 +00:00
kgssapi Avoid dynamic syscall overhead for statically compiled modules. 2014-10-26 19:42:44 +00:00
libkern Add some new modes to OpenCrypto. These modes are AES-ICM (can be used 2014-12-12 19:56:36 +00:00
mips Move MALTA_COMMON to std.MALTA (as we have for XLP and SWARM). 2015-01-07 12:12:36 +00:00
modules On x86 force NEW_PCIB, since that's the default. While this option 2015-01-14 05:41:28 +00:00
net Restore Ethernet-within-IP Encapsulation support that was broken after 2015-01-10 08:28:50 +00:00
net80211 Switch around the order of static inline to be in line with how it's 2015-01-11 18:43:45 +00:00
netgraph When the node receives NGM_FLOW_COOKIE update the if_link_state, instead 2015-01-12 09:50:42 +00:00
netinet Do not go one layer down to check ifqueue length. First, not all drivers 2015-01-12 18:06:22 +00:00
netinet6 Do not go one layer down to check ifqueue length. First, not all drivers 2015-01-12 14:52:43 +00:00
netipsec In order to reduce use of M_EXT outside of the mbuf allocator and 2015-01-06 12:59:37 +00:00
netnatm
netpfil Do not initialize pfi_unlnkdkifs_mtx and pf_frag_mtx. 2015-01-08 17:49:07 +00:00
netsmb
nfs Remove the old NFS client and server from head, 2014-12-23 00:47:46 +00:00
nfsclient Remove the old NFS client and server from head, 2014-12-23 00:47:46 +00:00
nfsserver Use M_SIZE() instead of hand-crafted (and mostly correct) NFSMSIZ() macro 2015-01-07 17:22:56 +00:00
nlm Avoid dynamic syscall overhead for statically compiled modules. 2014-10-26 19:42:44 +00:00
ofed Major callout subsystem cleanup and rewrite: 2015-01-15 15:32:30 +00:00
opencrypto Add some new modes to OpenCrypto. These modes are AES-ICM (can be used 2014-12-12 19:56:36 +00:00
pc98 Factor out duplicated code from dumpsys() on each architecture into generic 2015-01-07 01:01:39 +00:00
powerpc Add Altivec/VMX register support to ptrace. 2015-01-14 07:01:21 +00:00
rpc Add facility to stop all userspace processes. The supposed use of the 2014-12-13 16:18:29 +00:00
security Adjust printf format specifiers for dev_t and ino_t in kernel. 2014-12-17 07:27:19 +00:00
sparc64 Factor out duplicated code from dumpsys() on each architecture into generic 2015-01-07 01:01:39 +00:00
sys Major callout subsystem cleanup and rewrite: 2015-01-15 15:32:30 +00:00
teken mdoc: improvements to SEE ALSO. 2014-12-27 07:07:37 +00:00
tools Allow the make_dtb script to work outside of a "make buildkernel" context 2014-08-30 22:39:15 +00:00
ufs Handle MAKEENTRY cnp flag in the VOP_CREATE(). Curiously, some 2014-12-21 13:29:33 +00:00
vm Revert r263475: TDP_DEVMEMIO no longer needed, since amd64 /dev/kmem 2015-01-12 08:58:07 +00:00
x86 loader: implement multiboot support for Xen Dom0 2015-01-15 16:27:20 +00:00
xdr
xen Pacify clang 3.3 by ending the file with a newline. This is common 2015-01-06 21:26:35 +00:00
Makefile Remove "pci" from CSCOPEDIRS. 2014-09-23 06:32:19 +00:00