freebsd-dev/sys/amd64/include
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
..
pc - Add a new structure type for the ACPI 3.0 SMAP entry that includes the 2014-08-29 21:25:47 +00:00
xen xen: implement the privcmd user-space device 2014-10-22 17:07:20 +00:00
_align.h
_bus.h
_inttypes.h
_limits.h Copy amd64 _limits.h to x86 and merge with i386 _limits.h. Replace 2012-02-28 18:24:28 +00:00
_stdint.h Copy amd64 _stdint.h to x86 and merge with i386 _stdint.h. Replace 2012-02-28 18:38:33 +00:00
_types.h Copy amd64 _types.h to x86 and merge with i386 _types.h. Replace existing 2012-02-28 18:15:28 +00:00
acpica_machdep.h Merge acpica_machdep.h for amd64 and i386 and move to x86. In fact, these 2013-08-13 22:05:10 +00:00
apm_bios.h
asm.h Revert r274772: it is not valid on MIPS 2014-11-25 03:50:31 +00:00
asmacros.h Extend earlier addition of stack frames to most of support.S. This makes 2014-11-13 22:11:44 +00:00
atomic.h Remove empty lines before return statements for style consistency. 2013-08-21 22:05:58 +00:00
bus_dma.h
bus.h bhyve import part 2 of 2, guest kernel changes. 2011-05-14 18:37:24 +00:00
clock.h xen: implement an early timer for Xen PVH 2014-03-11 10:20:42 +00:00
counter.h Fix issues with zeroing and fetching the counters, on x86 and ppc64. 2013-07-01 02:48:27 +00:00
cpu.h amd64/i386: introduce APIC hooks for different APIC implementations. 2014-06-16 08:43:03 +00:00
cpufunc.h provide fast versions of ffsl and flsl for i386; ffsll and flsll for amd64 2014-02-14 15:18:37 +00:00
cputypes.h
db_machdep.h
dump.h Factor out duplicated code from dumpsys() on each architecture into generic 2015-01-07 01:01:39 +00:00
elf.h Convert machine/elf.h, machine/frame.h, machine/sigframe.h, 2013-02-20 17:39:52 +00:00
endian.h Copy amd64 endian.h to x86 and merge with i386 endian.h. Replace 2012-02-28 19:39:54 +00:00
exec.h
fdt.h Add basic support for FDT to i386 & amd64. This change includes: 2013-05-21 03:05:49 +00:00
float.h Copy amd64 float.h to x86 and merge with i386 float.h. Replace 2012-03-04 14:00:32 +00:00
floatingpoint.h
fpu.h Create a separate structure for per-CPU state saved across suspend and 2014-09-06 15:23:28 +00:00
frame.h Convert machine/elf.h, machine/frame.h, machine/sigframe.h, 2013-02-20 17:39:52 +00:00
gdb_machdep.h
ieeefp.h People porting FreeBSD to new architectures ought not have to 2011-10-21 06:41:46 +00:00
in_cksum.h MFp4 bz_ipv6_fast: 2012-05-24 22:00:48 +00:00
intr_machdep.h Add support for suspend/resume/migration operations when running as a 2013-09-20 05:06:03 +00:00
iodev.h
kdb.h
limits.h
md_var.h For x86, read MAXPHYADDR, defined in SDM vol 3 4.1.4 Enumeration of Paging 2015-01-12 07:36:25 +00:00
memdev.h Add reader/writer lock around mem_range_attr_get() and mem_range_attr_set(). 2011-01-17 22:58:28 +00:00
metadata.h loader: implement multiboot support for Xen Dom0 2015-01-15 16:27:20 +00:00
minidump.h
mp_watchdog.h
nexusvar.h
npx.h Move userland bits of i386 npx.h and amd64 fpu.h to x86 fpu.h. 2012-03-16 20:24:30 +00:00
ofw_machdep.h Add basic support for FDT to i386 & amd64. This change includes: 2013-05-21 03:05:49 +00:00
param.h Bump MAXCPU on amd64 from 64 to 256. In practice APIC only permits 255 2014-08-20 16:06:24 +00:00
pcb.h Create a separate structure for per-CPU state saved across suspend and 2014-09-06 15:23:28 +00:00
pci_cfgreg.h Move {amd64,i386}/pci/pci_bus.c and {amd64,i386}/include/pci_cfgreg.h to 2011-06-22 21:04:13 +00:00
pcpu.h Formalize the concept of virtual CPU ids by adding a per-cpu vcpu_id 2013-10-05 23:11:01 +00:00
pmap.h amd64: make uiomove_fromphys functional for pages not mapped by the DMAP 2014-10-24 09:48:58 +00:00
pmc_mdep.h Add software PMC support. 2012-03-28 20:58:30 +00:00
ppireg.h
proc.h Handle spurious page faults that may occur in no-fault sections of the 2012-03-22 04:52:51 +00:00
profile.h
psl.h Copy i386 psl.h to x86 and replace amd64/i386/pc98 psl.h with stubs. 2012-03-19 21:29:57 +00:00
ptrace.h Copy amd64 ptrace.h to x86 and merge with i386 ptrace.h. Replace 2012-03-04 20:24:28 +00:00
reg.h Copy i386 reg.h to x86 and merge with amd64 reg.h. Replace i386/amd64/pc98 2012-03-18 19:06:38 +00:00
reloc.h
resource.h Add support for managing PCI bus numbers. As with BARs and PCI-PCI bridge 2014-02-12 04:30:37 +00:00
runq.h
segments.h Hide struct pcb definition by #ifdef __amd64__ braces. If cc -m32 2013-11-26 19:38:42 +00:00
setjmp.h Copy amd64 setjmp.h to x86 and replace amd64/i386/pc98 setjmp.h with stubs. 2012-02-28 22:17:52 +00:00
sf_buf.h Merge all MD sf_buf allocators into one MI, residing in kern/subr_sfbuf.c 2014-08-05 09:44:10 +00:00
sigframe.h Convert machine/elf.h, machine/frame.h, machine/sigframe.h, 2013-02-20 17:39:52 +00:00
signal.h Convert machine/elf.h, machine/frame.h, machine/sigframe.h, 2013-02-20 17:39:52 +00:00
smp.h xen: add a hook to perform AP startup 2014-03-11 10:27:57 +00:00
specialreg.h Copy i386 specialreg.h to x86 and merge with amd64 specialreg.h. Replace 2012-03-19 21:34:11 +00:00
stack.h
stdarg.h Copy amd64 stdarg.h to x86 and replace amd64/i386/pc98 stdarg.h with stubs. 2012-02-28 22:30:58 +00:00
sysarch.h Copy amd64 sysarch.h to x86 and merge with i386 sysarch.h. Replace 2012-03-19 21:57:31 +00:00
timerreg.h
trap.h Copy amd64 trap.h to x86 and replace amd64/i386/pc98 trap.h with stubs. 2012-03-04 14:12:57 +00:00
tss.h
ucontext.h Convert machine/elf.h, machine/frame.h, machine/sigframe.h, 2013-02-20 17:39:52 +00:00
varargs.h
vdso.h Implement mechanism to export some kernel timekeeping data to 2012-06-22 07:06:40 +00:00
vm.h - Rename VM_MEMATTR_UNCACHED to VM_MEMATTR_WEAK_UNCACHEABLE on x86 to 2012-03-29 16:51:22 +00:00
vmm_dev.h 'struct vm_exception' was intended to be used only as the collateral for the 2015-01-13 22:00:47 +00:00
vmm_instruction_emul.h AMD processors that have the SVM decode assist capability will store the 2014-09-13 22:16:40 +00:00
vmm.h 'struct vm_exception' was intended to be used only as the collateral for the 2015-01-13 22:00:47 +00:00
vmparam.h Revert r276600: PHYS_TO_DMAP_RAW() and DMAP_TO_PHYS_RAW() are no 2015-01-12 07:50:55 +00:00