Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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>

authored by

Vivek Goyal and committed by
Linus Torvalds
92aa63a5 d58831e4

+24
+12
arch/i386/kernel/setup.c
··· 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! */ ··· 739 736 if (to != command_line) 740 737 to--; 741 738 if (!memcmp(from+7, "exactmap", 8)) { 739 + #ifdef CONFIG_CRASH_DUMP 740 + /* If we are doing a crash dump, we 741 + * still need to know the real mem 742 + * size before original memory map is 743 + * reset. 744 + */ 745 + find_max_pfn(); 746 + saved_max_pfn = max_pfn; 747 + #endif 742 748 from += 8+7; 743 749 e820.nr_map = 0; 744 750 userdef = 1;
+4
include/linux/bootmem.h
··· 22 22 */ 23 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 30 * node_bootmem_map is a map pointer - the bits represent all physical 27 31 * memory pages (including holes) on the node.
+8
mm/bootmem.c
··· 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 {