Skip to contentSkip to conversation

Zero size /proc/vmcore on ia64

Fastboot Bernhard Walle 5 participants 7 messages Feb 12, 2007 – Feb 15, 2007

lore
Share & tools
lore
#0 lore raw
Quoted 3 lines · Zou, Nanhai

I have not implement serial print in purgatory code yet, see comments in purgatory/arch/ia64/console-ia64.c However from your print, I can see last 2 entries of efi mem map are corrupt.

I have the same problem (corrupted memory map entries), and the cause was in kexec-tools, patch below. I'm not sure if the fix is right, at least the problem is the uninitialised value of size. :)

---
 crashdump-ia64.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
kexec/arch/ia64/crashdump-ia64.c +2 -2
index 14e95a6..be61dc1 100644
@@ -221,7 +221,7 @@ int load_crashdump_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
 	struct memory_range *mem_range;
 	int nr_ranges;
 	unsigned long sz;
-	size_t size;
+	size_t size = 0;
 	void *tmp;
 	if (info->kexec_flags & KEXEC_ON_CRASH ) {
 		if (get_crash_memory_ranges(&mem_range, &nr_ranges) = 0) {
@@ -238,7 +238,7 @@ int load_crashdump_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
 			elfcorehdr = add_buffer(info, tmp, sz, sz, EFI_PAGE_SIZE, min_base,
 					max_addr, -1);
 			loaded_segments[loaded_segments_num].start = elfcorehdr;
-			loaded_segments[loaded_segments_num].end = elfcorehdr + size;
+			loaded_segments[loaded_segments_num].end = elfcorehdr + sz;
 			loaded_segments[loaded_segments_num].reserved = 1;
 			loaded_segments_num++;
 			cmdline_add_elfcorehdr(cmdline, elfcorehdr);
#1 lore raw
Quoted 8 lines · Bernhard Walle
Quoted 3 lines · Zou, Nanhai

I have not implement serial print in purgatory code yet, see comments in purgatory/arch/ia64/console-ia64.c However from your print, I can see last 2 entries of efi mem map are corrupt.

I have the same problem (corrupted memory map entries), and the cause was in kexec-tools, patch below. I'm not sure if the fix is right, at least the problem is the uninitialised value of size. :)

But that patch doesn't fix the zero-size problem, it just fixes the invalid EFI map problem. That patch (against kexec-tools, not against the kernel) fixes both.

The problem is simply that the space for the core header doesn't occupy a EFI page.

---
 crashdump-ia64.c |   14 ++++++++++----
 kexec-ia64.h     |    6 +++++-
 2 files changed, 15 insertions(+), 5 deletions(-)
kexec/arch/ia64/crashdump-ia64.c +10 -4
index 14e95a6..e3d8b41 100644
@@ -220,8 +220,8 @@ int load_crashdump_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
 {
 	struct memory_range *mem_range;
 	int nr_ranges;
-	unsigned long sz;
-	size_t size;
+	unsigned long sz, memsz;
+	size_t size = 0;
 	void *tmp;
 	if (info->kexec_flags & KEXEC_ON_CRASH ) {
 		if (get_crash_memory_ranges(&mem_range, &nr_ranges) = 0) {
@@ -235,10 +235,16 @@ int load_crashdump_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
 						       &tmp, &sz) < 0)
 				return -1;
 
-			elfcorehdr = add_buffer(info, tmp, sz, sz, EFI_PAGE_SIZE, min_base,
+			/* round sz up */
+			if (sz != ((sz >> EFI_PAGE_SHIFT) << EFI_PAGE_SHIFT))
+				memsz = ((sz >> EFI_PAGE_SHIFT) + 1) << EFI_PAGE_SHIFT;
+			else
+				memsz = sz;
+
+			elfcorehdr = add_buffer(info, tmp, sz, memsz, EFI_PAGE_SIZE, min_base,
 					max_addr, -1);
 			loaded_segments[loaded_segments_num].start = elfcorehdr;
-			loaded_segments[loaded_segments_num].end = elfcorehdr + size;
+			loaded_segments[loaded_segments_num].end = elfcorehdr + memsz;
 			loaded_segments[loaded_segments_num].reserved = 1;
 			loaded_segments_num++;
 			cmdline_add_elfcorehdr(cmdline, elfcorehdr);
kexec/arch/ia64/kexec-ia64.h +5 -1
index 176d5f9..28a728b 100644
@@ -10,6 +10,10 @@ int update_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr);
 void move_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
 			  unsigned long addr);
 
-#define EFI_PAGE_SIZE	  (1UL<<12)
+#define EFI_PAGE_SHIFT		12
+
+#define EFI_PAGE_SIZE	  (1UL<<EFI_PAGE_SHIFT)
 #define ELF_PAGE_SIZE	  (1UL<<16)
+
+
 #endif /* KEXEC_IA64_H */
#2 lore raw
In reply to Bernhard Walle
Quoted 54 lines

-----Original Message-----
From: [email protected] [mailto:[email protected]] On Behalf Of Bernhard Walle
Sent: 2007Äê2ÔÂ13ÈÕ 5:50
To: [email protected]; Linux-IA64
Subject: Re: [Fastboot] Zero size /proc/vmcore on ia64

Quoted 8 lines · Bernhard Walle
Quoted 3 lines · Zou, Nanhai

I have not implement serial print in purgatory code yet, see comments in purgatory/arch/ia64/console-ia64.c However from your print, I can see last 2 entries of efi mem map are corrupt.

I have the same problem (corrupted memory map entries), and the cause was in kexec-tools, patch below. I'm not sure if the fix is right, at least the problem is the uninitialised value of size. :)

But that patch doesn't fix the zero-size problem, it just fixes the invalid EFI map problem. That patch (against kexec-tools, not against the kernel) fixes both.

The problem is simply that the space for the core header doesn't occupy a EFI page.

---
 crashdump-ia64.c |   14 ++++++++++----
 kexec-ia64.h     |    6 +++++-
 2 files changed, 15 insertions(+), 5 deletions(-)
kexec/arch/ia64/crashdump-ia64.c +2 -2
index 14e95a6..e3d8b41 100644
@@ -220,8 +220,8 @@ int load_crashdump_segments(struct kexec_info *info,
 struct mem_ehdr *ehdr,
 {
 	struct memory_range *mem_range;
 	int nr_ranges;
-	unsigned long sz;
-	size_t size;
+	unsigned long sz, memsz;
+	size_t size = 0;
 	void *tmp;
 	if (info->kexec_flags & KEXEC_ON_CRASH ) {
kexec/arch/ia64/crashdump-ia64.c +0 -1
 		if (get_crash_memory_ranges(&mem_range, &nr_ranges) = 0) {
@@ -235,10 +235,16 @@ int load_crashdump_segments(struct kexec_info *info,
 struct mem_ehdr *ehdr,
 						       &tmp, &sz) < 0)
 				return -1;
 
-			elfcorehdr = add_buffer(info, tmp, sz, sz, EFI_PAGE_SIZE,

kexec/arch/ia64/crashdump-ia64.c int load_crashdump_segments(struct kexec_info *info, · line 248

Quoted 10 lines
kexec/arch/ia64/crashdump-ia64.c +7 -0
 min_base,
+			/* round sz up */
+			if (sz != ((sz >> EFI_PAGE_SHIFT) << EFI_PAGE_SHIFT))
+				memsz = ((sz >> EFI_PAGE_SHIFT) + 1) << EFI_PAGE_SHIFT;
+			else
+				memsz = sz;
+
+			elfcorehdr = add_buffer(info, tmp, sz, memsz, EFI_PAGE_SIZE,
 min_base,
 					max_addr, -1);

The kexec-tools version seems to be different.
In my local version the size is aligned, there is size = (size + EFI_PAGE_SIZE - 1) & ~(EFI_PAGE_SIZE -1); so that is why I did not see this issue, someone has changed the code... Anyway you can round size to page size like this instead of if else, this will save 3 lines of code .:)

Thanks
Zou Nan hai

Quoted 27 lines
kexec/arch/ia64/crashdump-ia64.c +1 -1
 			loaded_segments[loaded_segments_num].start = elfcorehdr;
-			loaded_segments[loaded_segments_num].end = elfcorehdr + size;
+			loaded_segments[loaded_segments_num].end = elfcorehdr + memsz;
kexec/arch/ia64/crashdump-ia64.c +0 -0
 			loaded_segments[loaded_segments_num].reserved = 1;
 			loaded_segments_num++;
 			cmdline_add_elfcorehdr(cmdline, elfcorehdr);
kexec/arch/ia64/kexec-ia64.h +5 -1
index 176d5f9..28a728b 100644
@@ -10,6 +10,10 @@ int update_loaded_segments(struct kexec_info *info, struct
 mem_ehdr *ehdr);
 void move_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
 			  unsigned long addr);
 
-#define EFI_PAGE_SIZE	  (1UL<<12)
+#define EFI_PAGE_SHIFT		12
+
+#define EFI_PAGE_SIZE	  (1UL<<EFI_PAGE_SHIFT)
 #define ELF_PAGE_SIZE	  (1UL<<16)
+
+

#endif /* KEXEC_IA64_H */
-
To unsubscribe from this list: send the line "unsubscribe linux-ia64" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw
In reply to Bernhard Walle
Quoted 5 lines · Bernhard Walle
Quoted 5 lines

Index: kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c
=================================> > --- kexec-tools-bw.orig/kexec/arch/ia64/crashdump-ia64.c 2007-02-13 17:39:18.000000000 +0900
+++ kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c 2007-02-13 18:09:44.000000000 +0900

(quoted diff) +0 -0
@@ -232,13 +232,14 @@
 			if (crash_create_elf64_headers(info, &elf_info,
Quoted 8 lines

Review line 236

Quoted 5 lines
(quoted diff) +2 -1
 						       crash_memory_range,
 						       nr_ranges,
-						       &tmp, &sz) < 0)
+						       &tmp, &sz,
+						       4096) < 0)

Why not using EFI_PAGE_SIZE here? It would also be good to find a suitable constant name for 1024.

Indeed, I meant to use EFI_PAGE_SIZE instead of 4096. I'll fix that up and apply.

As for a good constant name, I'm open to suggestions.

Signature · 3 lines
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/
#4 lore raw
In reply to Bernhard Walle
Quoted 15 lines · Horms
Quoted 5 lines · Bernhard Walle
Quoted 5 lines

Index: kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c
=================================> > > --- kexec-tools-bw.orig/kexec/arch/ia64/crashdump-ia64.c 2007-02-13 17:39:18.000000000 +0900
+++ kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c 2007-02-13 18:09:44.000000000 +0900

(quoted diff) +0 -0
@@ -232,13 +232,14 @@
 			if (crash_create_elf64_headers(info, &elf_info,
Quoted 8 lines

Review line 236

Quoted 5 lines
(quoted diff) +2 -1
 						       crash_memory_range,
 						       nr_ranges,
-						       &tmp, &sz) < 0)
+						       &tmp, &sz,
+						       4096) < 0)

Why not using EFI_PAGE_SIZE here? It would also be good to find a suitable constant name for 1024.

Quoted 4 lines

Indeed, I meant to use EFI_PAGE_SIZE instead of 4096. I'll fix that up and apply.

As for a good constant name, I'm open to suggestions.

Hmmm ..., I don't know why there must be an alignment to 1024 on i386 and x86_64, Vivek?

Regards,
Bernhard

#5 lore raw
In reply to Bernhard Walle
Quoted 16 lines · Bernhard Walle
Quoted 15 lines · Horms
Quoted 13 lines · Bernhard Walle

Review line 236

Quoted 10 lines

Index: kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c
=================================> > > > --- kexec-tools-bw.orig/kexec/arch/ia64/crashdump-ia64.c 2007-02-13 17:39:18.000000000 +0900
+++ kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c 2007-02-13 18:09:44.000000000 +0900

(quoted diff) +2 -1
@@ -232,13 +232,14 @@
                  if (crash_create_elf64_headers(info, &elf_info,
                                                 crash_memory_range,
                                                 nr_ranges,
-                                                &tmp, &sz) < 0)
+                                                &tmp, &sz,
+                                                4096) < 0)

Why not using EFI_PAGE_SIZE here? It would also be good to find a suitable constant name for 1024.

Quoted 7 lines
Quoted 4 lines

Indeed, I meant to use EFI_PAGE_SIZE instead of 4096. I'll fix that up and apply.

As for a good constant name, I'm open to suggestions.

Hmmm ..., I don't know why there must be an alignment to 1024 on i386 and x86_64, Vivek?

The following comment explains it pretty well:

- /*

-        * The kernel command line option memmap= requires 1k granularity,
-        * therefore we align the size to 1024 here.
-        */

-
- align = 1024;

The comment was unfortunately removed by one of the patches in this thread, and I think your question is a good proof that we need the comment. I asked the same thing a few months ago too. =)

/ magnus

#6 lore raw
In reply to Bernhard Walle
Quoted 36 lines · Magnus Damm
Quoted 18 lines · Bernhard Walle
Quoted 3 lines · Horms
Quoted 2 lines · Bernhard Walle
Quoted 2 lines

Index: kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c
=================================> >> > > --- kexec-tools-bw.orig/kexec/arch/ia64/crashdump-ia64.c 2007-02-13

17:39:18.000000000 +0900

Quoted 1 line
Quoted 1 line
Quoted 1 line

+++ kexec-tools-bw/kexec/arch/ia64/crashdump-ia64.c 2007-02-13

18:09:44.000000000 +0900

Quoted 11 lines
Quoted 10 lines

Review line 236

Quoted 7 lines
(quoted diff) +2 -1
@@ -232,13 +232,14 @@
                  if (crash_create_elf64_headers(info, &elf_info,
                                                 crash_memory_range,
                                                 nr_ranges,
-                                                &tmp, &sz) < 0)
+                                                &tmp, &sz,
+                                                4096) < 0)

Why not using EFI_PAGE_SIZE here? It would also be good to find a suitable constant name for 1024.

Quoted 7 lines
Quoted 4 lines

Indeed, I meant to use EFI_PAGE_SIZE instead of 4096. I'll fix that up and apply.

As for a good constant name, I'm open to suggestions.

Hmmm ..., I don't know why there must be an alignment to 1024 on i386 and x86_64, Vivek?

The following comment explains it pretty well:

(quoted diff) +0 -6
-       /*
-        * The kernel command line option memmap= requires 1k granularity,
-        * therefore we align the size to 1024 here.
-        */
-
-       align = 1024;
Quoted 3 lines

The comment was unfortunately removed by one of the patches in this thread, and I think your question is a good proof that we need the comment. I asked the same thing a few months ago too. =)

If you can work out a good place to put the comment, I'll put it back in :-)

Signature · 3 lines
Horms
  H: http://www.vergenet.net/~horms/
  W: http://www.valinux.co.jp/en/