From: "Jan Beulich" Subject: Re: [V1 PATCH 06/11] PVH dom0: construct_dom0 changes Date: Tue, 12 Nov 2013 16:35:05 +0000 Message-ID: <528266C902000078001028F8@nat28.tlf.novell.com> References: <1383960215-22444-1-git-send-email-mukesh.rathor@oracle.com> <1383960215-22444-7-git-send-email-mukesh.rathor@oracle.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 1VgGvo-0002B0-8D for xen-devel@lists.xenproject.org; Tue, 12 Nov 2013 16:35:12 +0000 In-Reply-To: <1383960215-22444-7-git-send-email-mukesh.rathor@oracle.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: Mukesh Rathor Cc: xen-devel , keir.xen@gmail.com, tim@xen.org List-Id: xen-devel@lists.xenproject.org >>> On 09.11.13 at 02:23, Mukesh Rathor wrote: > +/* > + * Set the 1:1 map for all non-RAM regions for dom 0. Thus, dom0 will have > + * the entire io region mapped in the EPT/NPT. > + * > + * PVH FIXME: The following doesn't map MMIO ranges when they sit above the All other fixme-s of yours so far used lower case. Please - be consistent. > +static __init void pvh_fixup_page_tables_for_hap(struct vcpu *v, > + unsigned long v_start, > + unsigned long v_end) > +{ > + int i, j, k; > + l4_pgentry_t *pl4e, *l4start; > + l3_pgentry_t *pl3e; > + l2_pgentry_t *pl2e; > + l1_pgentry_t *pl1e; > + unsigned long cr3_pfn; > + > + ASSERT(paging_mode_enabled(v->domain)); > + > + l4start = map_domain_page(pagetable_get_pfn(v->arch.guest_table)); > + > + /* Give the guest a clean slate to start with */ > + pl4e = l4start + l4_table_offset(v_start); > + memset(l4start, 0, (unsigned long)pl4e - (unsigned long)l4start); > + > + pl4e = l4start + l4_table_offset(v_end) + 1; > + if ( (unsigned long)pl4e & (PAGE_SIZE - 1) ) > + memset(pl4e, 0, PAGE_SIZE - ((unsigned long)pl4e & (PAGE_SIZE - 1))); These look more complicated than necessary (largely due to the casts), but be it that way. > + pl4e = l4start + l4_table_offset(v_start); >... > + *pl4e = l4e_from_pfn(get_gpfn_from_mfn(l4e_get_pfn(*pl4e)), > + l4e_get_flags(*pl4e)); But this one I told before needs to be in a loop. You must not make assumptions on guest virtual address space layout, and hence you must not assume none of the initial mapping crosses an L4 boundary. And once these are in a loop, getting the earlier two loops simplified (using l4e_empty() rather than plain memset()) and ordered properly (the head part before the main loop, the tail part after) will be almost obvious legibility cleanups. Jan