From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gleb Natapov Subject: Re: [PATCH 9/9] [SVM] inject NMI after IRET from a previous NMI, not before. Date: Tue, 5 May 2009 12:32:44 +0300 Message-ID: <20090505093243.GO9795@redhat.com> References: <1241511275-2261-1-git-send-email-gleb@redhat.com> <1241511275-2261-9-git-send-email-gleb@redhat.com> <49FFFCA0.3070507@siemens.com> <20090505090314.GN9795@redhat.com> <4A0005F9.4050306@siemens.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: avi@redhat.com, kvm@vger.kernel.org To: Jan Kiszka Return-path: Received: from mx2.redhat.com ([66.187.237.31]:33377 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752613AbZEEJcs (ORCPT ); Tue, 5 May 2009 05:32:48 -0400 Content-Disposition: inline In-Reply-To: <4A0005F9.4050306@siemens.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, May 05, 2009 at 11:25:13AM +0200, Jan Kiszka wrote: > Gleb Natapov wrote: > > On Tue, May 05, 2009 at 10:45:20AM +0200, Jan Kiszka wrote: > >>> @@ -2331,8 +2358,16 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu) > >>> { > >>> struct vcpu_svm *svm = to_svm(vcpu); > >>> > >>> - if (svm->vmcb->control.int_state & SVM_INTERRUPT_SHADOW_MASK) > >>> - enable_irq_window(vcpu); > >>> + if ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_IRET_MASK)) > >>> + == HF_NMI_MASK) > >>> + return; /* IRET will cause a vm exit */ > >>> + > >>> + /* Something prevents NMI from been injected. Single step over > >>> + possible problem (IRET or exception injection or interrupt > >>> + shadow) */ > >>> + vcpu->arch.singlestep = true; > >>> + svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF); > >> Can you single-step like this out of an IRQ handler? I mean, IRET will > >> restore the flags from the stack, and those settings should be > >> overwritten. Or am I missing something? > >> > > It seems to be working :) Shouldn't CPU checks single step before > > executing IRET and thus using old flags value? It is interesting to > > check what rflag value is immediately after IRET. > > Hmm, guess I have to re-read some manuals. But regarding > rflags-after-iret, I think it should be cleared due to that restoring > from the stack. > Just re-tested this once more. DB is intercepted after IRET and TF/RF is cleared already. -- Gleb.