1. 23 Mar, 2023 3 commits
    • Santosh Shukla's avatar
      KVM: x86: Add support for SVM's Virtual NMI · fa4c027a
      Santosh Shukla authored
      Add support for SVM's Virtual NMIs implementation, which adds proper
      tracking of virtual NMI blocking, and an intr_ctrl flag that software can
      set to mark a virtual NMI as pending.  Pending virtual NMIs are serviced
      by hardware if/when virtual NMIs become unblocked, i.e. act more or less
      like real NMIs.
      
      Introduce two new kvm_x86_ops callbacks so to support SVM's vNMI, as KVM
      needs to treat a pending vNMI as partially injected.  Specifically, if
      two NMIs (for L1) arrive concurrently in KVM's software model, KVM's ABI
      is to inject one and pend the other.  Without vNMI, KVM manually tracks
      the pending NMI and uses NMI windows to detect when the NMI should be
      injected.
      
      With vNMI, the pending NMI is simply stuffed into the VMCB and handed
      off to hardware.  This means that KVM needs to be able to set a vNMI
      pending on-demand, and also query if a vNMI is pending, e.g. to honor the
      "at most one NMI pending" rule and to preserve all NMIs across save and
      restore.
      
      Warn if KVM attempts to open an NMI window when vNMI is fully enabled,
      as the above logic should prevent KVM from ever getting to
      kvm_check_and_inject_events() with two NMIs pending _in software_, and
      the "at most one NMI pending" logic should prevent having an NMI pending
      in hardware and an NMI pending in software if NMIs are also blocked, i.e.
      if KVM can't immediately inject the second NMI.
      Signed-off-by: default avatarSantosh Shukla <Santosh.Shukla@amd.com>
      Co-developed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Link: https://lore.kernel.org/r/20230227084016.3368-11-santosh.shukla@amd.com
      [sean: rewrite shortlog and changelog, massage code comments]
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      fa4c027a
    • Sean Christopherson's avatar
      KVM: x86: Route pending NMIs from userspace through process_nmi() · bdedff26
      Sean Christopherson authored
      Use the asynchronous NMI queue to handle pending NMIs coming in from
      userspace during KVM_SET_VCPU_EVENTS so that all of KVM's logic for
      handling multiple NMIs goes through process_nmi().  This will simplify
      supporting SVM's upcoming "virtual NMI" functionality, which will need
      changes KVM manages pending NMIs.
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      bdedff26
    • Santosh Shukla's avatar
      KVM: SVM: Add definitions for new bits in VMCB::int_ctrl related to vNMI · 1c4522ab
      Santosh Shukla authored
      Add defines for three new bits in VMVC::int_ctrl that are part of SVM's
      Virtual NMI (vNMI) support:
      
        V_NMI_PENDING_MASK(11)  - Virtual NMI is pending
        V_NMI_BLOCKING_MASK(12) - Virtual NMI is masked
        V_NMI_ENABLE_MASK(26)   - Enable NMI virtualization
      
      To "inject" an NMI, the hypervisor (KVM) sets V_NMI_PENDING.  When the
      CPU services the pending vNMI, hardware clears V_NMI_PENDING and sets
      V_NMI_BLOCKING, e.g. to indicate that the vCPU is handling an NMI.
      Hardware clears V_NMI_BLOCKING upon successful execution of IRET, or if a
      VM-Exit occurs while delivering the virtual NMI.
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Signed-off-by: default avatarSantosh Shukla <santosh.shukla@amd.com>
      Link: https://lore.kernel.org/r/20230227084016.3368-10-santosh.shukla@amd.com
      [sean: massage changelog]
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      1c4522ab
  2. 22 Mar, 2023 8 commits
  3. 16 Mar, 2023 9 commits
  4. 14 Mar, 2023 20 commits