All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] xen: fix two issues in Xen pv qspinlock handling
@ 2018-10-01  7:16 Juergen Gross
  2018-10-01  7:16 ` [PATCH 1/2] xen: fix race in xen_qlock_wait() Juergen Gross
                   ` (7 more replies)
  0 siblings, 8 replies; 35+ messages in thread
From: Juergen Gross @ 2018-10-01  7:16 UTC (permalink / raw)
  To: linux-kernel, xen-devel, x86
  Cc: boris.ostrovsky, hpa, tglx, mingo, bp, Juergen Gross,
	Waiman.Long, peterz

The Xen specific queue spinlock wait function has two issues which
could result in a hanging system.

They have a similar root cause of clearing a pending wakeup of a
waiting vcpu and later going to sleep waiting for the just cleared
wakeup event, which of course won't ever happen.

Juergen Gross (2):
  xen: fix race in xen_qlock_wait()
  xen: make xen_qlock_wait() nestable

 arch/x86/xen/spinlock.c | 33 ++++++++++++---------------------
 1 file changed, 12 insertions(+), 21 deletions(-)

Cc: Waiman.Long@hp.com
Cc: peterz@infradead.org

-- 
2.16.4


^ permalink raw reply	[flat|nested] 35+ messages in thread
* Re: [PATCH 2/2] xen: make xen_qlock_wait() nestable
@ 2018-10-01  9:03 Juergen Gross
  0 siblings, 0 replies; 35+ messages in thread
From: Juergen Gross @ 2018-10-01  9:03 UTC (permalink / raw)
  To: Jan Beulich
  Cc: H. Peter Anvin, Peter Zijlstra, the arch/x86 maintainers, lkml,
	stable, mingo, Borislav Petkov, longman, xen-devel,
	Thomas Gleixner, Boris Ostrovsky

On 01/10/2018 10:57, Jan Beulich wrote:
>>>> On 01.10.18 at 09:16, <jgross@suse.com> wrote:
>> xen_qlock_wait() isn't safe for nested calls due to interrupts. A call
>> of xen_qlock_kick() might be ignored in case a deeper nesting level
>> was active right before the call of xen_poll_irq():
>>
>> CPU 1:                                   CPU 2:
>> spin_lock(lock1)
>>                                          spin_lock(lock1)
>>                                          -> xen_qlock_wait()
>>                                             -> xen_clear_irq_pending()
>>                                             Interrupt happens
>> spin_unlock(lock1)
>> -> xen_qlock_kick(CPU 2)
>> spin_lock_irqsave(lock2)
>>                                          spin_lock_irqsave(lock2)
>>                                          -> xen_qlock_wait()
>>                                             -> xen_clear_irq_pending()
>>                                                clears kick for lock1
>>                                             -> xen_poll_irq()
>> spin_unlock_irq_restore(lock2)
>> -> xen_qlock_kick(CPU 2)
>>                                             wakes up
>>                                          spin_unlock_irq_restore(lock2)
>>                                          IRET
>>                                            resumes in xen_qlock_wait()
>>                                            -> xen_poll_irq()
>>                                            never wakes up
>>
>> The solution is to disable interrupts in xen_qlock_wait() and not to
>> poll for the irq in case xen_qlock_wait() is called in nmi context.
> 
> Are precautions against NMI really worthwhile? Locks acquired both
> in NMI context as well as outside of it are liable to deadlock anyway,
> aren't they?

The locks don't need to be the same. A NMI-only lock tried to be
acquired with xen_qlock_wait() for another lock having been interrupted
by the NMI will be enough to risk the issue.

So yes, I believe the test for NMI is good to have.


Juergen


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

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

end of thread, other threads:[~2018-10-10 13:53 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  7:16 [PATCH 0/2] xen: fix two issues in Xen pv qspinlock handling Juergen Gross
2018-10-01  7:16 ` [PATCH 1/2] xen: fix race in xen_qlock_wait() Juergen Gross
2018-10-01  7:37   ` Juergen Gross
2018-10-01  7:37   ` Juergen Gross
2018-10-01  8:54   ` Jan Beulich
2018-10-01  8:54   ` [Xen-devel] " Jan Beulich
2018-10-01  7:16 ` Juergen Gross
2018-10-01  7:16 ` [PATCH 2/2] xen: make xen_qlock_wait() nestable Juergen Gross
2018-10-01  7:16 ` Juergen Gross
2018-10-01  7:38   ` Juergen Gross
2018-10-01  7:38   ` Juergen Gross
2018-10-01  8:57   ` Jan Beulich
2018-10-01  8:57   ` [Xen-devel] " Jan Beulich
     [not found]   ` <5BB1E18802000078001ED127@suse.com>
2018-10-01  9:03     ` Juergen Gross
2018-10-01  9:18       ` Jan Beulich
2018-10-01  9:18       ` Jan Beulich
2018-10-10 11:53   ` David Woodhouse
2018-10-10 12:30     ` Thomas Gleixner
2018-10-10 12:30     ` Thomas Gleixner
2018-10-10 12:44       ` David Woodhouse
2018-10-10 12:47         ` Thomas Gleixner
2018-10-10 12:47         ` Thomas Gleixner
2018-10-10 13:38           ` Juergen Gross
2018-10-10 13:53             ` David Woodhouse
2018-10-10 13:53             ` David Woodhouse
2018-10-10 13:38           ` Juergen Gross
2018-10-10 12:44       ` David Woodhouse
2018-10-10 11:53   ` David Woodhouse
2018-10-01  7:37 ` [PATCH 0/2] xen: fix two issues in Xen pv qspinlock handling Juergen Gross
2018-10-01  7:37 ` Juergen Gross
2018-10-09 14:40 ` David Woodhouse
2018-10-09 14:52   ` Juergen Gross
2018-10-09 14:52   ` Juergen Gross
2018-10-09 14:40 ` David Woodhouse
2018-10-01  9:03 [PATCH 2/2] xen: make xen_qlock_wait() nestable Juergen Gross

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.