diff options
author | Avi Kivity <avi@redhat.com> | 2010-08-26 11:34:55 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 04:51:43 -0400 |
commit | 6230f7fc0453c5bc5daa8e053773021e1c4a2f16 (patch) | |
tree | 28f25a18011c75a61ee4058739dcbdedc6aaf823 | |
parent | 217fc9cfca21a0bc2f4246183ebd8ee9863b019d (diff) |
KVM: x86 emulator: simplify ALU opcode block decode further
The ALU opcode block is very regular; introduce D6ALU() to define decode
flags for 6 instructions at a time.
Suggested by Paolo Bonzini.
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/kvm/emulate.c | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 917b9b50fab0..8bfa3e3aa71d 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -2387,6 +2387,11 @@ static int em_rdtsc(struct x86_emulate_ctxt *ctxt) | |||
2387 | #define D2bv(_f) D((_f) | ByteOp), D(_f) | 2387 | #define D2bv(_f) D((_f) | ByteOp), D(_f) |
2388 | #define I2bv(_f, _e) I((_f) | ByteOp, _e), I(_f, _e) | 2388 | #define I2bv(_f, _e) I((_f) | ByteOp, _e), I(_f, _e) |
2389 | 2389 | ||
2390 | #define D6ALU(_f) D2bv((_f) | DstMem | SrcReg | ModRM), \ | ||
2391 | D2bv(((_f) | DstReg | SrcMem | ModRM) & ~Lock), \ | ||
2392 | D2bv(((_f) & ~Lock) | DstAcc | SrcImm) | ||
2393 | |||
2394 | |||
2390 | static struct opcode group1[] = { | 2395 | static struct opcode group1[] = { |
2391 | X7(D(Lock)), N | 2396 | X7(D(Lock)), N |
2392 | }; | 2397 | }; |
@@ -2439,35 +2444,25 @@ static struct group_dual group9 = { { | |||
2439 | 2444 | ||
2440 | static struct opcode opcode_table[256] = { | 2445 | static struct opcode opcode_table[256] = { |
2441 | /* 0x00 - 0x07 */ | 2446 | /* 0x00 - 0x07 */ |
2442 | D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), | 2447 | D6ALU(Lock), |
2443 | D2bv(DstAcc | SrcImm), | ||
2444 | D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), | 2448 | D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), |
2445 | /* 0x08 - 0x0F */ | 2449 | /* 0x08 - 0x0F */ |
2446 | D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), | 2450 | D6ALU(Lock), |
2447 | D2bv(DstAcc | SrcImm), | ||
2448 | D(ImplicitOps | Stack | No64), N, | 2451 | D(ImplicitOps | Stack | No64), N, |
2449 | /* 0x10 - 0x17 */ | 2452 | /* 0x10 - 0x17 */ |
2450 | D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), | 2453 | D6ALU(Lock), |
2451 | D2bv(DstAcc | SrcImm), | ||
2452 | D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), | 2454 | D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), |
2453 | /* 0x18 - 0x1F */ | 2455 | /* 0x18 - 0x1F */ |
2454 | D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), | 2456 | D6ALU(Lock), |
2455 | D2bv(DstAcc | SrcImm), | ||
2456 | D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), | 2457 | D(ImplicitOps | Stack | No64), D(ImplicitOps | Stack | No64), |
2457 | /* 0x20 - 0x27 */ | 2458 | /* 0x20 - 0x27 */ |
2458 | D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), | 2459 | D6ALU(Lock), N, N, |
2459 | D2bv(DstAcc | SrcImm), N, N, | ||
2460 | /* 0x28 - 0x2F */ | 2460 | /* 0x28 - 0x2F */ |
2461 | D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), | 2461 | D6ALU(Lock), N, I(ByteOp | DstAcc | No64, em_das), |
2462 | D2bv(DstAcc | SrcImm), | ||
2463 | N, I(ByteOp | DstAcc | No64, em_das), | ||
2464 | /* 0x30 - 0x37 */ | 2462 | /* 0x30 - 0x37 */ |
2465 | D2bv(DstMem | SrcReg | ModRM | Lock), D2bv(DstReg | SrcMem | ModRM), | 2463 | D6ALU(Lock), N, N, |
2466 | D2bv(DstAcc | SrcImm), N, N, | ||
2467 | /* 0x38 - 0x3F */ | 2464 | /* 0x38 - 0x3F */ |
2468 | D2bv(DstMem | SrcReg | ModRM), D2bv(DstReg | SrcMem | ModRM), | 2465 | D6ALU(0), N, N, |
2469 | D2bv(DstAcc | SrcImm), | ||
2470 | N, N, | ||
2471 | /* 0x40 - 0x4F */ | 2466 | /* 0x40 - 0x4F */ |
2472 | X16(D(DstReg)), | 2467 | X16(D(DstReg)), |
2473 | /* 0x50 - 0x57 */ | 2468 | /* 0x50 - 0x57 */ |
@@ -2618,6 +2613,7 @@ static struct opcode twobyte_table[256] = { | |||
2618 | 2613 | ||
2619 | #undef D2bv | 2614 | #undef D2bv |
2620 | #undef I2bv | 2615 | #undef I2bv |
2616 | #undef D6ALU | ||
2621 | 2617 | ||
2622 | static unsigned imm_size(struct decode_cache *c) | 2618 | static unsigned imm_size(struct decode_cache *c) |
2623 | { | 2619 | { |