From 8cd1a0cf5205a65503351945df3cdbea1a908c15 Mon Sep 17 00:00:00 2001 From: Bin Meng Date: Tue, 2 Feb 2021 15:04:47 +0800 Subject: [PATCH 1/4] x86: qemu: Fix broken multi-core boot Unfortunately the multi-core boot for QEMU x86 has been broken since commit 77a5e2d3bc61 ("x86: mp_init: Set up the CPU numbers at the start"). In order to support QEMU x86 multi-core boot, the /cpus node must be bound before any actual fix up in qemu_cpu_fixup(). This adds the uclass_get() call to ensure this, just like what was done before. Fixes: 77a5e2d3bc61 ("x86: mp_init: Set up the CPU numbers at the start") Signed-off-by: Bin Meng Reviewed-by: Simon Glass --- arch/x86/cpu/qfw_cpu.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/cpu/qfw_cpu.c b/arch/x86/cpu/qfw_cpu.c index a35de878b5..b959eaddde 100644 --- a/arch/x86/cpu/qfw_cpu.c +++ b/arch/x86/cpu/qfw_cpu.c @@ -17,10 +17,16 @@ int qemu_cpu_fixup(void) int ret; int cpu_num; int cpu_online; + struct uclass *uc; struct udevice *dev, *pdev; struct cpu_plat *plat; char *cpu; + /* This will cause the CPUs devices to be bound */ + ret = uclass_get(UCLASS_CPU, &uc); + if (ret) + return ret; + /* first we need to find '/cpus' */ for (device_find_first_child(dm_root(), &pdev); pdev; From d3a3d44fe2c1ca1710fb4599504332675c0ce966 Mon Sep 17 00:00:00 2001 From: Kory Maincent Date: Tue, 2 Feb 2021 16:42:27 +0100 Subject: [PATCH 2/4] command.h: Remove extern from the header Remove the extern of the header because they are useless. Signed-off-by: Kory Maincent Reviewed-by: Bin Meng Reviewed-by: Simon Glass [bmeng: minor edit on the commit message] Signed-off-by: Bin Meng --- include/command.h | 58 +++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/include/command.h b/include/command.h index e229bf2825..27604758a4 100644 --- a/include/command.h +++ b/include/command.h @@ -55,8 +55,8 @@ struct cmd_tbl { }; #if defined(CONFIG_CMD_RUN) -extern int do_run(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); +int do_run(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); #endif /* common/command.c */ @@ -69,7 +69,7 @@ int complete_subcmdv(struct cmd_tbl *cmdtp, int count, int argc, char *const argv[], char last_char, int maxv, char *cmdv[]); -extern int cmd_usage(const struct cmd_tbl *cmdtp); +int cmd_usage(const struct cmd_tbl *cmdtp); /* Dummy ->cmd and ->cmd_rep wrappers. */ int cmd_always_repeatable(struct cmd_tbl *cmdtp, int flag, int argc, @@ -85,10 +85,10 @@ static inline bool cmd_is_repeatable(struct cmd_tbl *cmdtp) } #ifdef CONFIG_AUTO_COMPLETE -extern int var_complete(int argc, char *const argv[], char last_char, int maxv, - char *cmdv[]); -extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, - int *colp); +int var_complete(int argc, char *const argv[], char last_char, int maxv, + char *cmdv[]); +int cmd_auto_complete(const char *const prompt, char *buf, int *np, + int *colp); #endif /** @@ -145,13 +145,13 @@ int cmd_get_data_size(char *arg, int default_size); #endif #ifdef CONFIG_CMD_BOOTD -extern int do_bootd(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); +int do_bootd(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); #endif #ifdef CONFIG_CMD_BOOTM -extern int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); -extern int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd); +int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); +int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd); #else static inline int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd) { @@ -159,28 +159,28 @@ static inline int bootm_maybe_autostart(struct cmd_tbl *cmdtp, const char *cmd) } #endif -extern int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, +int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); + +int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); + +int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc, char *const argv[]); -extern int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); +int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); +int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); -extern int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc, - char *const argv[]); - -extern int do_reset(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); -extern int do_poweroff(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); - -extern unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, - char *const argv[]); +unsigned long do_go_exec(ulong (*entry)(int, char * const []), int argc, + char *const argv[]); #if defined(CONFIG_CMD_NVEDIT_EFI) -extern int do_env_print_efi(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); -extern int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]); +int do_env_print_efi(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); +int do_env_set_efi(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]); #endif /** From ff0287ec28504f2c1230739a71b6139cd45d34de Mon Sep 17 00:00:00 2001 From: Kory Maincent Date: Tue, 2 Feb 2021 16:42:28 +0100 Subject: [PATCH 3/4] cmd: pxe_utils: Replace ifdef by IS_ENABLED Replace all the macro ifdef by IS_ENABLED. All of these configs are set in the defconfig files and not in the include board headers files. Signed-off-by: Kory Maincent Reviewed-by: Bin Meng [bmeng: keep the preprocessor case unchanged] Signed-off-by: Bin Meng --- cmd/pxe_utils.c | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 3526a651d7..81150b162b 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -492,16 +492,16 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) env_get("gatewayip"), env_get("netmask")); } -#ifdef CONFIG_CMD_NET - if (label->ipappend & 0x2) { - int err; + if (IS_ENABLED(CONFIG_CMD_NET)) { + if (label->ipappend & 0x2) { + int err; - strcpy(mac_str, " BOOTIF="); - err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); - if (err < 0) - mac_str[0] = '\0'; + strcpy(mac_str, " BOOTIF="); + err = format_mac_pxe(mac_str + 8, sizeof(mac_str) - 8); + if (err < 0) + mac_str[0] = '\0'; + } } -#endif if ((label->ipappend & 0x3) || label->append) { char bootargs[CONFIG_SYS_CBSIZE] = ""; @@ -649,15 +649,13 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) /* Try bootm for legacy and FIT format image */ if (genimg_get_format(buf) != IMAGE_FORMAT_INVALID) do_bootm(cmdtp, 0, bootm_argc, bootm_argv); -#ifdef CONFIG_CMD_BOOTI /* Try booting an AArch64 Linux kernel image */ - else + else if (IS_ENABLED(CONFIG_CMD_BOOTI)) do_booti(cmdtp, 0, bootm_argc, bootm_argv); -#elif defined(CONFIG_CMD_BOOTZ) /* Try booting a Image */ - else + else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) do_bootz(cmdtp, 0, bootm_argc, bootm_argv); -#endif + unmap_sysmem(buf); cleanup: @@ -1424,20 +1422,20 @@ void handle_pxe_menu(struct cmd_tbl *cmdtp, struct pxe_menu *cfg) struct menu *m; int err; -#ifdef CONFIG_CMD_BMP - /* display BMP if available */ - if (cfg->bmp) { - if (get_relfile(cmdtp, cfg->bmp, image_load_addr)) { - if (CONFIG_IS_ENABLED(CMD_CLS)) - run_command("cls", 0); - bmp_display(image_load_addr, - BMP_ALIGN_CENTER, BMP_ALIGN_CENTER); - } else { - printf("Skipping background bmp %s for failure\n", - cfg->bmp); + if (IS_ENABLED(CONFIG_CMD_BMP)) { + /* display BMP if available */ + if (cfg->bmp) { + if (get_relfile(cmdtp, cfg->bmp, image_load_addr)) { + if (CONFIG_IS_ENABLED(CMD_CLS)) + run_command("cls", 0); + bmp_display(image_load_addr, + BMP_ALIGN_CENTER, BMP_ALIGN_CENTER); + } else { + printf("Skipping background bmp %s for failure\n", + cfg->bmp); + } } } -#endif m = pxe_menu_to_menu(cfg); if (!m) From 18c25821836b4673aa67a43c792a4a82480f47fa Mon Sep 17 00:00:00 2001 From: Kory Maincent Date: Tue, 2 Feb 2021 16:42:29 +0100 Subject: [PATCH 4/4] cmd: pxe_utils: sysboot: Add zboot support to boot x86 Linux kernel image Add "zboot" command to the list of supported boot in the label_boot function. Signed-off-by: Kory Maincent Reviewed-by: Simon Glass Reviewed-by: Bin Meng [bmeng: add component tags in the summary] Signed-off-by: Bin Meng --- cmd/pxe_utils.c | 3 +++ include/command.h | 3 +++ 2 files changed, 6 insertions(+) diff --git a/cmd/pxe_utils.c b/cmd/pxe_utils.c index 81150b162b..71c5af4c25 100644 --- a/cmd/pxe_utils.c +++ b/cmd/pxe_utils.c @@ -655,6 +655,9 @@ static int label_boot(struct cmd_tbl *cmdtp, struct pxe_label *label) /* Try booting a Image */ else if (IS_ENABLED(CONFIG_CMD_BOOTZ)) do_bootz(cmdtp, 0, bootm_argc, bootm_argv); + /* Try booting an x86_64 Linux kernel image */ + else if (IS_ENABLED(CONFIG_CMD_ZBOOT)) + do_zboot_parent(cmdtp, 0, bootm_argc, bootm_argv, NULL); unmap_sysmem(buf); diff --git a/include/command.h b/include/command.h index 27604758a4..747f8f8095 100644 --- a/include/command.h +++ b/include/command.h @@ -165,6 +165,9 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]); +int do_zboot_parent(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[], int *repeatable); + int common_diskboot(struct cmd_tbl *cmdtp, const char *intf, int argc, char *const argv[]);