|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 23/30] x86emul: support APX+CMPccXADD insns
This group of promoted-from-VEX insns is again handled by transforming
to the VEX counterparts.
In the test harness'es predicates tables also replace the original (VEX)
entries to use the available CND().
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
--- a/tools/tests/x86_emulator/evex-disp8.c
+++ b/tools/tests/x86_emulator/evex-disp8.c
@@ -1096,6 +1096,13 @@ static const struct test apx_nci[] = {
#undef COND
};
+static const struct test cmpccxadd[] = {
+#define COND(c, n) \
+ INSN(cmp##c##xadd, 66, 0f38, e0 | (n), el, dq, no)
+ CONDS(),
+#undef COND
+};
+
#undef CONDS
static const struct test adx[] = {
@@ -1737,6 +1744,7 @@ void evex_disp8_test(void *instr, struct
RUN(avx512bw);
RUN(bmi1);
RUN(bmi2);
+ RUN(cmpccxadd);
#undef RUN
--- a/tools/tests/x86_emulator/predicates.c
+++ b/tools/tests/x86_emulator/predicates.c
@@ -1422,22 +1422,7 @@ static const struct vex {
{ { 0xdd }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenclast */
{ { 0xde }, 2, T, R, pfx_66, WIG, Ln }, /* vaesdec */
{ { 0xdf }, 2, T, R, pfx_66, WIG, Ln }, /* vaesdeclast */
- { { 0xe0 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpoxadd */
- { { 0xe1 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpnoxadd */
- { { 0xe2 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpbxadd */
- { { 0xe3 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpnbxadd */
- { { 0xe4 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpexadd */
- { { 0xe5 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpnexadd */
- { { 0xe6 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpbexadd */
- { { 0xe7 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpaxadd */
- { { 0xe8 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpsxadd */
- { { 0xe9 }, 2, F, W, pfx_66, Wn, L0 }, /* cmpnsxadd */
- { { 0xea }, 2, F, W, pfx_66, Wn, L0 }, /* cmppxadd */
- { { 0xeb }, 2, F, W, pfx_66, Wn, L0 }, /* cmpnpxadd */
- { { 0xec }, 2, F, W, pfx_66, Wn, L0 }, /* cmplxadd */
- { { 0xed }, 2, F, W, pfx_66, Wn, L0 }, /* cmpgexadd */
- { { 0xee }, 2, F, W, pfx_66, Wn, L0 }, /* cmplexadd */
- { { 0xef }, 2, F, W, pfx_66, Wn, L0 }, /* cmpgxadd */
+ CND(0xe0, 2, F, W, pfx_66, Wn, L0 ), /* cmp<cc>xadd */
{ { 0xf2 }, 2, T, R, pfx_no, Wn, L0 }, /* andn */
{ { 0xf3, 0x08 }, 2, T, R, pfx_no, Wn, L0 }, /* blsr */
{ { 0xf3, 0x10 }, 2, T, R, pfx_no, Wn, L0 }, /* blsmsk */
@@ -2067,6 +2052,7 @@ static const struct evex {
{ { 0xde }, 2, T, R, pfx_66, WIG, Ln }, /* vaesdec */
{ { 0xdf }, 2, T, R, pfx_66, WIG, Ln }, /* vaesdeclast */
#ifdef __x86_64__
+ CND(0xe0, 2, F, W, pfx_66, Wn, L0 ), /* cmp<cc>xadd */
{ { 0xf2 }, 2, T, R, pfx_no, Wn, L0 }, /* andn */
{ { 0xf3, 0x08 }, 2, T, R, pfx_no, Wn, L0 }, /* blsr */
{ { 0xf3, 0x10 }, 2, T, R, pfx_no, Wn, L0 }, /* blsmsk */
--- a/tools/tests/x86_emulator/test_x86_emulator.c
+++ b/tools/tests/x86_emulator/test_x86_emulator.c
@@ -2293,6 +2293,41 @@ int main(int argc, char **argv)
(res[2] + 1) )
goto fail;
printf("okay\n");
+
+ if ( cpu_has_apx_f )
+ {
+ printf("%-40s", "Testing cmpnpxadd %ebx,%r9d,-4(%r18)...");
+ instr[0] = 0x62; instr[1] = 0x7a; instr[2] = 0x65; instr[3] = 0x08;
+ instr[4] = 0xeb; instr[5] = 0x4a; instr[6] = 0xfc;
+ regs.rip = (unsigned long)&instr[0];
+ load_egpr(18, (unsigned long)(res + 2));
+ rc = x86_emulate(&ctxt, &emulops);
+ if ( (rc != X86EMUL_OKAY) ||
+ (regs.rip != (unsigned long)&instr[7]) ||
+ (regs.r9 != 0x13253749) ||
+ (regs.rbx != 0x02030405) ||
+ ((regs.eflags & EFLAGS_MASK) !=
+ (EFLAGS_ALWAYS_SET | X86_EFLAGS_PF)) ||
+ (res[0] + 1) ||
+ (res[1] != 0x13253749) ||
+ (res[2] + 1) )
+ goto fail;
+
+ regs.rip = (unsigned long)&instr[0];
+ regs.r9 <<= 8;
+ rc = x86_emulate(&ctxt, &emulops);
+ if ( (rc != X86EMUL_OKAY) ||
+ (regs.rip != (unsigned long)&instr[7]) ||
+ (regs.r9 != 0x13253749) ||
+ (regs.rbx != 0x02030405) ||
+ ((regs.eflags & EFLAGS_MASK) !=
+ (EFLAGS_ALWAYS_SET | X86_EFLAGS(CF, SF))) ||
+ (res[0] + 1) ||
+ (res[1] != 0x15283b4e) ||
+ (res[2] + 1) )
+ goto fail;
+ printf("okay\n");
+ }
}
else
printf("skipped\n");
--- a/xen/arch/x86/x86_emulate/decode.c
+++ b/xen/arch/x86/x86_emulate/decode.c
@@ -1267,6 +1267,8 @@ decode_0f38(struct x86_emulate_state *s,
case X86EMUL_OPC_VEX_F2(0, 0xf7): /* shrx */
break;
+ case X86EMUL_OPC_EVEX_66(0, 0xe0) ...
+ X86EMUL_OPC_EVEX_66(0, 0xef): /* cmp<cc>xadd */
case X86EMUL_OPC_EVEX(0, 0xf2): /* andn */
case X86EMUL_OPC_EVEX(0, 0xf3): /* Grp 17 */
case X86EMUL_OPC_EVEX(0, 0xf5): /* bzhi */
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -7323,6 +7323,10 @@ x86_emulate(
#endif /* !X86EMUL_NO_SIMD */
+ case X86EMUL_OPC_EVEX_66(0x0f38, 0xe0) ...
+ X86EMUL_OPC_EVEX_66(0x0f38, 0xef): /* cmp<cc>xadd r,r,m */
+ generate_exception_if(evex.lr || evex.brs || evex.opmsk, X86_EXC_UD);
+ fallthrough;
case X86EMUL_OPC_VEX_66(0x0f38, 0xe0) ...
X86EMUL_OPC_VEX_66(0x0f38, 0xef): /* cmp<cc>xadd r,r,m */
generate_exception_if(!mode_64bit() || dst.type != OP_MEM || vex.l,
@@ -9355,6 +9359,7 @@ x86_emulate(
#undef rex_prefix
#undef lock_prefix
#undef vex
+#undef evex
#undef ea
int x86_emul_rmw(
@@ -9443,6 +9448,8 @@ int x86_emul_rmw(
pvex->b = 1;
pvex->r = 1;
pvex->reg = 0xf; /* rAX */
+ if ( s->promoted_evex )
+ pvex->opcx &= 7; /* See copy_VEX(). */
buf[3] = ctxt->opcode;
buf[4] = 0x11; /* reg=rDX r/m=(%RCX) */
place_ret(&buf[5]);
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |