]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemd-boot: Add support for reading extra kernel cmdline from SMBIOS
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 10 Mar 2024 15:24:37 +0000 (16:24 +0100)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sun, 10 Mar 2024 15:30:34 +0000 (16:30 +0100)
Same as io.systemd.stub.kernel-cmdline-extra, but for type 1 entries
booted by systemd-boot.

man/smbios-type-11.xml
man/systemd-boot.xml
src/boot/efi/boot.c
src/vmspawn/vmspawn.c

index 93252274da14ca9e3e7964d14052172fc99ff8bc..2fc215ecbd4e8b72d5ae27c254249d32b780a62a 100644 (file)
 
         <xi:include href="version-info.xml" xpointer="v254"/></listitem>
       </varlistentry>
+
+      <varlistentry>
+        <term><varname>io.systemd.boot.kernel-cmdline-extra=</varname><replaceable>CMDLINE</replaceable></term>
+
+        <listitem><para>This allows configuration of additional kernel command line options for Boot Loader
+        Specification Type 1 entries, and is read by <command>systemd-boot</command>. For details see
+        <citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>1</manvolnum></citerefentry>.</para>
+
+        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
 
index 74514fb5d06f92153fb09b4ab5c7d0c93a397818..9ada3f20916e40358d06d367deb659b51200dabe 100644 (file)
     url="https://systemd.io/BOOT_LOADER_INTERFACE">Boot Loader Interface</ulink>.</para>
   </refsect1>
 
+  <refsect1>
+    <title>SMBIOS Type 11 Strings</title>
+
+    <para><command>systemd-boot</command> can be configured using SMBIOS Type 11 strings. Applicable strings
+    consist of a name, followed by <literal>=</literal>, followed by the value.
+    <command>systemd-boot</command> will search the table for a string with a specific name, and if found,
+    use its value. The following strings are read:</para>
+
+    <variablelist>
+      <varlistentry>
+        <term><varname>io.systemd.boot.kernel-cmdline-extra</varname></term>
+        <listitem><para>If set, the value of this string is added to the list of kernel command line
+        arguments for Boot Loader Specification Type 1 entries that are measured in PCR12 and passed to the
+        kernel.</para>
+
+        <xi:include href="version-info.xml" xpointer="v256"/></listitem>
+      </varlistentry>
+    </variablelist>
+  </refsect1>
+
   <refsect1>
     <title>Boot Counting</title>
 
index eba8b40e2ffca29b2cac2373d42c3e8a0e7389cc..d64e560a52788a9c8fb281491397ca3c29d7319d 100644 (file)
@@ -2374,7 +2374,16 @@ static EFI_STATUS image_start(
         /* If we had to append an initrd= entry to the command line, we have to pass it, and measure it.
          * Otherwise, only pass/measure it if it is not implicit anyway (i.e. embedded into the UKI or
          * so). */
-        char16_t *options = options_initrd ?: entry->options_implied ? NULL : entry->options;
+        _cleanup_free_ char16_t *options = xstrdup16(options_initrd ?: entry->options_implied ? NULL : entry->options);
+
+        if (!is_confidential_vm()) {
+                const char *extra = smbios_find_oem_string("io.systemd.boot.kernel-cmdline-extra");
+                if (extra) {
+                        _cleanup_free_ char16_t *tmp = TAKE_PTR(options), *extra16 = xstr8_to_16(extra);
+                        options = xasprintf("%ls %ls", tmp, extra16);
+                }
+        }
+
         if (options) {
                 loaded_image->LoadOptions = options;
                 loaded_image->LoadOptionsSize = strsize16(options);
index 6197f00a3c10c15dc5ab0f0b59cba3fd8ba33b0c..967f701e05c7383ab3e22dc76573f0fa12ba1b08 100644 (file)
@@ -1570,6 +1570,10 @@ static int run_virtual_machine(int kvm_device_fd, int vhost_device_fd) {
                                 r = strv_extendf(&cmdline, "type=11,value=io.systemd.stub.kernel-cmdline-extra=%s", escaped_kcl);
                                 if (r < 0)
                                         return log_oom();
+
+                                r = strv_extendf(&cmdline, "type=11,value=io.systemd.boot.kernel-cmdline-extra=%s", escaped_kcl);
+                                if (r < 0)
+                                        return log_oom();
                         } else
                                 log_warning("Cannot append extra args to kernel cmdline, native architecture doesn't support SMBIOS, ignoring");
                 }