Skip to content

Commit 975e517

Browse files
author
Peter Zijlstra
committed
KVM: x86: Introduce EM_ASM_2W
Replace the FASTOP2W instructions. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Sean Christopherson <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 2df2b52 commit 975e517

1 file changed

Lines changed: 28 additions & 19 deletions

File tree

arch/x86/kvm/emulate.c

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,15 @@ static int em_##op(struct x86_emulate_ctxt *ctxt) \
335335
ON64(case 8: __EM_ASM_2(op##q, rdx, rax); break;) \
336336
EM_ASM_END
337337

338+
/* 2-operand, word only (no byte op) */
339+
#define EM_ASM_2W(op) \
340+
EM_ASM_START(op) \
341+
case 1: break; \
342+
case 2: __EM_ASM_2(op##w, ax, dx); break; \
343+
case 4: __EM_ASM_2(op##l, eax, edx); break; \
344+
ON64(case 8: __EM_ASM_2(op##q, rax, rdx); break;) \
345+
EM_ASM_END
346+
338347
/*
339348
* fastop functions have a special calling convention:
340349
*
@@ -1064,7 +1073,7 @@ FASTOP1SRC2EX(idiv, idiv_ex);
10641073
FASTOP3WCL(shld);
10651074
FASTOP3WCL(shrd);
10661075

1067-
FASTOP2W(imul);
1076+
EM_ASM_2W(imul);
10681077

10691078
EM_ASM_1(not);
10701079
EM_ASM_1(neg);
@@ -1079,12 +1088,12 @@ FASTOP2CL(shl);
10791088
FASTOP2CL(shr);
10801089
FASTOP2CL(sar);
10811090

1082-
FASTOP2W(bsf);
1083-
FASTOP2W(bsr);
1084-
FASTOP2W(bt);
1085-
FASTOP2W(bts);
1086-
FASTOP2W(btr);
1087-
FASTOP2W(btc);
1091+
EM_ASM_2W(bsf);
1092+
EM_ASM_2W(bsr);
1093+
EM_ASM_2W(bt);
1094+
EM_ASM_2W(bts);
1095+
EM_ASM_2W(btr);
1096+
EM_ASM_2W(btc);
10881097

10891098
EM_ASM_2R(cmp, cmp_r);
10901099

@@ -1093,15 +1102,15 @@ static int em_bsf_c(struct x86_emulate_ctxt *ctxt)
10931102
/* If src is zero, do not writeback, but update flags */
10941103
if (ctxt->src.val == 0)
10951104
ctxt->dst.type = OP_NONE;
1096-
return fastop(ctxt, em_bsf);
1105+
return em_bsf(ctxt);
10971106
}
10981107

10991108
static int em_bsr_c(struct x86_emulate_ctxt *ctxt)
11001109
{
11011110
/* If src is zero, do not writeback, but update flags */
11021111
if (ctxt->src.val == 0)
11031112
ctxt->dst.type = OP_NONE;
1104-
return fastop(ctxt, em_bsr);
1113+
return em_bsr(ctxt);
11051114
}
11061115

11071116
static __always_inline u8 test_cc(unsigned int condition, unsigned long flags)
@@ -3221,7 +3230,7 @@ static int em_xchg(struct x86_emulate_ctxt *ctxt)
32213230
static int em_imul_3op(struct x86_emulate_ctxt *ctxt)
32223231
{
32233232
ctxt->dst.val = ctxt->src2.val;
3224-
return fastop(ctxt, em_imul);
3233+
return em_imul(ctxt);
32253234
}
32263235

32273236
static int em_cwd(struct x86_emulate_ctxt *ctxt)
@@ -4135,10 +4144,10 @@ static const struct group_dual group7 = { {
41354144

41364145
static const struct opcode group8[] = {
41374146
N, N, N, N,
4138-
F(DstMem | SrcImmByte | NoWrite, em_bt),
4139-
F(DstMem | SrcImmByte | Lock | PageTable, em_bts),
4140-
F(DstMem | SrcImmByte | Lock, em_btr),
4141-
F(DstMem | SrcImmByte | Lock | PageTable, em_btc),
4147+
I(DstMem | SrcImmByte | NoWrite, em_bt),
4148+
I(DstMem | SrcImmByte | Lock | PageTable, em_bts),
4149+
I(DstMem | SrcImmByte | Lock, em_btr),
4150+
I(DstMem | SrcImmByte | Lock | PageTable, em_btc),
41424151
};
41434152

41444153
/*
@@ -4459,27 +4468,27 @@ static const struct opcode twobyte_table[256] = {
44594468
/* 0xA0 - 0xA7 */
44604469
I(Stack | Src2FS, em_push_sreg), I(Stack | Src2FS, em_pop_sreg),
44614470
II(ImplicitOps, em_cpuid, cpuid),
4462-
F(DstMem | SrcReg | ModRM | BitOp | NoWrite, em_bt),
4471+
I(DstMem | SrcReg | ModRM | BitOp | NoWrite, em_bt),
44634472
F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shld),
44644473
F(DstMem | SrcReg | Src2CL | ModRM, em_shld), N, N,
44654474
/* 0xA8 - 0xAF */
44664475
I(Stack | Src2GS, em_push_sreg), I(Stack | Src2GS, em_pop_sreg),
44674476
II(EmulateOnUD | ImplicitOps, em_rsm, rsm),
4468-
F(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_bts),
4477+
I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_bts),
44694478
F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shrd),
44704479
F(DstMem | SrcReg | Src2CL | ModRM, em_shrd),
4471-
GD(0, &group15), F(DstReg | SrcMem | ModRM, em_imul),
4480+
GD(0, &group15), I(DstReg | SrcMem | ModRM, em_imul),
44724481
/* 0xB0 - 0xB7 */
44734482
I2bv(DstMem | SrcReg | ModRM | Lock | PageTable | SrcWrite, em_cmpxchg),
44744483
I(DstReg | SrcMemFAddr | ModRM | Src2SS, em_lseg),
4475-
F(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr),
4484+
I(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr),
44764485
I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg),
44774486
I(DstReg | SrcMemFAddr | ModRM | Src2GS, em_lseg),
44784487
D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),
44794488
/* 0xB8 - 0xBF */
44804489
N, N,
44814490
G(BitOp, group8),
4482-
F(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc),
4491+
I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc),
44834492
I(DstReg | SrcMem | ModRM, em_bsf_c),
44844493
I(DstReg | SrcMem | ModRM, em_bsr_c),
44854494
D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov),

0 commit comments

Comments
 (0)