linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] makedumpfile: add support for ARM crashdumps
@ 2010-06-22  6:59 Mika Westerberg
  2010-06-22  6:59 ` [PATCH 1/3] use ARCH_PFN_OFFSET for pfn_to_paddr/paddr_to_pfn translations Mika Westerberg
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Mika Westerberg @ 2010-06-22  6:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hello,

This series adds support for ARM kernel crashdumps to makedumpfile. Although,
kernel support is not yet in mainline, I think that it doesn't hurt to have
necessary userspace tools available when that happens.

If someone wants to try, kernel patches can be found:
	http://lists.infradead.org/pipermail/linux-arm-kernel/2010-May/014230.html

and kexec-tools already contain ARM crashdump support.

Regards,
MW

Mika Westerberg (3):
  use ARCH_PFN_OFFSET for pfn_to_paddr/paddr_to_pfn translations
  page_to_pfn(): use ULONGLONG_MAX to for invalid pfn
  add ARM crashdump support

 Makefile       |    4 +-
 arm.c          |  200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 makedumpfile.c |    7 +-
 makedumpfile.h |   43 ++++++++++++-
 4 files changed, 247 insertions(+), 7 deletions(-)
 create mode 100644 arm.c

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/3] use ARCH_PFN_OFFSET for pfn_to_paddr/paddr_to_pfn translations
  2010-06-22  6:59 [PATCH 0/3] makedumpfile: add support for ARM crashdumps Mika Westerberg
@ 2010-06-22  6:59 ` Mika Westerberg
  2010-06-22  6:59 ` [PATCH 2/3] page_to_pfn(): use ULONGLONG_MAX to for invalid pfn Mika Westerberg
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2010-06-22  6:59 UTC (permalink / raw)
  To: linux-arm-kernel

This is needed on architectures where PHYS_OFFSET is not always zero.
By default ARCH_PFN_OFFSET is zero but archs may redefine it if needed.

Also make sure that exclude_zero_pages() uses pfn_to_paddr().

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
---
 makedumpfile.c |    2 +-
 makedumpfile.h |   10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index 8a90baa..a33bab6 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -4810,7 +4810,7 @@ exclude_zero_pages(void)
 
 	initialize_2nd_bitmap(&bitmap2);
 
-	for (pfn = paddr = 0; pfn < info->max_mapnr;
+	for (pfn = 0, paddr = pfn_to_paddr(pfn); pfn < info->max_mapnr;
 	    pfn++, paddr += info->page_size) {
 
 		print_progress(PROGRESS_ZERO_PAGES, pfn, info->max_mapnr);
diff --git a/makedumpfile.h b/makedumpfile.h
index 2785001..2717d81 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -112,8 +112,6 @@ isAnon(unsigned long mapping)
 #define PAGEOFFSET(X)		(((unsigned long)(X)) & (PAGESIZE() - 1))
 #define PAGEBASE(X)		(((unsigned long)(X)) & ~(PAGESIZE() - 1))
 #define _2MB_PAGE_MASK		(~((2*1048576)-1))
-#define paddr_to_pfn(X)		((unsigned long long)(X) >> PAGESHIFT())
-#define pfn_to_paddr(X)		((unsigned long long)(X) << PAGESHIFT())
 
 /*
  * for SPARSEMEM
@@ -696,6 +694,14 @@ unsigned long long vaddr_to_paddr_ia64(unsigned long vaddr);
 #define VADDR_REGION(X)		(((unsigned long)(X)) >> REGION_SHIFT)
 #endif          /* ia64 */
 
+#ifndef ARCH_PFN_OFFSET
+#define ARCH_PFN_OFFSET		0
+#endif
+#define paddr_to_pfn(X) \
+	(((unsigned long long)(X) >> PAGESHIFT()) - ARCH_PFN_OFFSET)
+#define pfn_to_paddr(X) \
+	(((unsigned long long)(X) + ARCH_PFN_OFFSET) << PAGESHIFT())
+
 struct pt_load_segment {
 	off_t			file_offset;
 	unsigned long long	phys_start;
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/3] page_to_pfn(): use ULONGLONG_MAX to for invalid pfn
  2010-06-22  6:59 [PATCH 0/3] makedumpfile: add support for ARM crashdumps Mika Westerberg
  2010-06-22  6:59 ` [PATCH 1/3] use ARCH_PFN_OFFSET for pfn_to_paddr/paddr_to_pfn translations Mika Westerberg
@ 2010-06-22  6:59 ` Mika Westerberg
  2010-06-22  6:59 ` [PATCH 3/3] add ARM crashdump support Mika Westerberg
  2010-06-22  7:40 ` [PATCH 0/3] makedumpfile: add support for ARM crashdumps Masayuki Igawa
  3 siblings, 0 replies; 11+ messages in thread
From: Mika Westerberg @ 2010-06-22  6:59 UTC (permalink / raw)
  To: linux-arm-kernel

Some architectures define PHYS_PFN_OFFSET to be != 0 (ARM for example). This
means that mem_map[0] is actually first page in kernel direct mapped view (which
is a valid page).

Change invalid pfn to be ULONGLONG_MAX instead of 0 to handle such cases.

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
---
 makedumpfile.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index a33bab6..89360bd 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -4383,7 +4383,8 @@ unsigned long long
 page_to_pfn(unsigned long page)
 {
 	unsigned int num;
-	unsigned long long pfn = 0, index = 0;
+	unsigned long long pfn = ULONGLONG_MAX;
+	unsigned long long index = 0;
 	struct mem_map_data *mmd;
 
 	mmd = info->mem_map_data;
@@ -4398,7 +4399,7 @@ page_to_pfn(unsigned long page)
 		pfn = mmd->pfn_start + index;
 		break;
 	}
-	if (!pfn) {
+	if (pfn == ULONGLONG_MAX) {
 		ERRMSG("Can't convert the address of page descriptor (%lx) to pfn.\n", page);
 		return ULONGLONG_MAX;
 	}
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 3/3] add ARM crashdump support
  2010-06-22  6:59 [PATCH 0/3] makedumpfile: add support for ARM crashdumps Mika Westerberg
  2010-06-22  6:59 ` [PATCH 1/3] use ARCH_PFN_OFFSET for pfn_to_paddr/paddr_to_pfn translations Mika Westerberg
  2010-06-22  6:59 ` [PATCH 2/3] page_to_pfn(): use ULONGLONG_MAX to for invalid pfn Mika Westerberg
@ 2010-06-22  6:59 ` Mika Westerberg
  2010-06-24  7:33   ` Masayuki Igawa
  2010-06-22  7:40 ` [PATCH 0/3] makedumpfile: add support for ARM crashdumps Masayuki Igawa
  3 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2010-06-22  6:59 UTC (permalink / raw)
  To: linux-arm-kernel

This patch adds support for processing ARM kernel crashdumps as well.

Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
---
 Makefile       |    4 +-
 arm.c          |  200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 makedumpfile.h |   33 +++++++++
 3 files changed, 235 insertions(+), 2 deletions(-)
 create mode 100644 arm.c

diff --git a/Makefile b/Makefile
index 4a8a060..3d2ee34 100644
--- a/Makefile
+++ b/Makefile
@@ -23,8 +23,8 @@ CFLAGS_ARCH += -m64
 endif
 
 SRC	= makedumpfile.c makedumpfile.h diskdump_mod.h
-SRC_ARCH = x86.c x86_64.c ia64.c ppc64.c
-OBJ_ARCH = x86.o x86_64.o ia64.o ppc64.o
+SRC_ARCH = arm.c x86.c x86_64.c ia64.c ppc64.c
+OBJ_ARCH = arm.o x86.o x86_64.o ia64.o ppc64.o
 
 all: makedumpfile
 
diff --git a/arm.c b/arm.c
new file mode 100644
index 0000000..5acad78
--- /dev/null
+++ b/arm.c
@@ -0,0 +1,200 @@
+/*
+ * arm.c
+ *
+ * Created by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
+ * Copyright (C) 2010 Nokia Corporation
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+#ifdef __arm__
+
+#include "makedumpfile.h"
+
+#define PMD_TYPE_MASK	3
+#define PMD_TYPE_SECT	2
+#define PMD_TYPE_TABLE	1
+
+#define pgd_index(vaddr) ((vaddr) >> PGDIR_SHIFT)
+#define pte_index(vaddr) ((vaddr >> PAGESHIFT()) & (PTRS_PER_PTE - 1))
+
+#define pgd_offset(pgdir, vaddr) \
+	((pgdir) + pgd_index(vaddr) * 2 * sizeof(unsigned long))
+#define pmd_offset(dir, vaddr) (dir)
+#define pte_offset(pmd, vaddr) \
+	(pmd_page_vaddr(pmd) + pte_index(vaddr) * sizeof(unsigned long))
+
+/*
+ * These only work for kernel directly mapped addresses.
+ */
+#define __va(paddr) ((paddr) - info->phys_base + info->page_offset)
+#define __pa(vaddr) ((vaddr) - info->page_offset + info->phys_base)
+
+static inline unsigned long
+pmd_page_vaddr(unsigned long pmd)
+{
+	unsigned long ptr;
+
+	ptr = pmd & ~(PTRS_PER_PTE * sizeof(void *) - 1);
+	ptr += PTRS_PER_PTE * sizeof(void *);
+
+	return __va(ptr);
+}
+
+int
+get_phys_base_arm(void)
+{
+	unsigned long phys_base = ULONG_MAX;
+	int i;
+
+	/*
+	 * We resolve phys_base from PT_LOAD segments. LMA contains physical
+	 * address of the segment, and we use the first one.
+	 */
+	for (i = 0; i < info->num_load_memory; i++) {
+		const struct pt_load_segment *pls = &info->pt_load_segments[i];
+
+		if (pls->phys_start < phys_base)
+			phys_base = pls->phys_start;
+	}
+
+	if (phys_base == ULONG_MAX) {
+		ERRMSG("Can't determine phys_base.\n");
+		return FALSE;
+	}
+
+	info->phys_base = phys_base;
+	DEBUG_MSG("phys_base    : %lx\n", phys_base);
+
+	return TRUE;
+}
+
+int
+get_machdep_info_arm(void)
+{
+	unsigned long vmlist, vmalloc_start;
+
+	info->page_offset = __PAGE_OFFSET;
+	info->max_physmem_bits = _MAX_PHYSMEM_BITS;
+	info->kernel_start = SYMBOL(_stext);
+	info->section_size_bits = _SECTION_SIZE_BITS;
+
+	/*
+	 * For the compatibility, makedumpfile should run without the symbol
+	 * vmlist and the offset of vm_struct.addr if they are not necessary.
+	 */
+	if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL) ||
+		OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE) {
+		return TRUE;
+	}
+
+	if (!readmem(VADDR, SYMBOL(vmlist), &vmlist, sizeof(vmlist))) {
+		ERRMSG("Can't get vmlist.\n");
+		return FALSE;
+	}
+	if (!readmem(VADDR, vmlist + OFFSET(vm_struct.addr), &vmalloc_start,
+		     sizeof(vmalloc_start))) {
+		ERRMSG("Can't get vmalloc_start.\n");
+		return FALSE;
+	}
+
+	info->vmalloc_start = vmalloc_start;
+
+	DEBUG_MSG("page_offset  : %lx\n", info->page_offset);
+	DEBUG_MSG("kernel_start : %lx\n", info->kernel_start);
+	DEBUG_MSG("vmalloc_start: %lx\n", vmalloc_start);
+
+	return TRUE;
+}
+
+static int
+is_vmalloc_addr_arm(unsigned long vaddr)
+{
+	return (info->vmalloc_start && vaddr >= info->vmalloc_start);
+}
+
+/*
+ * vtop_arm() - translate arbitrary virtual address to physical
+ * @vaddr: virtual address to translate
+ *
+ * Function translates @vaddr into physical address using page tables. This
+ * address can be any virtual address. Returns physical address of the
+ * corresponding virtual address or %NOT_PADDR when there is no translation.
+ */
+static unsigned long long
+vtop_arm(unsigned long vaddr)
+{
+	unsigned long long paddr = NOT_PADDR;
+	unsigned long ptr, pgd, pte, pmd;
+
+	if (SYMBOL(swapper_pg_dir) == NOT_FOUND_SYMBOL) {
+		ERRMSG("Can't get the symbol of swapper_pg_dir.\n");
+		return NOT_PADDR;
+	}
+
+	ptr = pgd_offset(SYMBOL(swapper_pg_dir), vaddr);
+	if (!readmem(VADDR, ptr, &pgd, sizeof(pmd))) {
+		ERRMSG("Can't read pgd\n");
+		return NOT_PADDR;
+	}
+
+	if (info->vaddr_for_vtop == vaddr)
+		MSG("  PGD : %08lx => %08lx\n", ptr, pgd);
+
+	pmd = pmd_offset(pgd, vaddr);
+
+	switch (pmd & PMD_TYPE_MASK) {
+	case PMD_TYPE_TABLE: {
+		/* 4k small page */
+		ptr = pte_offset(pmd, vaddr);
+		if (!readmem(VADDR, ptr, &pte, sizeof(pte))) {
+			ERRMSG("Can't read pte\n");
+			return NOT_PADDR;
+		}
+
+		if (info->vaddr_for_vtop == vaddr)
+			MSG("  PTE : %08lx => %08lx\n", ptr, pte);
+
+		if (!(pte & _PAGE_PRESENT)) {
+			ERRMSG("Can't get a valid pte.\n");
+			return NOT_PADDR;
+		}
+
+		paddr = PAGEBASE(pte) + (vaddr & (PAGESIZE() - 1));
+		break;
+	}
+
+	case PMD_TYPE_SECT:
+		/* 1MB section */
+		pte = pmd & PMD_MASK;
+		paddr = pte + (vaddr & (PMD_SIZE - 1));
+		break;
+	}
+
+	return paddr;
+}
+
+unsigned long long
+vaddr_to_paddr_arm(unsigned long vaddr)
+{
+	unsigned long long paddr;
+
+	if ((paddr = vaddr_to_paddr_general(vaddr)) != NOT_PADDR)
+		return paddr;
+
+	if (is_vmalloc_addr_arm(vaddr))
+		paddr = vtop_arm(vaddr);
+	else
+		paddr = __pa(vaddr);
+
+	return paddr;
+}
+
+#endif /* __arm__ */
diff --git a/makedumpfile.h b/makedumpfile.h
index 2717d81..8a74b34 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -506,6 +506,24 @@ do { \
 #define VMEMMAP_START		(info->vmemmap_start)
 #define VMEMMAP_END		(info->vmemmap_end)
 
+#ifdef __arm__
+#define __PAGE_OFFSET		(0xc0000000)
+#define KVBASE_MASK		(0xffff)
+#define KVBASE			(SYMBOL(_stext) & ~KVBASE_MASK)
+#define _SECTION_SIZE_BITS	(28)
+#define _MAX_PHYSMEM_BITS	(32)
+#define ARCH_PFN_OFFSET		(info->phys_base >> PAGESHIFT())
+
+#define PTRS_PER_PTE		(512)
+#define PGDIR_SHIFT		(21)
+#define PMD_SHIFT		(21)
+#define PMD_SIZE		(1UL << PMD_SHIFT)
+#define PMD_MASK		(~(PMD_SIZE - 1))
+
+#define _PAGE_PRESENT		(1 << 0)
+
+#endif /* arm */
+
 #ifdef __x86__
 #define __PAGE_OFFSET		(0xc0000000)
 #define __VMALLOC_RESERVE       (128 << 20)
@@ -653,6 +671,16 @@ do { \
 /*
  * The function of dependence on machine
  */
+#ifdef __arm__
+int get_phys_base_arm(void);
+int get_machdep_info_arm(void);
+unsigned long long vaddr_to_paddr_arm(unsigned long vaddr);
+#define get_phys_base()		get_phys_base_arm()
+#define get_machdep_info()	get_machdep_info_arm()
+#define get_versiondep_info()	TRUE
+#define vaddr_to_paddr(X)	vaddr_to_paddr_arm(X)
+#endif /* arm */
+
 #ifdef __x86__
 int get_machdep_info_x86(void);
 int get_versiondep_info_x86(void);
@@ -1148,6 +1176,11 @@ struct domain_list {
 #define PAGES_PER_MAPWORD 	(sizeof(unsigned long) * 8)
 #define MFNS_PER_FRAME		(info->page_size / sizeof(unsigned long))
 
+#ifdef __arm__
+#define kvtop_xen(X)	FALSE
+#define get_xen_info_arch(X) FALSE
+#endif	/* arm */
+
 #ifdef __x86__
 #define HYPERVISOR_VIRT_START_PAE	(0xF5800000UL)
 #define HYPERVISOR_VIRT_START		(0xFC000000UL)
-- 
1.5.6.5

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 0/3] makedumpfile: add support for ARM crashdumps
  2010-06-22  6:59 [PATCH 0/3] makedumpfile: add support for ARM crashdumps Mika Westerberg
                   ` (2 preceding siblings ...)
  2010-06-22  6:59 ` [PATCH 3/3] add ARM crashdump support Mika Westerberg
@ 2010-06-22  7:40 ` Masayuki Igawa
  3 siblings, 0 replies; 11+ messages in thread
From: Masayuki Igawa @ 2010-06-22  7:40 UTC (permalink / raw)
  To: linux-arm-kernel

Hi, Mika.

Thank you for your patches.

I'll check them.

BTW, I'm preparing for makedumpfile-v1.3.6 release now.
So I'll skip merging these patches in this v1.3.6 release.
These patches will be merged in the next release(may be v1.3.7).

Thanks.
-- 
Masayuki Igawa


From: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Subject: [PATCH 0/3] makedumpfile: add support for ARM crashdumps
Date: Tue, 22 Jun 2010 09:59:09 +0300
> Hello,
> 
> This series adds support for ARM kernel crashdumps to makedumpfile. Although,
> kernel support is not yet in mainline, I think that it doesn't hurt to have
> necessary userspace tools available when that happens.
> 
> If someone wants to try, kernel patches can be found:
> 	http://lists.infradead.org/pipermail/linux-arm-kernel/2010-May/014230.html
> 
> and kexec-tools already contain ARM crashdump support.
> 
> Regards,
> MW
> 
> Mika Westerberg (3):
>   use ARCH_PFN_OFFSET for pfn_to_paddr/paddr_to_pfn translations
>   page_to_pfn(): use ULONGLONG_MAX to for invalid pfn
>   add ARM crashdump support
> 
>  Makefile       |    4 +-
>  arm.c          |  200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  makedumpfile.c |    7 +-
>  makedumpfile.h |   43 ++++++++++++-
>  4 files changed, 247 insertions(+), 7 deletions(-)
>  create mode 100644 arm.c
> 
> 
> _______________________________________________
> kexec mailing list
> kexec at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] add ARM crashdump support
  2010-06-22  6:59 ` [PATCH 3/3] add ARM crashdump support Mika Westerberg
@ 2010-06-24  7:33   ` Masayuki Igawa
  2010-06-24  8:19     ` Mika Westerberg
  0 siblings, 1 reply; 11+ messages in thread
From: Masayuki Igawa @ 2010-06-24  7:33 UTC (permalink / raw)
  To: linux-arm-kernel

Hi, Mika.

On Tue, 22 Jun 2010 09:59:12 +0300, Mika Westerberg wrote:
> This patch adds support for processing ARM kernel crashdumps as well.
> 
> Signed-off-by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
> ---
>  Makefile       |    4 +-
>  arm.c          |  200 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  makedumpfile.h |   33 +++++++++
>  3 files changed, 235 insertions(+), 2 deletions(-)
>  create mode 100644 arm.c
> 
> diff --git a/Makefile b/Makefile
> index 4a8a060..3d2ee34 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -23,8 +23,8 @@ CFLAGS_ARCH += -m64
>  endif
>  
>  SRC	= makedumpfile.c makedumpfile.h diskdump_mod.h
> -SRC_ARCH = x86.c x86_64.c ia64.c ppc64.c
> -OBJ_ARCH = x86.o x86_64.o ia64.o ppc64.o
> +SRC_ARCH = arm.c x86.c x86_64.c ia64.c ppc64.c
> +OBJ_ARCH = arm.o x86.o x86_64.o ia64.o ppc64.o
>  
>  all: makedumpfile
>  
> diff --git a/arm.c b/arm.c
> new file mode 100644
> index 0000000..5acad78
> --- /dev/null
> +++ b/arm.c
> @@ -0,0 +1,200 @@
> +/*
> + * arm.c
> + *
> + * Created by: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
> + * Copyright (C) 2010 Nokia Corporation
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License as published by
> + * the Free Software Foundation; either version 2 of the License, or
> + * (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +#ifdef __arm__
> +
> +#include "makedumpfile.h"
> +
> +#define PMD_TYPE_MASK	3
> +#define PMD_TYPE_SECT	2
> +#define PMD_TYPE_TABLE	1
> +
> +#define pgd_index(vaddr) ((vaddr) >> PGDIR_SHIFT)
> +#define pte_index(vaddr) ((vaddr >> PAGESHIFT()) & (PTRS_PER_PTE - 1))
> +
> +#define pgd_offset(pgdir, vaddr) \
> +	((pgdir) + pgd_index(vaddr) * 2 * sizeof(unsigned long))
> +#define pmd_offset(dir, vaddr) (dir)
> +#define pte_offset(pmd, vaddr) \
> +	(pmd_page_vaddr(pmd) + pte_index(vaddr) * sizeof(unsigned long))
> +
> +/*
> + * These only work for kernel directly mapped addresses.
> + */
> +#define __va(paddr) ((paddr) - info->phys_base + info->page_offset)
> +#define __pa(vaddr) ((vaddr) - info->page_offset + info->phys_base)
> +
> +static inline unsigned long
> +pmd_page_vaddr(unsigned long pmd)
> +{
> +	unsigned long ptr;
> +
> +	ptr = pmd & ~(PTRS_PER_PTE * sizeof(void *) - 1);
> +	ptr += PTRS_PER_PTE * sizeof(void *);
> +
> +	return __va(ptr);
> +}
> +
> +int
> +get_phys_base_arm(void)
> +{
> +	unsigned long phys_base = ULONG_MAX;
> +	int i;
> +
> +	/*
> +	 * We resolve phys_base from PT_LOAD segments. LMA contains physical
> +	 * address of the segment, and we use the first one.
> +	 */
> +	for (i = 0; i < info->num_load_memory; i++) {
> +		const struct pt_load_segment *pls = &info->pt_load_segments[i];
> +
> +		if (pls->phys_start < phys_base)
> +			phys_base = pls->phys_start;
> +	}
> +
> +	if (phys_base == ULONG_MAX) {
> +		ERRMSG("Can't determine phys_base.\n");
> +		return FALSE;
> +	}
> +
> +	info->phys_base = phys_base;
> +	DEBUG_MSG("phys_base    : %lx\n", phys_base);
> +
> +	return TRUE;
> +}
> +
> +int
> +get_machdep_info_arm(void)
> +{
> +	unsigned long vmlist, vmalloc_start;
> +
> +	info->page_offset = __PAGE_OFFSET;
> +	info->max_physmem_bits = _MAX_PHYSMEM_BITS;
> +	info->kernel_start = SYMBOL(_stext);
> +	info->section_size_bits = _SECTION_SIZE_BITS;
> +
> +	/*
> +	 * For the compatibility, makedumpfile should run without the symbol
> +	 * vmlist and the offset of vm_struct.addr if they are not necessary.
> +	 */
> +	if ((SYMBOL(vmlist) == NOT_FOUND_SYMBOL) ||
> +		OFFSET(vm_struct.addr) == NOT_FOUND_STRUCTURE) {
> +		return TRUE;
> +	}
> +
> +	if (!readmem(VADDR, SYMBOL(vmlist), &vmlist, sizeof(vmlist))) {
> +		ERRMSG("Can't get vmlist.\n");
> +		return FALSE;
> +	}
> +	if (!readmem(VADDR, vmlist + OFFSET(vm_struct.addr), &vmalloc_start,
> +		     sizeof(vmalloc_start))) {
> +		ERRMSG("Can't get vmalloc_start.\n");
> +		return FALSE;
> +	}
> +
> +	info->vmalloc_start = vmalloc_start;
> +
> +	DEBUG_MSG("page_offset  : %lx\n", info->page_offset);
> +	DEBUG_MSG("kernel_start : %lx\n", info->kernel_start);
> +	DEBUG_MSG("vmalloc_start: %lx\n", vmalloc_start);
> +
> +	return TRUE;
> +}
> +
> +static int
> +is_vmalloc_addr_arm(unsigned long vaddr)
> +{
> +	return (info->vmalloc_start && vaddr >= info->vmalloc_start);
> +}
> +
> +/*
> + * vtop_arm() - translate arbitrary virtual address to physical
> + * @vaddr: virtual address to translate
> + *
> + * Function translates @vaddr into physical address using page tables. This
> + * address can be any virtual address. Returns physical address of the
> + * corresponding virtual address or %NOT_PADDR when there is no translation.
> + */
> +static unsigned long long
> +vtop_arm(unsigned long vaddr)
> +{
> +	unsigned long long paddr = NOT_PADDR;
> +	unsigned long ptr, pgd, pte, pmd;
> +
> +	if (SYMBOL(swapper_pg_dir) == NOT_FOUND_SYMBOL) {
> +		ERRMSG("Can't get the symbol of swapper_pg_dir.\n");
> +		return NOT_PADDR;
> +	}
> +
> +	ptr = pgd_offset(SYMBOL(swapper_pg_dir), vaddr);
> +	if (!readmem(VADDR, ptr, &pgd, sizeof(pmd))) {
> +		ERRMSG("Can't read pgd\n");
> +		return NOT_PADDR;
> +	}
> +
> +	if (info->vaddr_for_vtop == vaddr)
> +		MSG("  PGD : %08lx => %08lx\n", ptr, pgd);
> +
> +	pmd = pmd_offset(pgd, vaddr);
> +
> +	switch (pmd & PMD_TYPE_MASK) {
> +	case PMD_TYPE_TABLE: {
> +		/* 4k small page */
> +		ptr = pte_offset(pmd, vaddr);
> +		if (!readmem(VADDR, ptr, &pte, sizeof(pte))) {
> +			ERRMSG("Can't read pte\n");
> +			return NOT_PADDR;
> +		}
> +
> +		if (info->vaddr_for_vtop == vaddr)
> +			MSG("  PTE : %08lx => %08lx\n", ptr, pte);
> +
> +		if (!(pte & _PAGE_PRESENT)) {
> +			ERRMSG("Can't get a valid pte.\n");
> +			return NOT_PADDR;
> +		}
> +
> +		paddr = PAGEBASE(pte) + (vaddr & (PAGESIZE() - 1));
> +		break;
> +	}
> +
> +	case PMD_TYPE_SECT:
> +		/* 1MB section */
> +		pte = pmd & PMD_MASK;
> +		paddr = pte + (vaddr & (PMD_SIZE - 1));
> +		break;
> +	}
> +
> +	return paddr;
> +}
> +
> +unsigned long long
> +vaddr_to_paddr_arm(unsigned long vaddr)
> +{
> +	unsigned long long paddr;
> +
> +	if ((paddr = vaddr_to_paddr_general(vaddr)) != NOT_PADDR)
> +		return paddr;

Here is a checkpatche.pl's error.
====
ERROR: do not use assignment in if condition
#303: FILE: arm.c:189:
+       if ((paddr = vaddr_to_paddr_general(vaddr)) != NOT_PADDR)

total: 1 errors, 0 warnings, 261 lines checked
====

How about is this?
====
+unsigned long long
+vaddr_to_paddr_arm(unsigned long vaddr)
+{
+	unsigned long long paddr = vaddr_to_paddr_general(vaddr);
+
+	if (paddr != NOT_PADDR)
+		return paddr;
====

BTW, I'm testing these patches for x86/x86_64 arch now.
I'll merge these patches after my testing.

But I cannot test for ARM because have no test machines of ARM.

Thanks.
-- Masayuki Igawa


> +
> +	if (is_vmalloc_addr_arm(vaddr))
> +		paddr = vtop_arm(vaddr);
> +	else
> +		paddr = __pa(vaddr);
> +
> +	return paddr;
> +}
> +
> +#endif /* __arm__ */
> diff --git a/makedumpfile.h b/makedumpfile.h
> index 2717d81..8a74b34 100644
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -506,6 +506,24 @@ do { \
>  #define VMEMMAP_START		(info->vmemmap_start)
>  #define VMEMMAP_END		(info->vmemmap_end)
>  
> +#ifdef __arm__
> +#define __PAGE_OFFSET		(0xc0000000)
> +#define KVBASE_MASK		(0xffff)
> +#define KVBASE			(SYMBOL(_stext) & ~KVBASE_MASK)
> +#define _SECTION_SIZE_BITS	(28)
> +#define _MAX_PHYSMEM_BITS	(32)
> +#define ARCH_PFN_OFFSET		(info->phys_base >> PAGESHIFT())
> +
> +#define PTRS_PER_PTE		(512)
> +#define PGDIR_SHIFT		(21)
> +#define PMD_SHIFT		(21)
> +#define PMD_SIZE		(1UL << PMD_SHIFT)
> +#define PMD_MASK		(~(PMD_SIZE - 1))
> +
> +#define _PAGE_PRESENT		(1 << 0)
> +
> +#endif /* arm */
> +
>  #ifdef __x86__
>  #define __PAGE_OFFSET		(0xc0000000)
>  #define __VMALLOC_RESERVE       (128 << 20)
> @@ -653,6 +671,16 @@ do { \
>  /*
>   * The function of dependence on machine
>   */
> +#ifdef __arm__
> +int get_phys_base_arm(void);
> +int get_machdep_info_arm(void);
> +unsigned long long vaddr_to_paddr_arm(unsigned long vaddr);
> +#define get_phys_base()		get_phys_base_arm()
> +#define get_machdep_info()	get_machdep_info_arm()
> +#define get_versiondep_info()	TRUE
> +#define vaddr_to_paddr(X)	vaddr_to_paddr_arm(X)
> +#endif /* arm */
> +
>  #ifdef __x86__
>  int get_machdep_info_x86(void);
>  int get_versiondep_info_x86(void);
> @@ -1148,6 +1176,11 @@ struct domain_list {
>  #define PAGES_PER_MAPWORD 	(sizeof(unsigned long) * 8)
>  #define MFNS_PER_FRAME		(info->page_size / sizeof(unsigned long))
>  
> +#ifdef __arm__
> +#define kvtop_xen(X)	FALSE
> +#define get_xen_info_arch(X) FALSE
> +#endif	/* arm */
> +
>  #ifdef __x86__
>  #define HYPERVISOR_VIRT_START_PAE	(0xF5800000UL)
>  #define HYPERVISOR_VIRT_START		(0xFC000000UL)
> -- 
> 1.5.6.5
> 
> 
> _______________________________________________
> kexec mailing list
> kexec at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] add ARM crashdump support
  2010-06-24  7:33   ` Masayuki Igawa
@ 2010-06-24  8:19     ` Mika Westerberg
  2010-06-24 23:31       ` Masayuki Igawa
  0 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2010-06-24  8:19 UTC (permalink / raw)
  To: linux-arm-kernel

On Thu, Jun 24, 2010 at 09:33:56AM +0200, ext Masayuki Igawa wrote:
> Hi, Mika.

(...)

> > +unsigned long long
> > +vaddr_to_paddr_arm(unsigned long vaddr)
> > +{
> > +	unsigned long long paddr;
> > +
> > +	if ((paddr = vaddr_to_paddr_general(vaddr)) != NOT_PADDR)
> > +		return paddr;
> 
> Here is a checkpatche.pl's error.
> ====
> ERROR: do not use assignment in if condition
> #303: FILE: arm.c:189:
> +       if ((paddr = vaddr_to_paddr_general(vaddr)) != NOT_PADDR)
> 
> total: 1 errors, 0 warnings, 261 lines checked
> ====

Ah, didn't notice that. Thanks.

> How about is this?
> ====
> +unsigned long long
> +vaddr_to_paddr_arm(unsigned long vaddr)
> +{
> +	unsigned long long paddr = vaddr_to_paddr_general(vaddr);
> +
> +	if (paddr != NOT_PADDR)
> +		return paddr;
> ====

Yeah, looks OK to me.

Do you want me to send a revisited version of the patches or do you change that
yourself?

> BTW, I'm testing these patches for x86/x86_64 arch now.
> I'll merge these patches after my testing.

Cool, thanks.

> But I cannot test for ARM because have no test machines of ARM.

Well I can do the testing for ARM (unless someone else, who is using ARM kdump
currently, wants to test this). If the above is the only change it should still
work.

Thanks,
MW

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] add ARM crashdump support
  2010-06-24  8:19     ` Mika Westerberg
@ 2010-06-24 23:31       ` Masayuki Igawa
  2010-06-25  7:05         ` Masayuki Igawa
  0 siblings, 1 reply; 11+ messages in thread
From: Masayuki Igawa @ 2010-06-24 23:31 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

From: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Date: Thu, 24 Jun 2010 11:19:15 +0300
> On Thu, Jun 24, 2010 at 09:33:56AM +0200, ext Masayuki Igawa wrote:
>> Hi, Mika.
> 
> (...)

>> How about is this?
>> ====
>> +unsigned long long
>> +vaddr_to_paddr_arm(unsigned long vaddr)
>> +{
>> +	unsigned long long paddr = vaddr_to_paddr_general(vaddr);
>> +
>> +	if (paddr != NOT_PADDR)
>> +		return paddr;
>> ====
> 
> Yeah, looks OK to me.
> 
> Do you want me to send a revisited version of the patches or do you change that
> yourself?

I'll change that myself.

> 
>> BTW, I'm testing these patches for x86/x86_64 arch now.
>> I'll merge these patches after my testing.
> 
> Cool, thanks.
> 
>> But I cannot test for ARM because have no test machines of ARM.
> 
> Well I can do the testing for ARM (unless someone else, who is using ARM kdump
> currently, wants to test this). If the above is the only change it should still
> work.

OK. I'll merge and push these patches (including this change).
And I'd like you to do the testing for ARM after that.

Thanks,
-- Masayuki Igawa

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] add ARM crashdump support
  2010-06-24 23:31       ` Masayuki Igawa
@ 2010-06-25  7:05         ` Masayuki Igawa
  2010-06-28  5:14           ` Mika Westerberg
  0 siblings, 1 reply; 11+ messages in thread
From: Masayuki Igawa @ 2010-06-25  7:05 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

From: Masayuki Igawa <igawa@mxs.nes.nec.co.jp>
Subject: Re: [PATCH 3/3] add ARM crashdump support
Date: Fri, 25 Jun 2010 08:31:33 +0900 (JST)
> From: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
> Date: Thu, 24 Jun 2010 11:19:15 +0300
>> On Thu, Jun 24, 2010 at 09:33:56AM +0200, ext Masayuki Igawa wrote:
>>> Hi, Mika.
>> 
>> (...)
> 
>>> How about is this?
>>> ====
>>> +unsigned long long
>>> +vaddr_to_paddr_arm(unsigned long vaddr)
>>> +{
>>> +	unsigned long long paddr = vaddr_to_paddr_general(vaddr);
>>> +
>>> +	if (paddr != NOT_PADDR)
>>> +		return paddr;
>>> ====
>> 
>> Yeah, looks OK to me.
>> 
>> Do you want me to send a revisited version of the patches or do you change that
>> yourself?
> 
> I'll change that myself.
> 
>> 
>>> BTW, I'm testing these patches for x86/x86_64 arch now.
>>> I'll merge these patches after my testing.
>> 
>> Cool, thanks.

I've finished my tests(x86/x86_64). No problems were found.
So I've merged and pushed these patches.

Thanks,
-- Masayuki Igawa


>> 
>>> But I cannot test for ARM because have no test machines of ARM.
>> 
>> Well I can do the testing for ARM (unless someone else, who is using ARM kdump
>> currently, wants to test this). If the above is the only change it should still
>> work.
> 
> OK. I'll merge and push these patches (including this change).
> And I'd like you to do the testing for ARM after that.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] add ARM crashdump support
  2010-06-25  7:05         ` Masayuki Igawa
@ 2010-06-28  5:14           ` Mika Westerberg
  2010-06-28  5:25             ` Masayuki Igawa
  0 siblings, 1 reply; 11+ messages in thread
From: Mika Westerberg @ 2010-06-28  5:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Fri, Jun 25, 2010 at 09:05:44AM +0200, ext Masayuki Igawa wrote:
> 
> I've finished my tests(x86/x86_64). No problems were found.
> So I've merged and pushed these patches.

Thanks!

I just pulled your latest tree and tested on ARM -> works well.

Regards,
MW

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 3/3] add ARM crashdump support
  2010-06-28  5:14           ` Mika Westerberg
@ 2010-06-28  5:25             ` Masayuki Igawa
  0 siblings, 0 replies; 11+ messages in thread
From: Masayuki Igawa @ 2010-06-28  5:25 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

From: Mika Westerberg <ext-mika.1.westerberg@nokia.com>
Subject: Re: [PATCH 3/3] add ARM crashdump support
Date: Mon, 28 Jun 2010 08:14:46 +0300
> I just pulled your latest tree and tested on ARM -> works well.

Thank you for your testing!
I'm glad to hear that.

Regards,
-- Masayuki Igawa

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2010-06-28  5:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-22  6:59 [PATCH 0/3] makedumpfile: add support for ARM crashdumps Mika Westerberg
2010-06-22  6:59 ` [PATCH 1/3] use ARCH_PFN_OFFSET for pfn_to_paddr/paddr_to_pfn translations Mika Westerberg
2010-06-22  6:59 ` [PATCH 2/3] page_to_pfn(): use ULONGLONG_MAX to for invalid pfn Mika Westerberg
2010-06-22  6:59 ` [PATCH 3/3] add ARM crashdump support Mika Westerberg
2010-06-24  7:33   ` Masayuki Igawa
2010-06-24  8:19     ` Mika Westerberg
2010-06-24 23:31       ` Masayuki Igawa
2010-06-25  7:05         ` Masayuki Igawa
2010-06-28  5:14           ` Mika Westerberg
2010-06-28  5:25             ` Masayuki Igawa
2010-06-22  7:40 ` [PATCH 0/3] makedumpfile: add support for ARM crashdumps Masayuki Igawa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).