xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH v3 01/18] x86emul: catch exceptions occurring in stubs
Date: Wed, 15 Feb 2017 11:27:58 +0000	[thread overview]
Message-ID: <3135d9be-eac8-df43-122f-ecfb9f538bf7@citrix.com> (raw)
In-Reply-To: <58A44456020000780013A193@prv-mh.provo.novell.com>

On 15/02/17 11:06, Jan Beulich wrote:
> --- a/xen/arch/x86/x86_emulate/x86_emulate.c
> +++ b/xen/arch/x86/x86_emulate/x86_emulate.c
> @@ -604,14 +604,42 @@ do{ asm volatile (
>  #define __emulate_1op_8byte(_op, _dst, _eflags)
>  #endif /* __i386__ */
>  
> +#ifdef __XEN__
> +# define invoke_stub(pre, post, constraints...) do {                    \
> +    union stub_exception_token res_ = { .raw = ~0 };                    \
> +    asm volatile ( pre "\n\tcall *%[stub]\n\t" post "\n"                \
> +                   ".Lret%=:\n\t"                                       \
> +                   ".pushsection .fixup,\"ax\"\n"                       \
> +                   ".Lfix%=:\n\t"                                       \
> +                   "pop %[exn]\n\t"                                     \
> +                   "jmp .Lret%=\n\t"                                    \
> +                   ".popsection\n\t"                                    \
> +                   _ASM_EXTABLE(.Lret%=, .Lfix%=)                       \
> +                   : [exn] "+g" (res_), constraints,                    \
> +                     [stub] "rm" (stub.func) );                         \
> +    if ( unlikely(~res_.raw) )                                          \
> +    {                                                                   \
> +        gprintk(XENLOG_WARNING,                                         \
> +                "exception %u (ec=%04x) in emulation stub (line %u)\n", \
> +                res_.fields.trapnr, res_.fields.ec, __LINE__);          \

Can we also hexdump the stub here?

In the non UD case, it might also be nice to dump the GPR state, but it
is too late to be useful here, and I am not sure doing so in the
exception handler is a good idea either. 

As we manually adjust the GPR input to the stubs, the combination of the
hexdump, the exception/error code and specific stub invocation ought to
be enough information to usefully investigate with.

> +        if ( res_.fields.trapnr != EXC_UD )                             \
> +            domain_crash(current->domain);                              \

goto done?

Otherwise, Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

> +        else                                                            \
> +            generate_exception(EXC_UD);                                 \
> +    }                                                                   \
> +} while (0)
> +#else
> +# define invoke_stub(pre, post, constraints...)                         \
> +    asm volatile ( pre "\n\tcall *%[stub]\n\t" post                     \
> +                   : constraints, [stub] "rm" (stub.func) )
> +#endif
> +
>  #define emulate_stub(dst, src...) do {                                  \
>      unsigned long tmp;                                                  \
> -    asm volatile ( _PRE_EFLAGS("[efl]", "[msk]", "[tmp]")               \
> -                   "call *%[stub];"                                     \
> -                   _POST_EFLAGS("[efl]", "[msk]", "[tmp]")              \
> -                   : dst, [tmp] "=&r" (tmp), [efl] "+g" (_regs._eflags) \
> -                   : [stub] "r" (stub.func),                            \
> -                     [msk] "i" (EFLAGS_MASK), ## src );                 \
> +    invoke_stub(_PRE_EFLAGS("[efl]", "[msk]", "[tmp]"),                 \
> +                _POST_EFLAGS("[efl]", "[msk]", "[tmp]"),                \
> +                dst, [tmp] "=&r" (tmp), [efl] "+g" (_regs._eflags)      \
> +                : [msk] "i" (EFLAGS_MASK), ## src);                     \
>  } while (0)
>  
>  /* Fetch next part of the instruction being emulated. */


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

  reply	other threads:[~2017-02-15 11:28 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-15 10:47 [PATCH v3 00/18] x86emul: MMX/SSEn support Jan Beulich
2017-02-15 11:06 ` [PATCH v3 01/18] x86emul: catch exceptions occurring in stubs Jan Beulich
2017-02-15 11:27   ` Andrew Cooper [this message]
2017-02-15 11:49     ` Jan Beulich
2017-02-15 16:55     ` [PATCH v3.1 " Jan Beulich
2017-02-15 11:07 ` [PATCH v3 02/18] x86emul: support most memory accessing MMX/SSE{, 2, 3} insns Jan Beulich
2017-02-20 13:45   ` Andrew Cooper
2017-02-20 14:52     ` Jan Beulich
2017-02-20 18:40       ` Andrew Cooper
2017-02-21  8:44         ` Jan Beulich
2017-02-15 11:08 ` [PATCH v3 03/18] x86emul: support MMX/SSE{,2,3} moves Jan Beulich
2017-02-15 11:09 ` [PATCH v3 04/18] x86emul: support MMX/SSE/SSE2 converts Jan Beulich
2017-02-15 11:09 ` [PATCH v3 05/18] x86emul: support {,V}{,U}COMIS{S,D} Jan Beulich
2017-02-20 15:28   ` [PATCH v3 05/18] x86emul: support {, V}{, U}COMIS{S, D} Jan Beulich
2017-02-15 11:10 ` [PATCH v3 06/18] x86emul: support MMX/SSE/SSE2 insns with only register operands Jan Beulich
2017-02-15 11:11 ` [PATCH v3 07/18] x86emul: support {,V}{LD,ST}MXCSR Jan Beulich
2017-02-20 14:52   ` Andrew Cooper
2017-02-20 15:12     ` Jan Beulich
2017-02-20 15:33       ` Jan Beulich
2017-02-15 11:12 ` [PATCH v3 08/18] x86emul: support {,V}MOVNTDQA Jan Beulich
2017-02-20 15:01   ` Andrew Cooper
2017-02-20 15:13     ` Jan Beulich
2017-02-15 11:12 ` [PATCH v3 09/18] x86emul/test: split generic and testcase specific parts Jan Beulich
2017-02-20 15:13   ` Andrew Cooper
2017-02-15 11:13 ` [PATCH v3 10/18] x86emul: test coverage for SSE/SSE2 insns Jan Beulich
2017-02-20 15:24   ` Andrew Cooper
2017-02-20 15:40     ` Jan Beulich
2017-02-20 15:41       ` Andrew Cooper
2017-02-15 11:14 ` [PATCH v3 11/18] x86emul: honor MMXEXT feature flag Jan Beulich
2017-02-20 15:37   ` Andrew Cooper
2017-02-15 11:14 ` [PATCH v3 12/18] x86emul: add tables for 0f38 and 0f3a extension space Jan Beulich
2017-02-20 16:05   ` Andrew Cooper
2017-02-21  8:52     ` Jan Beulich
2017-02-15 11:15 ` [PATCH v3 13/18] x86emul: support SSSE3 insns Jan Beulich
2017-02-15 11:15 ` [PATCH v3 14/18] x86emul: support SSE4.1 insns Jan Beulich
2017-02-15 11:16 ` [PATCH v3 15/18] x86emul: support SSE4.2 insns Jan Beulich
2017-02-15 11:16 ` [PATCH v3 16/18] x86emul: support PCLMULQDQ Jan Beulich
2017-02-15 11:17 ` [PATCH v3 17/18] x86emul: support AESNI insns Jan Beulich
2017-02-15 11:17 ` [PATCH v3 18/18] x86emul: support SHA insns Jan Beulich

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=3135d9be-eac8-df43-122f-ecfb9f538bf7@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --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;
as well as URLs for NNTP newsgroup(s).