From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Catterall Subject: [RFC 1/4] HVM x86 deprivileged mode: Page allocation helper Date: Thu, 6 Aug 2015 17:45:16 +0100 Message-ID: <1438879519-564-2-git-send-email-Ben.Catterall@citrix.com> References: <1438879519-564-1-git-send-email-Ben.Catterall@citrix.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1438879519-564-1-git-send-email-Ben.Catterall@citrix.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: xen-devel@lists.xensource.com Cc: keir@xen.org, ian.campbell@citrix.com, george.dunlap@eu.citrix.com, andrew.cooper3@citrix.com, tim@xen.org, jbeulich@suse.com, Ben Catterall List-Id: xen-devel@lists.xenproject.org This allocation function is used by the deprivileged mode initialisation code to allocate pages for the new page table mappings and page frames on the HAP page heap. Signed-off-by: Ben Catterall --- xen/arch/x86/mm/hap/hap.c | 23 +++++++++++++++++++++++ xen/include/asm-x86/domain.h | 1 + xen/include/asm-x86/hap.h | 5 +++++ 3 files changed, 29 insertions(+) diff --git a/xen/arch/x86/mm/hap/hap.c b/xen/arch/x86/mm/hap/hap.c index d375c4d..593cba7 100644 --- a/xen/arch/x86/mm/hap/hap.c +++ b/xen/arch/x86/mm/hap/hap.c @@ -844,6 +844,29 @@ static const struct paging_mode hap_paging_long_mode = { .guest_levels = 4 }; +/************************************************/ +/* HAP HVM functions */ +/************************************************/ +struct page_info *hvm_alloc_page(struct domain *d) +{ + struct page_info *pg; + + if( (pg = hap_alloc(d)) == NULL ) + { + HAP_ERROR("HVM: Out of memory allocating HVM page\n"); + domain_crash(d); + return NULL; + } + + ASSERT(paging_locked_by_me(d)); + + /* Track our used pages */ + page_list_add(pg, &d->arch.paging.hap.hvmlist); + + return pg; +} + + /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 0fce09e..c46a31a 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -154,6 +154,7 @@ struct shadow_vcpu { /************************************************/ struct hap_domain { struct page_list_head freelist; + struct page_list_head hvmlist; /* HVM usermode page allocation */ unsigned int total_pages; /* number of pages allocated */ unsigned int free_pages; /* number of pages on freelists */ unsigned int p2m_pages; /* number of pages allocates to p2m */ diff --git a/xen/include/asm-x86/hap.h b/xen/include/asm-x86/hap.h index bd87481..0432eb5 100644 --- a/xen/include/asm-x86/hap.h +++ b/xen/include/asm-x86/hap.h @@ -48,6 +48,11 @@ int hap_track_dirty_vram(struct domain *d, extern const struct paging_mode *hap_paging_get_mode(struct vcpu *); void hap_set_alloc_for_pvh_dom0(struct domain *d, unsigned long num_pages); +/************************************************/ +/* hap HVM functions */ +/************************************************/ + +struct page_info *hvm_alloc_page(struct domain *d); #endif /* XEN_HAP_H */ /* -- 2.1.4