diff mbox

Replace pending exception by PF if it happens serially.

Message ID 20090611082611.GA18996@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gleb Natapov June 11, 2009, 8:26 a.m. UTC
Replace previous exception with a new one in a hope that instruction
re-execution will regenerate lost exception.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
--
			Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Avi Kivity June 14, 2009, 11:01 a.m. UTC | #1
Gleb Natapov wrote:
> Replace previous exception with a new one in a hope that instruction
> re-execution will regenerate lost exception.
>
>   

Applied, thanks.

> +		switch(vcpu->arch.exception.nr) {
> +		case DF_VECTOR:
>  			/* triple fault -> shutdown */
>  			set_bit(KVM_REQ_TRIPLE_FAULT, &vcpu->requests);
>   

Added a 'return' here.  It will work without, but will raise endless 
questions from people who look at the code.

> +		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;
>  	}
diff mbox

Patch

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 272e2e8..3150d06 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -181,16 +181,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);