public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@redhat.com>
Cc: x86@kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/3] KVM: x86 emulator: trap and propagate #DE from DIV and IDIV
Date: Wed, 25 Aug 2010 18:05:02 -0300	[thread overview]
Message-ID: <20100825210501.GD32737@amt.cnet> (raw)
In-Reply-To: <1282648229-19575-4-git-send-email-avi@redhat.com>

On Tue, Aug 24, 2010 at 02:10:29PM +0300, Avi Kivity wrote:
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>  arch/x86/kvm/emulate.c |   17 ++++++++++++++---
>  1 files changed, 14 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
> index f82e43a..a7e26d0 100644
> --- a/arch/x86/kvm/emulate.c
> +++ b/arch/x86/kvm/emulate.c
> @@ -505,6 +505,12 @@ static void emulate_ts(struct x86_emulate_ctxt *ctxt, int err)
>  	emulate_exception(ctxt, TS_VECTOR, err, true);
>  }
>  
> +static int emulate_de(struct x86_emulate_ctxt *ctxt)
> +{
> +	emulate_exception(ctxt, DE_VECTOR, 0, false);
> +	return X86EMUL_PROPAGATE_FAULT;
> +}
> +
>  static int do_fetch_insn_byte(struct x86_emulate_ctxt *ctxt,
>  			      struct x86_emulate_ops *ops,
>  			      unsigned long eip, u8 *dest)
> @@ -1459,6 +1465,7 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
>  	struct decode_cache *c = &ctxt->decode;
>  	unsigned long *rax = &c->regs[VCPU_REGS_RAX];
>  	unsigned long *rdx = &c->regs[VCPU_REGS_RDX];
> +	u8 de = 0;
>  
>  	switch (c->modrm_reg) {
>  	case 0 ... 1:	/* test */
> @@ -1477,14 +1484,18 @@ static inline int emulate_grp3(struct x86_emulate_ctxt *ctxt,
>  		emulate_1op_rax_rdx("imul", c->src, *rax, *rdx, ctxt->eflags);
>  		break;
>  	case 6: /* div */
> -		emulate_1op_rax_rdx("div", c->src, *rax, *rdx, ctxt->eflags);
> +		emulate_1op_rax_rdx_ex("div", c->src, *rax, *rdx,
> +				       ctxt->eflags, de);
>  		break;
>  	case 7: /* idiv */
> -		emulate_1op_rax_rdx("idiv", c->src, *rax, *rdx, ctxt->eflags);
> +		emulate_1op_rax_rdx_ex("idiv", c->src, *rax, *rdx,
> +				       ctxt->eflags, de);
>  		break;
>  	default:
>  		return X86EMUL_UNHANDLEABLE;
>  	}
> +	if (de)
> +		return emulate_de(ctxt);
>  	return X86EMUL_CONTINUE;
>  }
>  
> @@ -3363,7 +3374,7 @@ special_insn:
>  		break;
>  	case 0xf6 ... 0xf7:	/* Grp3 */
>  		if (emulate_grp3(ctxt, ops) != X86EMUL_CONTINUE)
> -			goto cannot_emulate;
> +			goto done;
>  		break;

Must assign rc to emulate_grp3() retval.


  reply	other threads:[~2010-08-25 21:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-24 11:10 [PATCH 0/3] Trap and propagate divide errors when emulating DIV Avi Kivity
2010-08-24 11:10 ` [PATCH 1/3] x86: allow kernel exception fixup for divide errors (#DE) Avi Kivity
2010-08-24 11:22   ` Brian Gerst
2010-08-24 11:39     ` Avi Kivity
2010-08-24 11:10 ` [PATCH 2/3] KVM: x86 emulator: add macros for executing instructions that may trap Avi Kivity
2010-08-24 11:10 ` [PATCH 3/3] KVM: x86 emulator: trap and propagate #DE from DIV and IDIV Avi Kivity
2010-08-25 21:05   ` Marcelo Tosatti [this message]
2010-08-26  8:23     ` Avi Kivity

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=20100825210501.GD32737@amt.cnet \
    --to=mtosatti@redhat.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /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