diff options
author | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-05-30 17:47:00 +0100 |
---|---|---|
committer | kfraser@localhost.localdomain <kfraser@localhost.localdomain> | 2007-05-30 17:47:00 +0100 |
commit | 603d6a3905d975db7bd8a591a27ca9600edf4f76 (patch) | |
tree | a7dd70722f607c2a456d97e59144a418f2e5e38c | |
parent | d3f7f10c42ac5230bfecdfa73c5a07f9dcac935e (diff) | |
download | xen-603d6a3905d975db7bd8a591a27ca9600edf4f76.tar.gz xen-603d6a3905d975db7bd8a591a27ca9600edf4f76.tar.bz2 xen-603d6a3905d975db7bd8a591a27ca9600edf4f76.zip |
Clean up around domain init/destroy.
Signed-off-by: Keir Fraser <keir@xensource.com>
-rw-r--r-- | xen/arch/x86/domain.c | 26 | ||||
-rw-r--r-- | xen/common/domain.c | 27 | ||||
-rw-r--r-- | xen/include/asm-x86/domain.h | 3 | ||||
-rw-r--r-- | xen/include/xen/sched.h | 1 |
4 files changed, 28 insertions, 29 deletions
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index c0e0b0c56e..28dc3c5671 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -343,6 +343,8 @@ int vcpu_initialise(struct vcpu *v) struct domain *d = v->domain; int rc; + v->arch.vcpu_info_mfn = INVALID_MFN; + v->arch.flags = TF_kernel_mode; pae_l3_cache_init(&v->arch.pae_l3_cache); @@ -384,6 +386,11 @@ void vcpu_destroy(struct vcpu *v) { if ( is_pv_32on64_vcpu(v) ) release_compat_l4(v); + + unmap_vcpu_info(v); + + if ( is_hvm_vcpu(v) ) + hvm_vcpu_destroy(v); } int arch_domain_create(struct domain *d) @@ -489,17 +496,8 @@ int arch_domain_create(struct domain *d) void arch_domain_destroy(struct domain *d) { - struct vcpu *v; - - for_each_vcpu ( d, v ) - unmap_vcpu_info(v); - if ( is_hvm_domain(d) ) - { - for_each_vcpu ( d, v ) - hvm_vcpu_destroy(v); hvm_domain_destroy(d); - } paging_final_teardown(d); @@ -752,14 +750,14 @@ unmap_vcpu_info(struct vcpu *v) struct domain *d = v->domain; unsigned long mfn; - if ( v->vcpu_info_mfn == INVALID_MFN ) + if ( v->arch.vcpu_info_mfn == INVALID_MFN ) return; - mfn = v->vcpu_info_mfn; + mfn = v->arch.vcpu_info_mfn; unmap_domain_page_global(v->vcpu_info); v->vcpu_info = shared_info_addr(d, vcpu_info[v->vcpu_id]); - v->vcpu_info_mfn = INVALID_MFN; + v->arch.vcpu_info_mfn = INVALID_MFN; put_page_and_type(mfn_to_page(mfn)); } @@ -781,7 +779,7 @@ map_vcpu_info(struct vcpu *v, unsigned long mfn, unsigned offset) if ( offset > (PAGE_SIZE - sizeof(vcpu_info_t)) ) return -EINVAL; - if ( v->vcpu_info_mfn != INVALID_MFN ) + if ( v->arch.vcpu_info_mfn != INVALID_MFN ) return -EINVAL; /* Run this command on yourself or on other offline VCPUS. */ @@ -805,7 +803,7 @@ map_vcpu_info(struct vcpu *v, unsigned long mfn, unsigned offset) memcpy(new_info, v->vcpu_info, sizeof(*new_info)); v->vcpu_info = new_info; - v->vcpu_info_mfn = mfn; + v->arch.vcpu_info_mfn = mfn; /* Set new vcpu_info pointer /before/ setting pending flags. */ wmb(); diff --git a/xen/common/domain.c b/xen/common/domain.c index 031ee3fc8c..b4b339c947 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -69,19 +69,6 @@ struct domain *alloc_domain(domid_t domid) void free_domain(struct domain *d) { - struct vcpu *v; - int i; - - for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- ) - { - if ( (v = d->vcpu[i]) == NULL ) - continue; - vcpu_destroy(v); - sched_destroy_vcpu(v); - free_vcpu_struct(v); - } - - sched_destroy_domain(d); xfree(d); } @@ -136,7 +123,6 @@ struct vcpu *alloc_vcpu( v->domain = d; v->vcpu_id = vcpu_id; - v->vcpu_info_mfn = INVALID_MFN; v->runstate.state = is_idle_vcpu(v) ? RUNSTATE_running : RUNSTATE_offline; v->runstate.state_entry_time = NOW(); @@ -472,6 +458,17 @@ void domain_pause_for_debugger(void) static void complete_domain_destroy(struct rcu_head *head) { struct domain *d = container_of(head, struct domain, rcu); + struct vcpu *v; + int i; + + for ( i = MAX_VIRT_CPUS-1; i >= 0; i-- ) + { + if ( (v = d->vcpu[i]) == NULL ) + continue; + vcpu_destroy(v); + sched_destroy_vcpu(v); + free_vcpu_struct(v); + } acm_domain_destroy(d); @@ -482,6 +479,8 @@ static void complete_domain_destroy(struct rcu_head *head) arch_domain_destroy(d); + sched_destroy_domain(d); + free_domain(d); send_guest_global_virq(dom0, VIRQ_DOM_EXC); diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 347b2dd1cd..6bb8497319 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -290,6 +290,9 @@ struct arch_vcpu unsigned long shadow_ldt_mapcnt; struct paging_vcpu paging; + + /* Guest-specified relocation of vcpu_info. */ + unsigned long vcpu_info_mfn; } __cacheline_aligned; /* shorthands to improve code legibility */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 5ce2f5db7a..703b339918 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -75,7 +75,6 @@ struct vcpu int processor; vcpu_info_t *vcpu_info; - unsigned long vcpu_info_mfn; struct domain *domain; |