diff options
author | Vivek Goyal <vgoyal@in.ibm.com> | 2005-06-25 17:58:18 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-25 19:24:52 -0400 |
commit | 92aa63a5a1bf2e7b0c79e6716d24b76dbbdcf951 (patch) | |
tree | 1f4d49c8e9bf02e834e6af8c1f7d4484d9f76c6e | |
parent | d58831e4163699de204dea199be2e903bf5d6eff (diff) |
[PATCH] kdump: Retrieve saved max pfn
This patch retrieves the max_pfn being used by previous kernel and stores it
in a safe location (saved_max_pfn) before it is overwritten due to user
defined memory map. This pfn is used to make sure that user does not try to
read the physical memory beyond saved_max_pfn.
Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/i386/kernel/setup.c | 12 | ||||
-rw-r--r-- | include/linux/bootmem.h | 4 | ||||
-rw-r--r-- | mm/bootmem.c | 8 |
3 files changed, 24 insertions, 0 deletions
diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c index d88ebdfa6ccd..8d58a053e12e 100644 --- a/arch/i386/kernel/setup.c +++ b/arch/i386/kernel/setup.c | |||
@@ -59,6 +59,9 @@ | |||
59 | #include "setup_arch_pre.h" | 59 | #include "setup_arch_pre.h" |
60 | #include <bios_ebda.h> | 60 | #include <bios_ebda.h> |
61 | 61 | ||
62 | /* Forward Declaration. */ | ||
63 | void __init find_max_pfn(void); | ||
64 | |||
62 | /* This value is set up by the early boot code to point to the value | 65 | /* This value is set up by the early boot code to point to the value |
63 | immediately after the boot time page tables. It contains a *physical* | 66 | immediately after the boot time page tables. It contains a *physical* |
64 | address, and must not be in the .bss segment! */ | 67 | address, and must not be in the .bss segment! */ |
@@ -736,6 +739,15 @@ static void __init parse_cmdline_early (char ** cmdline_p) | |||
736 | if (to != command_line) | 739 | if (to != command_line) |
737 | to--; | 740 | to--; |
738 | if (!memcmp(from+7, "exactmap", 8)) { | 741 | if (!memcmp(from+7, "exactmap", 8)) { |
742 | #ifdef CONFIG_CRASH_DUMP | ||
743 | /* If we are doing a crash dump, we | ||
744 | * still need to know the real mem | ||
745 | * size before original memory map is | ||
746 | * reset. | ||
747 | */ | ||
748 | find_max_pfn(); | ||
749 | saved_max_pfn = max_pfn; | ||
750 | #endif | ||
739 | from += 8+7; | 751 | from += 8+7; |
740 | e820.nr_map = 0; | 752 | e820.nr_map = 0; |
741 | userdef = 1; | 753 | userdef = 1; |
diff --git a/include/linux/bootmem.h b/include/linux/bootmem.h index 500f451ce0c0..82bd8842d11c 100644 --- a/include/linux/bootmem.h +++ b/include/linux/bootmem.h | |||
@@ -22,6 +22,10 @@ extern unsigned long min_low_pfn; | |||
22 | */ | 22 | */ |
23 | extern unsigned long max_pfn; | 23 | extern unsigned long max_pfn; |
24 | 24 | ||
25 | #ifdef CONFIG_CRASH_DUMP | ||
26 | extern unsigned long saved_max_pfn; | ||
27 | #endif | ||
28 | |||
25 | /* | 29 | /* |
26 | * node_bootmem_map is a map pointer - the bits represent all physical | 30 | * node_bootmem_map is a map pointer - the bits represent all physical |
27 | * memory pages (including holes) on the node. | 31 | * memory pages (including holes) on the node. |
diff --git a/mm/bootmem.c b/mm/bootmem.c index f82f7aebbee3..45275f1f8947 100644 --- a/mm/bootmem.c +++ b/mm/bootmem.c | |||
@@ -33,6 +33,14 @@ EXPORT_SYMBOL(max_pfn); /* This is exported so | |||
33 | * dma_get_required_mask(), which uses | 33 | * dma_get_required_mask(), which uses |
34 | * it, can be an inline function */ | 34 | * it, can be an inline function */ |
35 | 35 | ||
36 | #ifdef CONFIG_CRASH_DUMP | ||
37 | /* | ||
38 | * If we have booted due to a crash, max_pfn will be a very low value. We need | ||
39 | * to know the amount of memory that the previous kernel used. | ||
40 | */ | ||
41 | unsigned long saved_max_pfn; | ||
42 | #endif | ||
43 | |||
36 | /* return the number of _pages_ that will be allocated for the boot bitmap */ | 44 | /* return the number of _pages_ that will be allocated for the boot bitmap */ |
37 | unsigned long __init bootmem_bootmap_pages (unsigned long pages) | 45 | unsigned long __init bootmem_bootmap_pages (unsigned long pages) |
38 | { | 46 | { |