Skip to content

Commit 2d82acd

Browse files
author
Peter Zijlstra
committed
KVM: x86: Introduce EM_ASM_3WCL
Replace the FASTOP3WCL 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 af4fe07 commit 2d82acd

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

arch/x86/kvm/emulate.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,9 @@ static int em_##op(struct x86_emulate_ctxt *ctxt) \
302302
#define __EM_ASM_2(op, dst, src) \
303303
__EM_ASM(#op " %%" #src ", %%" #dst " \n\t")
304304

305+
#define __EM_ASM_3(op, dst, src, src2) \
306+
__EM_ASM(#op " %%" #src2 ", %%" #src ", %%" #dst " \n\t")
307+
305308
#define EM_ASM_END \
306309
} \
307310
ctxt->eflags = (ctxt->eflags & ~EFLAGS_MASK) | (flags & EFLAGS_MASK); \
@@ -371,6 +374,16 @@ static int em_##op(struct x86_emulate_ctxt *ctxt) \
371374
ON64(case 8: __EM_ASM_2(op##q, rax, cl); break;) \
372375
EM_ASM_END
373376

377+
/* 3-operand, using "a" (dst), "d" (src) and CL (src2) */
378+
#define EM_ASM_3WCL(op) \
379+
EM_ASM_START(op) \
380+
case 1: break; \
381+
case 2: __EM_ASM_3(op##w, ax, dx, cl); break; \
382+
case 4: __EM_ASM_3(op##l, eax, edx, cl); break; \
383+
ON64(case 8: __EM_ASM_3(op##q, rax, rdx, cl); break;) \
384+
EM_ASM_END
385+
386+
374387
/*
375388
* fastop functions have a special calling convention:
376389
*
@@ -1097,8 +1110,8 @@ EM_ASM_1SRC2(imul, imul_ex);
10971110
EM_ASM_1SRC2EX(div, div_ex);
10981111
EM_ASM_1SRC2EX(idiv, idiv_ex);
10991112

1100-
FASTOP3WCL(shld);
1101-
FASTOP3WCL(shrd);
1113+
EM_ASM_3WCL(shld);
1114+
EM_ASM_3WCL(shrd);
11021115

11031116
EM_ASM_2W(imul);
11041117

@@ -4496,14 +4509,14 @@ static const struct opcode twobyte_table[256] = {
44964509
I(Stack | Src2FS, em_push_sreg), I(Stack | Src2FS, em_pop_sreg),
44974510
II(ImplicitOps, em_cpuid, cpuid),
44984511
I(DstMem | SrcReg | ModRM | BitOp | NoWrite, em_bt),
4499-
F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shld),
4500-
F(DstMem | SrcReg | Src2CL | ModRM, em_shld), N, N,
4512+
I(DstMem | SrcReg | Src2ImmByte | ModRM, em_shld),
4513+
I(DstMem | SrcReg | Src2CL | ModRM, em_shld), N, N,
45014514
/* 0xA8 - 0xAF */
45024515
I(Stack | Src2GS, em_push_sreg), I(Stack | Src2GS, em_pop_sreg),
45034516
II(EmulateOnUD | ImplicitOps, em_rsm, rsm),
45044517
I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_bts),
4505-
F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shrd),
4506-
F(DstMem | SrcReg | Src2CL | ModRM, em_shrd),
4518+
I(DstMem | SrcReg | Src2ImmByte | ModRM, em_shrd),
4519+
I(DstMem | SrcReg | Src2CL | ModRM, em_shrd),
45074520
GD(0, &group15), I(DstReg | SrcMem | ModRM, em_imul),
45084521
/* 0xB0 - 0xB7 */
45094522
I2bv(DstMem | SrcReg | ModRM | Lock | PageTable | SrcWrite, em_cmpxchg),

0 commit comments

Comments
 (0)