public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: avi@redhat.com, kvm@vger.kernel.org
Subject: Re: [PATCH 5/5] KVM: Fix the usage of X86EMUL_* values in x86.c
Date: Fri, 29 Jan 2010 19:39:57 -0200	[thread overview]
Message-ID: <20100129213957.GE18360@amt.cnet> (raw)
In-Reply-To: <20100128230334.5bcc0912.yoshikawa.takuya@oss.ntt.co.jp>

On Thu, Jan 28, 2010 at 11:03:34PM +0900, Takuya Yoshikawa wrote:
> pio_copy_data() and load|save_guest_segment_descriptor()
> return X86EMUL_* values. Mixing up these values with 0, 1, ...
> may produce unpridictable bugs.
> 
> Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
> ---
>  arch/x86/kvm/x86.c |   27 +++++++++++++++------------
>  1 files changed, 15 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index 78b8ddb..67f8231 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3454,7 +3454,6 @@ int complete_pio(struct kvm_vcpu *vcpu)
>  {
>  	struct kvm_pio_request *io = &vcpu->arch.pio;
>  	long delta;
> -	int r;
>  	unsigned long val;
>  
>  	if (!io->string) {
> @@ -3465,9 +3464,9 @@ int complete_pio(struct kvm_vcpu *vcpu)
>  		}
>  	} else {
>  		if (io->in) {
> -			r = pio_copy_data(vcpu);
> -			if (r)
> -				return r;
> +			int ret = pio_copy_data(vcpu);
> +			if (ret != X86EMUL_CONTINUE)
> +				return 1;
>  		}
>  
>  		delta = 1;
> @@ -3567,7 +3566,6 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, int in,
>  		  gva_t address, int rep, unsigned port)
>  {
>  	unsigned now, in_page;
> -	int ret = 0;
>  
>  	vcpu->run->exit_reason = KVM_EXIT_IO;
>  	vcpu->run->io.direction = in ? KVM_EXIT_IO_IN : KVM_EXIT_IO_OUT;
> @@ -3613,20 +3611,22 @@ int kvm_emulate_pio_string(struct kvm_vcpu *vcpu, int in,
>  
>  	if (!vcpu->arch.pio.in) {
>  		/* string PIO write */
> -		ret = pio_copy_data(vcpu);
> +		int ret = pio_copy_data(vcpu);
>  		if (ret == X86EMUL_PROPAGATE_FAULT) {
>  			kvm_inject_gp(vcpu, 0);
>  			return 1;
>  		}
> -		if (ret == 0 && !pio_string_write(vcpu)) {
> +		if (ret == X86EMUL_UNHANDLEABLE)
> +			return 1;
> +		if (ret == X86EMUL_CONTINUE && !pio_string_write(vcpu)) {
>  			complete_pio(vcpu);
>  			if (vcpu->arch.pio.count == 0)
> -				ret = 1;
> +				return 1;
>  		}
>  	}
>  	/* no string PIO read support yet */
>  
> -	return ret;
> +	return 0;
>  }
>  EXPORT_SYMBOL_GPL(kvm_emulate_pio_string);

This function is used by the emulator, and as such should return
X86_EMUL values?

      reply	other threads:[~2010-01-29 21:40 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-28 13:51 [PATCH 0/5] KVM: Cleanups: X86EMUL_* related Takuya Yoshikawa
2010-01-28 13:54 ` [PATCH 1/5] KVM: Use X86EMUL_* to check the return value from read_std Takuya Yoshikawa
2010-01-29 20:46   ` Marcelo Tosatti
2010-01-28 13:56 ` [PATCH 2/5] KVM: These functions should return X86EMUL_* not 0 or 1 or Takuya Yoshikawa
2010-01-29 21:18   ` Marcelo Tosatti
2010-01-28 13:59 ` [PATCH 3/5] KVM: Restrict rc values in x86_emulate_insn to X86EMUL_* values Takuya Yoshikawa
2010-01-29 21:21   ` Marcelo Tosatti
2010-01-28 14:01 ` [PATCH 4/5] KVM: load|save_guest_segment_descriptor() should return " Takuya Yoshikawa
2010-01-29 21:30   ` Marcelo Tosatti
2010-01-28 14:03 ` [PATCH 5/5] KVM: Fix the usage of X86EMUL_* values in x86.c Takuya Yoshikawa
2010-01-29 21:39   ` Marcelo Tosatti [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=20100129213957.GE18360@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --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