diff options
-rw-r--r-- | src/arch/arm64/Makefile.inc | 2 | ||||
-rw-r--r-- | src/arch/arm64/arm_tf.c | 5 | ||||
-rw-r--r-- | src/include/program_loading.h | 10 | ||||
-rw-r--r-- | src/lib/prog_loaders.c | 2 | ||||
-rw-r--r-- | src/lib/selfboot.c | 24 |
5 files changed, 26 insertions, 17 deletions
diff --git a/src/arch/arm64/Makefile.inc b/src/arch/arm64/Makefile.inc index ece35a6eea..6e3f080087 100644 --- a/src/arch/arm64/Makefile.inc +++ b/src/arch/arm64/Makefile.inc @@ -178,7 +178,7 @@ $(BL31): $(obj)/build.h BL31_CBFS := $(CONFIG_CBFS_PREFIX)/bl31 $(BL31_CBFS)-file := $(BL31) -$(BL31_CBFS)-type := stage +$(BL31_CBFS)-type := payload $(BL31_CBFS)-compression := $(CBFS_COMPRESS_FLAG) cbfs-files-y += $(BL31_CBFS) diff --git a/src/arch/arm64/arm_tf.c b/src/arch/arm64/arm_tf.c index 1ec87c4cc3..e976e34be0 100644 --- a/src/arch/arm64/arm_tf.c +++ b/src/arch/arm64/arm_tf.c @@ -50,11 +50,10 @@ void arm_tf_run_bl31(u64 payload_entry, u64 payload_arg0, u64 payload_spsr) if (prog_locate(&bl31)) die("BL31 not found"); - if (cbfs_prog_stage_load(&bl31)) + bl31_entry = selfload(&bl31, false); + if (!bl31_entry) die("BL31 load failed"); - bl31_entry = prog_entry(&bl31); - SET_PARAM_HEAD(&bl31_params, PARAM_BL31, VERSION_1, 0); if (IS_ENABLED(CONFIG_ARM64_USE_SECURE_OS)) { diff --git a/src/include/program_loading.h b/src/include/program_loading.h index e265b18359..3958fda41c 100644 --- a/src/include/program_loading.h +++ b/src/include/program_loading.h @@ -189,7 +189,13 @@ void payload_run(void); /* Mirror the payload to be loaded. */ void mirror_payload(struct prog *payload); -/* Defined in src/lib/selfboot.c */ -void *selfload(struct prog *payload); +/* + * Set check_regions to true to check that the payload targets usable memory. + * With this flag set, if it does not, the load will fail and this function + * will return NULL. + * + * Defined in src/lib/selfboot.c + */ +void *selfload(struct prog *payload, bool check_regions); #endif /* PROGRAM_LOADING_H */ diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c index ecbc679f2a..c0dcd60d61 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -161,7 +161,7 @@ void payload_load(void) mirror_payload(payload); /* Pass cbtables to payload if architecture desires it. */ - prog_set_entry(payload, selfload(payload), + prog_set_entry(payload, selfload(payload, true), cbmem_find(CBMEM_ID_CBTABLE)); out: diff --git a/src/lib/selfboot.c b/src/lib/selfboot.c index 1ce7f94f5a..162a03443c 100644 --- a/src/lib/selfboot.c +++ b/src/lib/selfboot.c @@ -88,7 +88,8 @@ static void get_bounce_buffer(unsigned long req_size) /* When the ramstage is relocatable there is no need for a bounce * buffer. All payloads should not overlap the ramstage. */ - if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE)) { + if (IS_ENABLED(CONFIG_RELOCATABLE_RAMSTAGE) || + !arch_supports_bounce_buffer()) { bounce_buffer = ~0UL; bounce_size = 0; return; @@ -357,15 +358,16 @@ static int payload_targets_usable_ram(struct segment *head) return 1; } -static int load_self_segments( - struct segment *head, - struct prog *payload) +static int load_self_segments(struct segment *head, struct prog *payload, + bool check_regions) { struct segment *ptr; unsigned long bounce_high = lb_end; - if (!payload_targets_usable_ram(head)) - return 0; + if (check_regions) { + if (!payload_targets_usable_ram(head)) + return 0; + } for(ptr = head->next; ptr != head; ptr = ptr->next) { /* @@ -373,8 +375,10 @@ static int load_self_segments( * allocated so that there aren't conflicts with the actual * payload. */ - bootmem_add_range(ptr->s_dstaddr, ptr->s_memsz, - LB_MEM_UNUSABLE); + if (check_regions) { + bootmem_add_range(ptr->s_dstaddr, ptr->s_memsz, + LB_MEM_UNUSABLE); + } if (!overlaps_coreboot(ptr)) continue; @@ -486,7 +490,7 @@ static int load_self_segments( return 1; } -void *selfload(struct prog *payload) +void *selfload(struct prog *payload, bool check_regions) { uintptr_t entry = 0; struct segment head; @@ -502,7 +506,7 @@ void *selfload(struct prog *payload) goto out; /* Load the segments */ - if (!load_self_segments(&head, payload)) + if (!load_self_segments(&head, payload, check_regions)) goto out; printk(BIOS_SPEW, "Loaded segments\n"); |