direct-io.hg

changeset 14372:a1daade92952

[LINUX] Kexec: Ensure that pages allocated for kexec have MFNs which are within
the required limits.

Previously we were lucky since most dom0 pages would be low enough but now Xen
is more aggressive in giving out higher MFNs when it can.

Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
author Ian Campbell <ian.campbell@xensource.com>
date Wed Mar 14 16:39:32 2007 +0000 (2007-03-14)
parents fa3d25355aa2
children e6c31944916b
files linux-2.6-xen-sparse/kernel/kexec.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/kernel/kexec.c	Wed Mar 14 16:36:04 2007 +0000
     1.2 +++ b/linux-2.6-xen-sparse/kernel/kexec.c	Wed Mar 14 16:39:32 2007 +0000
     1.3 @@ -330,13 +330,27 @@ static int kimage_is_destination_range(s
     1.4  	return 0;
     1.5  }
     1.6  
     1.7 -static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order)
     1.8 +static struct page *kimage_alloc_pages(gfp_t gfp_mask, unsigned int order, unsigned long limit)
     1.9  {
    1.10  	struct page *pages;
    1.11  
    1.12  	pages = alloc_pages(gfp_mask, order);
    1.13  	if (pages) {
    1.14  		unsigned int count, i;
    1.15 +#ifdef CONFIG_XEN
    1.16 +		int address_bits;
    1.17 +
    1.18 +		if (limit == ~0UL)
    1.19 +			address_bits = BITS_PER_LONG;
    1.20 +		else
    1.21 +			address_bits = long_log2(limit);
    1.22 +
    1.23 +		if (xen_create_contiguous_region((unsigned long)page_address(pages),
    1.24 +						 order, address_bits) < 0) {
    1.25 +			__free_pages(pages, order);
    1.26 +			return NULL;
    1.27 +		}
    1.28 +#endif
    1.29  		pages->mapping = NULL;
    1.30  		set_page_private(pages, order);
    1.31  		count = 1 << order;
    1.32 @@ -355,6 +369,9 @@ static void kimage_free_pages(struct pag
    1.33  	count = 1 << order;
    1.34  	for (i = 0; i < count; i++)
    1.35  		ClearPageReserved(page + i);
    1.36 +#ifdef CONFIG_XEN
    1.37 +	xen_destroy_contiguous_region((unsigned long)page_address(page), order);
    1.38 +#endif
    1.39  	__free_pages(page, order);
    1.40  }
    1.41  
    1.42 @@ -400,7 +417,7 @@ static struct page *kimage_alloc_normal_
    1.43  	do {
    1.44  		unsigned long pfn, epfn, addr, eaddr;
    1.45  
    1.46 -		pages = kimage_alloc_pages(GFP_KERNEL, order);
    1.47 +		pages = kimage_alloc_pages(GFP_KERNEL, order, KEXEC_CONTROL_MEMORY_LIMIT);
    1.48  		if (!pages)
    1.49  			break;
    1.50  		pfn   = kexec_page_to_pfn(pages);
    1.51 @@ -709,7 +726,7 @@ static struct page *kimage_alloc_page(st
    1.52  		kimage_entry_t *old;
    1.53  
    1.54  		/* Allocate a page, if we run out of memory give up */
    1.55 -		page = kimage_alloc_pages(gfp_mask, 0);
    1.56 +		page = kimage_alloc_pages(gfp_mask, 0, KEXEC_SOURCE_MEMORY_LIMIT);
    1.57  		if (!page)
    1.58  			return NULL;
    1.59  		/* If the page cannot be used file it away */