From: Sean Christopherson <sean.j.christopherson@intel.com>
To: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Denis Lunev" <den@virtuozzo.com>,
"Roman Kagan" <rkagan@virtuozzo.com>,
"Denis Plotnikov" <dplotnikov@virtuozzo.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Radim Krčmář" <rkrcmar@redhat.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Wanpeng Li" <wanpengli@tencent.com>,
"Jim Mattson" <jmattson@google.com>,
"Joerg Roedel" <joro@8bytes.org>,
"Thomas Gleixner" <tglx@linutronix.de>,
"Ingo Molnar" <mingo@redhat.com>,
"Borislav Petkov" <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
"x86@kernel.org" <x86@kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"Yi Wang" <wang.yi59@zte.com.cn>,
"Peng Hao" <peng.hao2@zte.com.cn>
Subject: Re: [PATCH 3/3] KVM: x86: always stop emulation on page fault
Date: Wed, 28 Aug 2019 07:23:40 -0700 [thread overview]
Message-ID: <20190828142340.GA21651@linux.intel.com> (raw)
In-Reply-To: <20190828131948.cb67f97cab502b9f5f63b1b8@virtuozzo.com>
On Wed, Aug 28, 2019 at 10:19:51AM +0000, Jan Dakinevich wrote:
> On Tue, 27 Aug 2019 07:50:30 -0700
> Sean Christopherson <sean.j.christopherson@intel.com> wrote:
> > Yikes, this patch and the previous have quite the sordid history.
> >
> >
> > The non-void return from inject_emulated_exception() was added by commit
> >
> > ef54bcfeea6c ("KVM: x86: skip writeback on injection of nested exception")
> >
> > for the purpose of skipping writeback. At the time, the above blob in the
> > decode flow didn't exist.
> >
> >
> > Decode exception handling was added by commit
> >
> > 6ea6e84309ca ("KVM: x86: inject exceptions produced by x86_decode_insn")
> >
> > but it was dead code even then. The patch discussion[1] even point out that
> > it was dead code, i.e. the change probably should have been reverted.
> >
> >
> > Peng Hao and Yi Wang later ran into what appears to be the same bug you're
> > hitting[2][3], and even had patches temporarily queued[4][5], but the
> > patches never made it to mainline as they broke kvm-unit-tests. Fun side
> > note, Radim even pointed out[4] the bug fixed by patch 1/3.
> >
> > So, the patches look correct, but there's the open question of why the
> > hypercall test was failing for Paolo.
>
> Sorry, I'm little confused. Could you please, point me which test or tests
> were broken? I've just run kvm-unit-test and I see same results with and
> without my changes.
>
> > I've tried to reproduce the #DF to
> > no avail.
Aha! The #DF occurs if patch 2/3, but not patch 3/3, is applied, and the
VMware backdoor is enabled. The backdoor is off by default, which is why
only Paolo was seeing the #DF.
To handle the VMware backdoor, KVM intercepts #GP faults, which includes
the non-canonical #GP from the hypercall unit test. With only patch 2/3
applied, x86_emulate_instruction() injects a #GP for the non-canonical RIP
but returns EMULATE_FAIL instead of EMULATE_DONE. EMULATE_FAIL causes
handle_exception_nmi() (or gp_interception() for SVM) to re-inject the
original #GP because it thinks emulation failed due to a non-VMware opcode.
Applying patch 3/3 resolves the issue as x86_emulate_instruction() returns
EMULATE_DONE after injecting the #GP.
TL;DR:
Swap the order of patches and everything should be hunky dory. Please
rebase to the latest kvm/queue, which has an equivalent to patch 1/3.
next prev parent reply other threads:[~2019-08-28 14:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-27 13:07 [PATCH 0/3] fix emulation error on Windows bootup Jan Dakinevich
2019-08-27 13:07 ` [PATCH 1/3] KVM: x86: fix wrong return code Jan Dakinevich
2019-08-27 13:42 ` Sean Christopherson
2019-08-27 13:07 ` [PATCH 2/3] KVM: x86: set ctxt->have_exception in x86_decode_insn() Jan Dakinevich
2019-08-27 14:53 ` Sean Christopherson
2019-08-28 10:19 ` Jan Dakinevich
2019-08-27 13:07 ` [PATCH 3/3] KVM: x86: always stop emulation on page fault Jan Dakinevich
2019-08-27 14:50 ` Sean Christopherson
2019-08-27 14:55 ` Sean Christopherson
2019-08-28 10:19 ` Jan Dakinevich
2019-08-28 14:23 ` Sean Christopherson [this message]
2019-09-11 15:51 ` [PATCH 0/3] fix emulation error on Windows bootup Paolo Bonzini
2019-09-11 19:53 ` Sean Christopherson
2019-09-13 9:51 ` Paolo Bonzini
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=20190828142340.GA21651@linux.intel.com \
--to=sean.j.christopherson@intel.com \
--cc=bp@alien8.de \
--cc=den@virtuozzo.com \
--cc=dplotnikov@virtuozzo.com \
--cc=hpa@zytor.com \
--cc=jan.dakinevich@virtuozzo.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peng.hao2@zte.com.cn \
--cc=rkagan@virtuozzo.com \
--cc=rkrcmar@redhat.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wang.yi59@zte.com.cn \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).