From: "Jan Beulich" Subject: [PATCH] linux/x86_64: correctly handle mem= reducing memory amount Date: Tue, 01 Dec 2009 10:57:34 +0000 Message-ID: <4B1504AE0200007800022D19@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part4F651D8E.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part4F651D8E.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline When mem=3D is being used to specify a value below the amount a domain got passed from Xen, init_memory_mapping() got called with the higher original value (end_pfn_map), triggering the BUG()s in maddr.h checking PFNs against end_pfn. Written and tested on 2.6.16.60 and made apply to the 2.6.18 tree without further testing. Signed-off-by: Jan Beulich --- sle10sp3-2009-11-27.orig/arch/x86_64/kernel/e820-xen.c 2009-10-01 = 14:16:23.000000000 +0200 +++ sle10sp3-2009-11-27/arch/x86_64/kernel/e820-xen.c 2009-12-01 = 11:31:11.000000000 +0100 @@ -30,12 +30,14 @@ unsigned long end_pfn;=20 EXPORT_SYMBOL(end_pfn); =20 +#ifndef CONFIG_XEN /*=20 * end_pfn only includes RAM, while end_pfn_map includes all e820 = entries. * The direct mapping extends to end_pfn_map, so that we can directly = access * apertures, ACPI and other tables without having to play with fixmaps. */=20 unsigned long end_pfn_map;=20 +#endif =20 /*=20 * Last pfn which the user wants to use. --- sle10sp3-2009-11-27.orig/include/asm-x86_64/proto.h 2009-08-10 = 10:13:16.000000000 +0200 +++ sle10sp3-2009-11-27/include/asm-x86_64/proto.h 2009-12-01 = 11:30:58.000000000 +0100 @@ -75,7 +75,11 @@ extern void load_gs_index(unsigned gs); extern void stop_timer_interrupt(void); extern void main_timer_handler(struct pt_regs *regs); =20 +#ifndef CONFIG_XEN extern unsigned long end_pfn_map;=20 +#else +#define end_pfn_map end_pfn +#endif =20 extern void show_trace(struct task_struct *, struct pt_regs *, unsigned = long * rsp); extern void show_registers(struct pt_regs *regs); --=__Part4F651D8E.0__= Content-Type: text/plain; name="xenlinux-x86_64-mem-reduction.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xenlinux-x86_64-mem-reduction.patch" Subject: correctly handle mem=3D reducing memory amount=0A=0AWhen mem=3D = is being used to specify a value below the amount a domain=0Agot passed = from Xen, init_memory_mapping() got called with the higher=0Aoriginal = value (end_pfn_map), triggering the BUG()s in maddr.h=0Achecking PFNs = against end_pfn.=0A=0AWritten and tested on 2.6.16.60 and made apply to = the 2.6.18 tree=0Awithout further testing.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- sle10sp3-2009-11-27.orig/arch/x86_64/kernel/= e820-xen.c 2009-10-01 14:16:23.000000000 +0200=0A+++ sle10sp3-2009-11-= 27/arch/x86_64/kernel/e820-xen.c 2009-12-01 11:31:11.000000000 = +0100=0A@@ -30,12 +30,14 @@=0A unsigned long end_pfn; =0A EXPORT_SYMBOL(end= _pfn);=0A =0A+#ifndef CONFIG_XEN=0A /* =0A * end_pfn only includes RAM, = while end_pfn_map includes all e820 entries.=0A * The direct mapping = extends to end_pfn_map, so that we can directly access=0A * apertures, = ACPI and other tables without having to play with fixmaps.=0A */ =0A = unsigned long end_pfn_map; =0A+#endif=0A =0A /* =0A * Last pfn which the = user wants to use.=0A--- sle10sp3-2009-11-27.orig/include/asm-x86_64/proto.= h 2009-08-10 10:13:16.000000000 +0200=0A+++ sle10sp3-2009-11-27/inclu= de/asm-x86_64/proto.h 2009-12-01 11:30:58.000000000 +0100=0A@@ -75,7 = +75,11 @@ extern void load_gs_index(unsigned gs);=0A extern void stop_timer= _interrupt(void);=0A extern void main_timer_handler(struct pt_regs = *regs);=0A =0A+#ifndef CONFIG_XEN=0A extern unsigned long end_pfn_map; = =0A+#else=0A+#define end_pfn_map end_pfn=0A+#endif=0A =0A extern void = show_trace(struct task_struct *, struct pt_regs *, unsigned long * = rsp);=0A extern void show_registers(struct pt_regs *regs);=0A --=__Part4F651D8E.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__Part4F651D8E.0__=--