On 15/06/2017 14:38, Ladi Prosek wrote: > On Thu, Jun 15, 2017 at 2:05 PM, Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote: >> >> >> 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. > > Yup, this seems to work. Thanks! Make sure to add a comment. :) Paolo