diff options
author | Robin Getz <robin.getz@analog.com> | 2009-06-26 08:23:51 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-07-16 01:52:21 -0400 |
commit | dc437b1b596e310bb583de3868c3d61a6798c81c (patch) | |
tree | bc208f10f955095dc8e71c952cd895d83a90db0f /arch/blackfin | |
parent | 15627bd35c6f02d159e0cb41d287dcba3a23a135 (diff) |
Blackfin: fix silent crash when no uClinux MTD filesystem exists
Since we need to relocate the attached filesystem with the uClinux MTD map
(to handle some anomalies), we need to know its real filesize. If we boot
a kernel without a filesystem actually attached, we end up blindly reading
and copying garbage (since there is no magic value to detect validity).
Often times this results in an early crash and no output. So add a few
basic sanity checks before operating on things to catch the majority of
cases.
Signed-off-by: Robin Getz <robin.getz@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'arch/blackfin')
-rw-r--r-- | arch/blackfin/kernel/setup.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/arch/blackfin/kernel/setup.c b/arch/blackfin/kernel/setup.c index 6e150d9b8862..e4d2da7c1c9d 100644 --- a/arch/blackfin/kernel/setup.c +++ b/arch/blackfin/kernel/setup.c | |||
@@ -568,17 +568,23 @@ static __init void memory_setup(void) | |||
568 | # endif /* ANOMALY_05000263 */ | 568 | # endif /* ANOMALY_05000263 */ |
569 | # endif /* CONFIG_ROMFS_FS */ | 569 | # endif /* CONFIG_ROMFS_FS */ |
570 | 570 | ||
571 | memory_end -= mtd_size; | 571 | /* Since the default MTD_UCLINUX has no magic number, we just blindly |
572 | 572 | * read 8 past the end of the kernel's image, and look at it. | |
573 | if (mtd_size == 0) { | 573 | * When no image is attached, mtd_size is set to a random number |
574 | console_init(); | 574 | * Do some basic sanity checks before operating on things |
575 | panic("Don't boot kernel without rootfs attached."); | 575 | */ |
576 | if (mtd_size == 0 || memory_end <= mtd_size) { | ||
577 | pr_emerg("Could not find valid ram mtd attached.\n"); | ||
578 | } else { | ||
579 | memory_end -= mtd_size; | ||
580 | |||
581 | /* Relocate MTD image to the top of memory after the uncached memory area */ | ||
582 | uclinux_ram_map.phys = memory_mtd_start = memory_end; | ||
583 | uclinux_ram_map.size = mtd_size; | ||
584 | pr_info("Found mtd parition at 0x%p, (len=0x%lx), moving to 0x%p\n", | ||
585 | _end, mtd_size, (void *)memory_mtd_start); | ||
586 | dma_memcpy((void *)uclinux_ram_map.phys, _end, uclinux_ram_map.size); | ||
576 | } | 587 | } |
577 | |||
578 | /* Relocate MTD image to the top of memory after the uncached memory area */ | ||
579 | uclinux_ram_map.phys = memory_mtd_start = memory_end; | ||
580 | uclinux_ram_map.size = mtd_size; | ||
581 | dma_memcpy((void *)uclinux_ram_map.phys, _end, uclinux_ram_map.size); | ||
582 | #endif /* CONFIG_MTD_UCLINUX */ | 588 | #endif /* CONFIG_MTD_UCLINUX */ |
583 | 589 | ||
584 | #if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263) | 590 | #if (defined(CONFIG_BFIN_EXTMEM_ICACHEABLE) && ANOMALY_05000263) |