All of lore.kernel.org
 help / color / mirror / Atom feed
From: Juergen Gross <jgross@suse.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Borislav Petkov <bp@alien8.de>,
	Peter Zijlstra <peterz@infradead.org>,
	the arch/x86 maintainers <x86@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	xen-devel <xen-devel@lists.xenproject.org>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	longman@redhat.com, mingo@redhat.com,
	lkml <linux-kernel@vger.kernel.org>,
	stable@vger.kernel.org, "H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [Xen-devel] [PATCH 2/2] xen: make xen_qlock_wait() nestable
Date: Mon, 1 Oct 2018 11:03:08 +0200	[thread overview]
Message-ID: <b09903d2-b6f5-299e-5880-f048fd4e1a8b@suse.com> (raw)

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


         reply	other threads:[~2018-10-01  9:03 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b09903d2-b6f5-299e-5880-f048fd4e1a8b@suse.com \
    --to=jgross@suse.com \
    --cc=JBeulich@suse.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.