s390/setup: fix memblock usage
authorHeiko Carstens <heiko.carstens@de.ibm.com>
Thu, 1 Dec 2016 11:20:09 +0000 (12:20 +0100)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Fri, 2 Dec 2016 06:36:24 +0000 (07:36 +0100)
When converting from bootmem to memblock I missed a subtle difference:
the memblock_alloc() functions return uninitialized memory, while the
memblock_virt_alloc() functions return zeroed memory.

This led to quite random early boot crashes.

Therefore use the correct version everywhere now.
Hopefully.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
arch/s390/kernel/setup.c

index 14b57ddd4f62d8ac5c31208efc9cc8b823544f57..b57e28f1edc253aca1d1b0babf3aa77cba95c551 100644 (file)
@@ -304,9 +304,7 @@ static void __init setup_lowcore(void)
         * Setup lowcore for boot cpu
         */
        BUILD_BUG_ON(sizeof(struct lowcore) != LC_PAGES * 4096);
-       lc = (struct lowcore *) memblock_alloc_base(sizeof(struct lowcore),
-                                                   sizeof(struct lowcore),
-                                                   MAX_DMA_ADDRESS);
+       lc = memblock_virt_alloc_low(sizeof(*lc), sizeof(*lc));
        lc->restart_psw.mask = PSW_KERNEL_BITS;
        lc->restart_psw.addr = (unsigned long) restart_int_handler;
        lc->external_new_psw.mask = PSW_KERNEL_BITS |
@@ -326,9 +324,11 @@ static void __init setup_lowcore(void)
        lc->clock_comparator = -1ULL;
        lc->kernel_stack = ((unsigned long) &init_thread_union)
                + THREAD_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs);
-       lc->async_stack = memblock_alloc(ASYNC_SIZE, ASYNC_SIZE)
+       lc->async_stack = (unsigned long)
+               memblock_virt_alloc(ASYNC_SIZE, ASYNC_SIZE)
                + ASYNC_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs);
-       lc->panic_stack = memblock_alloc(PAGE_SIZE, PAGE_SIZE)
+       lc->panic_stack = (unsigned long)
+               memblock_virt_alloc(PAGE_SIZE, PAGE_SIZE)
                + PAGE_SIZE - STACK_FRAME_OVERHEAD - sizeof(struct pt_regs);
        lc->current_task = (unsigned long)&init_task;
        lc->lpp = LPP_MAGIC;
@@ -350,7 +350,7 @@ static void __init setup_lowcore(void)
        lc->last_update_timer = S390_lowcore.last_update_timer;
        lc->last_update_clock = S390_lowcore.last_update_clock;
 
-       restart_stack = (void *) memblock_alloc(ASYNC_SIZE, ASYNC_SIZE);
+       restart_stack = memblock_virt_alloc(ASYNC_SIZE, ASYNC_SIZE);
        restart_stack += ASYNC_SIZE;
 
        /*
@@ -413,7 +413,7 @@ static void __init setup_resources(void)
        bss_resource.end = (unsigned long) &__bss_stop - 1;
 
        for_each_memblock(memory, reg) {
-               res = (void *) memblock_alloc(sizeof(*res), 8);
+               res = memblock_virt_alloc(sizeof(*res), 8);
                res->flags = IORESOURCE_BUSY | IORESOURCE_SYSTEM_RAM;
 
                res->name = "System RAM";
@@ -427,7 +427,7 @@ static void __init setup_resources(void)
                            std_res->start > res->end)
                                continue;
                        if (std_res->end > res->end) {
-                               sub_res = (void *) memblock_alloc(sizeof(*sub_res), 8);
+                               sub_res = memblock_virt_alloc(sizeof(*sub_res), 8);
                                *sub_res = *std_res;
                                sub_res->end = res->end;
                                std_res->start = res->end + 1;