1. 08 1月, 2021 4 次提交
    • B
      KVM: x86/mmu: Ensure TDP MMU roots are freed after yield · a889ea54
      Ben Gardon 提交于
      Many TDP MMU functions which need to perform some action on all TDP MMU
      roots hold a reference on that root so that they can safely drop the MMU
      lock in order to yield to other threads. However, when releasing the
      reference on the root, there is a bug: the root will not be freed even
      if its reference count (root_count) is reduced to 0.
      
      To simplify acquiring and releasing references on TDP MMU root pages, and
      to ensure that these roots are properly freed, move the get/put operations
      into another TDP MMU root iterator macro.
      
      Moving the get/put operations into an iterator macro also helps
      simplify control flow when a root does need to be freed. Note that using
      the list_for_each_entry_safe macro would not have been appropriate in
      this situation because it could keep a pointer to the next root across
      an MMU lock release + reacquire, during which time that root could be
      freed.
      Reported-by: NMaciej S. Szmigiero <maciej.szmigiero@oracle.com>
      Suggested-by: NPaolo Bonzini <pbonzini@redhat.com>
      Fixes: faaf05b0 ("kvm: x86/mmu: Support zapping SPTEs in the TDP MMU")
      Fixes: 063afacd ("kvm: x86/mmu: Support invalidate range MMU notifier for TDP MMU")
      Fixes: a6a0b05d ("kvm: x86/mmu: Support dirty logging for the TDP MMU")
      Fixes: 14881998 ("kvm: x86/mmu: Support disabling dirty logging for the tdp MMU")
      Signed-off-by: NBen Gardon <bgardon@google.com>
      Message-Id: <20210107001935.3732070-1-bgardon@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      a889ea54
    • S
      KVM: x86/mmu: Use raw level to index into MMIO walks' sptes array · dde81f94
      Sean Christopherson 提交于
      Bump the size of the sptes array by one and use the raw level of the
      SPTE to index into the sptes array.  Using the SPTE level directly
      improves readability by eliminating the need to reason out why the level
      is being adjusted when indexing the array.  The array is on the stack
      and is not explicitly initialized; bumping its size is nothing more than
      a superficial adjustment to the stack frame.
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20201218003139.2167891-4-seanjc@google.com>
      Reviewed-by: NVitaly Kuznetsov <vkuznets@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      dde81f94
    • S
      KVM: x86/mmu: Get root level from walkers when retrieving MMIO SPTE · 39b4d43e
      Sean Christopherson 提交于
      Get the so called "root" level from the low level shadow page table
      walkers instead of manually attempting to calculate it higher up the
      stack, e.g. in get_mmio_spte().  When KVM is using PAE shadow paging,
      the starting level of the walk, from the callers perspective, is not
      the CR3 root but rather the PDPTR "root".  Checking for reserved bits
      from the CR3 root causes get_mmio_spte() to consume uninitialized stack
      data due to indexing into sptes[] for a level that was not filled by
      get_walk().  This can result in false positives and/or negatives
      depending on what garbage happens to be on the stack.
      
      Opportunistically nuke a few extra newlines.
      
      Fixes: 95fb5b02 ("kvm: x86/mmu: Support MMIO in the TDP MMU")
      Reported-by: NRichard Herbert <rherbert@sympatico.ca>
      Cc: Ben Gardon <bgardon@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20201218003139.2167891-3-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      39b4d43e
    • S
      KVM: x86/mmu: Use -1 to flag an undefined spte in get_mmio_spte() · 2aa07893
      Sean Christopherson 提交于
      Return -1 from the get_walk() helpers if the shadow walk doesn't fill at
      least one spte, which can theoretically happen if the walk hits a
      not-present PDPTR.  Returning the root level in such a case will cause
      get_mmio_spte() to return garbage (uninitialized stack data).  In
      practice, such a scenario should be impossible as KVM shouldn't get a
      reserved-bit page fault with a not-present PDPTR.
      
      Note, using mmu->root_level in get_walk() is wrong for other reasons,
      too, but that's now a moot point.
      
      Fixes: 95fb5b02 ("kvm: x86/mmu: Support MMIO in the TDP MMU")
      Cc: Ben Gardon <bgardon@google.com>
      Cc: stable@vger.kernel.org
      Signed-off-by: NSean Christopherson <seanjc@google.com>
      Message-Id: <20201218003139.2167891-2-seanjc@google.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      2aa07893
  2. 04 12月, 2020 1 次提交
  3. 19 11月, 2020 2 次提交
  4. 15 11月, 2020 2 次提交
    • P
      KVM: X86: Implement ring-based dirty memory tracking · fb04a1ed
      Peter Xu 提交于
      This patch is heavily based on previous work from Lei Cao
      <lei.cao@stratus.com> and Paolo Bonzini <pbonzini@redhat.com>. [1]
      
      KVM currently uses large bitmaps to track dirty memory.  These bitmaps
      are copied to userspace when userspace queries KVM for its dirty page
      information.  The use of bitmaps is mostly sufficient for live
      migration, as large parts of memory are be dirtied from one log-dirty
      pass to another.  However, in a checkpointing system, the number of
      dirty pages is small and in fact it is often bounded---the VM is
      paused when it has dirtied a pre-defined number of pages. Traversing a
      large, sparsely populated bitmap to find set bits is time-consuming,
      as is copying the bitmap to user-space.
      
      A similar issue will be there for live migration when the guest memory
      is huge while the page dirty procedure is trivial.  In that case for
      each dirty sync we need to pull the whole dirty bitmap to userspace
      and analyse every bit even if it's mostly zeros.
      
      The preferred data structure for above scenarios is a dense list of
      guest frame numbers (GFN).  This patch series stores the dirty list in
      kernel memory that can be memory mapped into userspace to allow speedy
      harvesting.
      
      This patch enables dirty ring for X86 only.  However it should be
      easily extended to other archs as well.
      
      [1] https://patchwork.kernel.org/patch/10471409/Signed-off-by: NLei Cao <lei.cao@stratus.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: NPeter Xu <peterx@redhat.com>
      Message-Id: <20201001012222.5767-1-peterx@redhat.com>
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      fb04a1ed
    • P
      kvm: mmu: fix is_tdp_mmu_check when the TDP MMU is not in use · c887c9b9
      Paolo Bonzini 提交于
      In some cases where shadow paging is in use, the root page will
      be either mmu->pae_root or vcpu->arch.mmu->lm_root.  Then it will
      not have an associated struct kvm_mmu_page, because it is allocated
      with alloc_page instead of kvm_mmu_alloc_page.
      
      Just return false quickly from is_tdp_mmu_root if the TDP MMU is
      not in use, which also includes the case where shadow paging is
      enabled.
      Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
      c887c9b9
  5. 24 10月, 2020 1 次提交
  6. 23 10月, 2020 10 次提交
  7. 22 10月, 2020 4 次提交
新手
引导
客服 返回
顶部