From mboxrd@z Thu Jan 1 00:00:00 1970 From: George Dunlap Subject: Re: [V8 PATCH 2/8] pvh dom0: construct_dom0 changes Date: Wed, 26 Mar 2014 19:05:15 +0000 Message-ID: <533324EB.2030409@eu.citrix.com> References: <1395452357-1598-1-git-send-email-mukesh.rathor@oracle.com> <1395452357-1598-3-git-send-email-mukesh.rathor@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" 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 1WSt8o-0001IM-E6 for xen-devel@lists.xenproject.org; Wed, 26 Mar 2014 19:05:34 +0000 In-Reply-To: <1395452357-1598-3-git-send-email-mukesh.rathor@oracle.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: Mukesh Rathor , xen-devel@lists.xenproject.org Cc: keir.xen@gmail.com, tim@xen.org, JBeulich@suse.com List-Id: xen-devel@lists.xenproject.org On 03/22/2014 01:39 AM, Mukesh Rathor wrote: > This patch changes construct_dom0() to boot in PVH mode. [Apologies in advance for not following the previous review cycles.] This needs a better description. Minimally: * Call guest_physmap_add_range rather than simple physmap setting for pvh guests. * Map all non-RAM regions for dom0 as 1:1 up to 4GiB, so dom0 has IO memory mapped. * If pvh was specified, make sure that dom0 supports pvh mode * Allocate p2m pages, copying calculation from toolstack * Make space for the shared info in the p2m (?) * [A description of what "fixup_page_tables_for_hap" does] > + /* > + * pvh: we temporarily disable paging mode so that we can build cr3 needed > + * to run on dom0's page tables. > + */ > + save_pvh_pg_mode = d->arch.paging.mode; > + d->arch.paging.mode = 0; > + What on earth is this about? Setting d->arch.paging.mode to zero isn't actually disabling paging; it's just making people *thing* paging is disabled. AFAICT paging should be enabled at this point anyway, should it? diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index b8c5422..878697e 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -589,6 +589,21 @@ int hap_domctl(struct domain *d, xen_domctl_shadow_op_t *sc, } } +void __init hap_set_pvh_alloc_for_dom0(struct domain *d, + unsigned long num_pages) +{ + int rc; + unsigned long memkb = num_pages * (PAGE_SIZE / 1024); + + /* Copied from: libxl_get_required_shadow_memory() */ + memkb = 4 * (256 * d->max_vcpus + 2 * (memkb / 1024)); + num_pages = ( (memkb + 1023) / 1024) << (20 - PAGE_SHIFT); + paging_lock(d); + rc = hap_set_allocation(d, num_pages, NULL); + paging_unlock(d); The calculation for how many pages of shadow memory are needed logically belongs in domain_build.c, not hap.c. -George