Re: [PATCH] x86 e820: only void usable memory areas in memmap=exactmap case

Yinghai Lu
2013-01-15T04:45:47Z

[-- Attachment #1: Type: text/plain, Size: 1508 bytes --]

On Mon, Jan 14, 2013 at 4:54 PM, Thomas Renninger <trenn@suse.de> wrote:
> On Monday, January 14, 2013 11:04:36 AM Yinghai Lu wrote:
>> On Mon, Jan 14, 2013 at 7:05 AM, Thomas Renninger <trenn@suse.de> wrote:
>> > What is this for?:
>> > @@ -871,6 +879,11 @@ static int __init parse_memmap_one(char
>> >
>> > userdef = 1;
>> > if (*p == '@') {
>> >
>> > start_at = memparse(p+1, &p);
>> >
>> > + if (exactusablemap_parsed) {
>> > + /* remove all range with other types */
>> > + e820_remove_range(start_at, mem_size,
>> > + E820_RAM, 0);
>> > + }
>> >
>> > e820_add_region(start_at, mem_size, E820_RAM);
>> >
>> > } else if (*p == '#') {
>> >
>> > start_at = memparse(p+1, &p);
>>
>> remove all old renges before add E820_RAM, otherwise new add E820
>> ranges could be ignored.
> But this is intended?
> kexec must never request reserved memory to be used as ordinary E820_RAM
> by the kdump kernel.
> This also reverts what exactusablemap is all about:
> Keep all reserved memory ranges of the original BIOS map.
>
> Above would again wrongly remove the mmconf and other reserved regions
> if kexec passes memmap=exactuseablemap,x@y
>
> From what I can see the patch looks fine, but above part should
> simply be left out.

then, I would like to rename it to resetusablemap instead.

like attached.

Thanks

Yinghai

[-- Attachment #2: e820_resetusablemap.patch --]
[-- Type: application/octet-stream, Size: 1161 bytes --]

---
arch/x86/kernel/e820.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

Index: linux-2.6/arch/x86/kernel/e820.c
===================================================================
--- linux-2.6.orig/arch/x86/kernel/e820.c
+++ linux-2.6/arch/x86/kernel/e820.c
@@ -845,7 +845,7 @@ static int __init parse_memmap_one(char
if (!p)
return -EINVAL;

- if (!strncmp(p, "exactmap", 8)) {
+ if (!strncmp(p, "exactmap", 8) || !strncmp(p, "resetusablemap", 14)) {
if (exactmap_parsed)
return 0;

@@ -858,7 +858,11 @@ static int __init parse_memmap_one(char
*/
saved_max_pfn = e820_end_of_ram_pfn();
#endif
- e820.nr_map = 0;
+ if (!strncmp(p, "resetusablemap", 14)) {
+ /* remove all old E820_RAM ranges */
+ e820_remove_range(0, ULLONG_MAX, E820_RAM, 1);
+ } else
+ e820.nr_map = 0;
userdef = 1;
return 0;
}
@@ -890,6 +894,11 @@ static int __init parse_memmap_opt(char
p = strstr(p, "exactmap");
if (p)
parse_memmap_one("exactmap");
+ else {
+ p = strstr(boot_command_line, "resetusablemap");
+ if (p)
+ parse_memmap_one("resetusablemap");
+ }

while (str) {
char *k = strchr(str, ',');