From: "Jan Beulich" Subject: Re: [PATCH v3 2/3] xen/pvh: check permissions when adding MMIO regions Date: Thu, 22 Jan 2015 15:43:41 +0000 Message-ID: <54C128BD0200007800058515@mail.emea.novell.com> References: <1421939963-22182-1-git-send-email-roger.pau@citrix.com> <1421939963-22182-3-git-send-email-roger.pau@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YEJv4-0001bD-1H for xen-devel@lists.xenproject.org; Thu, 22 Jan 2015 15:43:42 +0000 In-Reply-To: <1421939963-22182-3-git-send-email-roger.pau@citrix.com> Content-Disposition: inline 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: Andrew Cooper , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org >>> On 22.01.15 at 16:19, wrote: > --- a/xen/arch/x86/domain_build.c > +++ b/xen/arch/x86/domain_build.c > @@ -320,11 +320,24 @@ static __init void pvh_add_mem_mapping(struct domain *d, unsigned long gfn, > { > unsigned long i; > p2m_access_t a; > + mfn_t omfn; > + p2m_type_t t; > int rc; > > - a = p2m_get_hostp2m(d)->default_access; Iirc this is rwx. > for ( i = 0; i < nr_mfns; i++ ) > { > + if ( !iomem_access_permitted(d, mfn + i, mfn + i) ) > + { > + omfn = get_gfn_query_unlocked(d, gfn + i, &t); > + guest_physmap_remove_page(d, gfn + i, mfn_x(omfn), PAGE_ORDER_4K); > + continue; > + } > + > + if ( rangeset_contains_singleton(mmio_ro_ranges, mfn + i) ) > + a = p2m_access_r; > + else > + a = p2m_access_rw; Shouldn't these two therefore be rx and rwx respectively? Or even better ->default_access in the else case (albeit that doesn't really matter here since nothing can have changed that field from its default value)? I'm particularly thinking of ROMs that may be sitting in these areas. Jan