Explorar el Código

xen/balloon: make sure we only include remaining extra ram

If the user specifies mem= on the kernel command line, some or all
of the extra memory E820 region may be clipped away, so make sure
we don't try to add more extra memory than exists in E820.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Jeremy Fitzhardinge hace 14 años
padre
commit
66946f6767
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  1. 5 2
      drivers/xen/balloon.c

+ 5 - 2
drivers/xen/balloon.c

@@ -50,6 +50,7 @@
 #include <asm/pgtable.h>
 #include <asm/pgtable.h>
 #include <asm/uaccess.h>
 #include <asm/uaccess.h>
 #include <asm/tlb.h>
 #include <asm/tlb.h>
+#include <asm/e820.h>
 
 
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypervisor.h>
 #include <asm/xen/hypercall.h>
 #include <asm/xen/hypercall.h>
@@ -391,7 +392,7 @@ static struct notifier_block xenstore_notifier;
 
 
 static int __init balloon_init(void)
 static int __init balloon_init(void)
 {
 {
-	unsigned long pfn;
+	unsigned long pfn, extra_pfn_end;
 	struct page *page;
 	struct page *page;
 
 
 	if (!xen_pv_domain())
 	if (!xen_pv_domain())
@@ -412,8 +413,10 @@ static int __init balloon_init(void)
 	register_balloon(&balloon_sysdev);
 	register_balloon(&balloon_sysdev);
 
 
 	/* Initialise the balloon with excess memory space. */
 	/* Initialise the balloon with excess memory space. */
+	extra_pfn_end = min(e820_end_of_ram_pfn(),
+			    (unsigned long)PFN_DOWN(xen_extra_mem_start + xen_extra_mem_size));
 	for (pfn = PFN_UP(xen_extra_mem_start);
 	for (pfn = PFN_UP(xen_extra_mem_start);
-	     pfn < PFN_DOWN(xen_extra_mem_start + xen_extra_mem_size);
+	     pfn < extra_pfn_end;
 	     pfn++) {
 	     pfn++) {
 		page = pfn_to_page(pfn);
 		page = pfn_to_page(pfn);
 		/* totalram_pages doesn't include the boot-time
 		/* totalram_pages doesn't include the boot-time