diff options
| author | Jan Altenberg <jan@linutronix.de> | 2013-12-27 11:48:46 +0100 |
|---|---|---|
| committer | Jan Altenberg <jan@linutronix.de> | 2013-12-27 11:48:46 +0100 |
| commit | 455c28f2c81b92e72c299b526ff66801ee71f175 (patch) | |
| tree | 84dd0bc45d80a1be217d986adb5066e0b9f03cc3 /kernel-devel/kexec-and-crash-kernel | |
| parent | 2ed7702eddc96469129694783d8ca964d62a5bc7 (diff) | |
| parent | d5b53316f812c80e9143207244e0ca2568ab2eae (diff) | |
Merge branch 'master' into kconfig
Diffstat (limited to 'kernel-devel/kexec-and-crash-kernel')
5 files changed, 185 insertions, 0 deletions
diff --git a/kernel-devel/kexec-and-crash-kernel/Makefile b/kernel-devel/kexec-and-crash-kernel/Makefile new file mode 100644 index 0000000..d641258 --- /dev/null +++ b/kernel-devel/kexec-and-crash-kernel/Makefile @@ -0,0 +1,9 @@ +all: + for pdf in `ls -1 *.tex` ; do \ + TEXINPUTS=`pwd`/../..:.:..:$(TEXINPUTS) pdflatex $$pdf; \ + TEXINPUTS=`pwd`/../..:.:..:$(TEXINPUTS) pdflatex $$pdf; \ + done + +clean: + rm -f *.aux *.log *.pdf *.log *.snm *.toc *.vrb *.nav *.out + diff --git a/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/crashkernel.diff b/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/crashkernel.diff new file mode 100644 index 0000000..1d3e082 --- /dev/null +++ b/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/crashkernel.diff @@ -0,0 +1,65 @@ +From: Magnus Damm <damm at opensource.se> + +Update the copy_oldmem_page() function to ioremap() only +when accessing memory that is outside the regular range +of system memory that is managed by the kernel. + +Without this patch a warning is triggered in the ARM-specific +ioremap implementation, see WARN_ON(pfn_valid()) in ioremap.c + +The copy_oldmem_page() function is used by the secondary crash +kernel to access memory using the /proc/vmcore code implemented +in fs/proc/vmcore.c. To pass information from the first kernel +to the secondary crash kernel a kernel command line option is +used to point out where the elf core hdr is located. + +The crash kernel is loaded through kexec-tools which also contains +code that reserves memory for the elfcorehdr= option. This memory +block is reserved _inside_ the main system memory of the secondary +kernel. The /proc/vmcore code in the secondary kernel is however +using copy_oldmem_page() to access both this elfcorehdr area and +the rest of the memory used by the the first kernel. + +So the copy_oldmem_page() function is used to access data that +may be located in system memory, or it may be outside. Always +using ioremap will not work, so this patch makes it conditional +based on pfn_valid(). + +For more details please look at the sh7372-based example here: +http://permalink.gmane.org/gmane.linux.ports.sh.devel/11502 + +Signed-off-by: Magnus Damm <damm at opensource.se> +--- + + arch/arm/kernel/crash_dump.c | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +--- 0001/arch/arm/kernel/crash_dump.c ++++ work/arch/arm/kernel/crash_dump.c 2011-06-18 20:59:49.000000000 +0900 +@@ -39,9 +39,13 @@ ssize_t copy_oldmem_page(unsigned long p + if (!csize) + return 0; + +- vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE); +- if (!vaddr) +- return -ENOMEM; ++ if (pfn_valid(pfn)) { ++ vaddr = phys_to_virt(pfn << PAGE_SHIFT); ++ } else { ++ vaddr = ioremap(pfn << PAGE_SHIFT, PAGE_SIZE); ++ if (!vaddr) ++ return -ENOMEM; ++ } + + if (userbuf) { + if (copy_to_user(buf, vaddr + offset, csize)) { +@@ -52,6 +56,8 @@ ssize_t copy_oldmem_page(unsigned long p + memcpy(buf, vaddr + offset, csize); + } + +- iounmap(vaddr); ++ if (!pfn_valid(pfn)) ++ iounmap(vaddr); ++ + return csize; + } diff --git a/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/kexec_fix_arm_braindamage.diff b/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/kexec_fix_arm_braindamage.diff new file mode 100644 index 0000000..877f5ea --- /dev/null +++ b/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/kexec_fix_arm_braindamage.diff @@ -0,0 +1,28 @@ +Index: kexec-tools-2.0.3/kexec/arch/arm/crashdump-arm.c +=================================================================== +--- kexec-tools-2.0.3.orig/kexec/arch/arm/crashdump-arm.c 2011-10-03 00:56:38.000000000 +0200 ++++ kexec-tools-2.0.3/kexec/arch/arm/crashdump-arm.c 2013-07-06 17:26:13.410309437 +0200 +@@ -204,12 +204,12 @@ + * @cmdline. Note that @cmdline must be at least %COMMAND_LINE_SIZE bytes long + * (including %NUL). + */ +-static void cmdline_add_mem(char *cmdline, unsigned long size) ++static void cmdline_add_mem(char *cmdline, unsigned long size, unsigned long offset) + { + char buf[COMMAND_LINE_SIZE]; + int buflen; + +- buflen = snprintf(buf, sizeof(buf), "%s mem=%ldK", cmdline, size >> 10); ++ buflen = snprintf(buf, sizeof(buf), "%s mem=%ldK@0x%X", cmdline, size >> 10, offset); + if (buflen < 0) + die("Failed to construct mem= command line parameter\n"); + if (buflen >= sizeof(buf)) +@@ -301,7 +301,7 @@ + * prevents the dump capture kernel from using any other memory regions + * which belong to the primary kernel. + */ +- cmdline_add_mem(mod_cmdline, elfcorehdr - crash_reserved_mem.start); ++ cmdline_add_mem(mod_cmdline, elfcorehdr - crash_reserved_mem.start, crash_reserved_mem.start); + + dump_memory_ranges(); + dbgprintf("kernel command line: \"%s\"\n", mod_cmdline); diff --git a/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/zreladdr.diff b/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/zreladdr.diff new file mode 100644 index 0000000..867e13a --- /dev/null +++ b/kernel-devel/kexec-and-crash-kernel/crashkernel_patches/zreladdr.diff @@ -0,0 +1,13 @@ +Index: linux-3.2/arch/arm/mach-omap2/Makefile.boot +=================================================================== +--- linux-3.2.orig/arch/arm/mach-omap2/Makefile.boot 2012-01-05 00:55:44.000000000 +0100 ++++ linux-3.2/arch/arm/mach-omap2/Makefile.boot 2013-07-06 17:00:18.718516198 +0200 +@@ -1,3 +1,8 @@ ++ifeq ($(CONFIG_CRASH_DUMP),y) ++ zreladdr-y += 0x84008000 ++params_phys-y := 0x84000100 ++else + zreladdr-y += 0x80008000 + params_phys-y := 0x80000100 ++endif + initrd_phys-y := 0x80800000 diff --git a/kernel-devel/kexec-and-crash-kernel/pres_kexec_and_crashkernel_en.tex b/kernel-devel/kexec-and-crash-kernel/pres_kexec_and_crashkernel_en.tex new file mode 100644 index 0000000..1791267 --- /dev/null +++ b/kernel-devel/kexec-and-crash-kernel/pres_kexec_and_crashkernel_en.tex @@ -0,0 +1,70 @@ +\input{configpres} + +\title{Kexec and Crashkernels} +\maketitle +\begin{frame} +\frametitle{What is kexec?} +Kexec is a mechanism to boot Linux from within Linux, +without going through the BIOS / the Bootloader. +\end{frame} + +\begin{frame} +\frametitle{kexec-tools} +http://horms.net/projects/kexec/ +\end{frame} + +\begin{frame}[fragile] +\frametitle{Using kexec: Kernel configuration} +\begin{verbatim} +Boot options --> +[*] Kexec system call +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Using kexec: Booting the new kernel} +\begin{verbatim} +# Load the kernel image and set the commandline +$ kexec -l uImage --append=$(cat /proc/cmdline) +# Start the new kernel +$ kexec -e +\end{verbatim} +\end{frame} + +\begin{frame}[fragile] +\frametitle{Using kexec: Crashkernel} +\begin{itemize} +\item Build production kernel (enable kexec system call!) +\item Build ''crash kernel'' (enable kexec system call and crash dump kernel): +\begin{verbatim} +Boot options --> +[*] Kexec system call +[*] Build kdump crash kernel +\end{verbatim} +\item The crash kernel option should automatically select /proc/vmcore +\end{itemize} +\end{frame} + + +\begin{frame}[fragile] +\frametitle{Using kexec: Crashkernel} +\begin{itemize} +\item Boot production kernel (Commandline: crashkernel=256M@0x84000000) +\item Check if crashkernel memory was reserved: +\begin{verbatim} +cat /proc/iomem | grep Crash + 84000000-93ffffff : Crash kernel +\end{verbatim} +\item Load crash kernel and let the system crash ;-) +\begin{verbatim} +kexec -p uImage-crash \ + --append="$(cat /proc/cmdline | \ + sed 's/crashkernel/bla/')" +echo c > /proc/sysrq-trigger +\end{verbatim} +\item After crashing the crash kernel should boot up! +\item Within the crashkernel the core file for the production kernel is available in /proc/vmcore +\end{itemize} +\end{frame} + +\input{tailpres} |
