xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: [PATCH] x86/emul: Adjustments to exception error code handling
Date: Mon, 5 Feb 2018 10:59:25 +0000	[thread overview]
Message-ID: <1517828365-18075-1-git-send-email-andrew.cooper3@citrix.com> (raw)

The mkec() end result in c/s bac133d43 wasn't really what I intended, and
unfortunately hides programmer errors if passing an error code with an
exception which doesn't take one.

Rework mkec() completely to simply insert X86_EVENT_NO_EC if no error code
parameter was provided.  It still is the programmers responsibility to get
error codes correct, but an error will now trip an ASSERT() later during event
injection.  All current generate_exception_if() users appear to be correct.

There is a minor improvement:

  add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-301 (-301)
  function                                     old     new   delta
  protmode_load_seg                           1460    1442     -18
  x86_emulate                               103975  103692    -283

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index f22f821..0b472b0 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -877,14 +877,12 @@ do {                                                    \
     if ( rc ) goto done;                                \
 } while (0)
 
-static inline int mkec(uint8_t e, int32_t ec, ...)
-{
-    return (e < 32 && ((1u << e) & EXC_HAS_EC)) ? ec : X86_EVENT_NO_EC;
-}
+/* CPP magic.  Chooses ec if not empty, otherwise X86_EVENT_NO_EC. */
+#define mkec(ignore, x, ...) x
 
 #define generate_exception_if(p, e, ec...)                                \
 ({  if ( (p) ) {                                                          \
-        x86_emul_hw_exception(e, mkec(e, ##ec, 0), ctxt);                 \
+        x86_emul_hw_exception(e, mkec(X, ##ec, X86_EVENT_NO_EC), ctxt);   \
         rc = X86EMUL_EXCEPTION;                                           \
         goto done;                                                        \
     }                                                                     \
-- 
2.1.4


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

             reply	other threads:[~2018-02-05 10:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 10:59 Andrew Cooper [this message]
2018-02-05 13:32 ` [PATCH] x86/emul: Adjustments to exception error code handling Jan Beulich
2018-02-05 16:00   ` Andrew Cooper
2018-02-05 16:26     ` 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=1517828365-18075-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --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 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).