From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Joerg Roedel" Subject: Re: [PATCH] KVM: detect if VCPU triple faults Date: Tue, 26 Feb 2008 16:37:30 +0100 Message-ID: <20080226153730.GE6504@amd.com> References: <1204025894-19064-1-git-send-email-joerg.roedel@amd.com> <47C40DE7.9040907@qumranet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm-devel@lists.sourceforge.net To: "Avi Kivity" Return-path: In-Reply-To: <47C40DE7.9040907@qumranet.com> Content-Disposition: inline List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: kvm-devel-bounces@lists.sourceforge.net Errors-To: kvm-devel-bounces@lists.sourceforge.net List-Id: kvm.vger.kernel.org On Tue, Feb 26, 2008 at 03:02:31PM +0200, Avi Kivity wrote: > Joerg Roedel wrote: > >In the current inject_page_fault path KVM only checks if there is another PF > >pending and injects a DF then. But it has to check for a pendig DF too to > >detect a shutdown condition in the VCPU. If this is not detected the VCPU goes > >to a PF -> DF -> PF loop when it should triple fault. This patch detects this > >condition and handles it with an KVM_SHUTDOWN exit to userspace. As a side > >effect it fixes the following warning when trying to reboot a SMP guest on SVM: > >diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h > >index 1af0ceb..01708b7 100644 > >--- a/arch/x86/kvm/paging_tmpl.h > >+++ b/arch/x86/kvm/paging_tmpl.h > >@@ -366,8 +366,9 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr, > > * - normal guest page fault due to the guest pte marked not present, not > > * writable, or not executable > > * > >- * Returns: 1 if we need to emulate the instruction, 0 otherwise, or > >- * a negative value on error. > >+ * Returns: 2 if the vcpu triple faulted > >+ * 1 if we need to emulate the instruction > >+ * 0 otherwise, or a negative value on error. > > */ > > > > This is a little icky. What about setting vcpu->requests bit KVM_REQ_TRIPLE_FAULT and checking it on the next entry? > > The check is zero cost since we check vcpu->requests anyway. We can use this for other situations as well (like setting cr3 to mmio space, bad paravirt mmio operation, etc.) Ah, right. This will be much simpler and cleaner. I will send an updated patch. Joerg -- | AMD Saxony Limited Liability Company & Co. KG Operating | Wilschdorfer Landstr. 101, 01109 Dresden, Germany System | Register Court Dresden: HRA 4896 Research | General Partner authorized to represent: Center | AMD Saxony LLC (Wilmington, Delaware, US) | General Manager of AMD Saxony LLC: Dr. Hans-R. Deppe, Thomas McCoy ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/