From: Gleb Natapov Subject: [PATCH 8/9] Replace pending exception by PF if it happens serially. Date: Tue, 5 May 2009 11:14:34 +0300 Message-ID: <1241511275-2261-8-git-send-email-gleb@redhat.com> References: <1241511275-2261-1-git-send-email-gleb@redhat.com> Cc: kvm@vger.kernel.org, Gleb Natapov To: avi@redhat.com Return-path: Received: from mx2.redhat.com ([66.187.237.31]:39541 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757039AbZEEIOj (ORCPT ); Tue, 5 May 2009 04:14:39 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n458EeBI029588 for ; Tue, 5 May 2009 04:14:40 -0400 In-Reply-To: <1241511275-2261-1-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: replace previous exception with a new one in a hope that instruction re-execution will regenerate lost exception. Signed-off-by: Gleb Natapov --- arch/x86/kvm/x86.c | 19 ++++++++++++------- 1 files changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index 4ba00ab..a869b89 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -177,16 +177,21 @@ void kvm_inject_page_fault(struct kvm_vcpu *vcpu, unsigned long addr, ++vcpu->stat.pf_guest; if (vcpu->arch.exception.pending) { - if (vcpu->arch.exception.nr == PF_VECTOR) { - printk(KERN_DEBUG "kvm: inject_page_fault:" - " double fault 0x%lx\n", addr); - vcpu->arch.exception.nr = DF_VECTOR; - vcpu->arch.exception.error_code = 0; - } else if (vcpu->arch.exception.nr == DF_VECTOR) { + switch(vcpu->arch.exception.nr) { + case DF_VECTOR: /* triple fault -> shutdown */ set_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests); + case PF_VECTOR: + vcpu->arch.exception.nr = DF_VECTOR; + vcpu->arch.exception.error_code = 0; + return; + default: + /* replace previous exception with a new one in a hope + that instruction re-execution will regenerate lost + exception */ + vcpu->arch.exception.pending = false; + break; } - return; } vcpu->arch.cr2 = addr; kvm_queue_exception_e(vcpu, PF_VECTOR, error_code); -- 1.6.2.1