From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com ([209.132.183.28]:41056 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753594AbdKJVmS (ORCPT ); Fri, 10 Nov 2017 16:42:18 -0500 Date: Fri, 10 Nov 2017 22:42:15 +0100 From: Radim =?utf-8?B?S3LEjW3DocWZ?= To: Paolo Bonzini Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, yfu@redhat.com, Eduardo Habkost , stable@vger.kernel.org Subject: Re: [PATCH] KVM: x86: inject exceptions produced by x86_decode_insn Message-ID: <20171110214214.GI2189@flask> References: <1510307378-97452-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1510307378-97452-1-git-send-email-pbonzini@redhat.com> Sender: stable-owner@vger.kernel.org List-ID: 2017-11-10 10:49+0100, Paolo Bonzini: > 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. > > Thanks to Eduardo Habkost for helping in the debugging of this issue. > > Reported-by: Yanan Fu > Cc: Eduardo Habkost > Cc: stable@vger.kernel.org > Signed-off-by: Paolo Bonzini > --- Applied, thanks.