From 68c1f1c1a6de21fe34158724c9c3203869856a64 Mon Sep 17 00:00:00 2001 From: Hector Martin Date: Mon, 23 Aug 2021 15:26:39 +0900 Subject: [PATCH] Revert "kboot: move SEPFW to initrd before booting" We've decided this needs to go via reserved-ranges, not in the initramfs. This reverts commit 6afe9ebaf9e2333f53d6a27ffbfff7a88094058e. --- src/kboot.c | 79 +---------------------------------------------------- src/kboot.h | 1 - 2 files changed, 1 insertion(+), 79 deletions(-) diff --git a/src/kboot.c b/src/kboot.c index 9b842d35..00725292 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -3,7 +3,6 @@ #include "kboot.h" #include "adt.h" #include "assert.h" -#include "cpio.h" #include "exception.h" #include "malloc.h" #include "memory.h" @@ -22,8 +21,7 @@ static char *bootargs = NULL; static void *initrd_start = NULL; static size_t initrd_size = 0; -#define DT_ALIGN 16384 -#define INITRD_ALIGN 65536 +#define DT_ALIGN 16384 #define bail(...) \ do { \ @@ -308,9 +306,6 @@ int kboot_prepare_dt(void *fdt) dt = NULL; } - if (kboot_prepare_fw() < 0) - bail("FDT: couldn't prepare firmware."); - dt_bufsize = fdt_totalsize(fdt); assert(dt_bufsize); @@ -343,78 +338,6 @@ int kboot_prepare_dt(void *fdt) return 0; } -static int kboot_prepare_sepfw(struct cpio *c) -{ - int adt_path[8]; - int adt_offset; - adt_offset = adt_path_offset_trace(adt, "/chosen/memory-map", adt_path); - if (adt_offset < 0) { - printf("kboot: Error getting /chosen/memory-map node\n"); - return -1; - } - - u64 base; - u64 sz; - if (adt_get_reg(adt, adt_path, "SEPFW", 0, &base, &sz) < 0) { - printf("kboot: Error getting SEPFW\n"); - return -1; - } - - if (cpio_add_file(c, "lib/firmware/apple/sepfw.bin", (const u8 *)base, sz) < 0) { - printf("kboot: unable to add lib/firmware/apple/sepfw.bin\n"); - return -1; - } - - return 0; -} - -int kboot_prepare_fw(void) -{ - struct cpio *c = cpio_init(); - u8 *cpio_start = NULL; - u8 *new_initrd_start = NULL; - size_t cpio_size = 0; - u32 new_initrd_size = 0; - - if (cpio_add_dir(c, "lib") < 0) - goto err; - if (cpio_add_dir(c, "lib/firmware") < 0) - goto err; - if (cpio_add_dir(c, "lib/firmware/apple") < 0) - goto err; - - if (kboot_prepare_sepfw(c) < 0) - printf("kboot: no SEPFW found.\n"); - - cpio_size = cpio_get_size(c); - new_initrd_size = cpio_size + ALIGN_UP(initrd_size, 4); - new_initrd_start = memalign(INITRD_ALIGN, new_initrd_size); - if (!new_initrd_start) { - printf("kboot: couldn't allocate initrd buffer\n"); - goto err; - } - - memcpy(new_initrd_start, initrd_start, initrd_size); - - cpio_start = new_initrd_start + ALIGN_UP(initrd_size, 4); - size_t res = cpio_finalize(c, cpio_start, cpio_size); - if (res != cpio_size) { - printf("kboot: unexpected cpio_finalize size: %lu should be %lu\n", res, cpio_size); - goto err; - } - - initrd_start = new_initrd_start; - initrd_size = new_initrd_size; - cpio_free(c); - - return 0; - -err: - free(new_initrd_start); - cpio_free(c); - return -1; -} - int kboot_boot(void *kernel) { usb_init(); diff --git a/src/kboot.h b/src/kboot.h index 7f30406e..744fe751 100644 --- a/src/kboot.h +++ b/src/kboot.h @@ -19,7 +19,6 @@ struct kernel_header { void kboot_set_initrd(void *start, size_t size); void kboot_set_bootargs(const char *ba); -int kboot_prepare_fw(void); int kboot_prepare_dt(void *fdt); int kboot_boot(void *kernel);