Commit 92aa63a5a1bf2e7b0c79e6716d24b76dbbdcf951
Committed by
Linus Torvalds
1 parent
d58831e416
Exists in
master
and in
39 other branches
[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>
Showing 3 changed files with 24 additions and 0 deletions Side-by-side Diff
arch/i386/kernel/setup.c
... | ... | @@ -59,6 +59,9 @@ |
59 | 59 | #include "setup_arch_pre.h" |
60 | 60 | #include <bios_ebda.h> |
61 | 61 | |
62 | +/* Forward Declaration. */ | |
63 | +void __init find_max_pfn(void); | |
64 | + | |
62 | 65 | /* This value is set up by the early boot code to point to the value |
63 | 66 | immediately after the boot time page tables. It contains a *physical* |
64 | 67 | address, and must not be in the .bss segment! */ |
... | ... | @@ -736,6 +739,15 @@ |
736 | 739 | if (to != command_line) |
737 | 740 | to--; |
738 | 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 | 751 | from += 8+7; |
740 | 752 | e820.nr_map = 0; |
741 | 753 | userdef = 1; |
include/linux/bootmem.h
mm/bootmem.c
... | ... | @@ -33,6 +33,14 @@ |
33 | 33 | * dma_get_required_mask(), which uses |
34 | 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 | 44 | /* return the number of _pages_ that will be allocated for the boot bitmap */ |
37 | 45 | unsigned long __init bootmem_bootmap_pages (unsigned long pages) |
38 | 46 | { |