diff options
author | Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> | 2012-04-30 04:46:31 -0400 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-05-06 09:15:57 -0400 |
commit | 1c2545be05f436523cabc54087c6a60ea10110d3 (patch) | |
tree | 5c36d2e33b66936d7de62022363bdde92116aa80 /arch/x86 | |
parent | 9b72d3b07dd99ac8ab2b84de5004a295af460536 (diff) |
KVM: x86 emulator: Move ModRM flags for groups to top level opcode tables
Needed for the following patch which simplifies ModRM fetching code.
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/kvm/emulate.c | 111 |
1 files changed, 56 insertions, 55 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 0d151e232480..8d2c3d04cfec 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c | |||
@@ -3359,8 +3359,8 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt) | |||
3359 | .check_perm = (_p) } | 3359 | .check_perm = (_p) } |
3360 | #define N D(0) | 3360 | #define N D(0) |
3361 | #define EXT(_f, _e) { .flags = ((_f) | RMExt), .u.group = (_e) } | 3361 | #define EXT(_f, _e) { .flags = ((_f) | RMExt), .u.group = (_e) } |
3362 | #define G(_f, _g) { .flags = ((_f) | Group), .u.group = (_g) } | 3362 | #define G(_f, _g) { .flags = ((_f) | Group | ModRM), .u.group = (_g) } |
3363 | #define GD(_f, _g) { .flags = ((_f) | GroupDual), .u.gdual = (_g) } | 3363 | #define GD(_f, _g) { .flags = ((_f) | GroupDual | ModRM), .u.gdual = (_g) } |
3364 | #define I(_f, _e) { .flags = (_f), .u.execute = (_e) } | 3364 | #define I(_f, _e) { .flags = (_f), .u.execute = (_e) } |
3365 | #define II(_f, _e, _i) \ | 3365 | #define II(_f, _e, _i) \ |
3366 | { .flags = (_f), .u.execute = (_e), .intercept = x86_intercept_##_i } | 3366 | { .flags = (_f), .u.execute = (_e), .intercept = x86_intercept_##_i } |
@@ -3380,25 +3380,25 @@ static int check_perm_out(struct x86_emulate_ctxt *ctxt) | |||
3380 | I2bv(((_f) & ~Lock) | DstAcc | SrcImm, _e) | 3380 | I2bv(((_f) & ~Lock) | DstAcc | SrcImm, _e) |
3381 | 3381 | ||
3382 | static struct opcode group7_rm1[] = { | 3382 | static struct opcode group7_rm1[] = { |
3383 | DI(SrcNone | ModRM | Priv, monitor), | 3383 | DI(SrcNone | Priv, monitor), |
3384 | DI(SrcNone | ModRM | Priv, mwait), | 3384 | DI(SrcNone | Priv, mwait), |
3385 | N, N, N, N, N, N, | 3385 | N, N, N, N, N, N, |
3386 | }; | 3386 | }; |
3387 | 3387 | ||
3388 | static struct opcode group7_rm3[] = { | 3388 | static struct opcode group7_rm3[] = { |
3389 | DIP(SrcNone | ModRM | Prot | Priv, vmrun, check_svme_pa), | 3389 | DIP(SrcNone | Prot | Priv, vmrun, check_svme_pa), |
3390 | II(SrcNone | ModRM | Prot | VendorSpecific, em_vmmcall, vmmcall), | 3390 | II(SrcNone | Prot | VendorSpecific, em_vmmcall, vmmcall), |
3391 | DIP(SrcNone | ModRM | Prot | Priv, vmload, check_svme_pa), | 3391 | DIP(SrcNone | Prot | Priv, vmload, check_svme_pa), |
3392 | DIP(SrcNone | ModRM | Prot | Priv, vmsave, check_svme_pa), | 3392 | DIP(SrcNone | Prot | Priv, vmsave, check_svme_pa), |
3393 | DIP(SrcNone | ModRM | Prot | Priv, stgi, check_svme), | 3393 | DIP(SrcNone | Prot | Priv, stgi, check_svme), |
3394 | DIP(SrcNone | ModRM | Prot | Priv, clgi, check_svme), | 3394 | DIP(SrcNone | Prot | Priv, clgi, check_svme), |
3395 | DIP(SrcNone | ModRM | Prot | Priv, skinit, check_svme), | 3395 | DIP(SrcNone | Prot | Priv, skinit, check_svme), |
3396 | DIP(SrcNone | ModRM | Prot | Priv, invlpga, check_svme), | 3396 | DIP(SrcNone | Prot | Priv, invlpga, check_svme), |
3397 | }; | 3397 | }; |
3398 | 3398 | ||
3399 | static struct opcode group7_rm7[] = { | 3399 | static struct opcode group7_rm7[] = { |
3400 | N, | 3400 | N, |
3401 | DIP(SrcNone | ModRM, rdtscp, check_rdtsc), | 3401 | DIP(SrcNone, rdtscp, check_rdtsc), |
3402 | N, N, N, N, N, N, | 3402 | N, N, N, N, N, N, |
3403 | }; | 3403 | }; |
3404 | 3404 | ||
@@ -3414,76 +3414,77 @@ static struct opcode group1[] = { | |||
3414 | }; | 3414 | }; |
3415 | 3415 | ||
3416 | static struct opcode group1A[] = { | 3416 | static struct opcode group1A[] = { |
3417 | I(DstMem | SrcNone | ModRM | Mov | Stack, em_pop), N, N, N, N, N, N, N, | 3417 | I(DstMem | SrcNone | Mov | Stack, em_pop), N, N, N, N, N, N, N, |
3418 | }; | 3418 | }; |
3419 | 3419 | ||
3420 | static struct opcode group3[] = { | 3420 | static struct opcode group3[] = { |
3421 | I(DstMem | SrcImm | ModRM, em_test), | 3421 | I(DstMem | SrcImm, em_test), |
3422 | I(DstMem | SrcImm | ModRM, em_test), | 3422 | I(DstMem | SrcImm, em_test), |
3423 | I(DstMem | SrcNone | ModRM | Lock, em_not), | 3423 | I(DstMem | SrcNone | Lock, em_not), |
3424 | I(DstMem | SrcNone | ModRM | Lock, em_neg), | 3424 | I(DstMem | SrcNone | Lock, em_neg), |
3425 | I(SrcMem | ModRM, em_mul_ex), | 3425 | I(SrcMem, em_mul_ex), |
3426 | I(SrcMem | ModRM, em_imul_ex), | 3426 | I(SrcMem, em_imul_ex), |
3427 | I(SrcMem | ModRM, em_div_ex), | 3427 | I(SrcMem, em_div_ex), |
3428 | I(SrcMem | ModRM, em_idiv_ex), | 3428 | I(SrcMem, em_idiv_ex), |
3429 | }; | 3429 | }; |
3430 | 3430 | ||
3431 | static struct opcode group4[] = { | 3431 | static struct opcode group4[] = { |
3432 | I(ByteOp | DstMem | SrcNone | ModRM | Lock, em_grp45), | 3432 | I(ByteOp | DstMem | SrcNone | Lock, em_grp45), |
3433 | I(ByteOp | DstMem | SrcNone | ModRM | Lock, em_grp45), | 3433 | I(ByteOp | DstMem | SrcNone | Lock, em_grp45), |
3434 | N, N, N, N, N, N, | 3434 | N, N, N, N, N, N, |
3435 | }; | 3435 | }; |
3436 | 3436 | ||
3437 | static struct opcode group5[] = { | 3437 | static struct opcode group5[] = { |
3438 | I(DstMem | SrcNone | ModRM | Lock, em_grp45), | 3438 | I(DstMem | SrcNone | Lock, em_grp45), |
3439 | I(DstMem | SrcNone | ModRM | Lock, em_grp45), | 3439 | I(DstMem | SrcNone | Lock, em_grp45), |
3440 | I(SrcMem | ModRM | Stack, em_grp45), | 3440 | I(SrcMem | Stack, em_grp45), |
3441 | I(SrcMemFAddr | ModRM | ImplicitOps | Stack, em_call_far), | 3441 | I(SrcMemFAddr | ImplicitOps | Stack, em_call_far), |
3442 | I(SrcMem | ModRM | Stack, em_grp45), | 3442 | I(SrcMem | Stack, em_grp45), |
3443 | I(SrcMemFAddr | ModRM | ImplicitOps, em_grp45), | 3443 | I(SrcMemFAddr | ImplicitOps, em_grp45), |
3444 | I(SrcMem | ModRM | Stack, em_grp45), N, | 3444 | I(SrcMem | Stack, em_grp45), N, |
3445 | }; | 3445 | }; |
3446 | 3446 | ||
3447 | static struct opcode group6[] = { | 3447 | static struct opcode group6[] = { |
3448 | DI(ModRM | Prot, sldt), | 3448 | DI(Prot, sldt), |
3449 | DI(ModRM | Prot, str), | 3449 | DI(Prot, str), |
3450 | DI(ModRM | Prot | Priv, lldt), | 3450 | DI(Prot | Priv, lldt), |
3451 | DI(ModRM | Prot | Priv, ltr), | 3451 | DI(Prot | Priv, ltr), |
3452 | N, N, N, N, | 3452 | N, N, N, N, |
3453 | }; | 3453 | }; |
3454 | 3454 | ||
3455 | static struct group_dual group7 = { { | 3455 | static struct group_dual group7 = { { |
3456 | DI(ModRM | Mov | DstMem | Priv, sgdt), | 3456 | DI(Mov | DstMem | Priv, sgdt), |
3457 | DI(ModRM | Mov | DstMem | Priv, sidt), | 3457 | DI(Mov | DstMem | Priv, sidt), |
3458 | II(ModRM | SrcMem | Priv, em_lgdt, lgdt), | 3458 | II(SrcMem | Priv, em_lgdt, lgdt), |
3459 | II(ModRM | SrcMem | Priv, em_lidt, lidt), | 3459 | II(SrcMem | Priv, em_lidt, lidt), |
3460 | II(SrcNone | ModRM | DstMem | Mov, em_smsw, smsw), N, | 3460 | II(SrcNone | DstMem | Mov, em_smsw, smsw), N, |
3461 | II(SrcMem16 | ModRM | Mov | Priv, em_lmsw, lmsw), | 3461 | II(SrcMem16 | Mov | Priv, em_lmsw, lmsw), |
3462 | II(SrcMem | ModRM | ByteOp | Priv | NoAccess, em_invlpg, invlpg), | 3462 | II(SrcMem | ByteOp | Priv | NoAccess, em_invlpg, invlpg), |
3463 | }, { | 3463 | }, { |
3464 | I(SrcNone | ModRM | Priv | VendorSpecific, em_vmcall), | 3464 | I(SrcNone | Priv | VendorSpecific, em_vmcall), |
3465 | EXT(0, group7_rm1), | 3465 | EXT(0, group7_rm1), |
3466 | N, EXT(0, group7_rm3), | 3466 | N, EXT(0, group7_rm3), |
3467 | II(SrcNone | ModRM | DstMem | Mov, em_smsw, smsw), N, | 3467 | II(SrcNone | DstMem | Mov, em_smsw, smsw), N, |
3468 | II(SrcMem16 | ModRM | Mov | Priv, em_lmsw, lmsw), EXT(0, group7_rm7), | 3468 | II(SrcMem16 | Mov | Priv, em_lmsw, lmsw), |
3469 | EXT(0, group7_rm7), | ||
3469 | } }; | 3470 | } }; |
3470 | 3471 | ||
3471 | static struct opcode group8[] = { | 3472 | static struct opcode group8[] = { |
3472 | N, N, N, N, | 3473 | N, N, N, N, |
3473 | I(DstMem | SrcImmByte | ModRM, em_bt), | 3474 | I(DstMem | SrcImmByte, em_bt), |
3474 | I(DstMem | SrcImmByte | ModRM | Lock | PageTable, em_bts), | 3475 | I(DstMem | SrcImmByte | Lock | PageTable, em_bts), |
3475 | I(DstMem | SrcImmByte | ModRM | Lock, em_btr), | 3476 | I(DstMem | SrcImmByte | Lock, em_btr), |
3476 | I(DstMem | SrcImmByte | ModRM | Lock | PageTable, em_btc), | 3477 | I(DstMem | SrcImmByte | Lock | PageTable, em_btc), |
3477 | }; | 3478 | }; |
3478 | 3479 | ||
3479 | static struct group_dual group9 = { { | 3480 | static struct group_dual group9 = { { |
3480 | N, I(DstMem64 | ModRM | Lock | PageTable, em_cmpxchg8b), N, N, N, N, N, N, | 3481 | N, I(DstMem64 | Lock | PageTable, em_cmpxchg8b), N, N, N, N, N, N, |
3481 | }, { | 3482 | }, { |
3482 | N, N, N, N, N, N, N, N, | 3483 | N, N, N, N, N, N, N, N, |
3483 | } }; | 3484 | } }; |
3484 | 3485 | ||
3485 | static struct opcode group11[] = { | 3486 | static struct opcode group11[] = { |
3486 | I(DstMem | SrcImm | ModRM | Mov | PageTable, em_mov), | 3487 | I(DstMem | SrcImm | Mov | PageTable, em_mov), |
3487 | X7(D(Undefined)), | 3488 | X7(D(Undefined)), |
3488 | }; | 3489 | }; |
3489 | 3490 | ||
@@ -3541,10 +3542,10 @@ static struct opcode opcode_table[256] = { | |||
3541 | /* 0x70 - 0x7F */ | 3542 | /* 0x70 - 0x7F */ |
3542 | X16(D(SrcImmByte)), | 3543 | X16(D(SrcImmByte)), |
3543 | /* 0x80 - 0x87 */ | 3544 | /* 0x80 - 0x87 */ |
3544 | G(ByteOp | DstMem | SrcImm | ModRM | Group, group1), | 3545 | G(ByteOp | DstMem | SrcImm, group1), |
3545 | G(DstMem | SrcImm | ModRM | Group, group1), | 3546 | G(DstMem | SrcImm, group1), |
3546 | G(ByteOp | DstMem | SrcImm | ModRM | No64 | Group, group1), | 3547 | G(ByteOp | DstMem | SrcImm | No64, group1), |
3547 | G(DstMem | SrcImmByte | ModRM | Group, group1), | 3548 | G(DstMem | SrcImmByte, group1), |
3548 | I2bv(DstMem | SrcReg | ModRM, em_test), | 3549 | I2bv(DstMem | SrcReg | ModRM, em_test), |
3549 | I2bv(DstMem | SrcReg | ModRM | Lock | PageTable, em_xchg), | 3550 | I2bv(DstMem | SrcReg | ModRM | Lock | PageTable, em_xchg), |
3550 | /* 0x88 - 0x8F */ | 3551 | /* 0x88 - 0x8F */ |