]> xenbits.xensource.com Git - xen.git/commitdiff
x86/emul: Avoid #UD in SIMD stubs
authorAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 7 Mar 2017 23:32:24 +0000 (23:32 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Wed, 8 Mar 2017 13:06:09 +0000 (13:06 +0000)
v{,u}comis{s,d}, and vcvt{,t}s{s,d}2si are two-operand instructions, while
vzero{all,upper} take no operands.  Each require vex.reg set to ~0 to avoid
suffering #UD.

Spotted while fuzzing with AFL
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/x86_emulate/x86_emulate.c

index 1b507f73d8de4dbff44ee2a2bb2e8957fc3e8435..613648e53f54f8a656a529e0b62ecdfa19cc45dd 100644 (file)
@@ -5620,7 +5620,7 @@ x86_emulate(
         {
             if ( ctxt->vendor == X86_VENDOR_AMD )
                 vex.l = 0;
-            generate_exception_if(vex.l, EXC_UD);
+            generate_exception_if(vex.l || vex.reg != 0xf, EXC_UD);
             host_and_vcpu_must_have(avx);
             get_fpu(X86EMUL_FPU_ymm, &fic);
         }
@@ -5673,6 +5673,7 @@ x86_emulate(
         }
         else
         {
+            generate_exception_if(vex.reg != 0xf, EXC_UD);
             host_and_vcpu_must_have(avx);
             get_fpu(X86EMUL_FPU_ymm, &fic);
         }
@@ -6273,6 +6274,7 @@ x86_emulate(
     case X86EMUL_OPC_VEX(0x0f, 0x77):    /* vzero{all,upper} */
         if ( vex.opcx != vex_none )
         {
+            generate_exception_if(vex.reg != 0xf, EXC_UD);
             host_and_vcpu_must_have(avx);
             get_fpu(X86EMUL_FPU_ymm, &fic);
         }