public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: avi@redhat.com, mtosatti@redhat.com, kvm@vger.kernel.org
Subject: Re: KVM: x86 emulator: cleanup and tiny fix of pio emulation
Date: Mon, 1 Mar 2010 15:59:42 +0200	[thread overview]
Message-ID: <20100301135942.GK16909@redhat.com> (raw)
In-Reply-To: <20100301225053.0c9669c1.yoshikawa.takuya@oss.ntt.co.jp>

On Mon, Mar 01, 2010 at 10:50:53PM +0900, Takuya Yoshikawa wrote:
> Cannot_emulate includes "c->eip = saved_eip". So the execution
> of this after kvm_emulate_pio() is redundant. Let's remove this.
> Others are trivial cleanups.
> 
I am looking into this now. Emulation of in/out is completely broken
(usually their emulation doesn't go through emulator.c so nobody notice)

> Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
> ---
>  arch/x86/kvm/emulate.c |   13 +++++--------
>  1 files changed, 5 insertions(+), 8 deletions(-)
> 
> 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))
For instance here kvm_emulate_pio() can never fail. Both return values
indicate success the only difference is that if 0 is returned exit to
userspace is needed.

>  			goto cannot_emulate;
> -		}
>  		break;
> +	}
>  	case 0xf4:              /* hlt */
>  		ctxt->vcpu->arch.halt_request = 1;
>  		break;
> -- 
> 1.6.3.3
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

--
			Gleb.

      reply	other threads:[~2010-03-01 13:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-01 13:50 KVM: x86 emulator: cleanup and tiny fix of pio emulation Takuya Yoshikawa
2010-03-01 13:59 ` Gleb Natapov [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100301135942.GK16909@redhat.com \
    --to=gleb@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=yoshikawa.takuya@oss.ntt.co.jp \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox