From: Tim Deegan Subject: Re: [PATCH v2] xen: allow guest_remove_page to remove p2m_mmio_direct pages Date: Thu, 19 Jun 2014 17:23:55 +0200 Message-ID: <20140619152355.GC87916@deinos.phlegethon.org> References: <1403189139-16835-1-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WxeC1-0001sk-Df for xen-devel@lists.xenproject.org; Thu, 19 Jun 2014 15:24:02 +0000 Content-Disposition: inline In-Reply-To: <1403189139-16835-1-git-send-email-roger.pau@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Roger Pau Monne Cc: xen-devel@lists.xenproject.org, Keir Fraser , Ian Jackson , Ian Campbell , Jan Beulich List-Id: xen-devel@lists.xenproject.org At 16:45 +0200 on 19 Jun (1403192739), Roger Pau Monne wrote: > IF a guest tries to do a foreign/grant mapping in a memory region > marked as p2m_mmio_direct Xen will complain with the following > message: > = > (XEN) memory.c:241:d0v0 Bad page free for domain 0 > = > Albeit the mapping will succeed. This is specially problematic for PVH > Dom0, in which we map all the e820 holes and memory up to 4GB as > p2m_mmio_direct. > = > In order to deal with it, add a special casing for p2m_mmio_direct > regions in guest_remove_page if the domain is a hardware domain, that > calls clear_mmio_p2m_entry in order to remove the mappings. > = > Signed-off-by: Roger Pau Monn=E9 Acked-by: Tim Deegan as being an improvement on what's there right now. But as I said, I think code that relies on this is probably doing the wrong thing -- in this case having MMIOmaps og all non-RAM areas seems wrong; dom0 ought to know what addresses are really hardware and map them appropriately. Tim. > --- > Changes since v1: > - Remove the is_hardware_domain check. > --- > xen/common/memory.c | 6 ++++++ > 1 files changed, 6 insertions(+), 0 deletions(-) > = > diff --git a/xen/common/memory.c b/xen/common/memory.c > index 257f4b0..c2dd31b 100644 > --- a/xen/common/memory.c > +++ b/xen/common/memory.c > @@ -204,6 +204,12 @@ int guest_remove_page(struct domain *d, unsigned lon= g gmfn) > p2m_mem_paging_drop_page(d, gmfn, p2mt); > return 1; > } > + if ( p2mt =3D=3D p2m_mmio_direct ) > + { > + clear_mmio_p2m_entry(d, gmfn); > + put_gfn(d, gmfn); > + return 1; > + } > #else > mfn =3D gmfn_to_mfn(d, gmfn); > #endif > -- = > 1.7.7.5 (Apple Git-26) > =