Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/72708 )
Change subject: include/bootstate.h: Fail compilation on invalid bootstate hooks ......................................................................
include/bootstate.h: Fail compilation on invalid bootstate hooks
No BS_ON_EXIT hooks are run on BS_PAYLOAD_BOOT or BS_OS_RESUME, so don't allow these hooks.
Change-Id: I318165f0bd510aed3138d3612dd3e264901aba96 Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M src/include/bootstate.h 1 file changed, 18 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/08/72708/1
diff --git a/src/include/bootstate.h b/src/include/bootstate.h index 87ed0c8..a1743a8 100644 --- a/src/include/bootstate.h +++ b/src/include/bootstate.h @@ -188,7 +188,11 @@ }; \ static struct boot_state_init_entry * \ bsie_ ## func_ ##_## state_ ##_## when_ BOOT_STATE_INIT_ATTR = \ - &func_ ##_## state_ ##_## when_; + &func_ ##_## state_ ##_## when_; \ + _Static_assert(!(state_ == BS_PAYLOAD_BOOT && when_ == BS_ON_EXIT), \ + "Invalid bootstate hook"); \ + _Static_assert(!(state_ == BS_OS_RESUME && when_ == BS_ON_EXIT), \ + "Invalid bootstate hook");
/* Hook per arch when coreboot is exiting to payload or ACPI OS resume. It's * the very last thing done before the transition. */