Skip to contentSkip to conversation

kexec-tools: ARM kernel crashdump support

PATCH Superseded Mika Westerberg 1 participant 3 messages Apr 26, 2010

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover kexec-tools: ARM kernel crashdump support

Hello,

These patches bring ARM kernel crashdump support for kexec-tools. They need kernel support which was posted on LAKML while ago[1]. I should've sent them both at the same time so that people actually could try them but apparently I didn't. Sorry about that. I can sent the whole series again if preferred.

Only zImage format is currently supported.

In addition, I have modified sample gdb macros from kernel/Documentation/kdump/gdbmacrox.txt to work with ARM crashdumps. They are included in the end of this email in case someone finds them useful.

I have been testing these on my N900.

Thanks,
MW

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2010-April/013245.html

Mika Westerberg (2):
kexec: add phys_offset field
kexec: implement ARM crashdump support

 kexec/arch/arm/Makefile           |    1 +
 kexec/arch/arm/crashdump-arm.c    |  318 +++++++++++++++++++++++++++++++++++++
 kexec/arch/arm/crashdump-arm.h    |   19 +++
 kexec/arch/arm/kexec-arm.c        |    5 -
 kexec/arch/arm/kexec-zImage-arm.c |   47 +++++-
 kexec/crashdump-elf.c             |    9 +-
 kexec/crashdump.h                 |    1 +
 7 files changed, 392 insertions(+), 8 deletions(-)
 create mode 100644 kexec/arch/arm/crashdump-arm.c
 create mode 100644 kexec/arch/arm/crashdump-arm.h

------------------------- ~/.gdbinit ------------------------- #
# Useful gdb macros for ARM kdumps. Derived from macros

# in Documentation/kdump/gdbmacros.txt.
#
# Credits:
# Alexander Nyberg <[email protected]>
# V Srivatsa <[email protected]>
# Maneesh Soni <[email protected]>
# Mika Westerberg <[email protected]>
#

define arch_current_thread_info

	set $current_thread_info = \
		(struct thread_info *)((unsigned long)$sp & ~(8192-1))

end

define current

	arch_current_thread_info

	set $current = $current_thread_info->task

end

define ps

	set $tasks_off=((size_t)&((struct task_struct *)0)->tasks)
	set $init_t=&init_task
	set $next_t=(((char *)($init_t->tasks).next) - $tasks_off)

	# get current task
	current

	printf "PID        COMMAND              TASK\n"

	while ($next_t != $init_t)
		set $next_t=(struct task_struct *)$next_t

		printf "%-10d %-20s 0x%x", $next_t->pid, $next_t->comm, $next_t
		if ($next_t == $current)
			printf "*\n"
		else
			printf "\n"
		end

		set $next_t=(char *)($next_t->tasks.next) - $tasks_off
	end

end

define dmesg

	set $i = 0
	set $end_idx = (log_end - 1) & (log_buf_len - 1)

	while ($i < logged_chars)
		set $idx = (log_end - 1 - logged_chars + $i) & (log_buf_len - 1)

		if ($idx + 100 <= $end_idx) || \
		   ($end_idx <= $idx && $idx + 100 < log_buf_len)
			printf "%.100s", &log_buf[$idx]
			set $i = $i + 100
		else
			printf "%c", log_buf[$idx]
			set $i = $i + 1
		end
	end

end
document dmesg
print the kernel ring buffer
end

define lsfs

	set $fs = file_systems

	while ($fs != 0)
		printf "%-20s %p\n", $fs->name, $fs
		set $fs = $fs->next
	end

end
document lsfs
prints registered filesystems
end

define print_mount_path

	if ($arg0 != $arg1->d_parent)
		print_mount_path $arg0->d_parent $arg1
	end
	if ($arg0->d_name.name[0] != '/')
		printf "/%s", $arg0->d_name.name
	end

end

define print_mount

	if ($arg0 != $arg1)
		print_mount $arg0->mnt_parent $arg1
	end

	print_mount_path $arg0->mnt_mountpoint $arg0->mnt_mountpoint->d_parent

end

define mounts

	current
	set $vfsmount_off=((size_t)&((struct vfsmount *)0)->mnt_list)
	set $root = $current->nsproxy->mnt_ns->root
	set $r_prev = $root->mnt_list.prev
	set $r_next = $root->mnt_list.next
	set $mnt=(struct vfsmount *)((char *)($r_next) - $vfsmount_off)
	while ($r_next != $r_prev)
		printf "%-20s %p %-10s ", $mnt->mnt_devname, $mnt, $mnt->mnt_sb->s_id
		if ($mnt->mnt_parent == $root)
			printf "/"
		else
			print_mount $mnt $root
		end
		printf "\n"

		set $r_next = $mnt->mnt_list.next
		set $mnt=(struct vfsmount *)((char *)($r_next) - $vfsmount_off)
	end

end
document mounts
prints out all mounts
end

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw

PATCH 1/2 kexec: add phys_offset field

Add new field 'phys_offset' to struct elf_info. This field is used to calculate virtual address of PT_LOAD segment on architectures where physical memory doesn't always start at address 0 (namely ARM).

---
 kexec/crashdump-elf.c |    9 ++++++++-
 kexec/crashdump.h     |    1 +
 2 files changed, 9 insertions(+), 1 deletions(-)
kexec/crashdump-elf.c +8 -1
index 6bcef8d..1291174 100644
@@ -236,7 +236,14 @@ int FUNC(struct kexec_info *info,
 		 * memory region.
 		 */
 		phdr->p_paddr = mstart;
-		phdr->p_vaddr = mstart + elf_info->page_offset;
+		/*
+		 * In some architectures (namely ARM), physical memory doesn't
+		 * always start at 0 so we need to calculate virtual address
+		 * based on elf_info->phys_offset like:
+		 *     virt = phys + page_offset - phys_offset
+		 */
+		phdr->p_vaddr = mstart + elf_info->page_offset -
+				elf_info->phys_offset;
 		phdr->p_filesz	= phdr->p_memsz	= mend - mstart + 1;
 		/* Do we need any alignment of segments? */
 		phdr->p_align	= 0;
kexec/crashdump.h +1 -0
index 30d6f29..8c0ccda 100644
@@ -27,6 +27,7 @@ struct crash_elf_info {
 	unsigned long backup_src_end;
 
 	unsigned long long page_offset;
+	unsigned long long phys_offset;
 	unsigned long lowmem_limit;
 
 	int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
Signature · 7 lines
1.5.6.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
#2 lore raw

PATCH 2/2 kexec: implement ARM crashdump support

In reply to Mika Westerberg

Implement support for loading dump capture kernels for ARM architecture. ARM doesn't need any backup memory regions so only elfcore header is allocated from the top of the reserved memory region. Only zImages are supported.

The dump capture kernel needs to be loaded to physical address corresponding to the memory region reserved with 'crashkernel=size@start' kernel command line parameter.

---
 kexec/arch/arm/Makefile           |    1 +
 kexec/arch/arm/crashdump-arm.c    |  318 +++++++++++++++++++++++++++++++++++++
 kexec/arch/arm/crashdump-arm.h    |   19 +++
 kexec/arch/arm/kexec-arm.c        |    5 -
 kexec/arch/arm/kexec-zImage-arm.c |   47 +++++-
 5 files changed, 383 insertions(+), 7 deletions(-)
 create mode 100644 kexec/arch/arm/crashdump-arm.c
 create mode 100644 kexec/arch/arm/crashdump-arm.h
kexec/arch/arm/Makefile +1 -0
index 2ecdb66..79ccc73 100644
@@ -5,6 +5,7 @@ arm_KEXEC_SRCS=  kexec/arch/arm/kexec-elf-rel-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-zImage-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-uImage-arm.c
 arm_KEXEC_SRCS+= kexec/arch/arm/kexec-arm.c
+arm_KEXEC_SRCS+= kexec/arch/arm/crashdump-arm.c
 arm_KEXEC_SRCS+= kexec/kexec-uImage.c
 
 dist += kexec/arch/arm/Makefile $(arm_KEXEC_SRCS)			\
kexec/arch/arm/crashdump-arm.c new file +318 -0

318 lines not on this page · raw message

kexec/arch/arm/crashdump-arm.h new file +19 -0
new file mode 100644
index 0000000..2a4d12b
@@ -0,0 +1,19 @@
+#ifndef CRASHDUMP_ARM_H
+#define CRASHDUMP_ARM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define COMMAND_LINE_SIZE	1024
+#define PAGE_OFFSET		0xc0000000
+#define CRASH_MAX_MEMORY_RANGES	32
+
+struct kexec_info;
+extern int load_crashdump_segments(struct kexec_info *, char *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* CRASHDUMP_ARM_H */
kexec/arch/arm/kexec-arm.c +0 -5
index 06ed8fd..55c76a6 100644
@@ -121,8 +121,3 @@ int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
-
-int is_crashkernel_mem_reserved(void)
-{
-	return 0; /* kdump is not supported on this platform (yet) */
-}
kexec/arch/arm/kexec-zImage-arm.c +45 -2

68 lines not on this page · raw message

Signature · 7 lines
1.5.6.5


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec