mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Re: [Xen-devel] [PATCH 1/2] xen: fix race in xen_qlock_wait()
@ 2018-10-01  8:58 Juergen Gross
  0 siblings, 0 replies; 2+ messages in thread
From: Juergen Gross @ 2018-10-01  8:58 UTC (permalink / raw)
  To: Jan Beulich
  Cc: Borislav Petkov, Peter Zijlstra, the arch/x86 maintainers,
	Thomas Gleixner, xen-devel, Boris Ostrovsky, longman, mingo,
	lkml, stable, H. Peter Anvin

On 01/10/2018 10:54, Jan Beulich wrote:
>>>> On 01.10.18 at 09:16, <jgross@suse.com> wrote:
>> In the following situation a vcpu waiting for a lock might not be
>> woken up from xen_poll_irq():
>>
>> CPU 1:                CPU 2:                      CPU 3:
>> takes a spinlock
>>                       tries to get lock
>>                       -> xen_qlock_wait()
>>                         -> xen_clear_irq_pending()
> 
> Doesn't the last line above ...
> 
>> frees the lock
>> -> xen_qlock_kick(cpu2)
> 
> ... need to be below here?

You are right, of course!

Thanks for noticing.


Juergen

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

* Re: [Xen-devel] [PATCH 1/2] xen: fix race in xen_qlock_wait()
  2018-10-01  7:16 ` [PATCH 1/2] xen: fix race in xen_qlock_wait() Juergen Gross
@ 2018-10-01  8:54   ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2018-10-01  8:54 UTC (permalink / raw)
  To: Juergen Gross
  Cc: Borislav Petkov, Peter Zijlstra, the arch/x86 maintainers, tglx,
	xen-devel, Boris Ostrovsky, longman, mingo, linux-kernel, stable,
	hpa

>>> On 01.10.18 at 09:16, <jgross@suse.com> wrote:
> In the following situation a vcpu waiting for a lock might not be
> woken up from xen_poll_irq():
> 
> CPU 1:                CPU 2:                      CPU 3:
> takes a spinlock
>                       tries to get lock
>                       -> xen_qlock_wait()
>                         -> xen_clear_irq_pending()

Doesn't the last line above ...

> frees the lock
> -> xen_qlock_kick(cpu2)

... need to be below here?

> takes lock again
>                                                   tries to get lock
>                                                   -> *lock = _Q_SLOW_VAL
>                         -> *lock == _Q_SLOW_VAL ?
>                         -> xen_poll_irq()
> frees the lock
> -> xen_qlock_kick(cpu3)
> 
> And cpu 2 will sleep forever.
> 
> This can be avoided easily by modifying xen_qlock_wait() to call
> xen_poll_irq() only if the related irq was not pending and to call
> xen_clear_irq_pending() only if it was pending.
> 
> Cc: stable@vger.kernel.org 
> Cc: Waiman.Long@hp.com 
> Cc: peterz@infradead.org 
> Signed-off-by: Juergen Gross <jgross@suse.com>

Patch itself
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan



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

end of thread, other threads:[~2018-10-01  8:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-01  8:58 [Xen-devel] [PATCH 1/2] xen: fix race in xen_qlock_wait() Juergen Gross
  -- strict thread matches above, loose matches on Subject: below --
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  8:54   ` [Xen-devel] " Jan Beulich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®