Hi all, this patch series implements the few missing functions to successfully complete a domain destruction. Stefano Stabellini (3): xen/arm: implement arch_domain_destroy xen/arm: implement domain_relinquish_resources xen/arm: implement vcpu_timer_destroy xen/arch/arm/domain.c | 61 ++++++++++++++++++++++++++++++++++++++++--------- xen/arch/arm/vtimer.c | 6 +++++ xen/arch/arm/vtimer.h | 1 + 3 files changed, 57 insertions(+), 11 deletions(-) Cheers, Stefano
Stefano Stabellini
2013-Jan-22 13:04 UTC
[PATCH 1/3] xen/arm: implement arch_domain_destroy
Implement arch_domain_destroy, use it in the error path of arch_domain_create. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- xen/arch/arm/domain.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 644b066..17713f8 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -440,20 +440,17 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) fail: d->is_dying = DOMDYING_dead; - free_xenheap_page(d->shared_info); - - p2m_teardown(d); - - domain_vgic_free(d); - domain_uart0_free(d); + arch_domain_destroy(d); return rc; } void arch_domain_destroy(struct domain *d) { - /* p2m_destroy */ - /* domain_vgic_destroy */ + p2m_teardown(d); + domain_vgic_free(d); + domain_uart0_free(d); + free_xenheap_page(d->shared_info); } static int is_guest_psr(uint32_t psr) -- 1.7.2.5
Stefano Stabellini
2013-Jan-22 13:04 UTC
[PATCH 2/3] xen/arm: implement domain_relinquish_resources
put_page on every entry in xenpage_list and page_list Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- xen/arch/arm/domain.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 44 insertions(+), 3 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 17713f8..3e9a690 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -9,6 +9,7 @@ #include <xen/grant_table.h> #include <asm/current.h> +#include <asm/event.h> #include <asm/regs.h> #include <asm/p2m.h> #include <asm/irq.h> @@ -517,11 +518,51 @@ void arch_vcpu_reset(struct vcpu *v) vcpu_end_shutdown_deferral(v); } +static int relinquish_memory(struct domain *d, struct page_list_head *list) +{ + struct page_info *page, *tmp; + int ret = 0; + + /* Use a recursive lock, as we may enter ''free_domheap_page''. */ + spin_lock_recursive(&d->page_alloc_lock); + + page_list_for_each_safe( page, tmp, list ) + { + /* Grab a reference to the page so it won''t disappear from under us. */ + if ( unlikely(!get_page(page, d)) ) + /* Couldn''t get a reference -- someone is freeing this page. */ + BUG(); + + if ( test_and_clear_bit(_PGC_allocated, &page->count_info) ) + put_page(page); + + put_page(page); + + if ( hypercall_preempt_check() ) + { + ret = -EAGAIN; + goto out; + } + } + + out: + spin_unlock_recursive(&d->page_alloc_lock); + return ret; +} + int domain_relinquish_resources(struct domain *d) { - /* XXX teardown pagetables, free pages etc */ - ASSERT(0); - return 0; + int ret = 0; + + ret = relinquish_memory(d, &d->xenpage_list); + if ( ret ) + return ret; + + ret = relinquish_memory(d, &d->page_list); + if ( ret ) + return ret; + + return ret; } void arch_dump_domain_info(struct domain *d) -- 1.7.2.5
Stefano Stabellini
2013-Jan-22 13:04 UTC
[PATCH 3/3] xen/arm: implement vcpu_timer_destroy
Implement a function to destroy the per-vcpu phys and virt timers, call it from vcpu_destroy. Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com> --- xen/arch/arm/domain.c | 1 + xen/arch/arm/vtimer.c | 6 ++++++ xen/arch/arm/vtimer.h | 1 + 3 files changed, 8 insertions(+), 0 deletions(-) diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index 3e9a690..e37ec54 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -402,6 +402,7 @@ int vcpu_initialise(struct vcpu *v) void vcpu_destroy(struct vcpu *v) { + vcpu_timer_destroy(v); free_xenheap_pages(v->arch.stack, STACK_ORDER); } diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c index 3616879..85201b5 100644 --- a/xen/arch/arm/vtimer.c +++ b/xen/arch/arm/vtimer.c @@ -65,6 +65,12 @@ int vcpu_vtimer_init(struct vcpu *v) return 0; } +void vcpu_timer_destroy(struct vcpu *v) +{ + kill_timer(&v->arch.virt_timer.timer); + kill_timer(&v->arch.phys_timer.timer); +} + int virt_timer_save(struct vcpu *v) { v->arch.virt_timer.ctl = READ_CP32(CNTV_CTL); diff --git a/xen/arch/arm/vtimer.h b/xen/arch/arm/vtimer.h index faebd68..43eef69 100644 --- a/xen/arch/arm/vtimer.h +++ b/xen/arch/arm/vtimer.h @@ -24,6 +24,7 @@ extern int vcpu_vtimer_init(struct vcpu *v); extern int vtimer_emulate(struct cpu_user_regs *regs, union hsr hsr); extern int virt_timer_save(struct vcpu *v); extern int virt_timer_restore(struct vcpu *v); +extern void vcpu_timer_destroy(struct vcpu *v); #endif -- 1.7.2.5
On Tue, 2013-01-22 at 13:03 +0000, Stefano Stabellini wrote:> Hi all, > this patch series implements the few missing functions to successfully > complete a domain destruction.These all look ok to me. Acked-by: Ian Campbell <ian.campbell@citrix.com>> > Stefano Stabellini (3): > xen/arm: implement arch_domain_destroy > xen/arm: implement domain_relinquish_resources > xen/arm: implement vcpu_timer_destroy > > xen/arch/arm/domain.c | 61 ++++++++++++++++++++++++++++++++++++++++--------- > xen/arch/arm/vtimer.c | 6 +++++ > xen/arch/arm/vtimer.h | 1 + > 3 files changed, 57 insertions(+), 11 deletions(-) > > Cheers, > > Stefano
At 17:34 +0000 on 24 Jan (1359048842), Ian Campbell wrote:> On Tue, 2013-01-22 at 13:03 +0000, Stefano Stabellini wrote: > > Hi all, > > this patch series implements the few missing functions to successfully > > complete a domain destruction. > > These all look ok to me. > > Acked-by: Ian Campbell <ian.campbell@citrix.com>Me too. Acked-by: Tim Deegan <tim@xen.org>
On Thu, 2013-01-24 at 17:43 +0000, Tim Deegan wrote:> At 17:34 +0000 on 24 Jan (1359048842), Ian Campbell wrote: > > On Tue, 2013-01-22 at 13:03 +0000, Stefano Stabellini wrote: > > > Hi all, > > > this patch series implements the few missing functions to successfully > > > complete a domain destruction. > > > > These all look ok to me. > > > > Acked-by: Ian Campbell <ian.campbell@citrix.com> > > Me too. > > Acked-by: Tim Deegan <tim@xen.org>Applied. Thanks.