Skip to content

Commit af4fe07

Browse files
author
Peter Zijlstra
committed
KVM: x86: Introduce EM_ASM_1SRC2
Replace the FASTOP1SRC2*() 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 67e944a commit af4fe07

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

arch/x86/kvm/emulate.c

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,24 @@ static int em_##op(struct x86_emulate_ctxt *ctxt) \
317317
ON64(case 8: __EM_ASM_1(op##q, rax); break;) \
318318
EM_ASM_END
319319

320+
/* 1-operand, using "c" (src2) */
321+
#define EM_ASM_1SRC2(op, name) \
322+
EM_ASM_START(name) \
323+
case 1: __EM_ASM_1(op##b, cl); break; \
324+
case 2: __EM_ASM_1(op##w, cx); break; \
325+
case 4: __EM_ASM_1(op##l, ecx); break; \
326+
ON64(case 8: __EM_ASM_1(op##q, rcx); break;) \
327+
EM_ASM_END
328+
329+
/* 1-operand, using "c" (src2) with exception */
330+
#define EM_ASM_1SRC2EX(op, name) \
331+
EM_ASM_START(name) \
332+
case 1: __EM_ASM_1_EX(op##b, cl); break; \
333+
case 2: __EM_ASM_1_EX(op##w, cx); break; \
334+
case 4: __EM_ASM_1_EX(op##l, ecx); break; \
335+
ON64(case 8: __EM_ASM_1_EX(op##q, rcx); break;) \
336+
EM_ASM_END
337+
320338
/* 2-operand, using "a" (dst), "d" (src) */
321339
#define EM_ASM_2(op) \
322340
EM_ASM_START(op) \
@@ -1074,10 +1092,10 @@ EM_ASM_2(cmp);
10741092
EM_ASM_2(test);
10751093
EM_ASM_2(xadd);
10761094

1077-
FASTOP1SRC2(mul, mul_ex);
1078-
FASTOP1SRC2(imul, imul_ex);
1079-
FASTOP1SRC2EX(div, div_ex);
1080-
FASTOP1SRC2EX(idiv, idiv_ex);
1095+
EM_ASM_1SRC2(mul, mul_ex);
1096+
EM_ASM_1SRC2(imul, imul_ex);
1097+
EM_ASM_1SRC2EX(div, div_ex);
1098+
EM_ASM_1SRC2EX(idiv, idiv_ex);
10811099

10821100
FASTOP3WCL(shld);
10831101
FASTOP3WCL(shrd);
@@ -4103,10 +4121,10 @@ static const struct opcode group3[] = {
41034121
I(DstMem | SrcImm | NoWrite, em_test),
41044122
I(DstMem | SrcNone | Lock, em_not),
41054123
I(DstMem | SrcNone | Lock, em_neg),
4106-
F(DstXacc | Src2Mem, em_mul_ex),
4107-
F(DstXacc | Src2Mem, em_imul_ex),
4108-
F(DstXacc | Src2Mem, em_div_ex),
4109-
F(DstXacc | Src2Mem, em_idiv_ex),
4124+
I(DstXacc | Src2Mem, em_mul_ex),
4125+
I(DstXacc | Src2Mem, em_imul_ex),
4126+
I(DstXacc | Src2Mem, em_div_ex),
4127+
I(DstXacc | Src2Mem, em_idiv_ex),
41104128
};
41114129

41124130
static const struct opcode group4[] = {

0 commit comments

Comments
 (0)