[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
/*
|
|
|
|
* Code to handle transition of Linux booting another kernel.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002-2003 Eric Biederman <ebiederm@xmission.com>
|
|
|
|
* GameCube/ppc32 port Copyright (C) 2004 Albert Herranz
|
|
|
|
* Copyright (C) 2005 IBM Corporation.
|
|
|
|
*
|
|
|
|
* This source code is licensed under the GNU General Public License,
|
|
|
|
* Version 2. See the file COPYING for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kexec.h>
|
|
|
|
#include <linux/reboot.h>
|
|
|
|
#include <linux/threads.h>
|
2010-07-12 11:36:09 +07:00
|
|
|
#include <linux/memblock.h>
|
2008-12-16 13:22:59 +07:00
|
|
|
#include <linux/of.h>
|
2010-09-17 05:58:23 +07:00
|
|
|
#include <linux/irq.h>
|
2011-01-07 01:00:36 +07:00
|
|
|
#include <linux/ftrace.h>
|
2010-09-17 05:58:23 +07:00
|
|
|
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
#include <asm/machdep.h>
|
2013-11-16 00:31:32 +07:00
|
|
|
#include <asm/pgalloc.h>
|
2008-02-14 07:56:49 +07:00
|
|
|
#include <asm/prom.h>
|
2008-12-16 13:22:59 +07:00
|
|
|
#include <asm/sections.h>
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
|
2010-09-17 05:58:23 +07:00
|
|
|
void machine_kexec_mask_interrupts(void) {
|
|
|
|
unsigned int i;
|
2012-04-23 19:30:02 +07:00
|
|
|
struct irq_desc *desc;
|
2010-09-17 05:58:23 +07:00
|
|
|
|
2012-04-23 19:30:02 +07:00
|
|
|
for_each_irq_desc(i, desc) {
|
2011-03-07 21:00:20 +07:00
|
|
|
struct irq_chip *chip;
|
2010-09-17 05:58:23 +07:00
|
|
|
|
2011-03-25 22:45:20 +07:00
|
|
|
chip = irq_desc_get_chip(desc);
|
2011-03-07 21:00:20 +07:00
|
|
|
if (!chip)
|
|
|
|
continue;
|
|
|
|
|
2011-03-25 21:43:57 +07:00
|
|
|
if (chip->irq_eoi && irqd_irq_inprogress(&desc->irq_data))
|
2011-03-07 21:00:20 +07:00
|
|
|
chip->irq_eoi(&desc->irq_data);
|
2010-09-17 05:58:23 +07:00
|
|
|
|
2011-03-07 21:00:20 +07:00
|
|
|
if (chip->irq_mask)
|
|
|
|
chip->irq_mask(&desc->irq_data);
|
2010-09-17 05:58:23 +07:00
|
|
|
|
2011-03-25 21:43:57 +07:00
|
|
|
if (chip->irq_disable && !irqd_irq_disabled(&desc->irq_data))
|
2011-03-07 21:00:20 +07:00
|
|
|
chip->irq_disable(&desc->irq_data);
|
2010-09-17 05:58:23 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
void machine_crash_shutdown(struct pt_regs *regs)
|
|
|
|
{
|
2011-01-07 00:56:09 +07:00
|
|
|
default_machine_crash_shutdown(regs);
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Do what every setup is needed on image and the
|
|
|
|
* reboot code buffer to allow us to avoid allocations
|
|
|
|
* later.
|
|
|
|
*/
|
|
|
|
int machine_kexec_prepare(struct kimage *image)
|
|
|
|
{
|
|
|
|
if (ppc_md.machine_kexec_prepare)
|
|
|
|
return ppc_md.machine_kexec_prepare(image);
|
2008-12-16 13:23:05 +07:00
|
|
|
else
|
|
|
|
return default_machine_kexec_prepare(image);
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
void machine_kexec_cleanup(struct kimage *image)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-07-13 10:46:09 +07:00
|
|
|
void arch_crash_save_vmcoreinfo(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef CONFIG_NEED_MULTIPLE_NODES
|
|
|
|
VMCOREINFO_SYMBOL(node_data);
|
|
|
|
VMCOREINFO_LENGTH(node_data, MAX_NUMNODES);
|
|
|
|
#endif
|
|
|
|
#ifndef CONFIG_NEED_MULTIPLE_NODES
|
|
|
|
VMCOREINFO_SYMBOL(contig_page_data);
|
|
|
|
#endif
|
2013-11-16 00:31:32 +07:00
|
|
|
#if defined(CONFIG_PPC64) && defined(CONFIG_SPARSEMEM_VMEMMAP)
|
|
|
|
VMCOREINFO_SYMBOL(vmemmap_list);
|
|
|
|
VMCOREINFO_SYMBOL(mmu_vmemmap_psize);
|
|
|
|
VMCOREINFO_SYMBOL(mmu_psize_defs);
|
|
|
|
VMCOREINFO_STRUCT_SIZE(vmemmap_backing);
|
|
|
|
VMCOREINFO_OFFSET(vmemmap_backing, list);
|
|
|
|
VMCOREINFO_OFFSET(vmemmap_backing, phys);
|
|
|
|
VMCOREINFO_OFFSET(vmemmap_backing, virt_addr);
|
|
|
|
VMCOREINFO_STRUCT_SIZE(mmu_psize_def);
|
|
|
|
VMCOREINFO_OFFSET(mmu_psize_def, shift);
|
|
|
|
#endif
|
2010-07-13 10:46:09 +07:00
|
|
|
}
|
|
|
|
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
/*
|
|
|
|
* Do not allocate memory (or fail in any way) in machine_kexec().
|
|
|
|
* We are past the point of no return, committed to rebooting now.
|
|
|
|
*/
|
2008-07-26 09:45:07 +07:00
|
|
|
void machine_kexec(struct kimage *image)
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
{
|
2011-01-07 01:00:36 +07:00
|
|
|
int save_ftrace_enabled;
|
|
|
|
|
|
|
|
save_ftrace_enabled = __ftrace_enabled_save();
|
|
|
|
|
2011-02-23 19:46:16 +07:00
|
|
|
if (ppc_md.machine_kexec)
|
|
|
|
ppc_md.machine_kexec(image);
|
|
|
|
else
|
|
|
|
default_machine_kexec(image);
|
2008-12-16 13:23:05 +07:00
|
|
|
|
2011-01-07 01:00:36 +07:00
|
|
|
__ftrace_enabled_restore(save_ftrace_enabled);
|
|
|
|
|
2008-12-16 13:23:05 +07:00
|
|
|
/* Fall back to normal restart if we're still alive. */
|
|
|
|
machine_restart(NULL);
|
[PATCH] powerpc: Merge kexec
This patch merges, to some extent, the PPC32 and PPC64 kexec implementations.
We adopt the PPC32 approach of having ppc_md callbacks for the kexec functions.
The current PPC64 implementation becomes the "default" implementation for PPC64
which platforms can select if they need no special treatment.
I've added these default callbacks to pseries/maple/cell/powermac, this means
iSeries no longer supports kexec - but it never worked anyway.
I've renamed PPC32's machine_kexec_simple to default_machine_kexec, inline with
PPC64. Judging by the comments it might be better named machine_kexec_non_of,
or something, but at the moment it's the only implementation for PPC32 so it's
the "default".
Kexec requires machine_shutdown(), which is in machine_kexec.c on PPC32, but we
already have in setup-common.c on powerpc. All this does is call
ppc_md.nvram_sync, which only powermac implements, so instead make
machine_shutdown a ppc_md member and have it call core99_nvram_sync directly
on powermac.
I've also stuck relocate_kernel.S into misc_32.S for powerpc.
Built for ARCH=ppc, and 32 & 64 bit ARCH=powerpc, with KEXEC=y/n. Booted on
P5 LPAR and successfully kexec'ed.
Should apply on top of 493f25ef4087395891c99fcfe2c72e62e293e89f.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Signed-off-by: Paul Mackerras <paulus@samba.org>
2005-11-14 19:35:00 +07:00
|
|
|
for(;;);
|
|
|
|
}
|
2006-07-05 11:39:42 +07:00
|
|
|
|
|
|
|
void __init reserve_crashkernel(void)
|
|
|
|
{
|
2007-10-19 13:41:01 +07:00
|
|
|
unsigned long long crash_size, crash_base;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* use common parsing */
|
2010-07-12 11:36:09 +07:00
|
|
|
ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
|
2007-10-19 13:41:01 +07:00
|
|
|
&crash_size, &crash_base);
|
|
|
|
if (ret == 0 && crash_size > 0) {
|
|
|
|
crashk_res.start = crash_base;
|
2008-04-30 11:47:12 +07:00
|
|
|
crashk_res.end = crash_base + crash_size - 1;
|
2007-10-19 13:41:01 +07:00
|
|
|
}
|
2006-07-05 11:39:42 +07:00
|
|
|
|
2008-04-30 11:47:12 +07:00
|
|
|
if (crashk_res.end == crashk_res.start) {
|
|
|
|
crashk_res.start = crashk_res.end = 0;
|
2006-07-05 11:39:42 +07:00
|
|
|
return;
|
2008-04-30 11:47:12 +07:00
|
|
|
}
|
2006-07-05 11:39:42 +07:00
|
|
|
|
|
|
|
/* We might have got these values via the command line or the
|
|
|
|
* device tree, either way sanitise them now. */
|
|
|
|
|
2011-06-09 23:13:32 +07:00
|
|
|
crash_size = resource_size(&crashk_res);
|
2008-04-30 11:47:12 +07:00
|
|
|
|
2011-12-15 05:57:15 +07:00
|
|
|
#ifndef CONFIG_NONSTATIC_KERNEL
|
2006-07-05 11:39:42 +07:00
|
|
|
if (crashk_res.start != KDUMP_KERNELBASE)
|
|
|
|
printk("Crash kernel location must be 0x%x\n",
|
|
|
|
KDUMP_KERNELBASE);
|
|
|
|
|
|
|
|
crashk_res.start = KDUMP_KERNELBASE;
|
2009-01-02 17:46:15 +07:00
|
|
|
#else
|
|
|
|
if (!crashk_res.start) {
|
2011-08-01 02:27:35 +07:00
|
|
|
#ifdef CONFIG_PPC64
|
2009-01-02 17:46:15 +07:00
|
|
|
/*
|
2011-08-01 02:27:35 +07:00
|
|
|
* On 64bit we split the RMO in half but cap it at half of
|
|
|
|
* a small SLB (128MB) since the crash kernel needs to place
|
|
|
|
* itself and some stacks to be in the first segment.
|
2009-01-02 17:46:15 +07:00
|
|
|
*/
|
2013-12-09 17:03:39 +07:00
|
|
|
crashk_res.start = min(0x8000000ULL, (ppc64_rma_size / 2));
|
2011-08-01 02:27:35 +07:00
|
|
|
#else
|
2009-01-02 17:46:15 +07:00
|
|
|
crashk_res.start = KDUMP_KERNELBASE;
|
2011-08-01 02:27:35 +07:00
|
|
|
#endif
|
2009-01-02 17:46:15 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
crash_base = PAGE_ALIGN(crashk_res.start);
|
|
|
|
if (crash_base != crashk_res.start) {
|
|
|
|
printk("Crash kernel base must be aligned to 0x%lx\n",
|
|
|
|
PAGE_SIZE);
|
|
|
|
crashk_res.start = crash_base;
|
|
|
|
}
|
|
|
|
|
2008-10-22 00:38:10 +07:00
|
|
|
#endif
|
2007-10-19 13:41:01 +07:00
|
|
|
crash_size = PAGE_ALIGN(crash_size);
|
|
|
|
crashk_res.end = crashk_res.start + crash_size - 1;
|
2006-07-05 11:39:42 +07:00
|
|
|
|
2009-01-02 17:46:15 +07:00
|
|
|
/* The crash region must not overlap the current kernel */
|
|
|
|
if (overlaps_crashkernel(__pa(_stext), _end - _stext)) {
|
|
|
|
printk(KERN_WARNING
|
|
|
|
"Crash kernel can not overlap current kernel\n");
|
|
|
|
crashk_res.start = crashk_res.end = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-07-05 11:39:42 +07:00
|
|
|
/* Crash kernel trumps memory limit */
|
|
|
|
if (memory_limit && memory_limit <= crashk_res.end) {
|
|
|
|
memory_limit = crashk_res.end + 1;
|
2009-05-08 19:19:27 +07:00
|
|
|
printk("Adjusted memory limit for crashkernel, now 0x%llx\n",
|
2012-08-21 08:42:33 +07:00
|
|
|
memory_limit);
|
2006-07-05 11:39:42 +07:00
|
|
|
}
|
|
|
|
|
2007-10-19 13:41:01 +07:00
|
|
|
printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
|
|
|
|
"for crashkernel (System RAM: %ldMB)\n",
|
|
|
|
(unsigned long)(crash_size >> 20),
|
|
|
|
(unsigned long)(crashk_res.start >> 20),
|
2010-07-12 11:36:09 +07:00
|
|
|
(unsigned long)(memblock_phys_mem_size() >> 20));
|
2007-10-19 13:41:01 +07:00
|
|
|
|
2010-07-12 11:36:09 +07:00
|
|
|
memblock_reserve(crashk_res.start, crash_size);
|
2006-07-05 11:39:42 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
int overlaps_crashkernel(unsigned long start, unsigned long size)
|
|
|
|
{
|
|
|
|
return (start + size) > crashk_res.start && start <= crashk_res.end;
|
|
|
|
}
|
2008-12-16 13:22:59 +07:00
|
|
|
|
|
|
|
/* Values we need to export to the second kernel via the device tree. */
|
2010-07-21 18:14:54 +07:00
|
|
|
static phys_addr_t kernel_end;
|
2014-01-22 04:40:28 +07:00
|
|
|
static phys_addr_t crashk_base;
|
2010-07-21 18:14:54 +07:00
|
|
|
static phys_addr_t crashk_size;
|
2014-01-22 04:40:28 +07:00
|
|
|
static unsigned long long mem_limit;
|
2008-12-16 13:22:59 +07:00
|
|
|
|
|
|
|
static struct property kernel_end_prop = {
|
|
|
|
.name = "linux,kernel-end",
|
2010-07-21 18:14:54 +07:00
|
|
|
.length = sizeof(phys_addr_t),
|
2008-12-16 13:22:59 +07:00
|
|
|
.value = &kernel_end,
|
|
|
|
};
|
|
|
|
|
2008-12-17 17:09:06 +07:00
|
|
|
static struct property crashk_base_prop = {
|
|
|
|
.name = "linux,crashkernel-base",
|
2010-07-21 18:14:54 +07:00
|
|
|
.length = sizeof(phys_addr_t),
|
2014-01-22 04:40:28 +07:00
|
|
|
.value = &crashk_base
|
2008-12-17 17:09:06 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct property crashk_size_prop = {
|
|
|
|
.name = "linux,crashkernel-size",
|
2010-07-21 18:14:54 +07:00
|
|
|
.length = sizeof(phys_addr_t),
|
2008-12-17 17:09:06 +07:00
|
|
|
.value = &crashk_size,
|
|
|
|
};
|
|
|
|
|
2012-08-21 08:42:43 +07:00
|
|
|
static struct property memory_limit_prop = {
|
|
|
|
.name = "linux,memory-limit",
|
|
|
|
.length = sizeof(unsigned long long),
|
2014-01-22 04:40:28 +07:00
|
|
|
.value = &mem_limit,
|
2012-08-21 08:42:43 +07:00
|
|
|
};
|
|
|
|
|
2014-01-22 04:40:28 +07:00
|
|
|
#define cpu_to_be_ulong __PASTE(cpu_to_be, BITS_PER_LONG)
|
|
|
|
|
2008-12-17 17:09:06 +07:00
|
|
|
static void __init export_crashk_values(struct device_node *node)
|
|
|
|
{
|
|
|
|
struct property *prop;
|
|
|
|
|
|
|
|
/* There might be existing crash kernel properties, but we can't
|
|
|
|
* be sure what's in them, so remove them. */
|
|
|
|
prop = of_find_property(node, "linux,crashkernel-base", NULL);
|
|
|
|
if (prop)
|
2012-10-02 23:58:46 +07:00
|
|
|
of_remove_property(node, prop);
|
2008-12-17 17:09:06 +07:00
|
|
|
|
|
|
|
prop = of_find_property(node, "linux,crashkernel-size", NULL);
|
|
|
|
if (prop)
|
2012-10-02 23:58:46 +07:00
|
|
|
of_remove_property(node, prop);
|
2008-12-17 17:09:06 +07:00
|
|
|
|
|
|
|
if (crashk_res.start != 0) {
|
2014-01-22 04:40:28 +07:00
|
|
|
crashk_base = cpu_to_be_ulong(crashk_res.start),
|
2012-10-02 23:58:46 +07:00
|
|
|
of_add_property(node, &crashk_base_prop);
|
2014-01-22 04:40:28 +07:00
|
|
|
crashk_size = cpu_to_be_ulong(resource_size(&crashk_res));
|
2012-10-02 23:58:46 +07:00
|
|
|
of_add_property(node, &crashk_size_prop);
|
2008-12-17 17:09:06 +07:00
|
|
|
}
|
2012-08-21 08:42:43 +07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* memory_limit is required by the kexec-tools to limit the
|
|
|
|
* crash regions to the actual memory used.
|
|
|
|
*/
|
2014-01-22 04:40:28 +07:00
|
|
|
mem_limit = cpu_to_be_ulong(memory_limit);
|
2012-10-02 23:58:46 +07:00
|
|
|
of_update_property(node, &memory_limit_prop);
|
2008-12-17 17:09:06 +07:00
|
|
|
}
|
|
|
|
|
2008-12-16 13:22:59 +07:00
|
|
|
static int __init kexec_setup(void)
|
|
|
|
{
|
|
|
|
struct device_node *node;
|
|
|
|
struct property *prop;
|
|
|
|
|
|
|
|
node = of_find_node_by_path("/chosen");
|
|
|
|
if (!node)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
/* remove any stale properties so ours can be found */
|
|
|
|
prop = of_find_property(node, kernel_end_prop.name, NULL);
|
|
|
|
if (prop)
|
2012-10-02 23:58:46 +07:00
|
|
|
of_remove_property(node, prop);
|
2008-12-16 13:22:59 +07:00
|
|
|
|
|
|
|
/* information needed by userspace when using default_machine_kexec */
|
2014-01-22 04:40:28 +07:00
|
|
|
kernel_end = cpu_to_be_ulong(__pa(_end));
|
2012-10-02 23:58:46 +07:00
|
|
|
of_add_property(node, &kernel_end_prop);
|
2008-12-16 13:22:59 +07:00
|
|
|
|
2008-12-17 17:09:06 +07:00
|
|
|
export_crashk_values(node);
|
|
|
|
|
2008-12-16 13:22:59 +07:00
|
|
|
of_node_put(node);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
late_initcall(kexec_setup);
|