From patchwork Mon Mar 1 13:50:53 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 82930 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o21DltpC002008 for ; Mon, 1 Mar 2010 13:47:55 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751132Ab0CANrw (ORCPT ); Mon, 1 Mar 2010 08:47:52 -0500 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:53417 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751071Ab0CANrv (ORCPT ); Mon, 1 Mar 2010 08:47:51 -0500 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 0408224837C; Mon, 1 Mar 2010 22:47:51 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id E672224837B; Mon, 1 Mar 2010 22:47:50 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.68]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id C4AF711C0A3; Mon, 1 Mar 2010 22:47:50 +0900 (JST) Date: Mon, 1 Mar 2010 22:50:53 +0900 From: Takuya Yoshikawa To: avi@redhat.com, mtosatti@redhat.com Cc: kvm@vger.kernel.org Subject: KVM: x86 emulator: cleanup and tiny fix of pio emulation Message-Id: <20100301225053.0c9669c1.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 2.6.0 (GTK+ 2.16.1; i486-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.3 (demeter.kernel.org [140.211.167.41]); Mon, 01 Mar 2010 13:47:55 +0000 (UTC) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 5b6794a..a27cc3d 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -2344,19 +2344,16 @@ special_insn: case 0xef: /* out (e/r)ax,dx */ port = c->regs[VCPU_REGS_RDX]; io_dir_in = 0; - do_io: - if (!emulator_io_permited(ctxt, ops, port, - (c->d & ByteOp) ? 1 : c->op_bytes)) { + do_io: { + int len = (c->d & ByteOp) ? 1 : c->op_bytes; + if (!emulator_io_permited(ctxt, ops, port, len)) { kvm_inject_gp(ctxt->vcpu, 0); goto done; } - if (kvm_emulate_pio(ctxt->vcpu, io_dir_in, - (c->d & ByteOp) ? 1 : c->op_bytes, - port) != 0) { - c->eip = saved_eip; + if (kvm_emulate_pio(ctxt->vcpu, io_dir_in, len, port)) goto cannot_emulate; - } break; + } case 0xf4: /* hlt */ ctxt->vcpu->arch.halt_request = 1; break;