From: Gleb Natapov <gleb@redhat.com>
To: Jan Kiszka <jan.kiszka@siemens.com>
Cc: Avi Kivity <avi@redhat.com>,
Marcelo Tosatti <mtosatti@redhat.com>, kvm <kvm@vger.kernel.org>
Subject: Re: KVM: x86: Push potential exception error code on task switches
Date: Wed, 14 Apr 2010 15:38:45 +0300 [thread overview]
Message-ID: <20100414123845.GA18132@redhat.com> (raw)
In-Reply-To: <4BC5B0FB.8020700@siemens.com>
On Wed, Apr 14, 2010 at 02:11:39PM +0200, Jan Kiszka wrote:
> static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
> - struct x86_emulate_ops *ops,
> - u16 tss_selector, int reason)
> + struct x86_emulate_ops *ops,
> + u16 tss_selector, int reason,
> + bool has_error_code, u32 error_code)
> {
> struct desc_struct curr_tss_desc, next_tss_desc;
> int ret;
> @@ -2416,12 +2417,23 @@ static int emulator_do_task_switch(struct x86_emulate_ctxt *ctxt,
> ops->set_cached_descriptor(&next_tss_desc, VCPU_SREG_TR, ctxt->vcpu);
> ops->set_segment_selector(tss_selector, VCPU_SREG_TR, ctxt->vcpu);
>
> + if (ret == X86EMUL_CONTINUE && has_error_code) {
It looks like we shouldn't get here if ret != X86EMUL_CONTINUE in the
first place. This check should be done just after call to
task_switch_16/32. Not directly related to your patch, but still...
> @@ -2416,12 +2417,23 @@ static int emulator_do_task_switch(struct
> x86_emulate_ctxt *ctxt,
> ops->set_cached_descriptor(&next_tss_desc, VCPU_SREG_TR,
> ctxt->vcpu);
> ops->set_segment_selector(tss_selector, VCPU_SREG_TR,
> ctxt->vcpu);
>
> + if (ret == X86EMUL_CONTINUE && has_error_code) {
> + struct decode_cache *c = &ctxt->decode;
> +
> + c->op_bytes = c->ad_bytes = (next_tss_desc.type & 8) ? 4
> : 2;
> + c->lock_prefix = 0;
> + c->src.val = (unsigned long) error_code;
> + emulate_push(ctxt);
> + ret = writeback(ctxt, ops);
> + }
I would move writeback() to emulator_task_switch(). Just make
c->dst.type = OP_NONE if writeback is not needed.
--
Gleb.
next prev parent reply other threads:[~2010-04-14 12:38 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-14 12:11 KVM: x86: Push potential exception error code on task switches Jan Kiszka
2010-04-14 12:22 ` Avi Kivity
2010-04-14 12:37 ` Jan Kiszka
2010-04-14 12:39 ` Jan Kiszka
2010-04-14 12:52 ` Avi Kivity
2010-04-14 12:58 ` Jan Kiszka
2010-04-14 13:07 ` Avi Kivity
2010-04-14 13:08 ` Avi Kivity
2010-04-14 13:19 ` Jan Kiszka
2010-04-15 8:41 ` Avi Kivity
2010-04-15 8:47 ` Jan Kiszka
2010-04-14 12:38 ` Gleb Natapov [this message]
2010-04-14 12:43 ` Jan Kiszka
2010-04-14 13:00 ` Jan Kiszka
2010-04-14 14:09 ` Gleb Natapov
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=20100414123845.GA18132@redhat.com \
--to=gleb@redhat.com \
--cc=avi@redhat.com \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.