From 724cdffca179057f4ebdf413ad764ea70b0e8ed2 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 30 Nov 2012 13:01:15 +0000 Subject: arm: Keep track of the tlb size as well as its location It may be necessary to know where the TLB area ends as well as where it starts. This allows board code to complete a secure memory erase without destroying the page tables. Signed-off-by: Gabe Black Signed-off-by: Simon Glass --- arch/arm/lib/board.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'arch/arm/lib/board.c') diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 0459d0ce9f..c214bba881 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -348,13 +348,14 @@ void board_init_f(ulong bootflag) #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) /* reserve TLB table */ - addr -= (4096 * 4); + gd->tlb_size = 4096 * 4; + addr -= gd->tlb_size; /* round down to next 64 kB limit */ addr &= ~(0x10000 - 1); gd->tlb_addr = addr; - debug("TLB table at: %08lx\n", addr); + debug("TLB table from %08lx to %08lx\n", addr, addr + gd->tlb_size); #endif /* round down to next 4 kB limit */ -- cgit From eae78c3406e8b53950ab716567157aa836a5f398 Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 30 Nov 2012 13:01:16 +0000 Subject: arm: Move fdt check earlier so that board_early_init_f() can use it We want to use the fdt inside board_early_init_f(), so check for its presence earlier in the pre-reloc init sequence. So far ARM and microblaze are the only only ones that use CONFIG_OF_CONTROL. Microblaze does not have the same init loop, and in particular does not have the board_early_init_f() call. So a patch for microblaze would have no meaning. Signed-off-by: Simon Glass --- arch/arm/lib/board.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'arch/arm/lib/board.c') diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index c214bba881..864b53380b 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -233,12 +233,11 @@ int power_init_board(void) init_fnc_t *init_sequence[] = { arch_cpu_init, /* basic arch cpu dependent setup */ - -#if defined(CONFIG_BOARD_EARLY_INIT_F) - board_early_init_f, -#endif #ifdef CONFIG_OF_CONTROL fdtdec_check_fdt, +#endif +#if defined(CONFIG_BOARD_EARLY_INIT_F) + board_early_init_f, #endif timer_init, /* initialize timer */ #ifdef CONFIG_BOARD_POSTCLK_INIT -- cgit From 06fd853890f23491605bfd6c9ab0116b79e15aaa Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 30 Nov 2012 13:01:17 +0000 Subject: arm: Add CONFIG_DELAY_ENVIRONMENT to delay environment loading This option delays loading of the environment until later, so that only the default environment will be available to U-Boot. This can address the security risk of untrusted data being used during boot. Any time you load untrusted data you expose yourself to a bug in the code. The attacker gets to choose the data so can sometimes carefully craft it to exploit a bug. We try to avoid touching user-controlled data during a verified boot unless strictly necessary. Since the default environment is good enough in this case (or you would just change it), this gets around the problem by just not loading the environment. When CONFIG_DELAY_ENVIRONMENT is defined, it is convenient to have a run-time way of enabling loading of the environment. Add this to the fdt as /config/delay-environment. Note: This patch depends on http://patchwork.ozlabs.org/patch/194342/ Signed-off-by: Doug Anderson Signed-off-by: Simon Glass Reviewed-by: Doug Anderson --- arch/arm/lib/board.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'arch/arm/lib/board.c') diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 864b53380b..a1eb7993ad 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -467,7 +468,28 @@ static char *failed = "*** failed ***\n"; #endif /* - ************************************************************************ + * Tell if it's OK to load the environment early in boot. + * + * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see + * if this is OK (defaulting to saying it's not OK). + * + * NOTE: Loading the environment early can be a bad idea if security is + * important, since no verification is done on the environment. + * + * @return 0 if environment should not be loaded, !=0 if it is ok to load + */ +static int should_load_env(void) +{ +#ifdef CONFIG_OF_CONTROL + return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 0); +#elif defined CONFIG_DELAY_ENVIRONMENT + return 0; +#else + return 1; +#endif +} + +/************************************************************************ * * This is the next part if the initialization sequence: we are now * running from RAM and have a "normal" C environment, i. e. global @@ -570,7 +592,10 @@ void board_init_r(gd_t *id, ulong dest_addr) #endif /* initialize environment */ - env_relocate(); + if (should_load_env()) + env_relocate(); + else + set_default_env(NULL); #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI) arm_pci_init(); -- cgit From e2e3e2b1be703e0c93d0e49cac9a0dd2e1ba8f6e Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 30 Nov 2012 13:01:19 +0000 Subject: arm: Add CONFIG_DISPLAY_BOARDINFO_LATE to display board info on LCD This option displays board info after stdio is running, so that it will appear on the LCD. If it is displayed earlier, the board info will appear on the serial console but not on the LCD. Here follows a blow-by-blow description. 1a. Without CONFIG_DISPLAY_BOARDINFO_LATE, on serial: U-Boot 2011.12-02550-g037e1c5-dirty (Nov 15 2012 - 14:29:42) for SMDK5250 CPU: S5PC520 @ 1700MHz Board: Google Snow, rev 0 I2C: ready DRAM: 2 GiB Elpida DDR3 @ 800MHz MMC: S5P MSHC0: 0, S5P MSHC1: 1 SF: Detected W25Q32 with page size 4 KiB, total 4 MiB *** Warning - bad CRC, using default environment In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0 SMDK5250 # 1b. Without CONFIG_DISPLAY_BOARDINFO_LATE, on LCD (note machine info is missing): In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0 SMDK5250 # 2a. With CONFIG_DISPLAY_BOARDINFO_LATE, on serial: U-Boot 2011.12-02550-g037e1c5 (Nov 15 2012 - 14:27:40) for SMDK5250 CPU: S5PC520 @ 1700MHz I2C: ready DRAM: 2 GiB Elpida DDR3 @ 800MHz MMC: S5P MSHC0: 0, S5P MSHC1: 1 SF: Detected W25Q32 with page size 4 KiB, total 4 MiB *** Warning - bad CRC, using default environment Model: Google Snow In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0 SMDK5250 # 2b. With CONFIG_DISPLAY_BOARDINFO_LATE, on LCD (note machine info is present): Model: Google Snow In: mkbp-keyb Out: lcd Err: lcd Net: No ethernet found. Hit any key to stop autoboot: 0 SMDK5250 # Since the LCD is all that a typical user sees, it is useful to display the model there. We may be able to rearrange things some other way one day, but at present this seems like a convenient way of getting the required behaviour. Signed-off-by: Simon Glass --- arch/arm/lib/board.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'arch/arm/lib/board.c') diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index a1eb7993ad..ec5c35f131 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -489,6 +489,16 @@ static int should_load_env(void) #endif } +#if defined(CONFIG_DISPLAY_BOARDINFO_LATE) && defined(CONFIG_OF_CONTROL) +static void display_fdt_model(const void *blob) +{ + const char *model; + + model = (char *)fdt_getprop(blob, 0, "model", NULL); + printf("Model: %s\n", model ? model : ""); +} +#endif + /************************************************************************ * * This is the next part if the initialization sequence: we are now @@ -612,6 +622,15 @@ void board_init_r(gd_t *id, ulong dest_addr) console_init_r(); /* fully init console as a device */ +#ifdef CONFIG_DISPLAY_BOARDINFO_LATE +# ifdef CONFIG_OF_CONTROL + /* Put this here so it appears on the LCD, now it is ready */ + display_fdt_model(gd->fdt_blob); +# else + checkboard(); +# endif +#endif + #if defined(CONFIG_ARCH_MISC_INIT) /* miscellaneous arch dependent initialisations */ arch_misc_init(); -- cgit From 2f8d8d6b3aedcea36db84872a4174eb8d5903f8f Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Fri, 30 Nov 2012 13:01:22 +0000 Subject: arm: Move bootstage record for board_init_f() to after arch_cpu_init() The timer may be inited in arch_cpu_init() so it is not safe to make a bootstage mark before this is called. Arrange the code to fix this. Note: The question was raised as to why we don't keep all archs in sync. PowerPC doesn't have specific bootstage markers at present (although it does use boot progress). I hope that the generic board series will solve this problem in general, but in the meantime this is a real problem, and only in ARM. We now get a correct time for board_init_f: Timer summary in microseconds: Mark Elapsed Stage 0 0 reset 100,000 100,000 spl_start 848,530 748,530 board_init_f 907,301 58,771 board_init_r 910,478 3,177 board_init Signed-off-by: Simon Glass --- arch/arm/lib/board.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'arch/arm/lib/board.c') diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index ec5c35f131..404ef4dceb 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -232,8 +232,17 @@ int __power_init_board(void) int power_init_board(void) __attribute__((weak, alias("__power_init_board"))); + /* Record the board_init_f() bootstage (after arch_cpu_init()) */ +static int mark_bootstage(void) +{ + bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); + + return 0; +} + init_fnc_t *init_sequence[] = { arch_cpu_init, /* basic arch cpu dependent setup */ + mark_bootstage, #ifdef CONFIG_OF_CONTROL fdtdec_check_fdt, #endif @@ -277,8 +286,6 @@ void board_init_f(ulong bootflag) void *new_fdt = NULL; size_t fdt_size = 0; - bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); - memset((void *)gd, 0, sizeof(gd_t)); gd->mon_len = _bss_end_ofs; -- cgit From 80e409508b9bba8c372cdd44565a3d472b10e904 Mon Sep 17 00:00:00 2001 From: Taylor Hutt Date: Fri, 30 Nov 2012 13:01:23 +0000 Subject: arm: Tabify code for MMC initialization The two modified lines were indented with spaces. They are now indented with tabs. Signed-off-by: Taylor Hutt Signed-off-by: Simon Glass --- arch/arm/lib/board.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch/arm/lib/board.c') diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index 404ef4dceb..cfe32cc926 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -599,8 +599,8 @@ void board_init_r(gd_t *id, ulong dest_addr) #endif #ifdef CONFIG_GENERIC_MMC - puts("MMC: "); - mmc_initialize(gd->bd); + puts("MMC: "); + mmc_initialize(gd->bd); #endif #ifdef CONFIG_HAS_DATAFLASH -- cgit