xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] xen/arm: domain destruction
@ 2013-01-22 13:03 Stefano Stabellini
  2013-01-22 13:04 ` [PATCH 1/3] xen/arm: implement arch_domain_destroy Stefano Stabellini
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Stefano Stabellini @ 2013-01-22 13:03 UTC (permalink / raw)
  To: xen-devel; +Cc: Tim Deegan, Ian Campbell, Stefano Stabellini

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] xen/arm: implement arch_domain_destroy
  2013-01-22 13:03 [PATCH 0/3] xen/arm: domain destruction Stefano Stabellini
@ 2013-01-22 13:04 ` Stefano Stabellini
  2013-01-22 13:04 ` [PATCH 2/3] xen/arm: implement domain_relinquish_resources Stefano Stabellini
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2013-01-22 13:04 UTC (permalink / raw)
  To: xen-devel; +Cc: tim, Ian.Campbell, Stefano Stabellini

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] xen/arm: implement domain_relinquish_resources
  2013-01-22 13:03 [PATCH 0/3] xen/arm: domain destruction Stefano Stabellini
  2013-01-22 13:04 ` [PATCH 1/3] xen/arm: implement arch_domain_destroy Stefano Stabellini
@ 2013-01-22 13:04 ` Stefano Stabellini
  2013-01-22 13:04 ` [PATCH 3/3] xen/arm: implement vcpu_timer_destroy Stefano Stabellini
  2013-01-24 17:34 ` [PATCH 0/3] xen/arm: domain destruction Ian Campbell
  3 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2013-01-22 13:04 UTC (permalink / raw)
  To: xen-devel; +Cc: tim, Ian.Campbell, Stefano Stabellini

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] xen/arm: implement vcpu_timer_destroy
  2013-01-22 13:03 [PATCH 0/3] xen/arm: domain destruction Stefano Stabellini
  2013-01-22 13:04 ` [PATCH 1/3] xen/arm: implement arch_domain_destroy Stefano Stabellini
  2013-01-22 13:04 ` [PATCH 2/3] xen/arm: implement domain_relinquish_resources Stefano Stabellini
@ 2013-01-22 13:04 ` Stefano Stabellini
  2013-01-24 17:34 ` [PATCH 0/3] xen/arm: domain destruction Ian Campbell
  3 siblings, 0 replies; 7+ messages in thread
From: Stefano Stabellini @ 2013-01-22 13:04 UTC (permalink / raw)
  To: xen-devel; +Cc: tim, Ian.Campbell, Stefano Stabellini

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

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] xen/arm: domain destruction
  2013-01-22 13:03 [PATCH 0/3] xen/arm: domain destruction Stefano Stabellini
                   ` (2 preceding siblings ...)
  2013-01-22 13:04 ` [PATCH 3/3] xen/arm: implement vcpu_timer_destroy Stefano Stabellini
@ 2013-01-24 17:34 ` Ian Campbell
  2013-01-24 17:43   ` Tim Deegan
  3 siblings, 1 reply; 7+ messages in thread
From: Ian Campbell @ 2013-01-24 17:34 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel@lists.xensource.com, Tim (Xen.org)

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

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] xen/arm: domain destruction
  2013-01-24 17:34 ` [PATCH 0/3] xen/arm: domain destruction Ian Campbell
@ 2013-01-24 17:43   ` Tim Deegan
  2013-02-05 11:35     ` Ian Campbell
  0 siblings, 1 reply; 7+ messages in thread
From: Tim Deegan @ 2013-01-24 17:43 UTC (permalink / raw)
  To: Ian Campbell; +Cc: xen-devel@lists.xensource.com, Stefano Stabellini

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>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 0/3] xen/arm: domain destruction
  2013-01-24 17:43   ` Tim Deegan
@ 2013-02-05 11:35     ` Ian Campbell
  0 siblings, 0 replies; 7+ messages in thread
From: Ian Campbell @ 2013-02-05 11:35 UTC (permalink / raw)
  To: Tim Deegan; +Cc: xen-devel@lists.xensource.com, Stefano Stabellini

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.

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-02-05 11:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-22 13:03 [PATCH 0/3] xen/arm: domain destruction Stefano Stabellini
2013-01-22 13:04 ` [PATCH 1/3] xen/arm: implement arch_domain_destroy Stefano Stabellini
2013-01-22 13:04 ` [PATCH 2/3] xen/arm: implement domain_relinquish_resources Stefano Stabellini
2013-01-22 13:04 ` [PATCH 3/3] xen/arm: implement vcpu_timer_destroy Stefano Stabellini
2013-01-24 17:34 ` [PATCH 0/3] xen/arm: domain destruction Ian Campbell
2013-01-24 17:43   ` Tim Deegan
2013-02-05 11:35     ` Ian Campbell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).