1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-25 11:37:56 +00:00

EFI: don't call printf after ExitBootServices, since it uses Boot Services

ExitBootServices terminates all boot services including console access.
Attempting to call printf afterwards can result in a crash, depending on the
implementation.

Move any printf statements to before we call bi_load, and remove any that
depend on calling bi_load first.

Reviewed by:	imp, tsoome
Differential Revision:	https://reviews.freebsd.org/D19374
This commit is contained in:
Rebecca Cran 2019-03-02 04:02:11 +00:00
parent 51244b1e46
commit ea7796a9ae
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344718
2 changed files with 15 additions and 7 deletions

View File

@ -74,16 +74,19 @@ __elfN(arm_exec)(struct preloaded_file *fp)
e = (Elf_Ehdr *)&fmp->md_data;
efi_time_fini();
entry = efi_translate(e->e_entry);
printf("Kernel entry at 0x%x...\n", (unsigned)entry);
printf("Kernel args: %s\n", fp->f_args);
if ((error = bi_load(fp->f_args, &modulep, &kernend)) != 0) {
efi_time_init();
return (error);
}
entry = efi_translate(e->e_entry);
printf("Kernel entry at 0x%x...\n", (unsigned)entry);
printf("Kernel args: %s\n", fp->f_args);
printf("modulep: %#x\n", modulep);
printf("relocation_offset %llx\n", __elfN(relocation_offset));
/* At this point we've called ExitBootServices, so we can't call
* printf or any other function that uses Boot Services */
dev_cleanup();

View File

@ -75,14 +75,19 @@ elf32_exec(struct preloaded_file *fp)
ehdr = (Elf_Ehdr *)&(md->md_data);
efi_time_fini();
entry = ehdr->e_entry & 0xffffff;
printf("Start @ 0x%x ...\n", entry);
err = bi_load(fp->f_args, &modulep, &kernend);
if (err != 0) {
efi_time_init();
return(err);
}
entry = ehdr->e_entry & 0xffffff;
printf("Start @ 0x%x ...\n", entry);
/* At this point we've called ExitBootServices, so we can't call
* printf or any other function that uses Boot Services */
dev_cleanup();
__exec((void *)entry, boothowto, bootdev, 0, 0, 0, bootinfop, modulep, kernend);