[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[microblaze-uclinux] Re: [PATCH] microblaze: fix uClinux romfs corruption
steve@xxxxxxxxxxxxxxx wrote:
> Fix Microblaze startup handling of uClinux romfs so that it is not
> overwritten or corrupted.
>
I looked at your patch again and I see what you are trying to fix. You are trying
to use petalinux with mainline kernel and you are using that objcopy hack
for compiled-in rootfs. For this case it necessary copy image and then cleanup bss
section. (I personally use romfs.img outside kernel code which works).
I did some tests around. I'll send you my patch to check if is work for you too.
Michal
> Signed-off-by: Steven J. Magnani <steve@xxxxxxxxxxxxxxx>
> ---
> diff -uprN a/arch/microblaze/kernel/setup.c b/arch/microblaze/kernel/setup.c
> --- a/arch/microblaze/kernel/setup.c 2009-05-18 12:24:21.000000000 -0500
> +++ b/arch/microblaze/kernel/setup.c 2009-05-18 12:44:05.000000000 -0500
> @@ -23,6 +23,7 @@
> #include <linux/bug.h>
> #include <linux/param.h>
> #include <linux/cache.h>
> +#include <linux/lmb.h>
IMHO this is unneeded.
> #include <asm/cacheflush.h>
> #include <asm/entry.h>
> #include <asm/cpuinfo.h>
> @@ -101,6 +102,23 @@ void __init machine_early_init(const cha
> unsigned int fdt)
> {
> unsigned long *src, *dst = (unsigned long *)0x0;
> +#ifdef CONFIG_MTD_UCLINUX
> + int romfs_size;
> + unsigned int romfs_base;
> + char *old_klimit = klimit;
> +
> + /* Move ROMFS out of BSS before clearing it */
> + {
I think here is no reason to have bracket here
> + 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. */
> + romfs_size = PAGE_ALIGN(get_romfs_len((unsigned *)romfs_base));
> + if (romfs_size > 0) {
> + memmove(&_ebss, (int *)romfs_base, romfs_size);
> + klimit += PAGE_ALIGN(romfs_size);
> + }
> + }
here too.
> +#endif
>
> /* clearing bss section */
> memset(__bss_start, 0, __bss_stop-__bss_start);
> @@ -126,27 +144,15 @@ void __init machine_early_init(const cha
> printk(KERN_NOTICE "Found FDT at 0x%08x\n", fdt);
>
> #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",
> - romfs_base, size);
> - early_printk("#### klimit %p ####\n", klimit);
> - BUG_ON(size < 0); /* What else can we do? */
> -
> - /* Use memmove to handle likely case of memory overlap */
> - early_printk("Moving 0x%08x bytes from 0x%08x to 0x%08x\n",
> - 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("Found romfs @ 0x%08x (0x%08x)\n",
> + romfs_base, romfs_size);
> + early_printk("#### klimit %p ####\n", old_klimit);
> + BUG_ON(romfs_size < 0); /* What else can we do? */
> +
> + early_printk("Moved 0x%08x bytes from 0x%08x to 0x%08x\n",
> + romfs_size, romfs_base, (unsigned)&_ebss);
> +
> + early_printk("New klimit: 0x%08x\n", (unsigned)klimit);
> #endif
>
> for (src = __ivt_start; src < __ivt_end; src++, dst++)
> diff -uprN a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c
> --- a/arch/microblaze/mm/init.c 2009-05-18 12:23:32.000000000 -0500
> +++ b/arch/microblaze/mm/init.c 2009-05-18 12:25:42.000000000 -0500
> @@ -41,7 +41,6 @@ unsigned int memory_size;
> */
> static void __init paging_init(void)
> {
> - int i;
> unsigned long zones_size[MAX_NR_ZONES];
>
> /* Clean every zones */
> @@ -61,6 +60,8 @@ void __init setup_memory(void)
> int i;
> unsigned long map_size;
> u32 kernel_align_start, kernel_align_size;
> + unsigned long bootmap_pages;
> + u64 bootmap_start;
>
> /* Find main memory where is the kernel */
> for (i = 0; i < lmb.memory.cnt; i++) {
> @@ -115,15 +116,13 @@ void __init setup_memory(void)
>
> /*
> * Find an area to use for the bootmem bitmap.
> - * We look for the first area which is at least
> - * 128kB in length (128kB is enough for a bitmap
> - * for 4GB of memory, using 4kB pages), plus 1 page
> - * (in case the address isn't page-aligned).
> */
> - map_size = init_bootmem_node(NODE_DATA(0), PFN_UP(TOPHYS((u32)_end)),
> - min_low_pfn, max_low_pfn);
> + bootmap_pages = bootmem_bootmap_pages(lmb_end_of_DRAM() >> PAGE_SHIFT);
>
> - lmb_reserve(PFN_UP(TOPHYS((u32)_end)) << PAGE_SHIFT, map_size);
> + bootmap_start = lmb_alloc(bootmap_pages << PAGE_SHIFT, PAGE_SIZE);
> +
> + map_size = init_bootmem_node(NODE_DATA(0), bootmap_start >> PAGE_SHIFT,
> + min_low_pfn, max_low_pfn);
>
> /* free bootmem is whole main memory */
> free_bootmem(memory_start, memory_size);
> @@ -134,7 +133,7 @@ void __init setup_memory(void)
> (u32) lmb.reserved.region[i].base,
> (u32) lmb_size_bytes(&lmb.reserved, i));
> reserve_bootmem(lmb.reserved.region[i].base,
> - lmb_size_bytes(&lmb.reserved, i) - 1, BOOTMEM_DEFAULT);
> + lmb_size_bytes(&lmb.reserved, i), BOOTMEM_DEFAULT);
> }
> paging_init();
> }
>
--
Michal Simek, Ing. (M.Eng)
w: www.monstr.eu p: +42-0-721842854
___________________________
microblaze-uclinux mailing list
microblaze-uclinux@xxxxxxxxxxxxxx
Project Home Page : http://www.itee.uq.edu.au/~jwilliams/mblaze-uclinux
Mailing List Archive : http://www.itee.uq.edu.au/~listarch/microblaze-uclinux/