selfboot: create selfboot_check function, remove check param

The selfboot function was changed at some point to take a parameter
which meant "check the allocated descriptors to see if they target
regions of real memory."

The region check had to be buried deep in the last step of loading since
that is where those descriptors were created and used.

An issue with the use of the parameter was that it was not possible
for compilers to easily divine whether the check code was used,
and it was hence possible for the code, and its dependencies, to be
compiled in even if never used (which caused problems for the
rampayload code).

Now that bounce buffers are gone, we can hoist the check code
to the outermost level. Further, by creating a selfload_check
and selfload function, we can make it easy for compilers
to discard unused code: if selfload_check is never called, all
the code it uses can be discarded too.

Change-Id: Id5b3f450fd18480d54ffb6e395429fba71edcd77
Signed-off-by: Ronald G. Minnich <rminnich@gmail.com>
Reviewed-on: https://review.coreboot.org/29259
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Ronald G. Minnich
2018-10-24 15:46:51 -07:00
parent de332f35da
commit c308554c10
4 changed files with 56 additions and 16 deletions

View File

@ -197,12 +197,15 @@ void payload_run(void);
void mirror_payload(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 false. On successful payload loading this functions return true.
* selfload() and selfload_check() load payloads into memory.
* selfload() does not check the payload to see if it targets memory.
* Call selfload_check() to check that the payload targets usable memory.
* If it does not, the load will fail and this function
* will return false. On successful payload loading these functions return true.
*
* Defined in src/lib/selfboot.c
*/
bool selfload(struct prog *payload, bool check_regions);
bool selfload_check(struct prog *payload);
bool selfload(struct prog *payload);
#endif /* PROGRAM_LOADING_H */