public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/28] drm/i915/gvt: KVM: KVMGT fixes and page-track cleanups
@ 2023-05-13  0:35 Sean Christopherson
  2023-05-13  0:35 ` [PATCH v3 01/28] drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page" Sean Christopherson
                   ` (28 more replies)
  0 siblings, 29 replies; 42+ messages in thread
From: Sean Christopherson @ 2023-05-13  0:35 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Zhenyu Wang, Zhi Wang
  Cc: kvm, intel-gvt-dev, intel-gfx, linux-kernel, Yan Zhao, Ben Gardon

Fix a variety of found-by-inspection bugs in KVMGT, and overhaul KVM's
page-track APIs to provide a leaner and cleaner interface.  The motivation
for this series is to (significantly) reduce the number of KVM APIs that
KVMGT uses, with a long-term goal of making all kvm_host.h headers
KVM-internal.

As always for this series, the KVMGT changes are compile tested only.

Based on "git://git.kernel.org/pub/scm/virt/kvm/kvm.git tags/kvm-6.4-1".

v3:
 - Collect reviewed/tested tags (I apologize if I missed any, I manually
   gathered them this time due to a goof in my workflow). [Yan]
 - Drop check on max KVM paging size from KVMGT. [Yan]
 - Drop the explicit change on THP pages, and instead validate that the
   pfns (not struct page pointers) are contiguous. [Yan]
 - Fix buggy intel_gvt_dma_map_guest_page() usage by eliminating a helper
   for shadowing 2MiB GTT entries. [Yan]
 - Move kvm_arch_flush_shadow_{all,memslot}() to mmu.c instead of exposing
   kvm_mmu_zap_all_fast() outside of mmu.c. [Yan]
 - Fix an alignment goof in hlist_for_each_entry_srcu() usage. [Yan]
 - Wrap full definition of external page track structures with
   CONFIG_KVM_EXTERNAL_WRITE_TRACKING. [Yan]

v2:
 - https://lore.kernel.org/all/20230311002258.852397-1-seanjc@google.com
 - Reuse vgpu_lock to protect gfn hash instead of introducing a new (and
   buggy) mutext. [Yan]
 - Remove a spurious return from kvm_page_track_init(). [Yan]
 - Take @kvm directly in the inner __kvm_page_track_write(). [Yan]
 - Delete the gfn sanity check that relies on kvm_is_visible_gfn() instead
   of providing a dedicated interface. [Yan]

v1: https://lore.kernel.org/lkml/20221223005739.1295925-1-seanjc@google.com

Sean Christopherson (24):
  drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page"
  drm/i915/gvt: Verify hugepages are contiguous in physical address
    space
  drm/i915/gvt: Put the page reference obtained by KVM's gfn_to_pfn()
  drm/i915/gvt: Explicitly check that vGPU is attached before shadowing
  drm/i915/gvt: Error out on an attempt to shadowing an unknown GTT
    entry type
  drm/i915/gvt: Don't rely on KVM's gfn_to_pfn() to query possible 2M
    GTT
  drm/i915/gvt: Use an "unsigned long" to iterate over memslot gfns
  drm/i915/gvt: Drop unused helper intel_vgpu_reset_gtt()
  drm/i915/gvt: Protect gfn hash table with vgpu_lock
  KVM: x86/mmu: Move kvm_arch_flush_shadow_{all,memslot}() to mmu.c
  KVM: x86/mmu: Don't rely on page-track mechanism to flush on memslot
    change
  KVM: x86/mmu: Don't bounce through page-track mechanism for guest PTEs
  KVM: drm/i915/gvt: Drop @vcpu from KVM's ->track_write() hook
  KVM: x86: Reject memslot MOVE operations if KVMGT is attached
  drm/i915/gvt: Don't bother removing write-protection on to-be-deleted
    slot
  KVM: x86/mmu: Move KVM-only page-track declarations to internal header
  KVM: x86/mmu: Use page-track notifiers iff there are external users
  KVM: x86/mmu: Drop infrastructure for multiple page-track modes
  KVM: x86/mmu: Rename page-track APIs to reflect the new reality
  KVM: x86/mmu: Assert that correct locks are held for page
    write-tracking
  KVM: x86/mmu: Bug the VM if write-tracking is used but not enabled
  KVM: x86/mmu: Drop @slot param from exported/external page-track APIs
  KVM: x86/mmu: Handle KVM bookkeeping in page-track APIs, not callers
  drm/i915/gvt: Drop final dependencies on KVM internal details

Yan Zhao (4):
  drm/i915/gvt: remove interface intel_gvt_is_valid_gfn
  KVM: x86: Add a new page-track hook to handle memslot deletion
  drm/i915/gvt: switch from ->track_flush_slot() to
    ->track_remove_region()
  KVM: x86: Remove the unused page-track hook track_flush_slot()

 arch/x86/include/asm/kvm_host.h       |  16 +-
 arch/x86/include/asm/kvm_page_track.h |  73 +++-----
 arch/x86/kvm/mmu.h                    |   2 +
 arch/x86/kvm/mmu/mmu.c                |  51 +++--
 arch/x86/kvm/mmu/page_track.c         | 256 +++++++++++++-------------
 arch/x86/kvm/mmu/page_track.h         |  58 ++++++
 arch/x86/kvm/x86.c                    |  22 +--
 drivers/gpu/drm/i915/gvt/gtt.c        | 102 ++--------
 drivers/gpu/drm/i915/gvt/gtt.h        |   1 -
 drivers/gpu/drm/i915/gvt/gvt.h        |   3 +-
 drivers/gpu/drm/i915/gvt/kvmgt.c      | 117 +++++-------
 drivers/gpu/drm/i915/gvt/page_track.c |  10 +-
 12 files changed, 320 insertions(+), 391 deletions(-)
 create mode 100644 arch/x86/kvm/mmu/page_track.h


base-commit: b3c98052d46948a8d65d2778c7f306ff38366aac
-- 
2.40.1.606.ga4b1b128d6-goog


^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2023-06-14  3:06 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-13  0:35 [PATCH v3 00/28] drm/i915/gvt: KVM: KVMGT fixes and page-track cleanups Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 01/28] drm/i915/gvt: Verify pfn is "valid" before dereferencing "struct page" Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 02/28] drm/i915/gvt: remove interface intel_gvt_is_valid_gfn Sean Christopherson
2023-05-15 11:07   ` Wang, Zhi A
2023-05-13  0:35 ` [PATCH v3 03/28] drm/i915/gvt: Verify hugepages are contiguous in physical address space Sean Christopherson
2023-05-16  9:37   ` Yan Zhao
2023-05-17 14:50     ` Sean Christopherson
2023-05-18  9:06       ` Yan Zhao
2023-05-18 18:04         ` Sean Christopherson
2023-05-19  3:18           ` Yan Zhao
2023-05-13  0:35 ` [PATCH v3 04/28] drm/i915/gvt: Put the page reference obtained by KVM's gfn_to_pfn() Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 05/28] drm/i915/gvt: Explicitly check that vGPU is attached before shadowing Sean Christopherson
2023-05-15 11:24   ` Wang, Zhi A
2023-05-15 17:57     ` Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 06/28] drm/i915/gvt: Error out on an attempt to shadowing an unknown GTT entry type Sean Christopherson
2023-05-15 11:28   ` Wang, Zhi A
2023-05-13  0:35 ` [PATCH v3 07/28] drm/i915/gvt: Don't rely on KVM's gfn_to_pfn() to query possible 2M GTT Sean Christopherson
2023-05-17  0:57   ` Yan Zhao
2023-05-13  0:35 ` [PATCH v3 08/28] drm/i915/gvt: Use an "unsigned long" to iterate over memslot gfns Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 09/28] drm/i915/gvt: Drop unused helper intel_vgpu_reset_gtt() Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 10/28] drm/i915/gvt: Protect gfn hash table with vgpu_lock Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 11/28] KVM: x86/mmu: Move kvm_arch_flush_shadow_{all,memslot}() to mmu.c Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 12/28] KVM: x86/mmu: Don't rely on page-track mechanism to flush on memslot change Sean Christopherson
2023-05-17  2:06   ` Yan Zhao
2023-05-13  0:35 ` [PATCH v3 13/28] KVM: x86/mmu: Don't bounce through page-track mechanism for guest PTEs Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 14/28] KVM: drm/i915/gvt: Drop @vcpu from KVM's ->track_write() hook Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 15/28] KVM: x86: Reject memslot MOVE operations if KVMGT is attached Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 16/28] drm/i915/gvt: Don't bother removing write-protection on to-be-deleted slot Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 17/28] KVM: x86: Add a new page-track hook to handle memslot deletion Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 18/28] drm/i915/gvt: switch from ->track_flush_slot() to ->track_remove_region() Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 19/28] KVM: x86: Remove the unused page-track hook track_flush_slot() Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 20/28] KVM: x86/mmu: Move KVM-only page-track declarations to internal header Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 21/28] KVM: x86/mmu: Use page-track notifiers iff there are external users Sean Christopherson
2023-05-17  3:27   ` Yan Zhao
2023-05-13  0:35 ` [PATCH v3 22/28] KVM: x86/mmu: Drop infrastructure for multiple page-track modes Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 23/28] KVM: x86/mmu: Rename page-track APIs to reflect the new reality Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 24/28] KVM: x86/mmu: Assert that correct locks are held for page write-tracking Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 25/28] KVM: x86/mmu: Bug the VM if write-tracking is used but not enabled Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 26/28] KVM: x86/mmu: Drop @slot param from exported/external page-track APIs Sean Christopherson
2023-05-13  0:35 ` [PATCH v3 27/28] KVM: x86/mmu: Handle KVM bookkeeping in page-track APIs, not callers Sean Christopherson
2023-05-13  0:36 ` [PATCH v3 28/28] drm/i915/gvt: Drop final dependencies on KVM internal details Sean Christopherson
2023-06-14  3:06 ` [PATCH v3 00/28] drm/i915/gvt: KVM: KVMGT fixes and page-track cleanups Ma, Yongwei

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox