Re: [PATCH v2] KVM: Fix simultaneous NMIs

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

 



On 09/20/2011 04:25 PM, Marcelo Tosatti wrote:
>
>  @@ -2827,6 +2828,7 @@ static int kvm_vcpu_ioctl_x86_set_mce(struct kvm_vcpu *vcpu,
>   static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
>   					struct kvm_vcpu_events *events)
>   {
>  +	process_nmi(vcpu);
>   	events->exception.injected =
>   		vcpu->arch.exception.pending&&
>   		!kvm_exception_is_soft(vcpu->arch.exception.nr);
>  @@ -2844,7 +2846,7 @@ static void kvm_vcpu_ioctl_x86_get_vcpu_events(struct kvm_vcpu *vcpu,
>   			KVM_X86_SHADOW_INT_MOV_SS | KVM_X86_SHADOW_INT_STI);
>
>   	events->nmi.injected = vcpu->arch.nmi_injected;
>  -	events->nmi.pending = vcpu->arch.nmi_pending;
>  +	events->nmi.pending = vcpu->arch.nmi_pending != 0;
>   	events->nmi.masked = kvm_x86_ops->get_nmi_mask(vcpu);
>   	events->nmi.pad = 0;

nmi_queued should also be saved and restored. Not sure if its necessary
though.

Should at least reset nmi_queued somewhere (set_vcpu_events?).

Did you miss the call to process_nmi()?

We do have a small issue. If we exit during NMI-blocked-by-STI and nmi_pending == 2, then we lose the second interrupt. Should rarely happen, since external interrupts never exit in that condition, but it's a wart.


>  @@ -2864,6 +2866,7 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu,
>   			| KVM_VCPUEVENT_VALID_SHADOW))
>   		return -EINVAL;
>
>  +	process_nmi(vcpu);

This should be after nmi fields are set, not before?


It's actually to clear queued NMIs in case we set nmi_pending (which should never happen unless the machine is completely quiet, since it's asynchronous to the vcpu; same as the IRR).

--
error compiling committee.c: too many arguments to function

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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