]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
x86/emul: Correct the return value handling of VMFUNC
authorAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 18 Jan 2017 08:51:53 +0000 (09:51 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 18 Jan 2017 08:51:53 +0000 (09:51 +0100)
The bracketing of x86_emulate() calling the ops->vmfunc() hook is wrong with
respect to the assignment to rc, which can trip the new assertions in
x86_emulate_wrapper().

The hvmemul_vmfunc() hook should only raise #UD if X86EMUL_EXCEPTION is
returned.  This is only a latent bug at the moment.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
master commit: 3ab1876504d409689824e161a8b04e57e1e5dd46
master date: 2016-12-22 13:32:46 +0000

xen/arch/x86/hvm/emulate.c
xen/arch/x86/x86_emulate/x86_emulate.c

index f32b7dc210d1945a5b2c03186a22d6a7bf499fe6..40fa4f03452291786917e0ebc0e395e0b987d399 100644 (file)
@@ -1697,7 +1697,7 @@ static int hvmemul_vmfunc(
     if ( !hvm_funcs.altp2m_vcpu_emulate_vmfunc )
         return X86EMUL_UNHANDLEABLE;
     rc = hvm_funcs.altp2m_vcpu_emulate_vmfunc(ctxt->regs);
-    if ( rc != X86EMUL_OKAY )
+    if ( rc == X86EMUL_EXCEPTION )
         hvmemul_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE,
                                     ctxt);
 
index 6bb3c7462180ab26e4b5ec5bea6d5307c66b7a83..b06c456286c0cc1eb94308bcd36c9ca3e188e964 100644 (file)
@@ -4356,7 +4356,7 @@ x86_emulate(
             generate_exception_if(lock_prefix | rep_prefix() | (vex.pfx == vex_66),
                                   EXC_UD, -1);
             fail_if(!ops->vmfunc);
-            if ( (rc = ops->vmfunc(ctxt) != X86EMUL_OKAY) )
+            if ( (rc = ops->vmfunc(ctxt)) != X86EMUL_OKAY )
                 goto done;
             goto no_writeback;