From: Anthony Liguori <anthony@codemonkey.ws>
To: Guillaume Thouvenin <guillaume.thouvenin@ext.bull.net>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>,
Avi Kivity <avi@qumranet.com>
Subject: Re: [PATCH] gfxboot VMX workaround v2
Date: Fri, 18 Apr 2008 08:23:07 -0500 [thread overview]
Message-ID: <4808A0BB.20500@codemonkey.ws> (raw)
In-Reply-To: <20080418141816.29e745f0@frecb000711.frec.bull.fr>
Guillaume Thouvenin wrote:
> On Tue, 15 Apr 2008 16:06:43 +0300
> Avi Kivity <avi@qumranet.com> wrote:
>
>
>>> ...
>>> handle_vmentry_failure: invalid guest state
>>> handle_vmentry_failure: start emulation
>>> handle_vmentry_failure: emulation failed
>>>
>>>
>> What instruction failed, exactly?
>>
>>
>
> I added the code do dump the instruction and it seems that it's the
> emulation of 0xe6 (== out imm8, al) that failed. I made modifications
> to emulate it (see below) and now I have another problem in kvm
> userspace with the following message (and the emulation doesn't work):
>
> enterprise:~ $ kvm_run: Operation not permitted
> enterprise:~ $ kvm_run returned -1
>
>
>> You need to load rip as well.
>>
>
> Ooops, yes. So jump far emulation is now like:
>
> + case 0xea: /* jmp far */ {
> + struct kvm_segment kvm_seg;
> + long int eip;
> + int ret;
> +
> + kvm_x86_ops->get_segment(ctxt->vcpu, &kvm_seg, VCPU_SREG_CS);
> +
> + ret = load_segment_descriptor(ctxt->vcpu, kvm_seg.selector, 9, VCPU_SREG_CS);
> + if (ret < 0){
> + printk(KERN_INFO "%s: Failed to load CS descriptor\n", __FUNCTION__);
> + goto cannot_emulate;
> + }
> +
> + switch (c->op_bytes) {
> + case 2:
> + eip = insn_fetch(s16, 2, c->eip);
> + break;
> + case 4:
> + eip = insn_fetch(s32, 4, c->eip);
> + break;
> + default:
> + DPRINTF("jmp far: Invalid op_bytes\n");
> + goto cannot_emulate;
> + }
> + printk(KERN_INFO "eip == 0x%lx\n", eip);
> + c->eip = eip;
> + break;
> + }
>
> It seems that the jump to cs:eip works and now I have the following error:
>
> [18535.446917] handle_vmentry_failure: invalid guest state
> [18535.449519] handle_vmentry_failure: start emulation
> [18535.457519] eip == 0x6e18
> [18535.467685] handle_vmentry_failure: emulation of 0xe6 failed
>
> For the emulation of 0xe6 I used the following one that I found in
> nitin's tree:
>
This doesn't seem right. You should have been able to break out of the
emulator long before encountering an out instruction. The next
instruction you encounter should be a mov instruction. Are you sure
you're updating eip correctly?
Regards,
Anthony Liguori
> + case 0xe6: /* out imm8, al */
> + case 0xe7: /* out imm8, ax/eax */ {
> + struct kvm_io_device *pio_dev;
> +
> + pio_dev = vcpu_find_pio_dev(ctxt->vcpu, c->src.val);
> + kvm_iodevice_write(pio_dev, c->src.val,
> + (c->d & ByteOp) ? 1 : c->op_bytes,
> + &c->regs[VCPU_REGS_RAX]);
> + }
> + break;
>
> I will look closer where is the problem and as you suggested, I will
> display the instruction to be emulated and the register state before
> and after, and compare with the expected state.
>
>
> Thanks for your help,
> Regards,
> Guillaume
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
> Don't miss this year's exciting event. There's still time to save $100.
> Use priority code J8TL2D2.
> http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
> _______________________________________________
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
next prev parent reply other threads:[~2008-04-18 13:23 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-07 13:12 [PATCH] gfxboot VMX workaround v2 Alexander Graf
2008-04-07 16:05 ` Anthony Liguori
2008-04-07 16:25 ` Alexander Graf
2008-04-07 16:51 ` Anthony Liguori
2008-04-07 17:03 ` Alexander Graf
2008-04-07 17:05 ` Anthony Liguori
2008-04-08 0:05 ` Avi Kivity
2008-04-08 7:30 ` Guillaume Thouvenin
2008-04-08 12:14 ` Anthony Liguori
2008-04-08 13:02 ` Guillaume Thouvenin
2008-04-08 21:56 ` Avi Kivity
2008-04-15 9:07 ` Guillaume Thouvenin
2008-04-15 13:06 ` Avi Kivity
2008-04-18 12:18 ` Guillaume Thouvenin
2008-04-18 12:55 ` Guillaume Thouvenin
2008-04-18 13:23 ` Anthony Liguori [this message]
2008-04-18 14:05 ` Guillaume Thouvenin
2008-04-18 15:25 ` Anthony Liguori
2008-04-20 7:52 ` Avi Kivity
2008-04-21 15:11 ` Guillaume Thouvenin
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=4808A0BB.20500@codemonkey.ws \
--to=anthony@codemonkey.ws \
--cc=avi@qumranet.com \
--cc=guillaume.thouvenin@ext.bull.net \
--cc=kvm-devel@lists.sourceforge.net \
/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