linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Wanpeng Li <kernellwp@gmail.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	kvm <kvm@vger.kernel.org>,
	yfu@redhat.com, Eduardo Habkost <ehabkost@redhat.com>
Subject: Re: [PATCH] KVM: x86: inject exceptions produced by x86_decode_insn
Date: Thu, 16 Nov 2017 18:12:13 +0100	[thread overview]
Message-ID: <20171116171212.GA20438@flask> (raw)
In-Reply-To: <4ff4d2f3-439b-2a8f-ef89-b2a1984e809d@redhat.com>

2017-11-13 09:32+0100, Paolo Bonzini:
> On 13/11/2017 08:15, Wanpeng Li wrote:
> > 2017-11-10 17:49 GMT+08:00 Paolo Bonzini <pbonzini@redhat.com>:
> >> Sometimes, a processor might execute an instruction while another
> >> processor is updating the page tables for that instruction's code page,
> >> but before the TLB shootdown completes.  The interesting case happens
> >> if the page is in the TLB.
> >>
> >> In general, the processor will succeed in executing the instruction and
> >> nothing bad happens.  However, what if the instruction is an MMIO access?
> >> If *that* happens, KVM invokes the emulator, and the emulator gets the
> >> updated page tables.  If the update side had marked the code page as non
> >> present, the page table walk then will fail and so will x86_decode_insn.
> >>
> >> Unfortunately, even though kvm_fetch_guest_virt is correctly returning
> >> X86EMUL_PROPAGATE_FAULT, x86_decode_insn's caller treats the failure as
> >> a fatal error if the instruction cannot simply be reexecuted (as is the
> >> case for MMIO).  And this in fact happened sometimes when rebooting
> >> Windows 2012r2 guests.  Just checking ctxt->have_exception and injecting
> >> the exception if true is enough to fix the case.
> > 
> > I found the only place which can set ctxt->have_exception is in the
> > function x86_emulate_insn(), and x86_decode_insn() will not set
> > ctxt->have_exception even if kvm_fetch_guest_virt() returns
> > X86_EMUL_PROPAGATE_FAULT.
> 
> Hmm, you're right.  Looks like Yanan has been (un)lucky when trying out
> this patch! :(

I have dropped this patch in the meantime.

  parent reply	other threads:[~2017-11-16 17:12 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-10  9:49 [PATCH] KVM: x86: inject exceptions produced by x86_decode_insn Paolo Bonzini
2017-11-10 21:42 ` Radim Krčmář
2017-11-13  7:15 ` Wanpeng Li
2017-11-13  8:32   ` Paolo Bonzini
2017-11-13 10:09     ` Yanan Fu
2017-11-16 17:12     ` Radim Krčmář [this message]
2017-11-29 11:44     ` Eduardo Habkost
2017-11-29 11:44       ` Paolo Bonzini
2017-11-29 18:42         ` Eduardo Habkost
2017-11-29 22:47           ` Paolo Bonzini
2017-11-29 23:10             ` Eduardo Habkost
2017-11-30 16:04               ` Eduardo Habkost
2017-11-30  9:20           ` Wanpeng Li
2017-11-30 16:00             ` Paolo Bonzini
2017-11-30 20:33           ` Eduardo Habkost

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=20171116171212.GA20438@flask \
    --to=rkrcmar@redhat.com \
    --cc=ehabkost@redhat.com \
    --cc=kernellwp@gmail.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=yfu@redhat.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;
as well as URLs for NNTP newsgroup(s).