Re: [PATCH 2/2] x86 e820: Introduce memmap=resetusablemap for kdump usage

Yinghai Lu
2013-01-24T04:07:23Z

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

On Tue, Jan 22, 2013 at 12:06 PM, Yinghai Lu <yinghai@kernel.org> wrote:
> On Tue, Jan 22, 2013 at 8:32 AM, H. Peter Anvin <hpa@zytor.com> wrote:
>>> Again: Please explain what is bad with this solution.
>>> I cannot see a better and more robust way for kdump other than
>>> reserving the original reserved memory areas as declared by the BIOS.
>>
>> It is bad because it creates more complexity than is needed.
>>
>> The whole point is that what we want is simply to switch type 1 to type
>> X, with the sole exceptions being the areas explicitly reserved for the
>> kdump kernel.
>
> Do you prefer to "reserveram" way in attached patch?

Hi, Thomas,

Can you please check attached reserveram version on your setup?

If it is ok, i will put it in for-x86-boot patchset and send it to
Peter for v3.9.

Thanks

Yinghai

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

Subject: [PATCH] x86, mm: Introduce memmap=reserveram

kdump voided the whole original e820 map and half way made
it up via memmap= options passed via kdump boot params again.

But this is conceptionally wrong. The whole original memory ranges
which are declared reserved, ACPI data/nvs or however are not usable
must stay the same and get honored by the kdump kernel.

Therefore memmap=reserveram gets introduced.
kdump passes this one and only the usable e820 ranges are updated to
reserved at first by kernel, then when kdump passes the usable ranges
to use via memmap=x@y parameter(s), kernel will remove reserved range
and add usable range accordingly.

This for example fixes mmconf (extended PCI config access) and
possibly other kernel parts which rely on remapped memory to be
in reserved or ACPI (data/nvs) declared e820 memory areas.

Changelog is from Thomas Renninger, and updated to reserveram

-v2: According to HPA, use reserveram instead of resetusablemap.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>

---
arch/x86/kernel/e820.c | 19 +++++++++++++++++--
1 file changed, 17 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
@@ -836,6 +836,7 @@ static int __init parse_memopt(char *p)
early_param("mem", parse_memopt);

static bool __initdata exactmap_parsed;
+static bool __initdata reserveram_parsed;

static int __init parse_memmap_one(char *p)
{
@@ -845,7 +846,7 @@ static int __init parse_memmap_one(char
if (!p)
return -EINVAL;

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

@@ -858,7 +859,12 @@ static int __init parse_memmap_one(char
*/
saved_max_pfn = e820_end_of_ram_pfn();
#endif
- e820.nr_map = 0;
+ if (!strncmp(p, "reserveram", 10)) {
+ e820_update_range(0, ULLONG_MAX, E820_RAM,
+ E820_RESERVED);
+ reserveram_parsed = true;
+ } else
+ e820.nr_map = 0;
userdef = 1;
return 0;
}
@@ -871,6 +877,10 @@ static int __init parse_memmap_one(char
userdef = 1;
if (*p == '@') {
start_at = memparse(p+1, &p);
+ if (reserveram_parsed) {
+ /* Remove old reserved so new ram could take over. */
+ e820_remove_range(start_at, mem_size, E820_RESERVED, 0);
+ }
e820_add_region(start_at, mem_size, E820_RAM);
} else if (*p == '#') {
start_at = memparse(p+1, &p);
@@ -890,6 +900,11 @@ static int __init parse_memmap_opt(char
p = strstr(p, "exactmap");
if (p)
parse_memmap_one("exactmap");
+ else {
+ p = strstr(boot_command_line, "reserveram");
+ if (p)
+ parse_memmap_one("reserveram");
+ }

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

[-- Attachment #3: Type: text/plain, Size: 143 bytes --]