x86/traps: Fix failed ASSERT() in do_guest_trap()
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 10 Aug 2016 09:41:28 +0000 (10:41 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 10 Aug 2016 11:44:02 +0000 (12:44 +0100)
c/s 2e426d6 "x86/traps: Drop use_error_code parameter from do_{,guest_}trap()"
introduced an assertion which covered the correctness of shifting 1u by an
input parameter.

While all other inputs provide a constants vector, the `int $N` handling path
from do_general_protection() passes any vector.

This path is triggered by XTF, which uses `int 0x20` to facilitate returning
to kernel mode after running specific tests in user mode.

No vectors above 32 have an error code, so adjust the logic to cope.

Reported-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/traps.c

index c228b454d49e67eba4ef4f9989a22fac5c20fc63..e822719e95c5107bc072a8a67476f272307d906d 100644 (file)
@@ -631,11 +631,8 @@ static void do_guest_trap(unsigned int trapnr,
     struct vcpu *v = current;
     struct trap_bounce *tb;
     const struct trap_info *ti;
-    bool_t use_error_code;
-
-    ASSERT(trapnr < 32);
-
-    use_error_code = (TRAP_HAVE_EC & (1u << trapnr));
+    const bool use_error_code =
+        ((trapnr < 32) && (TRAP_HAVE_EC & (1u << trapnr)));
 
     trace_pv_trap(trapnr, regs->eip, use_error_code, regs->error_code);