All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: keir@xen.org, tim@xen.org, xen-devel@lists.xen.org
Subject: Re: Xen crash: map_domain_page() on an NMI path
Date: Thu, 19 Dec 2013 16:19:06 +0000	[thread overview]
Message-ID: <52B31C7A.5040802@citrix.com> (raw)
In-Reply-To: <52B308E702000078000A99D4@nat28.tlf.novell.com>

On 19/12/13 14:55, Jan Beulich wrote:
>>>> Andrew Cooper <andrew.cooper3@citrix.com> 12/18/13 8:37 PM >>>
>> However, the interesting point is the nested crash.  This is a failed
>> assertion while attempting to execute the kexec crash path.  Xen is
>> 4.3.1 based, and built with debug, so the stack trace below is generated
>> with frame pointers, and is correct.
>> ...
>> Here, we have managed to re-enter the __context_switch() path because of
>> an NMI interrupting it.  The sync_local_execstate() in map_domain_page()
>> is by way of mapcache_current_vcpu().
>>
>> I am struggling to work out how best to fix this.  Would it be best for
>> the crash path to unconditionally change to the idle_pagetables and use
>> mapcache_override_current(NULL)?
> It is wrong to at all call map_domain_page() in NMI context, so fixing the
> environment for it to get invoked is not the right solution in any case (or
> else you'd have to fix more than this, like forcibly making the spin lock
> available that the code will want to acquire subsequently).
>
> As with anything else on the NMI path, and as you probably know better
> than me - great care is needed in every piece of code that may get
> invoked here. I don't think we want to make map_domain_page() usable
> in NMI context; instead I would think map_vtd_domain_page() might
> better learn of possibly getting called this way, and use fixmaps in that
> case (assuming we can determine a reasonably low maximum number of
> pages that may need to be mapped this way at any one time - ideally that
> would turn out to be just one).
>
> Jan

I would certainly agree that anything complicated in NMI context
(map_domain_page() included) must be completely avoided.

However, once we have started crashing, I would argue we have moved to a
new context (a 'crashing' context perhaps?), which must be able to
function correctly, no matter which context it originated from (be it
regular, interrupt, NMI or MCE contexts).  The advantage of the crashing
context is that we can safely trash anything we need to, in order to
execute purgatory with sensible state.


This particular use of map_vtd_domain_page() is for the qinval control
region, which looks to be up to 8 contiguous frames, per IOMMU.  There
are another 8 frames per IOMMU for the intremap control region (and
other control regions as well).

I don't think this practical to put all of this in the fixmap.

However, for hardware pieces like this which are set up once at the
start of day, and have the hardware pointed at a chosen region, would it
be acceptable to allocate their frames low enough to be covered by the
direct map area (protected by BUG()s?) and set up their base virtual
addresses knowing that there will always be a valid mapping from any Xen
pagetables?  This seems better than constantly playing around with the
mappings.


For the 'crashing' context, I was thinking of extending enum
system_state to include "panic" and "crash_single" states, where
crash_single implies "safe to not actually lock a spinlock"  Integrating
this without an adverse effect on spinlock performance might be a little
tricky however.

~Andrew

  reply	other threads:[~2013-12-19 16:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-18 19:37 Xen crash: map_domain_page() on an NMI path Andrew Cooper
2013-12-19 11:00 ` Tim Deegan
2013-12-19 12:11   ` Andrew Cooper
2013-12-19 14:55 ` Jan Beulich
2013-12-19 16:19   ` Andrew Cooper [this message]
2013-12-20  8:43     ` Jan Beulich
2013-12-27  7:29       ` Kai Huang
2013-12-27 11:38         ` Andrew Cooper

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=52B31C7A.5040802@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=tim@xen.org \
    --cc=xen-devel@lists.xen.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.