From: "Jan Beulich" Subject: [PATCH 2/2] x86/emulator: generalize movq emulation (SSE2 and AVX variants) Date: Wed, 16 Nov 2011 14:00:22 +0000 Message-ID: <4EC3D00602000078000614FC@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartC2ED42E6.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartC2ED42E6.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Extend the existing movq emulation to also support its SSE2 and AVX variants, the latter implying the addition of VEX decoding. Fold the read and write cases (as most of the logic is identical), and add movntq and variants (as they're very similar). Extend the testing code to also exercise these instructions. Signed-off-by: Jan Beulich --- a/tools/tests/x86_emulator/test_x86_emulator.c +++ b/tools/tests/x86_emulator/test_x86_emulator.c @@ -1,3 +1,5 @@ +#include +#include #include #include #include @@ -53,11 +55,84 @@ static int cmpxchg( return X86EMUL_OKAY; } =20 +static int cpuid( + unsigned int *eax, + unsigned int *ebx, + unsigned int *ecx, + unsigned int *edx, + struct x86_emulate_ctxt *ctxt) +{ + asm ("cpuid" : "+a" (*eax), "+c" (*ecx), "=3Dd" (*edx), "=3Db" = (*ebx)); + return X86EMUL_OKAY; +} + +#define cpu_has_mmx ({ \ + unsigned int eax =3D 1, ecx =3D 0, edx; \ + cpuid(&eax, &ecx, &ecx, &edx, NULL); \ + (edx & (1U << 23)) !=3D 0; \ +}) + +#define cpu_has_sse ({ \ + unsigned int eax =3D 1, ecx =3D 0, edx; \ + cpuid(&eax, &ecx, &ecx, &edx, NULL); \ + (edx & (1U << 25)) !=3D 0; \ +}) + +#define cpu_has_sse2 ({ \ + unsigned int eax =3D 1, ecx =3D 0, edx; \ + cpuid(&eax, &ecx, &ecx, &edx, NULL); \ + (edx & (1U << 26)) !=3D 0; \ +}) + +static inline uint64_t xgetbv(uint32_t xcr) +{ + uint64_t res; + + asm ( ".byte 0x0f, 0x01, 0xd0" : "=3DA" (res) : "c" (xcr) ); + + return res; +} + +#define cpu_has_avx ({ \ + unsigned int eax =3D 1, ecx =3D 0, edx; \ + cpuid(&eax, &edx, &ecx, &edx, NULL); \ + if ( !(ecx & (1U << 27)) || (xgetbv(0) & 6) !=3D 6 ) \ + ecx =3D 0; \ + (ecx & (1U << 28)) !=3D 0; \ +}) + +int get_fpu( + void (*exception_callback)(void *, struct cpu_user_regs *), + void *exception_callback_arg, + enum x86_emulate_fpu_type type, + struct x86_emulate_ctxt *ctxt) +{ + switch ( type ) + { + case X86EMUL_FPU_fpu: + break; + case X86EMUL_FPU_ymm: + if ( cpu_has_avx ) + break; + case X86EMUL_FPU_xmm: + if ( cpu_has_sse ) + break; + case X86EMUL_FPU_mmx: + if ( cpu_has_mmx ) + break; + default: + return X86EMUL_UNHANDLEABLE; + } + return X86EMUL_OKAY; +} + static struct x86_emulate_ops emulops =3D { .read =3D read, .insn_fetch =3D read, .write =3D write, .cmpxchg =3D cmpxchg, + .cpuid =3D cpuid, + .get_fpu =3D get_fpu, }; =20 int main(int argc, char **argv) @@ -66,6 +141,8 @@ int main(int argc, char **argv) struct cpu_user_regs regs; char *instr; unsigned int *res, i, j; + unsigned long sp; + bool stack_exec; int rc; #ifndef __x86_64__ unsigned int bcdres_native, bcdres_emul; @@ -85,6 +162,16 @@ int main(int argc, char **argv) } instr =3D (char *)res + 0x100; =20 +#ifdef __x86_64__ + asm ("movq %%rsp, %0" : "=3Dg" (sp)); +#else + asm ("movl %%esp, %0" : "=3Dg" (sp)); +#endif + stack_exec =3D mprotect((void *)(sp & -0x1000L) - (MMAP_SZ - 0x1000), + MMAP_SZ, PROT_READ|PROT_WRITE|PROT_EXEC) =3D=3D = 0; + if ( !stack_exec ) + printf("Warning: Stack could not be made executable (%d).\n", = errno); + printf("%-40s", "Testing addl %%ecx,(%%eax)..."); instr[0] =3D 0x01; instr[1] =3D 0x08; regs.eflags =3D 0x200; @@ -442,6 +529,108 @@ int main(int argc, char **argv) printf("skipped\n"); #endif =20 + printf("%-40s", "Testing movq %mm3,(%ecx)..."); + if ( stack_exec && cpu_has_mmx ) + { + extern const unsigned char movq_to_mem[]; + + asm volatile ( "pcmpeqb %%mm3, %%mm3\n" + ".pushsection .test, \"a\", @progbits\n" + "movq_to_mem: movq %%mm3, (%0)\n" + ".popsection" :: "c" (NULL) ); + + memcpy(instr, movq_to_mem, 15); + memset(res, 0x33, 64); + memset(res + 8, 0xff, 8); + regs.eip =3D (unsigned long)&instr[0]; + regs.ecx =3D (unsigned long)res; + rc =3D x86_emulate(&ctxt, &emulops); + if ( (rc !=3D X86EMUL_OKAY) || + memcmp(res, res + 8, 32) ) + goto fail; + printf("okay\n"); + } + else + printf("skipped\n"); + + printf("%-40s", "Testing movq (%edx),%mm5..."); + if ( stack_exec && cpu_has_mmx ) + { + extern const unsigned char movq_from_mem[]; + + asm volatile ( "pcmpgtb %%mm5, %%mm5\n" + ".pushsection .test, \"a\", @progbits\n" + "movq_from_mem: movq (%0), %%mm5\n" + ".popsection" :: "d" (NULL) ); + + memcpy(instr, movq_from_mem, 15); + regs.eip =3D (unsigned long)&instr[0]; + regs.ecx =3D 0; + regs.edx =3D (unsigned long)res; + rc =3D x86_emulate(&ctxt, &emulops); + if ( rc !=3D X86EMUL_OKAY ) + goto fail; + asm ( "pcmpeqb %%mm3, %%mm3\n\t" + "pcmpeqb %%mm5, %%mm3\n\t" + "pmovmskb %%mm3, %0" : "=3Dr" (rc) ); + if ( rc !=3D 0xff ) + goto fail; + printf("okay\n"); + } + else + printf("skipped\n"); + + printf("%-40s", "Testing movdqu %xmm2,(%ecx)..."); + if ( stack_exec && cpu_has_sse2 ) + { + extern const unsigned char movdqu_to_mem[]; + + asm volatile ( "pcmpeqb %%xmm2, %%xmm2\n" + ".pushsection .test, \"a\", @progbits\n" + "movdqu_to_mem: movdqu %%xmm2, (%0)\n" + ".popsection" :: "c" (NULL) ); + + memcpy(instr, movdqu_to_mem, 15); + memset(res, 0x55, 64); + memset(res + 8, 0xff, 16); + regs.eip =3D (unsigned long)&instr[0]; + regs.ecx =3D (unsigned long)res; + rc =3D x86_emulate(&ctxt, &emulops); + if ( (rc !=3D X86EMUL_OKAY) || + memcmp(res, res + 8, 32) ) + goto fail; + printf("okay\n"); + } + else + printf("skipped\n"); + + printf("%-40s", "Testing movdqu (%edx),%xmm4..."); + if ( stack_exec && cpu_has_sse2 ) + { + extern const unsigned char movdqu_from_mem[]; + + asm volatile ( "pcmpgtb %%xmm4, %%xmm4\n" + ".pushsection .test, \"a\", @progbits\n" + "movdqu_from_mem: movdqu (%0), %%xmm4\n" + ".popsection" :: "d" (NULL) ); + + memcpy(instr, movdqu_from_mem, 15); + regs.eip =3D (unsigned long)&instr[0]; + regs.ecx =3D 0; + regs.edx =3D (unsigned long)res; + rc =3D x86_emulate(&ctxt, &emulops); + if ( rc !=3D X86EMUL_OKAY ) + goto fail; + asm ( "pcmpeqb %%xmm2, %%xmm2\n\t" + "pcmpeqb %%xmm4, %%xmm2\n\t" + "pmovmskb %%xmm2, %0" : "=3Dr" (rc) ); + if ( rc !=3D 0xffff ) + goto fail; + printf("okay\n"); + } + else + printf("skipped\n"); + for ( j =3D 1; j <=3D 2; j++ ) { #if defined(__i386__) --- a/tools/tests/x86_emulator/x86_emulate.c +++ b/tools/tests/x86_emulator/x86_emulate.c @@ -9,5 +9,10 @@ typedef bool bool_t; =20 #define BUG() abort() =20 +#define DEFINE_PER_CPU(type, var) type this_cpu_##var +#define this_cpu(var) this_cpu_##var + +#define vm86_mode(regs) 0 + #include "x86_emulate/x86_emulate.h" #include "x86_emulate/x86_emulate.c" --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -905,6 +906,20 @@ static int hvmemul_get_fpu( if ( !cpu_has_mmx ) return X86EMUL_UNHANDLEABLE; break; + case X86EMUL_FPU_xmm: + if ( !cpu_has_xmm || + (curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_EM) || + !(curr->arch.hvm_vcpu.guest_cr[4] & X86_CR4_OSFXSR) ) + return X86EMUL_UNHANDLEABLE; + break; + case X86EMUL_FPU_ymm: + if ( !(curr->arch.hvm_vcpu.guest_cr[0] & X86_CR0_PE) || + vm86_mode(ctxt->regs) || + !(curr->arch.hvm_vcpu.guest_cr[4] & X86_CR4_OSXSAVE) || + !(curr->arch.xcr0 & XSTATE_SSE) || + !(curr->arch.xcr0 & XSTATE_YMM) ) + return X86EMUL_UNHANDLEABLE; + break; default: return X86EMUL_UNHANDLEABLE; } --- a/xen/arch/x86/x86_emulate/x86_emulate.c +++ b/xen/arch/x86/x86_emulate/x86_emulate.c @@ -253,6 +253,47 @@ static uint8_t twobyte_table[256] =3D { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; =20 +#define REX_PREFIX 0x40 +#define REX_B 0x01 +#define REX_X 0x02 +#define REX_R 0x04 +#define REX_W 0x08 + +#define vex_none 0 + +enum vex_opcx { + vex_0f =3D vex_none + 1, + vex_0f38, + vex_0f3a, +}; + +enum vex_pfx { + vex_66 =3D vex_none + 1, + vex_f3, + vex_f2 +}; + +union vex { + uint8_t raw[2]; + struct { + uint8_t opcx:5; + uint8_t b:1; + uint8_t x:1; + uint8_t r:1; + uint8_t pfx:2; + uint8_t l:1; + uint8_t reg:4; + uint8_t w:1; + }; +}; + +#define copy_REX_VEX(ptr, rex, vex) do { \ + if ( (vex).opcx !=3D vex_none ) \ + ptr[0] =3D 0xc4, ptr[1] =3D (vex).raw[0], ptr[2] =3D (vex).raw[1];= \ + else if ( mode_64bit() ) \ + ptr[1] =3D rex | REX_PREFIX; \ +} while (0) + /* Type, address-of, and value of an instruction's operand. */ struct operand { enum { OP_REG, OP_MEM, OP_IMM, OP_NONE } type; @@ -281,6 +322,18 @@ struct operand { }; }; =20 +typedef union { + uint64_t mmx; + uint64_t __attribute__ ((aligned(16))) xmm[2]; + uint64_t __attribute__ ((aligned(32))) ymm[4]; +} mmval_t; + +/* + * While alignment gets specified above, this doesn't get honored by the + * compiler for automatic variables. Thus use a per-CPU variable instead. + */ +static DEFINE_PER_CPU(mmval_t, mmval); + /* MSRs. */ #define MSR_TSC 0x00000010 #define MSR_SYSENTER_CS 0x00000174 @@ -972,9 +1025,12 @@ static bool_t vcpu_has( generate_exception_if(!vcpu_has(leaf, subleaf, reg, \ X86_FEATURE_##feature % 32, \ ctxt, ops), EXC_UD, -1) +#define vcpu_must_have_mmx() vcpu_must_have(1, 0, EDX, MMX) +#define vcpu_must_have_sse() vcpu_must_have(1, 0, EDX, XMM) #define vcpu_must_have_sse2() vcpu_must_have(1, 0, EDX, XMM2) #define vcpu_must_have_sse3() vcpu_must_have(1, 0, ECX, XMM3) #define vcpu_must_have_cx16() vcpu_must_have(1, 0, ECX, CX16) +#define vcpu_must_have_avx() vcpu_must_have(1, 0, ECX, AVX) =20 static int in_realmode( @@ -1255,6 +1311,7 @@ x86_emulate( =20 uint8_t b, d, sib, sib_index, sib_base, twobyte =3D 0, rex_prefix =3D = 0; uint8_t modrm =3D 0, modrm_mod =3D 0, modrm_reg =3D 0, modrm_rm =3D = 0; + union vex vex =3D {}; unsigned int op_bytes, def_op_bytes, ad_bytes, def_ad_bytes; #define REPE_PREFIX 1 #define REPNE_PREFIX 2 @@ -1287,6 +1344,7 @@ x86_emulate( { case 0x66: /* operand-size override */ op_bytes =3D def_op_bytes ^ 6; + vex.pfx =3D vex_66; break; case 0x67: /* address-size override */ ad_bytes =3D def_ad_bytes ^ (mode_64bit() ? 12 : 6); @@ -1314,9 +1372,11 @@ x86_emulate( break; case 0xf2: /* REPNE/REPNZ */ rep_prefix =3D REPNE_PREFIX; + vex.pfx =3D vex_f2; break; case 0xf3: /* REP/REPE/REPZ */ rep_prefix =3D REPE_PREFIX; + vex.pfx =3D vex_f3; break; case 0x40 ... 0x4f: /* REX */ if ( !mode_64bit() ) @@ -1360,6 +1420,70 @@ x86_emulate( { modrm =3D insn_fetch_type(uint8_t); modrm_mod =3D (modrm & 0xc0) >> 6; + + if ( !twobyte && (b & ~1) =3D=3D 0xc4 ) + switch ( def_ad_bytes ) + { + default: + BUG(); + case 2: + if ( in_realmode(ctxt, ops) || vm86_mode(&_regs) ) + break; + /* fall through */ + case 4: + if ( modrm_mod !=3D 3 ) + break; + /* fall through */ + case 8: + /* VEX */ + generate_exception_if(rex_prefix || vex.pfx, EXC_UD, -1); + + vex.raw[0] =3D b; + if ( b & 1 ) + { + vex.raw[1] =3D b; + vex.opcx =3D vex_0f; + vex.x =3D 1; + vex.b =3D 1; + vex.w =3D 0; + } + else + { + vex.raw[1] =3D insn_fetch_type(uint8_t); + if ( mode_64bit() ) + { + if ( !vex.b ) + rex_prefix |=3D REX_B; + if ( !vex.x ) + rex_prefix |=3D REX_X; + if ( vex.w ) + { + rex_prefix |=3D REX_W; + op_bytes =3D 8; + } + } + } + vex.reg ^=3D 0xf; + if ( !mode_64bit() ) + vex.reg &=3D 0x7; + else if ( !vex.r ) + rex_prefix |=3D REX_R; + + fail_if(vex.opcx !=3D vex_0f); + twobyte =3D 1; + b =3D insn_fetch_type(uint8_t); + d =3D twobyte_table[b]; + + /* Unrecognised? */ + if ( d =3D=3D 0 ) + goto cannot_emulate; + + modrm =3D insn_fetch_type(uint8_t); + modrm_mod =3D (modrm & 0xc0) >> 6; + + break; + } + modrm_reg =3D ((rex_prefix & 4) << 1) | ((modrm & 0x38) >> 3); modrm_rm =3D modrm & 0x07; =20 @@ -3917,44 +4041,77 @@ x86_emulate( break; } =20 - case 0x6f: /* movq mm/m64,mm */ { - uint8_t stub[] =3D { 0x0f, 0x6f, modrm, 0xc3 }; + case 0x6f: /* movq mm/m64,mm */ + /* {,v}movdq{a,u} xmm/m128,xmm */ + /* vmovdq{a,u} ymm/m256,ymm */ + case 0x7f: /* movq mm,mm/m64 */ + /* {,v}movdq{a,u} xmm,xmm/m128 */ + /* vmovdq{a,u} ymm,ymm/m256 */ + case 0xe7: /* movntq mm,mm/m64 */ + /* {,v}movntdq xmm,xmm/m128 */ + /* vmovntdq{a,u} ymm,ymm/m256 */ + { + uint8_t stub[] =3D { 0x3e, 0x3e, 0x0f, b, modrm, 0xc3 }; struct fpu_insn_ctxt fic =3D { .insn_bytes =3D sizeof(stub)-1 }; - uint64_t val; - if ( ea.type =3D=3D OP_MEM ) + + if ( vex.opcx =3D=3D vex_none ) { - unsigned long lval, hval; - if ( (rc =3D read_ulong(ea.mem.seg, ea.mem.off+0, - &lval, 4, ctxt, ops)) || - (rc =3D read_ulong(ea.mem.seg, ea.mem.off+4, - &hval, 4, ctxt, ops)) ) - goto done; - val =3D ((uint64_t)hval << 32) | (uint32_t)lval; - stub[2] =3D modrm & 0x38; /* movq (%eax),%mmN */ + switch ( vex.pfx ) + { + case vex_f3: + fail_if(b =3D=3D 0xe7); + /* fall through */ + case vex_66: + vcpu_must_have_sse2(); + stub[0] =3D 0x66; /* movdqa */ + get_fpu(X86EMUL_FPU_xmm, &fic); + ea.bytes =3D 16; + break; + case vex_none: + if ( b !=3D 0xe7 ) + vcpu_must_have_mmx(); + else + vcpu_must_have_sse(); + get_fpu(X86EMUL_FPU_mmx, &fic); + ea.bytes =3D 8; + break; + default: + goto cannot_emulate; + } + } + else + { + fail_if(vex.opcx !=3D vex_0f || vex.reg || + (vex.pfx !=3D vex_66 && (vex.pfx !=3D vex_f3 || b = =3D=3D 0xe7))); + vcpu_must_have_avx(); + get_fpu(X86EMUL_FPU_ymm, &fic); + ea.bytes =3D 16 << vex.l; } - get_fpu(X86EMUL_FPU_mmx, &fic); - asm volatile ( "call *%0" : : "r" (stub), "a" (&val) : "memory" = ); - put_fpu(&fic); - break; - } - - case 0x7f: /* movq mm,mm/m64 */ { - uint8_t stub[] =3D { 0x0f, 0x7f, modrm, 0xc3 }; - struct fpu_insn_ctxt fic =3D { .insn_bytes =3D sizeof(stub)-1 }; - uint64_t val; - if ( ea.type =3D=3D OP_MEM ) - stub[2] =3D modrm & 0x38; /* movq %mmN,(%eax) */ - get_fpu(X86EMUL_FPU_mmx, &fic); - asm volatile ( "call *%0" : : "r" (stub), "a" (&val) : "memory" = ); - put_fpu(&fic); if ( ea.type =3D=3D OP_MEM ) { - unsigned long lval =3D (uint32_t)val, hval =3D (uint32_t)(val = >> 32); - if ( (rc =3D ops->write(ea.mem.seg, ea.mem.off+0, &lval, 4, = ctxt)) || - (rc =3D ops->write(ea.mem.seg, ea.mem.off+4, &hval, 4, = ctxt)) ) - goto done; + /* XXX + generate_exception_if(vex.pfx =3D=3D vex_66 && + (ops->ea(ea.mem.seg, ea.mem.off) + & (ea.bytes - 1)), EXC_GP, 0); */ + if ( b =3D=3D 0x6f ) + rc =3D ops->read(ea.mem.seg, ea.mem.off+0, &this_cpu(mmval= ), + ea.bytes, ctxt); + /* convert memory operand to (%rAX) */ + rex_prefix &=3D ~REX_B; + vex.b =3D 1; + stub[4] &=3D 0x38; + } + if ( !rc ) + { + copy_REX_VEX(stub, rex_prefix, vex); + asm volatile ( "call *%0" : : "r" (stub), "a" (&this_cpu(mmval)= ) + : "memory" ); } - break; + put_fpu(&fic); + if ( b !=3D 0x6f && ea.type =3D=3D OP_MEM ) + rc =3D ops->write(ea.mem.seg, ea.mem.off, &this_cpu(mmval), + ea.bytes, ctxt); + goto done; } =20 case 0x80 ... 0x8f: /* jcc (near) */ { --- a/xen/arch/x86/x86_emulate/x86_emulate.h +++ b/xen/arch/x86/x86_emulate/x86_emulate.h @@ -99,7 +99,9 @@ struct segment_register { /* FPU sub-types which may be requested via ->get_fpu(). */ enum x86_emulate_fpu_type { X86EMUL_FPU_fpu, /* Standard FPU coprocessor instruction set */ - X86EMUL_FPU_mmx /* MMX instruction set (%mm0-%mm7) */ + X86EMUL_FPU_mmx, /* MMX instruction set (%mm0-%mm7) */ + X86EMUL_FPU_xmm, /* SSE instruction set (%xmm0-%xmm7/15) */ + X86EMUL_FPU_ymm /* AVX/XOP instruction set (%ymm0-%ymm7/15) */ }; =20 /* --- a/xen/arch/x86/x86_emulate.c +++ b/xen/arch/x86/x86_emulate.c @@ -10,9 +10,11 @@ */ =20 #include +#include #include =20 /* Avoid namespace pollution. */ #undef cmpxchg +#undef cpuid =20 #include "x86_emulate/x86_emulate.c" --- a/xen/include/asm-x86/cpufeature.h +++ b/xen/include/asm-x86/cpufeature.h @@ -218,7 +218,7 @@ #define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC) =20 #define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE) - +#define cpu_has_avx boot_cpu_has(X86_FEATURE_AVX) #define cpu_has_lwp boot_cpu_has(X86_FEATURE_LWP) =20 #define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON) --=__PartC2ED42E6.0__= Content-Type: text/plain; name="x86-emul-mm-mov.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-emul-mm-mov.patch" x86/emulator: generalize movq emulation (SSE2 and AVX variants)=0A=0AExtend= the existing movq emulation to also support its SSE2 and AVX=0Avariants, = the latter implying the addition of VEX decoding. Fold the=0Aread and = write cases (as most of the logic is identical), and add=0Amovntq and = variants (as they're very similar).=0A=0AExtend the testing code to also = exercise these instructions.=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/tools/tests/x86_emulator/test_x86_emulator.c=0A+++ = b/tools/tests/x86_emulator/test_x86_emulator.c=0A@@ -1,3 +1,5 @@=0A+#includ= e =0A+#include =0A #include =0A #include = =0A #include =0A@@ -53,11 +55,84 @@ static int = cmpxchg(=0A return X86EMUL_OKAY;=0A }=0A =0A+static int cpuid(=0A+ = unsigned int *eax,=0A+ unsigned int *ebx,=0A+ unsigned int *ecx,=0A+ = unsigned int *edx,=0A+ struct x86_emulate_ctxt *ctxt)=0A+{=0A+ = asm ("cpuid" : "+a" (*eax), "+c" (*ecx), "=3Dd" (*edx), "=3Db" (*ebx));=0A+= return X86EMUL_OKAY;=0A+}=0A+=0A+#define cpu_has_mmx ({ \=0A+ = unsigned int eax =3D 1, ecx =3D 0, edx; \=0A+ cpuid(&eax, &ecx, &ecx, = &edx, NULL); \=0A+ (edx & (1U << 23)) !=3D 0; \=0A+})=0A+=0A+#define = cpu_has_sse ({ \=0A+ unsigned int eax =3D 1, ecx =3D 0, edx; \=0A+ = cpuid(&eax, &ecx, &ecx, &edx, NULL); \=0A+ (edx & (1U << 25)) !=3D 0; = \=0A+})=0A+=0A+#define cpu_has_sse2 ({ \=0A+ unsigned int eax =3D 1, = ecx =3D 0, edx; \=0A+ cpuid(&eax, &ecx, &ecx, &edx, NULL); \=0A+ = (edx & (1U << 26)) !=3D 0; \=0A+})=0A+=0A+static inline uint64_t xgetbv(uin= t32_t xcr)=0A+{=0A+ uint64_t res;=0A+=0A+ asm ( ".byte 0x0f, 0x01, = 0xd0" : "=3DA" (res) : "c" (xcr) );=0A+=0A+ return res;=0A+}=0A+=0A+#def= ine cpu_has_avx ({ \=0A+ unsigned int eax =3D 1, ecx =3D 0, edx; \=0A+ = cpuid(&eax, &edx, &ecx, &edx, NULL); \=0A+ if ( !(ecx & (1U << 27)) = || (xgetbv(0) & 6) !=3D 6 ) \=0A+ ecx =3D 0; \=0A+ (ecx & (1U << = 28)) !=3D 0; \=0A+})=0A+=0A+int get_fpu(=0A+ void (*exception_callback)(= void *, struct cpu_user_regs *),=0A+ void *exception_callback_arg,=0A+ = enum x86_emulate_fpu_type type,=0A+ struct x86_emulate_ctxt *ctxt)=0A+= {=0A+ switch ( type )=0A+ {=0A+ case X86EMUL_FPU_fpu:=0A+ = break;=0A+ case X86EMUL_FPU_ymm:=0A+ if ( cpu_has_avx )=0A+ = break;=0A+ case X86EMUL_FPU_xmm:=0A+ if ( cpu_has_sse = )=0A+ break;=0A+ case X86EMUL_FPU_mmx:=0A+ if ( = cpu_has_mmx )=0A+ break;=0A+ default:=0A+ return = X86EMUL_UNHANDLEABLE;=0A+ }=0A+ return X86EMUL_OKAY;=0A+}=0A+=0A = static struct x86_emulate_ops emulops =3D {=0A .read =3D = read,=0A .insn_fetch =3D read,=0A .write =3D write,=0A = .cmpxchg =3D cmpxchg,=0A+ .cpuid =3D cpuid,=0A+ .get_fpu = =3D get_fpu,=0A };=0A =0A int main(int argc, char **argv)=0A@@ -66,6 = +141,8 @@ int main(int argc, char **argv)=0A struct cpu_user_regs = regs;=0A char *instr;=0A unsigned int *res, i, j;=0A+ unsigned = long sp;=0A+ bool stack_exec;=0A int rc;=0A #ifndef __x86_64__=0A = unsigned int bcdres_native, bcdres_emul;=0A@@ -85,6 +162,16 @@ int = main(int argc, char **argv)=0A }=0A instr =3D (char *)res + = 0x100;=0A =0A+#ifdef __x86_64__=0A+ asm ("movq %%rsp, %0" : "=3Dg" = (sp));=0A+#else=0A+ asm ("movl %%esp, %0" : "=3Dg" (sp));=0A+#endif=0A+ = stack_exec =3D mprotect((void *)(sp & -0x1000L) - (MMAP_SZ - 0x1000),=0A= + MMAP_SZ, PROT_READ|PROT_WRITE|PROT_EXEC) =3D=3D = 0;=0A+ if ( !stack_exec )=0A+ printf("Warning: Stack could not = be made executable (%d).\n", errno);=0A+=0A printf("%-40s", "Testing = addl %%ecx,(%%eax)...");=0A instr[0] =3D 0x01; instr[1] =3D 0x08;=0A = regs.eflags =3D 0x200;=0A@@ -442,6 +529,108 @@ int main(int argc, char = **argv)=0A printf("skipped\n");=0A #endif=0A =0A+ printf("%-40s", = "Testing movq %mm3,(%ecx)...");=0A+ if ( stack_exec && cpu_has_mmx = )=0A+ {=0A+ extern const unsigned char movq_to_mem[];=0A+=0A+ = asm volatile ( "pcmpeqb %%mm3, %%mm3\n"=0A+ = ".pushsection .test, \"a\", @progbits\n"=0A+ = "movq_to_mem: movq %%mm3, (%0)\n"=0A+ ".popsection" = :: "c" (NULL) );=0A+=0A+ memcpy(instr, movq_to_mem, 15);=0A+ = memset(res, 0x33, 64);=0A+ memset(res + 8, 0xff, 8);=0A+ = regs.eip =3D (unsigned long)&instr[0];=0A+ regs.ecx =3D = (unsigned long)res;=0A+ rc =3D x86_emulate(&ctxt, &emulops);=0A+ = if ( (rc !=3D X86EMUL_OKAY) ||=0A+ memcmp(res, res + 8, = 32) )=0A+ goto fail;=0A+ printf("okay\n");=0A+ }=0A+ = else=0A+ printf("skipped\n");=0A+=0A+ printf("%-40s", "Testing = movq (%edx),%mm5...");=0A+ if ( stack_exec && cpu_has_mmx )=0A+ = {=0A+ extern const unsigned char movq_from_mem[];=0A+=0A+ = asm volatile ( "pcmpgtb %%mm5, %%mm5\n"=0A+ = ".pushsection .test, \"a\", @progbits\n"=0A+ = "movq_from_mem: movq (%0), %%mm5\n"=0A+ ".popsection"= :: "d" (NULL) );=0A+=0A+ memcpy(instr, movq_from_mem, 15);=0A+ = regs.eip =3D (unsigned long)&instr[0];=0A+ regs.ecx =3D = 0;=0A+ regs.edx =3D (unsigned long)res;=0A+ rc =3D = x86_emulate(&ctxt, &emulops);=0A+ if ( rc !=3D X86EMUL_OKAY )=0A+ = goto fail;=0A+ asm ( "pcmpeqb %%mm3, %%mm3\n\t"=0A+ = "pcmpeqb %%mm5, %%mm3\n\t"=0A+ "pmovmskb %%mm3, %0" : = "=3Dr" (rc) );=0A+ if ( rc !=3D 0xff )=0A+ goto = fail;=0A+ printf("okay\n");=0A+ }=0A+ else=0A+ = printf("skipped\n");=0A+=0A+ printf("%-40s", "Testing movdqu %xmm2,(%ecx= )...");=0A+ if ( stack_exec && cpu_has_sse2 )=0A+ {=0A+ = extern const unsigned char movdqu_to_mem[];=0A+=0A+ asm volatile ( = "pcmpeqb %%xmm2, %%xmm2\n"=0A+ ".pushsection .test, = \"a\", @progbits\n"=0A+ "movdqu_to_mem: movdqu = %%xmm2, (%0)\n"=0A+ ".popsection" :: "c" (NULL) = );=0A+=0A+ memcpy(instr, movdqu_to_mem, 15);=0A+ memset(res, = 0x55, 64);=0A+ memset(res + 8, 0xff, 16);=0A+ regs.eip = =3D (unsigned long)&instr[0];=0A+ regs.ecx =3D (unsigned = long)res;=0A+ rc =3D x86_emulate(&ctxt, &emulops);=0A+ if ( = (rc !=3D X86EMUL_OKAY) ||=0A+ memcmp(res, res + 8, 32) )=0A+ = goto fail;=0A+ printf("okay\n");=0A+ }=0A+ else=0A+ = printf("skipped\n");=0A+=0A+ printf("%-40s", "Testing movdqu = (%edx),%xmm4...");=0A+ if ( stack_exec && cpu_has_sse2 )=0A+ {=0A+ = extern const unsigned char movdqu_from_mem[];=0A+=0A+ asm = volatile ( "pcmpgtb %%xmm4, %%xmm4\n"=0A+ ".pushsecti= on .test, \"a\", @progbits\n"=0A+ "movdqu_from_mem: = movdqu (%0), %%xmm4\n"=0A+ ".popsection" :: "d" = (NULL) );=0A+=0A+ memcpy(instr, movdqu_from_mem, 15);=0A+ = regs.eip =3D (unsigned long)&instr[0];=0A+ regs.ecx =3D = 0;=0A+ regs.edx =3D (unsigned long)res;=0A+ rc =3D = x86_emulate(&ctxt, &emulops);=0A+ if ( rc !=3D X86EMUL_OKAY )=0A+ = goto fail;=0A+ asm ( "pcmpeqb %%xmm2, %%xmm2\n\t"=0A+ = "pcmpeqb %%xmm4, %%xmm2\n\t"=0A+ "pmovmskb %%xmm2, = %0" : "=3Dr" (rc) );=0A+ if ( rc !=3D 0xffff )=0A+ goto = fail;=0A+ printf("okay\n");=0A+ }=0A+ else=0A+ = printf("skipped\n");=0A+=0A for ( j =3D 1; j <=3D 2; j++ )=0A {=0A = #if defined(__i386__)=0A--- a/tools/tests/x86_emulator/x86_emulate.c=0A+++ = b/tools/tests/x86_emulator/x86_emulate.c=0A@@ -9,5 +9,10 @@ typedef bool = bool_t;=0A =0A #define BUG() abort()=0A =0A+#define DEFINE_PER_CPU(type, = var) type this_cpu_##var=0A+#define this_cpu(var) this_cpu_##var=0A+=0A+#de= fine vm86_mode(regs) 0=0A+=0A #include "x86_emulate/x86_emulate.h"=0A = #include "x86_emulate/x86_emulate.c"=0A--- a/xen/arch/x86/hvm/emulate.c=0A+= ++ b/xen/arch/x86/hvm/emulate.c=0A@@ -16,6 +16,7 @@=0A #include =0A #include =0A #include =0A+#include = =0A #include =0A #include = =0A #include =0A@@ -905,6 +906,20 @@ static int hvmemul_ge= t_fpu(=0A if ( !cpu_has_mmx )=0A return X86EMUL_UNHANDL= EABLE;=0A break;=0A+ case X86EMUL_FPU_xmm:=0A+ if ( = !cpu_has_xmm ||=0A+ (curr->arch.hvm_vcpu.guest_cr[0] & = X86_CR0_EM) ||=0A+ !(curr->arch.hvm_vcpu.guest_cr[4] & = X86_CR4_OSFXSR) )=0A+ return X86EMUL_UNHANDLEABLE;=0A+ = break;=0A+ case X86EMUL_FPU_ymm:=0A+ if ( !(curr->arch.hvm_vcpu.g= uest_cr[0] & X86_CR0_PE) ||=0A+ vm86_mode(ctxt->regs) ||=0A+ = !(curr->arch.hvm_vcpu.guest_cr[4] & X86_CR4_OSXSAVE) ||=0A+ = !(curr->arch.xcr0 & XSTATE_SSE) ||=0A+ !(curr->arch.xcr0= & XSTATE_YMM) )=0A+ return X86EMUL_UNHANDLEABLE;=0A+ = break;=0A default:=0A return X86EMUL_UNHANDLEABLE;=0A = }=0A--- a/xen/arch/x86/x86_emulate/x86_emulate.c=0A+++ b/xen/arch/x86/x86_e= mulate/x86_emulate.c=0A@@ -253,6 +253,47 @@ static uint8_t twobyte_table[25= 6] =3D {=0A 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0=0A };=0A = =0A+#define REX_PREFIX 0x40=0A+#define REX_B 0x01=0A+#define REX_X = 0x02=0A+#define REX_R 0x04=0A+#define REX_W 0x08=0A+=0A+#define vex_none = 0=0A+=0A+enum vex_opcx {=0A+ vex_0f =3D vex_none + 1,=0A+ = vex_0f38,=0A+ vex_0f3a,=0A+};=0A+=0A+enum vex_pfx {=0A+ vex_66 =3D = vex_none + 1,=0A+ vex_f3,=0A+ vex_f2=0A+};=0A+=0A+union vex {=0A+ = uint8_t raw[2];=0A+ struct {=0A+ uint8_t opcx:5;=0A+ = uint8_t b:1;=0A+ uint8_t x:1;=0A+ uint8_t r:1;=0A+ = uint8_t pfx:2;=0A+ uint8_t l:1;=0A+ uint8_t reg:4;=0A+ = uint8_t w:1;=0A+ };=0A+};=0A+=0A+#define copy_REX_VEX(ptr, rex, vex) = do { \=0A+ if ( (vex).opcx !=3D vex_none ) \=0A+ ptr[0] =3D = 0xc4, ptr[1] =3D (vex).raw[0], ptr[2] =3D (vex).raw[1]; \=0A+ else if ( = mode_64bit() ) \=0A+ ptr[1] =3D rex | REX_PREFIX; \=0A+} while = (0)=0A+=0A /* Type, address-of, and value of an instruction's operand. = */=0A struct operand {=0A enum { OP_REG, OP_MEM, OP_IMM, OP_NONE } = type;=0A@@ -281,6 +322,18 @@ struct operand {=0A };=0A };=0A =0A+typede= f union {=0A+ uint64_t mmx;=0A+ uint64_t __attribute__ ((aligned(16))= ) xmm[2];=0A+ uint64_t __attribute__ ((aligned(32))) ymm[4];=0A+} = mmval_t;=0A+=0A+/*=0A+ * While alignment gets specified above, this = doesn't get honored by the=0A+ * compiler for automatic variables. Thus = use a per-CPU variable instead.=0A+ */=0A+static DEFINE_PER_CPU(mmval_t, = mmval);=0A+=0A /* MSRs. */=0A #define MSR_TSC 0x00000010=0A = #define MSR_SYSENTER_CS 0x00000174=0A@@ -972,9 +1025,12 @@ static bool_t = vcpu_has(=0A generate_exception_if(!vcpu_has(leaf, subleaf, reg, \=0A = X86_FEATURE_##feature % 32, \=0A = ctxt, ops), EXC_UD, -1)=0A+#define vcpu_must_h= ave_mmx() vcpu_must_have(1, 0, EDX, MMX)=0A+#define vcpu_must_have_sse() = vcpu_must_have(1, 0, EDX, XMM)=0A #define vcpu_must_have_sse2() vcpu_must_h= ave(1, 0, EDX, XMM2)=0A #define vcpu_must_have_sse3() vcpu_must_have(1, 0, = ECX, XMM3)=0A #define vcpu_must_have_cx16() vcpu_must_have(1, 0, ECX, = CX16)=0A+#define vcpu_must_have_avx() vcpu_must_have(1, 0, ECX, AVX)=0A = =0A static int=0A in_realmode(=0A@@ -1255,6 +1311,7 @@ x86_emulate(=0A =0A = uint8_t b, d, sib, sib_index, sib_base, twobyte =3D 0, rex_prefix =3D = 0;=0A uint8_t modrm =3D 0, modrm_mod =3D 0, modrm_reg =3D 0, modrm_rm = =3D 0;=0A+ union vex vex =3D {};=0A unsigned int op_bytes, = def_op_bytes, ad_bytes, def_ad_bytes;=0A #define REPE_PREFIX 1=0A #define = REPNE_PREFIX 2=0A@@ -1287,6 +1344,7 @@ x86_emulate(=0A {=0A = case 0x66: /* operand-size override */=0A op_bytes =3D = def_op_bytes ^ 6;=0A+ vex.pfx =3D vex_66;=0A = break;=0A case 0x67: /* address-size override */=0A = ad_bytes =3D def_ad_bytes ^ (mode_64bit() ? 12 : 6);=0A@@ -1314,9 +1372,11 = @@ x86_emulate(=0A break;=0A case 0xf2: /* REPNE/REPNZ = */=0A rep_prefix =3D REPNE_PREFIX;=0A+ vex.pfx =3D = vex_f2;=0A break;=0A case 0xf3: /* REP/REPE/REPZ */=0A = rep_prefix =3D REPE_PREFIX;=0A+ vex.pfx =3D = vex_f3;=0A break;=0A case 0x40 ... 0x4f: /* REX */=0A = if ( !mode_64bit() )=0A@@ -1360,6 +1420,70 @@ x86_emulate(=0A = {=0A modrm =3D insn_fetch_type(uint8_t);=0A modrm_mod = =3D (modrm & 0xc0) >> 6;=0A+=0A+ if ( !twobyte && (b & ~1) =3D=3D = 0xc4 )=0A+ switch ( def_ad_bytes )=0A+ {=0A+ = default:=0A+ BUG();=0A+ case 2:=0A+ = if ( in_realmode(ctxt, ops) || vm86_mode(&_regs) )=0A+ = break;=0A+ /* fall through */=0A+ case = 4:=0A+ if ( modrm_mod !=3D 3 )=0A+ = break;=0A+ /* fall through */=0A+ case 8:=0A+ = /* VEX */=0A+ generate_exception_if(rex_prefix = || vex.pfx, EXC_UD, -1);=0A+=0A+ vex.raw[0] =3D b;=0A+ = if ( b & 1 )=0A+ {=0A+ = vex.raw[1] =3D b;=0A+ vex.opcx =3D vex_0f;=0A+ = vex.x =3D 1;=0A+ vex.b =3D 1;=0A+ = vex.w =3D 0;=0A+ }=0A+ else=0A+ = {=0A+ vex.raw[1] =3D insn_fetch_type(uint8_t);= =0A+ if ( mode_64bit() )=0A+ {=0A+ = if ( !vex.b )=0A+ = rex_prefix |=3D REX_B;=0A+ if ( !vex.x )=0A+ = rex_prefix |=3D REX_X;=0A+ if ( = vex.w )=0A+ {=0A+ = rex_prefix |=3D REX_W;=0A+ op_bytes =3D 8;=0A+ = }=0A+ }=0A+ }=0A+ = vex.reg ^=3D 0xf;=0A+ if ( !mode_64bit() = )=0A+ vex.reg &=3D 0x7;=0A+ else if ( = !vex.r )=0A+ rex_prefix |=3D REX_R;=0A+=0A+ = fail_if(vex.opcx !=3D vex_0f);=0A+ twobyte =3D 1;=0A+ = b =3D insn_fetch_type(uint8_t);=0A+ d =3D = twobyte_table[b];=0A+=0A+ /* Unrecognised? */=0A+ = if ( d =3D=3D 0 )=0A+ goto cannot_emulate;=0A+=0A+ = modrm =3D insn_fetch_type(uint8_t);=0A+ = modrm_mod =3D (modrm & 0xc0) >> 6;=0A+=0A+ break;=0A+ = }=0A+=0A modrm_reg =3D ((rex_prefix & 4) << 1) | ((modrm & = 0x38) >> 3);=0A modrm_rm =3D modrm & 0x07;=0A =0A@@ -3917,44 = +4041,77 @@ x86_emulate(=0A break;=0A }=0A =0A- case 0x6f: = /* movq mm/m64,mm */ {=0A- uint8_t stub[] =3D { 0x0f, 0x6f, modrm, = 0xc3 };=0A+ case 0x6f: /* movq mm/m64,mm */=0A+ /* = {,v}movdq{a,u} xmm/m128,xmm */=0A+ /* vmovdq{a,u} ymm/m256,ym= m */=0A+ case 0x7f: /* movq mm,mm/m64 */=0A+ /* {,v}movdq{= a,u} xmm,xmm/m128 */=0A+ /* vmovdq{a,u} ymm,ymm/m256 */=0A+ = case 0xe7: /* movntq mm,mm/m64 */=0A+ /* {,v}movntdq = xmm,xmm/m128 */=0A+ /* vmovntdq{a,u} ymm,ymm/m256 */=0A+ = {=0A+ uint8_t stub[] =3D { 0x3e, 0x3e, 0x0f, b, modrm, 0xc3 };=0A = struct fpu_insn_ctxt fic =3D { .insn_bytes =3D sizeof(stub)-1 };=0A- = uint64_t val;=0A- if ( ea.type =3D=3D OP_MEM )=0A+=0A+ = if ( vex.opcx =3D=3D vex_none )=0A {=0A- unsigned long = lval, hval;=0A- if ( (rc =3D read_ulong(ea.mem.seg, ea.mem.off+0= ,=0A- &lval, 4, ctxt, ops)) ||=0A- = (rc =3D read_ulong(ea.mem.seg, ea.mem.off+4,=0A- = &hval, 4, ctxt, ops)) )=0A- goto done;=0A- = val =3D ((uint64_t)hval << 32) | (uint32_t)lval;=0A- = stub[2] =3D modrm & 0x38; /* movq (%eax),%mmN */=0A+ switch ( = vex.pfx )=0A+ {=0A+ case vex_f3:=0A+ = fail_if(b =3D=3D 0xe7);=0A+ /* fall through */=0A+ = case vex_66:=0A+ vcpu_must_have_sse2();=0A+ = stub[0] =3D 0x66; /* movdqa */=0A+ get_fpu(X86EMUL_FPU_xmm,= &fic);=0A+ ea.bytes =3D 16;=0A+ break;=0A+ = case vex_none:=0A+ if ( b !=3D 0xe7 )=0A+ = vcpu_must_have_mmx();=0A+ else=0A+ = vcpu_must_have_sse();=0A+ get_fpu(X86EMUL_FPU_mmx, = &fic);=0A+ ea.bytes =3D 8;=0A+ break;=0A+ = default:=0A+ goto cannot_emulate;=0A+ = }=0A+ }=0A+ else=0A+ {=0A+ fail_if(vex.opcx= !=3D vex_0f || vex.reg ||=0A+ (vex.pfx !=3D vex_66 && = (vex.pfx !=3D vex_f3 || b =3D=3D 0xe7)));=0A+ vcpu_must_have_avx= ();=0A+ get_fpu(X86EMUL_FPU_ymm, &fic);=0A+ ea.bytes = =3D 16 << vex.l;=0A }=0A- get_fpu(X86EMUL_FPU_mmx, = &fic);=0A- asm volatile ( "call *%0" : : "r" (stub), "a" (&val) : = "memory" );=0A- put_fpu(&fic);=0A- break;=0A- }=0A-=0A- = case 0x7f: /* movq mm,mm/m64 */ {=0A- uint8_t stub[] =3D { 0x0f, = 0x7f, modrm, 0xc3 };=0A- struct fpu_insn_ctxt fic =3D { .insn_bytes = =3D sizeof(stub)-1 };=0A- uint64_t val;=0A- if ( ea.type = =3D=3D OP_MEM )=0A- stub[2] =3D modrm & 0x38; /* movq %mmN,(%eax= ) */=0A- get_fpu(X86EMUL_FPU_mmx, &fic);=0A- asm volatile ( = "call *%0" : : "r" (stub), "a" (&val) : "memory" );=0A- put_fpu(&fic= );=0A if ( ea.type =3D=3D OP_MEM )=0A {=0A- = unsigned long lval =3D (uint32_t)val, hval =3D (uint32_t)(val >> 32);=0A- = if ( (rc =3D ops->write(ea.mem.seg, ea.mem.off+0, &lval, 4, = ctxt)) ||=0A- (rc =3D ops->write(ea.mem.seg, ea.mem.off+4, = &hval, 4, ctxt)) )=0A- goto done;=0A+ /* XXX=0A+ = generate_exception_if(vex.pfx =3D=3D vex_66 &&=0A+ = (ops->ea(ea.mem.seg, ea.mem.off)=0A+ = & (ea.bytes - 1)), EXC_GP, 0); */=0A+ if ( b = =3D=3D 0x6f )=0A+ rc =3D ops->read(ea.mem.seg, ea.mem.off+0,= &this_cpu(mmval),=0A+ ea.bytes, ctxt);=0A+ = /* convert memory operand to (%rAX) */=0A+ rex_prefix = &=3D ~REX_B;=0A+ vex.b =3D 1;=0A+ stub[4] &=3D = 0x38;=0A+ }=0A+ if ( !rc )=0A+ {=0A+ = copy_REX_VEX(stub, rex_prefix, vex);=0A+ asm volatile ( "call = *%0" : : "r" (stub), "a" (&this_cpu(mmval))=0A+ = : "memory" );=0A }=0A- break;=0A+ put_fpu(&f= ic);=0A+ if ( b !=3D 0x6f && ea.type =3D=3D OP_MEM )=0A+ = rc =3D ops->write(ea.mem.seg, ea.mem.off, &this_cpu(mmval),=0A+ = ea.bytes, ctxt);=0A+ goto done;=0A }=0A =0A = case 0x80 ... 0x8f: /* jcc (near) */ {=0A--- a/xen/arch/x86/x86_emulate/x86= _emulate.h=0A+++ b/xen/arch/x86/x86_emulate/x86_emulate.h=0A@@ -99,7 +99,9 = @@ struct segment_register {=0A /* FPU sub-types which may be requested = via ->get_fpu(). */=0A enum x86_emulate_fpu_type {=0A X86EMUL_FPU_fpu, = /* Standard FPU coprocessor instruction set */=0A- X86EMUL_FPU_mmx /* = MMX instruction set (%mm0-%mm7) */=0A+ X86EMUL_FPU_mmx, /* MMX = instruction set (%mm0-%mm7) */=0A+ X86EMUL_FPU_xmm, /* SSE instruction = set (%xmm0-%xmm7/15) */=0A+ X86EMUL_FPU_ymm /* AVX/XOP instruction set = (%ymm0-%ymm7/15) */=0A };=0A =0A /*=0A--- a/xen/arch/x86/x86_emulate.c=0A++= + b/xen/arch/x86/x86_emulate.c=0A@@ -10,9 +10,11 @@=0A */=0A =0A #include = =0A+#include =0A #include =0A =0A /* Avoid namespace pollution. */=0A #undef cmpxchg=0A+#undef = cpuid=0A =0A #include "x86_emulate/x86_emulate.c"=0A--- a/xen/include/asm-x= 86/cpufeature.h=0A+++ b/xen/include/asm-x86/cpufeature.h=0A@@ -218,7 = +218,7 @@=0A #define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2API= C)=0A =0A #define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)= =0A-=0A+#define cpu_has_avx boot_cpu_has(X86_FEATURE_AVX)=0A = #define cpu_has_lwp boot_cpu_has(X86_FEATURE_LWP)=0A =0A = #define cpu_has_arch_perfmon boot_cpu_has(X86_FEATURE_ARCH_PERFMON)=0A --=__PartC2ED42E6.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=__PartC2ED42E6.0__=--