Initial implementation of kdump for ARM
Subsystems (2)
cover Initial implementation of kdump for ARM
Hello,
This series implements initial support for crashdumps on ARM. Mostly this stuff is adapted from other architectures (namely x86). I've been testing this on my N900 which is OMAP3430 based. I've used LKDTM module to crash the kernel in different places.
This works as follows (see also Documentation/kdump/kdump.txt):
1. Memory is reserved for the dump capture kernel by using kernel command line option: crashkernel=size at start
2. Userspace tool prepares vmcore header based on /proc/iomem and passes this and the dump capture kernel using kexec system call. We also reserve primary kernel memory by passing mem=size$start options to the dump capture kernel.
3. When crash happens, primary kernel saves current machine state and passes control to the dump capture kernel
4. Dump capture kernel makes /proc/vmcore available to userspace which can use it as it likes (for example copying it to some media etc.).
I also have rough modifications for kexec-tools which makes it possible to load the dump capture kernel and related information. I've planned to clean those and send them to kexec mailing list after this kernel part is finished. I also have some gdb macros adapted from Documentation/kdump/gdbmacros.txt that work on ARM kernel crashdumps, in case someone is interested.
When ARM switches to use LMB, some of the patches that reserve bootmem need to be reworked.
Note that these probably don't work with SMP systems (I don't have such hardware available).
I would really appreciate any comments and suggestions.
Thanks,
MW
Mika Westerberg (10):
arm: kdump: reserve memory for crashkernel
arm: kdump: implement crash_setup_regs()
arm: kdump: implement machine_crash_shutdown()
arm: kdump: skip indirection page when crashing
arm: kdump: make kexec work in interrupt context
arm: kdump: implement copy_oldmem_page()
arm: allow passing an ELF64 header to elf_check_arch()
arm: kdump: add support for elfcorehdr= parameter
arm: implement reserve memory early parameter
arm: kdump: add CONFIG_CRASH_DUMP Kconfig option
arch/arm/Kconfig | 11 ++++ arch/arm/Makefile | 10 ++++ arch/arm/include/asm/elf.h | 4 +- arch/arm/include/asm/kexec.h | 35 ++++++++++++- arch/arm/include/asm/setup.h | 4 ++ arch/arm/kernel/Makefile | 1 + arch/arm/kernel/crash_dump.c | 82 +++++++++++++++++++++++++++++++ arch/arm/kernel/elf.c | 6 ++- arch/arm/kernel/machine_kexec.c | 4 ++ arch/arm/kernel/relocate_kernel.S | 6 ++ arch/arm/kernel/setup.c | 98 ++++++++++++++++++++++++++++++++++-- arch/arm/mm/init.c | 25 +++++++++- arch/arm/mm/mmu.c | 10 ++-- 13 files changed, 277 insertions(+), 19 deletions(-) create mode 100644 arch/arm/kernel/crash_dump.c
RFC 1/10 arm: kdump: reserve memory for crashkernel
Implemented ARM support for command line option "crashkernel=size at start" which allows user to reserve some memory for a dump capture kernel.
--- arch/arm/kernel/setup.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 51 insertions(+), 0 deletions(-)
arch/arm/kernel/setup.c +51 -0
@@ -19,6 +19,7 @@#include <linux/seq_file.h> #include <linux/screen_info.h> #include <linux/init.h> +#include <linux/kexec.h> #include <linux/root_dev.h> #include <linux/cpu.h> #include <linux/interrupt.h>
@@ -661,6 +662,55 @@ static int __init customize_machine(void) }arch_initcall (customize_machine); +#ifdef CONFIG_KEXEC +static inline unsigned long long get_total_mem (void ) +{ +unsigned long total; + + total = max_low_pfn - min_low_pfn; +return total <<PAGE_SHIFT ; +} + +/** +* reserve_crashkernel() - reserves memory are for crash kernel +* +* This function reserves memory area given in "crashkernel=" kernel command +* line parameter. The memory reserved is used by a dump capture kernel when +* primary kernel is crashing. +*/ +static void __init reserve_crashkernel (void ) +{ +unsigned long long crash_size, crash_base; +unsigned long long total_mem; +int ret; + + total_mem =get_total_mem (); + ret =parse_crashkernel (boot_command_line, total_mem, + &crash_size, &crash_base); +if (ret) +return ; + + ret =reserve_bootmem (crash_base, crash_size,BOOTMEM_EXCLUSIVE ); +if (ret <0 ) { +printk (KERN_WARNING "crashkernel reservation failed - " +"memory is in use (0x%lx)\n" , (unsigned long )crash_base); +return ; + } + +printk (KERN_INFO "Reserving %ldMB of memory@%ldMB " +"for crashkernel (System RAM: %ldMB)\n" , + (unsigned long )(crash_size >>20 ), + (unsigned long )(crash_base >>20 ), + (unsigned long )(total_mem >>20 )); + + crashk_res.start = crash_base; + crashk_res.end = crash_base + crash_size -1 ; +insert_resource (&iomem_resource, &crashk_res); +} +#else +static inline void reserve_crashkernel (void ) {} +#endif /* CONFIG_KEXEC */ +void __init setup_arch (char **cmdline_p) {struct tag *tags = (struct tag *)&init_tags;
@@ -720,6 +770,7 @@ void __init setup_arch(char **cmdline_p)#ifdef CONFIG_SMP smp_init_cpus ();#endif +reserve_crashkernel ();cpu_init ();tcm_init ();
Signature · 1 line
1.5.6.5
RFC 2/10 arm: kdump: implement crash_setup_regs()
Implement machine specific function crash_setup_regs() which is responsible for storing machine state when crash occured.
--- arch/arm/include/asm/kexec.h | 35 ++++++++++++++++++++++++++++++++--- 1 files changed, 32 insertions(+), 3 deletions(-)
arch/arm/include/asm/kexec.h +32 -3
@@ -19,10 +19,39 @@#ifndef __ASSEMBLY__ -struct kimage ; -/* Provide a dummy definition to avoid build failures. */ +/* +* crash_setup_regs() - save registers for the panic kernel +* @newregs: registers are saved here +* @oldregs: registers to be saved (may be %NULL) +* +* Function copies machine registers from @oldregs to @newregs. If @oldregs is +* %NULL then current registers are stored there. +*/ static inline void crash_setup_regs (struct pt_regs *newregs, -struct pt_regs *oldregs) { } +struct pt_regs *oldregs) +{ +if (oldregs) { +memcpy (newregs, oldregs,sizeof (*newregs)); + }else { + __asm__ __volatile__("mov %0, r0" :"=r" (newregs->ARM_r0)); + __asm__ __volatile__("mov %0, r1" :"=r" (newregs->ARM_r1)); + __asm__ __volatile__("mov %0, r2" :"=r" (newregs->ARM_r2)); + __asm__ __volatile__("mov %0, r3" :"=r" (newregs->ARM_r3)); + __asm__ __volatile__("mov %0, r4" :"=r" (newregs->ARM_r4)); + __asm__ __volatile__("mov %0, r5" :"=r" (newregs->ARM_r5)); + __asm__ __volatile__("mov %0, r6" :"=r" (newregs->ARM_r6)); + __asm__ __volatile__("mov %0, r7" :"=r" (newregs->ARM_r7)); + __asm__ __volatile__("mov %0, r8" :"=r" (newregs->ARM_r8)); + __asm__ __volatile__("mov %0, r9" :"=r" (newregs->ARM_r9)); + __asm__ __volatile__("mov %0, r10" :"=r" (newregs->ARM_r10)); + __asm__ __volatile__("mov %0, r11" :"=r" (newregs->ARM_fp)); + __asm__ __volatile__("mov %0, r12" :"=r" (newregs->ARM_ip)); + __asm__ __volatile__("mov %0, r13" :"=r" (newregs->ARM_sp)); + __asm__ __volatile__("mov %0, r14" :"=r" (newregs->ARM_lr)); + __asm__ __volatile__("mov %0, r15" :"=r" (newregs->ARM_pc)); + __asm__ __volatile__("mrs %0, cpsr" :"=r" (newregs->ARM_cpsr)); + } +}#endif /* __ASSEMBLY__ */
Signature · 1 line
1.5.6.5
RFC 3/10 arm: kdump: implement machine_crash_shutdown()
Implement function machine_crash_shutdown() which disables IRQs and saves machine state to ELF notes structure.
--- arch/arm/kernel/machine_kexec.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
arch/arm/kernel/machine_kexec.c +4 -0
@@ -43,6 +43,10 @@ void machine_shutdown(void)void machine_crash_shutdown (struct pt_regs *regs) { +local_irq_disable (); +crash_save_cpu (regs,smp_processor_id ()); + +printk (KERN_INFO "Loading crashdump kernel...\n" ); }void machine_kexec (struct kimage *image)
Signature · 1 line
1.5.6.5
RFC 4/10 arm: kdump: skip indirection page when crashing
When we are crashing there is no indirection page in place. Only control page is present.
--- arch/arm/kernel/relocate_kernel.S | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/kernel/relocate_kernel.S +6 -0
@@ -10,6 +10,12 @@ relocate_new_kernel: ldr r0,kexec_indirection_page ldr r1,kexec_start_address + /* + * If there is no indirection page (we are doing crashdumps) + * skip any relocation. + */ + cmp r0, #0 + beq 2f 0: /* top, read another word for the indirection page */ ldr r3, [r0],#4
Signature · 1 line
1.5.6.5
RFC 5/10 arm: kdump: make kexec work in interrupt context
When crash happens in interrupt context there is no userspace context. We always use current->active_mm in those cases.
--- arch/arm/mm/mmu.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
arch/arm/mm/mmu.c +6 -4
@@ -1050,10 +1050,12 @@ void setup_mm_for_reboot(char mode)pgd_t *pgd;int i; -if (current->mm && current->mm->pgd) - pgd = current->mm->pgd; -else - pgd = init_mm.pgd; +/* +* We need to access to user-mode page tables here. For kernel threads +* we don't have any user-mode mappings so we use the context that we +* "borrowed". +*/ + pgd = current->active_mm->pgd; base_pmdval =PMD_SECT_AP_WRITE |PMD_SECT_AP_READ |PMD_TYPE_SECT ;if (cpu_architecture () <= CPU_ARCH_ARMv5TEJ && !cpu_is_xscale ())
Signature · 1 line
1.5.6.5
RFC 6/10 arm: kdump: implement copy_oldmem_page()
This function is used by vmcore code to read a page from the old kernel memory.
--- arch/arm/kernel/Makefile | 1 + arch/arm/kernel/crash_dump.c | 82 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 0 deletions(-) create mode 100644 arch/arm/kernel/crash_dump.c
arch/arm/kernel/Makefile +1 -0
@@ -39,6 +39,7 @@ obj-$(CONFIG_ARM_THUMBEE) += thumbee.o obj-$(CONFIG_KGDB) += kgdb.o obj-$(CONFIG_ARM_UNWIND) += unwind.o obj-$(CONFIG_HAVE_TCM) += tcm.o +obj-$(CONFIG_CRASH_DUMP) += crash_dump.o obj-$(CONFIG_CRUNCH) += crunch.o crunch-bits.o AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
arch/arm/kernel/crash_dump.c new file +82 -0
82 lines not on this page · raw message
Signature · 1 line
1.5.6.5
RFC 7/10 arm: allow passing an ELF64 header to elf_check_arch()
This is needed to shut following compiler warning when CONFIG_PROC_VMCORE is enabled:
fs/proc/vmcore.c: In function 'parse_crash_elf64_headers':fs/proc/vmcore.c:500: warning: passing argument 1 of 'elf_check_arch' from incompatible pointer type
ELF32 and ELF64 headers have common fields of same size (namely e_ident and e_machine) which are checked in arm_elf_check_arch().
--- arch/arm/include/asm/elf.h | 4 ++-- arch/arm/kernel/elf.c | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-)
arch/arm/include/asm/elf.h +2 -2
@@ -92,8 +92,8 @@ struct elf32_hdr;/* * This is used to ensure we don't load something for the wrong architecture. */ -extern int elf_check_arch (const struct elf32_hdr *); -#define elf_check_arch elf_check_arch +extern int arm_elf_check_arch (const struct elf32_hdr *); +#define elf_check_arch (x) arm_elf_check_arch((const struct elf32_hdr *)(x))extern int arm_elf_read_implies_exec (const struct elf32_hdr *,int );#define elf_read_implies_exec (ex,stk) arm_elf_read_implies_exec(&(ex), stk)
arch/arm/kernel/elf.c +4 -2
@@ -4,11 +4,13 @@#include <linux/binfmts.h> #include <linux/elf.h> -int elf_check_arch (const struct elf32_hdr *x) +int arm_elf_check_arch (const struct elf32_hdr *x) {unsigned int eflags;/* Make sure it's an ARM executable */ +if (x->e_ident[EI_CLASS ] !=ELF_CLASS ) +return 0 ;if (x->e_machine !=EM_ARM )return 0 ;
@@ -35,7 +37,7 @@ int elf_check_arch(const struct elf32_hdr *x) }return 1 ; } -EXPORT_SYMBOL (elf_check_arch); +EXPORT_SYMBOL (arm_elf_check_arch);void elf_set_personality (const struct elf32_hdr *x) {
Signature · 1 line
1.5.6.5
RFC 8/10 arm: kdump: add support for elfcorehdr= parameter
This parameter is used by primary kernel to pass address of vmcore header to the dump capture kernel.
--- arch/arm/kernel/setup.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)
arch/arm/kernel/setup.c +25 -0
@@ -20,6 +20,7 @@#include <linux/screen_info.h> #include <linux/init.h> #include <linux/kexec.h> +#include <linux/crash_dump.h> #include <linux/root_dev.h> #include <linux/cpu.h> #include <linux/interrupt.h>
@@ -711,6 +712,30 @@ static void __init reserve_crashkernel(void)static inline void reserve_crashkernel (void ) {}#endif /* CONFIG_KEXEC */ +/* +* Note: elfcorehdr_addr is not just limited to vmcore. It is also used by +* is_kdump_kernel() to determine if we are booting after a panic. Hence +* ifdef it under CONFIG_CRASH_DUMP and not CONFIG_PROC_VMCORE. +*/ + +#ifdef CONFIG_CRASH_DUMP +/* +* elfcorehdr= specifies the location of elf core header stored by the crashed +* kernel. This option will be passed by kexec loader to the capture kernel. +*/ +static int __init setup_elfcorehdr (char *arg) +{ +char *end; + +if (!arg) +return -EINVAL ; + + elfcorehdr_addr =memparse (arg, &end); +return end > arg ?0 : -EINVAL ; +} +early_param ("elfcorehdr" , setup_elfcorehdr); +#endif /* CONFIG_CRASH_DUMP */ +void __init setup_arch (char **cmdline_p) {struct tag *tags = (struct tag *)&init_tags;
Signature · 1 line
1.5.6.5
RFC 9/10 arm: implement reserve memory early parameter
Implemented mem=size$start early parameter which makes it possible to reserve some memory from the kernel. This can be used for dump capture kernels to preserve any memory used by the primary kernel.
--- arch/arm/include/asm/setup.h | 4 ++++ arch/arm/kernel/setup.c | 22 ++++++++++++++++------ arch/arm/mm/init.c | 25 +++++++++++++++++++++++-- 3 files changed, 43 insertions(+), 8 deletions(-)
arch/arm/include/asm/setup.h +4 -0
@@ -203,6 +203,10 @@ struct membank {unsigned long size;unsigned short node;unsigned short highmem; + +#define MEMBANK_FREE 0 +#define MEMBANK_RESERVED 1 +unsigned int flags; };struct meminfo {
arch/arm/kernel/setup.c +16 -6
@@ -387,7 +387,8 @@ static struct machine_desc * __init setup_machine(unsigned int nr)return list; } -static int __init arm_add_memory (unsigned long start,unsigned long size) +static int __init arm_add_memory (unsigned long start,unsigned long size, +unsigned long flags) {struct membank *bank = &meminfo.bank[meminfo.nr_banks];
@@ -405,6 +406,7 @@ static int __init arm_add_memory(unsigned long start, unsigned long size) bank->start =PAGE_ALIGN (start); bank->size = size &PAGE_MASK ; bank->node =PHYS_TO_NID (start); + bank->flags = flags;/* * Check whether this memory region has non-zero size or
@@ -418,13 +420,17 @@ static int __init arm_add_memory(unsigned long start, unsigned long size) }/* -* Pick out the memory size. We look for mem=size at start, +* Pick out the memory size. We look for mem=size at start or mem=size$start, * where start and size are "size[KkMm]" +* +* If '$' is used as a separator, it is interpreted as reserve this memory. This +* can be usefull for example when we are running dump capture kernel and want +* to reserve any memory used by the primary kernel. */ static int __init early_mem (char *p) {static int usermem__initdata =0 ; -unsigned long size, start; +unsigned long size, start, flags =0 ;char *endp;/*
@@ -439,10 +445,14 @@ static int __init early_mem(char *p) start =PHYS_OFFSET ; size =memparse (p, &endp); -if (*endp =='@' ) +if (*endp =='@' ) { + start =memparse (endp +1 ,NULL ); + }else if (*endp =='$' ) { start =memparse (endp +1 ,NULL ); + flags =MEMBANK_RESERVED ; + } -arm_add_memory (start, size); +arm_add_memory (start, size, flags);return 0 ; }
@@ -536,7 +546,7 @@ __tagtable(ATAG_CORE, parse_tag_core);static int __init parse_tag_mem32 (const struct tag *tag) { -return arm_add_memory (tag->u.mem.start, tag->u.mem.size); +return arm_add_memory (tag->u.mem.start, tag->u.mem.size,0 ); }__tagtable (ATAG_MEM , parse_tag_mem32);
arch/arm/mm/init.c +23 -2
@@ -274,8 +274,29 @@ static void __init bootmem_init_node(int node, struct meminfo *mi,for_each_nodebank (i, mi, node) {struct membank *bank = &mi->bank[i]; -if (!bank->highmem) -free_bootmem_node (pgdat,bank_phys_start (bank),bank_phys_size (bank)); +unsigned long start, size; + +if (bank->highmem) +continue ; + + start =bank_phys_start (bank); + size =bank_phys_size (bank); + +free_bootmem_node (pgdat, start, size); + +if (bank->flags &MEMBANK_RESERVED ) { +int err; + + err =reserve_bootmem_node (pgdat, start, size, +BOOTMEM_EXCLUSIVE ); +if (err) +continue ; + +printk (KERN_INFO +"reserved memory: " +"[0x%08lx - 0x%08lx] (%4ld MB)\n" , + start, start + size -1 , size >>20 ); + } }/*
Signature · 1 line
1.5.6.5
RFC 10/10 arm: kdump: add CONFIG_CRASH_DUMP Kconfig option
Add CONFIG_CRASH_DUMP configuration option which is used by dump capture kernels. This option also forces one to link kernel in different address (by default it is 0x02008000).
--- arch/arm/Kconfig | 11 +++++++++++ arch/arm/Makefile | 10 ++++++++++ 2 files changed, 21 insertions(+), 0 deletions(-)
arch/arm/Kconfig +11 -0
@@ -1466,6 +1466,17 @@ config ATAGS_PROC Should the atags used to boot the kernel be exported in an "atags" file in procfs. Useful with kexec. +config CRASH_DUMP + bool "Build kdump crash kernel (EXPERIMENTAL)" + depends on EXPERIMENTAL + help + Build a kernel suitable for use as kdump capture kernel. This should + be set only on dump capture kernels. Note that dump capture kernel + must be loaded into different address than the primary kernel. See + file arch/arm/Makefile how to change this. + + For more details see Documentation/kdump/kdump.txt + endmenu menu "CPU Power Management"
arch/arm/Makefile +10 -0
@@ -109,6 +109,16 @@ CHECKFLAGS += -D__arm__ #Default value head-y := arch/arm/kernel/head$(MMUEXT).o arch/arm/kernel/init_task.o textofs-y := 0x00008000 + +# +# Dump capture kernels are linked by default to address 0x02008000 to prevent +# them from stepping over the primary kernel memory. Adjust this if you need to +# link it into a different address. +# +# Remember also check your $(MACHINE)/Makefile.boot to correspond this. +# +textofs-$(CONFIG_CRASH_DUMP) := 0x02008000 + textofs-$(CONFIG_ARCH_CLPS711X) := 0x00028000 # SA1111 DMA bug: we don't want the kernel to live in precious DMA-able memory ifeq ($(CONFIG_ARCH_SA1100),y)
Signature · 1 line
1.5.6.5
RFC 9/10 arm: implement reserve memory early parameter
In reply to Mika WesterbergQuoted 3 lines · Mika Westerberg
Implemented mem=size$start early parameter which makes it possible to reserve some memory from the kernel. This can be used for dump capture kernels to preserve any memory used by the primary kernel.
Please note that if we move ARM over to LMB, these patches will have to be redone.
However, I'm not sure why this is required - it appears that x86 doesn't require this kind of feature. Can you explain in more detail how this new parameter format would be used?
RFC 9/10 arm: implement reserve memory early parameter
Quoted 7 lines · ext Russell King - ARM Linux
Quoted 3 lines · Mika Westerberg
Implemented mem=size$start early parameter which makes it possible to reserve some memory from the kernel. This can be used for dump capture kernels to preserve any memory used by the primary kernel.
Please note that if we move ARM over to LMB, these patches will have to be redone.
Yes.
Quoted 3 lines
However, I'm not sure why this is required - it appears that x86 doesn't require this kind of feature. Can you explain in more detail how this new parameter format would be used?
Well the idea is to preserve memory used by the primary kernel so that the dump capture kernel is not allowed to use it.
When dump capture kernel is loaded with kexec (a userspace program) it goes through system RAM found in /proc/iomem and marks all segments that are not reserved for crash kernel as being reserved. This marking is done by constructing kernel command line containing something like:
mem=32M at 2112M mem=64M$2048M mem=160M$2144M mem=256M$2304M
Here the last 3 parameters are those that tell the dump capture kernel what memory belongs to the primary kernel.
I actually tried to use only mem=32 at 2112M parameter but somehow the dump capture kernel fails to boot. I couldn't find any reason for that, but it might be that there is something I missed.
I get following when I start the kernel with only mem=32 at 2112M (the kernel is linked to 0xc4000000):
<6>PID hash table entries: 128 (order: -3, 512 bytes)
<6>Dentry cache hash table entries: 4096 (order: 2, 16384 bytes) <6>Inode-cache hash table entries: 2048 (order: 1, 8192 bytes) <6>allocated 163840 bytes of page_cgroup
<6>please try 'cgroup_disable=memory' option if you don't want memory cgroups <1>BUG: Bad page state in process swapper pfn:84000
<1>Unhandled fault: alignment exception (0x001) at 0xfffffffb <0>Internal error: : 1 [#1] PREEMPT
<0>last sysfs file:
<d>Modules linked in:
CPU: 0 Not tainted (2.6.32.10-10448-g59e4695-dirty #12) PC is at bad_page+0xe8/0x13c LR is at 0x0 pc : [<c409fb9c>] lr : [<00000000>] psr: 00000193
sp : c44b7ed0 ip : c44b7e30 fp : c44b7ef4
r10: 00000000 r9 : 00080000 r8 : 7ffffbff
r7 : 00084000 r6 : 00080000 r5 : c45bd000 r4 : ffffffbf
r3 : fffffff7 r2 : 7fbffbff r1 : c45bd000 r0 : c44544ee
Flags: nzcv IRQs off FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 10c5387f Table: 84004019 DAC: 00000017
<0>Process swapper (pid: 0, stack limit = 0xc44b62e8)
<0>Stack: (0xc44b7ed0 to 0xc44b8000)
<0>7ec0: c44cb004 0000087f c44b7f0c c44b7ee8
<0>7ee0: c45bd000 7ffffbff c44b7f1c c44b7ef8 c40a0a18 c409fac0 00000000 00000001 <0>7f00: 00080000 00084000 c402c0cc 00000001 c44b7f2c c44b7f20 c40a0c24 c40a09b4 <0>7f20: c44b7f44 c44b7f30 c40a0c60 c40a0c1c 00000007 00000001 c44b7f54 c44b7f48 <0>7f40: c4029134 c40a0c34 c44b7f9c c44b7f58 c4016c9c c40290c0 c44b7fa4 00002000 <0>7f60: 00000000 00000001 00086000 00080000 413fc082 00000000 c451f830 c402ae14 <0>7f80: c44ba62c 840291ec 413fc082 0000001f c44b7fac c44b7fa0 c4016dc4 c4016b78 <0>7fa0: c44b7fcc c44b7fb0 c400c43c c4016dbc c402ae18 c44fa140 c402ae18 c44fa140 <0>7fc0: c44b7ff4 c44b7fd0 c40089ec c400c35c c4008674 00000000 00000000 c402ae18 <0>7fe0: 10c53c7d c44fa4b0 00000000 c44b7ff8 84008034 c40088d4 00000000 00000000
Backtrace: [<c409fab4>] (bad_page+0x0/0x13c) from [<c40a0a18>] (free_hot_cold_page+0x70/0x22c) r5:7ffffbff r4:c45bd000 [<c40a09a8>] (free_hot_cold_page+0x0/0x22c) from [<c40a0c24>] (free_hot_page+0x14/0x18) [<c40a0c10>] (free_hot_page+0x0/0x18) from [<c40a0c60>] (__free_pages+0x38/0x44) [<c40a0c28>] (__free_pages+0x0/0x44) from [<c4029134>] (__free_pages_bootmem+0x80/0x84) r5:00000001 r4:00000007 [<c40290b4>] (__free_pages_bootmem+0x0/0x84) from [<c4016c9c>] (free_all_bootmem_core+0x130/0x224) [<c4016b6c>] (free_all_bootmem_core+0x0/0x224) from [<c4016dc4>] (free_all_bootmem_node+0x14/0x18) [<c4016db0>] (free_all_bootmem_node+0x0/0x18) from [<c400c43c>] (mem_init+0xec/0x208) [<c400c350>] (mem_init+0x0/0x208) from [<c40089ec>] (start_kernel+0x124/0x2cc) r5:c44fa140 r4:c402ae18 [<c40088c8>] (start_kernel+0x0/0x2cc) from [<84008034>] (0x84008034)
Thanks,
MW
RFC 9/10 arm: implement reserve memory early parameter
In reply to Russell King - ARM LinuxQuoted 11 lines · ext Russell King - ARM Linux
Quoted 3 lines · Mika Westerberg
Implemented mem=size$start early parameter which makes it possible to reserve some memory from the kernel. This can be used for dump capture kernels to preserve any memory used by the primary kernel.
Please note that if we move ARM over to LMB, these patches will have to be redone.
However, I'm not sure why this is required - it appears that x86 doesn't require this kind of feature. Can you explain in more detail how this new parameter format would be used?
Hi,
I investigated this further and it seems that this is, like you commented, not required. It should be enough to pass correct mem=size at start parameter to the dump capture kernel.
I have following changes to get kernel linked into different address (in this case 0xc2008000):
arch/arm/Makefile: textofs-y := 0x02008000 arch/arm/mach-omap2/Makefile.boot: zreladdr-y := 0x82008000
Physical memory in this platform starts at 0x80000000.
When I start the kernel with 'mem=32M at 0x82000000' boot fails in very early stage:
[ 0.000000] BUG: Bad page state in process swapper pfn:82000 [ 0.000000] page:c2ac2000 count:0 mapcount:0 mapping:(null) index:0xffffffff [ 0.000000] page flags: 0x92092(error|dirty|slab|writeback|swapcache|buddy)
Is mem= parameter supposed to work so that I can pass also start address? Now it seems to still use hard-coded PHYS_OFFSET etc. Or maybe I'm doing something wrong here.
I managed to get this working with following patch but it is probably not correct. Any ideas how to get it working properly?
Thanks,
MW
arch/arm/include/asm/memory.h +2 -1
@@ -171,7 +171,8 @@* direct-mapped view. We assume this is the first page * of RAM in the mem_map as well. */ -#define PHYS_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT) +extern unsigned long phys_pfn_offset; +#define PHYS_PFN_OFFSET phys_pfn_offset/* * These are *only* valid on the kernel direct mapped RAM memory.
arch/arm/kernel/setup.c +5 -1
@@ -90,6 +90,8 @@ EXPORT_SYMBOL(system_serial_high);unsigned int elf_hwcap;EXPORT_SYMBOL (elf_hwcap); +unsigned long phys_pfn_offset =PHYS_OFFSET >>PAGE_SHIFT ; +EXPORT_SYMBOL (phys_pfn_offset);#ifdef MULTI_CPU struct processor processor;
@@ -439,8 +441,10 @@ static int __init early_mem(char *p) start =PHYS_OFFSET ; size =memparse (p, &endp); -if (*endp =='@' ) +if (*endp =='@' ) { start =memparse (endp +1 ,NULL ); + phys_pfn_offset = start >>PAGE_SHIFT ; + }arm_add_memory (start, size);
RFC 7/10 arm: allow passing an ELF64 header to elf_check_arch()
In reply to Mika WesterbergQuoted 9 lines · Mika Westerberg
This is needed to shut following compiler warning when
CONFIG_PROC_VMCOREis enabled:
fs/proc/vmcore.c: In function 'parse_crash_elf64_headers':fs/proc/vmcore.c:500: warning: passing argument 1 of 'elf_check_arch' from incompatible pointer typeELF32 and ELF64 headers have common fields of same size (namely
e_identande_machine) which are checked inarm_elf_check_arch().
A smaller patch:
-#define elf_check_arch elf_check_arch
+#define elf_check_arch(x) elf_check_arch((const struct elf32_hdr *)(x))
RFC 7/10 arm: allow passing an ELF64 header to elf_check_arch()
Quoted 13 lines · ext Russell King - ARM Linux
Quoted 9 lines · Mika Westerberg
This is needed to shut following compiler warning when
CONFIG_PROC_VMCOREis enabled:
fs/proc/vmcore.c: In function 'parse_crash_elf64_headers':fs/proc/vmcore.c:500: warning: passing argument 1 of 'elf_check_arch' from incompatible pointer typeELF32 and ELF64 headers have common fields of same size (namely
e_identande_machine) which are checked inarm_elf_check_arch().A smaller patch:
Review
Quoted 2 lines
(quoted diff) +1
-1-#define elf_check_arch elf_check_arch +#define elf_check_arch(x) elf_check_arch((const struct elf32_hdr *)(x))
With this I get:
arch/arm/kernel/elf.c:7: error: expected declaration specifiers or '...' before '(' tokenarch/arm/kernel/elf.c: In function 'elf_check_arch':arch/arm/kernel/elf.c:8: error: number of arguments doesn't match prototype /home/westeri/devel/maemo/linux/linux-2.6/arch/arm/include/asm/elf.h:95: error:
prototype declarationarch/arm/kernel/elf.c:12: error: 'x' undeclared (first use in this function) arch/arm/kernel/elf.c:12: error: (Each undeclared identifier is reported only oncearch/arm/kernel/elf.c:12: error: for each function it appears in.) make[1]: *** [arch/arm/kernel/elf.o] Error 1
make: *** [arch/arm/kernel] Error 2
That's why I changed name of the function to arm_elf_check_arch().
Thanks,
MW
RFC 7/10 arm: allow passing an ELF64 header to elf_check_arch()
In reply to Mika WesterbergQuoted 9 lines · Mika Westerberg
This is needed to shut following compiler warning when
CONFIG_PROC_VMCOREis enabled:
fs/proc/vmcore.c: In function 'parse_crash_elf64_headers':fs/proc/vmcore.c:500: warning: passing argument 1 of 'elf_check_arch' from incompatible pointer typeELF32 and ELF64 headers have common fields of same size (namely
e_identande_machine) which are checked inarm_elf_check_arch().
Wouldn't it be better to just disable the elf64 code entirely on 32-bit archs, saving about half of the code size in vmcore.c which looks like it will never be called?
-- Jamie
RFC 7/10 arm: allow passing an ELF64 header to elf_check_arch()
Quoted 8 lines · ext Jamie Lokier
Quoted 7 lines · Mika Westerberg
This is needed to shut following compiler warning when
CONFIG_PROC_VMCOREis enabled:
fs/proc/vmcore.c: In function 'parse_crash_elf64_headers':fs/proc/vmcore.c:500: warning: passing argument 1 of 'elf_check_arch' from incompatible pointer type
Quoted 6 lines
Quoted 2 lines
ELF32 and ELF64 headers have common fields of same size (namely
e_identande_machine) which are checked inarm_elf_check_arch().Wouldn't it be better to just disable the elf64 code entirely on 32-bit archs, saving about half of the code size in
vmcore.cwhich looks like it will never be called?
I took this approach from the other architectures that implement kdump.
At least on those archs that support both 32 and 64-bit both versions should be supported. But I can add the required #ifdefs to vmcore code if preferred.
Thanks,
MW
RFC 7/10 arm: allow passing an ELF64 header to elf_check_arch()
Quoted 9 lines · Mika Westerberg
Quoted 3 lines · ext Jamie Lokier
Wouldn't it be better to just disable the elf64 code entirely on 32-bit archs, saving about half of the code size in
vmcore.cwhich looks like it will never be called?I took this approach from the other architectures that implement kdump.
At least on those archs that support both 32 and 64-bit both versions should be supported. But I can add the required #ifdefs to vmcore code if preferred.
Ok, copying the other archs makes sense. Someone can trim vmcore.c in a separate patch later and tidy up the archs while they're at it. (I've put it on my todo list but I rarely actually do the things on it...)
-- Jamie
RFC 5/10 arm: kdump: make kexec work in interrupt context
In reply to Mika WesterbergQuoted 2 lines · Mika Westerberg
When crash happens in interrupt context there is no userspace context. We always use
current->active_mmin those cases.
Ok. This should probably be a standalone bug fix. Please send it to the patch system, thanks.
RFC 2/10 arm: kdump: implement crash_setup_regs()
In reply to Mika WesterbergQuoted 2 lines · Mika Westerberg
Implement machine specific function
crash_setup_regs()which is responsible for storing machine state when crash occured.
Slightly concerned about this...
Quoted 8 lines
arch/arm/include/asm/kexec.h +8
-0+ }else { + __asm__ __volatile__("mov %0, r0" :"=r" (newregs->ARM_r0)); + __asm__ __volatile__("mov %0, r1" :"=r" (newregs->ARM_r1)); + __asm__ __volatile__("mov %0, r2" :"=r" (newregs->ARM_r2)); + __asm__ __volatile__("mov %0, r3" :"=r" (newregs->ARM_r3)); + __asm__ __volatile__("mov %0, r4" :"=r" (newregs->ARM_r4)); + __asm__ __volatile__("mov %0, r5" :"=r" (newregs->ARM_r5)); + __asm__ __volatile__("mov %0, r6" :"=r" (newregs->ARM_r6));
arch/arm/include/asm/kexec.h line 52
Quoted 10 lines
arch/arm/include/asm/kexec.h +10
-0+ __asm__ __volatile__("mov %0, r7" :"=r" (newregs->ARM_r7)); + __asm__ __volatile__("mov %0, r8" :"=r" (newregs->ARM_r8)); + __asm__ __volatile__("mov %0, r9" :"=r" (newregs->ARM_r9)); + __asm__ __volatile__("mov %0, r10" :"=r" (newregs->ARM_r10)); + __asm__ __volatile__("mov %0, r11" :"=r" (newregs->ARM_fp)); + __asm__ __volatile__("mov %0, r12" :"=r" (newregs->ARM_ip)); + __asm__ __volatile__("mov %0, r13" :"=r" (newregs->ARM_sp)); + __asm__ __volatile__("mov %0, r14" :"=r" (newregs->ARM_lr)); + __asm__ __volatile__("mov %0, r15" :"=r" (newregs->ARM_pc)); + __asm__ __volatile__("mrs %0, cpsr" :"=r" (newregs->ARM_cpsr));
How is whatever follows on supposed to work back from this state? It's entirely possible that the compiler will generate a load of asm between each __asm__ statement corrupting the registers - and you can't save all this state without having one register storing the 'newregs' pointer.
It'd probably be better to do something like:
__asm__ __volatile__("stmia %0, {r0 - r15}" : : "r" (&newregs->ARM_r0));
__asm__ __volatile__("mrs %0, cpsr" : "=r" (newregs->ARM_cpsr));instead, which should mean only one register is (potentially) corrupted. However, I still think you're going to have problems knowing what's in each register.
RFC 2/10 arm: kdump: implement crash_setup_regs()
Quoted 22 lines · ext Russell King - ARM Linux
Quoted 2 lines · Mika Westerberg
Implement machine specific function
crash_setup_regs()which is responsible for storing machine state when crash occured.Slightly concerned about this...
Quoted 16 lines
arch/arm/include/asm/kexec.h +16
-0+ }else { + __asm__ __volatile__("mov %0, r0" :"=r" (newregs->ARM_r0)); + __asm__ __volatile__("mov %0, r1" :"=r" (newregs->ARM_r1)); + __asm__ __volatile__("mov %0, r2" :"=r" (newregs->ARM_r2)); + __asm__ __volatile__("mov %0, r3" :"=r" (newregs->ARM_r3)); + __asm__ __volatile__("mov %0, r4" :"=r" (newregs->ARM_r4)); + __asm__ __volatile__("mov %0, r5" :"=r" (newregs->ARM_r5)); + __asm__ __volatile__("mov %0, r6" :"=r" (newregs->ARM_r6)); + __asm__ __volatile__("mov %0, r7" :"=r" (newregs->ARM_r7)); + __asm__ __volatile__("mov %0, r8" :"=r" (newregs->ARM_r8)); + __asm__ __volatile__("mov %0, r9" :"=r" (newregs->ARM_r9)); + __asm__ __volatile__("mov %0, r10" :"=r" (newregs->ARM_r10)); + __asm__ __volatile__("mov %0, r11" :"=r" (newregs->ARM_fp)); + __asm__ __volatile__("mov %0, r12" :"=r" (newregs->ARM_ip)); + __asm__ __volatile__("mov %0, r13" :"=r" (newregs->ARM_sp)); + __asm__ __volatile__("mov %0, r14" :"=r" (newregs->ARM_lr));
Quoted 8 lines
arch/arm/include/asm/kexec.h line 52
Quoted 2 lines
arch/arm/include/asm/kexec.h +2
-0+ __asm__ __volatile__("mov %0, r15" :"=r" (newregs->ARM_pc)); + __asm__ __volatile__("mrs %0, cpsr" :"=r" (newregs->ARM_cpsr));How is whatever follows on supposed to work back from this state? It's entirely possible that the compiler will generate a load of asm between each
__asm__statement corrupting the registers - and you can't save all this state without having one register storing the 'newregs' pointer.
Yeah. I'll have to admit that this is copied from other archs. For example in x86 they do similar. Anyway I think that it is not necessary to get these exactly correct because what we are really interested are the frames before, e.g where the crash happened.
Quoted 8 lines
It'd probably be better to do something like:
__asm__ __volatile__("stmia %0, {r0 - r15}" : : "r" (&newregs->ARM_r0)); __asm__ __volatile__("mrs %0, cpsr" : "=r" (newregs->ARM_cpsr));instead, which should mean only one register is (potentially) corrupted. However, I still think you're going to have problems knowing what's in each register.
Thanks. I think we can live with one register corrupted (unless someone has better aproach for this). I'll use this in the next revision of the patches.
Regards,
MW