Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-05 Thread Gleb Natapov
On Thu, Sep 04, 2014 at 07:44:51PM +0200, Paolo Bonzini wrote: > Il 04/09/2014 17:05, Gleb Natapov ha scritto: > >> > > >> > If you do that, KVM gets down to the "if (writeback)" and writes the > >> > ctxt->eip from L2 into the L1 EIP. > > Heh, that's a bummer. We should not write back if an inst

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-04 Thread Paolo Bonzini
Il 04/09/2014 17:05, Gleb Natapov ha scritto: >> > >> > If you do that, KVM gets down to the "if (writeback)" and writes the >> > ctxt->eip from L2 into the L1 EIP. > Heh, that's a bummer. We should not write back if an instruction caused a > vmexit. > You're right, that works. Paolo ---

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-04 Thread Paolo Bonzini
Il 04/09/2014 17:05, Gleb Natapov ha scritto: >> > if (ctxt->have_exception) { >> > inject_emulated_exception(vcpu); >> > - r = EMULATE_DONE; >> > + return EMULATE_DONE; > If there was no vmexit we still want to writeback. Perhaps: > writeback

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-04 Thread Gleb Natapov
On Thu, Sep 04, 2014 at 04:12:19PM +0200, Paolo Bonzini wrote: > Il 04/09/2014 09:02, Gleb Natapov ha scritto: > > On Tue, Sep 02, 2014 at 05:13:49PM +0200, Paolo Bonzini wrote: > >> > This is required for the following patch to work correctly. If a nested > >> > page > >> > fault happens during

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-04 Thread Paolo Bonzini
Il 04/09/2014 09:02, Gleb Natapov ha scritto: > On Tue, Sep 02, 2014 at 05:13:49PM +0200, Paolo Bonzini wrote: >> > This is required for the following patch to work correctly. If a nested >> > page >> > fault happens during emulation, we must inject a vmexit, not a page fault. >> > Luckily we alr

Re: [PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-04 Thread Gleb Natapov
On Tue, Sep 02, 2014 at 05:13:49PM +0200, Paolo Bonzini wrote: > This is required for the following patch to work correctly. If a nested page > fault happens during emulation, we must inject a vmexit, not a page fault. > Luckily we already have the required machinery: it is enough to return > X86E

[PATCH 3/4] KVM: x86: inject nested page faults on emulated instructions

2014-09-02 Thread Paolo Bonzini
This is required for the following patch to work correctly. If a nested page fault happens during emulation, we must inject a vmexit, not a page fault. Luckily we already have the required machinery: it is enough to return X86EMUL_INTERCEPTED instead of X86EMUL_PROPAGATE_FAULT. Reported-by: Valen