From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?windows-1252?Q?Roger_Pau_Monn=E9?= Subject: Re: [PATCH v3 2/3] xen/pvh: check permissions when adding MMIO regions Date: Fri, 23 Jan 2015 12:29:06 +0100 Message-ID: <54C23082.4090605@citrix.com> References: <1421939963-22182-1-git-send-email-roger.pau@citrix.com> <1421939963-22182-3-git-send-email-roger.pau@citrix.com> <54C128BD0200007800058515@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YEcQI-0002zo-Pc for xen-devel@lists.xenproject.org; Fri, 23 Jan 2015 11:29:10 +0000 In-Reply-To: <54C128BD0200007800058515@mail.emea.novell.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: Jan Beulich Cc: Andrew Cooper , xen-devel@lists.xenproject.org List-Id: xen-devel@lists.xenproject.org El 22/01/15 a les 16.43, Jan Beulich ha escrit: >>>> 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. Yes, it should be rx and rwx. I would prefer to use the explicit types. IMHO it's easier to understand to which access type it's set (without having to dig to what value p2m_get_hostp2m(d)->default_access is set). Roger.