Skip to content

Commit

Permalink
dasharo/uefi_capsules.c: coalesce and store UEFI capsules
Browse files Browse the repository at this point in the history
How it approximately works:

(During a normal system run):
1. OS puts a capsule into RAM and calls UpdateCapsule() function of EFI
   runtime
2. If applying the update requires a reboot, EFI implementation creates
   a new CapsuleUpdateData* EFI variable pointing at the beginning of
   capsules description (not data, but description of the data) and does
   a warm reboot leaving capsule data and its description in RAM to be
   picked by firmware on the next boot process

(After DEV_INIT:)
3. Capsules are discovered by checking for CapsuleUpdateData* variables
4  Capsule description in memory and capsule data is validated for
   sanity
5. Capsule data is coalesced into a continuous piece of memory

(On BS_WRITE_TABLES via dasharo_add_capsules_to_bootmem() hook:)
6. Buffer with coalesced capsules is marked as reserved

(On BS_WRITE_TABLES via lb_uefi_capsules() hook:)
7. coreboot table entries are added for each of the discovered capsules

(In UEFI payload:)
8. CapsuleUpdateData* get removed
9. CBMEM is checked for any update capsules which are then applied

Change-Id: I162d678ae5c504906084b59c1a8d8c26dadb9433
Signed-off-by: Sergii Dmytruk <[email protected]>
  • Loading branch information
SergiiDmytruk committed Jun 13, 2024
1 parent 0b39614 commit c588ab4
Show file tree
Hide file tree
Showing 6 changed files with 778 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/drivers/efi/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ config DRIVERS_EFI_VARIABLE_STORE
help
Adds a driver that is able to read and write an EFI formatted
VariableStore as used by tianocore.

config DRIVERS_EFI_UPDATE_CAPSULES
bool "Include EFI update capsules driver"
depends on DRIVERS_EFI_VARIABLE_STORE && SMMSTORE_V2
help
Adds a driver that is able to parse CapsuleUpdateData* EFI variables
to discover firmware updates and expose them for tianocore thorough
CBMEM for execution. tianocore is responsible for erasing the variables.
2 changes: 2 additions & 0 deletions src/drivers/efi/Makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
all-$(CONFIG_DRIVERS_EFI_VARIABLE_STORE) += efivars.c
smm-$(CONFIG_DRIVERS_EFI_VARIABLE_STORE) += efivars.c

ramstage-$(CONFIG_DRIVERS_EFI_UPDATE_CAPSULES) += capsules.c

all-$(CONFIG_USE_UEFI_VARIABLE_STORE) += option.c
smm-$(CONFIG_USE_UEFI_VARIABLE_STORE) += option.c
Loading

0 comments on commit c588ab4

Please sign in to comment.