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
(After DEV_INIT:)
1. Capsules are parsed from CapsuleUpdateData* EFI variables and are
   validated for sanity
2. Capsule data is coalesced into a continuous piece of memory

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

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

Change-Id: I162d678ae5c504906084b59c1a8d8c26dadb9433
Signed-off-by: Sergii Dmytruk <[email protected]>
  • Loading branch information
SergiiDmytruk committed May 18, 2024
1 parent c5e5924 commit 0ca0983
Show file tree
Hide file tree
Showing 5 changed files with 789 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib/bootmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <console/console.h>
#include <bootmem.h>
#include <cbmem.h>
#include <dasharo/uefi_capsules.h>
#include <device/resource.h>
#include <symbols.h>
#include <assert.h>
Expand Down Expand Up @@ -80,6 +81,8 @@ static void bootmem_init(void)
/* Add memory used by CBMEM. */
cbmem_add_bootmem();

dasharo_add_capsules_to_bootmem();

bootmem_add_range((uintptr_t)_stack, REGION_SIZE(stack),
BM_MEM_RAMSTAGE);
bootmem_add_range((uintptr_t)_program, REGION_SIZE(program),
Expand Down
5 changes: 5 additions & 0 deletions src/security/memory/memory_clear.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <security/memory/memory.h>
#include <cbmem.h>
#include <acpi/acpi.h>
#include <dasharo/uefi_capsules.h>

/* Helper to find free space for memset_pae. */
static uintptr_t get_free_memory_range(struct memranges *mem,
Expand Down Expand Up @@ -60,6 +61,10 @@ static void clear_memory(void *unused)
if (acpi_is_wakeup_s3())
return;

/* Process capsules before clearing memory and only if not waking up
* from S3. */
dasharo_parse_capsules();

if (!security_clear_dram_request())
return;

Expand Down
2 changes: 2 additions & 0 deletions src/vendorcode/dasharo/Makefile.inc
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ smm-y += options.c
all-y += options.c

ramstage-y += smbios.c

ramstage-y += uefi_capsules.c
10 changes: 10 additions & 0 deletions src/vendorcode/dasharo/include/dasharo/uefi_capsules.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* SPDX-License-Identifier: GPL-2.0-only */

#ifndef DASHARO_UEFI_CAPSULES_H
#define DASHARO_UEFI_CAPSULES_H

void dasharo_parse_capsules(void);

void dasharo_add_capsules_to_bootmem(void);

#endif /* DASHARO_UEFI_CAPSULES_H */
Loading

0 comments on commit 0ca0983

Please sign in to comment.