From: "Jan Beulich" Subject: [PATCH] x86: consider modules when cutting off memory Date: Mon, 18 Nov 2013 08:37:15 +0000 Message-ID: <5289DFCB0200007800103E6F@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartC9FA1FAB.0__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1ViKKf-00063e-1J for xen-devel@lists.xenproject.org; Mon, 18 Nov 2013 08:37:21 +0000 List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Keir Fraser 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. --=__PartC9FA1FAB.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The code in question runs after module ranges got already removed from the E820 table, so when determining the new maximum page/PDX we need to explicitly take them into account. Furthermore we need to round up the ending addresses here, in order to fully cover eventual partial trailing pages. Signed-off-by: Jan Beulich --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1013,9 +1013,17 @@ void __init __start_xen(unsigned long mb ASSERT(j); } map_e =3D boot_e820.map[j].addr + boot_e820.map[j].size; - if ( (map_e >> PAGE_SHIFT) < max_page ) + for ( j =3D 0; j < mbi->mods_count; ++j ) { - max_page =3D map_e >> PAGE_SHIFT; + uint64_t end =3D pfn_to_paddr(mod[j].mod_start) + + mod[j].mod_end; + + if ( map_e < end ) + map_e =3D end; + } + if ( PFN_UP(map_e) < max_page ) + { + max_page =3D PFN_UP(map_e); max_pdx =3D pfn_to_pdx(max_page - 1) + 1; } printk(XENLOG_WARNING "Ignoring inaccessible memory = range" --=__PartC9FA1FAB.0__= Content-Type: text/plain; name="x86-memory-cutoff-modules.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-memory-cutoff-modules.patch" x86: consider modules when cutting off memory=0A=0AThe code in question = runs after module ranges got already removed from=0Athe E820 table, so = when determining the new maximum page/PDX we need to=0Aexplicitly take = them into account.=0A=0AFurthermore we need to round up the ending = addresses here, in order to=0Afully cover eventual partial trailing = pages.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/setup.c=0A+++ b/xen/arch/x86/setup.c=0A@@ -1013,9 +1013,17 = @@ void __init __start_xen(unsigned long mb=0A = ASSERT(j);=0A }=0A map_e =3D boot_e820.map[= j].addr + boot_e820.map[j].size;=0A- if ( (map_e >> = PAGE_SHIFT) < max_page )=0A+ for ( j =3D 0; j < mbi->mods_co= unt; ++j )=0A {=0A- max_page =3D map_e = >> PAGE_SHIFT;=0A+ uint64_t end =3D pfn_to_paddr(mod[j].= mod_start) +=0A+ mod[j].mod_end;=0A+=0A+ = if ( map_e < end )=0A+ map_e =3D = end;=0A+ }=0A+ if ( PFN_UP(map_e) < max_page = )=0A+ {=0A+ max_page =3D PFN_UP(map_e);= =0A max_pdx =3D pfn_to_pdx(max_page - 1) + 1;=0A = }=0A printk(XENLOG_WARNING "Ignoring inaccessible= memory range"=0A --=__PartC9FA1FAB.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.xen.org http://lists.xen.org/xen-devel --=__PartC9FA1FAB.0__=--