Skip to contentSkip to conversation

x86 emulator broken (vmload)

DISCUSSION Alexander Graf 2 participants 2 messages Dec 18, 2008 – Dec 23, 2008 KVM

lore
Share & tools
lore
#0 lore raw

While creating some userspace patches for the nested SVM implementation, I stumbled across an emulation problem in the x86 emulator that was not there some weeks ago.

Basically I'm running into an endless loop at:

NSVM: emulating at 0xe0e4077d -> 0

which is the "VMLOAD" instruction.

The endless loop is caused by this code:

        while(true) {
                int er;

                er = emulate_instruction(&svm->vcpu, kvm_run, 0, 0, 0);
                nsvm_printk("NSVM: emulating at 0x%lx -> %d\n",

svm->vcpu.arch.regs[VCPU_REGS_RIP], er);

                /* So we can now emulate the SVM instructions that most
probably
                   occur at the end of the codepath */
                if (er != EMULATE_DONE) {
                        while (true)
                                if (nested_svm_emulate(svm, kvm_run) ==
EMULATE_FAIL)
                                        break;
                        break;
                }
        }

While I have to admit that the while(true) is potentially a bad idea and I should limit that to like 100 instructions (patch floating around locally), emulate_instruction always returns EMULATE_DONE, even on the vmload instruction (which is clearly wrong).

Does anyone have ideas on this?

Alex

#1 lore raw
Quoted 2 lines · Alexander Graf

emulate_instruction always returns EMULATE_DONE, even on the vmload instruction (which is clearly wrong).

The emulator though that any svm instruction that isn't a vmmcall must be an lidt. I've fixed it up.

Signature · 1 line
error compiling committee.c: too many arguments to function