Adding ESRT and EFI vars support for fwupd
Michał Kotyla
michal.kotyla at 3mdeb.com
Mon Aug 22 01:29:57 PDT 2022
Hello DragonflyBSD community,
Background
----------
As some might know, FreeBSD gained an interface for querying ESRT about
a year ago ([1], [2]), which was done as part of [3].
[1]:
https://reviews.freebsd.org/rGd12d651f8692cfcaf6fd0a6e8264c29547f644c9
[2]:
https://reviews.freebsd.org/rG24f398e7a153a05a7e94ae8dd623e2b6d28d94eb
[3]: https://nlnet.nl/project/fwdup-BSD/
Adding it allowed to make UEFI capsule plugin of fwupd [4] work for
FreeBSD [5] to perform firmware updates on EFI systems.
Now it's turn for DragonflyBSD and we would like to ask about requirements
and recommendations on the API and its implementation such that they
would be accepted by the upstream.
[4]: https://fwupd.org/
[5]:
https://github.com/fwupd/fwupd/blob/main/plugins/uefi-capsule/fu-uefi-backend-freebsd.c
The same project is being done for OpenBSD [6] and NetBSD as well [7]
[6]: https://www.mail-archive.com/tech%openbsd.org@localhost/msg70825.html
[7]: http://mail-index.netbsd.org/tech-kern/2022/08/17/msg028319.html
ESRT
----
Initial idea is to use sysctl() interface like it was done in FreeBSD
implementation ([1] and [2]). Here is a list of wanted ESRT variables:
"fw_resource_count",
"fw_resource_count_max",
"fw_resource_version",
"fw_class",
"fw_type",
"fw_version",
"lowest_supported_fw_version",
"capsule_flags",
"last_attempt_version",
"last_attempt_status"
EFI variables
-------------
We also need a working efivar or similar implementation to be usable
with fwupd:
• efi_append_variable() appends data of size to the variable specified
by guid
and name
• efi_del_variable() deletes the variable specified by guid and name
• efi_get_variable() gets variable's data_size, and its attributes are
stored
in attributes
• efi_get_variable_attributes() gets attributes for the variable
specified by
guid and name
• efi_get_variable_size() gets the size of the data for the variable
specified
by guid and name
• efi_get_next_variable_name() iterates across the currently extant
variables,
passing back a guid and name
• efi_guid_to_name() translates from an efi_guid_t to a well known name
• efi_guid_to_symbol() translates from an efi_guid_t to a unique (within
libefivar) C-style symbol name
• efi_guid_to_str() allocates a suitable string and populates it with string
representation of a UEFI GUID
• efi_name_to_guid() translates from a well known name to an efi_guid_t
• efi_set_variable() sets the variable specified by guid and name
• efi_str_to_guid() parses a UEFI GUID from string form to an efi_guid_t
• efi_variables_supported() checks if EFI variables are accessible
• efi_generate_file_device_path() generates an EFI file device path for
an EFI
binary from a filesystem path
It looks like those functionalities are already implemented in
lib/libefivar/efivar.c
Expectation
----------
Please help shaping this API for ESRT and UEFI capsules, so you'll be
happy with
it :) The implementation is a separate thing, but let me know if you
have any
specific ideas about it right away, they can help to avoid too many
rounds of
review.
Best regards,
Michał Kotyla
--
Michał Kotyla
Embedded Linux Developer
GPG: 14FC54DC259CF70A
https://3mdeb.com | @3mdeb_com
More information about the Kernel
mailing list