aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/emulate.c
diff options
context:
space:
mode:
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>2011-05-29 09:05:15 -0400
committerAvi Kivity <avi@redhat.com>2011-07-12 06:16:07 -0400
commitf411e6cdc275e63ead2ffb427d0497daae6f6069 (patch)
tree847d4298b99054f51524ce9fd538d91838d9b444 /arch/x86/kvm/emulate.c
parentd06e03adcb30f9e9fff4df1d80a3087f54a62d9a (diff)
KVM: x86 emulator: Use opcode::execute for CLI/STI(FA/FB)
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'arch/x86/kvm/emulate.c')
-rw-r--r--arch/x86/kvm/emulate.c38
1 files changed, 21 insertions, 17 deletions
diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
index e9dbbc91ce8e..663bdb3637aa 100644
--- a/arch/x86/kvm/emulate.c
+++ b/arch/x86/kvm/emulate.c
@@ -2846,6 +2846,25 @@ static int em_jcxz(struct x86_emulate_ctxt *ctxt)
2846 return X86EMUL_CONTINUE; 2846 return X86EMUL_CONTINUE;
2847} 2847}
2848 2848
2849static int em_cli(struct x86_emulate_ctxt *ctxt)
2850{
2851 if (emulator_bad_iopl(ctxt))
2852 return emulate_gp(ctxt, 0);
2853
2854 ctxt->eflags &= ~X86_EFLAGS_IF;
2855 return X86EMUL_CONTINUE;
2856}
2857
2858static int em_sti(struct x86_emulate_ctxt *ctxt)
2859{
2860 if (emulator_bad_iopl(ctxt))
2861 return emulate_gp(ctxt, 0);
2862
2863 ctxt->interruptibility = KVM_X86_SHADOW_INT_STI;
2864 ctxt->eflags |= X86_EFLAGS_IF;
2865 return X86EMUL_CONTINUE;
2866}
2867
2849static bool valid_cr(int nr) 2868static bool valid_cr(int nr)
2850{ 2869{
2851 switch (nr) { 2870 switch (nr) {
@@ -3276,7 +3295,8 @@ static struct opcode opcode_table[256] = {
3276 DI(ImplicitOps | Priv, hlt), D(ImplicitOps), 3295 DI(ImplicitOps | Priv, hlt), D(ImplicitOps),
3277 G(ByteOp, group3), G(0, group3), 3296 G(ByteOp, group3), G(0, group3),
3278 /* 0xF8 - 0xFF */ 3297 /* 0xF8 - 0xFF */
3279 D(ImplicitOps), D(ImplicitOps), D(ImplicitOps), D(ImplicitOps), 3298 D(ImplicitOps), D(ImplicitOps),
3299 I(ImplicitOps, em_cli), I(ImplicitOps, em_sti),
3280 D(ImplicitOps), D(ImplicitOps), G(0, group4), G(0, group5), 3300 D(ImplicitOps), D(ImplicitOps), G(0, group4), G(0, group5),
3281}; 3301};
3282 3302
@@ -4049,22 +4069,6 @@ special_insn:
4049 case 0xf9: /* stc */ 4069 case 0xf9: /* stc */
4050 ctxt->eflags |= EFLG_CF; 4070 ctxt->eflags |= EFLG_CF;
4051 break; 4071 break;
4052 case 0xfa: /* cli */
4053 if (emulator_bad_iopl(ctxt)) {
4054 rc = emulate_gp(ctxt, 0);
4055 goto done;
4056 } else
4057 ctxt->eflags &= ~X86_EFLAGS_IF;
4058 break;
4059 case 0xfb: /* sti */
4060 if (emulator_bad_iopl(ctxt)) {
4061 rc = emulate_gp(ctxt, 0);
4062 goto done;
4063 } else {
4064 ctxt->interruptibility = KVM_X86_SHADOW_INT_STI;
4065 ctxt->eflags |= X86_EFLAGS_IF;
4066 }
4067 break;
4068 case 0xfc: /* cld */ 4072 case 0xfc: /* cld */
4069 ctxt->eflags &= ~EFLG_DF; 4073 ctxt->eflags &= ~EFLG_DF;
4070 break; 4074 break;