| 1 |
For x86, building xen.efi requires gcc 4.5.x or above (4.6.x or newer |
| 2 |
recommended, as 4.5.x was probably never really tested for this purpose) and |
| 3 |
binutils 2.22 or newer. Additionally, the binutils build must be configured to |
| 4 |
include support for the x86_64-pep emulation (i.e. |
| 5 |
`--enable-targets=x86_64-pep` or an option of equivalent effect should be |
| 6 |
passed to the configure script). |
| 7 |
|
| 8 |
For arm64, the PE/COFF header is open-coded in assembly, so no toolchain |
| 9 |
support for PE/COFF is required. Also, the PE/COFF header co-exists with the |
| 10 |
normal Image format, so a single binary may be booted as an Image file or as an |
| 11 |
EFI application. When booted as an EFI application, Xen requires a |
| 12 |
configuration file as described below unless a bootloader, such as GRUB, has |
| 13 |
loaded the modules and describes them in the device tree provided to Xen. If a |
| 14 |
bootloader provides a device tree containing modules then any configuration |
| 15 |
files are ignored, and the bootloader is responsible for populating all |
| 16 |
relevant device tree nodes. |
| 17 |
The property "xen,uefi-cfg-load" can be specified in the /chosen node to force |
| 18 |
Xen to load the configuration file even if multiboot modules are found. |
| 19 |
|
| 20 |
Once built, `make install-xen` will place the resulting binary directly into |
| 21 |
the EFI boot partition, provided `EFI_VENDOR` is set in the environment (and |
| 22 |
`EFI_MOUNTPOINT` is overridden as needed, should the default of `/boot/efi` not |
| 23 |
match your system). When built with debug info, the binary can be quite large. |
| 24 |
Setting `INSTALL_EFI_STRIP=1` in the environment will cause it to be stripped |
| 25 |
of debug info in the process of installing. `INSTALL_EFI_STRIP` can also be set |
| 26 |
to any combination of options suitable to pass to `strip`, in case the default |
| 27 |
ones don't do. The xen.efi binary will also be installed in `/usr/lib64/efi/`, |
| 28 |
unless `EFI_DIR` is set in the environment to override this default. This |
| 29 |
binary will not be stripped in the process. |
| 30 |
|
| 31 |
The binary itself will require a configuration file (names with the `.efi` |
| 32 |
extension of the binary's name replaced by `.cfg`, and - until an existing |
| 33 |
file is found - trailing name components dropped at `.`, `-`, and `_` |
| 34 |
separators will be tried) to be present in the same directory as the binary. |
| 35 |
(To illustrate the name handling, a binary named `xen-4.2-unstable.efi` would |
| 36 |
try `xen-4.2-unstable.cfg`, `xen-4.2.cfg`, `xen-4.cfg`, and `xen.cfg` in |
| 37 |
order.) One can override this with a command line option (`-cfg=<filename>`). |
| 38 |
This configuration file and EFI commandline are only used for booting directly |
| 39 |
from EFI firmware, or when using an EFI loader that does not support |
| 40 |
the multiboot2 protocol. When booting using GRUB or another multiboot aware |
| 41 |
loader the EFI commandline is ignored and all information is passed from |
| 42 |
the loader to Xen using the multiboot protocol. |
| 43 |
|
| 44 |
The configuration file consists of one or more sections headed by a section |
| 45 |
name enclosed in square brackets, with individual values specified in each |
| 46 |
section. A section named `[global]` is treated specially to allow certain |
| 47 |
settings to apply to all other sections (or to provide defaults for certain |
| 48 |
settings in case individual sections don't specify them). This file (for now) |
| 49 |
needs to be of ASCII type and not e.g. UTF-8 or UTF-16. A typical file would |
| 50 |
thus look like this (`#` serving as comment character): |
| 51 |
|
| 52 |
**************************example begin****************************** |
| 53 |
|
| 54 |
[global] |
| 55 |
default=sle11sp2 |
| 56 |
|
| 57 |
[sle11sp2] |
| 58 |
options=console=vga,com1 com1=57600 loglvl=all noreboot |
| 59 |
kernel=vmlinuz-3.0.31-0.4-xen [domain 0 command line options] |
| 60 |
ramdisk=initrd-3.0.31-0.4-xen |
| 61 |
|
| 62 |
**************************example end******************************** |
| 63 |
|
| 64 |
The individual values used here are: |
| 65 |
|
| 66 |
###`default=<name>` |
| 67 |
|
| 68 |
Specifies the section to use for booting, if none was specified on the command |
| 69 |
line; only meaningful in the `[global]` section. This isn't required; if |
| 70 |
absent, section headers will be ignored and for each value looked for the |
| 71 |
first instance within the file will be used. |
| 72 |
|
| 73 |
###`options=<text>` |
| 74 |
|
| 75 |
Specifies the options passed to the hypervisor, see [Xen Hypervisor Command |
| 76 |
Line Options](xen-command-line.html). |
| 77 |
|
| 78 |
###`kernel=<filename>[ <options>]` |
| 79 |
|
| 80 |
Specifies the Dom0 kernel binary and the options to pass to it. |
| 81 |
|
| 82 |
The options should in general be the same as is used when booting |
| 83 |
natively, e.g. including `root=...` etc. |
| 84 |
|
| 85 |
Check your bootloader (e.g. grub) configuration or `/proc/cmdline` for |
| 86 |
the native configuration. |
| 87 |
|
| 88 |
###`ramdisk=<filename>` |
| 89 |
|
| 90 |
Specifies a Linux-style initial RAM disk image to load. |
| 91 |
|
| 92 |
Other values to specify are: |
| 93 |
|
| 94 |
###`video=gfx-<xres>[x<yres>[x<depth>]]` |
| 95 |
|
| 96 |
Specifies a video mode to select if available. In case of problems, the |
| 97 |
`-basevideo` command line option can be used to skip altering video modes. |
| 98 |
|
| 99 |
###`xsm=<filename>` |
| 100 |
|
| 101 |
Specifies an XSM module to load. |
| 102 |
|
| 103 |
###`ucode=<filename>` |
| 104 |
|
| 105 |
Specifies a CPU microcode blob to load. (x86 only) |
| 106 |
|
| 107 |
###`dtb=<filename>` |
| 108 |
|
| 109 |
Specifies a device tree file to load. The platform firmware may provide a |
| 110 |
DTB in an EFI configuration table, so this field is optional in that |
| 111 |
case. A dtb specified in the configuration file will override a device tree |
| 112 |
provided in the EFI configuration table. (ARM only) |
| 113 |
|
| 114 |
###`chain=<filename>` |
| 115 |
|
| 116 |
Specifies an alternate configuration file to use in case the specified section |
| 117 |
(and in particular its `kernel=` setting) can't be found in the default (or |
| 118 |
specified) configuration file. This is only meaningful in the [global] section |
| 119 |
and really not meant to be used together with the `-cfg=` command line option. |
| 120 |
|
| 121 |
Filenames must be specified relative to the location of the EFI binary. |
| 122 |
|
| 123 |
Extra options to be passed to Xen can also be specified on the command line, |
| 124 |
following a `--` separator option. |
| 125 |
|
| 126 |
## Unified Xen kernel image |
| 127 |
|
| 128 |
The "Unified" kernel image can be generated by adding additional |
| 129 |
sections to the Xen EFI executable with objcopy, similar to how |
| 130 |
[systemd-boot uses the stub to add them to the Linux kernel](https://wiki.archlinux.org/index.php/systemd-boot#Preparing_a_unified_kernel_image) |
| 131 |
|
| 132 |
The sections for the xen configuration file, the dom0 kernel, dom0 initrd, |
| 133 |
XSM and CPU microcode should be added after the Xen `.pad` section, the |
| 134 |
ending address of which can be located with: |
| 135 |
|
| 136 |
``` |
| 137 |
objdump -h xen.efi \ |
| 138 |
| perl -ane '/\.pad/ && printf "0x%016x\n", hex($F[2]) + hex($F[3])' |
| 139 |
``` |
| 140 |
|
| 141 |
For all the examples the `.pad` section ended at 0xffff82d041000000. |
| 142 |
All the sections are optional (`.config`, `.kernel`, `.ramdisk`, `.xsm`, |
| 143 |
`.ucode` (x86) and `.dtb` (ARM)) and the order does not matter. |
| 144 |
The virtual addresses do not need to be contiguous, although they should not |
| 145 |
be overlapping and should all be greater than the last virtual address of the |
| 146 |
hypervisor components. |
| 147 |
|
| 148 |
``` |
| 149 |
objcopy \ |
| 150 |
--add-section .config=xen.cfg \ |
| 151 |
--change-section-vma .config=0xffff82d041000000 |
| 152 |
--add-section .ucode=ucode.bin \ |
| 153 |
--change-section-vma .ucode=0xffff82d041010000 \ |
| 154 |
--add-section .xsm=xsm.cfg \ |
| 155 |
--change-section-vma .xsm=0xffff82d041080000 \ |
| 156 |
--add-section .kernel=vmlinux \ |
| 157 |
--change-section-vma .kernel=0xffff82d041100000 \ |
| 158 |
--add-section .ramdisk=initrd.img \ |
| 159 |
--change-section-vma .ramdisk=0xffff82d042000000 \ |
| 160 |
xen.efi \ |
| 161 |
xen.unified.efi |
| 162 |
``` |
| 163 |
|
| 164 |
The unified executable can be signed with sbsigntool to make |
| 165 |
it usable with UEFI secure boot: |
| 166 |
|
| 167 |
``` |
| 168 |
sbsign \ |
| 169 |
--key signing.key \ |
| 170 |
--cert cert.pem \ |
| 171 |
--output xen.signed.efi \ |
| 172 |
xen.unified.efi |
| 173 |
``` |
| 174 |
## UEFI boot and Dom0 modules on ARM |
| 175 |
|
| 176 |
When booting using UEFI on ARM, it is possible to specify the Dom0 modules |
| 177 |
directly from the device tree without using the Xen configuration file, here an |
| 178 |
example: |
| 179 |
|
| 180 |
chosen { |
| 181 |
#size-cells = <0x1>; |
| 182 |
#address-cells = <0x1>; |
| 183 |
xen,xen-bootargs = "[Xen boot arguments]" |
| 184 |
|
| 185 |
module@1 { |
| 186 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 187 |
xen,uefi-binary = "vmlinuz-3.0.31-0.4-xen"; |
| 188 |
bootargs = "[domain 0 command line options]"; |
| 189 |
}; |
| 190 |
|
| 191 |
module@2 { |
| 192 |
compatible = "multiboot,ramdisk", "multiboot,module"; |
| 193 |
xen,uefi-binary = "initrd-3.0.31-0.4-xen"; |
| 194 |
}; |
| 195 |
} |
| 196 |
|
| 197 |
## UEFI boot and dom0less on ARM |
| 198 |
|
| 199 |
Dom0less feature is supported by ARM and it is possible to use it when Xen is |
| 200 |
started as an EFI application. |
| 201 |
The way to specify the domU domains is by Device Tree as specified in the |
| 202 |
[dom0less](dom0less.html) documentation page under the "Device Tree |
| 203 |
configuration" section, but instead of declaring the reg property in the boot |
| 204 |
module, the user must specify the "xen,uefi-binary" property containing the name |
| 205 |
of the binary file that has to be loaded in memory. |
| 206 |
The UEFI stub will load the binary in memory and it will add the reg property |
| 207 |
accordingly. |
| 208 |
|
| 209 |
An example here: |
| 210 |
|
| 211 |
domU1 { |
| 212 |
#address-cells = <1>; |
| 213 |
#size-cells = <1>; |
| 214 |
compatible = "xen,domain"; |
| 215 |
memory = <0 0x20000>; |
| 216 |
cpus = <1>; |
| 217 |
vpl011; |
| 218 |
|
| 219 |
module@1 { |
| 220 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 221 |
xen,uefi-binary = "vmlinuz-3.0.31-0.4-xen"; |
| 222 |
bootargs = "console=ttyAMA0"; |
| 223 |
}; |
| 224 |
module@2 { |
| 225 |
compatible = "multiboot,ramdisk", "multiboot,module"; |
| 226 |
xen,uefi-binary = "initrd-3.0.31-0.4-xen"; |
| 227 |
}; |
| 228 |
module@3 { |
| 229 |
compatible = "multiboot,device-tree", "multiboot,module"; |
| 230 |
xen,uefi-binary = "passthrough.dtb"; |
| 231 |
}; |
| 232 |
}; |
| 233 |
|
| 234 |
## How to boot different Xen setup using UEFI |
| 235 |
|
| 236 |
These are the different ways to boot a Xen system from UEFI: |
| 237 |
|
| 238 |
- Boot Xen and Dom0 (minimum required) |
| 239 |
- Boot Xen and DomU(s) (true dom0less, only on ARM) |
| 240 |
- Boot Xen, Dom0 and DomU(s) (only on ARM) |
| 241 |
|
| 242 |
### Boot Xen and Dom0 |
| 243 |
|
| 244 |
This configuration can be started using the Xen configuration file in the |
| 245 |
example above. |
| 246 |
|
| 247 |
### Boot Xen and DomU(s) |
| 248 |
|
| 249 |
This configuration needs the domU domain(s) specified in the /chosen node, |
| 250 |
examples of how to do that are provided by the documentation about dom0less |
| 251 |
and the example above shows how to use the "xen,uefi-binary" property to use the |
| 252 |
UEFI stub for module loading. |
| 253 |
When adding DomU modules to device tree, also add the property |
| 254 |
xen,uefi-cfg-load under chosen for Xen to load the Xen config file. |
| 255 |
Otherwise, Xen will skip the config file and rely on device tree alone. |
| 256 |
When using the Xen configuration file in conjunction with the device tree, you |
| 257 |
can specify the Xen boot arguments in the configuration file with the "options=" |
| 258 |
keyword or in the device tree with the "xen,xen-bootargs" property, but be |
| 259 |
aware that the Xen configuration file value has a precedence over the DT value. |
| 260 |
|
| 261 |
Example 1 of how to boot a true dom0less configuration: |
| 262 |
|
| 263 |
Xen configuration file: skipped. |
| 264 |
|
| 265 |
Device tree: |
| 266 |
|
| 267 |
``` |
| 268 |
chosen { |
| 269 |
#size-cells = <0x1>; |
| 270 |
#address-cells = <0x1>; |
| 271 |
xen,xen-bootargs = "<Xen command line>" |
| 272 |
|
| 273 |
domU1 { |
| 274 |
#size-cells = <0x1>; |
| 275 |
#address-cells = <0x1>; |
| 276 |
compatible = "xen,domain"; |
| 277 |
cpus = <0x1>; |
| 278 |
memory = <0x0 0xc0000>; |
| 279 |
vpl011; |
| 280 |
|
| 281 |
module@1 { |
| 282 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 283 |
xen,uefi-binary = "Image-domu1.bin"; |
| 284 |
bootargs = "console=ttyAMA0 root=/dev/ram0 rw"; |
| 285 |
}; |
| 286 |
}; |
| 287 |
domU2 { |
| 288 |
#size-cells = <0x1>; |
| 289 |
#address-cells = <0x1>; |
| 290 |
compatible = "xen,domain"; |
| 291 |
cpus = <0x1>; |
| 292 |
memory = <0x0 0x100000>; |
| 293 |
vpl011; |
| 294 |
|
| 295 |
module@2 { |
| 296 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 297 |
xen,uefi-binary = "Image-domu2.bin"; |
| 298 |
bootargs = "console=ttyAMA0 root=/dev/ram0 rw"; |
| 299 |
}; |
| 300 |
}; |
| 301 |
}; |
| 302 |
``` |
| 303 |
|
| 304 |
Example 2 of how to boot a true dom0less configuration: |
| 305 |
|
| 306 |
Xen configuration file: |
| 307 |
|
| 308 |
``` |
| 309 |
[global] |
| 310 |
default=xen |
| 311 |
|
| 312 |
[xen] |
| 313 |
options=<Xen command line> |
| 314 |
dtb=<optional DTB> |
| 315 |
``` |
| 316 |
|
| 317 |
Device tree: |
| 318 |
|
| 319 |
``` |
| 320 |
chosen { |
| 321 |
#size-cells = <0x1>; |
| 322 |
#address-cells = <0x1>; |
| 323 |
xen,uefi-cfg-load; |
| 324 |
|
| 325 |
domU1 { |
| 326 |
#size-cells = <0x1>; |
| 327 |
#address-cells = <0x1>; |
| 328 |
compatible = "xen,domain"; |
| 329 |
cpus = <0x1>; |
| 330 |
memory = <0x0 0xc0000>; |
| 331 |
vpl011; |
| 332 |
|
| 333 |
module@1 { |
| 334 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 335 |
xen,uefi-binary = "Image-domu1.bin"; |
| 336 |
bootargs = "console=ttyAMA0 root=/dev/ram0 rw"; |
| 337 |
}; |
| 338 |
}; |
| 339 |
domU2 { |
| 340 |
#size-cells = <0x1>; |
| 341 |
#address-cells = <0x1>; |
| 342 |
compatible = "xen,domain"; |
| 343 |
cpus = <0x1>; |
| 344 |
memory = <0x0 0x100000>; |
| 345 |
vpl011; |
| 346 |
|
| 347 |
module@2 { |
| 348 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 349 |
xen,uefi-binary = "Image-domu2.bin"; |
| 350 |
bootargs = "console=ttyAMA0 root=/dev/ram0 rw"; |
| 351 |
}; |
| 352 |
}; |
| 353 |
}; |
| 354 |
``` |
| 355 |
|
| 356 |
### Boot Xen, Dom0 and DomU(s) |
| 357 |
|
| 358 |
This configuration is a mix of the two configuration above, to boot this one |
| 359 |
the configuration file can be processed or the Dom0 modules can be read from |
| 360 |
the device tree. |
| 361 |
|
| 362 |
Here the first example: |
| 363 |
|
| 364 |
Xen configuration file: |
| 365 |
|
| 366 |
``` |
| 367 |
[global] |
| 368 |
default=xen |
| 369 |
|
| 370 |
[xen] |
| 371 |
options=<Xen command line> |
| 372 |
kernel=vmlinuz-3.0.31-0.4-xen [domain 0 command line options] |
| 373 |
ramdisk=initrd-3.0.31-0.4-xen |
| 374 |
dtb=<optional DTB> |
| 375 |
``` |
| 376 |
|
| 377 |
Device tree: |
| 378 |
|
| 379 |
``` |
| 380 |
chosen { |
| 381 |
#size-cells = <0x1>; |
| 382 |
#address-cells = <0x1>; |
| 383 |
xen,uefi-cfg-load; |
| 384 |
|
| 385 |
domU1 { |
| 386 |
#size-cells = <0x1>; |
| 387 |
#address-cells = <0x1>; |
| 388 |
compatible = "xen,domain"; |
| 389 |
cpus = <0x1>; |
| 390 |
memory = <0x0 0xc0000>; |
| 391 |
vpl011; |
| 392 |
|
| 393 |
module@1 { |
| 394 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 395 |
xen,uefi-binary = "Image-domu1.bin"; |
| 396 |
bootargs = "console=ttyAMA0 root=/dev/ram0 rw"; |
| 397 |
}; |
| 398 |
}; |
| 399 |
}; |
| 400 |
``` |
| 401 |
|
| 402 |
Here the second example: |
| 403 |
|
| 404 |
Device tree: |
| 405 |
|
| 406 |
``` |
| 407 |
chosen { |
| 408 |
#size-cells = <0x1>; |
| 409 |
#address-cells = <0x1>; |
| 410 |
xen,xen-bootargs = "[Xen boot arguments]" |
| 411 |
|
| 412 |
module@1 { |
| 413 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 414 |
xen,uefi-binary = "vmlinuz-3.0.31-0.4-xen"; |
| 415 |
bootargs = "[domain 0 command line options]"; |
| 416 |
}; |
| 417 |
|
| 418 |
module@2 { |
| 419 |
compatible = "multiboot,ramdisk", "multiboot,module"; |
| 420 |
xen,uefi-binary = "initrd-3.0.31-0.4-xen"; |
| 421 |
}; |
| 422 |
|
| 423 |
domU1 { |
| 424 |
#size-cells = <0x1>; |
| 425 |
#address-cells = <0x1>; |
| 426 |
compatible = "xen,domain"; |
| 427 |
cpus = <0x1>; |
| 428 |
memory = <0x0 0xc0000>; |
| 429 |
vpl011; |
| 430 |
|
| 431 |
module@1 { |
| 432 |
compatible = "multiboot,kernel", "multiboot,module"; |
| 433 |
xen,uefi-binary = "Image-domu1.bin"; |
| 434 |
bootargs = "console=ttyAMA0 root=/dev/ram0 rw"; |
| 435 |
}; |
| 436 |
}; |
| 437 |
}; |
| 438 |
``` |