From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jan Kiszka Subject: Re: [PATCH 9/9] [SVM] inject NMI after IRET from a previous NMI, not before. Date: Tue, 05 May 2009 11:25:13 +0200 Message-ID: <4A0005F9.4050306@siemens.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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: avi@redhat.com, kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from lizzard.sbs.de ([194.138.37.39]:20798 "EHLO lizzard.sbs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751965AbZEEJZe (ORCPT ); Tue, 5 May 2009 05:25:34 -0400 In-Reply-To: <20090505090314.GN9795@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: 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. Jan -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux