Skip to contentSkip to conversation

kdump: fix an error that can not parse the e820 reserved region

PATCH Superseded Lianbo Jiang 2 participants 3 messages Sep 5, 2018 – Sep 6, 2018

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kdump: fix an error that can not parse the e820 reserved region

When kexec-tools load the kernel and initramfs for kdump, kexec-tools will read /proc/iomem and recreate the e820 ranges for kdump kernel. But it fails to parse the e820 reserved region, because the memcmp() is case sensitive when comparing the string. In fact, it may be "Reserved" or "reserved" in the /proc/iomem, so we use the strncasecmp() instead of the memcmp() to fix it.

---
 kexec/arch/i386/crashdump-x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/arch/i386/crashdump-x86.c +1 -1
index 437e8a8..6669c1a 100644
@@ -287,7 +287,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 			type = RANGE_PRAM;
 		} else if(memcmp(str,"Persistent Memory\n",18) == 0 ) {
 			type = RANGE_PMEM;
-		} else if(memcmp(str,"reserved\n",9) == 0 ) {
+		} else if(strncasecmp(str,"reserved\n",9) == 0 ) {
 			type = RANGE_RESERVED;
 		} else if (memcmp(str, "GART\n", 5) == 0) {
 			gart_start = start;
Signature · 7 lines
2.17.1


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

Hi Lianbo,

Quoted 17 lines · Lianbo Jiang

When kexec-tools load the kernel and initramfs for kdump, kexec-tools will read /proc/iomem and recreate the e820 ranges for kdump kernel. But it fails to parse the e820 reserved region, because the memcmp() is case sensitive when comparing the string. In fact, it may be "Reserved" or "reserved" in the /proc/iomem, so we use the strncasecmp() instead of the memcmp() to fix it.

---
 kexec/arch/i386/crashdump-x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/arch/i386/crashdump-x86.c +0 -0
index 437e8a8..6669c1a 100644

kexec/arch/i386/crashdump-x86.c static int get_crash_memory_ranges(struct memory_range **range, int *ranges, · line 291

Quoted 6 lines
kexec/arch/i386/crashdump-x86.c +1 -1
@@ -287,7 +287,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 			type = RANGE_PRAM;
 		} else if(memcmp(str,"Persistent Memory\n",18) == 0 ) {
 			type = RANGE_PMEM;
-		} else if(memcmp(str,"reserved\n",9) == 0 ) {
+		} else if(strncasecmp(str,"reserved\n",9) == 0 ) {
 			type = RANGE_RESERVED;

It would be better to use two memcmp in two "else if" for "reserved" and "Reserved"

BTW, add one whitespace before the function arguments.

Quoted 10 lines
kexec/arch/i386/crashdump-x86.c +0 -0
 		} else if (memcmp(str, "GART\n", 5) == 0) {
 			gart_start = start;
Signature · 7 lines
2.17.1


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

Thanks
Dave

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

author
#2 lore raw
Quoted 15 lines · Dave Young

Hi Lianbo,

Quoted 12 lines · Lianbo Jiang

When kexec-tools load the kernel and initramfs for kdump, kexec-tools will read /proc/iomem and recreate the e820 ranges for kdump kernel. But it fails to parse the e820 reserved region, because the memcmp() is case sensitive when comparing the string. In fact, it may be "Reserved" or "reserved" in the /proc/iomem, so we use the strncasecmp() instead of the memcmp() to fix it.

---
 kexec/arch/i386/crashdump-x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 14 lines

kexec/arch/i386/crashdump-x86.c static int get_crash_memory_ranges(struct memory_range **range, int *ranges, · line 291

Quoted 11 lines
kexec/arch/i386/crashdump-x86.c +1 -1
index 437e8a8..6669c1a 100644
@@ -287,7 +287,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges,
 			type = RANGE_PRAM;
 		} else if(memcmp(str,"Persistent Memory\n",18) == 0 ) {
 			type = RANGE_PMEM;
-		} else if(memcmp(str,"reserved\n",9) == 0 ) {
+		} else if(strncasecmp(str,"reserved\n",9) == 0 ) {
 			type = RANGE_RESERVED;

It would be better to use two memcmp in two "else if" for "reserved" and "Reserved"

Ok, i will post v2 again later.
Thanks.

Quoted 8 lines

BTW, add one whitespace before the function arguments.

Quoted 6 lines
kexec/arch/i386/crashdump-x86.c +0 -0
 		} else if (memcmp(str, "GART\n", 5) == 0) {
 			gart_start = start;
Signature · 1 line
2.17.1
Quoted 8 lines
Quoted 4 lines

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

Thanks
Dave

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