Skip to content
Snippets Groups Projects
Commit 76da19df authored by Kumar Gala's avatar Kumar Gala Committed by Wolfgang Denk
Browse files

Added arch_lmb_reserve to allow arch specific memory regions protection


Each architecture has different ways of determine what regions of memory
might not be valid to get overwritten when we boot.  This provides a
hook to allow them to reserve any regions they care about.  Currently
only ppc, m68k and sparc need/use this.

Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
parent e02d4a99
No related branches found
No related tags found
No related merge requests found
...@@ -128,6 +128,12 @@ void __board_lmb_reserve(struct lmb *lmb) ...@@ -128,6 +128,12 @@ void __board_lmb_reserve(struct lmb *lmb)
} }
void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve"))); void board_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__board_lmb_reserve")));
void __arch_lmb_reserve(struct lmb *lmb)
{
/* please define platform specific arch_lmb_reserve() */
}
void arch_lmb_reserve(struct lmb *lmb) __attribute__((weak, alias("__arch_lmb_reserve")));
#if defined(__ARM__) #if defined(__ARM__)
#define IH_INITRD_ARCH IH_ARCH_ARM #define IH_INITRD_ARCH IH_ARCH_ARM
#elif defined(__avr32__) #elif defined(__avr32__)
...@@ -173,6 +179,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) ...@@ -173,6 +179,7 @@ static int bootm_start(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size); lmb_add(&images.lmb, (phys_addr_t)mem_start, mem_size);
arch_lmb_reserve(&images.lmb);
board_lmb_reserve(&images.lmb); board_lmb_reserve(&images.lmb);
/* get kernel image header, start address and length */ /* get kernel image header, start address and length */
......
...@@ -43,22 +43,10 @@ DECLARE_GLOBAL_DATA_PTR; ...@@ -43,22 +43,10 @@ DECLARE_GLOBAL_DATA_PTR;
static ulong get_sp (void); static ulong get_sp (void);
static void set_clocks_in_mhz (bd_t *kbd); static void set_clocks_in_mhz (bd_t *kbd);
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) void arch_lmb_reserve(struct lmb *lmb)
{ {
ulong sp; ulong sp;
ulong rd_len;
ulong initrd_start, initrd_end;
int ret;
ulong cmd_start, cmd_end;
ulong bootmap_base;
bd_t *kbd;
void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
struct lmb *lmb = &images->lmb;
bootmap_base = getenv_bootm_low();
/* /*
* Booting a (Linux) kernel image * Booting a (Linux) kernel image
* *
...@@ -74,6 +62,21 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) ...@@ -74,6 +62,21 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
/* adjust sp by 1K to be safe */ /* adjust sp by 1K to be safe */
sp -= 1024; sp -= 1024;
lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp)); lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
}
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
ulong rd_len;
ulong initrd_start, initrd_end;
int ret;
ulong cmd_start, cmd_end;
ulong bootmap_base;
bd_t *kbd;
void (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
struct lmb *lmb = &images->lmb;
bootmap_base = getenv_bootm_low();
/* allocate space and init command line */ /* allocate space and init command line */
ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base); ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
......
...@@ -55,30 +55,10 @@ static void set_clocks_in_mhz (bd_t *kbd); ...@@ -55,30 +55,10 @@ static void set_clocks_in_mhz (bd_t *kbd);
#define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE (768*1024*1024) #define CONFIG_SYS_LINUX_LOWMEM_MAX_SIZE (768*1024*1024)
#endif #endif
__attribute__((noinline)) void arch_lmb_reserve(struct lmb *lmb)
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{ {
ulong sp;
ulong initrd_start, initrd_end;
ulong rd_len;
ulong size;
phys_size_t bootm_size; phys_size_t bootm_size;
ulong size, sp, bootmap_base;
ulong cmd_start, cmd_end, bootmap_base;
bd_t *kbd;
void (*kernel)(bd_t *, ulong r4, ulong r5, ulong r6,
ulong r7, ulong r8, ulong r9);
int ret;
ulong of_size = images->ft_len;
struct lmb *lmb = &images->lmb;
#if defined(CONFIG_OF_LIBFDT)
char *of_flat_tree = images->ft_addr;
#endif
kernel = (void (*)(bd_t *, ulong, ulong, ulong,
ulong, ulong, ulong))images->ep;
bootmap_base = getenv_bootm_low(); bootmap_base = getenv_bootm_low();
bootm_size = getenv_bootm_size(); bootm_size = getenv_bootm_size();
...@@ -116,6 +96,32 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) ...@@ -116,6 +96,32 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
sp -= 1024; sp -= 1024;
lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - sp)); lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + get_effective_memsize() - sp));
return ;
}
__attribute__((noinline))
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
{
ulong initrd_start, initrd_end;
ulong rd_len;
ulong cmd_start, cmd_end, bootmap_base;
bd_t *kbd;
void (*kernel)(bd_t *, ulong r4, ulong r5, ulong r6,
ulong r7, ulong r8, ulong r9);
int ret;
ulong of_size = images->ft_len;
struct lmb *lmb = &images->lmb;
#if defined(CONFIG_OF_LIBFDT)
char *of_flat_tree = images->ft_addr;
#endif
kernel = (void (*)(bd_t *, ulong, ulong, ulong,
ulong, ulong, ulong))images->ep;
bootmap_base = getenv_bootm_low();
if (!of_size) { if (!of_size) {
/* allocate space and init command line */ /* allocate space and init command line */
ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base); ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
......
...@@ -81,6 +81,15 @@ struct __attribute__ ((packed)) { ...@@ -81,6 +81,15 @@ struct __attribute__ ((packed)) {
/* temporary initrd image holder */ /* temporary initrd image holder */
image_header_t ihdr; image_header_t ihdr;
void arch_lmb_reserve(struct lmb *lmb)
{
/* Reserve the space used by PROM and stack. This is done
* to avoid that the RAM image is copied over stack or
* PROM.
*/
lmb_reserve(lmb, CONFIG_SYS_RELOC_MONITOR_BASE, CONFIG_SYS_RAM_END);
}
/* boot the linux kernel */ /* boot the linux kernel */
int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t * images) int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t * images)
{ {
...@@ -124,13 +133,6 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t * images) ...@@ -124,13 +133,6 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t * images)
rd_len = images->rd_end - images->rd_start; rd_len = images->rd_end - images->rd_start;
if (rd_len) { if (rd_len) {
/* Reserve the space used by PROM and stack. This is done
* to avoid that the RAM image is copied over stack or
* PROM.
*/
lmb_reserve(lmb, CONFIG_SYS_RELOC_MONITOR_BASE, CONFIG_SYS_RAM_END);
ret = boot_ramdisk_high(lmb, images->rd_start, rd_len, ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
&initrd_start, &initrd_end); &initrd_start, &initrd_end);
if (ret) { if (ret) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment