Re: [PATCH 4/4] KVM: SVM: don't NMI singlestep over event injection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




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



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux