From: "Jan Beulich" Subject: [PATCH] x86: restore reserving of IO-APIC pages in XENMEM_machine_memory_map output Date: Thu, 02 Oct 2014 14:31:04 +0100 Message-ID: <542D6FB8020000780003BFDF@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartCAFFBE88.0__=" Return-path: Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1XZgTL-0004tX-7F for xen-devel@lists.xenproject.org; Thu, 02 Oct 2014 13:31:07 +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. --=__PartCAFFBE88.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Commit d1222afda4 ("x86: allow Dom0 read-only access to IO-APICs") had an unintended side effect: By no longer adding IO-APIC pages to Dom0's iomem_caps these also no longer get reported as reserved in the machine memory map presented to it (which got added there intentionally by commit b8a456caed ["x86: improve reporting through XENMEM_machine_memory_map"] because many BIOSes fail to add these). Signed-off-by: Jan Beulich --- Treating everything in mmio_ro_ranges this way doesn't appear to be a suitable option: Certain PCI device ranges (most notably MSI-X control pages) get tracked there as well, and hence this rangeset isn't really stable across the lifetime of a system and thus shouldn't be used for purposes like the one here. --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -122,6 +122,7 @@ #include #include #include +#include #include =20 /* Mapping of the fixmap space needed early. */ @@ -4481,10 +4482,9 @@ struct memory_map_context struct xen_memory_map map; }; =20 -static int handle_iomem_range(unsigned long s, unsigned long e, void *p) +static int _handle_iomem_range(unsigned long s, unsigned long e, + struct memory_map_context *ctxt) { - struct memory_map_context *ctxt =3D p; - if ( s > ctxt->s ) { e820entry_t ent; @@ -4507,6 +4507,31 @@ static int handle_iomem_range(unsigned l return 0; } =20 +static int handle_iomem_range(unsigned long s, unsigned long e, void *p) +{ + int err =3D 0; + + do { + unsigned long low =3D -1UL; + unsigned int i; + + for ( i =3D 0; i < nr_ioapics; ++i ) + { + unsigned long mfn =3D paddr_to_pfn(mp_ioapics[i].mpc_apicaddr)= ; + + if ( mfn >=3D s && mfn <=3D e && mfn < low ) + low =3D mfn; + } + if ( !(low + 1) ) + break; + if ( s < low ) + err =3D _handle_iomem_range(s, low - 1, p); + s =3D low + 1; + } while ( !err ); + + return err || s > e ? err : _handle_iomem_range(s, e, p); +} + int xenmem_add_to_physmap_one( struct domain *d, unsigned int space, @@ -4734,7 +4759,7 @@ long arch_memory_op(unsigned long cmd, X { unsigned long s =3D PFN_DOWN(e820.map[i].addr); =20 - if ( s ) + if ( s > ctxt.s ) { rc =3D rangeset_report_ranges(current->domain->iomem_caps,= ctxt.s, s - 1, --=__PartCAFFBE88.0__= Content-Type: text/plain; name="x86-machine-memmap-IO-APIC.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-machine-memmap-IO-APIC.patch" x86: restore reserving of IO-APIC pages in XENMEM_machine_memory_map = output=0A=0ACommit d1222afda4 ("x86: allow Dom0 read-only access to = IO-APICs") had=0Aan unintended side effect: By no longer adding IO-APIC = pages to Dom0's=0Aiomem_caps these also no longer get reported as reserved = in the machine=0Amemory map presented to it (which got added there = intentionally by=0Acommit b8a456caed ["x86: improve reporting through=0AXEN= MEM_machine_memory_map"] because many BIOSes fail to add these).=0A=0ASigne= d-off-by: Jan Beulich =0A---=0ATreating everything in = mmio_ro_ranges this way doesn't appear to be a=0Asuitable option: Certain = PCI device ranges (most notably MSI-X control=0Apages) get tracked there = as well, and hence this rangeset isn't really=0Astable across the lifetime = of a system and thus shouldn't be used for=0Apurposes like the one = here.=0A=0A--- a/xen/arch/x86/mm.c=0A+++ b/xen/arch/x86/mm.c=0A@@ -122,6 = +122,7 @@=0A #include =0A #include =0A #include = =0A+#include =0A #include =0A =0A = /* Mapping of the fixmap space needed early. */=0A@@ -4481,10 +4482,9 @@ = struct memory_map_context=0A struct xen_memory_map map;=0A };=0A = =0A-static int handle_iomem_range(unsigned long s, unsigned long e, void = *p)=0A+static int _handle_iomem_range(unsigned long s, unsigned long = e,=0A+ struct memory_map_context *ctxt)=0A = {=0A- struct memory_map_context *ctxt =3D p;=0A-=0A if ( s > = ctxt->s )=0A {=0A e820entry_t ent;=0A@@ -4507,6 +4507,31 @@ = static int handle_iomem_range(unsigned l=0A return 0;=0A }=0A = =0A+static int handle_iomem_range(unsigned long s, unsigned long e, void = *p)=0A+{=0A+ int err =3D 0;=0A+=0A+ do {=0A+ unsigned long = low =3D -1UL;=0A+ unsigned int i;=0A+=0A+ for ( i =3D 0; i < = nr_ioapics; ++i )=0A+ {=0A+ unsigned long mfn =3D = paddr_to_pfn(mp_ioapics[i].mpc_apicaddr);=0A+=0A+ if ( mfn >=3D = s && mfn <=3D e && mfn < low )=0A+ low =3D mfn;=0A+ = }=0A+ if ( !(low + 1) )=0A+ break;=0A+ if ( s < = low )=0A+ err =3D _handle_iomem_range(s, low - 1, p);=0A+ = s =3D low + 1;=0A+ } while ( !err );=0A+=0A+ return err || s > e ? = err : _handle_iomem_range(s, e, p);=0A+}=0A+=0A int xenmem_add_to_physmap_o= ne(=0A struct domain *d,=0A unsigned int space,=0A@@ -4734,7 = +4759,7 @@ long arch_memory_op(unsigned long cmd, X=0A {=0A = unsigned long s =3D PFN_DOWN(e820.map[i].addr);=0A =0A- if = ( s )=0A+ if ( s > ctxt.s )=0A {=0A = rc =3D rangeset_report_ranges(current->domain->iomem_caps,=0A = ctxt.s, s - 1,=0A --=__PartCAFFBE88.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 --=__PartCAFFBE88.0__=--