[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 12:35:00 +00: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>
|
2008-02-14 00:56:49 +00:00
|
|
|
#include <linux/lmb.h>
|
2008-12-16 06:22:59 +00:00
|
|
|
#include <linux/of.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 12:35:00 +00:00
|
|
|
#include <asm/machdep.h>
|
2008-02-14 00:56:49 +00:00
|
|
|
#include <asm/prom.h>
|
2008-12-16 06:22:59 +00: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 12:35:00 +00:00
|
|
|
|
|
|
|
void machine_crash_shutdown(struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
if (ppc_md.machine_crash_shutdown)
|
2005-12-04 07:39:12 +00:00
|
|
|
ppc_md.machine_crash_shutdown(regs);
|
2008-12-16 06:23:05 +00:00
|
|
|
else
|
|
|
|
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 12:35:00 +00: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 06:23:05 +00: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 12:35:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void machine_kexec_cleanup(struct kimage *image)
|
|
|
|
{
|
|
|
|
if (ppc_md.machine_kexec_cleanup)
|
|
|
|
ppc_md.machine_kexec_cleanup(image);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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 02:45:07 +00: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 12:35:00 +00:00
|
|
|
{
|
|
|
|
if (ppc_md.machine_kexec)
|
|
|
|
ppc_md.machine_kexec(image);
|
2008-12-16 06:23:05 +00:00
|
|
|
else
|
|
|
|
default_machine_kexec(image);
|
|
|
|
|
|
|
|
/* 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 12:35:00 +00:00
|
|
|
for(;;);
|
|
|
|
}
|
2006-07-05 04:39:42 +00:00
|
|
|
|
|
|
|
void __init reserve_crashkernel(void)
|
|
|
|
{
|
2007-10-19 06:41:01 +00:00
|
|
|
unsigned long long crash_size, crash_base;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
/* this is necessary because of lmb_phys_mem_size() */
|
|
|
|
lmb_analyze();
|
|
|
|
|
|
|
|
/* use common parsing */
|
|
|
|
ret = parse_crashkernel(boot_command_line, lmb_phys_mem_size(),
|
|
|
|
&crash_size, &crash_base);
|
|
|
|
if (ret == 0 && crash_size > 0) {
|
|
|
|
crashk_res.start = crash_base;
|
2008-04-30 04:47:12 +00:00
|
|
|
crashk_res.end = crash_base + crash_size - 1;
|
2007-10-19 06:41:01 +00:00
|
|
|
}
|
2006-07-05 04:39:42 +00:00
|
|
|
|
2008-04-30 04:47:12 +00:00
|
|
|
if (crashk_res.end == crashk_res.start) {
|
|
|
|
crashk_res.start = crashk_res.end = 0;
|
2006-07-05 04:39:42 +00:00
|
|
|
return;
|
2008-04-30 04:47:12 +00:00
|
|
|
}
|
2006-07-05 04:39:42 +00:00
|
|
|
|
|
|
|
/* We might have got these values via the command line or the
|
|
|
|
* device tree, either way sanitise them now. */
|
|
|
|
|
2008-04-30 04:47:12 +00:00
|
|
|
crash_size = crashk_res.end - crashk_res.start + 1;
|
|
|
|
|
2008-10-21 17:38:10 +00:00
|
|
|
#ifndef CONFIG_RELOCATABLE
|
2006-07-05 04:39:42 +00: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 10:46:15 +00:00
|
|
|
#else
|
|
|
|
if (!crashk_res.start) {
|
|
|
|
/*
|
|
|
|
* unspecified address, choose a region of specified size
|
|
|
|
* can overlap with initrd (ignoring corruption when retained)
|
|
|
|
* ppc64 requires kernel and some stacks to be in first segemnt
|
|
|
|
*/
|
|
|
|
crashk_res.start = KDUMP_KERNELBASE;
|
|
|
|
}
|
|
|
|
|
|
|
|
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-21 17:38:10 +00:00
|
|
|
#endif
|
2007-10-19 06:41:01 +00:00
|
|
|
crash_size = PAGE_ALIGN(crash_size);
|
|
|
|
crashk_res.end = crashk_res.start + crash_size - 1;
|
2006-07-05 04:39:42 +00:00
|
|
|
|
2009-01-02 10:46:15 +00: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 04:39:42 +00:00
|
|
|
/* Crash kernel trumps memory limit */
|
|
|
|
if (memory_limit && memory_limit <= crashk_res.end) {
|
|
|
|
memory_limit = crashk_res.end + 1;
|
|
|
|
printk("Adjusted memory limit for crashkernel, now 0x%lx\n",
|
|
|
|
memory_limit);
|
|
|
|
}
|
|
|
|
|
2007-10-19 06:41:01 +00: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),
|
|
|
|
(unsigned long)(lmb_phys_mem_size() >> 20));
|
|
|
|
|
|
|
|
lmb_reserve(crashk_res.start, crash_size);
|
2006-07-05 04:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int overlaps_crashkernel(unsigned long start, unsigned long size)
|
|
|
|
{
|
|
|
|
return (start + size) > crashk_res.start && start <= crashk_res.end;
|
|
|
|
}
|
2008-12-16 06:22:59 +00:00
|
|
|
|
|
|
|
/* Values we need to export to the second kernel via the device tree. */
|
|
|
|
static unsigned long kernel_end;
|
2008-12-17 10:09:06 +00:00
|
|
|
static unsigned long crashk_size;
|
2008-12-16 06:22:59 +00:00
|
|
|
|
|
|
|
static struct property kernel_end_prop = {
|
|
|
|
.name = "linux,kernel-end",
|
|
|
|
.length = sizeof(unsigned long),
|
|
|
|
.value = &kernel_end,
|
|
|
|
};
|
|
|
|
|
2008-12-17 10:09:06 +00:00
|
|
|
static struct property crashk_base_prop = {
|
|
|
|
.name = "linux,crashkernel-base",
|
|
|
|
.length = sizeof(unsigned long),
|
|
|
|
.value = &crashk_res.start,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct property crashk_size_prop = {
|
|
|
|
.name = "linux,crashkernel-size",
|
|
|
|
.length = sizeof(unsigned long),
|
|
|
|
.value = &crashk_size,
|
|
|
|
};
|
|
|
|
|
|
|
|
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)
|
|
|
|
prom_remove_property(node, prop);
|
|
|
|
|
|
|
|
prop = of_find_property(node, "linux,crashkernel-size", NULL);
|
|
|
|
if (prop)
|
|
|
|
prom_remove_property(node, prop);
|
|
|
|
|
|
|
|
if (crashk_res.start != 0) {
|
|
|
|
prom_add_property(node, &crashk_base_prop);
|
|
|
|
crashk_size = crashk_res.end - crashk_res.start + 1;
|
|
|
|
prom_add_property(node, &crashk_size_prop);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-16 06:22:59 +00: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)
|
|
|
|
prom_remove_property(node, prop);
|
|
|
|
|
|
|
|
/* information needed by userspace when using default_machine_kexec */
|
|
|
|
kernel_end = __pa(_end);
|
|
|
|
prom_add_property(node, &kernel_end_prop);
|
|
|
|
|
2008-12-17 10:09:06 +00:00
|
|
|
export_crashk_values(node);
|
|
|
|
|
2008-12-16 06:22:59 +00:00
|
|
|
of_node_put(node);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
late_initcall(kexec_setup);
|