x86/pv: Fix bugs with the handling of int80_bounce
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 5 May 2017 16:38:19 +0000 (17:38 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 9 May 2017 18:00:04 +0000 (19:00 +0100)
Testing has revealed two issues:

 1) Passing a NULL handle to set_trap_table() is intended to flush the entire
    table.  The 64bit guest case (and 32bit guest on 32bit Xen, when it
    existed) called init_int80_direct_trap() to reset int80_bounce, but c/s
    cda335c279 which introduced the 32bit guest on 64bit Xen support omitted
    this step.  Previously therefore, it was impossible for a 32bit guest to
    reset its registered int80_bounce details.

 2) init_int80_direct_trap() doesn't honour the guests request to have
    interrupts disabled on entry.  PVops Linux requests that interrupts are
    disabled, but Xen currently leaves them enabled when following the int80
    fastpath.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Release-acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/x86/x86_64/compat/traps.c
xen/arch/x86/x86_64/traps.c

index 8e9a11ccb088fec86b3f2ce4b8029ad7680651aa..1751ec67e8d0ee54ef53973af04329447dd2e347 100644 (file)
@@ -339,6 +339,7 @@ int compat_set_trap_table(XEN_GUEST_HANDLE(trap_info_compat_t) traps)
     if ( guest_handle_is_null(traps) )
     {
         memset(dst, 0, NR_VECTORS * sizeof(*dst));
+        init_int80_direct_trap(current);
         return 0;
     }
 
index ad4d6c1f44d7cbffb1a729105eb8f030dbde8cf1..78f410517cbfc47cf83583f906afaa2fa0b0850f 100644 (file)
@@ -427,12 +427,13 @@ void init_int80_direct_trap(struct vcpu *v)
     struct trap_info *ti = &v->arch.pv_vcpu.trap_ctxt[0x80];
     struct trap_bounce *tb = &v->arch.pv_vcpu.int80_bounce;
 
-    tb->flags = TBF_EXCEPTION;
     tb->cs    = ti->cs;
     tb->eip   = ti->address;
 
     if ( null_trap_bounce(v, tb) )
         tb->flags = 0;
+    else
+        tb->flags = TBF_EXCEPTION | (TI_GET_IF(ti) ? TBF_INTERRUPT : 0);
 }
 
 static long register_guest_callback(struct callback_register *reg)