x86: Move nested_p2m per domain data into its own struct.
PATCH 1/1 x86: Move nested_p2m per domain data into its own struct.
An upcoming change may require to increase the size of struct domain (for x86). The result is a build failure because struct domain gets larger than a page.
Signed-off-by Jean Guyader <[email protected]>
--- xen/arch/x86/domain.c | 5 +++++ xen/arch/x86/mm/hap/hap.c | 4 ++-- xen/arch/x86/mm/mm-locks.h | 4 ++-- xen/arch/x86/mm/p2m.c | 13 ++++++------- xen/include/asm-x86/domain.h | 9 +++++++-- 5 files changed, 22 insertions(+), 13 deletions(-)
xen/arch/x86/domain.c +5 -0
@@ -598,6 +598,11 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags)/* For Guest vMCE MSRs virtualization */ vmce_init_msr (d); + + d->arch.nested_p2m = xzalloc(struct nested_p2m_per_domain); + rc = -ENOMEM ; +if ( d->arch.nested_p2m ==NULL ) + goto fail; }if (is_hvm_domain (d) )
xen/arch/x86/mm/hap/hap.c +2 -2
@@ -607,7 +607,7 @@ int hap_enable(struct domain *d, u32 mode) }for (i =0 ; i <MAX_NESTEDP2M ; i++) { - rv =p2m_alloc_table (d->arch.nested_p2m[i]); + rv =p2m_alloc_table (d->arch.nested_p2m->nested_p2m[i]);if ( rv !=0 ) goto out; }
@@ -626,7 +626,7 @@ void hap_final_teardown(struct domain *d)/* Destroy nestedp2m's first */ for (i =0 ; i <MAX_NESTEDP2M ; i++) { -p2m_teardown (d->arch.nested_p2m[i]); +p2m_teardown (d->arch.nested_p2m->nested_p2m[i]); }if ( d->arch.paging.hap.total_pages !=0 )
xen/arch/x86/mm/mm-locks.h +2 -2
@@ -160,8 +160,8 @@ declare_mm_lock(shr)* (i.e. assigning a p2m table to be the shadow of that cr3 */ declare_mm_lock(nestedp2m) -#define nestedp2m_lock (d) mm_lock(nestedp2m, &(d)->arch.nested_p2m_lock) -#define nestedp2m_unlock (d) mm_unlock(&(d)->arch.nested_p2m_lock) +#define nestedp2m_lock (d) mm_lock(nestedp2m, &(d)->arch.nested_p2m->nested_p2m_lock) +#define nestedp2m_unlock (d) mm_unlock(&(d)->arch.nested_p2m->nested_p2m_lock)/* P2M lock (per-p2m-table) *
xen/arch/x86/mm/p2m.c +6 -7
@@ -96,9 +96,9 @@ p2m_init_nestedp2m(struct domain *d)uint8_t i;struct p2m_domain *p2m; -mm_lock_init (&d->arch.nested_p2m_lock); +mm_lock_init (&d->arch.nested_p2m->nested_p2m_lock);for (i =0 ; i <MAX_NESTEDP2M ; i++) { - d->arch.nested_p2m[i] = p2m = xzalloc(struct p2m_domain); + d->arch.nested_p2m->nested_p2m[i] = p2m = xzalloc(struct p2m_domain);if (p2m ==NULL )return -ENOMEM ;if ( !zalloc_cpumask_var (&p2m->dirty_cpumask) )
@@ -376,11 +376,10 @@ static void p2m_teardown_nestedp2m(struct domain *d)uint8_t i;for (i =0 ; i <MAX_NESTEDP2M ; i++) { -if ( !d->arch.nested_p2m[i] ) +if ( !d->arch.nested_p2m->nested_p2m[i] )continue ; -free_cpumask_var (d->arch.nested_p2m[i]->dirty_cpumask); -xfree (d->arch.nested_p2m[i]); - d->arch.nested_p2m[i] =NULL ; +free_cpumask_var (d->arch.nested_p2m->nested_p2m[i]->dirty_cpumask); + d->arch.nested_p2m->nested_p2m[i] =NULL ; } }
@@ -1328,7 +1327,7 @@ p2m_flush_nestedp2m(struct domain *d) {int i;for ( i =0 ; i <MAX_NESTEDP2M ; i++ ) -p2m_flush_table (d->arch.nested_p2m[i]); +p2m_flush_table (d->arch.nested_p2m->nested_p2m[i]); } struct p2m_domain *
xen/include/asm-x86/domain.h +7 -2
@@ -238,6 +238,12 @@ struct pv_domainunsigned int nr_e820; }; +struct nested_p2m_per_domain +{ +struct p2m_domain *nested_p2m[MAX_NESTEDP2M ]; +mm_lock_t nested_p2m_lock; +}; +struct arch_domain {#ifdef CONFIG_X86_64
@@ -274,8 +280,7 @@ struct arch_domainint page_alloc_unlock_level;/* nestedhvm: translate l2 guest physical to host physical */ -struct p2m_domain *nested_p2m[MAX_NESTEDP2M ]; -mm_lock_t nested_p2m_lock; +struct nested_p2m_per_domain *nested_p2m;/* NB. protected by d->event_lock and by irq_desc[irq].lock */ struct radix_tree_root irq_pirq;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
xen/include/asm-x86/domain.h struct pv_domain · line 244
Quoted 11 lines
Quoted 1 line
Quoted 1 line · Jean Guyader
xen/include/asm-x86/domain.h +4
-0@@ -238,6 +238,12 @@ struct pv_domainunsigned int nr_e820; }; +struct nested_p2m_per_domain +{ +struct p2m_domain *nested_p2m[MAX_NESTEDP2M ]; +mm_lock_t nested_p2m_lock;
So you call these nested_p2m* but the container ...
xen/include/asm-x86/domain.h struct arch_domain · line 283
Quoted 12 lines
xen/include/asm-x86/domain.h +2
-0+}; +struct
arch_domain
{
#ifdefCONFIG_X86_64xen/include/asm-x86/domain.h +1
-2@@ -274,8 +280,7 @@ struct arch_domainint page_alloc_unlock_level;/* nestedhvm: translate l2 guest physical to host physical */ -struct p2m_domain *nested_p2m[MAX_NESTEDP2M ]; -mm_lock_t nested_p2m_lock; +struct nested_p2m_per_domain *nested_p2m;
... is also called this way. Pretty redundant, just requiring extra typing and eventually leading to ugly to read wrapped lines.
Jan
Quoted 2 lines
xen/include/asm-x86/domain.h +0
-0/* NB. protected by d->event_lock and by irq_desc[irq].lock */