From: "Jan Beulich" Subject: Re: [V1 PATCH 06/11] PVH dom0: construct_dom0 changes Date: Fri, 15 Nov 2013 07:40:21 +0000 Message-ID: <5285DDF50200007800103602@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> <528266C902000078001028F8@nat28.tlf.novell.com> <20131114183418.6f396e00@mantra.us.oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VhE0v-0003fF-64 for xen-devel@lists.xenproject.org; Fri, 15 Nov 2013 07:40:25 +0000 In-Reply-To: <20131114183418.6f396e00@mantra.us.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 15.11.13 at 03:34, Mukesh Rathor wrote: > On Tue, 12 Nov 2013 16:35:05 +0000 > "Jan Beulich" wrote: > >> >>> On 09.11.13 at 02:23, Mukesh Rathor >> >>> wrote: > ...... >> 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. > > Ah right, my bad. > >> 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. > > Actually, the loop will go from v_start->L4 to v_end->L4. The memsets > are clearing the entries before v_start and after v_end. So, I'm > thinking something like: > > clear entries before v_start using memset > clear entries after v_end using memset > > for ( pl4e = l4start + l4_table_offset(v_start); > pl4e <= l4start + l4_table_offset(v_end); > pl4e++) > { > pl3e = map_l3t_from_l4e(*pl4e); > for ( i = 0; i < PAGE_SIZE / sizeof(*pl3e); i++, pl3e++ ) > { > ... > } > > Look ok? Yes, with the leading part getting cleared prior to the loop, and the trailing part after (thus allowing to not re-initialized pl4e in each loop's for()). And the ending condition of course if off by one above: You really want pl4e <= l4start + l4_table_offset(v_end - 1). Jan