All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Andrew Cooper <andrew.cooper3@citrix.com>
Cc: xen-devel@lists.xenproject.org, Wei Liu <wl@xen.org>,
	Jan Beulich <jbeulich@suse.com>,
	Sander Eikelenboom <linux@eikelenboom.it>
Subject: Re: [Xen-devel] [PATCH v2 5/6] x86/smp: use a dedicated scratch cpumask in send_IPI_mask
Date: Tue, 18 Feb 2020 12:22:38 +0100	[thread overview]
Message-ID: <20200218112238.GT4679@Air-de-Roger> (raw)
In-Reply-To: <1071be16-b929-a251-f2f9-a55d40ce2e53@citrix.com>

On Tue, Feb 18, 2020 at 11:21:12AM +0000, Andrew Cooper wrote:
> On 18/02/2020 11:10, Roger Pau Monné wrote:
> > On Tue, Feb 18, 2020 at 10:53:45AM +0000, Andrew Cooper wrote:
> >> On 17/02/2020 18:43, Roger Pau Monne wrote:
> >>> @@ -67,7 +68,20 @@ static void send_IPI_shortcut(unsigned int shortcut, int vector,
> >>>  void send_IPI_mask(const cpumask_t *mask, int vector)
> >>>  {
> >>>      bool cpus_locked = false;
> >>> -    cpumask_t *scratch = this_cpu(scratch_cpumask);
> >>> +    cpumask_t *scratch = this_cpu(send_ipi_cpumask);
> >>> +    unsigned long flags;
> >>> +
> >>> +    if ( in_mc() || in_nmi() )
> >>> +    {
> >>> +        /*
> >>> +         * When in #MC or #MNI context Xen cannot use the per-CPU scratch mask
> >>> +         * because we have no way to avoid reentry, so do not use the APIC
> >>> +         * shorthand.
> >>> +         */
> >>> +        alternative_vcall(genapic.send_IPI_mask, mask, vector);
> >>> +        return;
> >> The set of things you can safely do in an NMI/MCE handler is small, and
> >> does not include sending IPIs.  (In reality, if you're using x2apic, it
> >> is safe to send an IPI because there is no risk of clobbering ICR2
> >> behind your outer context's back).
> >>
> >> However, if we escalate from NMI/MCE context into crash context, then
> >> anything goes.  In reality, we only ever send NMIs from the crash path,
> >> and that is not permitted to use a shorthand, making this code dead.
> > This was requested by Jan, as safety measure
> 
> That may be, but it doesn't mean it is correct.  If execution ever
> enters this function in NMI/MCE context, there is a real,
> state-corrupting bug, higher up the call stack.

Ack, then I guess we should just BUG() here if ever called from #NMI
or #MC context?

Thanks, Roger.

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

  reply	other threads:[~2020-02-18 11:23 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-17 18:43 [Xen-devel] [PATCH v2 0/6] x86: fixes/improvements for scratch cpumask Roger Pau Monne
2020-02-17 18:43 ` [Xen-devel] [PATCH v2 1/6] x86/smp: unify header includes in smp.h Roger Pau Monne
2020-02-17 18:43 ` [Xen-devel] [PATCH v2 2/6] x86: introduce a nmi_count tracking variable Roger Pau Monne
2020-02-17 18:43 ` [Xen-devel] [PATCH v2 3/6] x86: track when in #MC context Roger Pau Monne
2020-02-17 19:29   ` Julien Grall
2020-02-18  9:45     ` Roger Pau Monné
2020-02-18  9:48     ` Roger Pau Monné
2020-02-18 11:20       ` Julien Grall
2020-02-17 18:43 ` [Xen-devel] [PATCH v2 4/6] x86: track when in #NMI context Roger Pau Monne
2020-02-18 10:40   ` Andrew Cooper
2020-02-18 10:59     ` Roger Pau Monné
2020-02-17 18:43 ` [Xen-devel] [PATCH v2 5/6] x86/smp: use a dedicated scratch cpumask in send_IPI_mask Roger Pau Monne
2020-02-18 10:53   ` Andrew Cooper
2020-02-18 11:10     ` Roger Pau Monné
2020-02-18 11:21       ` Andrew Cooper
2020-02-18 11:22         ` Roger Pau Monné [this message]
2020-02-18 11:35           ` Andrew Cooper
2020-02-18 11:46             ` Roger Pau Monné
2020-02-18 13:29               ` Andrew Cooper
2020-02-18 14:43                 ` Roger Pau Monné
2020-02-18 15:34                   ` Andrew Cooper
2020-02-18 15:40                     ` Jan Beulich
2020-02-18 16:18                       ` Roger Pau Monné
2020-02-18 16:33                         ` Jan Beulich
2020-02-18 11:28         ` Jan Beulich
2020-02-18 11:44           ` Andrew Cooper
2020-02-17 18:43 ` [Xen-devel] [PATCH v2 6/6] x86: add accessors for scratch cpu mask Roger Pau Monne
2020-02-18  7:40 ` [Xen-devel] [PATCH v2 0/6] x86: fixes/improvements for scratch cpumask Jürgen Groß
2020-02-18 10:15   ` Roger Pau Monné
2020-02-18 10:46     ` Jürgen Groß
2020-02-18 10:26   ` Andrew Cooper
2020-02-18 10:54     ` Jürgen Groß

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=20200218112238.GT4679@Air-de-Roger \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=linux@eikelenboom.it \
    --cc=wl@xen.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.