From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: [PATCH 4/4] KVM: SVM: don't NMI singlestep over event injection Date: Thu, 15 Jun 2017 14:05:20 +0200 Message-ID: References: <20170615112032.15812-1-lprosek@redhat.com> <20170615112032.15812-5-lprosek@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: rkrcmar@redhat.com To: Ladi Prosek , kvm@vger.kernel.org Return-path: Received: from mail-lf0-f68.google.com ([209.85.215.68]:35386 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752141AbdFOMFX (ORCPT ); Thu, 15 Jun 2017 08:05:23 -0400 Received: by mail-lf0-f68.google.com with SMTP id v20so1207418lfa.2 for ; Thu, 15 Jun 2017 05:05:23 -0700 (PDT) In-Reply-To: <20170615112032.15812-5-lprosek@redhat.com> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 15/06/2017 13:20, Ladi Prosek wrote: > @@ -4823,6 +4826,22 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu) > if (unlikely(svm->nested.exit_required)) > return; > > + /* > + * Disable singlestep if we're injecting an interrupt/exception. > + * We don't want our modified rflags to be pushed on the stack where > + * we might not be able to easily reset them if we disabled NMI > + * singlestep later. > + */ > + if (svm->nmi_singlestep && svm->vmcb->control.event_inj) { > + /* > + * We enabled NMI singlestepping because the NMI window was > + * closed. It's unlikely that injecting another event will make > + * it any better. Try again later, on next iret at the latest. > + */ > + disable_nmi_singlestep(svm); > + set_intercept(svm, INTERCEPT_IRET); > + } > + > pre_svm_run(svm); > > sync_lapic_to_cr8(vcpu); > I wonder if we could just force an immediate vmexit instead of asking for one at the next IRET. Based on the AMD manual, event injection happens before external interrupts cause a vmexit. Interrupts here are disabled (through either IF or GIF) until VMRUN, so just a smp_send_reschedule(vcpu->cpu); should be enough after disable_nmi_singlestep. Or if you put the code in pre_svm_run you have a cpu local variable. Paolo