From patchwork Sun May 29 13:05:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 827752 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4TD5NeQ001520 for ; Sun, 29 May 2011 13:05:23 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753852Ab1E2NFV (ORCPT ); Sun, 29 May 2011 09:05:21 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:38212 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751818Ab1E2NFU (ORCPT ); Sun, 29 May 2011 09:05:20 -0400 Received: by pwi15 with SMTP id 15so1326739pwi.19 for ; Sun, 29 May 2011 06:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:in-reply-to :references:x-mailer:mime-version:content-type :content-transfer-encoding; bh=Vj/k3atU5yyjMDjDdsXZOpzSpuO2pkHS39Q+3svRNhw=; b=avtjh/6IZZSeRZjNfRfdyRtOJpn5HnXXH/ZXnHqO2dSc/mKowVWsiLJ4EMEFdo5TVM +Kwo048Y8Y4vhFVpEsn9C6yEGxk0WKteW69A4MXrkfSxu/nsL38ChUnV8nP4xP7LM4+G 11JxORiCzuyyyaxgwiwm952/26Ff/wukC6RJc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=iArPJRaJ6p0jRIDNmuZJ/atxTWZpYwyZp96Z3PyKrXpNo8LBWg13f7J95meAFVFoOt AzyHF2zrldwcGwZ2xKHV3+4Wt9VY41r91g/7QJELoytnBCGJmbk7gw+QeGDYsRXg/Pzs yEJqSSShr4jjBb/qelLn3hlIPiQ3ph8iX/h90= Received: by 10.68.16.167 with SMTP id h7mr1575763pbd.398.1306674319913; Sun, 29 May 2011 06:05:19 -0700 (PDT) Received: from amd (x096101.dynamic.ppp.asahi-net.or.jp [122.249.96.101]) by mx.google.com with ESMTPS id k9sm2054359pbc.38.2011.05.29.06.05.17 (version=SSLv3 cipher=OTHER); Sun, 29 May 2011 06:05:19 -0700 (PDT) Date: Sun, 29 May 2011 22:05:15 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org, yoshikawa.takuya@oss.ntt.co.jp, gleb@redhat.com Subject: [PATCH 10/10] KVM: x86 emulator: Use opcode::execute for CLI/STI(FA/FB) Message-Id: <20110529220515.301a5a19.takuya.yoshikawa@gmail.com> In-Reply-To: <20110529215200.17be7761.takuya.yoshikawa@gmail.com> References: <20110529215200.17be7761.takuya.yoshikawa@gmail.com> X-Mailer: Sylpheed 3.1.0 (GTK+ 2.24.4; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Sun, 29 May 2011 13:05:23 +0000 (UTC) From: Takuya Yoshikawa Signed-off-by: Takuya Yoshikawa --- arch/x86/kvm/emulate.c | 38 +++++++++++++++++++++----------------- 1 files changed, 21 insertions(+), 17 deletions(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 2bf3415..e0c83a7 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2844,6 +2844,25 @@ static int em_jcxz(struct x86_emulate_ctxt *ctxt) return X86EMUL_CONTINUE; } +static int em_cli(struct x86_emulate_ctxt *ctxt) +{ + if (emulator_bad_iopl(ctxt)) + return emulate_gp(ctxt, 0); + + ctxt->eflags &= ~X86_EFLAGS_IF; + return X86EMUL_CONTINUE; +} + +static int em_sti(struct x86_emulate_ctxt *ctxt) +{ + if (emulator_bad_iopl(ctxt)) + return emulate_gp(ctxt, 0); + + ctxt->interruptibility = KVM_X86_SHADOW_INT_STI; + ctxt->eflags |= X86_EFLAGS_IF; + return X86EMUL_CONTINUE; +} + static bool valid_cr(int nr) { switch (nr) { @@ -3274,7 +3293,8 @@ static struct opcode opcode_table[256] = { DI(ImplicitOps | Priv, hlt), D(ImplicitOps), G(ByteOp, group3), G(0, group3), /* 0xF8 - 0xFF */ - D(ImplicitOps), D(ImplicitOps), D(ImplicitOps), D(ImplicitOps), + D(ImplicitOps), D(ImplicitOps), + I(ImplicitOps, em_cli), I(ImplicitOps, em_sti), D(ImplicitOps), D(ImplicitOps), G(0, group4), G(0, group5), }; @@ -4035,22 +4055,6 @@ special_insn: case 0xf9: /* stc */ ctxt->eflags |= EFLG_CF; break; - case 0xfa: /* cli */ - if (emulator_bad_iopl(ctxt)) { - rc = emulate_gp(ctxt, 0); - goto done; - } else - ctxt->eflags &= ~X86_EFLAGS_IF; - break; - case 0xfb: /* sti */ - if (emulator_bad_iopl(ctxt)) { - rc = emulate_gp(ctxt, 0); - goto done; - } else { - ctxt->interruptibility = KVM_X86_SHADOW_INT_STI; - ctxt->eflags |= X86_EFLAGS_IF; - } - break; case 0xfc: /* cld */ ctxt->eflags &= ~EFLG_DF; break;