From: Dario Faggioli Date: Thu, 21 Sep 2017 00:30:37 +0000 (+0200) Subject: xen: credit2: fix spinlock irq-safety violation X-Git-Tag: 4.10.0-rc1~278 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=00cc5cd669122b77b336dae52566e813ec45122d;p=xen.git xen: credit2: fix spinlock irq-safety violation In commit ad4b3e1e9df34 ("xen: credit2: implement utilization cap") xfree() was being called (for deallocating the budget replenishment timer, during domain destruction) inside an IRQ disabled critical section. That must not happen, as it uses the mem-pool's lock, which needs to be taken with IRQ enabled. And, in fact, we crash (in debug builds): (XEN) **************************************** (XEN) Panic on CPU 0: (XEN) Xen BUG at spinlock.c:47 (XEN) **************************************** Let's, therefore, kill and deallocate the timer outside of the critical sections, when IRQs are enabled. Signed-off-by: Dario Faggioli --- diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c index 5b2cae184a..ccd5c951b2 100644 --- a/xen/common/sched_credit2.c +++ b/xen/common/sched_credit2.c @@ -2921,15 +2921,15 @@ csched2_free_domdata(const struct scheduler *ops, void *data) struct csched2_dom *sdom = data; struct csched2_private *prv = csched2_priv(ops); - write_lock_irqsave(&prv->lock, flags); - kill_timer(sdom->repl_timer); - xfree(sdom->repl_timer); + + write_lock_irqsave(&prv->lock, flags); list_del_init(&sdom->sdom_elem); write_unlock_irqrestore(&prv->lock, flags); + xfree(sdom->repl_timer); xfree(data); }