All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/traps: Fix failed ASSERT() in do_guest_trap()
@ 2016-08-10  9:53 Andrew Cooper
  2016-08-10 10:07 ` Jan Beulich
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Cooper @ 2016-08-10  9:53 UTC (permalink / raw)
  To: Xen-devel; +Cc: Andrew Cooper, Wei Liu, Jan Beulich

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>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wei.liu2@citrix.com>

RFC:

1) Should we start making use of Linux's "Fixes:" tag?

2) I considered using TRAP_nr instead of 32, but "(trapnr < TRAP_nr)" is odd,
and it hides the visual correctness of seeing that 1u is never shifted out of
range.
---
 xen/arch/x86/traps.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index c228b45..e822719 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -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);
 
-- 
2.1.4


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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] x86/traps: Fix failed ASSERT() in do_guest_trap()
  2016-08-10  9:53 [PATCH] x86/traps: Fix failed ASSERT() in do_guest_trap() Andrew Cooper
@ 2016-08-10 10:07 ` Jan Beulich
  0 siblings, 0 replies; 2+ messages in thread
From: Jan Beulich @ 2016-08-10 10:07 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: Wei Liu, Xen-devel

>>> On 10.08.16 at 11:53, <andrew.cooper3@citrix.com> wrote:
> 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>

> RFC:
> 
> 1) Should we start making use of Linux's "Fixes:" tag?

It wouldn't hurt if someone did, but mentioning the offending commit
in the description would seem enough (and often better) to me. In no
case would I like seeing just a commit ID, without also the title being
quoted, as that will always mean one has to consult the repo for
understanding what exact change was broken (that is, of course,
only for those of us who can't memorize all the commit ID-s and their
respective titles of the last few years).

> 2) I considered using TRAP_nr instead of 32, but "(trapnr < TRAP_nr)" is odd,
> and it hides the visual correctness of seeing that 1u is never shifted out of
> range.

Either variant is fine with me.

Jan


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-08-10 10:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-10  9:53 [PATCH] x86/traps: Fix failed ASSERT() in do_guest_trap() Andrew Cooper
2016-08-10 10:07 ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.