From: Ahmad Fatoum <a.fat...@pengutronix.de> bootm_init is a late initcall and thus the code has the implicit assumption that bootm_force_signed_images is called after it runs.
Rework the code to allow calling the function at any time. Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de> --- common/bootm.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/common/bootm.c b/common/bootm.c index 15b18c12faa1856e08e30f59a5c2151558f20ec3..755c9358ce3a17c8ce37a9db13cf18d0aea1b5e7 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -116,12 +116,22 @@ static const char * const bootm_verify_names[] = { static bool force_signed_images = IS_ENABLED(CONFIG_BOOTM_FORCE_SIGNED_IMAGES); -void bootm_force_signed_images(void) +static void bootm_optional_signed_images(void) { - static unsigned int verify_mode = 0; + /* This function should not be exported */ + BUG_ON(force_signed_images); - if (force_signed_images) - return; + globalvar_remove("bootm.verify"); + /* recreate bootm.verify with a single enumeration as option */ + globalvar_add_simple_enum("bootm.verify", (unsigned int *)&bootm_verify_mode, + bootm_verify_names, ARRAY_SIZE(bootm_verify_names)); + + bootm_verify_mode = BOOTM_VERIFY_AVAILABLE; +} + +static void bootm_require_signed_images(void) +{ + static unsigned int verify_mode = 0; /* recreate bootm.verify with a single enumeration as option */ globalvar_remove("bootm.verify"); @@ -129,6 +139,11 @@ void bootm_force_signed_images(void) &bootm_verify_names[BOOTM_VERIFY_SIGNATURE], 1); bootm_verify_mode = BOOTM_VERIFY_SIGNATURE; +} + +void bootm_force_signed_images(void) +{ + bootm_require_signed_images(); force_signed_images = true; } @@ -1086,14 +1101,13 @@ static int bootm_init(void) globalvar_add_simple("bootm.initrd.loadaddr", NULL); } - if (bootm_signed_images_are_forced()) - bootm_verify_mode = BOOTM_VERIFY_SIGNATURE; - globalvar_add_simple_bool("bootm.dryrun", &bootm_dryrun); globalvar_add_simple_int("bootm.verbose", &bootm_verbosity, "%u"); - globalvar_add_simple_enum("bootm.verify", (unsigned int *)&bootm_verify_mode, - bootm_verify_names, ARRAY_SIZE(bootm_verify_names)); + if (bootm_signed_images_are_forced()) + bootm_require_signed_images(); + else + bootm_optional_signed_images(); if (IS_ENABLED(CONFIG_ROOTWAIT_BOOTARG)) globalvar_add_simple_int("linux.rootwait", -- 2.47.3