From: Paolo Bonzini <pbonzini@redhat.com>
To: Liran Alon <LIRAN.ALON@ORACLE.COM>,
rkrcmar@redhat.com, kvm@vger.kernel.org
Cc: jmattson@google.com, wanpeng.li@hotmail.com,
idan.brown@ORACLE.COM,
Krish Sadhukhan <krish.sadhukhan@ORACLE.COM>
Subject: Re: [PATCH] KVM: nVMX: Fix bug of injecting L2 exception into L1
Date: Mon, 20 Nov 2017 23:58:02 +0100 [thread overview]
Message-ID: <ad5acb87-7385-d03f-5e7e-478bd6db4040@redhat.com> (raw)
In-Reply-To: <5A135B29.9080805@ORACLE.COM>
On 20/11/2017 23:46, Liran Alon wrote:
>>>
>>
>> But this is buggy as well, because the #GP is lost, isn't it?
>
> I don't think so.
>
> Since commit 664f8e26b00c ("KVM: X86: Fix loss of exception which has
> not yet been injected"), there is a fundamental difference between a
> pending exception and an injected exception.
> A pending exception means that no side-effects of the exception have
> been applied yet. Including incrementing the RIP after the instruction
> which cause exception. In our case for example, handle_wrmsr() calls
> kvm_inject_gp() and returns without calling
> kvm_skip_emulated_instruction() which increments the RIP.
Ok, I was almost sure this was going to be the case if the #GP wasn't
lost (but couldn't convince myself 100%).
> Therefore, when we exit from L2 to L1 on vmx-preemption-timer, we can
> safely clear exception.pending because when L1 will resume L2, the
> exception will be raised again (the same WRMSR instruction will be run
> again which will raise #GP again).
> This is also why vmcs12_save_pending_event() only makes sure to save in
> VMCS12 idt-vectoring-info the "injected" events and not the "pending"
> events (interrupt.pending is misleading name and I would rename it in
> upcoming patch to interrupt.injected. See explanation below).
Indeed. And then kvm_event_needs_reinjection starts making sense.
> I can confirm this patch works because I have wrote a kvm-unit-test
> which reproduce this issue. And after the fix the #GP is not lost and
> raised to L2 directly correctly.
> (I haven't posted the unit-test yet because it is very dependent on
> correct vmx-preemption-timer timer config that varies between
> environments).
Can you post it anyway? Tests always help understanding the code.
Paolo
next prev parent reply other threads:[~2017-11-20 22:58 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-19 16:25 [PATCH] KVM: nVMX: Fix bug of injecting L2 exception into L1 Liran Alon
2017-11-20 21:47 ` Paolo Bonzini
2017-11-20 22:46 ` Liran Alon
2017-11-20 22:58 ` Paolo Bonzini [this message]
2018-01-09 10:08 ` Paolo Bonzini
-- strict thread matches above, loose matches on Subject: below --
2017-12-12 0:06 Liran Alon
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ad5acb87-7385-d03f-5e7e-478bd6db4040@redhat.com \
--to=pbonzini@redhat.com \
--cc=LIRAN.ALON@ORACLE.COM \
--cc=idan.brown@ORACLE.COM \
--cc=jmattson@google.com \
--cc=krish.sadhukhan@ORACLE.COM \
--cc=kvm@vger.kernel.org \
--cc=rkrcmar@redhat.com \
--cc=wanpeng.li@hotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox