From patchwork Wed Feb 17 13:49:16 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 79940 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o1HDpfUj001342 for ; Wed, 17 Feb 2010 13:51:43 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934258Ab0BQNt2 (ORCPT ); Wed, 17 Feb 2010 08:49:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58641 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934294Ab0BQNt0 (ORCPT ); Wed, 17 Feb 2010 08:49:26 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o1HDnIZu025491 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 17 Feb 2010 08:49:19 -0500 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o1HDnHOl030206; Wed, 17 Feb 2010 08:49:18 -0500 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id DA09118D450; Wed, 17 Feb 2010 15:49:16 +0200 (IST) Date: Wed, 17 Feb 2010 15:49:16 +0200 From: Gleb Natapov To: Jan Kiszka Cc: Avi Kivity , Marcelo Tosatti , kvm Subject: Re: [PATCH 2/2] KVM: SVM: Make stepping out of NMI handlers more robust Message-ID: <20100217134916.GA14767@redhat.com> References: <8cb458e40c9d594f27975b10bb24ecb9a90d8102.1266257833.git.jan.kiszka@siemens.com> <20100216080436.GX2995@redhat.com> <4B7A6210.5060606@siemens.com> <20100216093416.GA2995@redhat.com> <4B7A692B.8050207@siemens.com> <20100216094954.GB2995@redhat.com> <4B7A6E03.2020606@siemens.com> <20100216100858.GF2995@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100216100858.GF2995@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Wed, 17 Feb 2010 13:51:43 +0000 (UTC) diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 52f78dd..b85b200 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -109,6 +109,7 @@ struct vcpu_svm { struct nested_state nested; bool nmi_singlestep; + bool nmi_singlestep_tf; }; /* enable NPT for AMD64 and X86 with PAE */ @@ -1221,9 +1222,14 @@ static int db_interception(struct vcpu_svm *svm) if (svm->nmi_singlestep) { svm->nmi_singlestep = false; - if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP)) + if (!(svm->vcpu.guest_debug & KVM_GUESTDBG_SINGLESTEP)) { svm->vmcb->save.rflags &= ~(X86_EFLAGS_TF | X86_EFLAGS_RF); + if (svm->nmi_singlestep_tf) { + svm->vmcb->save.rflags |= X86_EFLAGS_TF; + kvm_queue_exception(&svm->vcpu, DB_VECTOR); + } + } update_db_intercept(&svm->vcpu); } @@ -2586,6 +2592,7 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu) possible problem (IRET or exception injection or interrupt shadow) */ svm->nmi_singlestep = true; + svm->nmi_singlestep_tf = (svm->vmcb->save.rflags | X86_EFLAGS_TF); svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF); update_db_intercept(vcpu); }