Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Jan 19, 2022
    • Sean Christopherson's avatar
      KVM: Move x86 VMX's posted interrupt list_head to vcpu_vmx · 12a8eee5
      Sean Christopherson authored
      
      Move the seemingly generic block_vcpu_list from kvm_vcpu to vcpu_vmx, and
      rename the list and all associated variables to clarify that it tracks
      the set of vCPU that need to be poked on a posted interrupt to the wakeup
      vector.  The list is not used to track _all_ vCPUs that are blocking, and
      the term "blocked" can be misleading as it may refer to a blocking
      condition in the host or the guest, where as the PI wakeup case is
      specifically for the vCPUs that are actively blocking from within the
      guest.
      
      No functional change intended.
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20211208015236.1616697-7-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      12a8eee5
    • Sean Christopherson's avatar
      KVM: Drop unused kvm_vcpu.pre_pcpu field · e6eec09b
      Sean Christopherson authored
      
      Remove kvm_vcpu.pre_pcpu as it no longer has any users.  No functional
      change intended.
      
      Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
      Reviewed-by: default avatarMaxim Levitsky <mlevitsk@redhat.com>
      Message-Id: <20211208015236.1616697-6-seanjc@google.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e6eec09b
    • Christian Borntraeger's avatar
      KVM: avoid warning on s390 in mark_page_dirty · e09fccb5
      Christian Borntraeger authored
      
      Avoid warnings on s390 like
      [ 1801.980931] CPU: 12 PID: 117600 Comm: kworker/12:0 Tainted: G            E     5.17.0-20220113.rc0.git0.32ce2abb03cf.300.fc35.s390x+next #1
      [ 1801.980938] Workqueue: events irqfd_inject [kvm]
      [...]
      [ 1801.981057] Call Trace:
      [ 1801.981060]  [<000003ff805f0f5c>] mark_page_dirty_in_slot+0xa4/0xb0 [kvm]
      [ 1801.981083]  [<000003ff8060e9fe>] adapter_indicators_set+0xde/0x268 [kvm]
      [ 1801.981104]  [<000003ff80613c24>] set_adapter_int+0x64/0xd8 [kvm]
      [ 1801.981124]  [<000003ff805fb9aa>] kvm_set_irq+0xc2/0x130 [kvm]
      [ 1801.981144]  [<000003ff805f8d86>] irqfd_inject+0x76/0xa0 [kvm]
      [ 1801.981164]  [<0000000175e56906>] process_one_work+0x1fe/0x470
      [ 1801.981173]  [<0000000175e570a4>] worker_thread+0x64/0x498
      [ 1801.981176]  [<0000000175e5ef2c>] kthread+0x10c/0x110
      [ 1801.981180]  [<0000000175de73c8>] __ret_from_fork+0x40/0x58
      [ 1801.981185]  [<000000017698440a>] ret_from_fork+0xa/0x40
      
      when writing to a guest from an irqfd worker as long as we do not have
      the dirty ring.
      
      Signed-off-by: default avatarChristian Borntraeger <borntraeger@linux.ibm.com>
      Reluctantly-acked-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Message-Id: <20220113122924.740496-1-borntraeger@linux.ibm.com>
      Fixes: 2efd61a6
      
       ("KVM: Warn if mark_page_dirty() is called without an active vCPU")
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      e09fccb5
  2. Jan 07, 2022
    • David Woodhouse's avatar
      KVM: Reinstate gfn_to_pfn_cache with invalidation support · 982ed0de
      David Woodhouse authored
      
      This can be used in two modes. There is an atomic mode where the cached
      mapping is accessed while holding the rwlock, and a mode where the
      physical address is used by a vCPU in guest mode.
      
      For the latter case, an invalidation will wake the vCPU with the new
      KVM_REQ_GPC_INVALIDATE, and the architecture will need to refresh any
      caches it still needs to access before entering guest mode again.
      
      Only one vCPU can be targeted by the wake requests; it's simple enough
      to make it wake all vCPUs or even a mask but I don't see a use case for
      that additional complexity right now.
      
      Invalidation happens from the invalidate_range_start MMU notifier, which
      needs to be able to sleep in order to wake the vCPU and wait for it.
      
      This means that revalidation potentially needs to "wait" for the MMU
      operation to complete and the invalidate_range_end notifier to be
      invoked. Like the vCPU when it takes a page fault in that period, we
      just spin — fixing that in a future patch by implementing an actual
      *wait* may be another part of shaving this particularly hirsute yak.
      
      As noted in the comments in the function itself, the only case where
      the invalidate_range_start notifier is expected to be called *without*
      being able to sleep is when the OOM reaper is killing the process. In
      that case, we expect the vCPU threads already to have exited, and thus
      there will be nothing to wake, and no reason to wait. So we clear the
      KVM_REQUEST_WAIT bit and send the request anyway, then complain loudly
      if there actually *was* anything to wake up.
      
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Message-Id: <20211210163625.2886-3-dwmw2@infradead.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      982ed0de
    • David Woodhouse's avatar
      KVM: Warn if mark_page_dirty() is called without an active vCPU · 2efd61a6
      David Woodhouse authored
      The various kvm_write_guest() and mark_page_dirty() functions must only
      ever be called in the context of an active vCPU, because if dirty ring
      tracking is enabled it may simply oops when kvm_get_running_vcpu()
      returns NULL for the vcpu and then kvm_dirty_ring_get() dereferences it.
      
      This oops was reported by "butt3rflyh4ck" <butterflyhuangxx@gmail.com> in
      https://lore.kernel.org/kvm/CAFcO6XOmoS7EacN_n6v4Txk7xL7iqRa2gABg3F7E3Naf5uG94g@mail.gmail.com/
      
      
      
      That actual bug will be fixed under separate cover but this warning
      should help to prevent new ones from being added.
      
      Signed-off-by: default avatarDavid Woodhouse <dwmw@amazon.co.uk>
      Message-Id: <20211210163625.2886-2-dwmw2@infradead.org>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      2efd61a6
  3. Dec 09, 2021
  4. Dec 08, 2021