From: Pawel R. <paw...@in...> - 2022-03-04 09:25:24
|
changeset a478a9c1096a in /hg/p/tboot/code details: http://hg.code.sf.net/p/tboot/code/code?cmd=changeset;node=a478a9c1096a description: Reverted changeset [f90511] due to Tboot losing its in-memory logs Changes made by the above-mentioned changeset broke Tboot's functionality of saving logs into memory - txt-stat was unable to find & display them. This went unnoticed and I apologize for that. diffstat: tboot/common/efi_memmap.c | 6 ---- tboot/common/loader.c | 66 +--------------------------------------------- tboot/include/efi_memmap.h | 1 - tboot/include/loader.h | 1 - 4 files changed, 1 insertions(+), 73 deletions(-) diffs (131 lines): diff -r ec3c0f5b7447 -r a478a9c1096a tboot/common/efi_memmap.c --- a/tboot/common/efi_memmap.c Tue Mar 01 11:05:35 2022 +0100 +++ b/tboot/common/efi_memmap.c Fri Mar 04 10:23:55 2022 +0100 @@ -335,12 +335,6 @@ } } - -bool efi_memmap_present(void) -{ - return efi_mmap_available; -} - static bool insert_after_region(uint32_t pos, uint64_t addr, uint64_t size, uint32_t type, uint64_t attr) { diff -r ec3c0f5b7447 -r a478a9c1096a tboot/common/loader.c --- a/tboot/common/loader.c Tue Mar 01 11:05:35 2022 +0100 +++ b/tboot/common/loader.c Fri Mar 04 10:23:55 2022 +0100 @@ -331,18 +331,6 @@ return true; } - -static bool remove_mb2_tag_by_type(loader_ctx *lctx, uint32_t tag_type) -{ - struct mb2_tag *start = next_mb2_tag(NULL); - struct mb2_tag *victim = find_mb2_tag_type(start, tag_type); - - if (victim != NULL) { - return remove_mb2_tag(lctx,victim); - } - return false; -} - static bool grow_mb2_tag(loader_ctx *lctx, struct mb2_tag *which, uint32_t how_much) { @@ -1414,22 +1402,11 @@ } /* replace map in loader context with copy */ - if ( is_loader_launch_efi(g_ldr_ctx) && efi_memmap_present() ) { - /* for EFI, reclaim MB2 space by deleting the E820 map, - this ensures grow_mb2_tag() has enough slack available. - Due to the growth of each, there can only be one... - */ - remove_mb2_tag_by_type(g_ldr_ctx, MB2_TAG_TYPE_MMAP); - replace_efi_map(g_ldr_ctx); - } else { - remove_mb2_tag_by_type(g_ldr_ctx, MB2_TAG_TYPE_EFI_MMAP); - replace_e820_map(g_ldr_ctx); - } + replace_e820_map(g_ldr_ctx); if (get_tboot_dump_memmap()) { printk(TBOOT_DETA"adjusted e820 map:\n"); print_e820_map(); - efi_memmap_dump(); } if ( !verify_loader_context(g_ldr_ctx) ) @@ -1931,47 +1908,6 @@ return; } -void -replace_efi_map(loader_ctx *lctx) -{ - /* currently must be MBI type 2 */ - if ( LOADER_CTX_BAD(lctx) || lctx->type == MB1_ONLY ){ - return; - } - - struct mb2_tag *start = (struct mb2_tag *)(lctx->addr + 8); - struct mb2_tag_efi_mmap *tag; - tag = (struct mb2_tag_efi_mmap *)find_mb2_tag_type(start, MB2_TAG_TYPE_EFI_MMAP); - - if ( !tag ) { - printk(TBOOT_INFO"MB2 EFI map not found\n"); - return; - } - - const uint32_t old_mmap_size = tag->size - sizeof(struct mb2_tag_efi_mmap); - uint32_t new_descr_size=0; - uint32_t new_descr_vers=0; - uint32_t new_mmap_size=0; - void *new_mmap; - - new_mmap = (void *)efi_memmap_get_addr(&new_descr_size, &new_descr_vers, &new_mmap_size); - - if ( old_mmap_size < new_mmap_size ) { - /* we have to grow */ - if (false == - grow_mb2_tag(lctx, (struct mb2_tag *)tag, (new_mmap_size-old_mmap_size))) { - printk(TBOOT_ERR"MB2 failed to grow EFI map tag\n"); - return; - } - } else { - tag->size = sizeof(struct mb2_tag_efi_mmap) + new_mmap_size; - } - /* copy in new data */ - tag->descr_size = new_descr_size; - tag->descr_vers = new_descr_vers; - tb_memcpy(tag->efi_mmap, new_mmap, new_mmap_size); -} - void print_loader_ctx(loader_ctx *lctx) { if (lctx->type != MB2_ONLY){ diff -r ec3c0f5b7447 -r a478a9c1096a tboot/include/efi_memmap.h --- a/tboot/include/efi_memmap.h Tue Mar 01 11:05:35 2022 +0100 +++ b/tboot/include/efi_memmap.h Fri Mar 04 10:23:55 2022 +0100 @@ -98,5 +98,4 @@ uint64_t *ram_base, uint64_t *ram_size); void efi_memmap_dump(void); -bool efi_memmap_present(void); #endif \ No newline at end of file diff -r ec3c0f5b7447 -r a478a9c1096a tboot/include/loader.h --- a/tboot/include/loader.h Tue Mar 01 11:05:35 2022 +0100 +++ b/tboot/include/loader.h Fri Mar 04 10:23:55 2022 +0100 @@ -97,7 +97,6 @@ extern void determine_loader_type(void *addr, uint32_t magic); extern unsigned long get_loader_ctx_end(loader_ctx *lctx); extern void replace_e820_map(loader_ctx *lctx); -extern void replace_efi_map(loader_ctx *lctx); extern uint8_t *get_loader_rsdp(loader_ctx *lctx, uint32_t *length); extern bool is_loader_launch_efi(loader_ctx *lctx); extern bool get_loader_efi_ptr(loader_ctx *lctx, uint32_t *address, |