From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Andy Lutomirski <luto@amacapital.net>
Cc: Juergen Gross <jgross@suse.com>, X86 ML <x86@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
"xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [Xen-devel] [PATCH v1] xen: get rid of paravirt op adjust_exception_frame
Date: Wed, 26 Jul 2017 15:31:27 +0100 [thread overview]
Message-ID: <53f936d4-c6e0-3e9b-4291-8f16cbb87779@citrix.com> (raw)
In-Reply-To: <CALCETrW1ky01H8akGx2sMqL8ogQBibKaQO+tT4x8D13de5w97g@mail.gmail.com>
On 26/07/17 15:09, Andy Lutomirski wrote:
> On Wed, Jul 26, 2017 at 7:01 AM, Andrew Cooper
> <andrew.cooper3@citrix.com> wrote:
>> On 26/07/17 14:48, Andy Lutomirski wrote:
>>>> /* Runs on exception stack */
>>>> -ENTRY(nmi)
>>>> - /*
>>>> - * Fix up the exception frame if we're on Xen.
>>>> - * PARAVIRT_ADJUST_EXCEPTION_FRAME is guaranteed to push at most
>>>> - * one value to the stack on native, so it may clobber the rdx
>>>> - * scratch slot, but it won't clobber any of the important
>>>> - * slots past it.
>>>> - *
>>>> - * Xen is a different story, because the Xen frame itself overlaps
>>>> - * the "NMI executing" variable.
>>>> - */
>>> I would keep this comment. The Xen frame really is in the way AFAICT.
>> (For reasons best explained by the original authors) there is only ever
>> a single stack which a PV guest registers with Xen, which functions
>> equivalently to tss.sp0. There is no support for stack switching via
>> task switch or IST.
>>
>> Therefore, nested NMIs won't clobber the top of this stack.
>>
> Does that mean that nested NMIs on Xen just nest normally without
> clobbering each other?
Yes.
> If so, that's neat, although I wonder how we
> don't get crashes due to this:
>
> /* Normal 64-bit system call target */
> ENTRY(xen_syscall_target)
> undo_xen_syscall
> <-- NMI right here
> jmp entry_SYSCALL_64_after_swapgs
> ENDPROC(xen_syscall_target)
I'm going to go out on a limb here and say "because no has hit that
condition yet" (or at least managed to diagnose such a crash).
PV domU's don't get given NMIs. PV dom0 might, depending on how Xen is
handling the NMI itself. On XenServer at least, dom0 never gets handed
an NMI.
I expect is a sufficiently rarely used path that noone has noticed if it
is indeed broken.
~Andrew
>
> I think it would be nice if Xen could instead enter the native syscall
> path a bit later like this:
>
> ENTRY(entry_SYSCALL_64)
> /*
> * Interrupts are off on entry.
> * We do not frame this tiny irq-off block with TRACE_IRQS_OFF/ON,
> * it is too small to ever cause noticeable irq latency.
> */
> SWAPGS_UNSAFE_STACK
> /*
> * A hypervisor implementation might want to use a label
> * after the swapgs, so that it can do the swapgs
> * for the guest and jump here on syscall.
> */
> GLOBAL(entry_SYSCALL_64_after_swapgs)
>
> movq %rsp, PER_CPU_VAR(rsp_scratch)
> movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp
>
> TRACE_IRQS_OFF
>
> /* Construct struct pt_regs on stack */
> pushq $__USER_DS /* pt_regs->ss */
> pushq PER_CPU_VAR(rsp_scratch) /* pt_regs->sp */
> pushq %r11 /* pt_regs->flags */
> pushq $__USER_CS /* pt_regs->cs */
> pushq %rcx /* pt_regs->ip */
>
> <-- Xen enters here
>
> then we wouldn't have all this funny business. And Xen could
> completely skip the nmi nesting code.
next prev parent reply other threads:[~2017-07-26 14:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-24 14:28 Juergen Gross
2017-07-26 12:59 ` Boris Ostrovsky
2017-07-26 13:48 ` Andy Lutomirski
2017-07-26 14:01 ` [Xen-devel] " Andrew Cooper
2017-07-26 14:09 ` Andy Lutomirski
2017-07-26 14:31 ` Andrew Cooper [this message]
2017-07-26 15:12 ` Juergen Gross
2017-07-26 15:50 ` Juergen Gross
2017-07-26 17:57 ` Andy Lutomirski
2017-07-26 18:43 ` Juergen Gross
2017-07-26 20:15 ` Andy Lutomirski
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=53f936d4-c6e0-3e9b-4291-8f16cbb87779@citrix.com \
--to=andrew.cooper3@citrix.com \
--cc=boris.ostrovsky@oracle.com \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@redhat.com \
--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 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®