Skip to contentSkip to conversation

kexec: support parsing the string "Reserved" to get the correct e820 reserved region

PATCH Simon Horman 1 participant 1 message Apr 1, 2020 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): CACi5LpMDGg9JzB7pWY7KdUoV3aFa26Mp8qHR9M6uuEbfhvPcVg@mail.gmail.com

Simon Horman

author Applied
#2 lore raw
Quoted 54 lines · Bhupesh Sharma

Hi Lianbo,

Quoted 46 lines · Lianbo Jiang

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.

---
Note:
Please follow up this commit below about kdump fix.
1ac3e4a57000 ("kdump: fix an error that can not parse the e820 reserved region")

Changes since v1:
[1] use strncasecmp() instead of introducing another 'else-if'( suggested by Bhupesh)

 kexec/arch/i386/kexec-x86-common.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kexec/arch/i386/kexec-x86-common.c +1 -2
index 61ea19380ab2..9303704a0714 100644
@@ -90,7 +90,7 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *ranges
                if (memcmp(str, "System RAM\n", 11) == 0) {
                        type = RANGE_RAM;
                }
-               else if (memcmp(str, "reserved\n", 9) == 0) {
+               else if (strncasecmp(str, "reserved\n", 9) == 0) {
                        type = RANGE_RESERVED;
                }
                else if (memcmp(str, "ACPI Tables\n", 12) == 0) {
--
Quoted 2 lines

2.17.1

Thanks for the changes. V2 seems fine to me, so:

Quoted 1 line

Thanks, applied.

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