From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 0/4] KVM: SVM: improve NMI window singlestep Date: Thu, 15 Jun 2017 14:03:03 +0200 Message-ID: <9586f0ae-d46e-97d8-227b-de9914581a06@redhat.com> References: <20170615112032.15812-1-lprosek@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit To: Ladi Prosek , KVM list Return-path: Received: from mail-qt0-f194.google.com ([209.85.216.194]:36539 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751902AbdFOMDG (ORCPT ); Thu, 15 Jun 2017 08:03:06 -0400 Received: by mail-qt0-f194.google.com with SMTP id s33so2612591qtg.3 for ; Thu, 15 Jun 2017 05:03:06 -0700 (PDT) In-Reply-To: <20170615112032.15812-1-lprosek@redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 15/06/2017 13:20, Ladi Prosek wrote: > NMI window singlestep kind of works with these patches because it's meant > only for short sequences (I believe that the original intention was to > step over an IRET but I doubt it's that simple anymore) Yes, it was meant to step over an IRET or an interrupt shadow. One extra case that may cause NMI singlestep these days is GIF=0, but that is also solved easily: diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index d1efe2c62b3f..15a2f7f8e539 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c @@ -4622,6 +4622,9 @@ static void enable_nmi_window(struct kvm_vcpu *vcpu) if ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_IRET_MASK)) == HF_NMI_MASK) return; /* IRET will cause a vm exit */ + if ((svm->vcpu.arch.hflags & (HF_NMI_MASK | HF_GIF_MASK)) + == HF_NMI_MASK) + return; /* STGI will cause a vm exit */ so you could include this change in your series. Paolo > so we can get > away with half-butting it. In particular, it's unlikely that the guest > would set the TRAP flag while the NMI window is closed. Properly handling > KVM_GUESTDBG_SINGLESTEP would likely involve intercepting PUSHF & POPF, > clearing the TRAP flag from the stack on interrupt entry, and possibly more.