From: Tim Deegan Subject: Re: [PATCH v2 2/3] xen/pvh: check permissions when adding MMIO regions Date: Thu, 22 Jan 2015 16:24:01 +0100 Message-ID: <20150122152401.GB98445@deinos.phlegethon.org> References: <1421773534-15752-1-git-send-email-roger.pau@citrix.com> <1421773534-15752-3-git-send-email-roger.pau@citrix.com> <54BE9C35.7010800@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YEJc4-0007XS-GK for xen-devel@lists.xenproject.org; Thu, 22 Jan 2015 15:24:06 +0000 Content-Disposition: inline In-Reply-To: <54BE9C35.7010800@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: Andrew Cooper Cc: xen-devel@lists.xenproject.org, Jan Beulich , Roger Pau Monne List-Id: xen-devel@lists.xenproject.org At 18:19 +0000 on 20 Jan (1421774373), Andrew Cooper wrote: > On 20/01/15 17:05, Roger Pau Monne wrote: > > Check that MMIO regions added to PVH Dom0 are allowed. Previously a PVH= Dom0 > > would have access to the full MMIO range. > > > > Signed-off-by: Roger Pau Monn=E9 > > Cc: Jan Beulich > > Cc: Andrew Cooper > > --- > > Changes since v1: > > - Use the newly introduced p2m_access_t to set the access type. > > - Don't add a next label. > > --- > > xen/arch/x86/domain_build.c | 17 +++++++++++++++-- > > 1 file changed, 15 insertions(+), 2 deletions(-) > > > > diff --git a/xen/arch/x86/domain_build.c b/xen/arch/x86/domain_build.c > > index f687c78..41d2541 100644 > > --- a/xen/arch/x86/domain_build.c > > +++ b/xen/arch/x86/domain_build.c > > @@ -319,12 +319,25 @@ static __init void pvh_add_mem_mapping(struct dom= ain *d, unsigned long gfn, > > unsigned long mfn, unsigned lon= g nr_mfns) > > { > > unsigned long i; > > + mfn_t omfn; > > + p2m_type_t t; > > + p2m_access_t a; > > int rc; > > = > > for ( i =3D 0; i < nr_mfns; i++ ) > > { > > - if ( (rc =3D set_mmio_p2m_entry(d, gfn + i, _mfn(mfn + i), > > - p2m_get_hostp2m(d)->default_acce= ss)) ) > > + if ( !iomem_access_permitted(d, mfn + i, mfn + i) ) { > > + omfn =3D get_gfn_query_unlocked(d, gfn + i, &t); > > + guest_physmap_remove_page(d, gfn + i, mfn_x(omfn), PAGE_OR= DER_4K); > > + continue; > > + } > = > This suggests a design flaw (possibly pre-existing). We should not be > removing physmap entries in pvh_add_mem_mapping(), nor should we be a > position to need to revoke physmap entries during domain build. > = > If there is anything needing revoking at this stage, it should not have > been added earlier. +1. ISTR saying something like this before. = Tim.