All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/8] makedumpfile: Xen4 support for SLES11
@ 2012-07-23 11:32 ptesarik
  2012-07-23 11:32 ` [PATCH 1/8] Read the Xen crash ELF note into memory at startup ptesarik
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

This patchset was created to allow using makedumpfile for Dom0 dumps in SLES11
SP1 and SP2. Most of the patches account for changes to the Xen hypervisor,
except the last one, which reflects that the "max_pfn" symbol is not exported
by the SLES kernel.

Petr Tesarik
SUSE Linux


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 1/8] Read the Xen crash ELF note into memory at startup
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-07-23 11:32 ` [PATCH 2/8] Split early Xen setup from late Xen setup ptesarik
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-crash_xen_info_t.patch --]
[-- Type: text/plain, Size: 6492 bytes --]

Instead of seeking individual fields inside the ELF note, copy the
corresponding struct type from the Xen sources, so people can understand
why the code does what it does.

This is mainly a cleanup patch to improve maintainability, but it also
simplifies reusing the crash note data from other places.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 elf_info.c     |   45 +++++++++++++++++++++++++++++----------------
 elf_info.h     |   38 +++++++++++++++++++++++++++++++++++++-
 makedumpfile.c |   28 ++++++++--------------------
 makedumpfile.h |    2 --
 4 files changed, 74 insertions(+), 39 deletions(-)

--- a/elf_info.c
+++ b/elf_info.c
@@ -86,9 +86,8 @@ static unsigned long		size_eraseinfo;
 /*
  * Xen information:
  */
-static off_t			offset_xen_crash_info;
+static void			*xen_crash_info;
 static unsigned long		size_xen_crash_info;
-static unsigned long		xen_p2m_mfn;
 
 
 /*
@@ -292,8 +291,7 @@ static int
 get_pt_note_info(void)
 {
 	int n_type, size_desc;
-	unsigned long p2m_mfn;
-	off_t offset, offset_desc, off_p2m = 0;
+	off_t offset, offset_desc;
 	char buf[VMCOREINFO_XEN_NOTE_NAME_BYTES];
 	char note[MAX_SIZE_NHDR];
 
@@ -346,23 +344,25 @@ get_pt_note_info(void)
 		 */
 		} else if (n_type == XEN_ELFNOTE_CRASH_INFO) {
 			flags_memory |= MEMORY_XEN;
-			offset_xen_crash_info = offset_desc;
 			size_xen_crash_info   = size_desc;
+			xen_crash_info = malloc(size_desc);
+			if (!xen_crash_info) {
+				ERRMSG("Can't allocate note (%d bytes). %s\n",
+				    size_desc, strerror(errno));
+				return FALSE;
+			}
 
-			off_p2m = offset + offset_next_note(note)
-					 - sizeof(p2m_mfn);
-			if (lseek(fd_memory, off_p2m, SEEK_SET) < 0){
+			if (lseek(fd_memory, offset_desc, SEEK_SET) < 0) {
 				ERRMSG("Can't seek the dump memory(%s). %s\n",
 				    name_memory, strerror(errno));
 				return FALSE;
 			}
-			if (read(fd_memory, &p2m_mfn, sizeof(p2m_mfn))
-			     != sizeof(p2m_mfn)) {
+			if (read(fd_memory, xen_crash_info, size_desc)
+			    != size_desc) {
 				ERRMSG("Can't read the dump memory(%s). %s\n",
 				    name_memory, strerror(errno));
 				return FALSE;
 			}
-			xen_p2m_mfn = p2m_mfn;
 
 		/*
 		 * Check whether a source dumpfile contains eraseinfo.
@@ -826,13 +826,12 @@ get_vmcoreinfo_xen(off_t *offset, unsign
 		*size   = size_vmcoreinfo_xen;
 }
 
-void
-get_xen_crash_info(off_t *offset, unsigned long *size)
+void *
+get_xen_crash_info(unsigned long *size)
 {
-	if (offset)
-		*offset = offset_xen_crash_info;
 	if (size)
 		*size   = size_xen_crash_info;
+	return xen_crash_info;
 }
 
 int
@@ -859,9 +858,23 @@ set_eraseinfo(off_t offset, unsigned lon
 	size_eraseinfo   = size;
 }
 
+#if defined(__ia64__)
+#define p2m_mfn dom0_mm_pgd_mfn
+#else
+#define p2m_mfn dom0_pfn_to_mfn_frame_list_list
+#endif
+
 unsigned long
 get_xen_p2m_mfn(void)
 {
-	return xen_p2m_mfn;
+#if defined(__x86__) || defined(__x86_64__) || defined(__ia64__)
+	if (xen_crash_info) {
+		if (size_xen_crash_info >= sizeof(crash_xen_info_v2_t))
+			return ((crash_xen_info_v2_t*)xen_crash_info)->p2m_mfn;
+		if (size_xen_crash_info >= sizeof(crash_xen_info_t))
+			return ((crash_xen_info_t*)xen_crash_info)->p2m_mfn;
+	}
+#endif
+	return 0;
 }
 
--- a/elf_info.h
+++ b/elf_info.h
@@ -24,6 +24,42 @@
 
 #define MAX_SIZE_NHDR	MAX(sizeof(Elf64_Nhdr), sizeof(Elf32_Nhdr))
 
+typedef struct {
+	unsigned long xen_major_version;
+	unsigned long xen_minor_version;
+	unsigned long xen_extra_version;
+	unsigned long xen_changeset;
+	unsigned long xen_compiler;
+	unsigned long xen_compile_date;
+	unsigned long xen_compile_time;
+	unsigned long tainted;
+} crash_xen_info_common_t;
+
+typedef struct {
+	crash_xen_info_common_t c;
+#if defined(__x86__) || defined(__x86_64__)
+	/* added by changeset 2b43fb3afb3e: */
+	unsigned long dom0_pfn_to_mfn_frame_list_list;
+#endif
+#if defined(__ia64__)
+	/* added by changeset d7c3b12014b3: */
+	unsigned long dom0_mm_pgd_mfn;
+#endif
+} crash_xen_info_t;
+
+/* changeset 439a3e9459f2 added xen_phys_start
+ * to the middle of the struct... */
+typedef struct {
+	crash_xen_info_common_t c;
+#if defined(__x86__) || defined(__x86_64__)
+	unsigned long xen_phys_start;
+	unsigned long dom0_pfn_to_mfn_frame_list_list;
+#endif
+#if defined(__ia64__)
+	unsigned long dom0_mm_pgd_mfn;
+#endif
+} crash_xen_info_v2_t;
+
 
 off_t paddr_to_offset(unsigned long long paddr);
 off_t paddr_to_offset2(unsigned long long paddr, off_t hint);
@@ -62,7 +98,7 @@ void get_vmcoreinfo(off_t *offset, unsig
 
 int has_vmcoreinfo_xen(void);
 void get_vmcoreinfo_xen(off_t *offset, unsigned long *size);
-void get_xen_crash_info(off_t *offset, unsigned long *size);
+void *get_xen_crash_info(unsigned long *size);
 
 int has_eraseinfo(void);
 void get_eraseinfo(off_t *offset, unsigned long *size);
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5315,30 +5315,18 @@ get_structure_info_xen(void)
 int
 get_xen_phys_start(void)
 {
-	off_t offset, offset_xen_crash_info;
-	unsigned long xen_phys_start, size_xen_crash_info;
-	const off_t failed = (off_t)-1;
+	unsigned long size_xen_crash_info;
+	crash_xen_info_v2_t *xen_crash_info;
 
 	if (info->xen_phys_start)
 		return TRUE;
 
-	get_xen_crash_info(&offset_xen_crash_info, &size_xen_crash_info);
-	if (size_xen_crash_info >= SIZE_XEN_CRASH_INFO_V2) {
-		offset = offset_xen_crash_info + size_xen_crash_info
-			 - sizeof(unsigned long) * 2;
-		if (lseek(info->fd_memory, offset, SEEK_SET) == failed) {
-			ERRMSG("Can't seek the dump memory(%s). %s\n",
-			    info->name_memory, strerror(errno));
-			return FALSE;
-		}
-		if (read(info->fd_memory, &xen_phys_start, sizeof(unsigned long))
-		    != sizeof(unsigned long)) {
-			ERRMSG("Can't read the dump memory(%s). %s\n",
-			    info->name_memory, strerror(errno));
-			return FALSE;
-		}
-		info->xen_phys_start = xen_phys_start;
-	}
+#if defined(__x86__) || defined(__x86_64__)
+	xen_crash_info = get_xen_crash_info(&size_xen_crash_info);
+	if (xen_crash_info &&
+	    size_xen_crash_info >= sizeof(crash_xen_info_v2_t))
+		info->xen_phys_start = xen_crash_info->xen_phys_start;
+#endif
 
 	return TRUE;
 }
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -416,8 +416,6 @@ do { \
 #define SIZE_BUF_STDIN	(4096)
 #define STRLEN_OSRELEASE (65)	/* same length as diskdump.h */
 
-#define SIZE_XEN_CRASH_INFO_V2	(sizeof(unsigned long) * 10)
-
 /*
  * The value of dependence on machine
  */



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 2/8] Split early Xen setup from late Xen setup
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
  2012-07-23 11:32 ` [PATCH 1/8] Read the Xen crash ELF note into memory at startup ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-07-23 11:32 ` [PATCH 3/8] Support Xen4 virtuall address space layout ptesarik
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-split-xen-setup.patch --]
[-- Type: text/plain, Size: 6727 bytes --]

Previously, get_xen_info_arch() was called after initializing the generic Xen
variables. This is necessary, because the arch-specific code translates domain
addresses to pickled domain IDs, and the domain list is initialized by the
generic code.

Now, Xen4 on x86_64 changed the virtual memory layout, and this initialization
should ideally be done in the arch-specific code. Unfortunately, the generic
code must know the virtual address space to perform readmem of type XEN_VADDR,
so there is no working ordering, and instead we must provide hooks for "early"
arch-specific initialization to set up data needed by the generic code, and
"late" arch-specific initialization to do stuff that depends on data set by
the generic code (currently only the domain_list).

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 arch/ia64.c    |   14 +++++++++++---
 arch/x86.c     |   24 ++++++++++++++++++++++--
 arch/x86_64.c  |   24 ++++++++++++++++++++++--
 makedumpfile.c |   27 ++++++---------------------
 makedumpfile.h |    9 +++++++++
 5 files changed, 70 insertions(+), 28 deletions(-)

--- a/arch/x86.c
+++ b/arch/x86.c
@@ -291,11 +291,24 @@ kvtop_xen_x86(unsigned long kvaddr)
 	return entry;
 }
 
-int get_xen_info_x86(void)
+int get_xen_basic_info_x86(void)
 {
 	unsigned long frame_table_vaddr;
 	unsigned long xen_end;
-	int i;
+
+	if (!info->xen_phys_start) {
+		unsigned long size_xen_crash_info;
+		crash_xen_info_v2_t *xen_crash_info;
+
+		xen_crash_info = get_xen_crash_info(&size_xen_crash_info);
+		if (!xen_crash_info ||
+		    size_xen_crash_info < sizeof(crash_xen_info_v2_t)) {
+			ERRMSG("Can't get Xen physical start address.\n"
+			       "Please use the --xen_phys_start option.");
+			return FALSE;
+		}
+		info->xen_phys_start = xen_crash_info->xen_phys_start;
+	}
 
 	if (SYMBOL(pgd_l2) == NOT_FOUND_SYMBOL &&
 	    SYMBOL(pgd_l3) == NOT_FOUND_SYMBOL) {
@@ -331,6 +344,13 @@ int get_xen_info_x86(void)
 	info->xen_heap_start = 0;
 	info->xen_heap_end   = paddr_to_pfn(xen_end);
 
+	return TRUE;
+}
+
+int get_xen_info_x86(void)
+{
+	int i;
+
 	/*
 	 * pickled_id == domain addr for x86
 	 */
--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -338,11 +338,24 @@ kvtop_xen_x86_64(unsigned long kvaddr)
 	return entry;
 }
 
-int get_xen_info_x86_64(void)
+int get_xen_basic_info_x86_64(void)
 {
 	unsigned long frame_table_vaddr;
 	unsigned long xen_end;
-	int i;
+
+	if (!info->xen_phys_start) {
+		unsigned long size_xen_crash_info;
+		crash_xen_info_v2_t *xen_crash_info;
+
+		xen_crash_info = get_xen_crash_info(&size_xen_crash_info);
+		if (!xen_crash_info ||
+		    size_xen_crash_info < sizeof(crash_xen_info_v2_t)) {
+			ERRMSG("Can't get Xen physical start address.\n"
+			       "Please use the --xen_phys_start option.");
+			return FALSE;
+		}
+		info->xen_phys_start = xen_crash_info->xen_phys_start;
+	}
 
 	if (SYMBOL(pgd_l4) == NOT_FOUND_SYMBOL) {
 		ERRMSG("Can't get pml4.\n");
@@ -372,6 +385,13 @@ int get_xen_info_x86_64(void)
 	info->xen_heap_start = 0;
 	info->xen_heap_end   = paddr_to_pfn(xen_end);
 
+	return TRUE;
+}
+
+int get_xen_info_x86_64(void)
+{
+	int i;
+
 	/*
 	 * pickled_id == domain addr for x86_64
 	 */
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5313,31 +5313,18 @@ get_structure_info_xen(void)
 }
 
 int
-get_xen_phys_start(void)
-{
-	unsigned long size_xen_crash_info;
-	crash_xen_info_v2_t *xen_crash_info;
-
-	if (info->xen_phys_start)
-		return TRUE;
-
-#if defined(__x86__) || defined(__x86_64__)
-	xen_crash_info = get_xen_crash_info(&size_xen_crash_info);
-	if (xen_crash_info &&
-	    size_xen_crash_info >= sizeof(crash_xen_info_v2_t))
-		info->xen_phys_start = xen_crash_info->xen_phys_start;
-#endif
-
-	return TRUE;
-}
-
-int
 get_xen_info(void)
 {
 	unsigned long domain;
 	unsigned int domain_id;
 	int num_domain;
 
+	/*
+	 * Get architecture specific basic data
+	 */
+	if (!get_xen_basic_info_arch())
+		return FALSE;
+
 	if (SYMBOL(alloc_bitmap) == NOT_FOUND_SYMBOL) {
 		ERRMSG("Can't get the symbol of alloc_bitmap.\n");
 		return FALSE;
@@ -5816,8 +5803,6 @@ initial_xen(void)
 		if (!read_vmcoreinfo_from_vmcore(offset, size, TRUE))
 			return FALSE;
 	}
-	if (!get_xen_phys_start())
-		return FALSE;
 	if (!get_xen_info())
 		return FALSE;
 
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -1274,6 +1274,7 @@ struct domain_list {
 
 #ifdef __arm__
 #define kvtop_xen(X)	FALSE
+#define get_xen_basic_info_arch(X) FALSE
 #define get_xen_info_arch(X) FALSE
 #endif	/* arm */
 
@@ -1292,6 +1293,8 @@ struct domain_list {
 unsigned long long kvtop_xen_x86(unsigned long kvaddr);
 #define kvtop_xen(X)	kvtop_xen_x86(X)
 
+int get_xen_basic_info_x86(void);
+#define get_xen_basic_info_arch(X) get_xen_basic_info_x86(X)
 int get_xen_info_x86(void);
 #define get_xen_info_arch(X) get_xen_info_x86(X)
 
@@ -1319,6 +1322,8 @@ int get_xen_info_x86(void);
 unsigned long long kvtop_xen_x86_64(unsigned long kvaddr);
 #define kvtop_xen(X)	kvtop_xen_x86_64(X)
 
+int get_xen_basic_info_x86_64(void);
+#define get_xen_basic_info_arch(X) get_xen_basic_info_x86_64(X)
 int get_xen_info_x86_64(void);
 #define get_xen_info_arch(X) get_xen_info_x86_64(X)
 
@@ -1354,6 +1359,8 @@ int get_xen_info_x86_64(void);
 unsigned long long kvtop_xen_ia64(unsigned long kvaddr);
 #define kvtop_xen(X)	kvtop_xen_ia64(X)
 
+int get_xen_basic_info_ia64(void);
+#define get_xen_basic_info_arch(X) get_xen_basic_info_ia64(X)
 int get_xen_info_ia64(void);
 #define get_xen_info_arch(X) get_xen_info_ia64(X)
 
@@ -1361,11 +1368,13 @@ int get_xen_info_ia64(void);
 
 #if defined(__powerpc64__) || defined(__powerpc32__) /* powerpcXX */
 #define kvtop_xen(X)	FALSE
+#define get_xen_basic_info_arch(X) FALSE
 #define get_xen_info_arch(X) FALSE
 #endif	/* powerpcXX */
 
 #ifdef __s390x__ /* s390x */
 #define kvtop_xen(X)	FALSE
+#define get_xen_basic_info_arch(X) FALSE
 #define get_xen_info_arch(X) FALSE
 #endif	/* s390x */
 
--- a/arch/ia64.c
+++ b/arch/ia64.c
@@ -329,10 +329,9 @@ kvtop_xen_ia64(unsigned long kvaddr)
 }
 
 int
-get_xen_info_ia64(void)
+get_xen_basic_info_ia64(void)
 {
-	unsigned long xen_start, xen_end, xen_heap_start;
-	int i;
+	unsigned long xen_start, xen_end;
 
 	info->frame_table_vaddr = VIRT_FRAME_TABLE_ADDR; /* "frame_table" is same value */
 
@@ -357,6 +356,15 @@ get_xen_info_ia64(void)
 	info->xen_heap_start = paddr_to_pfn(xen_start);
 	info->xen_heap_end   = paddr_to_pfn(xen_end);
 
+	return TRUE;
+}
+
+int
+get_xen_info_ia64(void)
+{
+	unsigned long xen_heap_start;
+	int i;
+
 	if (SYMBOL(xen_heap_start) == NOT_FOUND_SYMBOL) {
 		ERRMSG("Can't get the symbol of xen_heap_start.\n");
 		return FALSE;



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 3/8] Support Xen4 virtuall address space layout
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
  2012-07-23 11:32 ` [PATCH 1/8] Read the Xen crash ELF note into memory at startup ptesarik
  2012-07-23 11:32 ` [PATCH 2/8] Split early Xen setup from late Xen setup ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-07-23 11:32 ` [PATCH 4/8] Fix domain pickled_id computation for xen-3.4+ ptesarik
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-xen4-virt-space.patch --]
[-- Type: text/plain, Size: 7809 bytes --]

Starting with xen-4.0.0, the virtual memory layout on x86_64 has changed.
To support both Xen3 and Xen4, some of the former constants have to be
converted to a variable.

Note the addition of XEN_VIRT_END - even though the location of Xen code
and data has changed, its size has stayed at 1G, so we can compute the end
of this portion from the start point with the same formula for both versions.

A side-by-side comparison of the virtual address space for Xen3 and Xen4:

      Range       |             Xen3             |             Xen4
------------------+------------------------------+-----------------------------
0xffff800000000000|[256G] Read-only machine-to-phys translation table
0xffff803fffffffff|       (GUEST ACCESSIBLE)
------------------+------------------------------------------------------------
0xffff804000000000|[256G] Reserved for future shared info with the guest OS
0xffff807fffffffff|       (GUEST ACCESSIBLE)
------------------+------------------------------+-----------------------------
0xffff808000000000|[512G] Reserved for future use|[512G] ioremap for PCI
0xffff80ffffffffff|                              | mmconfig space
------------------+------------------------------+-----------------------------
0xffff810000000000|[512G] Guest linear page table
0xffff817fffffffff|
------------------+------------------------------------------------------------
0xffff818000000000|[512G] Shadow linear page table
0xffff81ffffffffff|
------------------+------------------------------------------------------------
0xffff820000000000|[512G] Per-domain mappings (e.g., GDT, LDT)
0xffff827fffffffff|
------------------+------------------------------------------------------------
0xffff828000000000|[16G] Machine-to-phys
0xffff8283ffffffff| translation table
------------------+------------------------------------------------------------
0xffff828400000000|[16G] Page-frame information
0xffff8287ffffffff| array
------------------+------------------------------------------------------------
0xffff828800000000|[16G] ioremap()/fixmap area
0xffff828bffffffff|
------------------+------------------------------+-----------------------------
0xffff828c00000000|[1G] Compatibility            |
0xffff828c3fffffff| machine-to-phys translation  |
                  | table                        |
------------------+------------------------------+
0xffff828c40000000|[1G] High read-only compat    |
0xffff828c7fffffff| machine-to-phys translation  |[256G] Machine-to-phys
                  | table                        |translation table
------------------+------------------------------+
0xffff828c80000000|[1G] Xen text, static data,   |
0xffff828cbfffffff| bss                          |
------------------+------------------------------+
0xffff828cc0000000|                              |
0xffff82bfffffffff|                              |
------------------+                              +-----------------------------
0xffff82c000000000|                              |[16G] ioremap()/fixmap area
0xffff82c3ffffffff|                              |
------------------+                              +-----------------------------
0xffff82c400000000|                              |[1G] Compatibility
0xffff82c43fffffff|                              | machine-to-phys translation
                  |                              | table
------------------+                              +-----------------------------
0xffff82c440000000|[461G] Reserved for future use|[1G] High read-only compat
0xffff82c47fffffff|                              | machine-to-phys translation
                  |                              | table
------------------+                              +-----------------------------
0xffff82c480000000|                              |[1G] Xen text, static data,
0xffff82c4bfffffff|                              | bss
------------------+                              +-----------------------------
0xffff82c4c0000000|                              |[197G] Reserved for future
0xffff82f5ffffffff|                              | use
------------------+                              +-----------------------------
0xffff82f600000000|                              |[40G] Page-frame information
0xffff82ffffffffff|                              | array
------------------+------------------------------+-----------------------------
0xffff830000000000|[1T] 1:1 direct mapping of all|
0xffff83ffffffffff| physical memory              |[5T] 1:1 direct mapping of
------------------+------------------------------+ all physical memory
0xffff840000000000|[4T] Reserved for future use  |
0xffff87ffffffffff|                              |
------------------+------------------------------+-----------------------------

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 arch/x86_64.c  |   22 +++++++++++++++++-----
 makedumpfile.h |   15 ++++++++++++---
 2 files changed, 29 insertions(+), 8 deletions(-)

--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -915,6 +915,10 @@ struct DumpInfo {
 	unsigned long *p2m_mfn_frame_list;
 	int	num_domain;
 	struct domain_list *domain_list;
+#if defined(__x86_64__)
+	unsigned long xen_virt_start;
+	unsigned long directmap_virt_end;
+#endif
 
 	/*
 	 * for splitting
@@ -1309,15 +1313,20 @@ int get_xen_info_x86(void);
 #define HYPERVISOR_VIRT_START (0xffff800000000000)
 #define HYPERVISOR_VIRT_END   (0xffff880000000000)
 #define DIRECTMAP_VIRT_START  (0xffff830000000000)
-#define DIRECTMAP_VIRT_END    (0xffff840000000000)
-#define XEN_VIRT_START        (0xffff828c80000000)
+#define DIRECTMAP_VIRT_END_V3 (0xffff840000000000)
+#define DIRECTMAP_VIRT_END_V4 (0xffff880000000000)
+#define DIRECTMAP_VIRT_END    (info->directmap_virt_end)
+#define XEN_VIRT_START_V3     (0xffff828c80000000)
+#define XEN_VIRT_START_V4     (0xffff82c480000000)
+#define XEN_VIRT_START        (info->xen_virt_start)
+#define XEN_VIRT_END          (XEN_VIRT_START + (1UL << 30))
 
 #define is_xen_vaddr(x) \
 	((x) >= HYPERVISOR_VIRT_START && (x) < HYPERVISOR_VIRT_END)
 #define is_direct(x) \
 	((x) >= DIRECTMAP_VIRT_START && (x) < DIRECTMAP_VIRT_END)
 #define is_xen_text(x) \
-	((x) >= XEN_VIRT_START && (x) < DIRECTMAP_VIRT_START)
+	((x) >= XEN_VIRT_START && (x) < XEN_VIRT_END)
 
 unsigned long long kvtop_xen_x86_64(unsigned long kvaddr);
 #define kvtop_xen(X)	kvtop_xen_x86_64(X)
--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -340,21 +340,33 @@ kvtop_xen_x86_64(unsigned long kvaddr)
 
 int get_xen_basic_info_x86_64(void)
 {
+	unsigned long size_xen_crash_info;
+	crash_xen_info_common_t *xen_crash_info;
+	crash_xen_info_v2_t *xen_crash_info2;
 	unsigned long frame_table_vaddr;
 	unsigned long xen_end;
 
-	if (!info->xen_phys_start) {
-		unsigned long size_xen_crash_info;
-		crash_xen_info_v2_t *xen_crash_info;
+	xen_crash_info = get_xen_crash_info(&size_xen_crash_info);
 
-		xen_crash_info = get_xen_crash_info(&size_xen_crash_info);
+	if (!info->xen_phys_start) {
 		if (!xen_crash_info ||
 		    size_xen_crash_info < sizeof(crash_xen_info_v2_t)) {
 			ERRMSG("Can't get Xen physical start address.\n"
 			       "Please use the --xen_phys_start option.");
 			return FALSE;
 		}
-		info->xen_phys_start = xen_crash_info->xen_phys_start;
+
+		xen_crash_info2 = (crash_xen_info_v2_t*) xen_crash_info;
+		info->xen_phys_start = xen_crash_info2->xen_phys_start;
+	}
+
+	if (xen_crash_info &&
+	    xen_crash_info->xen_major_version >= 4) {
+		info->xen_virt_start = XEN_VIRT_START_V4;
+		info->directmap_virt_end = DIRECTMAP_VIRT_END_V4;
+	} else {
+		info->xen_virt_start = XEN_VIRT_START_V3;
+		info->directmap_virt_end = DIRECTMAP_VIRT_END_V3;
 	}
 
 	if (SYMBOL(pgd_l4) == NOT_FOUND_SYMBOL) {



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 4/8] Fix domain pickled_id computation for xen-3.4+
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
                   ` (2 preceding siblings ...)
  2012-07-23 11:32 ` [PATCH 3/8] Support Xen4 virtuall address space layout ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-07-23 11:32 ` [PATCH 5/8] Add infrastructure for Xen PGC_xxx macros ptesarik
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-xen4-pickled-domain.patch --]
[-- Type: text/plain, Size: 2749 bytes --]

Originally, Xen stored the 32-bit address of the domain structure in struct
page_info. On x86-64, the physical address was stored, but since all heap
objects were allocated in the 1:1 mapping which started at 0xffff830000000000,
the end result was the same as if we simply chopped off the high bits (actual
implementation in makedumpfile).

Then, during the development of Xen-3.4, this logic was changed several times
for x86-64:

changeset 39517e863cc8 widened the _domain field to 64 bits and stored the
        virtual address of struct domain instead of physical address
changeset beba88f6f90d removed the pickle/unpickle macros
changeset 0858f961c77a changed _domain back from unsigned long to u32,
        *and* stores the MFN of struct domain instead

All the above changes went into Xen-3.4, and the relation between a domain
address and the contents of the _domain field hasn't changed since then.
That means, when the MADDR space was compressed in Xen-4.0, the type of the
_domain field was changed to _pdx_t, which was specifically invented to
preserve its calculation from the struct domain address.

To sum it up:

1. For all Xen versions before Xen-3.4, the _domain field contains the address
   of struct domain (with high bits chopped for x86-64).
2. For all Xen versions starting with Xen-3.4, the _domain field can be
   computed from struct domain address as:
        (addr - DIRECTMAP_VIRT_START) >> PAGE_SHIFT

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 arch/x86_64.c |   28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -402,14 +402,30 @@ int get_xen_basic_info_x86_64(void)
 
 int get_xen_info_x86_64(void)
 {
+	crash_xen_info_common_t *xen_crash_info;
 	int i;
 
-	/*
-	 * pickled_id == domain addr for x86_64
-	 */
-	for (i = 0; i < info->num_domain; i++) {
-		info->domain_list[i].pickled_id =
-			info->domain_list[i].domain_addr;
+	xen_crash_info = get_xen_crash_info(NULL);
+	if (xen_crash_info &&
+	    (xen_crash_info->xen_major_version >= 4 ||
+	     (xen_crash_info->xen_major_version == 3 &&
+	      xen_crash_info->xen_minor_version >= 4))) {
+		/*
+		 * cf. changeset 0858f961c77a
+		 */
+		for (i = 0; i < info->num_domain; i++) {
+			info->domain_list[i].pickled_id =
+				(info->domain_list[i].domain_addr
+				 - DIRECTMAP_VIRT_START) >> info->page_shift;
+		}
+	} else {
+		/*
+		 * pickled_id == domain addr for x86_64
+		 */
+		for (i = 0; i < info->num_domain; i++) {
+			info->domain_list[i].pickled_id =
+				info->domain_list[i].domain_addr;
+		}
 	}
 
 	return TRUE;



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 5/8] Add infrastructure for Xen PGC_xxx macros
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
                   ` (3 preceding siblings ...)
  2012-07-23 11:32 ` [PATCH 4/8] Fix domain pickled_id computation for xen-3.4+ ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-07-23 11:32 ` [PATCH 6/8] Handle Xen4 heap pages ptesarik
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-xen4-PGC_flags.patch --]
[-- Type: text/plain, Size: 2314 bytes --]

The highest bits of the _count field in struct page_info contain some
page specific flags. However, since they are allocated from top to bottom,
we need some infrastructure to get their values right on all platforms,
namely a macro that defines the size of a "long" value.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 makedumpfile.h |   19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -78,6 +78,12 @@ int get_mem_type(void);
 #define LSEEKED_PDATA	(3)
 
 /*
+ * Xen page flags
+ */
+#define PG_shift(idx)	(BITS_PER_LONG - (idx))
+#define PG_mask(x, idx)	(x ## UL << PG_shift(idx))
+
+/*
  * Memory flags
  */
 #define MEMORY_PAGETABLE_4L	(1 << 0)
@@ -426,6 +432,8 @@ do { \
 #define VMEMMAP_END		(info->vmemmap_end)
 
 #ifdef __arm__
+#define BITS_PER_LONG		32
+
 #define KVBASE_MASK		(0xffff)
 #define KVBASE			(SYMBOL(_stext) & ~KVBASE_MASK)
 #define _SECTION_SIZE_BITS	(28)
@@ -443,6 +451,8 @@ do { \
 #endif /* arm */
 
 #ifdef __x86__
+#define BITS_PER_LONG		32
+
 #define __PAGE_OFFSET		(0xc0000000)
 #define __VMALLOC_RESERVE       (128 << 20)
 #define MAXMEM                  (-PAGE_OFFSET-__VMALLOC_RESERVE)
@@ -474,6 +484,8 @@ do { \
 #endif /* x86 */
 
 #ifdef __x86_64__
+#define BITS_PER_LONG		64
+
 #define __PAGE_OFFSET_ORIG	(0xffff810000000000) /* 2.6.26, or former */
 #define __PAGE_OFFSET_2_6_27	(0xffff880000000000) /* 2.6.27, or later  */
 
@@ -523,6 +535,8 @@ do { \
 #endif /* x86_64 */
 
 #ifdef __powerpc64__
+#define BITS_PER_LONG		64
+
 #define __PAGE_OFFSET		(0xc000000000000000)
 #define KERNELBASE		PAGE_OFFSET
 #define VMALLOCBASE     	(0xD000000000000000)
@@ -532,6 +546,7 @@ do { \
 #endif
 
 #ifdef __powerpc32__
+#define BITS_PER_LONG		32
 
 #define __PAGE_OFFSET		(0xc0000000)
 #define KERNELBASE		PAGE_OFFSET
@@ -543,6 +558,8 @@ do { \
 #endif
 
 #ifdef __s390x__
+#define BITS_PER_LONG		64
+
 #define __PAGE_OFFSET		(info->page_size - 1)
 #define KERNELBASE		(0)
 #define KVBASE			KERNELBASE
@@ -583,6 +600,8 @@ do { \
 #endif /* __s390x__ */
 
 #ifdef __ia64__ /* ia64 */
+#define BITS_PER_LONG		64
+
 #define REGION_SHIFT		(61)
 
 #define KERNEL_CACHED_REGION	(7)



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 6/8] Handle Xen4 heap pages
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
                   ` (4 preceding siblings ...)
  2012-07-23 11:32 ` [PATCH 5/8] Add infrastructure for Xen PGC_xxx macros ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-08-09 15:45   ` Trapp, Norbert
  2012-07-23 11:32 ` [PATCH 7/8] Update the algorithm to find unused Xen pages for Xen4 ptesarik
                   ` (2 subsequent siblings)
  8 siblings, 1 reply; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-xen4-heap.patch --]
[-- Type: text/plain, Size: 3674 bytes --]

In Xen3, heap pages were allocated in a fixed range, so they could be
recognized by their address. This is no longer the case with Xen4. Instead, we
have to look at the page flags and check if PGC_xen_heap is set.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 arch/ia64.c    |   36 +++++++++++++++++-------------------
 arch/x86_64.c  |   18 ++++++++----------
 makedumpfile.c |    6 +++++-
 makedumpfile.h |    1 +
 4 files changed, 31 insertions(+), 30 deletions(-)

--- a/arch/ia64.c
+++ b/arch/ia64.c
@@ -335,26 +335,24 @@ get_xen_basic_info_ia64(void)
 
 	info->frame_table_vaddr = VIRT_FRAME_TABLE_ADDR; /* "frame_table" is same value */
 
-	if (SYMBOL(xenheap_phys_end) == NOT_FOUND_SYMBOL) {
-		ERRMSG("Can't get the symbol of xenheap_phys_end.\n");
-		return FALSE;
+	if (SYMBOL(xenheap_phys_end) != NOT_FOUND_SYMBOL) {
+		if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
+		      sizeof(xen_end))) {
+			ERRMSG("Can't get the value of xenheap_phys_end.\n");
+			return FALSE;
+		}
+		if (SYMBOL(xen_pstart) == NOT_FOUND_SYMBOL) {
+			ERRMSG("Can't get the symbol of xen_pstart.\n");
+			return FALSE;
+		}
+		if (!readmem(VADDR_XEN, SYMBOL(xen_pstart), &xen_start,
+		    sizeof(xen_start))) {
+			ERRMSG("Can't get the value of xen_pstart.\n");
+			return FALSE;
+		}
+		info->xen_heap_start = paddr_to_pfn(xen_start);
+		info->xen_heap_end   = paddr_to_pfn(xen_end);
 	}
-	if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
-	      sizeof(xen_end))) {
-		ERRMSG("Can't get the value of xenheap_phys_end.\n");
-		return FALSE;
-	}
-	if (SYMBOL(xen_pstart) == NOT_FOUND_SYMBOL) {
-		ERRMSG("Can't get the symbol of xen_pstart.\n");
-		return FALSE;
-	}
-	if (!readmem(VADDR_XEN, SYMBOL(xen_pstart), &xen_start,
-	    sizeof(xen_start))) {
-		ERRMSG("Can't get the value of xen_pstart.\n");
-		return FALSE;
-	}
-	info->xen_heap_start = paddr_to_pfn(xen_start);
-	info->xen_heap_end   = paddr_to_pfn(xen_end);
 
 	return TRUE;
 }
--- a/arch/x86_64.c
+++ b/arch/x86_64.c
@@ -385,17 +385,15 @@ int get_xen_basic_info_x86_64(void)
 	}
 	info->frame_table_vaddr = frame_table_vaddr;
 
-	if (SYMBOL(xenheap_phys_end) == NOT_FOUND_SYMBOL) {
-		ERRMSG("Can't get the symbol of xenheap_phys_end.\n");
-		return FALSE;
+	if (SYMBOL(xenheap_phys_end) != NOT_FOUND_SYMBOL) {
+		if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
+		    sizeof(xen_end))) {
+			ERRMSG("Can't get the value of xenheap_phys_end.\n");
+			return FALSE;
+		}
+		info->xen_heap_start = 0;
+		info->xen_heap_end   = paddr_to_pfn(xen_end);
 	}
-	if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
-	    sizeof(xen_end))) {
-		ERRMSG("Can't get the value of xenheap_phys_end.\n");
-		return FALSE;
-	}
-	info->xen_heap_start = 0;
-	info->xen_heap_end   = paddr_to_pfn(xen_end);
 
 	return TRUE;
 }
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5715,7 +5715,11 @@ exclude_xen_user_domain(void)
 			 */
 			if (_domain == 0)
 				continue;
-			if (info->xen_heap_start <= pfn && pfn < info->xen_heap_end)
+			if (!info->xen_heap_end) {
+				if (count_info & PGC_xen_heap)
+					continue;
+			} else if (info->xen_heap_start <= pfn &&
+				   pfn < info->xen_heap_end)
 				continue;
 			if ((count_info & 0xffff) && is_select_domain(_domain))
 				continue;
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -82,6 +82,7 @@ int get_mem_type(void);
  */
 #define PG_shift(idx)	(BITS_PER_LONG - (idx))
 #define PG_mask(x, idx)	(x ## UL << PG_shift(idx))
+#define PGC_xen_heap        PG_mask(1, 2)
 
 /*
  * Memory flags



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 7/8] Update the algorithm to find unused Xen pages for Xen4
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
                   ` (5 preceding siblings ...)
  2012-07-23 11:32 ` [PATCH 6/8] Handle Xen4 heap pages ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-07-23 11:32 ` [PATCH 8/8] Make max_pfn symbol optional for Xen dumps ptesarik
  2012-07-24  5:13 ` [PATCH 0/8] makedumpfile: Xen4 support for SLES11 Atsushi Kumagai
  8 siblings, 0 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-xen4-page-usage.patch --]
[-- Type: text/plain, Size: 2484 bytes --]

Xen3 used to maintain a bitmap of used/unused pages, which no longer exists in
Xen4. Instead, we have to inspect page flags in frame_table[].

To maintain backward compatibility, the bitmap is used if found, but if the
alloc_bitmap symbol doesn't exist, the new code assumes that it is reading a
Xen4 crashdump.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 makedumpfile.c |   13 +++++++------
 makedumpfile.h |    7 +++++++
 2 files changed, 14 insertions(+), 6 deletions(-)

--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -5325,11 +5325,8 @@ get_xen_info(void)
 	if (!get_xen_basic_info_arch())
 		return FALSE;
 
-	if (SYMBOL(alloc_bitmap) == NOT_FOUND_SYMBOL) {
-		ERRMSG("Can't get the symbol of alloc_bitmap.\n");
-		return FALSE;
-	}
-	if (!readmem(VADDR_XEN, SYMBOL(alloc_bitmap), &info->alloc_bitmap,
+	if (SYMBOL(alloc_bitmap) != NOT_FOUND_SYMBOL &&
+	    !readmem(VADDR_XEN, SYMBOL(alloc_bitmap), &info->alloc_bitmap,
 	      sizeof(info->alloc_bitmap))) {
 		ERRMSG("Can't get the value of alloc_bitmap.\n");
 		return FALSE;
@@ -5689,7 +5686,7 @@ exclude_xen_user_domain(void)
 			print_progress(PROGRESS_XEN_DOMAIN, j + (size * i),
 					size * num_pt_loads);
 
-			if (!allocated_in_map(pfn)) {
+			if (info->alloc_bitmap && !allocated_in_map(pfn)) {
 				clear_bit_on_2nd_bitmap(pfn);
 				continue;
 			}
@@ -5701,6 +5698,10 @@ exclude_xen_user_domain(void)
 				clear_bit_on_2nd_bitmap(pfn);
 				continue;	/* page_info may not exist */
 			}
+			if (!info->alloc_bitmap && page_state_is(count_info, free)) {
+				clear_bit_on_2nd_bitmap(pfn);
+				continue;
+			}
 			if (!readmem(VADDR_XEN,
 			      page_info_addr + OFFSET(page_info._domain),
 			      &_domain, sizeof(_domain))) {
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -83,6 +83,13 @@ int get_mem_type(void);
 #define PG_shift(idx)	(BITS_PER_LONG - (idx))
 #define PG_mask(x, idx)	(x ## UL << PG_shift(idx))
 #define PGC_xen_heap        PG_mask(1, 2)
+ /* Mutually-exclusive page states: { inuse, offlining, offlined, free }. */
+#define PGC_state           PG_mask(3, 9)
+#define PGC_state_inuse     PG_mask(0, 9)
+#define PGC_state_offlining PG_mask(1, 9)
+#define PGC_state_offlined  PG_mask(2, 9)
+#define PGC_state_free      PG_mask(3, 9)
+#define page_state_is(count_info, st) (((count_info)&PGC_state) == PGC_state_##st)
 
 /*
  * Memory flags



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* [PATCH 8/8] Make max_pfn symbol optional for Xen dumps
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
                   ` (6 preceding siblings ...)
  2012-07-23 11:32 ` [PATCH 7/8] Update the algorithm to find unused Xen pages for Xen4 ptesarik
@ 2012-07-23 11:32 ` ptesarik
  2012-07-24  5:13 ` [PATCH 0/8] makedumpfile: Xen4 support for SLES11 Atsushi Kumagai
  8 siblings, 0 replies; 12+ messages in thread
From: ptesarik @ 2012-07-23 11:32 UTC (permalink / raw)
  To: kexec; +Cc: Petr Tesarik

[-- Attachment #1: makedumpfile-xen-max_pfn-optional.patch --]
[-- Type: text/plain, Size: 2396 bytes --]

After commit ec5b5835a113cf62a168d4a7354564a38de6b52c, makedumpfile fails on
Xen dumps unless the "max_pfn" symbol is known. This happens even when the
dump level is 0 and 1, where it worked previously. This is especially bad for
kernels which do not put the "max_pfn" symbol into its ELF VMCOREINFO.

With this patch, the "max_pfn" symbol is required only if the specified
dump level needs it.

Signed-off-by: Petr Tesarik <ptesarik@suse.cz>

---
 makedumpfile.c |   33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -143,13 +143,15 @@ get_dom0_mapnr()
 {
 	unsigned long max_pfn;
 
-	if (SYMBOL(max_pfn) == NOT_FOUND_SYMBOL)
-		return FALSE;
-
-	if (!readmem(VADDR, SYMBOL(max_pfn), &max_pfn, sizeof max_pfn))
-		return FALSE;
+	if (SYMBOL(max_pfn) != NOT_FOUND_SYMBOL) {
+		if (!readmem(VADDR, SYMBOL(max_pfn), &max_pfn, sizeof max_pfn)) {
+			ERRMSG("Can't read domain-0 max_pfn.\n");
+			return FALSE;
+		}
 
-	info->dom0_mapnr = max_pfn;
+		info->dom0_mapnr = max_pfn;
+		DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
+	}
 
 	return TRUE;
 }
@@ -2430,14 +2432,6 @@ get_mem_map(void)
 {
 	int ret;
 
-	if (is_xen_memory()) {
-		if (!get_dom0_mapnr()) {
-			ERRMSG("Can't domain-0 pfn.\n");
-			return FALSE;
-		}
-		DEBUG_MSG("domain-0 pfn : %llx\n", info->dom0_mapnr);
-	}
-
 	switch (get_mem_type()) {
 	case SPARSEMEM:
 		DEBUG_MSG("\n");
@@ -3475,6 +3469,10 @@ exclude_free_page(void)
 		ERRMSG("Can't get necessary structures for excluding free pages.\n");
 		return FALSE;
 	}
+	if (is_xen_memory() && !info->dom0_mapnr) {
+		ERRMSG("Can't get max domain-0 PFN for excluding free pages.\n");
+		return FALSE;
+	}
 
 	/*
 	 * Detect free pages and update 2nd-bitmap.
@@ -3749,6 +3747,11 @@ exclude_unnecessary_pages(void)
 	struct mem_map_data *mmd;
 	struct timeval tv_start;
 
+	if (is_xen_memory() && !info->dom0_mapnr) {
+		ERRMSG("Can't get max domain-0 PFN for excluding pages.\n");
+		return FALSE;
+	}
+
 	gettimeofday(&tv_start, NULL);
 
 	for (mm = 0; mm < info->num_mem_map; mm++) {
@@ -5816,6 +5819,8 @@ initial_xen(void)
 out:
 	if (!get_max_mapnr())
 		return FALSE;
+	if (!get_dom0_mapnr())
+		return FALSE;
 
 	return TRUE;
 #endif



_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH 0/8] makedumpfile: Xen4 support for SLES11
  2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
                   ` (7 preceding siblings ...)
  2012-07-23 11:32 ` [PATCH 8/8] Make max_pfn symbol optional for Xen dumps ptesarik
@ 2012-07-24  5:13 ` Atsushi Kumagai
  2012-07-24  8:05   ` Petr Tesarik
  8 siblings, 1 reply; 12+ messages in thread
From: Atsushi Kumagai @ 2012-07-24  5:13 UTC (permalink / raw)
  To: ptesarik; +Cc: kexec, fngw.zhang, Norbert.Trapp

Hello Petr,

On Mon, 23 Jul 2012 13:32:44 +0200
ptesarik@suse.cz wrote:

> This patchset was created to allow using makedumpfile for Dom0 dumps in SLES
> SP1 and SP2. Most of the patches account for changes to the Xen hypervisor,
> except the last one, which reflects that the "max_pfn" symbol is not exporte
> by the SLES kernel.
> 
> Petr Tesarik
> SUSE Linux

Thank you for your work.

Although I haven't seen almost your patchset yet, does your patchset have 
a functional overlap with the patchset Norbert sent ?

  http://lists.infradead.org/pipermail/kexec/2012-June/006420.html
  (This thread needs some experts in Xen)

It seems that the two have the same purpose, but I can't decide which is 
better way. Do you have any opinion ?


Thanks
Atsushi Kumagai

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* Re: [PATCH 0/8] makedumpfile: Xen4 support for SLES11
  2012-07-24  5:13 ` [PATCH 0/8] makedumpfile: Xen4 support for SLES11 Atsushi Kumagai
@ 2012-07-24  8:05   ` Petr Tesarik
  0 siblings, 0 replies; 12+ messages in thread
From: Petr Tesarik @ 2012-07-24  8:05 UTC (permalink / raw)
  To: Atsushi Kumagai; +Cc: kexec, fngw.zhang, Norbert.Trapp

Dne Út 24. července 2012 07:13:17 Atsushi Kumagai napsal(a):
> Hello Petr,
> 
> On Mon, 23 Jul 2012 13:32:44 +0200
> 
> ptesarik@suse.cz wrote:
> > This patchset was created to allow using makedumpfile for Dom0 dumps in
> > SLES SP1 and SP2. Most of the patches account for changes to the Xen
> > hypervisor, except the last one, which reflects that the "max_pfn"
> > symbol is not exporte by the SLES kernel.
> > 
> > Petr Tesarik
> > SUSE Linux
> 
> Thank you for your work.
> 
> Although I haven't seen almost your patchset yet, does your patchset have
> a functional overlap with the patchset Norbert sent ?
> 
>   http://lists.infradead.org/pipermail/kexec/2012-June/006420.html
>   (This thread needs some experts in Xen)

Yes, I found that one only after I sent my patch set. I've contacted Norbert 
and asked him about his opinion.

> It seems that the two have the same purpose, but I can't decide which is
> better way. Do you have any opinion ?

OK, I'll have a look at Norbert's work and see if I can combine the two 
somehow.

Stay tuned,
Petr Tesarik

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

* RE: [PATCH 6/8] Handle Xen4 heap pages
  2012-07-23 11:32 ` [PATCH 6/8] Handle Xen4 heap pages ptesarik
@ 2012-08-09 15:45   ` Trapp, Norbert
  0 siblings, 0 replies; 12+ messages in thread
From: Trapp, Norbert @ 2012-08-09 15:45 UTC (permalink / raw)
  To: ptesarik, kexec

Hello Petr et al,

When trying out your patches I noticed that the size of
the produced file with xen and dom0 pages was larger
than when using my own patches. When adding counters
for the different page types to your patches it turned
out that the free pages and the xen heap pages were
not recognized. The reason seems to be that the count_info
variable in the Xen page_info structure is of size unsigned long
for Xen4. Yeah, it was already unsigned long for Xen3.4, but
before that it was unsigned int. And the Xen4 PGC_... symbols
seem to expect unsigned long variables. So the count_info
variable in exclude_xen_user_domain should be of size
unsigned long for Xen4 and so on, shouldn't it?

With kind regards
Norbert

> -----Original Message-----
> From: kexec-bounces@lists.infradead.org [mailto:kexec-bounces@lists.infradead.org] On Behalf Of ptesarik@suse.cz
> Sent: Monday, July 23, 2012 1:33 PM
> To: kexec@lists.infradead.org
> Cc: Petr Tesarik
> Subject: [PATCH 6/8] Handle Xen4 heap pages
> 
> In Xen3, heap pages were allocated in a fixed range, so they could be
> recognized by their address. This is no longer the case with Xen4. Instead, we
> have to look at the page flags and check if PGC_xen_heap is set.
> 
> Signed-off-by: Petr Tesarik <ptesarik@suse.cz>
> 
> ---
>  arch/ia64.c    |   36 +++++++++++++++++-------------------
>  arch/x86_64.c  |   18 ++++++++----------
>  makedumpfile.c |    6 +++++-
>  makedumpfile.h |    1 +
>  4 files changed, 31 insertions(+), 30 deletions(-)
> 
> --- a/arch/ia64.c
> +++ b/arch/ia64.c
> @@ -335,26 +335,24 @@ get_xen_basic_info_ia64(void)
> 
>  	info->frame_table_vaddr = VIRT_FRAME_TABLE_ADDR; /* "frame_table" is same value */
> 
> -	if (SYMBOL(xenheap_phys_end) == NOT_FOUND_SYMBOL) {
> -		ERRMSG("Can't get the symbol of xenheap_phys_end.\n");
> -		return FALSE;
> +	if (SYMBOL(xenheap_phys_end) != NOT_FOUND_SYMBOL) {
> +		if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
> +		      sizeof(xen_end))) {
> +			ERRMSG("Can't get the value of xenheap_phys_end.\n");
> +			return FALSE;
> +		}
> +		if (SYMBOL(xen_pstart) == NOT_FOUND_SYMBOL) {
> +			ERRMSG("Can't get the symbol of xen_pstart.\n");
> +			return FALSE;
> +		}
> +		if (!readmem(VADDR_XEN, SYMBOL(xen_pstart), &xen_start,
> +		    sizeof(xen_start))) {
> +			ERRMSG("Can't get the value of xen_pstart.\n");
> +			return FALSE;
> +		}
> +		info->xen_heap_start = paddr_to_pfn(xen_start);
> +		info->xen_heap_end   = paddr_to_pfn(xen_end);
>  	}
> -	if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
> -	      sizeof(xen_end))) {
> -		ERRMSG("Can't get the value of xenheap_phys_end.\n");
> -		return FALSE;
> -	}
> -	if (SYMBOL(xen_pstart) == NOT_FOUND_SYMBOL) {
> -		ERRMSG("Can't get the symbol of xen_pstart.\n");
> -		return FALSE;
> -	}
> -	if (!readmem(VADDR_XEN, SYMBOL(xen_pstart), &xen_start,
> -	    sizeof(xen_start))) {
> -		ERRMSG("Can't get the value of xen_pstart.\n");
> -		return FALSE;
> -	}
> -	info->xen_heap_start = paddr_to_pfn(xen_start);
> -	info->xen_heap_end   = paddr_to_pfn(xen_end);
> 
>  	return TRUE;
>  }
> --- a/arch/x86_64.c
> +++ b/arch/x86_64.c
> @@ -385,17 +385,15 @@ int get_xen_basic_info_x86_64(void)
>  	}
>  	info->frame_table_vaddr = frame_table_vaddr;
> 
> -	if (SYMBOL(xenheap_phys_end) == NOT_FOUND_SYMBOL) {
> -		ERRMSG("Can't get the symbol of xenheap_phys_end.\n");
> -		return FALSE;
> +	if (SYMBOL(xenheap_phys_end) != NOT_FOUND_SYMBOL) {
> +		if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
> +		    sizeof(xen_end))) {
> +			ERRMSG("Can't get the value of xenheap_phys_end.\n");
> +			return FALSE;
> +		}
> +		info->xen_heap_start = 0;
> +		info->xen_heap_end   = paddr_to_pfn(xen_end);
>  	}
> -	if (!readmem(VADDR_XEN, SYMBOL(xenheap_phys_end), &xen_end,
> -	    sizeof(xen_end))) {
> -		ERRMSG("Can't get the value of xenheap_phys_end.\n");
> -		return FALSE;
> -	}
> -	info->xen_heap_start = 0;
> -	info->xen_heap_end   = paddr_to_pfn(xen_end);
> 
>  	return TRUE;
>  }
> --- a/makedumpfile.c
> +++ b/makedumpfile.c
> @@ -5715,7 +5715,11 @@ exclude_xen_user_domain(void)
>  			 */
>  			if (_domain == 0)
>  				continue;
> -			if (info->xen_heap_start <= pfn && pfn < info->xen_heap_end)
> +			if (!info->xen_heap_end) {
> +				if (count_info & PGC_xen_heap)
> +					continue;
> +			} else if (info->xen_heap_start <= pfn &&
> +				   pfn < info->xen_heap_end)
>  				continue;
>  			if ((count_info & 0xffff) && is_select_domain(_domain))
>  				continue;
> --- a/makedumpfile.h
> +++ b/makedumpfile.h
> @@ -82,6 +82,7 @@ int get_mem_type(void);
>   */
>  #define PG_shift(idx)	(BITS_PER_LONG - (idx))
>  #define PG_mask(x, idx)	(x ## UL << PG_shift(idx))
> +#define PGC_xen_heap        PG_mask(1, 2)
> 
>  /*
>   * Memory flags
> 
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

Norbert Trapp
PDG ES&S SWE OS 6

FUJITSU
Fujitsu Technology Solutions GmbH
Domagkstraße 28, D-80807 München, Germany
E-mail: Norbert.Trapp@ts.fujitsu.com
Web: ts.fujitsu.com
Company details: ts.fujitsu.com/imprint
Please be advised that neither Fujitsu, its affiliates, its employees or agents accept liability for any errors, omissions or damages caused by delays of receipt or by any virus infection in this message or its attachments, or which may otherwise arise as a result of this e-mail transmission.

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

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

end of thread, other threads:[~2012-08-09 15:45 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-23 11:32 [PATCH 0/8] makedumpfile: Xen4 support for SLES11 ptesarik
2012-07-23 11:32 ` [PATCH 1/8] Read the Xen crash ELF note into memory at startup ptesarik
2012-07-23 11:32 ` [PATCH 2/8] Split early Xen setup from late Xen setup ptesarik
2012-07-23 11:32 ` [PATCH 3/8] Support Xen4 virtuall address space layout ptesarik
2012-07-23 11:32 ` [PATCH 4/8] Fix domain pickled_id computation for xen-3.4+ ptesarik
2012-07-23 11:32 ` [PATCH 5/8] Add infrastructure for Xen PGC_xxx macros ptesarik
2012-07-23 11:32 ` [PATCH 6/8] Handle Xen4 heap pages ptesarik
2012-08-09 15:45   ` Trapp, Norbert
2012-07-23 11:32 ` [PATCH 7/8] Update the algorithm to find unused Xen pages for Xen4 ptesarik
2012-07-23 11:32 ` [PATCH 8/8] Make max_pfn symbol optional for Xen dumps ptesarik
2012-07-24  5:13 ` [PATCH 0/8] makedumpfile: Xen4 support for SLES11 Atsushi Kumagai
2012-07-24  8:05   ` Petr Tesarik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.