Page MenuHomeFreeBSD

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

Authored by bcran on Feb 27 2019, 12:59 AM.

Details

Summary

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

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

Test Plan

Tested on i386 (MinnowBoard Turbot): loader now proceeds to the point where it starts executing the kernel
I'm running a "make tinderbox" to verify that arm still builds.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bcran created this revision.Feb 27 2019, 12:59 AM
tsoome added inline comments.Feb 27 2019, 6:16 AM
stand/efi/loader/arch/arm/exec.c
89 ↗(On Diff #54443)

It is not really about allocations - loader does still use the pre-allocated heap, but it is about the need to avoid calling Boot Services (note, Runtime Services are ok). And printf() is directly related to BS because we do use SimpleTextOutputProtocol.

bcran added inline comments.Feb 27 2019, 7:28 AM
stand/efi/loader/arch/arm/exec.c
89 ↗(On Diff #54443)

Ah, of course! Thanks, I'll update the comment.

bcran updated this revision to Diff 54452.Feb 27 2019, 7:29 AM

Update comments.

bcran marked an inline comment as done.Feb 27 2019, 7:30 AM
imp accepted this revision.Feb 27 2019, 2:26 PM
This revision is now accepted and ready to land.Feb 27 2019, 2:26 PM
tsoome accepted this revision.Feb 27 2019, 2:30 PM
This revision was automatically updated to reflect the committed changes.
bcran retitled this revision from EFI: don't call printf after ExitBootServices, since it allocates memory to EFI: don't call printf after ExitBootServices, since it uses Boot Services.Mar 2 2019, 4:03 AM
bcran edited the summary of this revision. (Show Details)