Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] kdump: fix an error that can not parse the e820 reserved region
@ 2018-09-05 13:41 Lianbo Jiang
  2018-09-06  2:30 ` Dave Young
  0 siblings, 1 reply; 3+ messages in thread
From: Lianbo Jiang @ 2018-09-05 13:41 UTC (permalink / raw)
  To: kexec; +Cc: horms, dyoung

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.

Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
---
 kexec/arch/i386/crashdump-x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 437e8a8..6669c1a 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -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;
-- 
2.17.1


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

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

* Re: [PATCH] kdump: fix an error that can not parse the e820 reserved region
  2018-09-05 13:41 [PATCH] kdump: fix an error that can not parse the e820 reserved region Lianbo Jiang
@ 2018-09-06  2:30 ` Dave Young
  2018-09-06  5:20   ` lijiang
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Young @ 2018-09-06  2:30 UTC (permalink / raw)
  To: Lianbo Jiang; +Cc: horms, kexec

Hi Lianbo,

On 09/05/18 at 09:41pm, Lianbo Jiang wrote:
> 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.
> 
> Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
> ---
>  kexec/arch/i386/crashdump-x86.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
> index 437e8a8..6669c1a 100644
> --- a/kexec/arch/i386/crashdump-x86.c
> +++ b/kexec/arch/i386/crashdump-x86.c
> @@ -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. 

>  		} else if (memcmp(str, "GART\n", 5) == 0) {
>  			gart_start = start;
> -- 
> 2.17.1
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec

Thanks
Dave

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

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

* Re: [PATCH] kdump: fix an error that can not parse the e820 reserved region
  2018-09-06  2:30 ` Dave Young
@ 2018-09-06  5:20   ` lijiang
  0 siblings, 0 replies; 3+ messages in thread
From: lijiang @ 2018-09-06  5:20 UTC (permalink / raw)
  To: Dave Young; +Cc: horms, kexec

在 2018年09月06日 10:30, Dave Young 写道:
> Hi Lianbo,
> 
> On 09/05/18 at 09:41pm, Lianbo Jiang wrote:
>> 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.
>>
>> Signed-off-by: Lianbo Jiang <lijiang@redhat.com>
>> ---
>>  kexec/arch/i386/crashdump-x86.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
>> index 437e8a8..6669c1a 100644
>> --- a/kexec/arch/i386/crashdump-x86.c
>> +++ b/kexec/arch/i386/crashdump-x86.c
>> @@ -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.

> BTW, add one whitespace before the function arguments. 
> 
>>  		} else if (memcmp(str, "GART\n", 5) == 0) {
>>  			gart_start = start;
>> -- 
>> 2.17.1
>>
>>
>> _______________________________________________
>> kexec mailing list
>> kexec@lists.infradead.org
>> http://lists.infradead.org/mailman/listinfo/kexec
> 
> Thanks
> Dave
> 

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

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

end of thread, other threads:[~2018-09-06  5:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-05 13:41 [PATCH] kdump: fix an error that can not parse the e820 reserved region Lianbo Jiang
2018-09-06  2:30 ` Dave Young
2018-09-06  5:20   ` lijiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox