From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH] KVM: SVM: fix cr8 intercept window Date: Tue, 11 Mar 2014 22:05:14 -0300 Message-ID: <20140312010513.GA8131@amt.cnet> References: <1394561478-8815-1-git-send-email-rkrcmar@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org, pbonzini@redhat.com, gleb@kernel.org, stable@vger.kernel.org To: Radim =?utf-8?B?S3LEjW3DocWZ?= Return-path: Content-Disposition: inline In-Reply-To: <1394561478-8815-1-git-send-email-rkrcmar@redhat.com> Sender: stable-owner@vger.kernel.org List-Id: kvm.vger.kernel.org On Tue, Mar 11, 2014 at 07:11:18PM +0100, Radim Kr=C4=8Dm=C3=A1=C5=99 w= rote: > We always disable cr8 intercept in its handler, but only re-enable it > if handling KVM_REQ_EVENT, so there can be a window where we do not > intercept cr8 writes, which allows an interrupt to disrupt a higher > priority task. >=20 > Fix this by disabling intercepts in the same function that re-enables > them when needed. This fixes BSOD in Windows 2008. >=20 > Cc: > Signed-off-by: Radim Kr=C4=8Dm=C3=A1=C5=99 > --- > arch/x86/kvm/svm.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c > index 64d9bb9..f676c18 100644 > --- a/arch/x86/kvm/svm.c > +++ b/arch/x86/kvm/svm.c > @@ -3003,10 +3003,8 @@ static int cr8_write_interception(struct vcpu_= svm *svm) > u8 cr8_prev =3D kvm_get_cr8(&svm->vcpu); > /* instruction emulation calls kvm_set_cr8() */ > r =3D cr_interception(svm); > - if (irqchip_in_kernel(svm->vcpu.kvm)) { > - clr_cr_intercept(svm, INTERCEPT_CR8_WRITE); > + if (irqchip_in_kernel(svm->vcpu.kvm)) > return r; > - } > if (cr8_prev <=3D kvm_get_cr8(&svm->vcpu)) > return r; > kvm_run->exit_reason =3D KVM_EXIT_SET_TPR; > @@ -3568,6 +3566,8 @@ static void update_cr8_intercept(struct kvm_vcp= u *vcpu, int tpr, int irr) > if (is_guest_mode(vcpu) && (vcpu->arch.hflags & HF_VINTR_MASK)) > return; > =20 > + clr_cr_intercept(svm, INTERCEPT_CR8_WRITE); > + > if (irr =3D=3D -1) > return; Shouldnt IRR be injected if TPR < IRR ? (via KVM_REQ_EVENT). 1) IRR has interrupt 10. 2) TPR now 9 due to CR8 write. 3) 10 should be injected. Also not clearing the intercept can cause continuous CR8 writes to=20 exit until KVM_REQ_EVENT ?=20