[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] x86/emul: Adjustments to exception error code handling



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@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.