Skip to content

Commit 2df2b52

Browse files
author
Peter Zijlstra
committed
KVM: x86: Introduce EM_ASM_2R
Replace the FASTOP2R instruction. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Sean Christopherson <seanjc@google.com> Link: https://lkml.kernel.org/r/20250714103440.024933524@infradead.org
1 parent b26deb0 commit 2df2b52

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

arch/x86/kvm/emulate.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,15 @@ static int em_##op(struct x86_emulate_ctxt *ctxt) \
326326
ON64(case 8: __EM_ASM_2(op##q, rax, rdx); break;) \
327327
EM_ASM_END
328328

329+
/* 2-operand, reversed */
330+
#define EM_ASM_2R(op, name) \
331+
EM_ASM_START(name) \
332+
case 1: __EM_ASM_2(op##b, dl, al); break; \
333+
case 2: __EM_ASM_2(op##w, dx, ax); break; \
334+
case 4: __EM_ASM_2(op##l, edx, eax); break; \
335+
ON64(case 8: __EM_ASM_2(op##q, rdx, rax); break;) \
336+
EM_ASM_END
337+
329338
/*
330339
* fastop functions have a special calling convention:
331340
*
@@ -1077,8 +1086,7 @@ FASTOP2W(bts);
10771086
FASTOP2W(btr);
10781087
FASTOP2W(btc);
10791088

1080-
1081-
FASTOP2R(cmp, cmp_r);
1089+
EM_ASM_2R(cmp, cmp_r);
10821090

10831091
static int em_bsf_c(struct x86_emulate_ctxt *ctxt)
10841092
{
@@ -4336,12 +4344,12 @@ static const struct opcode opcode_table[256] = {
43364344
I2bv(DstAcc | SrcMem | Mov | MemAbs, em_mov),
43374345
I2bv(DstMem | SrcAcc | Mov | MemAbs | PageTable, em_mov),
43384346
I2bv(SrcSI | DstDI | Mov | String | TwoMemOp, em_mov),
4339-
F2bv(SrcSI | DstDI | String | NoWrite | TwoMemOp, em_cmp_r),
4347+
I2bv(SrcSI | DstDI | String | NoWrite | TwoMemOp, em_cmp_r),
43404348
/* 0xA8 - 0xAF */
43414349
I2bv(DstAcc | SrcImm | NoWrite, em_test),
43424350
I2bv(SrcAcc | DstDI | Mov | String, em_mov),
43434351
I2bv(SrcSI | DstAcc | Mov | String, em_mov),
4344-
F2bv(SrcAcc | DstDI | String | NoWrite, em_cmp_r),
4352+
I2bv(SrcAcc | DstDI | String | NoWrite, em_cmp_r),
43454353
/* 0xB0 - 0xB7 */
43464354
X8(I(ByteOp | DstReg | SrcImm | Mov, em_mov)),
43474355
/* 0xB8 - 0xBF */

0 commit comments

Comments
 (0)