Re: [PATCH] kexec: support parsing the string "Reserved" to get the correct e820 reserved region

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



在 2020年02月13日 03:46, Bhupesh Sharma 写道:
> Hi Lianbo,
> 
> Thanks for the patch.
> 
> On Wed, Feb 12, 2020 at 6:27 PM Lianbo Jiang <lijiang@xxxxxxxxxx> wrote:
>>
>> When loading kernel and initramfs for kexec, kexec-tools could get the
>> e820 reserved region from "/proc/iomem" in order to rebuild the e820
>> ranges for kexec kernel, but there may be the string "Reserved" in the
>> "/proc/iomem", which caused the failure of parsing. For example:
>>
>>  #cat /proc/iomem|grep -i reserved
>> 00000000-00000fff : Reserved
>> 7f338000-7f34dfff : Reserved
>> 7f3cd000-8fffffff : Reserved
>> f17f0000-f17f1fff : Reserved
>> fe000000-ffffffff : Reserved
>>
>> Currently, kexec-tools can not handle the above case because the memcmp()
>> is case sensitive when comparing the string.
>>
>> So, let's fix this corner and make sure that the string "reserved" and
>> "Reserved" in the "/proc/iomem" are both parsed appropriately.
>>
>> Signed-off-by: Lianbo Jiang <lijiang@xxxxxxxxxx>
>> ---
>> Note:
>> Please follow up this commit below about kdump fix.
>> 1ac3e4a57000 ("kdump: fix an error that can not parse the e820 reserved region")
>>
>>  kexec/arch/i386/kexec-x86-common.c | 3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/kexec/arch/i386/kexec-x86-common.c b/kexec/arch/i386/kexec-x86-common.c
>> index 61ea19380ab2..86bcc8c0677e 100644
>> --- a/kexec/arch/i386/kexec-x86-common.c
>> +++ b/kexec/arch/i386/kexec-x86-common.c
>> @@ -93,6 +93,9 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
>>                 else if (memcmp(str, "reserved\n", 9) == 0) {
>>                         type = RANGE_RESERVED;
>>                 }
>> +               else if (memcmp(str, "Reserved\n", 9) == 0) {
>> +                       type = RANGE_RESERVED;
>> +               }
> 
> Instead of introducing another 'else-if' case here, can we use
> strncasecmp() instead.
> 
> It  compares the two input strings (say s1 and s2), ignoring the case
> of the characters. Also it only compares the first n bytes of s1 (so
> the format is the same as memcmp).
> 
> In this way, we can be sure to future-proof the kexec-tools code check
> from future notation of the "Reserved" field in terms of the case used
> to denote the "Reserved" string.
> 
> What's your view on the same?
> 
Thanks for your comment, Bhupesh.

I have no preference about this, both are good to me. 

If no one disagrees with this suggestion, I will change to the strncasecmp()
and post v2 later. Any other reviewers?

Lianbo

> Regards,
> Bhupesh
> 
>>                 else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
>>                         type = RANGE_ACPI;
>>                 }
>> --
>> 2.17.1
>>
>>
>> _______________________________________________
>> kexec mailing list
>> kexec@xxxxxxxxxxxxxxxxxxx
>> http://lists.infradead.org/mailman/listinfo/kexec
>>
> 


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




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux