Mailing List Archive

[xen-unstable] p2m: merge ptp allocation
# HG changeset patch
# User Keir Fraser <keir.fraser@citrix.com>
# Date 1271157648 -3600
# Node ID de7a50eb485494e0d56de0158148edec6d9fc0ef
# Parent 2a4970daad74449a8f827ea649c9f3f35ecba2f4
p2m: merge ptp allocation

Signed-off-by: Christoph Egger <Christop.Egger@amd.com>
---
xen/arch/x86/mm/hap/p2m-ept.c | 6 -----
xen/arch/x86/mm/hap/private.h | 3 --
xen/arch/x86/mm/p2m.c | 45 +++++++++++++++++++++++++++---------------
xen/include/asm-x86/p2m.h | 2 +
4 files changed, 33 insertions(+), 23 deletions(-)

diff -r 2a4970daad74 -r de7a50eb4854 xen/arch/x86/mm/hap/p2m-ept.c
--- a/xen/arch/x86/mm/hap/p2m-ept.c Tue Apr 13 09:38:54 2010 +0100
+++ b/xen/arch/x86/mm/hap/p2m-ept.c Tue Apr 13 12:20:48 2010 +0100
@@ -97,13 +97,9 @@ static int ept_set_middle_entry(struct d
{
struct page_info *pg;

- pg = d->arch.p2m->alloc_page(d);
+ pg = p2m_alloc_ptp(d, 0);
if ( pg == NULL )
return 0;
-
- pg->count_info = 1;
- pg->u.inuse.type_info = 1 | PGT_validated;
- page_list_add_tail(pg, &d->arch.p2m->pages);

ept_entry->emt = 0;
ept_entry->ipat = 0;
diff -r 2a4970daad74 -r de7a50eb4854 xen/arch/x86/mm/hap/private.h
--- a/xen/arch/x86/mm/hap/private.h Tue Apr 13 09:38:54 2010 +0100
+++ b/xen/arch/x86/mm/hap/private.h Tue Apr 13 12:20:48 2010 +0100
@@ -30,5 +30,4 @@ unsigned long hap_gva_to_gfn_4_levels(st
unsigned long hap_gva_to_gfn_4_levels(struct vcpu *v, unsigned long gva,
uint32_t *pfec);

-
-#endif /* __SVM_NPT_H__ */
+#endif /* __HAP_PRIVATE_H__ */
diff -r 2a4970daad74 -r de7a50eb4854 xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c Tue Apr 13 09:38:54 2010 +0100
+++ b/xen/arch/x86/mm/p2m.c Tue Apr 13 12:20:48 2010 +0100
@@ -134,6 +134,22 @@ p2m_find_entry(void *table, unsigned lon
return (l1_pgentry_t *)table + index;
}

+struct page_info *
+p2m_alloc_ptp(struct domain *d, unsigned long type)
+{
+ struct page_info *pg;
+
+ pg = d->arch.p2m->alloc_page(d);
+ if (pg == NULL)
+ return NULL;
+
+ page_list_add_tail(pg, &d->arch.p2m->pages);
+ pg->u.inuse.type_info = type | 1 | PGT_validated;
+ pg->count_info |= 1;
+
+ return pg;
+}
+
// Walk one level of the P2M table, allocating a new table if required.
// Returns 0 on error.
//
@@ -156,15 +172,14 @@ p2m_next_level(struct domain *d, mfn_t *
/* PoD: Not present doesn't imply empty. */
if ( !l1e_get_flags(*p2m_entry) )
{
- struct page_info *pg = d->arch.p2m->alloc_page(d);
+ struct page_info *pg;
+
+ pg = p2m_alloc_ptp(d, type);
if ( pg == NULL )
return 0;
- page_list_add_tail(pg, &d->arch.p2m->pages);
- pg->u.inuse.type_info = type | 1 | PGT_validated;
- pg->count_info |= 1;

new_entry = l1e_from_pfn(mfn_x(page_to_mfn(pg)),
- __PAGE_HYPERVISOR|_PAGE_USER);
+ __PAGE_HYPERVISOR | _PAGE_USER);

switch ( type ) {
case PGT_l3_page_table:
@@ -195,16 +210,15 @@ p2m_next_level(struct domain *d, mfn_t *
if ( type == PGT_l2_page_table && (l1e_get_flags(*p2m_entry) & _PAGE_PSE) )
{
unsigned long flags, pfn;
- struct page_info *pg = d->arch.p2m->alloc_page(d);
+ struct page_info *pg;
+
+ pg = p2m_alloc_ptp(d, PGT_l2_page_table);
if ( pg == NULL )
return 0;
- page_list_add_tail(pg, &d->arch.p2m->pages);
- pg->u.inuse.type_info = PGT_l2_page_table | 1 | PGT_validated;
- pg->count_info = 1;
-
+
flags = l1e_get_flags(*p2m_entry);
pfn = l1e_get_pfn(*p2m_entry);
-
+
l1_entry = map_domain_page(mfn_x(page_to_mfn(pg)));
for ( i = 0; i < L2_PAGETABLE_ENTRIES; i++ )
{
@@ -224,13 +238,12 @@ p2m_next_level(struct domain *d, mfn_t *
if ( type == PGT_l1_page_table && (l1e_get_flags(*p2m_entry) & _PAGE_PSE) )
{
unsigned long flags, pfn;
- struct page_info *pg = d->arch.p2m->alloc_page(d);
+ struct page_info *pg;
+
+ pg = p2m_alloc_ptp(d, PGT_l1_page_table);
if ( pg == NULL )
return 0;
- page_list_add_tail(pg, &d->arch.p2m->pages);
- pg->u.inuse.type_info = PGT_l1_page_table | 1 | PGT_validated;
- pg->count_info |= 1;
-
+
/* New splintered mappings inherit the flags of the old superpage,
* with a little reorganisation for the _PAGE_PSE_PAT bit. */
flags = l1e_get_flags(*p2m_entry);
diff -r 2a4970daad74 -r de7a50eb4854 xen/include/asm-x86/p2m.h
--- a/xen/include/asm-x86/p2m.h Tue Apr 13 09:38:54 2010 +0100
+++ b/xen/include/asm-x86/p2m.h Tue Apr 13 12:20:48 2010 +0100
@@ -444,6 +444,8 @@ int p2m_mem_paging_prep(struct domain *d
/* Resume normal operation (in case a domain was paused) */
void p2m_mem_paging_resume(struct domain *d);

+struct page_info *p2m_alloc_ptp(struct domain *d, unsigned long type);
+
#endif /* _XEN_P2M_H */

/*

_______________________________________________
Xen-changelog mailing list
Xen-changelog@lists.xensource.com
http://lists.xensource.com/xen-changelog