While there is global.linux.bootargs.dyn to avoid boot script variables contaminating later boot targets, there is no such thing for the global.bootm. variables and as such it was up to the boot targets to either ignore the variables or to override them. The proper way would to expect the boot script boot callback to restore the variables as they were before, so let's do that. Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx> --- common/boot.c | 11 ++++++++--- common/bootm.c | 17 +++++++++++++++++ include/bootm.h | 1 + 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/common/boot.c b/common/boot.c index 42818c6e2154..2530a5bbeeac 100644 --- a/common/boot.c +++ b/common/boot.c @@ -74,20 +74,22 @@ static int bootscript_boot(struct bootentry *entry, int verbose, int dryrun) struct bootentry_script *bs = container_of(entry, struct bootentry_script, entry); int ret; - struct bootm_data data = {}; + struct bootm_data backup = {}, data = {}; if (dryrun == 1) { printf("Would run %s\n", bs->scriptpath); return 0; } + bootm_data_init_defaults(&backup); + globalvar_add_simple("linux.bootargs.dyn.ip", NULL); globalvar_add_simple("linux.bootargs.dyn.root", NULL); ret = run_command(bs->scriptpath); if (ret) { pr_err("Running script '%s' failed: %s\n", bs->scriptpath, strerror(-ret)); - return ret; + goto out; } bootm_data_init_defaults(&data); @@ -97,7 +99,10 @@ static int bootscript_boot(struct bootentry *entry, int verbose, int dryrun) if (dryrun >= 2) data.dryrun = dryrun - 1; - return bootm_boot(&data); + ret = bootm_boot(&data); +out: + bootm_data_restore_defaults(&backup); + return ret; } static unsigned int boot_watchdog_timeout; diff --git a/common/bootm.c b/common/bootm.c index d1dbf6890f6f..d24b18b41cb2 100644 --- a/common/bootm.c +++ b/common/bootm.c @@ -68,6 +68,23 @@ void bootm_data_init_defaults(struct bootm_data *data) data->dryrun = bootm_dryrun; } +void bootm_data_restore_defaults(const struct bootm_data *data) +{ + globalvar_set("bootm.oftree", data->oftree_file); + globalvar_set("bootm.tee", data->tee_file); + globalvar_set("bootm.image", data->os_file); + pr_setenv("global.bootm.image.loadaddr", "0x%lx", data->os_address); + pr_setenv("global.bootm.initrd.loadaddr", "0x%lx", data->initrd_address); + globalvar_set("bootm.initrd", data->initrd_file); + globalvar_set("bootm.root_dev", data->root_dev); + bootm_set_verify_mode(data->verify); + bootm_appendroot = data->appendroot; + bootm_provide_machine_id = data->provide_machine_id; + bootm_provide_hostname = data->provide_hostname; + bootm_verbosity = data->verbose; + bootm_dryrun = data->dryrun; +} + static enum bootm_verify bootm_verify_mode = BOOTM_VERIFY_HASH; enum bootm_verify bootm_get_verify_mode(void) diff --git a/include/bootm.h b/include/bootm.h index 98ac5e5a9374..fdec137771f0 100644 --- a/include/bootm.h +++ b/include/bootm.h @@ -138,6 +138,7 @@ static inline int bootm_verbose(struct image_data *data) #endif void bootm_data_init_defaults(struct bootm_data *data); +void bootm_data_restore_defaults(const struct bootm_data *data); int bootm_load_os(struct image_data *data, unsigned long load_address); -- 2.39.5