diff options
author | Avi Kivity <avi.kivity@gmail.com> | 2013-01-19 12:51:54 -0500 |
---|---|---|
committer | Marcelo Tosatti <mtosatti@redhat.com> | 2013-01-23 19:15:37 -0500 |
commit | 11c363ba8f8eb163c275920b4a27697eb43da6e9 (patch) | |
tree | 0f5f34329c3fd607d0d5477db2fbcadb78bb46e0 /arch/x86 | |
parent | 95413dc41398fec2518abf4e0449503b1306dcbc (diff) |
KVM: x86 emulator: convert BT/BTS/BTR/BTC/BSF/BSR to fastop
Reviewed-by: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi.kivity@gmail.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/emulate.c | 76 |
1 files changed, 26 insertions, 50 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index edb09e9c111c..62014dca9e26 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -478,6 +478,15 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt) | |||
478 | ON64(FOP2E(op##q, rax, rbx)) \ | 478 | ON64(FOP2E(op##q, rax, rbx)) \ |
479 | FOP_END | 479 | FOP_END |
480 | 480 | ||
481 | /* 2 operand, word only */ | ||
482 | #define FASTOP2W(op) \ | ||
483 | FOP_START(op) \ | ||
484 | FOPNOP() \ | ||
485 | FOP2E(op##w, ax, bx) \ | ||
486 | FOP2E(op##l, eax, ebx) \ | ||
487 | ON64(FOP2E(op##q, rax, rbx)) \ | ||
488 | FOP_END | ||
489 | |||
481 | /* 2 operand, src is CL */ | 490 | /* 2 operand, src is CL */ |
482 | #define FASTOP2CL(op) \ | 491 | #define FASTOP2CL(op) \ |
483 | FOP_START(op) \ | 492 | FOP_START(op) \ |
@@ -2066,6 +2075,13 @@ FASTOP2CL(shl); | |||
2066 | FASTOP2CL(shr); | 2075 | FASTOP2CL(shr); |
2067 | FASTOP2CL(sar); | 2076 | FASTOP2CL(sar); |
2068 | 2077 | ||
2078 | FASTOP2W(bsf); | ||
2079 | FASTOP2W(bsr); | ||
2080 | FASTOP2W(bt); | ||
2081 | FASTOP2W(bts); | ||
2082 | FASTOP2W(btr); | ||
2083 | FASTOP2W(btc); | ||
2084 | |||
2069 | static int em_mul_ex(struct x86_emulate_ctxt *ctxt) | 2085 | static int em_mul_ex(struct x86_emulate_ctxt *ctxt) |
2070 | { | 2086 | { |
2071 | u8 ex = 0; | 2087 | u8 ex = 0; |
@@ -3377,47 +3393,6 @@ static int em_sti(struct x86_emulate_ctxt *ctxt) | |||
3377 | return X86EMUL_CONTINUE; | 3393 | return X86EMUL_CONTINUE; |
3378 | } | 3394 | } |
3379 | 3395 | ||
3380 | static int em_bt(struct x86_emulate_ctxt *ctxt) | ||
3381 | { | ||
3382 | /* Disable writeback. */ | ||
3383 | ctxt->dst.type = OP_NONE; | ||
3384 | /* only subword offset */ | ||
3385 | ctxt->src.val &= (ctxt->dst.bytes << 3) - 1; | ||
3386 | |||
3387 | emulate_2op_SrcV_nobyte(ctxt, "bt"); | ||
3388 | return X86EMUL_CONTINUE; | ||
3389 | } | ||
3390 | |||
3391 | static int em_bts(struct x86_emulate_ctxt *ctxt) | ||
3392 | { | ||
3393 | emulate_2op_SrcV_nobyte(ctxt, "bts"); | ||
3394 | return X86EMUL_CONTINUE; | ||
3395 | } | ||
3396 | |||
3397 | static int em_btr(struct x86_emulate_ctxt *ctxt) | ||
3398 | { | ||
3399 | emulate_2op_SrcV_nobyte(ctxt, "btr"); | ||
3400 | return X86EMUL_CONTINUE; | ||
3401 | } | ||
3402 | |||
3403 | static int em_btc(struct x86_emulate_ctxt *ctxt) | ||
3404 | { | ||
3405 | emulate_2op_SrcV_nobyte(ctxt, "btc"); | ||
3406 | return X86EMUL_CONTINUE; | ||
3407 | } | ||
3408 | |||
3409 | static int em_bsf(struct x86_emulate_ctxt *ctxt) | ||
3410 | { | ||
3411 | emulate_2op_SrcV_nobyte(ctxt, "bsf"); | ||
3412 | return X86EMUL_CONTINUE; | ||
3413 | } | ||
3414 | |||
3415 | static int em_bsr(struct x86_emulate_ctxt *ctxt) | ||
3416 | { | ||
3417 | emulate_2op_SrcV_nobyte(ctxt, "bsr"); | ||
3418 | return X86EMUL_CONTINUE; | ||
3419 | } | ||
3420 | |||
3421 | static int em_cpuid(struct x86_emulate_ctxt *ctxt) | 3396 | static int em_cpuid(struct x86_emulate_ctxt *ctxt) |
3422 | { | 3397 | { |
3423 | u32 eax, ebx, ecx, edx; | 3398 | u32 eax, ebx, ecx, edx; |
@@ -3773,10 +3748,10 @@ static const struct group_dual group7 = { { | |||
3773 | 3748 | ||
3774 | static const struct opcode group8[] = { | 3749 | static const struct opcode group8[] = { |
3775 | N, N, N, N, | 3750 | N, N, N, N, |
3776 | I(DstMem | SrcImmByte, em_bt), | 3751 | F(DstMem | SrcImmByte | NoWrite, em_bt), |
3777 | I(DstMem | SrcImmByte | Lock | PageTable, em_bts), | 3752 | F(DstMem | SrcImmByte | Lock | PageTable, em_bts), |
3778 | I(DstMem | SrcImmByte | Lock, em_btr), | 3753 | F(DstMem | SrcImmByte | Lock, em_btr), |
3779 | I(DstMem | SrcImmByte | Lock | PageTable, em_btc), | 3754 | F(DstMem | SrcImmByte | Lock | PageTable, em_btc), |
3780 | }; | 3755 | }; |
3781 | 3756 | ||
3782 | static const struct group_dual group9 = { { | 3757 | static const struct group_dual group9 = { { |
@@ -4025,28 +4000,29 @@ static const struct opcode twobyte_table[256] = { | |||
4025 | X16(D(ByteOp | DstMem | SrcNone | ModRM| Mov)), | 4000 | X16(D(ByteOp | DstMem | SrcNone | ModRM| Mov)), |
4026 | /* 0xA0 - 0xA7 */ | 4001 | /* 0xA0 - 0xA7 */ |
4027 | I(Stack | Src2FS, em_push_sreg), I(Stack | Src2FS, em_pop_sreg), | 4002 | I(Stack | Src2FS, em_push_sreg), I(Stack | Src2FS, em_pop_sreg), |
4028 | II(ImplicitOps, em_cpuid, cpuid), I(DstMem | SrcReg | ModRM | BitOp, em_bt), | 4003 | II(ImplicitOps, em_cpuid, cpuid), |
4004 | F(DstMem | SrcReg | ModRM | BitOp | NoWrite, em_bt), | ||
4029 | F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shld), | 4005 | F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shld), |
4030 | F(DstMem | SrcReg | Src2CL | ModRM, em_shld), N, N, | 4006 | F(DstMem | SrcReg | Src2CL | ModRM, em_shld), N, N, |
4031 | /* 0xA8 - 0xAF */ | 4007 | /* 0xA8 - 0xAF */ |
4032 | I(Stack | Src2GS, em_push_sreg), I(Stack | Src2GS, em_pop_sreg), | 4008 | I(Stack | Src2GS, em_push_sreg), I(Stack | Src2GS, em_pop_sreg), |
4033 | DI(ImplicitOps, rsm), | 4009 | DI(ImplicitOps, rsm), |
4034 | I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_bts), | 4010 | F(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_bts), |
4035 | F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shrd), | 4011 | F(DstMem | SrcReg | Src2ImmByte | ModRM, em_shrd), |
4036 | F(DstMem | SrcReg | Src2CL | ModRM, em_shrd), | 4012 | F(DstMem | SrcReg | Src2CL | ModRM, em_shrd), |
4037 | D(ModRM), I(DstReg | SrcMem | ModRM, em_imul), | 4013 | D(ModRM), I(DstReg | SrcMem | ModRM, em_imul), |
4038 | /* 0xB0 - 0xB7 */ | 4014 | /* 0xB0 - 0xB7 */ |
4039 | I2bv(DstMem | SrcReg | ModRM | Lock | PageTable, em_cmpxchg), | 4015 | I2bv(DstMem | SrcReg | ModRM | Lock | PageTable, em_cmpxchg), |
4040 | I(DstReg | SrcMemFAddr | ModRM | Src2SS, em_lseg), | 4016 | I(DstReg | SrcMemFAddr | ModRM | Src2SS, em_lseg), |
4041 | I(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr), | 4017 | F(DstMem | SrcReg | ModRM | BitOp | Lock, em_btr), |
4042 | I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg), | 4018 | I(DstReg | SrcMemFAddr | ModRM | Src2FS, em_lseg), |
4043 | I(DstReg | SrcMemFAddr | ModRM | Src2GS, em_lseg), | 4019 | I(DstReg | SrcMemFAddr | ModRM | Src2GS, em_lseg), |
4044 | D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), | 4020 | D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), |
4045 | /* 0xB8 - 0xBF */ | 4021 | /* 0xB8 - 0xBF */ |
4046 | N, N, | 4022 | N, N, |
4047 | G(BitOp, group8), | 4023 | G(BitOp, group8), |
4048 | I(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc), | 4024 | F(DstMem | SrcReg | ModRM | BitOp | Lock | PageTable, em_btc), |
4049 | I(DstReg | SrcMem | ModRM, em_bsf), I(DstReg | SrcMem | ModRM, em_bsr), | 4025 | F(DstReg | SrcMem | ModRM, em_bsf), F(DstReg | SrcMem | ModRM, em_bsr), |
4050 | D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), | 4026 | D(DstReg | SrcMem8 | ModRM | Mov), D(DstReg | SrcMem16 | ModRM | Mov), |
4051 | /* 0xC0 - 0xC7 */ | 4027 | /* 0xC0 - 0xC7 */ |
4052 | D2bv(DstMem | SrcReg | ModRM | Lock), | 4028 | D2bv(DstMem | SrcReg | ModRM | Lock), |