Skip to content

Commit

Permalink
Block early_write during MMU pagetable initialization to avoid crashi…
Browse files Browse the repository at this point in the history
…ng kernel
  • Loading branch information
hno authored and amery committed Apr 2, 2012
1 parent 0001448 commit f7d7280
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/arm/kernel/early_printk.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,12 @@

extern void printch(int);

int early_write_ok = 1;

static void early_write(const char *s, unsigned n)
{
if (!early_write_ok)
return;
while (n-- > 0) {
if (*s == '\n')
printch('\r');
Expand Down
10 changes: 10 additions & 0 deletions arch/arm/mm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -993,16 +993,23 @@ void __init arm_mm_memblock_reserve(void)
* called function. This means you can't use any function or debugging
* method which may touch any device, otherwise the kernel _will_ crash.
*/
#define EARLY_WRITE_OK defined(CONFIG_DEBUG_LL) && !defined(CONFIG_DEBUG_ICEDCC)
static void __init devicemaps_init(struct machine_desc *mdesc)
{
struct map_desc map;
unsigned long addr;
#if EARLY_WRITE_OK
extern int early_write_ok;
#endif

/*
* Allocate the vector page early.
*/
vectors_page = early_alloc(PAGE_SIZE);

#if EARLY_WRITE_OK
early_write_ok = 0;
#endif
for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
pmd_clear(pmd_off_k(addr));

Expand Down Expand Up @@ -1067,6 +1074,9 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
*/
local_flush_tlb_all();
flush_cache_all();
#if EARLY_WRITE_OK
early_write_ok = 1;
#endif
}

static void __init kmap_init(void)
Expand Down

0 comments on commit f7d7280

Please sign in to comment.