xen/arm: domain destruction
cover xen/arm: domain destruction
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
PATCH 1/3 xen/arm: implement arch_domain_destroy
Implement arch_domain_destroy, use it in the error path of arch_domain_create.
--- xen/arch/arm/domain.c | 13 +++++-------- 1 files changed, 5 insertions(+), 8 deletions(-)
xen/arch/arm/domain.c +5 -8
@@ -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)
Signature · 1 line
1.7.2.5
PATCH 2/3 xen/arm: implement domain_relinquish_resources
In reply to Stefano Stabelliniput_page on every entry in xenpage_list and page_list
--- xen/arch/arm/domain.c | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 44 insertions(+), 3 deletions(-)
xen/arch/arm/domain.c +44 -3
@@ -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)
Signature · 1 line
1.7.2.5
PATCH 3/3 xen/arm: implement vcpu_timer_destroy
In reply to Stefano StabelliniImplement a function to destroy the per-vcpu phys and virt timers, call it from vcpu_destroy.
--- 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(-)
xen/arch/arm/domain.c +1 -0
@@ -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 ); }
xen/arch/arm/vtimer.c +6 -0
@@ -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 );
xen/arch/arm/vtimer.h +1 -0
@@ -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
Signature · 1 line
1.7.2.5
Quoted 3 lines · Stefano Stabellini
Hi all,
this patch series implements the few missing functions to successfully complete a domain destruction.
These all look ok to me.
Quoted 14 lines
Stefano Stabellini (3):
xen/arm: implementarch_domain_destroyxen/arm: implementdomain_relinquish_resourcesxen/arm: implementvcpu_timer_destroyxen/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
Tim Deegan
Acked-byQuoted 8 lines · Ian Campbell
Quoted 3 lines · Stefano Stabellini
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 <[email protected]>
Me too.
Ian Campbell
AppliedQuoted 6 lines · Tim Deegan
Quoted 5 lines · Ian Campbell
Quoted 3 lines · Stefano Stabellini
Hi all,
this patch series implements the few missing functions to successfully complete a domain destruction.
Quoted 7 lines
Quoted 3 lines
These all look ok to me.
Acked-by Ian Campbell <[email protected]>Me too.
Acked-by Tim Deegan <[email protected]>
Applied. Thanks.