From: Christoph Egger Date: Fri, 31 Aug 2012 20:15:31 +0000 (+0100) Subject: nestedsvm: fix interrupt handling X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~7999 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5fdfc1eedd92bc5358ee3b6e63efb0d60fb835c4;p=xen.git nestedsvm: fix interrupt handling Give the l2 guest a chance to finish the delivery of the last injected interrupt or exception before we emulate a VMEXIT. For example after a NPF handled by the host there can be an interrupt for the l1 guest. Signed-off-by: Christoph Egger Committed-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c index 0b6ff88672..119589696c 100644 --- a/xen/arch/x86/hvm/svm/nestedsvm.c +++ b/xen/arch/x86/hvm/svm/nestedsvm.c @@ -1164,6 +1164,8 @@ enum hvm_intblk nsvm_intr_blocked(struct vcpu *v) return hvm_intblk_svm_gif; if ( nestedhvm_vcpu_in_guestmode(v) ) { + struct vmcb_struct *n2vmcb = nv->nv_n2vmcx; + if ( svm->ns_hostflags.fields.vintrmask ) if ( !svm->ns_hostflags.fields.rflagsif ) return hvm_intblk_rflags_ie; @@ -1176,6 +1178,14 @@ enum hvm_intblk nsvm_intr_blocked(struct vcpu *v) */ if ( v->arch.hvm_vcpu.hvm_io.io_state != HVMIO_none ) return hvm_intblk_shadow; + + if ( !nv->nv_vmexit_pending && n2vmcb->exitintinfo.bytes != 0 ) { + /* Give the l2 guest a chance to finish the delivery of + * the last injected interrupt or exception before we + * emulate a VMEXIT (e.g. VMEXIT(INTR) ). + */ + return hvm_intblk_shadow; + } } if ( nv->nv_vmexit_pending ) {