On Tue, Sep 9, 2008 at 10:16 AM, Guillaume Thouvenin
<[EMAIL PROTECTED]> wrote:
> On Mon, 8 Sep 2008 21:47:19 +0300
> Mohammed Gamal <[EMAIL PROTECTED]> wrote:
>
>
>> +     SrcMem | ModRM | Stack, 0,
>
> Are you sure about this? In Xen they use "DstMem | SrcNone | ModRM"
> Anyway I tested the patch and the next problem is with the following
> instruction:
>
I'll look at the Xen code, however this is working well with me. I
added some logging to report all instructions in addition to a test
case in the real mode test harness and the call instruction jumps to
the correct address.

> emulation failed (emulation failure) rip 4423e 3c 25 0f 84
>
> Thus I added the following patch (see the end of this email) and now
> another problem:
>
> emulation failed (mmio) rip 44b5b 03 84 c0 75
>
We don't handle mmio emulation yet. It'd be great to see it handled.

> So it's not the same problem. I'm trying to fix that. It would be cool
> to be able to boot a distribution with emulate_invalid_guest_state enabled ;)
>
> Signed-off-by: Guillaume Thouvenin <[EMAIL PROTECTED]>
>
> ---
> diff --git a/arch/x86/kvm/x86_emulate.c b/arch/x86/kvm/x86_emulate.c
> index 30b93ee..b65bc94 100644
> --- a/arch/x86/kvm/x86_emulate.c
> +++ b/arch/x86/kvm/x86_emulate.c
> @@ -107,7 +107,7 @@ static u16 opcode_table[256] = {
>        /* 0x38 - 0x3F */
>        ByteOp | DstMem | SrcReg | ModRM, DstMem | SrcReg | ModRM,
>        ByteOp | DstReg | SrcMem | ModRM, DstReg | SrcMem | ModRM,
> -       0, 0, 0, 0,
> +       ByteOp | DstReg |SrcImm, DstReg|SrcImm, 0, 0,
>        /* 0x40 - 0x47 */
>        DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg, DstReg,
>        /* 0x48 - 0x4F */
> @@ -1405,10 +1405,22 @@ special_insn:
>              xor:              /* xor */
>                emulate_2op_SrcV("xor", c->src, c->dst, ctxt->eflags);
>                break;
> -       case 0x38 ... 0x3d:
> +       case 0x38 ... 0x3b:
>              cmp:              /* cmp */
>                emulate_2op_SrcV("cmp", c->src, c->dst, ctxt->eflags);
>                break;
> +       case 0x3c ... 0x3d:     /* cmp al imm8 or ax imm16 or eax imm32 */
> +               c->dst.type = OP_REG;
> +               c->dst.bytes = c->op_bytes;
> +               c->dst.ptr = &c->regs[VCPU_REGS_RAX];
> +               if (c->op_bytes == 1)
> +                       c->dst.val = *(u8 *)c->dst.ptr;
> +               else if (c->op_bytes == 2)
> +                       c->dst.val = *(u16 *)c->dst.ptr;
> +               else
> +                       c->dst.val = *(u32 *)c->dst.ptr;
> +               c->dst.orig_val = c->dst.val;
> +               goto cmp;
>        case 0x40 ... 0x47: /* inc r16/r32 */
>                emulate_1op("inc", c->dst, ctxt->eflags);
>                break;
>

It'd be great to add a test case for this instruction in the to ensure
it's not broken. You can find the test harness in the userspace tree
at user/test/x86/realmode.c
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to