public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Avi Kivity <avi@redhat.com>
To: Manish Regmi <regmi.manish@gmail.com>
Cc: kvm@vger.kernel.org
Subject: Re: [PATCH 0/1] trace all instructions whose emulation failed
Date: Mon, 19 Apr 2010 12:20:37 +0300	[thread overview]
Message-ID: <4BCC2065.6020308@redhat.com> (raw)
In-Reply-To: <l2x652016d31004172333i7cb9994vdeee1fe0ce19d9c3@mail.gmail.com>

On 04/18/2010 09:33 AM, Manish Regmi wrote:
> Hi,
>    The following patch makes sure all code path of failed emulation
> runs trace_kvm_emulate_insn_failed().
> Please let me know if there is anything missing or wrong.
> Thank you.
>
> Signed-off-by: Manish Regmi<regmi.manish@gmail.com>
> --------
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index b6e7535..fd1e875 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -3784,36 +3784,35 @@ int emulate_instruction(struct kvm_vcpu *vcpu,
>   		c =&vcpu->arch.emulate_ctxt.decode;
>   		if (emulation_type&  EMULTYPE_TRAP_UD) {
>   			if (!c->twobyte)
> -				return EMULATE_FAIL;
> +				goto emulate_failed;
>   			switch (c->b) {
>   			case 0x01: /* VMMCALL */
>   				if (c->modrm_mod != 3 || c->modrm_rm != 1)
> -					return EMULATE_FAIL;
> +					goto emulate_failed;
>   				break;
>   			case 0x34: /* sysenter */
>   			case 0x35: /* sysexit */
>   				if (c->modrm_mod != 0 || c->modrm_rm != 0)
> -					return EMULATE_FAIL;
> +					goto emulate_failed;
>   				break;
>   			case 0x05: /* syscall */
>   				if (c->modrm_mod != 0 || c->modrm_rm != 0)
> -					return EMULATE_FAIL;
> +					goto emulate_failed;;
>   				break;
>   			default:
> -				return EMULATE_FAIL;
> +				goto emulate_failed;
>   			}
>
>   			if (!(c->modrm_reg == 0 || c->modrm_reg == 3))
> -				return EMULATE_FAIL;
> +				goto emulate_failed;
>   		}
>
>   		++vcpu->stat.insn_emulation;
>   		if (r)  {
>   			++vcpu->stat.insn_emulation_fail;
> -			trace_kvm_emulate_insn_failed(vcpu);
>   			if (kvm_mmu_unprotect_page_virt(vcpu, cr2))
>   				return EMULATE_DONE;
> -			return EMULATE_FAIL;
> +			goto emulate_failed;
>   		}
>   	}
>
>    

It's better not to trace #UD triggered emulations, since we except these 
to fail, for example if the guest executes the UD2 instruction.

-- 
error compiling committee.c: too many arguments to function


  reply	other threads:[~2010-04-19  9:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-18  6:33 [PATCH 0/1] trace all instructions whose emulation failed Manish Regmi
2010-04-19  9:20 ` Avi Kivity [this message]
2010-04-19 22:37   ` Manish Regmi

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=4BCC2065.6020308@redhat.com \
    --to=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=regmi.manish@gmail.com \
    /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