| 1 |
<?xml version='1.0'?> <!--*-nxml-*--> |
| 2 |
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
| 3 |
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"> |
| 4 |
<!-- SPDX-License-Identifier: LGPL-2.1-or-later --> |
| 5 |
|
| 6 |
<refentry id="systemd-stub" conditional='ENABLE_BOOTLOADER' |
| 7 |
xmlns:xi="http://www.w3.org/2001/XInclude"> |
| 8 |
<refentryinfo> |
| 9 |
<title>systemd-stub</title> |
| 10 |
<productname>systemd</productname> |
| 11 |
</refentryinfo> |
| 12 |
|
| 13 |
<refmeta> |
| 14 |
<refentrytitle>systemd-stub</refentrytitle> |
| 15 |
<manvolnum>7</manvolnum> |
| 16 |
</refmeta> |
| 17 |
|
| 18 |
<refnamediv> |
| 19 |
<refname>systemd-stub</refname> |
| 20 |
<refname>sd-stub</refname> |
| 21 |
<refname>linuxx64.efi.stub</refname> |
| 22 |
<refname>linuxia32.efi.stub</refname> |
| 23 |
<refname>linuxaa64.efi.stub</refname> |
| 24 |
<refpurpose>A simple UEFI kernel boot stub</refpurpose> |
| 25 |
</refnamediv> |
| 26 |
|
| 27 |
<refsynopsisdiv> |
| 28 |
<para><simplelist> |
| 29 |
<member><filename>/usr/lib/systemd/boot/efi/linuxx64.efi.stub</filename></member> |
| 30 |
<member><filename>/usr/lib/systemd/boot/efi/linuxia32.efi.stub</filename></member> |
| 31 |
<member><filename>/usr/lib/systemd/boot/efi/linuxaa64.efi.stub</filename></member> |
| 32 |
<member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.addon.efi</filename></member> |
| 33 |
<member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.cred</filename></member> |
| 34 |
<member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.raw</filename></member> |
| 35 |
<member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.sysext.raw</filename></member> |
| 36 |
<member><filename><replaceable>ESP</replaceable>/.../<replaceable>foo</replaceable>.efi.extra.d/*.confext.raw</filename></member> |
| 37 |
<member><filename><replaceable>ESP</replaceable>/loader/addons/*.addon.efi</filename></member> |
| 38 |
<member><filename><replaceable>ESP</replaceable>/loader/credentials/*.cred</filename></member> |
| 39 |
<member><filename><replaceable>ESP</replaceable>/loader/extensions/*.raw</filename></member> |
| 40 |
<member><filename><replaceable>ESP</replaceable>/loader/extensions/*.sysext.raw</filename></member> |
| 41 |
<member><filename><replaceable>ESP</replaceable>/loader/extensions/*.confext.raw</filename></member> |
| 42 |
</simplelist></para> |
| 43 |
</refsynopsisdiv> |
| 44 |
|
| 45 |
<refsect1> |
| 46 |
<title>Description</title> |
| 47 |
|
| 48 |
<para><command>systemd-stub</command> (stored in per-architecture files |
| 49 |
<filename>linuxx64.efi.stub</filename>, <filename>linuxia32.efi.stub</filename>, |
| 50 |
<filename>linuxaa64.efi.stub</filename> on disk) is a simple UEFI boot stub. An UEFI boot stub is |
| 51 |
attached to a Linux kernel binary image, and is a piece of code that runs in the UEFI firmware |
| 52 |
environment before transitioning into the Linux kernel environment. The UEFI boot stub ensures a Linux |
| 53 |
kernel is executable as regular UEFI binary, and is able to do various preparations before switching the |
| 54 |
system into the Linux world.</para> |
| 55 |
|
| 56 |
<para>The UEFI boot stub looks for various resources for the kernel invocation inside the UEFI PE binary |
| 57 |
itself. This allows combining various resources inside a single PE binary image (a "Unified Kernel Image" |
| 58 |
or "UKI" for short), which may then be signed via UEFI SecureBoot as a whole, covering all individual |
| 59 |
resources at once. Specifically it may include the following PE sections:</para> |
| 60 |
|
| 61 |
<itemizedlist> |
| 62 |
<!-- Let's keep this in the canonical order we also measure the sections by, i.e. as in |
| 63 |
src/fundamental/uki.h's UnifiedSection enum --> |
| 64 |
|
| 65 |
<listitem><para>A <literal>.linux</literal> section with the ELF Linux kernel image. |
| 66 |
This section is required.</para></listitem> |
| 67 |
|
| 68 |
<listitem><para>An optional <literal>.osrel</literal> section with OS release information, i.e. the |
| 69 |
contents of the |
| 70 |
<citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file of |
| 71 |
the OS the kernel belongs to.</para></listitem> |
| 72 |
|
| 73 |
<listitem><para>An optional <literal>.cmdline</literal> section with the kernel command line to pass to |
| 74 |
the invoked kernel.</para></listitem> |
| 75 |
|
| 76 |
<listitem><para>An optional <literal>.initrd</literal> section with the initrd.</para></listitem> |
| 77 |
|
| 78 |
<listitem><para>An optional <literal>.ucode</literal> section with an initrd containing microcode, to |
| 79 |
be handed to the kernel before any other initrd. This initrd must not be compressed.</para></listitem> |
| 80 |
|
| 81 |
<listitem><para>An optional <literal>.splash</literal> section with an image (in the Windows |
| 82 |
<filename>.BMP</filename> format) to show on screen before invoking the kernel.</para></listitem> |
| 83 |
|
| 84 |
<listitem><para>An optional <literal>.dtb</literal> section with a compiled binary DeviceTree. |
| 85 |
</para></listitem> |
| 86 |
|
| 87 |
<listitem><para>Zero or more <literal>.dtbauto</literal> sections. <command>systemd-stub</command> |
| 88 |
will always use the first matching one. The match is performed by taking the first DeviceTree's |
| 89 |
<literal>compatible</literal> string supplied by the firmware in configuration tables and comparing it |
| 90 |
with the first <literal>compatible</literal> string from each of the <literal>.dtbauto</literal> |
| 91 |
sections. If the firmware does not provide a DeviceTree, the match is done using the |
| 92 |
<literal>.hwids</literal> section instead. After selecting the matching entry in the |
| 93 |
<literal>.hwids</literal> section (see the description below), the <literal>compatible</literal> string |
| 94 |
from that entry will be used to perform the same matching procedure. If a match is found, that |
| 95 |
<literal>.dtbauto</literal> section will be loaded and will override <literal>.dtb</literal> if |
| 96 |
present.</para></listitem> |
| 97 |
|
| 98 |
<listitem><para>Zero or more <literal>.efifw</literal> sections for the firmware image. It works |
| 99 |
in many ways similar to <literal>.dtbauto</literal> sections. <command>systemd-stub</command> |
| 100 |
will always use the first matching one. The match is performed by first selecting the most appropriate |
| 101 |
entry in the <literal>.hwids</literal> section based on the hardware IDs supplied by SMBIOS (see below). |
| 102 |
If a suitable entry is found, the <literal>fwid</literal> string from that entry will be used to |
| 103 |
perform the matching procedure for firmware blobs in <literal>.efifw</literal> section. The first |
| 104 |
matching firmware will be loaded. |
| 105 |
</para></listitem> |
| 106 |
|
| 107 |
<listitem><para>An optional <literal>.hwids</literal> section with hardware IDs of the machines to |
| 108 |
match DeviceTrees. <command>systemd-stub</command> will use the SMBIOS data to calculate hardware IDs |
| 109 |
of the machine (as per <ulink |
| 110 |
url="https://learn.microsoft.com/en-us/windows-hardware/drivers/install/specifying-hardware-ids-for-a-computer">specification</ulink>), |
| 111 |
and then it will try to find any of them in the <literal>.hwids</literal> section. The first |
| 112 |
matching entry will be used.</para></listitem> |
| 113 |
|
| 114 |
<listitem><para>An optional <literal>.uname</literal> section with the kernel version information, i.e. |
| 115 |
the output of <command>uname -r</command> for the kernel included in the <literal>.linux</literal> |
| 116 |
section.</para></listitem> |
| 117 |
|
| 118 |
<listitem><para>An optional <literal>.sbat</literal> section with |
| 119 |
<ulink url="https://github.com/rhboot/shim/blob/main/SBAT.md">SBAT</ulink> revocation metadata. |
| 120 |
</para></listitem> |
| 121 |
|
| 122 |
<listitem><para>An optional <literal>.pcrsig</literal> section with a set of cryptographic signatures |
| 123 |
for the expected TPM2 PCR values after the kernel has been booted, in JSON format. This is useful for |
| 124 |
implementing TPM2 policies that bind disk encryption and similar to kernels that are signed by a |
| 125 |
specific key.</para></listitem> |
| 126 |
|
| 127 |
<listitem><para>An optional <literal>.pcrpkey</literal> section with a public key in the PEM format |
| 128 |
matching the signature data in the <literal>.pcrsig</literal> section.</para></listitem> |
| 129 |
</itemizedlist> |
| 130 |
|
| 131 |
<!-- FIXME: how does .dtauto/.hwids matching interact with profiles? --> |
| 132 |
|
| 133 |
<para>In a basic UKI, the sections listed above appear at most once, with the exception of |
| 134 |
<literal>.dtbauto</literal> and <literal>.efifw</literal> sections. In a multi-profile UKI, |
| 135 |
multiple sets of these sections are present in a single file and form "profiles", |
| 136 |
one of which can be selected at boot. For this, the PE section <literal>.profile</literal> is |
| 137 |
defined to be used as the separator between sets of sections. The |
| 138 |
<literal>.profile</literal> section itself may contain meta-information about the section, and follows a |
| 139 |
similar structure as the contents of the <literal>.osrel</literal> section. For further details about |
| 140 |
multi-profile UKIs, see below.</para> <para>If UEFI SecureBoot is enabled and the |
| 141 |
<literal>.cmdline</literal> section is present in the executed image, any attempts to override the kernel |
| 142 |
command line by passing one as invocation parameters to the EFI binary are ignored. Thus, in order to |
| 143 |
allow overriding the kernel command line, either disable UEFI SecureBoot, or do not include a kernel |
| 144 |
command line PE section in the kernel image file. If a command line is accepted via EFI invocation |
| 145 |
parameters to the EFI binary it is measured into TPM PCR 12 (if a TPM is present).</para> <para>If a |
| 146 |
DeviceTree is embedded in the <literal>.dtb</literal> section, it replaces an existing DeviceTree in the |
| 147 |
corresponding EFI configuration table. <command>systemd-stub</command> will ask the firmware via the |
| 148 |
<literal>EFI_DT_FIXUP_PROTOCOL</literal> for hardware specific fixups to the DeviceTree.</para> |
| 149 |
|
| 150 |
<para>The contents of 11 of these 12 sections are measured into TPM PCR 11. It is otherwise not used and |
| 151 |
thus the result can be pre-calculated without too much effort. The <literal>.pcrsig</literal> section is |
| 152 |
not included in this PCR measurement, since it is supposed to contain signatures for the output of the |
| 153 |
measurement operation, and thus cannot also be input to it. If an UKI contains multiple profiles, only |
| 154 |
the PE sections of the selected profile (and those of the base profile, except if overridden) are |
| 155 |
measured.</para> |
| 156 |
|
| 157 |
<para>If non-zero, the selected numeric profile is measured into PCR 12.</para> |
| 158 |
|
| 159 |
<para>When <literal>.pcrsig</literal> and/or <literal>.pcrpkey</literal> sections are present in a |
| 160 |
unified kernel image their contents are passed to the booted kernel in an synthetic initrd cpio archive |
| 161 |
that places them in the <filename>/.extra/tpm2-pcr-signature.json</filename> and |
| 162 |
<filename>/.extra/tpm2-pcr-public-key.pem</filename> files. Typically, a |
| 163 |
<citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> line then |
| 164 |
ensures they are copied into <filename>/run/systemd/tpm2-pcr-signature.json</filename> and |
| 165 |
<filename>/run/systemd/tpm2-pcr-public-key.pem</filename> where they remain accessible even after the |
| 166 |
system transitions out of the initrd environment into the host file system. Tools such |
| 167 |
<citerefentry><refentrytitle>[email protected]</refentrytitle><manvolnum>8</manvolnum></citerefentry>, |
| 168 |
<citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 169 |
and <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 170 |
will automatically use files present under these paths to unlock protected resources (encrypted storage |
| 171 |
or credentials) or bind encryption to booted kernels.</para> |
| 172 |
|
| 173 |
<para>For further details about the UKI concept, see the <ulink |
| 174 |
url="https://uapi-group.org/specifications/specs/unified_kernel_image/">UAPI.5 UKI specification</ulink>.</para> |
| 175 |
</refsect1> |
| 176 |
|
| 177 |
<refsect1> |
| 178 |
<title>Companion Files</title> |
| 179 |
|
| 180 |
<para>The <command>systemd-stub</command> UEFI boot stub automatically collects three types of auxiliary |
| 181 |
companion files optionally placed in drop-in directories on the same partition as the EFI binary, |
| 182 |
dynamically generates <command>cpio</command> initrd archives from them, and passes them to the kernel. |
| 183 |
Specifically:</para> |
| 184 |
|
| 185 |
<itemizedlist> |
| 186 |
<listitem><para>For a kernel binary called <filename><replaceable>foo</replaceable>.efi</filename>, it |
| 187 |
will look for files with the <filename>.cred</filename> suffix in a directory named |
| 188 |
<filename><replaceable>foo</replaceable>.efi.extra.d/</filename> next to it. If the kernel binary |
| 189 |
uses a counter for the purpose of |
| 190 |
<ulink url="https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT">Automatic Boot Assessment</ulink>, this |
| 191 |
counter will be ignored. For example, <filename><replaceable>foo</replaceable>+3-0.efi</filename> |
| 192 |
will look in directory <filename><replaceable>foo</replaceable>.efi.extra.d/</filename>. |
| 193 |
A <command>cpio</command> |
| 194 |
archive is generated from all files found that way, placing them in the |
| 195 |
<filename>/.extra/credentials/</filename> directory of the initrd file hierarchy. The main initrd may |
| 196 |
then access them in this directory. This is supposed to be used to store auxiliary, encrypted, |
| 197 |
authenticated credentials for use with <varname>LoadCredentialEncrypted</varname> in the UEFI System |
| 198 |
Partition. See |
| 199 |
<citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry> |
| 200 |
and |
| 201 |
<citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 202 |
for |
| 203 |
details on encrypted credentials. The generated <command>cpio</command> archive is measured into TPM |
| 204 |
PCR 12 (if a TPM is present).</para></listitem> |
| 205 |
|
| 206 |
<listitem><para>Similarly, files |
| 207 |
<filename><replaceable>foo</replaceable>.efi.extra.d/*.sysext.raw</filename> are packed up in a |
| 208 |
<command>cpio</command> archive and placed in the <filename>/.extra/sysext/</filename> directory in the |
| 209 |
initrd file hierarchy. This is supposed to be used to pass additional UKI-specific system extension |
| 210 |
images to the initrd. See |
| 211 |
<citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for |
| 212 |
details on system extension images. The generated <command>cpio</command> archive containing these |
| 213 |
system extension images is measured into TPM PCR 13 (if a TPM is present).</para></listitem> |
| 214 |
|
| 215 |
<!-- Note: the actual suffix we look for for sysexts is just *.raw (not *.sysext.raw), for |
| 216 |
compatibility reasons with old versions. But we want people to name their system extensions |
| 217 |
properly, hence we document the *.sysext.raw suffix only. --> |
| 218 |
|
| 219 |
<listitem><para>Similarly, files <filename>/loader/extensions/*.sysext.raw</filename> |
| 220 |
are packed up in a <command>cpio</command> archive and placed in the <filename>/.extra/global_sysext/</filename> |
| 221 |
directory in the initrd file hierarchy. This is supposed to be used to pass additional global system |
| 222 |
extension images to the initrd. See |
| 223 |
<citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for |
| 224 |
details on system extension images. The generated <command>cpio</command> archive containing these |
| 225 |
system extension images is measured into TPM PCR 13 (if a TPM is present).</para></listitem> |
| 226 |
|
| 227 |
<listitem><para>Similarly, files |
| 228 |
<filename><replaceable>foo</replaceable>.efi.extra.d/*.confext.raw</filename> are packed up in a |
| 229 |
<command>cpio</command> archive and placed in the <filename>/.extra/confext/</filename> directory in |
| 230 |
the initrd file hierarchy. This is supposed to be used to pass additional UKI-specific configuration |
| 231 |
extension images to the initrd. See |
| 232 |
<citerefentry><refentrytitle>systemd-confext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for |
| 233 |
details on configuration extension images. The generated <command>cpio</command> archive containing |
| 234 |
these configuration extension images is measured into TPM PCR 12 (if a TPM is present).</para></listitem> |
| 235 |
|
| 236 |
<listitem><para>Similarly, files <filename>/loader/extensions/*.confext.raw</filename> |
| 237 |
are packed up in a <command>cpio</command> archive and placed in the <filename>/.extra/global_confext/</filename> |
| 238 |
directory in the initrd file hierarchy. This is supposed to be used to pass additional global configuration |
| 239 |
extension images to the initrd. See |
| 240 |
<citerefentry><refentrytitle>systemd-confext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for |
| 241 |
details on configuration extension images. The generated <command>cpio</command> archive containing |
| 242 |
these configuration extension images is measured into TPM PCR 12 (if a TPM is present).</para></listitem> |
| 243 |
|
| 244 |
<listitem><para>Similarly, files |
| 245 |
<filename><replaceable>foo</replaceable>.efi.extra.d/*.addon.efi</filename> are loaded and verified as |
| 246 |
PE binaries and specific sections are loaded from them. Addons are used to pass additional kernel |
| 247 |
command line parameters (<literal>.cmdline</literal> section), or DeviceTree blobs |
| 248 |
(<literal>.dtb</literal> section), additional initrds (<literal>.initrd</literal> section), |
| 249 |
and microcode updates (<literal>.ucode</literal> section). Addons allow those resources to be passed |
| 250 |
regardless of the kernel version being booted, for example allowing platform vendors to ship |
| 251 |
platform-specific configuration.</para> |
| 252 |
|
| 253 |
<para>In case Secure Boot is enabled, these files will be validated using keys in UEFI DB, Shim's DB or |
| 254 |
Shim's MOK, and only loaded if the check passes. Additionally, if both the addon and the UKI contain a |
| 255 |
<literal>.uname</literal> section, the addon will be rejected if they do not match exactly. It is |
| 256 |
recommended to always add a <literal>.sbat</literal> section to all signed addons, so that they may be |
| 257 |
revoked with a SBAT policy update, without requiring blocklisting via DBX/MOKX. The |
| 258 |
<citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool will add |
| 259 |
a SBAT policy by default if none is passed when building addons. For more information on SBAT see |
| 260 |
<ulink url="https://github.com/rhboot/shim/blob/main/SBAT.md">Shim documentation</ulink>.</para> |
| 261 |
|
| 262 |
<para>Addon files are sorted, loaded, and measured into TPM PCR 12 (if a TPM is present) and appended |
| 263 |
to the kernel command line. UKI command line options are listed first, then options from addons in |
| 264 |
<filename>/loader/addons/*.addon.efi</filename>, and finally UKI-specific addons. Device tree blobs are |
| 265 |
loaded and measured following the same algorithm. Microcode addons are passed to the kernel in inverse |
| 266 |
order (UKI specific addons, global addons, UKI embedded section). This is because the microcode update |
| 267 |
driver stops on the first matching filename. Addons are always loaded in the same order based on |
| 268 |
the filename, so that, given the same set of addons, the same set of measurements can be expected in |
| 269 |
PCR12. However, note that the filename is not protected by the PE signature, and as such an attacker |
| 270 |
with write access to the ESP could potentially rename these files to change the order in which they are |
| 271 |
loaded, in a way that could alter the functionality of the kernel, as some options might be |
| 272 |
order-dependent. If you sign such addons, you should pay attention to the PCR12 values and make use of |
| 273 |
an attestation service so that improper use of your signed addons can be detected and dealt with using |
| 274 |
one of the aforementioned revocation mechanisms.</para></listitem> |
| 275 |
|
| 276 |
<listitem><para>Files <filename>/loader/credentials/*.cred</filename> are packed up in a |
| 277 |
<command>cpio</command> archive and placed in the <filename>/.extra/global_credentials/</filename> |
| 278 |
directory of the initrd file hierarchy. This is supposed to be used to pass additional credentials to |
| 279 |
the initrd, regardless of the kernel version being booted. The generated <command>cpio</command> |
| 280 |
archive is measured into TPM PCR 12 (if a TPM is present).</para></listitem> |
| 281 |
|
| 282 |
<listitem><para>Additionally, files <filename>/loader/addons/*.addon.efi</filename> are loaded and |
| 283 |
verified as PE binaries, and <literal>.cmdline</literal>, <literal>.dtb</literal>, |
| 284 |
<literal>.initrd</literal>, and <literal>.ucode</literal> sections are parsed from them. |
| 285 |
This is supposed to be used to pass additional command line parameters, DeviceTree blobs, initrds, |
| 286 |
and microcode updates to the kernel, regardless of the kernel version being booted.</para></listitem> |
| 287 |
</itemizedlist> |
| 288 |
|
| 289 |
<para>These mechanisms may be used to parameterize and extend trusted (i.e. signed), immutable initrd |
| 290 |
images in a reasonably safe way: all data they contain is measured into TPM PCRs. On access they should be |
| 291 |
further validated: in case of the credentials case by encrypting/authenticating them via TPM, as exposed |
| 292 |
by <command>systemd-creds encrypt -T</command> (see |
| 293 |
<citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry> for |
| 294 |
details); in case of the system extension images by using signed Verity images.</para> |
| 295 |
|
| 296 |
<para>Note that earlier components of the boot process might register additional initrds, and thus |
| 297 |
additional "companion" resources such as system extensions, configuration extensions and credentials for |
| 298 |
consumption by the kernel and OS eventually booted. For example, |
| 299 |
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry> does |
| 300 |
this for resources configured in UAPI.1 Type #1 <literal>extra</literal> |
| 301 |
lines. <filename>systemd-stub</filename> will combine any resources provided that way with the companion |
| 302 |
file resources it acquires itself.</para> |
| 303 |
</refsect1> |
| 304 |
|
| 305 |
<refsect1> |
| 306 |
<title>Multi-Profile UKIs</title> |
| 307 |
|
| 308 |
<para>In many contexts it is useful to allow invocation of a single UKI in multiple different modes (or |
| 309 |
"profiles") without compromising the cryptographic integrity, measurements and so on of the boot |
| 310 |
process. For example, a single UKI might provide three distinct profiles: a regular boot one, one that |
| 311 |
invokes a "factory reset" operation, and one that boots into a storage target mode (as in |
| 312 |
<citerefentry><refentrytitle>systemd-storagetm.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>). Each |
| 313 |
profile would then use the same <literal>.linux</literal> and <literal>.initrd</literal> sections, but would |
| 314 |
have a separate <literal>.cmdline</literal> section. For example the latter two profiles would extend the |
| 315 |
regular kernel command line with <literal>systemd.unit=factory-reset.target</literal> or |
| 316 |
<literal>rd.systemd.unit=storagetm.target</literal>.</para> |
| 317 |
|
| 318 |
<para>A single UKI may support multiple profiles by means of the special <literal>.profile</literal> PE |
| 319 |
section. This section acts as separator between the PE sections of the individual profiles. |
| 320 |
<literal>.profile</literal> PE sections hence may appear multiple times in a single UKI, and the other PE |
| 321 |
sections listed above may appear multiple times too, if <literal>.profile</literal> are used, but only |
| 322 |
once before the first <literal>.profile</literal> section, once between each subsequent pair, and once |
| 323 |
after the last appearance of <literal>.profile</literal>. The sections listed before the first |
| 324 |
<literal>.profile</literal> are considered the "base" profile of the UKI. Each |
| 325 |
<literal>.profile</literal> section then introduces a new profile, which are numbered starting from zero. |
| 326 |
The PE sections following each <literal>.profile</literal> are specific to that profile. When booting |
| 327 |
into a specific profile, the base section's profiles are used in combination with the specific profile's |
| 328 |
sections: if the same section is defined in both, the per-profile section overrides the base profile's |
| 329 |
version, otherwise the base profile sections are used.</para> |
| 330 |
|
| 331 |
<para>A UKI that contains no <literal>.profile</literal> is consider equivalent to one that just contains |
| 332 |
a single <literal>.profile</literal>, as having only a single profile <literal>@0</literal>.</para> |
| 333 |
|
| 334 |
<para>Here's a simple example for a multi-profile UKI's sections, inspired by the setup suggested above:</para> |
| 335 |
|
| 336 |
<table> |
| 337 |
<title>Multi-Profile UKI Example</title> |
| 338 |
|
| 339 |
<tgroup cols='2' align='left' colsep='1' rowsep='1'> |
| 340 |
<colspec colname="section" /> |
| 341 |
<colspec colname="profile" /> |
| 342 |
|
| 343 |
<thead> |
| 344 |
<row> |
| 345 |
<entry>Section</entry> |
| 346 |
<entry>Profile</entry> |
| 347 |
</row> |
| 348 |
</thead> |
| 349 |
|
| 350 |
<tbody> |
| 351 |
<row> |
| 352 |
<entry><literal>.linux</literal></entry> |
| 353 |
<entry morerows="3" valign="middle">Base profile</entry> |
| 354 |
</row> |
| 355 |
<row> |
| 356 |
<entry><literal>.osrel</literal></entry> |
| 357 |
</row> |
| 358 |
<row> |
| 359 |
<entry><literal>.cmdline</literal></entry> |
| 360 |
</row> |
| 361 |
<row> |
| 362 |
<entry><literal>.initrd</literal></entry> |
| 363 |
</row> |
| 364 |
<row> |
| 365 |
<entry><literal>.profile</literal></entry> |
| 366 |
<entry>Profile @0</entry> |
| 367 |
</row> |
| 368 |
<row> |
| 369 |
<entry><literal>.profile</literal></entry> |
| 370 |
<entry morerows="1" valign="middle">Profile @1</entry> |
| 371 |
</row> |
| 372 |
<row> |
| 373 |
<entry><literal>.cmdline</literal></entry> |
| 374 |
</row> |
| 375 |
<row> |
| 376 |
<entry><literal>.profile</literal></entry> |
| 377 |
<entry morerows="1" valign="middle">Profile @2</entry> |
| 378 |
</row> |
| 379 |
<row> |
| 380 |
<entry><literal>.cmdline</literal></entry> |
| 381 |
</row> |
| 382 |
</tbody> |
| 383 |
</tgroup> |
| 384 |
</table> |
| 385 |
|
| 386 |
<para>The section list above would define three profiles. The first four sections make up the base |
| 387 |
profile. A <literal>.profile</literal> section then introduces profile @0. It does not override any |
| 388 |
sections (or add any) from the base section, hence it is immediately followed by another |
| 389 |
<literal>.profile</literal> section that then introduces section @1. This profile overrides the kernel |
| 390 |
command line. Finally, the last two sections define section @2, again overriding the command line. (Note |
| 391 |
that in this example the first <literal>.cmdline</literal> could also moved behind the first |
| 392 |
<literal>.profile</literal> with equivalent effect. To keep things nicely extensible, it is probably a |
| 393 |
good idea to keep the generic command line in the base section instead of profile 0, in case later added |
| 394 |
profiles might want to reuse it.)</para> |
| 395 |
|
| 396 |
<para>The profile to boot may be controlled via the UKI's own command line: if the first argument starts |
| 397 |
with <literal>@</literal>, followed by a positive integer number in decimal, it selects the profile to |
| 398 |
boot into. If the first argument is not specified like that, the UKI will automatically boot into profile |
| 399 |
0.</para> |
| 400 |
|
| 401 |
<para>A <literal>.profile</literal> section may contain meta-information about the profile. It follows a |
| 402 |
similar format as <literal>.osrel</literal> (i.e. an environment-variable-assignment-block-like list of |
| 403 |
newline separated strings). Currently two fields are defined: <literal>ID=</literal> is supposed to carry |
| 404 |
a short identifying string that identifies the profile |
| 405 |
(e.g. <literal>ID=factory-reset</literal>). <literal>TITLE=</literal> should contain a human-readable |
| 406 |
string that may appear in the boot menu entry for this profile (e.g. <literal>TITLE='Factory Reset this |
| 407 |
Device'</literal>).</para> |
| 408 |
</refsect1> |
| 409 |
|
| 410 |
<refsect1> |
| 411 |
<title>TPM PCR Notes</title> |
| 412 |
|
| 413 |
<para>Note that when a unified kernel using <command>systemd-stub</command> is invoked the firmware will |
| 414 |
measure it as a whole to TPM PCR 4, covering all embedded resources, such as the stub code itself, the |
| 415 |
core kernel, the embedded initrd and kernel command line (see above for a full list), including all UKI |
| 416 |
profiles.</para> |
| 417 |
|
| 418 |
<para>Also note that when <command>systemd-stub</command> measures a PE section, it will measure the |
| 419 |
amount of bytes that the section takes up in memory (<varname>VirtualSize</varname>) and not the amount |
| 420 |
of bytes that the section takes up on disk (<varname>SizeOfRawData</varname>). This means that if the |
| 421 |
size in memory is larger than the size on disk, <command>systemd-stub</command> will end up measuring |
| 422 |
extra zeroes. To avoid this from happening, it is recommended to make sure that the size in memory of |
| 423 |
each section that is measured by <command>systemd-stub</command> is always smaller than or equal to the |
| 424 |
size on disk. <command>ukify</command> automatically makes sure this is the case when building UKIs or |
| 425 |
addons.</para> |
| 426 |
|
| 427 |
<para>Also note that the Linux kernel will measure all initrds it receives into TPM PCR 9. This means |
| 428 |
every type of initrd (of the selected UKI profile) will possibly be measured two or three times: the |
| 429 |
initrds embedded in the kernel image will be measured to PCR 4, PCR 9 and PCR 11; the initrd synthesized |
| 430 |
from credentials (and the one synthesized from configuration extensions) will be measured to both PCR 9 |
| 431 |
and PCR 12; the initrd synthesized from system extensions will be measured to both PCR 4 and PCR 9. Let's |
| 432 |
summarize the OS resources and the PCRs they are measured to:</para> |
| 433 |
|
| 434 |
<table> |
| 435 |
<title>OS Resource PCR Summary</title> |
| 436 |
|
| 437 |
<tgroup cols='2' align='left' colsep='1' rowsep='1'> |
| 438 |
<colspec colname="pcr" /> |
| 439 |
<colspec colname="definition" /> |
| 440 |
|
| 441 |
<thead> |
| 442 |
<row> |
| 443 |
<entry>OS Resource</entry> |
| 444 |
<entry>Measurement PCR</entry> |
| 445 |
</row> |
| 446 |
</thead> |
| 447 |
|
| 448 |
<tbody> |
| 449 |
<row> |
| 450 |
<entry><command>systemd-stub</command> code (the entry point of the unified PE binary)</entry> |
| 451 |
<entry>4</entry> |
| 452 |
</row> |
| 453 |
|
| 454 |
<row> |
| 455 |
<entry>Core kernel code (embedded in unified PE binary)</entry> |
| 456 |
<entry>4 + 11</entry> |
| 457 |
</row> |
| 458 |
|
| 459 |
<row> |
| 460 |
<entry>OS release information (embedded in the unified PE binary)</entry> |
| 461 |
<entry>4 + 11</entry> |
| 462 |
</row> |
| 463 |
|
| 464 |
<row> |
| 465 |
<entry>Main initrd (embedded in unified PE binary)</entry> |
| 466 |
<entry>4 + 9 + 11</entry> |
| 467 |
</row> |
| 468 |
|
| 469 |
<row> |
| 470 |
<entry>Microcode initrd (embedded in unified PE binary)</entry> |
| 471 |
<entry>4 + 9 + 11</entry> |
| 472 |
</row> |
| 473 |
|
| 474 |
<row> |
| 475 |
<entry>Default kernel command line (embedded in unified PE binary)</entry> |
| 476 |
<entry>4 + 11</entry> |
| 477 |
</row> |
| 478 |
|
| 479 |
<row> |
| 480 |
<entry>Overridden kernel command line</entry> |
| 481 |
<entry>12</entry> |
| 482 |
</row> |
| 483 |
|
| 484 |
<row> |
| 485 |
<entry>Boot splash (embedded in the unified PE binary)</entry> |
| 486 |
<entry>4 + 11</entry> |
| 487 |
</row> |
| 488 |
|
| 489 |
<row> |
| 490 |
<entry>TPM2 PCR signature JSON (embedded in unified PE binary, synthesized into initrd)</entry> |
| 491 |
<entry>4 + 9</entry> |
| 492 |
</row> |
| 493 |
|
| 494 |
<row> |
| 495 |
<entry>TPM2 PCR PEM public key (embedded in unified PE binary, synthesized into initrd)</entry> |
| 496 |
<entry>4 + 9 + 11</entry> |
| 497 |
</row> |
| 498 |
|
| 499 |
<row> |
| 500 |
<entry>Credentials (synthesized initrd from companion files)</entry> |
| 501 |
<entry>9 + 12</entry> |
| 502 |
</row> |
| 503 |
|
| 504 |
<row> |
| 505 |
<entry>System Extensions (synthesized initrd from companion files)</entry> |
| 506 |
<entry>9 + 13</entry> |
| 507 |
</row> |
| 508 |
|
| 509 |
<row> |
| 510 |
<entry>Configuration Extensions (synthesized initrd from companion files)</entry> |
| 511 |
<entry>9 + 12</entry> |
| 512 |
</row> |
| 513 |
|
| 514 |
<row> |
| 515 |
<entry>Selected profile unless zero</entry> |
| 516 |
<entry>12</entry> |
| 517 |
</row> |
| 518 |
</tbody> |
| 519 |
</tgroup> |
| 520 |
</table> |
| 521 |
</refsect1> |
| 522 |
|
| 523 |
<refsect1> |
| 524 |
<title>EFI Variables</title> |
| 525 |
|
| 526 |
<para>The following EFI variables are defined, set and read by <command>systemd-stub</command>, under the |
| 527 |
vendor UUID <literal>4a67b082-0a4c-41cf-b6c7-440b29bb8c4f</literal>, for communication between the boot |
| 528 |
stub and the OS:</para> |
| 529 |
|
| 530 |
<variablelist class='efi-variables'> |
| 531 |
<varlistentry> |
| 532 |
<term><varname>LoaderDevicePartUUID</varname></term> |
| 533 |
|
| 534 |
<listitem><para>Contains the partition UUID of the partition the boot loader has been started from on |
| 535 |
the current boot (usually a EFI System Partition). If already set by the boot loader, this will |
| 536 |
remain untouched by <command>systemd-stub</command>. If not set yet, this will be set to the |
| 537 |
partition UUID of the partition the unified kernel is started from, in order to support systems that |
| 538 |
directly boot into a unified kernel image, bypassing any boot loader. |
| 539 |
<citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry> |
| 540 |
uses this information to automatically find the disk booted from, in order to discover various other |
| 541 |
partitions on the same disk automatically.</para> |
| 542 |
|
| 543 |
<xi:include href="version-info.xml" xpointer="v224"/></listitem> |
| 544 |
</varlistentry> |
| 545 |
|
| 546 |
<varlistentry> |
| 547 |
<term><varname>LoaderFirmwareInfo</varname></term> |
| 548 |
<term><varname>LoaderFirmwareType</varname></term> |
| 549 |
|
| 550 |
<listitem><para>Brief firmware information. Use |
| 551 |
<citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view this |
| 552 |
data.</para> |
| 553 |
|
| 554 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 555 |
</varlistentry> |
| 556 |
|
| 557 |
<varlistentry> |
| 558 |
<term><varname>LoaderTpm2ActivePcrBanks</varname></term> |
| 559 |
|
| 560 |
<listitem><para>Hexadecimal string representation of a bitmask with values defined by the TCG EFI |
| 561 |
Protocol Specification for TPM 2.0 as EFI_TCG2_BOOT_HASH_ALG_*. If no TPM2 support or no active |
| 562 |
banks were detected, will be set to <constant>0</constant>. Set by the boot loader. Use |
| 563 |
<citerefentry><refentrytitle>systemd-analyze</refentrytitle><manvolnum>1</manvolnum></citerefentry> |
| 564 |
to view this data.</para> |
| 565 |
|
| 566 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 567 |
</varlistentry> |
| 568 |
|
| 569 |
<varlistentry> |
| 570 |
<term><varname>LoaderImageIdentifier</varname></term> |
| 571 |
|
| 572 |
<listitem><para>The file system path to the EFI executable of the boot loader for the current boot, |
| 573 |
relative to the partition's root directory (i.e. relative to the partition indicated by |
| 574 |
<varname>LoaderDevicePartUUID</varname>, see above). If not set yet, this will be set to the file |
| 575 |
system path of the EFI executable of the booted unified kernel, in order to support systems that |
| 576 |
directly boot into a unified kernel image, bypassing any boot loader. Use |
| 577 |
<citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view |
| 578 |
this data.</para> |
| 579 |
|
| 580 |
<xi:include href="version-info.xml" xpointer="v237"/></listitem> |
| 581 |
</varlistentry> |
| 582 |
|
| 583 |
<varlistentry> |
| 584 |
<term><varname>StubDevicePartUUID</varname></term> |
| 585 |
<term><varname>StubImageIdentifier</varname></term> |
| 586 |
|
| 587 |
<listitem><para>Similar to <varname>LoaderDevicePartUUID</varname> and |
| 588 |
<varname>LoaderImageIdentifier</varname>, but indicates the location of the unified kernel image EFI |
| 589 |
binary rather than the location of the boot loader binary, regardless of whether booted via a boot loader |
| 590 |
or not.</para> |
| 591 |
|
| 592 |
<xi:include href="version-info.xml" xpointer="v257"/></listitem> |
| 593 |
</varlistentry> |
| 594 |
|
| 595 |
<varlistentry> |
| 596 |
<term><varname>StubDeviceURL</varname></term> |
| 597 |
|
| 598 |
<listitem><para>If the kernel image has been invoked via network booting this variable contains the |
| 599 |
originating URL. This may be used to automatically acquire additional resources from the same |
| 600 |
source.</para> |
| 601 |
|
| 602 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 603 |
</varlistentry> |
| 604 |
|
| 605 |
<varlistentry> |
| 606 |
<term><varname>StubInfo</varname></term> |
| 607 |
|
| 608 |
<listitem><para>Brief stub information. Use |
| 609 |
<citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view |
| 610 |
this data.</para> |
| 611 |
|
| 612 |
<xi:include href="version-info.xml" xpointer="v250"/></listitem> |
| 613 |
</varlistentry> |
| 614 |
|
| 615 |
<varlistentry> |
| 616 |
<term><varname>StubPcrKernelImage</varname></term> |
| 617 |
|
| 618 |
<listitem><para>The PCR register index the kernel image, initrd image, boot splash, devicetree |
| 619 |
database, and the embedded command line are measured into, formatted as decimal ASCII string (e.g. |
| 620 |
<literal>11</literal>). This variable is set if a measurement was successfully completed, and remains |
| 621 |
unset otherwise.</para> |
| 622 |
|
| 623 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 624 |
</varlistentry> |
| 625 |
|
| 626 |
<varlistentry> |
| 627 |
<term><varname>StubPcrKernelParameters</varname></term> |
| 628 |
|
| 629 |
<listitem><para>The PCR register index the kernel command line and credentials are measured into, |
| 630 |
formatted as decimal ASCII string (e.g. <literal>12</literal>). This variable is set if a measurement |
| 631 |
was successfully completed, and remains unset otherwise.</para> |
| 632 |
|
| 633 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 634 |
</varlistentry> |
| 635 |
|
| 636 |
<varlistentry> |
| 637 |
<term><varname>StubPcrInitRDSysExts</varname></term> |
| 638 |
|
| 639 |
<listitem><para>The PCR register index the system extensions for the initrd, which are picked up from |
| 640 |
the file system the kernel image is located on. Formatted as decimal ASCII string (e.g. |
| 641 |
<literal>13</literal>). This variable is set if a measurement was successfully completed, and remains |
| 642 |
unset otherwise.</para> |
| 643 |
|
| 644 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 645 |
</varlistentry> |
| 646 |
|
| 647 |
<varlistentry> |
| 648 |
<term><varname>StubPcrInitRDConfExts</varname></term> |
| 649 |
|
| 650 |
<listitem><para>The PCR register index the configuration extensions for the initrd, which are picked |
| 651 |
up from the file system the kernel image is located on. Formatted as decimal ASCII string (e.g. |
| 652 |
<literal>12</literal>). This variable is set if a measurement was successfully completed, and remains |
| 653 |
unset otherwise.</para> |
| 654 |
|
| 655 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 656 |
</varlistentry> |
| 657 |
|
| 658 |
<varlistentry> |
| 659 |
<term><varname>StubProfile</varname></term> |
| 660 |
|
| 661 |
<listitem><para>The numeric index of the selected profile, without the <literal>@</literal>, |
| 662 |
formatted as decimal string. Set both on single-profile and multi-profile UKIs. (In the former case |
| 663 |
this variable will be set to <literal>0</literal> unconditionally.)</para> |
| 664 |
|
| 665 |
<xi:include href="version-info.xml" xpointer="v257"/></listitem> |
| 666 |
</varlistentry> |
| 667 |
|
| 668 |
<varlistentry> |
| 669 |
<term><varname>LoaderPcrSMBIOS</varname></term> |
| 670 |
|
| 671 |
<listitem><para>The PCR register index select SMBIOS structures are measured into — type 1 |
| 672 |
(system information, with the volatile "Wake-up Type" field zeroed out), type 2 (baseboard |
| 673 |
information) and type 11 (OEM strings). Formatted as decimal ASCII string (e.g. |
| 674 |
<literal>1</literal>). This variable is set if a measurement was successfully completed, and remains |
| 675 |
unset otherwise. <command>systemd-stub</command> performs this measurement only if it has not already |
| 676 |
been done in the same boot (e.g. by the boot loader), as indicated by this variable being set |
| 677 |
already.</para> |
| 678 |
|
| 679 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 680 |
</varlistentry> |
| 681 |
|
| 682 |
<varlistentry> |
| 683 |
<term><varname>LoaderBootSecret</varname></term> |
| 684 |
|
| 685 |
<listitem><para>A non-volatile EFI variable only accessible from the pre-boot environment |
| 686 |
(i.e. access from the OS is not permitted) that contains a per-system secret. It is set automatically |
| 687 |
by <command>systemd-stub</command> if not present already. A secret derived from the value of this |
| 688 |
EFI variable is passed to the OS in <filename>/.extra/boot-secret</filename>, see below.</para> |
| 689 |
|
| 690 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 691 |
</varlistentry> |
| 692 |
</variablelist> |
| 693 |
|
| 694 |
<para>Note that some of the variables above may also be set by the boot loader. The stub will only set |
| 695 |
them if they are not set already. Some of these variables are defined by the <ulink |
| 696 |
url="https://systemd.io/BOOT_LOADER_INTERFACE">Boot Loader Interface</ulink>.</para> |
| 697 |
</refsect1> |
| 698 |
|
| 699 |
<refsect1> |
| 700 |
<title>initrd Resources</title> |
| 701 |
|
| 702 |
<para>The following resources are passed as initrd cpio archives to the booted kernel, and thus make up |
| 703 |
the initial file system hierarchy in the initrd execution environment:</para> |
| 704 |
|
| 705 |
<variablelist> |
| 706 |
<varlistentry> |
| 707 |
<term><filename>/</filename></term> |
| 708 |
|
| 709 |
<listitem><para>The main initrd from the <literal>.initrd</literal> PE section of the unified kernel |
| 710 |
image.</para> |
| 711 |
|
| 712 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 713 |
</varlistentry> |
| 714 |
|
| 715 |
<varlistentry> |
| 716 |
<term><filename>/.extra/credentials/*.cred</filename></term> |
| 717 |
<listitem><para>Credential files (suffix <literal>.cred</literal>) that are placed next to the |
| 718 |
unified kernel image (as described above) are copied into the |
| 719 |
<filename>/.extra/credentials/</filename> directory in the initrd execution |
| 720 |
environment.</para> |
| 721 |
|
| 722 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 723 |
</varlistentry> |
| 724 |
|
| 725 |
<varlistentry> |
| 726 |
<term><filename>/.extra/global_credentials/*.cred</filename></term> |
| 727 |
<listitem><para>Similarly, credential files in the <filename>/loader/credentials/</filename> |
| 728 |
directory in the file system the unified kernel image is placed in are copied into the |
| 729 |
<filename>/.extra/global_credentials/</filename> directory in the initrd execution |
| 730 |
environment.</para> |
| 731 |
|
| 732 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 733 |
</varlistentry> |
| 734 |
|
| 735 |
<varlistentry> |
| 736 |
<term><filename>/.extra/sysext/*.sysext.raw</filename></term> |
| 737 |
<listitem><para>System extension image files (suffix <literal>.sysext.raw</literal>) that are placed |
| 738 |
next to the unified kernel image (as described above) are copied into the |
| 739 |
<filename>/.extra/sysext/</filename> directory in the initrd execution environment.</para> |
| 740 |
|
| 741 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 742 |
</varlistentry> |
| 743 |
|
| 744 |
<varlistentry> |
| 745 |
<term><filename>/.extra/global_sysext/*.sysext.raw</filename></term> |
| 746 |
<listitem><para>Similarly, system extension image files (suffix <literal>.sysext.raw</literal>) that |
| 747 |
are placed in the <filename>/loader/extensions/</filename> directory in the file system the unified |
| 748 |
kernel image is placed in are copied into the <filename>/.extra/global_sysext/</filename> |
| 749 |
directory in the initrd execution environment.</para> |
| 750 |
|
| 751 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 752 |
</varlistentry> |
| 753 |
|
| 754 |
<varlistentry> |
| 755 |
<term><filename>/.extra/confext/*.confext.raw</filename></term> |
| 756 |
<listitem><para>Configuration extension image files (suffix <literal>.confext.raw</literal>) that are |
| 757 |
placed next to the unified kernel image (as described above) are copied into the |
| 758 |
<filename>/.extra/confext/</filename> directory in the initrd execution environment.</para> |
| 759 |
|
| 760 |
<xi:include href="version-info.xml" xpointer="v255"/></listitem> |
| 761 |
</varlistentry> |
| 762 |
|
| 763 |
<varlistentry> |
| 764 |
<term><filename>/.extra/global_confext/*.confext.raw</filename></term> |
| 765 |
<listitem><para>Similarly, configuration extension image files (suffix <literal>.confext.raw</literal>) |
| 766 |
that are placed in the <filename>/loader/extensions/</filename> directory in the file system the unified |
| 767 |
kernel image is placed in are copied into the <filename>/.extra/global_confext/</filename> |
| 768 |
directory in the initrd execution environment.</para> |
| 769 |
|
| 770 |
<xi:include href="version-info.xml" xpointer="v258"/></listitem> |
| 771 |
</varlistentry> |
| 772 |
|
| 773 |
<varlistentry> |
| 774 |
<term><filename>/.extra/tpm2-pcr-signature.json</filename></term> |
| 775 |
<listitem><para>The TPM2 PCR signature JSON object included in the <literal>.pcrsig</literal> PE |
| 776 |
section of the unified kernel image is copied into the |
| 777 |
<filename>/.extra/tpm2-pcr-signature.json</filename> file in the initrd execution environment.</para> |
| 778 |
|
| 779 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 780 |
</varlistentry> |
| 781 |
|
| 782 |
<varlistentry> |
| 783 |
<term><filename>/.extra/tpm2-pcr-public-key.pem</filename></term> |
| 784 |
<listitem><para>The PEM public key included in the <literal>.pcrpkey</literal> PE section of the |
| 785 |
unified kernel image is copied into the <filename>/.extra/tpm2-pcr-public-key.pem</filename> file in |
| 786 |
the initrd execution environment.</para> |
| 787 |
|
| 788 |
<xi:include href="version-info.xml" xpointer="v252"/></listitem> |
| 789 |
</varlistentry> |
| 790 |
|
| 791 |
<varlistentry> |
| 792 |
<term><filename>/.extra/profile</filename></term> |
| 793 |
<term><filename>/.extra/os-release</filename></term> |
| 794 |
<listitem><para>The contents of the <literal>.profile</literal> and <literal>.osrel</literal> |
| 795 |
sections of the selected profile, if any.</para> |
| 796 |
|
| 797 |
<xi:include href="version-info.xml" xpointer="v257"/></listitem> |
| 798 |
</varlistentry> |
| 799 |
|
| 800 |
<varlistentry> |
| 801 |
<term><filename>/.extra/boot-secret</filename></term> |
| 802 |
<listitem><para>A 32 byte per-system secret which is derived from a 32 byte secret stored in an EFI |
| 803 |
variable (<varname>LoaderBootSecret</varname>, see above), which itself is only accessible to the |
| 804 |
pre-boot environment. This may be used for various early-boot cryptographic purposes, and OS file |
| 805 |
system access to it is restricted to root. The <varname>IMAGE_ID=</varname>/<varname>ID=</varname> |
| 806 |
data from the <literal>.osrel</literal> is hashed into the secret, to ensure that different images |
| 807 |
get a distinct secret passed. Moreover, a randomized 32 byte value stored in the ESP in the |
| 808 |
<literal>/loader/boot-secret-mixin</literal> file is hashed in as well, ensuring that distinct disks will |
| 809 |
result in different boot secrets.</para> |
| 810 |
|
| 811 |
<para>Note: this boot secret is ultimately protected only by firmware-enforced access controls on the |
| 812 |
EFI variable. This is generally a much weaker protection than TPM-based approaches have, and it is |
| 813 |
hence strongly recommended to use the TPM on systems that possess one. The boot secret is primarily |
| 814 |
intended to be a lower-security fallback for cases where a TPM is not available.</para> |
| 815 |
|
| 816 |
<para>Applications should never protect resources directly with this secret, but derive their own |
| 817 |
secret from it (by hashing it together with some application ID, in HMAC mode for example), in order |
| 818 |
not to accidentally leak the primary boot secret.</para> |
| 819 |
|
| 820 |
<para>Note that the boot secret is only available if the pre-boot environment had a suitable RNG |
| 821 |
source at the current boot or an earlier one. This source can be an initialized on-disk |
| 822 |
random seed or the EFI RNG support, or both.</para> |
| 823 |
|
| 824 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 825 |
</varlistentry> |
| 826 |
</variablelist> |
| 827 |
|
| 828 |
<para>Note that all these files are located in the <literal>tmpfs</literal> file system the kernel sets |
| 829 |
up for the initrd file hierarchy and are thus lost when the system transitions from the initrd execution |
| 830 |
environment into the host file system. If these resources shall be kept around over this transition they |
| 831 |
need to be copied to a place that survives the transition first, for example via a suitable |
| 832 |
<citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> line. By |
| 833 |
default, this is done for the TPM2 PCR signature and public key files.</para> |
| 834 |
</refsect1> |
| 835 |
|
| 836 |
<refsect1> |
| 837 |
<title>SMBIOS Type 11 Strings</title> |
| 838 |
|
| 839 |
<para><command>systemd-stub</command> can be configured using SMBIOS Type 11 strings. Applicable strings |
| 840 |
consist of a name, followed by <literal>=</literal>, followed by the value. Unless |
| 841 |
<command>systemd-stub</command> detects it is running inside a confidential computing environment, |
| 842 |
<command>systemd-stub</command> will search the table for a string with a specific name, and if found, |
| 843 |
use its value. The following strings are read:</para> |
| 844 |
|
| 845 |
<variablelist> |
| 846 |
<varlistentry> |
| 847 |
<term><varname>io.systemd.stub.kernel-cmdline-extra</varname></term> |
| 848 |
<listitem><para>If set, the value of this string is added to the list of kernel command line |
| 849 |
arguments that are measured in PCR12 and passed to the kernel.</para> |
| 850 |
|
| 851 |
<xi:include href="version-info.xml" xpointer="v254"/></listitem> |
| 852 |
</varlistentry> |
| 853 |
|
| 854 |
<varlistentry> |
| 855 |
<term><varname>io.systemd.boot.loglevel</varname></term> |
| 856 |
<listitem><para>If set, the value of this string is used as log level. Valid values (from most to |
| 857 |
least critical) are <literal>emerg</literal>, <literal>alert</literal>, <literal>crit</literal>, |
| 858 |
<literal>err</literal>, <literal>warning</literal>, <literal>notice</literal>, <literal>info</literal>, |
| 859 |
and <literal>debug</literal>.</para> |
| 860 |
|
| 861 |
<xi:include href="version-info.xml" xpointer="v261"/></listitem> |
| 862 |
</varlistentry> |
| 863 |
</variablelist> |
| 864 |
</refsect1> |
| 865 |
|
| 866 |
<refsect1> |
| 867 |
<title>Assembling Kernel Images</title> |
| 868 |
|
| 869 |
<para>In order to assemble a bootable Unified Kernel Image from various components as described above, use |
| 870 |
<citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para> |
| 871 |
</refsect1> |
| 872 |
|
| 873 |
<refsect1> |
| 874 |
<title>See Also</title> |
| 875 |
<para><simplelist type="inline"> |
| 876 |
<member><citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 877 |
<member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member> |
| 878 |
<member><citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 879 |
<member><citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry></member> |
| 880 |
<member><ulink url="https://uapi-group.org/specifications/specs/boot_loader_specification">UAPI.1 Boot Loader Specification</ulink></member> |
| 881 |
<member><ulink url="https://systemd.io/BOOT_LOADER_INTERFACE">Boot Loader Interface</ulink></member> |
| 882 |
<member><citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 883 |
<member><citerefentry><refentrytitle>systemd-measure</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 884 |
<member><ulink url="https://systemd.io/TPM2_PCR_MEASUREMENTS">TPM2 PCR Measurements Made by systemd</ulink></member> |
| 885 |
</simplelist></para> |
| 886 |
</refsect1> |
| 887 |
</refentry> |