Hi to all,
I'm trying to implement the sidt emulation in kvm in addition to the
lidt emulation (already implemented) but I'm having some problems and
I was wondering if you could help me with it.
In order to add the sidt emulation first I've added the following function:
1) void realmode_sidt(struct kvm_vcpu *vcpu, struct kvm_desc_ptr *dt)
That reads the needed information from the IDTR and puts them in the
kvm_desc_ptr structure.
Than I've added the sidt opcode in the opcode group table in order to
allow kvm to correctly decode the instruction as follows:
 static u32 group_table[ ] = {
        ...
        [Group7*8] =
        0,
        SrcNone | ModRM | DstMem | Priv,             //sidt instruction
        ModRM | SrcMem | Priv,
        ModRM | SrcMem | Priv,                            //lidt instruction
        SrcNone | ModRM | DstMem | Mov,
        0,
        SrcMem16 | ModRM | Mov | Priv,
        SrcMem | ModRM | ByteOp | Priv,
        ...
Then, I've added the sidt switch case in the "twobyte_insn" section as follow:
twobyte_insn:
        switch (c->b) {
        case 0x01: /* lgdt, lidt, lmsw */
                switch (c->modrm_reg) {
                        u16 size;
                        unsigned long address;
                ...
                case 1: /* sidt */
                        struct kvm_desc_ptr *dt;
                        realmode_sidt(ctxt->vcpu, &dt);
                        c->dst.type = OP_MEM;
                        c->dst.val=dt;
                        c->dst.bytes=sizeof(dt);
                        goto writeback;
                ....
Where "realmode_sidt" function reads the Guest IDT Register address
and fills the dt struct with the correct values.
Now, the problem is that, even if the instruction is correctly decoded
(the &dt pointer is the same as if I print it from within the guest)
and even if the return value of all intermediate functions is always
correct (EMULATION_CONTINUE)
the guest immediately performs a restarts (even if c->ctxt.restart is false)
after the execution of the sidt instruction within the guest OS.
I dont' understand why is it so.
Could you please suggests to me how could I fix this problem???

Thanks in advance,
Matteo
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to