Skip to content
  • Avi Kivity's avatar
    KVM: Fix race between nmi injection and enabling nmi window · f8636849
    Avi Kivity authored
    
    
    The interrupt injection logic looks something like
    
      if an nmi is pending, and nmi injection allowed
        inject nmi
      if an nmi is pending
        request exit on nmi window
    
    the problem is that "nmi is pending" can be set asynchronously by
    the PIT; if it happens to fire between the two if statements, we
    will request an nmi window even though nmi injection is allowed.  On
    SVM, this has disasterous results, since it causes eflags.TF to be
    set in random guest code.
    
    The fix is simple; make nmi_pending synchronous using the standard
    vcpu->requests mechanism; this ensures the code above is completely
    synchronous wrt nmi_pending.
    
    Signed-off-by: default avatarAvi Kivity <avi@redhat.com>
    f8636849