<feed xmlns='http://www.w3.org/2005/Atom'>
<title>efi-boot-shim.git/fallback.c, branch rolling</title>
<subtitle> (mirror of https://github.com/vyos/efi-boot-shim.git)
</subtitle>
<id>https://git.amelek.net/vyos/efi-boot-shim.git/atom?h=rolling</id>
<link rel='self' href='https://git.amelek.net/vyos/efi-boot-shim.git/atom?h=rolling'/>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/'/>
<updated>2025-03-03T20:03:33+00:00</updated>
<entry>
<title>fallback: don't add new boot order entries backwards</title>
<updated>2025-03-03T20:03:33+00:00</updated>
<author>
<name>Peter Jones</name>
<email>pjones@redhat.com</email>
</author>
<published>2025-02-28T22:16:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=498b1497d917bc6cb645ffddca2a1d96814b7f6d'/>
<id>urn:sha1:498b1497d917bc6cb645ffddca2a1d96814b7f6d</id>
<content type='text'>
In issues #554 and elsewhere, it's been noted that when fallback is
creating multiple entries, it will create them in one order and add them
to BootOrder in the opposite order.  This is weird.

This patch changes fallback to keep a list of "new" entries, and then
prepend that entire list to BootOrder when it's done, rather than
prepending one at a time, that avoiding the inversion.

Resolves issue #554.

Signed-off-by: Peter Jones &lt;pjones@redhat.com&gt;
</content>
</entry>
<entry>
<title>Create utils file</title>
<updated>2025-02-06T20:13:23+00:00</updated>
<author>
<name>Eric Snowberg</name>
<email>eric.snowberg@oracle.com</email>
</author>
<published>2023-08-29T17:33:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=38dfa37ec218bda0dd6bb5c4ce9e6ecb05fda851'/>
<id>urn:sha1:38dfa37ec218bda0dd6bb5c4ce9e6ecb05fda851</id>
<content type='text'>
Move some functions currently used within fallback that will later also
be used in shim.

Signed-off-by: Eric Snowberg &lt;eric.snowberg@oracle.com&gt;
</content>
</entry>
<entry>
<title>Null-terminate 'arguments' in fallback</title>
<updated>2024-11-12T22:21:31+00:00</updated>
<author>
<name>Vitaly Kuznetsov</name>
<email>vkuznets@redhat.com</email>
</author>
<published>2023-09-06T11:22:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=338fded6cf8a4388562a532faba0862a204bc456'/>
<id>urn:sha1:338fded6cf8a4388562a532faba0862a204bc456</id>
<content type='text'>
In case CSV entry contains boot argument (e.g. an image to load for shim)
it must be null-terminated. While populate_stanza() makes sure 'arguments'
end with '\0', add_boot_option() doesn't account for it in 'size'
calculations. E.g. for the following CSV entry:

 shimx64.efi,6.6.0-0.rc0.20230904git708283abf896.6.fc40.x86_64,\EFI\Linux\5f93b3c9cf1c488a99786fb8e99fb840-6.6.0-0.rc0.20230904git708283abf896.6.fc40.x86_64.efi,Comment

the resulting variable after 'fallback' looks like:

 # hexdump /sys/firmware/efi/efivars/Boot0004-8be4df61-93ca-11d2-aa0d-00e098032b8c | tail -3
 0000180 0038 0036 005f 0036 0034 002e 0065 0066
 0000190 0069
 0000192

Add trailing '\0' to 'size' calculations in add_boot_option() when
'arguments' is not empty. The resulting variable looks like:

 # hexdump /sys/firmware/efi/efivars/Boot0004-8be4df61-93ca-11d2-aa0d-00e098032b8c | tail -3
 0000180 0038 0036 005f 0036 0034 002e 0065 0066
 0000190 0069 0000
 0000194

and the specified image is loaded by shim without issues.

Signed-off-by: Vitaly Kuznetsov &lt;vkuznets@redhat.com&gt;
</content>
</entry>
<entry>
<title>Change type of fallback_verbose_wait from int to unsigned long</title>
<updated>2023-06-21T18:45:35+00:00</updated>
<author>
<name>Kamil Aronowski</name>
<email>kamil.aronowski@yahoo.com</email>
</author>
<published>2023-05-08T08:15:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=908c388c922c6369cace0b76660198becee2284e'/>
<id>urn:sha1:908c388c922c6369cace0b76660198becee2284e</id>
<content type='text'>
The variable fallback_verbose_wait from now on is of the type unsigned
long to match the type of the argument usleep() accepts.

Signed-off-by: Kamil Aronowski &lt;kamil.aronowski@yahoo.com&gt;
</content>
</entry>
<entry>
<title>Rename 'msecs' to 'usecs' to avoid potential confusion</title>
<updated>2023-06-21T18:19:51+00:00</updated>
<author>
<name>Kamil Aronowski</name>
<email>kamil.aronowski@yahoo.com</email>
</author>
<published>2023-04-12T16:50:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=549d34691d68518e55c2edd6e759b19de7f8ddef'/>
<id>urn:sha1:549d34691d68518e55c2edd6e759b19de7f8ddef</id>
<content type='text'>
The function msleep uses gBS-&gt;Stall which waits for a specified number
of microseconds.

Reference: https://edk2-docs.gitbook.io/edk-ii-uefi-driver-writer-s-guide/5_uefi_services/51_services_that_uefi_drivers_commonly_use/517_stall

This reference even mentions an example sleeping for 10 microseconds: // Wait 10 uS. Notice the letter 'u'.

Therefore it's a good idea to call the function 'usleep' rather than
'msleep', so no one confuses it with milliseconds, and to change the
argument name to match as well.

Signed-off-by: Kamil Aronowski &lt;kamil.aronowski@yahoo.com&gt;
</content>
</entry>
<entry>
<title>shim: use SHIM_DEVEL_VERBOSE when built in devel mode</title>
<updated>2022-05-17T22:16:07+00:00</updated>
<author>
<name>Peter Jones</name>
<email>pjones@redhat.com</email>
</author>
<published>2022-04-27T21:09:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=803dc5c16e276c26f8400b469370f2a2ca39d7f3'/>
<id>urn:sha1:803dc5c16e276c26f8400b469370f2a2ca39d7f3</id>
<content type='text'>
This makes SHIM_VERBOSE / SHIM_DEVEL_VERBOSE work the same way as
SHIM_DEBUG / SHIM_DEVEL_DEBUG when shim is built with ENABLE_SHIM_DEVEL
set.

Signed-off-by: Peter Jones &lt;pjones@redhat.com&gt;
</content>
</entry>
<entry>
<title>Minor coverity fixes</title>
<updated>2021-12-10T22:08:21+00:00</updated>
<author>
<name>Peter Jones</name>
<email>pjones@redhat.com</email>
</author>
<published>2021-12-09T22:21:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=d0df9304c7a777557e1925dc9f75406ec00e6179'/>
<id>urn:sha1:d0df9304c7a777557e1925dc9f75406ec00e6179</id>
<content type='text'>
- one missing free
- one minor deadcode issue
- two unchecked allocations
- one debug hexdump of a variable we just freed

Signed-off-by: Peter Jones &lt;pjones@redhat.com&gt;
</content>
</entry>
<entry>
<title>fallback: fix fallback not passing arguments of the first boot option</title>
<updated>2021-12-10T19:56:54+00:00</updated>
<author>
<name>Javier Martinez Canillas</name>
<email>javierm@redhat.com</email>
</author>
<published>2021-11-09T15:39:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=4804ba077381dcd0288d98e3d08bc87ee77afad1'/>
<id>urn:sha1:4804ba077381dcd0288d98e3d08bc87ee77afad1</id>
<content type='text'>
The buffer used to read the data in the CSV is declared as a stack variable
in the try_boot_csv() function, but a pointer to the arguments field of the
first boot option is stored in the global first_new_option_args variable.

Later, when is used set the arguments to boot the first entry, the variable
points to memory that no longer exists. This leads to booting an entry with
garbage as arguments instead of the correct value.

Reported-by: Alexander Larsson &lt;alexl@redhat.com&gt;
Signed-off-by: Javier Martinez Canillas &lt;javierm@redhat.com&gt;
</content>
</entry>
<entry>
<title>fallback: fix crash when boot entry index &gt;= size of BootOrder list</title>
<updated>2021-10-12T14:29:57+00:00</updated>
<author>
<name>Renaud Métrich</name>
<email>rmetrich@redhat.com</email>
</author>
<published>2021-10-05T07:14:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=41319e14c9144063605750baccd5bb332a3cf4fc'/>
<id>urn:sha1:41319e14c9144063605750baccd5bb332a3cf4fc</id>
<content type='text'>
Seen on Dell PowerEdge R740 when booting with BOOTX64 constantly.

This patch keeps the behaviour previous to commit #1b30c2b by returning
the index of the "Linux" entry.
Then a check is made to find the entry in the current BootOrder:
- if it isn't there, prepend the entry and copy the rest (this enlarges
  the BootOrder array by 1)
- if it's there, prepend the entry and copy all remaining entries

------------------------------------------------------------------------------

Example of outputs on a Dell PowerEdge R740:
- 0000 is BOOTX64 entry
- other entries are Dell's default ones (internal, no "Linux" there)

1. Entry not already existing in BootOrder

----
set_boot_order:486: Original nbootorder: 3
Original BootOrder: 0000 0003 0004
 :
add_to_boot_list:578: device path: "HD(1,GPT,99D47E76-590F-48FD-8FD6-0A0CE790D635)/\EFI\redhat\shimx64.efi"
find_boot_option:454: Found boot entry "Boot0005" with label "Red Hat Enterprise Linux" for file "\EFI\redhat\shimx64.efi"
add_to_boot_list:623: New nbootorder: 4
BootOrder: 0005 0000 0003 0004
find_boot_options:937: Found directory named "Dell"
update_boot_order:509: nbootorder: 4
BootOrder: 0005 0000 0003 0004
----

2. Entry not existing at all

----
set_boot_order:486: Original nbootorder: 3
Original BootOrder: 0000 0001 0002
 :
add_to_boot_list:578: device path: "HD(1,GPT,99D47E76-590F-48FD-8FD6-0A0CE790D635)/\EFI\redhat\shimx64.efi"
add_boot_option:245: Creating boot entry "Boot0005" with label "Red Hat Enterprise Linux" for file "\EFI\redhat\shimx64.efi"
add_boot_option:282: nbootorder: 4
BootOrder: 0005 0000 0001 0002
find_boot_options:937: Found directory named "Dell"
update_boot_order:509: nbootorder: 4
BootOrder: 0005 0000 0001 0002
----

3. Entry already existing in BootOrder

----
set_boot_order:486: Original nbootorder: 4
Original BootOrder: 0000 0005 0001 0002
 :
add_to_boot_list:578: device path: "HD(1,GPT,99D47E76-590F-48FD-8FD6-0A0CE790D635)/\EFI\redhat\shimx64.efi"
find_boot_option:454: Found boot entry "Boot0005" with label "Red Hat Enterprise Linux" for file "\EFI\redhat\shimx64.efi"
add_to_boot_list:623: New nbootorder: 4
BootOrder: 0005 0000 0001 0002
find_boot_options:937: Found directory named "Dell"
update_boot_order:509: nbootorder: 4
BootOrder: 0005 0000 0001 0002
----
</content>
</entry>
<entry>
<title>Revert "fallback: find_boot_option() needs to return the index for the boot entry in optnum"</title>
<updated>2021-10-12T14:29:57+00:00</updated>
<author>
<name>Renaud Métrich</name>
<email>rmetrich@redhat.com</email>
</author>
<published>2021-10-05T06:47:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.amelek.net/vyos/efi-boot-shim.git/commit/?id=1e4a858bba0afdbd36b9c1a11b9954ef8b871843'/>
<id>urn:sha1:1e4a858bba0afdbd36b9c1a11b9954ef8b871843</id>
<content type='text'>
This reverts commit 1b30c2b9e5ee7d3e305a28a92805152d5cbfc9cb.

This commit was creating duplicated entries when the "Linux" entry was
not already in the BootOrder list, which may happen upon firmware reset.
</content>
</entry>
</feed>
