Skip to content

Commit

Permalink
x86, kexec, 64bit: Only set ident mapping for ram.
Browse files Browse the repository at this point in the history
We should set mappings only for usable memory ranges under max_pfn
Otherwise causes same problem that is fixed by

	x86, mm: Only direct map addresses that are marked as E820_RAM

This patch exposes pfn_mapped array, and only sets ident mapping for ranges
in that array.

This patch relies on new kernel_ident_mapping_init that could handle existing
pgd/pud between different calls.

Signed-off-by: Yinghai Lu <yinghai@kernel.org>
Link: http://lkml.kernel.org/r/1359058816-7615-25-git-send-email-yinghai@kernel.org
Cc: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
  • Loading branch information
Yinghai Lu authored and H. Peter Anvin committed Jan 29, 2013
1 parent 9ebdc79 commit 0e691cf
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
4 changes: 4 additions & 0 deletions arch/x86/include/asm/page.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@

struct page;

#include <linux/range.h>
extern struct range pfn_mapped[];
extern int nr_pfn_mapped;

static inline void clear_user_page(void *page, unsigned long vaddr,
struct page *pg)
{
Expand Down
13 changes: 9 additions & 4 deletions arch/x86/kernel/machine_kexec_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ static int init_pgtable(struct kimage *image, unsigned long start_pgtable)

level4p = (pgd_t *)__va(start_pgtable);
clear_page(level4p);
result = kernel_ident_mapping_init(&info, level4p,
0, max_pfn << PAGE_SHIFT);
if (result)
return result;
for (i = 0; i < nr_pfn_mapped; i++) {
mstart = pfn_mapped[i].start << PAGE_SHIFT;
mend = pfn_mapped[i].end << PAGE_SHIFT;

result = kernel_ident_mapping_init(&info,
level4p, mstart, mend);
if (result)
return result;
}

/*
* segments's mem ranges could be outside 0 ~ max_pfn,
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ static int __meminit split_mem_range(struct map_range *mr, int nr_range,
return nr_range;
}

static struct range pfn_mapped[E820_X_MAX];
static int nr_pfn_mapped;
struct range pfn_mapped[E820_X_MAX];
int nr_pfn_mapped;

static void add_pfn_range_mapped(unsigned long start_pfn, unsigned long end_pfn)
{
Expand Down

0 comments on commit 0e691cf

Please sign in to comment.