From 3243d87441bf7f97c5c9f7dd46b35f5783ec6740 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 30 Apr 2008 13:21:45 +1000 Subject: [POWERPC] Make emergency stack safe for current_thread_info() use The current_thread_info() macro, used by preempt_count(), assumes the base address and size of the stack are THREAD_SIZE aligned. The emergency stack currently isn't either of these things, which could potentially cause problems anytime we're running on the emergency stack. That includes when we detect a bad kernel stack pointer, and also during early_setup_secondary(). Signed-off-by: Michael Ellerman Signed-off-by: Paul Mackerras --- arch/powerpc/kernel/setup_64.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'arch/powerpc/kernel') diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index dff6308..25e3fd8 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -487,9 +487,12 @@ static void __init emergency_stack_init(void) */ limit = min(0x10000000UL, lmb.rmo_size); - for_each_possible_cpu(i) - paca[i].emergency_sp = - __va(lmb_alloc_base(HW_PAGE_SIZE, 128, limit)) + HW_PAGE_SIZE; + for_each_possible_cpu(i) { + unsigned long sp; + sp = lmb_alloc_base(THREAD_SIZE, THREAD_SIZE, limit); + sp += THREAD_SIZE; + paca[i].emergency_sp = __va(sp); + } } /* -- cgit v1.1 From eabd90944b3a00766e84da3d117ea0f3e0a3b1a3 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Wed, 30 Apr 2008 14:47:12 +1000 Subject: [POWERPC] Fix crashkernel= handling when no crashkernel= specified Commit edd8ce67436851a62f99f1d9707b40ea6a8e5323 (Use extended crashkernel command line on ppc64), changed the logic in reserve_crashkernel() which deals with the crashkernel= command line option. This introduced a bug in the case when there is no crashkernel= option, or it is incorrect. We would fall through and calculate the crash_size based on the existing values in crashk_res. If both start and end are 0, the default, we calculate the crash_size as 1 byte - which is wrong. Rework the logic so that we use crashk_res, regardless of whether it's set by the command line or via the device tree (see prom.c). Then check if we have an empty range (end == start), and if so make sure to set both end and start to zero (this is checked in machine_kexec_64.c). Then we calculate the crash_size once we know we have a non-zero range. Finally we always want to warn the user if they specify a base != 32MB, so remove the special case for that in the command line parsing case. Signed-off-by: Michael Ellerman Signed-off-by: Paul Mackerras --- arch/powerpc/kernel/machine_kexec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'arch/powerpc/kernel') diff --git a/arch/powerpc/kernel/machine_kexec.c b/arch/powerpc/kernel/machine_kexec.c index 2d202f2..29a0e03 100644 --- a/arch/powerpc/kernel/machine_kexec.c +++ b/arch/powerpc/kernel/machine_kexec.c @@ -74,20 +74,20 @@ void __init reserve_crashkernel(void) ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(), &crash_size, &crash_base); if (ret == 0 && crash_size > 0) { - if (crash_base == 0) - crash_base = KDUMP_KERNELBASE; crashk_res.start = crash_base; - } else { - /* handle the device tree */ - crash_size = crashk_res.end - crashk_res.start + 1; + crashk_res.end = crash_base + crash_size - 1; } - if (crash_size == 0) + if (crashk_res.end == crashk_res.start) { + crashk_res.start = crashk_res.end = 0; return; + } /* We might have got these values via the command line or the * device tree, either way sanitise them now. */ + crash_size = crashk_res.end - crashk_res.start + 1; + if (crashk_res.start != KDUMP_KERNELBASE) printk("Crash kernel location must be 0x%x\n", KDUMP_KERNELBASE); -- cgit v1.1