2019-06-03 07:44:46 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
[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 23:35:00 +11: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kexec.h>
|
|
|
|
#include <linux/reboot.h>
|
|
|
|
#include <linux/threads.h>
|
2010-07-12 14:36:09 +10:00
|
|
|
#include <linux/memblock.h>
|
2008-12-16 06:22:59 +00:00
|
|
|
#include <linux/of.h>
|
2010-09-16 17:58:23 -05:00
|
|
|
#include <linux/irq.h>
|
2011-01-06 18:00:36 +00:00
|
|
|
#include <linux/ftrace.h>
|
2010-09-16 17:58:23 -05:00
|
|
|
|
2018-07-05 16:24:51 +00:00
|
|
|
#include <asm/kdump.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 23:35:00 +11:00
|
|
|
#include <asm/machdep.h>
|
2013-11-15 23:01:32 +05:30
|
|
|
#include <asm/pgalloc.h>
|
2008-12-16 06:22:59 +00:00
|
|
|
#include <asm/sections.h>
|
2022-06-11 18:55:15 +02:00
|
|
|
#include <asm/setup.h>
|
2022-05-06 11:14:24 +02:00
|
|
|
#include <asm/firmware.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 23:35:00 +11:00
|
|
|
|
2024-02-26 16:00:10 +05:30
|
|
|
#ifdef CONFIG_CRASH_DUMP
|
[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 23:35:00 +11:00
|
|
|
void machine_crash_shutdown(struct pt_regs *regs)
|
|
|
|
{
|
2011-01-06 17:56:09 +00: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 23:35:00 +11:00
|
|
|
}
|
2024-02-26 16:00:10 +05:30
|
|
|
#endif
|
[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 23:35:00 +11:00
|
|
|
|
|
|
|
void machine_kexec_cleanup(struct kimage *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-25 19: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 23:35:00 +11:00
|
|
|
{
|
2011-01-06 18:00:36 +00:00
|
|
|
int save_ftrace_enabled;
|
|
|
|
|
|
|
|
save_ftrace_enabled = __ftrace_enabled_save();
|
2018-04-19 12:34:06 +05:30
|
|
|
this_cpu_disable_ftrace();
|
2011-01-06 18:00:36 +00:00
|
|
|
|
2011-02-23 12:46:16 +00:00
|
|
|
if (ppc_md.machine_kexec)
|
|
|
|
ppc_md.machine_kexec(image);
|
|
|
|
else
|
|
|
|
default_machine_kexec(image);
|
2008-12-16 06:23:05 +00:00
|
|
|
|
2018-04-19 12:34:06 +05:30
|
|
|
this_cpu_enable_ftrace();
|
2011-01-06 18:00:36 +00:00
|
|
|
__ftrace_enabled_restore(save_ftrace_enabled);
|
|
|
|
|
2008-12-16 06:23:05 +00: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 23:35:00 +11:00
|
|
|
for(;;);
|
|
|
|
}
|
2006-07-05 14:39:42 +10:00
|
|
|
|
2024-02-26 16:00:10 +05:30
|
|
|
#ifdef CONFIG_CRASH_RESERVE
|
2007-10-18 23:41:01 -07:00
|
|
|
|
2025-01-31 17:08:30 +05:30
|
|
|
static unsigned long long __init get_crash_base(unsigned long long crash_base)
|
|
|
|
{
|
2008-04-30 14:47:12 +10:00
|
|
|
|
2011-12-14 22:57:15 +00:00
|
|
|
#ifndef CONFIG_NONSTATIC_KERNEL
|
2025-01-31 17:08:30 +05:30
|
|
|
if (crash_base != KDUMP_KERNELBASE)
|
2006-07-05 14:39:42 +10:00
|
|
|
printk("Crash kernel location must be 0x%x\n",
|
|
|
|
KDUMP_KERNELBASE);
|
|
|
|
|
2025-01-31 17:08:30 +05:30
|
|
|
return KDUMP_KERNELBASE;
|
2009-01-02 10:46:15 +00:00
|
|
|
#else
|
2025-01-31 17:08:30 +05:30
|
|
|
unsigned long long crash_base_align;
|
|
|
|
|
|
|
|
if (!crash_base) {
|
2011-07-31 19:27:35 +00:00
|
|
|
#ifdef CONFIG_PPC64
|
2009-01-02 10:46:15 +00:00
|
|
|
/*
|
2022-02-04 14:26:01 +05:30
|
|
|
* On the LPAR platform place the crash kernel to mid of
|
2022-09-12 12:20:31 +05:30
|
|
|
* RMA size (max. of 512MB) to ensure the crash kernel
|
2022-02-04 14:26:01 +05:30
|
|
|
* gets enough space to place itself and some stack to be
|
|
|
|
* in the first segment. At the same time normal kernel
|
|
|
|
* also get enough space to allocate memory for essential
|
|
|
|
* system resource in the first segment. Keep the crash
|
|
|
|
* kernel starts at 128MB offset on other platforms.
|
2009-01-02 10:46:15 +00:00
|
|
|
*/
|
2022-02-04 14:26:01 +05:30
|
|
|
if (firmware_has_feature(FW_FEATURE_LPAR))
|
2025-01-31 17:08:30 +05:30
|
|
|
crash_base = min_t(u64, ppc64_rma_size / 2, SZ_512M);
|
2022-02-04 14:26:01 +05:30
|
|
|
else
|
2025-01-31 17:08:30 +05:30
|
|
|
crash_base = min_t(u64, ppc64_rma_size / 2, SZ_128M);
|
2011-07-31 19:27:35 +00:00
|
|
|
#else
|
2025-01-31 17:08:30 +05:30
|
|
|
crash_base = KDUMP_KERNELBASE;
|
2011-07-31 19:27:35 +00:00
|
|
|
#endif
|
2009-01-02 10:46:15 +00:00
|
|
|
}
|
|
|
|
|
2025-01-31 17:08:30 +05:30
|
|
|
crash_base_align = PAGE_ALIGN(crash_base);
|
|
|
|
if (crash_base != crash_base_align)
|
|
|
|
pr_warn("Crash kernel base must be aligned to 0x%lx\n", PAGE_SIZE);
|
2009-01-02 10:46:15 +00:00
|
|
|
|
2025-01-31 17:08:30 +05:30
|
|
|
return crash_base_align;
|
2008-10-21 17:38:10 +00:00
|
|
|
#endif
|
2025-01-31 17:08:30 +05:30
|
|
|
}
|
2006-07-05 14:39:42 +10:00
|
|
|
|
2025-01-31 17:08:30 +05:30
|
|
|
void __init arch_reserve_crashkernel(void)
|
|
|
|
{
|
|
|
|
unsigned long long crash_size, crash_base, crash_end;
|
|
|
|
unsigned long long kernel_start, kernel_size;
|
|
|
|
unsigned long long total_mem_sz;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
total_mem_sz = memory_limit ? memory_limit : memblock_phys_mem_size();
|
|
|
|
|
|
|
|
/* use common parsing */
|
|
|
|
ret = parse_crashkernel(boot_command_line, total_mem_sz, &crash_size,
|
Add a new optional ",cma" suffix to the crashkernel= command line option
Patch series "kdump: crashkernel reservation from CMA", v5.
This series implements a way to reserve additional crash kernel memory
using CMA.
Currently, all the memory for the crash kernel is not usable by the 1st
(production) kernel. It is also unmapped so that it can't be corrupted by
the fault that will eventually trigger the crash. This makes sense for
the memory actually used by the kexec-loaded crash kernel image and initrd
and the data prepared during the load (vmcoreinfo, ...). However, the
reserved space needs to be much larger than that to provide enough
run-time memory for the crash kernel and the kdump userspace. Estimating
the amount of memory to reserve is difficult. Being too careful makes
kdump likely to end in OOM, being too generous takes even more memory from
the production system. Also, the reservation only allows reserving a
single contiguous block (or two with the "low" suffix). I've seen systems
where this fails because the physical memory is fragmented.
By reserving additional crashkernel memory from CMA, the main crashkernel
reservation can be just large enough to fit the kernel and initrd image,
minimizing the memory taken away from the production system. Most of the
run-time memory for the crash kernel will be memory previously available
to userspace in the production system. As this memory is no longer
wasted, the reservation can be done with a generous margin, making kdump
more reliable. Kernel memory that we need to preserve for dumping is
normally not allocated from CMA, unless it is explicitly allocated as
movable. Currently this is only the case for memory ballooning and zswap.
Such movable memory will be missing from the vmcore. User data is
typically not dumped by makedumpfile. When dumping of user data is
intended this new CMA reservation cannot be used.
There are five patches in this series:
The first adds a new ",cma" suffix to the recenly introduced generic
crashkernel parsing code. parse_crashkernel() takes one more argument to
store the cma reservation size.
The second patch implements reserve_crashkernel_cma() which performs the
reservation. If the requested size is not available in a single range,
multiple smaller ranges will be reserved.
The third patch updates Documentation/, explicitly mentioning the
potential DMA corruption of the CMA-reserved memory.
The fourth patch adds a short delay before booting the kdump kernel,
allowing pending DMA transfers to finish.
The fifth patch enables the functionality for x86 as a proof of
concept. There are just three things every arch needs to do:
- call reserve_crashkernel_cma()
- include the CMA-reserved ranges in the physical memory map
- exclude the CMA-reserved ranges from the memory available
through /proc/vmcore by excluding them from the vmcoreinfo
PT_LOAD ranges.
Adding other architectures is easy and I can do that as soon as this
series is merged.
With this series applied, specifying
crashkernel=100M craskhernel=1G,cma
on the command line will make a standard crashkernel reservation
of 100M, where kexec will load the kernel and initrd.
An additional 1G will be reserved from CMA, still usable by the production
system. The crash kernel will have 1.1G memory available. The 100M can
be reliably predicted based on the size of the kernel and initrd.
The new cma suffix is completely optional. When no
crashkernel=size,cma is specified, everything works as before.
This patch (of 5):
Add a new cma_size parameter to parse_crashkernel(). When not NULL, call
__parse_crashkernel to parse the CMA reservation size from
"crashkernel=size,cma" and store it in cma_size.
Set cma_size to NULL in all calls to parse_crashkernel().
Link: https://lkml.kernel.org/r/aEqnxxfLZMllMC8I@dwarf.suse.cz
Link: https://lkml.kernel.org/r/aEqoQckgoTQNULnh@dwarf.suse.cz
Signed-off-by: Jiri Bohac <jbohac@suse.cz>
Cc: Baoquan He <bhe@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Donald Dutile <ddutile@redhat.com>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Philipp Rudo <prudo@redhat.com>
Cc: Pingfan Liu <piliu@redhat.com>
Cc: Tao Liu <ltao@redhat.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
2025-06-12 12:13:21 +02:00
|
|
|
&crash_base, NULL, NULL, NULL);
|
2025-01-31 17:08:30 +05:30
|
|
|
|
|
|
|
if (ret)
|
2009-01-02 10:46:15 +00:00
|
|
|
return;
|
|
|
|
|
2025-01-31 17:08:30 +05:30
|
|
|
crash_base = get_crash_base(crash_base);
|
|
|
|
crash_end = crash_base + crash_size - 1;
|
2007-10-18 23:41:01 -07:00
|
|
|
|
2025-01-31 17:08:30 +05:30
|
|
|
kernel_start = __pa(_stext);
|
|
|
|
kernel_size = _end - _stext;
|
|
|
|
|
|
|
|
/* The crash region must not overlap the current kernel */
|
|
|
|
if ((kernel_start + kernel_size > crash_base) && (kernel_start <= crash_end)) {
|
|
|
|
pr_warn("Crash kernel can not overlap current kernel\n");
|
2018-06-28 10:49:56 +05:30
|
|
|
return;
|
|
|
|
}
|
2025-01-31 17:08:30 +05:30
|
|
|
|
|
|
|
reserve_crashkernel_generic(crash_size, crash_base, 0, false);
|
2006-07-05 14:39:42 +10:00
|
|
|
}
|
|
|
|
|
2021-12-16 17:00:16 -05:00
|
|
|
int __init overlaps_crashkernel(unsigned long start, unsigned long size)
|
2006-07-05 14:39:42 +10:00
|
|
|
{
|
|
|
|
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. */
|
2010-07-21 11:14:54 +00:00
|
|
|
static phys_addr_t kernel_end;
|
2014-01-22 08:40:28 +11:00
|
|
|
static phys_addr_t crashk_base;
|
2010-07-21 11:14:54 +00:00
|
|
|
static phys_addr_t crashk_size;
|
2014-01-22 08:40:28 +11:00
|
|
|
static unsigned long long mem_limit;
|
2008-12-16 06:22:59 +00:00
|
|
|
|
|
|
|
static struct property kernel_end_prop = {
|
|
|
|
.name = "linux,kernel-end",
|
2010-07-21 11:14:54 +00:00
|
|
|
.length = sizeof(phys_addr_t),
|
2008-12-16 06:22:59 +00:00
|
|
|
.value = &kernel_end,
|
|
|
|
};
|
|
|
|
|
2008-12-17 10:09:06 +00:00
|
|
|
static struct property crashk_base_prop = {
|
|
|
|
.name = "linux,crashkernel-base",
|
2010-07-21 11:14:54 +00:00
|
|
|
.length = sizeof(phys_addr_t),
|
2014-01-22 08:40:28 +11:00
|
|
|
.value = &crashk_base
|
2008-12-17 10:09:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static struct property crashk_size_prop = {
|
|
|
|
.name = "linux,crashkernel-size",
|
2010-07-21 11:14:54 +00:00
|
|
|
.length = sizeof(phys_addr_t),
|
2008-12-17 10:09:06 +00:00
|
|
|
.value = &crashk_size,
|
|
|
|
};
|
|
|
|
|
2012-08-21 01:42:43 +00:00
|
|
|
static struct property memory_limit_prop = {
|
|
|
|
.name = "linux,memory-limit",
|
|
|
|
.length = sizeof(unsigned long long),
|
2014-01-22 08:40:28 +11:00
|
|
|
.value = &mem_limit,
|
2012-08-21 01:42:43 +00:00
|
|
|
};
|
|
|
|
|
2014-01-22 08:40:28 +11:00
|
|
|
#define cpu_to_be_ulong __PASTE(cpu_to_be, BITS_PER_LONG)
|
|
|
|
|
2008-12-17 10:09:06 +00:00
|
|
|
static void __init export_crashk_values(struct device_node *node)
|
|
|
|
{
|
|
|
|
/* There might be existing crash kernel properties, but we can't
|
|
|
|
* be sure what's in them, so remove them. */
|
2016-04-28 15:34:55 +10:00
|
|
|
of_remove_property(node, of_find_property(node,
|
|
|
|
"linux,crashkernel-base", NULL));
|
|
|
|
of_remove_property(node, of_find_property(node,
|
|
|
|
"linux,crashkernel-size", NULL));
|
2008-12-17 10:09:06 +00:00
|
|
|
|
|
|
|
if (crashk_res.start != 0) {
|
2014-01-22 08:40:28 +11:00
|
|
|
crashk_base = cpu_to_be_ulong(crashk_res.start),
|
2012-10-02 16:58:46 +00:00
|
|
|
of_add_property(node, &crashk_base_prop);
|
2014-01-22 08:40:28 +11:00
|
|
|
crashk_size = cpu_to_be_ulong(resource_size(&crashk_res));
|
2012-10-02 16:58:46 +00:00
|
|
|
of_add_property(node, &crashk_size_prop);
|
2008-12-17 10:09:06 +00:00
|
|
|
}
|
2012-08-21 01:42:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* memory_limit is required by the kexec-tools to limit the
|
|
|
|
* crash regions to the actual memory used.
|
|
|
|
*/
|
2014-01-22 08:40:28 +11:00
|
|
|
mem_limit = cpu_to_be_ulong(memory_limit);
|
2012-10-02 16:58:46 +00:00
|
|
|
of_update_property(node, &memory_limit_prop);
|
2008-12-17 10:09:06 +00:00
|
|
|
}
|
|
|
|
|
2008-12-16 06:22:59 +00:00
|
|
|
static int __init kexec_setup(void)
|
|
|
|
{
|
|
|
|
struct device_node *node;
|
|
|
|
|
|
|
|
node = of_find_node_by_path("/chosen");
|
|
|
|
if (!node)
|
|
|
|
return -ENOENT;
|
|
|
|
|
|
|
|
/* remove any stale properties so ours can be found */
|
2016-04-28 15:34:55 +10:00
|
|
|
of_remove_property(node, of_find_property(node, kernel_end_prop.name, NULL));
|
2008-12-16 06:22:59 +00:00
|
|
|
|
|
|
|
/* information needed by userspace when using default_machine_kexec */
|
2014-01-22 08:40:28 +11:00
|
|
|
kernel_end = cpu_to_be_ulong(__pa(_end));
|
2012-10-02 16:58:46 +00:00
|
|
|
of_add_property(node, &kernel_end_prop);
|
2008-12-16 06:22:59 +00:00
|
|
|
|
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);
|
2024-02-26 16:00:10 +05:30
|
|
|
#endif /* CONFIG_CRASH_RESERVE */
|