@@ -1464,7 +1464,6 @@ static void boot_entry_add_type1(
1464
1464
assert (config );
1465
1465
assert (device );
1466
1466
assert (root_dir );
1467
- assert (path );
1468
1467
assert (file );
1469
1468
assert (content );
1470
1469
@@ -1607,7 +1606,8 @@ static void boot_entry_add_type1(
1607
1606
1608
1607
config_add_entry (config , entry );
1609
1608
1610
- boot_entry_parse_tries (entry , path , file , u".conf" );
1609
+ if (path )
1610
+ boot_entry_parse_tries (entry , path , file , u".conf" );
1611
1611
TAKE_PTR (entry );
1612
1612
}
1613
1613
@@ -1717,6 +1717,19 @@ static void config_load_defaults(Config *config, EFI_FILE *root_dir) {
1717
1717
(void ) efivar_get_str16 (MAKE_GUID_PTR (LOADER ), u"LoaderEntryLastBooted" , & config -> entry_saved );
1718
1718
}
1719
1719
1720
+ static bool valid_type1_filename (const char16_t * fname ) {
1721
+ assert (fname );
1722
+
1723
+ if (IN_SET (fname [0 ], u'.' , u'\0' ))
1724
+ return false;
1725
+ if (!endswith_no_case (fname , u".conf" ))
1726
+ return false;
1727
+ if (startswith_no_case (fname , u"auto-" ))
1728
+ return false;
1729
+
1730
+ return true;
1731
+ }
1732
+
1720
1733
static void config_load_type1_entries (
1721
1734
Config * config ,
1722
1735
EFI_HANDLE * device ,
@@ -1747,13 +1760,9 @@ static void config_load_type1_entries(
1747
1760
if (err != EFI_SUCCESS || !f )
1748
1761
break ;
1749
1762
1750
- if (f -> FileName [0 ] == '.' )
1751
- continue ;
1752
1763
if (FLAGS_SET (f -> Attribute , EFI_FILE_DIRECTORY ))
1753
1764
continue ;
1754
- if (!endswith_no_case (f -> FileName , u".conf" ))
1755
- continue ;
1756
- if (startswith_no_case (f -> FileName , u"auto-" ))
1765
+ if (!valid_type1_filename (f -> FileName ))
1757
1766
continue ;
1758
1767
1759
1768
err = file_read (entries_dir ,
@@ -1769,6 +1778,41 @@ static void config_load_type1_entries(
1769
1778
}
1770
1779
}
1771
1780
1781
+ static void config_load_smbios_entries (
1782
+ Config * config ,
1783
+ EFI_HANDLE * device ,
1784
+ EFI_FILE * root_dir ,
1785
+ const char16_t * loaded_image_path ) {
1786
+
1787
+ assert (config );
1788
+ assert (device );
1789
+ assert (root_dir );
1790
+
1791
+ /* Loads Boot Loader Type #1 entries from SMBIOS 11 */
1792
+
1793
+ if (is_confidential_vm ())
1794
+ return ; /* Don't consume SMBIOS in CoCo contexts */
1795
+
1796
+ for (const char * after = NULL , * extra ;; after = extra ) {
1797
+ extra = smbios_find_oem_string ("io.systemd.boot.entries-extra:" , after );
1798
+ if (!extra )
1799
+ break ;
1800
+
1801
+ const char * eq = strchr8 (extra , '=' );
1802
+ if (!eq )
1803
+ continue ;
1804
+
1805
+ _cleanup_free_ char16_t * fname = xstrn8_to_16 (extra , eq - extra );
1806
+ if (!valid_type1_filename (fname ))
1807
+ continue ;
1808
+
1809
+ /* Make a copy, since boot_entry_add_type1() wants to modify it */
1810
+ _cleanup_free_ char * contents = xstrdup8 (eq + 1 );
1811
+
1812
+ boot_entry_add_type1 (config , device , root_dir , /* path= */ NULL , fname , contents , loaded_image_path );
1813
+ }
1814
+ }
1815
+
1772
1816
static int boot_entry_compare (const BootEntry * a , const BootEntry * b ) {
1773
1817
int r ;
1774
1818
@@ -2775,7 +2819,7 @@ static EFI_STATUS image_start(
2775
2819
_cleanup_free_ char16_t * options = xstrdup16 (options_initrd ?: entry -> options_implied ? NULL : entry -> options );
2776
2820
2777
2821
if (entry -> type == LOADER_LINUX && !is_confidential_vm ()) {
2778
- const char * extra = smbios_find_oem_string ("io.systemd.boot.kernel-cmdline-extra" );
2822
+ const char * extra = smbios_find_oem_string ("io.systemd.boot.kernel-cmdline-extra=" , /* after= */ NULL );
2779
2823
if (extra ) {
2780
2824
_cleanup_free_ char16_t * tmp = TAKE_PTR (options ), * extra16 = xstr8_to_16 (extra );
2781
2825
if (isempty (tmp ))
@@ -2989,6 +3033,9 @@ static void config_load_all_entries(
2989
3033
/* Similar, but on any XBOOTLDR partition */
2990
3034
config_load_xbootldr (config , loaded_image -> DeviceHandle );
2991
3035
3036
+ /* Pick up entries defined via SMBIOS Type #11 */
3037
+ config_load_smbios_entries (config , loaded_image -> DeviceHandle , root_dir , loaded_image_path );
3038
+
2992
3039
/* Sort entries after version number */
2993
3040
sort_pointer_array ((void * * ) config -> entries , config -> n_entries , (compare_pointer_func_t ) boot_entry_compare );
2994
3041
0 commit comments