Skip to contentSkip to conversation

KVM: x86: fix failure of injecting exceptions inx86_emulate_instruction

PATCH Paolo Bonzini 1 participant 1 message Sep 21, 2018 1 message not in the archive KVM

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Paolo Bonzini

author maintainer
#1 lore raw
Quoted 4 lines · On 21/09/2018 04:08, [email protected] wrote:
Quoted 4 lines
Quoted 4 lines

Unqueued, sorry. The hypercall test from kvm-unit-tests fails. A VMCALL on the "edge" of canonical address space, i.e. at 0x7ffffffffffd, raises a general protection fault before this patch and a double fault afterwards.

Quoted 8 lines
Quoted 4 lines

Peng Hao submitted a very similar patch[1], the difference being that it also modified x86_emulate_instruction() to ignore the result of inject_emulated_exception(). I have no idea if that change is correct but it may be related to the aforementioned unit test failing.

The return value of inject_emulated_exception for #PF represents whether in nested vcpu, not about the success or failure. Because we are not in nested vcpu, inject_emulated_exception must return false. And for other exceptions, inject_emulated_exception just return false. After propagating exceptions to guest, we just should return to guest mode and let guest handle.

Yes, your patch should work, and the x86_emulate_instruction code that is there now is clearly wrong (though I'm not sure how the double-fault comes up, #GP + #UD shouldn't generate one because #UD is a benign exception).

Peng Hao, do you have a testcase? Eduardo's kvm-unit-tests patch from Nov 2017 doesn't reproduce the bug anymore for me.

Thanks,

Paolo