basic/linux: update kernel headers from v6.14-rc1
[systemd.io.git] / man / systemd-stub.xml
blob730d27cf6c392fa23183b03cdf0fa745b48de456
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 -->
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>
13   <refmeta>
14     <refentrytitle>systemd-stub</refentrytitle>
15     <manvolnum>7</manvolnum>
16   </refmeta>
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>
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     </simplelist></para>
40   </refsynopsisdiv>
42   <refsect1>
43     <title>Description</title>
45     <para><command>systemd-stub</command> (stored in per-architecture files
46     <filename>linuxx64.efi.stub</filename>, <filename>linuxia32.efi.stub</filename>,
47     <filename>linuxaa64.efi.stub</filename> on disk) is a simple UEFI boot stub. An UEFI boot stub is
48     attached to a Linux kernel binary image, and is a piece of code that runs in the UEFI firmware
49     environment before transitioning into the Linux kernel environment. The UEFI boot stub ensures a Linux
50     kernel is executable as regular UEFI binary, and is able to do various preparations before switching the
51     system into the Linux world.</para>
53     <para>The UEFI boot stub looks for various resources for the kernel invocation inside the UEFI PE binary
54     itself. This allows combining various resources inside a single PE binary image (a "Unified Kernel Image"
55     or "UKI" for short), which may then be signed via UEFI SecureBoot as a whole, covering all individual
56     resources at once. Specifically it may include the following PE sections:</para>
58     <itemizedlist>
59       <!-- Let's keep this in the canonical order we also measure the sections by, i.e. as in
60            src/fundamental/uki.h's UnifiedSection enum -->
62       <listitem><para>A <literal>.linux</literal> section with the ELF Linux kernel image.
63       This section is required.</para></listitem>
65       <listitem><para>An optional <literal>.osrel</literal> section with OS release information, i.e. the
66       contents of the
67       <citerefentry><refentrytitle>os-release</refentrytitle><manvolnum>5</manvolnum></citerefentry> file of
68       the OS the kernel belongs to.</para></listitem>
70       <listitem><para>An optional <literal>.cmdline</literal> section with the kernel command line to pass to
71       the invoked kernel.</para></listitem>
73       <listitem><para>An optional <literal>.initrd</literal> section with the initrd.</para></listitem>
75       <listitem><para>An optional <literal>.ucode</literal> section with an initrd containing microcode, to
76       be handed to the kernel before any other initrd. This initrd must not be compressed.</para></listitem>
78       <listitem><para>An optional <literal>.splash</literal> section with an image (in the Windows
79       <filename>.BMP</filename> format) to show on screen before invoking the kernel.</para></listitem>
81       <listitem><para>An optional <literal>.dtb</literal> section with a compiled binary DeviceTree.
82       </para></listitem>
84       <listitem><para>Zero or more <literal>.dtbauto</literal> sections. <command>systemd-stub</command>
85       will always use the first matching one. The match is performed by taking the first DeviceTree's
86       <literal>compatible</literal> string supplied by the firmware in configuration tables and comparing it
87       with the first <literal>compatible</literal> string from each of the <literal>.dtbauto</literal>
88       sections. If the firmware does not provide a DeviceTree, the match is done using the
89       <literal>.hwids</literal> section instead. After selecting a <literal>.hwids</literal> section (see the
90       description below), the <literal>compatible</literal> string from that section will be used to perform
91       the same matching procedure. If a match is found, that <literal>.dtbauto</literal> section will be
92       loaded and will override <literal>.dtb</literal> if present.</para></listitem>
94       <listitem><para>Zero or more <literal>.efifw</literal> sections for the firmware image. It works
95       in many ways similar to <literal>.dtbauto</literal> sections. <command>systemd-stub</command>
96       will always use the first matching one. The match is performed by first selecting the most appropriate
97       entry in the <literal>.hwids</literal> section based on the hardware IDs supplied by SMBIOS (see below).
98       If a suitable entry is found, the <literal>fwid</literal> string from that entry will be used to
99       perform the matching procedure for firmware blobs in <literal>.efifw</literal> section. The first
100       matching firmware will be loaded.
101       </para></listitem>
103       <listitem><para>Zero or more <literal>.hwids</literal> sections with hardware IDs of the machines to
104       match DeviceTrees. <command>systemd-stub</command> will use the SMBIOS data to calculate hardware IDs
105       of the machine (as per <ulink
106       url="https://learn.microsoft.com/en-us/windows-hardware/drivers/install/specifying-hardware-ids-for-a-computer">specification</ulink>),
107       and then it will try to find any of them in each of the <literal>.hwids</literal> sections. The first
108       matching section will be used.</para></listitem>
110       <listitem><para>An optional <literal>.uname</literal> section with the kernel version information, i.e.
111       the output of <command>uname -r</command> for the kernel included in the <literal>.linux</literal>
112       section.</para></listitem>
114       <listitem><para>An optional <literal>.sbat</literal> section with
115       <ulink url="https://github.com/rhboot/shim/blob/main/SBAT.md">SBAT</ulink> revocation metadata.
116       </para></listitem>
118       <listitem><para>An optional <literal>.pcrsig</literal> section with a set of cryptographic signatures
119       for the expected TPM2 PCR values after the kernel has been booted, in JSON format. This is useful for
120       implementing TPM2 policies that bind disk encryption and similar to kernels that are signed by a
121       specific key.</para></listitem>
123       <listitem><para>An optional <literal>.pcrpkey</literal> section with a public key in the PEM format
124       matching the signature data in the <literal>.pcrsig</literal> section.</para></listitem>
125     </itemizedlist>
127     <!-- FIXME: how does .dtauto/.hwids matching interact with profiles? -->
129     <para>In a basic UKI, the sections listed above appear at most once, with the exception of
130     <literal>.dtbauto</literal> and <literal>.hwids</literal> sections. In a multi-profile UKI,
131     multiple sets of these sections are present in a single file and form "profiles",
132     one of which can be selected at boot. For this, the PE section <literal>.profile</literal> is
133     defined to be used as the separator between sets of sections. The
134     <literal>.profile</literal> section itself may contain meta-information about the section, and follows a
135     similar structure as the contents of the <literal>.osrel</literal> section. For further details about
136     multi-profile UKIs, see below.</para> <para>If UEFI SecureBoot is enabled and the
137     <literal>.cmdline</literal> section is present in the executed image, any attempts to override the kernel
138     command line by passing one as invocation parameters to the EFI binary are ignored. Thus, in order to
139     allow overriding the kernel command line, either disable UEFI SecureBoot, or do not include a kernel
140     command line PE section in the kernel image file. If a command line is accepted via EFI invocation
141     parameters to the EFI binary it is measured into TPM PCR 12 (if a TPM is present).</para> <para>If a
142     DeviceTree is embedded in the <literal>.dtb</literal> section, it replaces an existing DeviceTree in the
143     corresponding EFI configuration table. systemd-stub will ask the firmware via the
144     <literal>EFI_DT_FIXUP_PROTOCOL</literal> for hardware specific fixups to the DeviceTree.</para> <para>The
145     contents of 11 of these 12 sections are measured into TPM PCR 11. It is otherwise not used and thus the
146     result can be pre-calculated without too much effort. The <literal>.pcrsig</literal> section is not
147     included in this PCR measurement, since it is supposed to contain signatures for the output of the
148     measurement operation, and thus cannot also be input to it. If an UKI contains multiple profiles, only
149     the PE sections of the selected profile (and those of the base profile, except if overridden) are
150     measured.</para>
152     <para>If non-zero, the selected numeric profile is measured into PCR 12.</para>
154     <para>When <literal>.pcrsig</literal> and/or <literal>.pcrpkey</literal> sections are present in a
155     unified kernel image their contents are passed to the booted kernel in an synthetic initrd cpio archive
156     that places them in the <filename>/.extra/tpm2-pcr-signature.json</filename> and
157     <filename>/.extra/tpm2-pcr-public-key.pem</filename> files. Typically, a
158     <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> line then
159     ensures they are copied into <filename>/run/systemd/tpm2-pcr-signature.json</filename> and
160     <filename>/run/systemd/tpm2-pcr-public-key.pem</filename> where they remain accessible even after the
161     system transitions out of the initrd environment into the host file system. Tools such
162     <citerefentry><refentrytitle>systemd-cryptsetup@.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>,
163     <citerefentry><refentrytitle>systemd-cryptenroll</refentrytitle><manvolnum>1</manvolnum></citerefentry>
164     and <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>
165     will automatically use files present under these paths to unlock protected resources (encrypted storage
166     or credentials) or bind encryption to booted kernels.</para>
168     <para>For further details about the UKI concept, see the <ulink
169     url="https://uapi-group.org/specifications/specs/unified_kernel_image/">UKI specification</ulink>.</para>
170   </refsect1>
172   <refsect1>
173     <title>Companion Files</title>
175     <para>The <command>systemd-stub</command> UEFI boot stub automatically collects three types of auxiliary
176     companion files optionally placed in drop-in directories on the same partition as the EFI binary,
177     dynamically generates <command>cpio</command> initrd archives from them, and passes them to the kernel.
178     Specifically:</para>
180     <itemizedlist>
181       <listitem><para>For a kernel binary called <filename><replaceable>foo</replaceable>.efi</filename>, it
182       will look for files with the <filename>.cred</filename> suffix in a directory named
183       <filename><replaceable>foo</replaceable>.efi.extra.d/</filename> next to it. If the kernel binary
184       uses a counter for the purpose of
185       <ulink url="https://systemd.io/AUTOMATIC_BOOT_ASSESSMENT">Automatic Boot Assessment</ulink>, this
186       counter will be ignored. For example, <filename><replaceable>foo</replaceable>+3-0.efi</filename>
187       will look in directory <filename><replaceable>foo</replaceable>.efi.extra.d/</filename>.
188       A <command>cpio</command>
189       archive is generated from all files found that way, placing them in the
190       <filename>/.extra/credentials/</filename> directory of the initrd file hierarchy. The main initrd may
191       then access them in this directory. This is supposed to be used to store auxiliary, encrypted,
192       authenticated credentials for use with <varname>LoadCredentialEncrypted</varname> in the UEFI System
193       Partition. See
194       <citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry>
195       and
196       <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry>
197       for
198       details on encrypted credentials. The generated <command>cpio</command> archive is measured into TPM
199       PCR 12 (if a TPM is present).</para></listitem>
201       <listitem><para>Similarly, files
202       <filename><replaceable>foo</replaceable>.efi.extra.d/*.sysext.raw</filename> are packed up in a
203       <command>cpio</command> archive and placed in the <filename>/.extra/sysext/</filename> directory in the
204       initrd file hierarchy. This is supposed to be used to pass additional system extension images to the
205       initrd. See
206       <citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
207       details on system extension images. The generated <command>cpio</command> archive containing these
208       system extension images is measured into TPM PCR 13 (if a TPM is present).</para></listitem>
210       <!-- Note: the actual suffix we look for for sysexts is just *.raw (not *.sysext.raw), for
211            compatibility reasons with old versions. But we want people to name their system extensions
212            properly, hence we document the *.sysext.raw suffix only. -->
214       <listitem><para>Similarly, files
215       <filename><replaceable>foo</replaceable>.efi.extra.d/*.confext.raw</filename> are packed up in a
216       <command>cpio</command> archive and placed in the <filename>/.extra/confext/</filename> directory in
217       the initrd file hierarchy. This is supposed to be used to pass additional configuration extension
218       images to the initrd. See
219       <citerefentry><refentrytitle>systemd-confext</refentrytitle><manvolnum>8</manvolnum></citerefentry> for
220       details on configuration extension images. The generated <command>cpio</command> archive containing
221       these configuration extension images is measured into TPM PCR 12 (if a TPM is present).</para></listitem>
223       <listitem><para>Similarly, files
224       <filename><replaceable>foo</replaceable>.efi.extra.d/*.addon.efi</filename> are loaded and verified as
225       PE binaries and specific sections are loaded from them. Addons are used to pass additional kernel
226       command line parameters (<literal>.cmdline</literal> section), or DeviceTree blobs
227       (<literal>.dtb</literal> section), additional initrds (<literal>.initrd</literal> section),
228       and microcode updates (<literal>.ucode</literal> section). Addons allow those resources to be passed
229       regardless of the kernel version being booted, for example allowing platform vendors to ship
230       platform-specific configuration.</para>
232       <para>In case Secure Boot is enabled, these files will be validated using keys in UEFI DB, Shim's DB or
233       Shim's MOK, and only loaded if the check passes. Additionally, if both the addon and the UKI contain a
234       <literal>.uname</literal> section, the addon will be rejected if they do not match exactly. It is
235       recommended to always add a <literal>.sbat</literal> section to all signed addons, so that they may be
236       revoked with a SBAT policy update, without requiring blocklisting via DBX/MOKX. The
237       <citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry> tool will add
238       a SBAT policy by default if none is passed when building addons. For more information on SBAT see
239       <ulink url="https://github.com/rhboot/shim/blob/main/SBAT.md">Shim documentation</ulink>.</para>
241       <para>Addon files are sorted, loaded, and measured into TPM PCR 12 (if a TPM is present) and appended
242       to the kernel command line. UKI command line options are listed first, then options from addons in
243       <filename>/loader/addons/*.addon.efi</filename>, and finally UKI-specific addons. Device tree blobs are
244       loaded and measured following the same algorithm. Microcode addons are passed to the kernel in inverse
245       order (UKI specific addons, global addons, UKI embedded section). This is because the microcode update
246       driver stops on the first matching filename. Addons are always loaded in the same order based on
247       the filename, so that, given the same set of addons, the same set of measurements can be expected in
248       PCR12. However, note that the filename is not protected by the PE signature, and as such an attacker
249       with write access to the ESP could potentially rename these files to change the order in which they are
250       loaded, in a way that could alter the functionality of the kernel, as some options might be
251       order-dependent. If you sign such addons, you should pay attention to the PCR12 values and make use of
252       an attestation service so that improper use of your signed addons can be detected and dealt with using
253       one of the aforementioned revocation mechanisms.</para></listitem>
255       <listitem><para>Files <filename>/loader/credentials/*.cred</filename> are packed up in a
256       <command>cpio</command> archive and placed in the <filename>/.extra/global_credentials/</filename>
257       directory of the initrd file hierarchy. This is supposed to be used to pass additional credentials to
258       the initrd, regardless of the kernel version being booted. The generated <command>cpio</command>
259       archive is measured into TPM PCR 12 (if a TPM is present).</para></listitem>
261       <listitem><para>Additionally, files <filename>/loader/addons/*.addon.efi</filename> are loaded and
262       verified as PE binaries, and <literal>.cmdline</literal>, <literal>.dtb</literal>,
263       <literal>.initrd</literal>, and <literal>.ucode</literal> sections are parsed from them.
264       This is supposed to be used to pass additional command line parameters, DeviceTree blobs, initrds,
265       and microcode updates to the kernel, regardless of the kernel version being booted.</para></listitem>
266     </itemizedlist>
268     <para>These mechanisms may be used to parameterize and extend trusted (i.e. signed), immutable initrd
269     images in a reasonably safe way: all data they contain is measured into TPM PCRs. On access they should be
270     further validated: in case of the credentials case by encrypting/authenticating them via TPM, as exposed
271     by <command>systemd-creds encrypt -T</command> (see
272     <citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry> for
273     details); in case of the system extension images by using signed Verity images.</para>
274   </refsect1>
276   <refsect1>
277     <title>Multi-Profile UKIs</title>
279     <para>In many contexts it is useful to allow invocation of a single UKI in multiple different modes (or
280     "profiles") without compromising the cryptographic integrity, measurements and so on of the boot
281     process. For example, a single UKI might provide three distinct profiles: a regular boot one, one that
282     invokes a "factory reset" operation, and one that boots into a storage target mode (as in
283     <citerefentry><refentrytitle>systemd-storagetm.service</refentrytitle><manvolnum>8</manvolnum></citerefentry>). Each
284     profile would then use the same <literal>.linux</literal> and <literal>.initrd</literal> sections, but would
285     have a separate <literal>.cmdline</literal> section. For example the latter two profiles would extend the
286     regular kernel command line with <literal>systemd.unit=factory-reset.target</literal> or
287     <literal>rd.systemd.unit=storagetm.target</literal>.</para>
289     <para>A single UKI may support multiple profiles by means of the special <literal>.profile</literal> PE
290     section. This section acts as separator between the PE sections of the individual
291     profiles. <literal>.profile</literal> PE sections hence may appear multiple times in a single UKI, and
292     the other PE sections listed above may appear multiple times too, if <literal>.profile</literal> are
293     used, but only once before the first <literal>.profile</literal> section, once between each subsequent
294     pair, and once after the last appearance of <literal>.profile</literal>. The sections listed before the
295     first <literal>.profile</literal> are considered the "base" profile of the UKI. Each
296     <literal>.profile</literal> section then introduces a new profile, which are numbered starting from
297     zero. The PE sections following each <literal>.profile</literal> are specific to that profile. When
298     booting into a specific profile the base section's profiles are used in combination with the specific
299     profile's sections: if the same section is defined in both, the per-profile section overrides the base
300     profile's version, otherwise the per-profile sections is used together with the base profile
301     sections.</para> <para>A UKI that contains no <literal>.profile</literal> is consider equivalent to one
302     that just contains a single <literal>.profile</literal>, as having only a single profile @0.</para>
304     <para>Here's a simple example for a multi-profile UKI's sections, inspired by the setup suggested above:</para>
306     <table>
307       <title>Multi-Profile UKI Example</title>
309       <tgroup cols='2' align='left' colsep='1' rowsep='1'>
310         <colspec colname="section" />
311         <colspec colname="profile" />
313         <thead>
314           <row>
315             <entry>Section</entry>
316             <entry>Profile</entry>
317           </row>
318         </thead>
320         <tbody>
321           <row>
322             <entry><literal>.linux</literal></entry>
323             <entry morerows="3" valign="middle">Base profile</entry>
324           </row>
325           <row>
326             <entry><literal>.osrel</literal></entry>
327           </row>
328           <row>
329             <entry><literal>.cmdline</literal></entry>
330           </row>
331           <row>
332             <entry><literal>.initrd</literal></entry>
333           </row>
334           <row>
335             <entry><literal>.profile</literal></entry>
336             <entry>Profile @0</entry>
337           </row>
338           <row>
339             <entry><literal>.profile</literal></entry>
340             <entry morerows="1" valign="middle">Profile @1</entry>
341           </row>
342           <row>
343             <entry><literal>.cmdline</literal></entry>
344           </row>
345           <row>
346             <entry><literal>.profile</literal></entry>
347             <entry morerows="1" valign="middle">Profile @2</entry>
348           </row>
349           <row>
350             <entry><literal>.cmdline</literal></entry>
351           </row>
352         </tbody>
353       </tgroup>
354     </table>
356     <para>The section list above would define three profiles. The first four sections make up the base
357     profile. A <literal>.profile</literal> section then introduces profile @0. It does not override any
358     sections (or add any) from the base section, hence it is immediately followed by another
359     <literal>.profile</literal> section that then introduces section @1. This profile overrides the kernel
360     command line. Finally, the last two sections define section @2, again overriding the command line. (Note
361     that in this example the first <literal>.cmdline</literal> could also moved behind the first
362     <literal>.profile</literal> with equivalent effect. To keep things nicely extensible, it is probably a
363     good idea to keep the generic command line in the base section instead of profile 0, in case later added
364     profiles might want to reuse it.)</para>
366     <para>The profile to boot may be controlled via the UKI's own command line: if the first argument starts
367     with <literal>@</literal>, followed by a positive integer number in decimal, it selects the profile to
368     boot into. If the first argument is not specified like that, the UKI will automatically boot into profile
369     0.</para>
371     <para>A <literal>.profile</literal> section may contain meta-information about the profile. It follows a
372     similar format as <literal>.osrel</literal> (i.e. an environment-variable-assignment-block-like list of
373     newline separated strings). Currently two fields are defined: <literal>ID=</literal> is supposed to carry
374     a short identifying string that identifies the profile
375     (e.g. <literal>ID=factory-reset</literal>). <literal>TITLE=</literal> should contain a human readable
376     string that may appear in the boot menu entry for this profile (e.g. <literal>TITLE='Factory Reset this
377     Device'</literal>).</para>
378   </refsect1>
380   <refsect1>
381     <title>TPM PCR Notes</title>
383     <para>Note that when a unified kernel using <command>systemd-stub</command> is invoked the firmware will
384     measure it as a whole to TPM PCR 4, covering all embedded resources, such as the stub code itself, the
385     core kernel, the embedded initrd and kernel command line (see above for a full list), including all UKI
386     profiles.</para>
388     <para>Also note that when <command>systemd-stub</command> measures a PE section, it will measure the
389     amount of bytes that the section takes up in memory (<varname>VirtualSize</varname>) and not the amount
390     of bytes that the section takes up on disk (<varname>SizeOfRawData</varname>). This means that if the
391     size in memory is larger than the size on disk, <command>systemd-stub</command> will end up measuring
392     extra zeroes. To avoid this from happening, it is recommended to make sure that the size in memory of
393     each section that is measured by <command>systemd-stub</command> is always smaller than or equal to the
394     size on disk. <command>ukify</command> automatically makes sure this is the case when building UKIs or
395     addons.</para>
397     <para>Also note that the Linux kernel will measure all initrds it receives into TPM PCR 9. This means
398     every type of initrd (of the selected UKI profile) will possibly be measured two or three times: the
399     initrds embedded in the kernel image will be measured to PCR 4, PCR 9 and PCR 11; the initrd synthesized
400     from credentials (and the one synthesized from configuration extensions) will be measured to both PCR 9
401     and PCR 12; the initrd synthesized from system extensions will be measured to both PCR 4 and PCR 9. Let's
402     summarize the OS resources and the PCRs they are measured to:</para>
404     <table>
405       <title>OS Resource PCR Summary</title>
407       <tgroup cols='2' align='left' colsep='1' rowsep='1'>
408         <colspec colname="pcr" />
409         <colspec colname="definition" />
411         <thead>
412           <row>
413             <entry>OS Resource</entry>
414             <entry>Measurement PCR</entry>
415           </row>
416         </thead>
418         <tbody>
419           <row>
420             <entry><command>systemd-stub</command> code (the entry point of the unified PE binary)</entry>
421             <entry>4</entry>
422           </row>
424           <row>
425             <entry>Core kernel code (embedded in unified PE binary)</entry>
426             <entry>4 + 11</entry>
427           </row>
429           <row>
430             <entry>OS release information (embedded in the unified PE binary)</entry>
431             <entry>4 + 11</entry>
432           </row>
434           <row>
435             <entry>Main initrd (embedded in unified PE binary)</entry>
436             <entry>4 + 9 + 11</entry>
437           </row>
439           <row>
440             <entry>Microcode initrd (embedded in unified PE binary)</entry>
441             <entry>4 + 9 + 11</entry>
442           </row>
444           <row>
445             <entry>Default kernel command line (embedded in unified PE binary)</entry>
446             <entry>4 + 11</entry>
447           </row>
449           <row>
450             <entry>Overridden kernel command line</entry>
451             <entry>12</entry>
452           </row>
454           <row>
455             <entry>Boot splash (embedded in the unified PE binary)</entry>
456             <entry>4 + 11</entry>
457           </row>
459           <row>
460             <entry>TPM2 PCR signature JSON (embedded in unified PE binary, synthesized into initrd)</entry>
461             <entry>4 + 9</entry>
462           </row>
464           <row>
465             <entry>TPM2 PCR PEM public key (embedded in unified PE binary, synthesized into initrd)</entry>
466             <entry>4 + 9 + 11</entry>
467           </row>
469           <row>
470             <entry>Credentials (synthesized initrd from companion files)</entry>
471             <entry>9 + 12</entry>
472           </row>
474           <row>
475             <entry>System Extensions (synthesized initrd from companion files)</entry>
476             <entry>9 + 13</entry>
477           </row>
479           <row>
480             <entry>Configuration Extensions (synthesized initrd from companion files)</entry>
481             <entry>9 + 12</entry>
482           </row>
484           <row>
485             <entry>Selected profile unless zero</entry>
486             <entry>12</entry>
487           </row>
488         </tbody>
489       </tgroup>
490     </table>
491   </refsect1>
493   <refsect1>
494     <title>EFI Variables</title>
496     <para>The following EFI variables are defined, set and read by <command>systemd-stub</command>, under the
497     vendor UUID <literal>4a67b082-0a4c-41cf-b6c7-440b29bb8c4f</literal>, for communication between the boot
498     stub and the OS:</para>
500     <variablelist class='efi-variables'>
501       <varlistentry>
502         <term><varname>LoaderDevicePartUUID</varname></term>
504         <listitem><para>Contains the partition UUID of the partition the boot loader has been started from on
505         the current boot (usually a EFI System Partition). If already set by the boot loader, this will
506         remain untouched by <command>systemd-stub</command>. If not set yet, this will be set to the
507         partition UUID of the partition the unified kernel is started from, in order to support systems that
508         directly boot into a unified kernel image, bypassing any boot loader.
509         <citerefentry><refentrytitle>systemd-gpt-auto-generator</refentrytitle><manvolnum>8</manvolnum></citerefentry>
510         uses this information to automatically find the disk booted from, in order to discover various other
511         partitions on the same disk automatically.</para>
513         <xi:include href="version-info.xml" xpointer="v224"/></listitem>
514       </varlistentry>
516       <varlistentry>
517         <term><varname>LoaderFirmwareInfo</varname></term>
518         <term><varname>LoaderFirmwareType</varname></term>
520         <listitem><para>Brief firmware information. Use
521         <citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view this
522         data.</para>
524         <xi:include href="version-info.xml" xpointer="v250"/></listitem>
525       </varlistentry>
527       <varlistentry>
528         <term><varname>LoaderImageIdentifier</varname></term>
530         <listitem><para>The file system path to the EFI executable of the boot loader for the current boot,
531         relative to the partition's root directory (i.e. relative to the partition indicated by
532         <varname>LoaderDevicePartUUID</varname>, see above). If not set yet, this will be set to the file
533         system path of the EFI executable of the booted unified kernel, in order to support systems that
534         directly boot into a unified kernel image, bypassing any boot loader.  Use
535         <citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view
536         this data.</para>
538         <xi:include href="version-info.xml" xpointer="v237"/></listitem>
539       </varlistentry>
541       <varlistentry>
542         <term><varname>StubDevicePartUUID</varname></term>
543         <term><varname>StubImageIdentifier</varname></term>
545         <listitem><para>Similar to <varname>LoaderDevicePartUUID</varname> and
546         <varname>StubImageIdentifier</varname>, but indicates the location of the unified kernel image EFI
547         binary rather than the location of the boot loader binary, regardless of whether booted via a boot loader
548         or not.</para>
550         <xi:include href="version-info.xml" xpointer="v257"/></listitem>
551       </varlistentry>
553       <varlistentry>
554         <term><varname>StubInfo</varname></term>
556         <listitem><para>Brief stub information. Use
557         <citerefentry><refentrytitle>bootctl</refentrytitle><manvolnum>1</manvolnum></citerefentry> to view
558         this data.</para>
560         <xi:include href="version-info.xml" xpointer="v250"/></listitem>
561       </varlistentry>
563       <varlistentry>
564         <term><varname>StubPcrKernelImage</varname></term>
566         <listitem><para>The PCR register index the kernel image, initrd image, boot splash, devicetree
567         database, and the embedded command line are measured into, formatted as decimal ASCII string (e.g.
568         <literal>11</literal>). This variable is set if a measurement was successfully completed, and remains
569         unset otherwise.</para>
571         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
572       </varlistentry>
574       <varlistentry>
575         <term><varname>StubPcrKernelParameters</varname></term>
577         <listitem><para>The PCR register index the kernel command line and credentials are measured into,
578         formatted as decimal ASCII string (e.g. <literal>12</literal>). This variable is set if a measurement
579         was successfully completed, and remains unset otherwise.</para>
581         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
582       </varlistentry>
584       <varlistentry>
585         <term><varname>StubPcrInitRDSysExts</varname></term>
587         <listitem><para>The PCR register index the system extensions for the initrd, which are picked up from
588         the file system the kernel image is located on. Formatted as decimal ASCII string (e.g.
589         <literal>13</literal>). This variable is set if a measurement was successfully completed, and remains
590         unset otherwise.</para>
592         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
593       </varlistentry>
595       <varlistentry>
596         <term><varname>StubPcrInitRDConfExts</varname></term>
598         <listitem><para>The PCR register index the configuration extensions for the initrd, which are picked
599         up from the file system the kernel image is located on. Formatted as decimal ASCII string (e.g.
600         <literal>12</literal>). This variable is set if a measurement was successfully completed, and remains
601         unset otherwise.</para>
603         <xi:include href="version-info.xml" xpointer="v255"/></listitem>
604       </varlistentry>
606       <varlistentry>
607         <term><varname>StubProfile</varname></term>
609         <listitem><para>The numeric index of the selected profile, without the <literal>@</literal>,
610         formatted as decimal string. Set both on single-profile and multi-profile UKIs. (In the former case
611         this variable will be set to <literal>0</literal> unconditionally.)</para>
613         <xi:include href="version-info.xml" xpointer="v257"/></listitem>
614       </varlistentry>
615     </variablelist>
617     <para>Note that some of the variables above may also be set by the boot loader. The stub will only set
618     them if they are not set already. Some of these variables are defined by the <ulink
619     url="https://systemd.io/BOOT_LOADER_INTERFACE">Boot Loader Interface</ulink>.</para>
620   </refsect1>
622   <refsect1>
623     <title>initrd Resources</title>
625     <para>The following resources are passed as initrd cpio archives to the booted kernel, and thus make up
626     the initial file system hierarchy in the initrd execution environment:</para>
628     <variablelist>
629       <varlistentry>
630         <term><filename>/</filename></term>
632         <listitem><para>The main initrd from the <literal>.initrd</literal> PE section of the unified kernel
633         image.</para>
635         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
636       </varlistentry>
638       <varlistentry>
639         <term><filename>/.extra/credentials/*.cred</filename></term>
640         <listitem><para>Credential files (suffix <literal>.cred</literal>) that are placed next to the
641         unified kernel image (as described above) are copied into the
642         <filename>/.extra/credentials/</filename> directory in the initrd execution
643         environment.</para>
645         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
646       </varlistentry>
648       <varlistentry>
649         <term><filename>/.extra/global_credentials/*.cred</filename></term>
650         <listitem><para>Similarly, credential files in the <filename>/loader/credentials/</filename>
651         directory in the file system the unified kernel image is placed in are copied into the
652         <filename>/.extra/global_credentials/</filename> directory in the initrd execution
653         environment.</para>
655         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
656       </varlistentry>
658       <varlistentry>
659         <term><filename>/.extra/sysext/*.sysext.raw</filename></term>
660         <listitem><para>System extension image files (suffix <literal>.sysext.raw</literal>) that are placed
661         next to the unified kernel image (as described above) are copied into the
662         <filename>/.extra/sysext/</filename> directory in the initrd execution environment.</para>
664         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
665       </varlistentry>
667       <varlistentry>
668         <term><filename>/.extra/confext/*.confext.raw</filename></term>
669         <listitem><para>Configuration extension image files (suffix <literal>.confext.raw</literal>) that are
670         placed next to the unified kernel image (as described above) are copied into the
671         <filename>/.extra/confext/</filename> directory in the initrd execution environment.</para>
673         <xi:include href="version-info.xml" xpointer="v255"/></listitem>
674       </varlistentry>
676       <varlistentry>
677         <term><filename>/.extra/tpm2-pcr-signature.json</filename></term>
678         <listitem><para>The TPM2 PCR signature JSON object included in the <literal>.pcrsig</literal> PE
679         section of the unified kernel image is copied into the
680         <filename>/.extra/tpm2-pcr-signature.json</filename> file in the initrd execution environment.</para>
682         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
683       </varlistentry>
685       <varlistentry>
686         <term><filename>/.extra/tpm2-pcr-public-key.pem</filename></term>
687         <listitem><para>The PEM public key included in the <literal>.pcrpkey</literal> PE section of the
688         unified kernel image is copied into the <filename>/.extra/tpm2-pcr-public-key.pem</filename> file in
689         the initrd execution environment.</para>
691         <xi:include href="version-info.xml" xpointer="v252"/></listitem>
692       </varlistentry>
694       <varlistentry>
695         <term><filename>/.extra/profile</filename></term>
696         <term><filename>/.extra/os-release</filename></term>
697         <listitem><para>The contents of the <literal>.profile</literal> and <literal>.osrel</literal>
698         sections of the selected profile, if any.</para>
700         <xi:include href="version-info.xml" xpointer="v257"/></listitem>
701       </varlistentry>
702     </variablelist>
704     <para>Note that all these files are located in the <literal>tmpfs</literal> file system the kernel sets
705     up for the initrd file hierarchy and are thus lost when the system transitions from the initrd execution
706     environment into the host file system. If these resources shall be kept around over this transition they
707     need to be copied to a place that survives the transition first, for example via a suitable
708     <citerefentry><refentrytitle>tmpfiles.d</refentrytitle><manvolnum>5</manvolnum></citerefentry> line. By
709     default, this is done for the TPM2 PCR signature and public key files.</para>
710   </refsect1>
712   <refsect1>
713     <title>SMBIOS Type 11 Strings</title>
715     <para><command>systemd-stub</command> can be configured using SMBIOS Type 11 strings. Applicable strings
716     consist of a name, followed by <literal>=</literal>, followed by the value. Unless
717     <command>systemd-stub</command> detects it is running inside a confidential computing environment,
718     <command>systemd-stub</command> will search the table for a string with a specific name, and if found,
719     use its value. The following strings are read:</para>
721     <variablelist>
722       <varlistentry>
723         <term><varname>io.systemd.stub.kernel-cmdline-extra</varname></term>
724         <listitem><para>If set, the value of this string is added to the list of kernel command line
725         arguments that are measured in PCR12 and passed to the kernel.</para>
727         <xi:include href="version-info.xml" xpointer="v254"/></listitem>
728       </varlistentry>
729     </variablelist>
730   </refsect1>
732   <refsect1>
733     <title>Assembling Kernel Images</title>
735     <para>In order to assemble a bootable Unified Kernel Image from various components as described above, use
736     <citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
737   </refsect1>
739   <refsect1>
740     <title>See Also</title>
741     <para><simplelist type="inline">
742       <member><citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry></member>
743       <member><citerefentry><refentrytitle>systemd.exec</refentrytitle><manvolnum>5</manvolnum></citerefentry></member>
744       <member><citerefentry><refentrytitle>systemd-creds</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
745       <member><citerefentry><refentrytitle>systemd-sysext</refentrytitle><manvolnum>8</manvolnum></citerefentry></member>
746       <member><ulink url="https://uapi-group.org/specifications/specs/boot_loader_specification">Boot Loader Specification</ulink></member>
747       <member><ulink url="https://systemd.io/BOOT_LOADER_INTERFACE">Boot Loader Interface</ulink></member>
748       <member><citerefentry><refentrytitle>ukify</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
749       <member><citerefentry><refentrytitle>systemd-measure</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
750       <member><ulink url="https://systemd.io/TPM2_PCR_MEASUREMENTS">TPM2 PCR Measurements Made by systemd</ulink></member>
751     </simplelist></para>
752   </refsect1>
753 </refentry>