Commit cda1fd5a authored by Michal Simek's avatar Michal Simek

microblaze: Cleanup compiled-in rootfs in BSS section

This patch is based on patch from Steve Magnani.

There were bug for compiled-in rootfs. We have to move
moving rootfs which is in BSS section to _ebss section
which is at the end of kernel and then clear bss section
not vice-versa.
Signed-off-by: default avatarMichal Simek <monstr@monstr.eu>
parent 1dff89a9
...@@ -98,6 +98,29 @@ void __init machine_early_init(const char *cmdline, unsigned int ram, ...@@ -98,6 +98,29 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
{ {
unsigned long *src, *dst = (unsigned long *)0x0; unsigned long *src, *dst = (unsigned long *)0x0;
/* If CONFIG_MTD_UCLINUX is defined, assume ROMFS is at the
* end of kernel. There are two position which we want to check.
* The first is __init_end and the second __bss_start.
*/
#ifdef CONFIG_MTD_UCLINUX
int romfs_size;
unsigned int romfs_base;
char *old_klimit = klimit;
romfs_base = (ram ? ram : (unsigned int)&__init_end);
romfs_size = PAGE_ALIGN(get_romfs_len((unsigned *)romfs_base));
if (!romfs_size) {
romfs_base = (unsigned int)&__bss_start;
romfs_size = PAGE_ALIGN(get_romfs_len((unsigned *)romfs_base));
}
/* Move ROMFS out of BSS before clearing it */
if (romfs_size > 0) {
memmove(&_ebss, (int *)romfs_base, romfs_size);
klimit += romfs_size;
}
#endif
/* clearing bss section */ /* clearing bss section */
memset(__bss_start, 0, __bss_stop-__bss_start); memset(__bss_start, 0, __bss_stop-__bss_start);
memset(_ssbss, 0, _esbss-_ssbss); memset(_ssbss, 0, _esbss-_ssbss);
...@@ -119,27 +142,15 @@ void __init machine_early_init(const char *cmdline, unsigned int ram, ...@@ -119,27 +142,15 @@ void __init machine_early_init(const char *cmdline, unsigned int ram,
printk(KERN_NOTICE "Found FDT at 0x%08x\n", fdt); printk(KERN_NOTICE "Found FDT at 0x%08x\n", fdt);
#ifdef CONFIG_MTD_UCLINUX #ifdef CONFIG_MTD_UCLINUX
{
int size;
unsigned int romfs_base;
romfs_base = (ram ? ram : (unsigned int)&__init_end);
/* if CONFIG_MTD_UCLINUX_EBSS is defined, assume ROMFS is at the
* end of kernel, which is ROMFS_LOCATION defined above. */
size = PAGE_ALIGN(get_romfs_len((unsigned *)romfs_base));
early_printk("Found romfs @ 0x%08x (0x%08x)\n", early_printk("Found romfs @ 0x%08x (0x%08x)\n",
romfs_base, size); romfs_base, romfs_size);
early_printk("#### klimit %p ####\n", klimit); early_printk("#### klimit %p ####\n", old_klimit);
BUG_ON(size < 0); /* What else can we do? */ BUG_ON(romfs_size < 0); /* What else can we do? */
/* Use memmove to handle likely case of memory overlap */ early_printk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n",
early_printk("Moving 0x%08x bytes from 0x%08x to 0x%08x\n", romfs_size, romfs_base, (unsigned)&_ebss);
size, romfs_base, (unsigned)&_ebss);
memmove(&_ebss, (int *)romfs_base, size);
/* update klimit */
klimit += PAGE_ALIGN(size);
early_printk("New klimit: 0x%08x\n", (unsigned)klimit); early_printk("New klimit: 0x%08x\n", (unsigned)klimit);
}
#endif #endif
for (src = __ivt_start; src < __ivt_end; src++, dst++) for (src = __ivt_start; src < __ivt_end; src++, dst++)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment