1. 14 2月, 2018 1 次提交
    • T
      drm/i915/gvt: Support BAR0 8-byte reads/writes · a26ca6ad
      Tina Zhang 提交于
      GGTT is in BAR0 with 8 bytes aligned. With a qemu patch (commit:
      38d49e8c1523d97d2191190d3f7b4ce7a0ab5aa3), VFIO can use 8-byte reads/
      writes to access it.
      
      This patch is to support the 8-byte GGTT reads/writes.
      
      Ideally, we would like to support 8-byte reads/writes for the total BAR0.
      But it needs more work for handling 8-byte MMIO reads/writes.
      
      This patch can fix the issue caused by partial updating GGTT entry, during
      guest booting up.
      
      v3:
      - Use intel_vgpu_get_bar_gpa() stead. (Zhenyu)
      - Include all the GGTT checking logic in gtt_entry(). (Zhenyu)
      
      v2:
      - Limit to GGTT entry. (Zhenyu)
      Signed-off-by: NTina Zhang <tina.zhang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      a26ca6ad
  2. 07 2月, 2018 1 次提交
  3. 01 2月, 2018 1 次提交
  4. 22 12月, 2017 1 次提交
  5. 21 12月, 2017 1 次提交
  6. 08 12月, 2017 1 次提交
  7. 04 12月, 2017 2 次提交
    • T
      drm/i915/gvt: Dmabuf support for GVT-g · e546e281
      Tina Zhang 提交于
      This patch introduces a guest's framebuffer sharing mechanism based on
      dma-buf subsystem. With this sharing mechanism, guest's framebuffer can
      be shared between guest VM and host.
      
      v17:
      - modify VFIO_DEVICE_GET_GFX_DMABUF interface. (Alex)
      
      v16:
      - add x_hot and y_hot. (Gerd)
      - add flag validation for VFIO_DEVICE_GET_GFX_DMABUF. (Alex)
      - rebase 4.14.0-rc6.
      
      v15:
      - add VFIO_DEVICE_GET_GFX_DMABUF ABI. (Gerd)
      - add intel_vgpu_dmabuf_cleanup() to clean up the vGPU's dmabuf. (Gerd)
      
      v14:
      - add PROBE, DMABUF and REGION flags. (Alex)
      
      v12:
      - refine the lifecycle of dmabuf.
      
      v9:
      - remove dma-buf management. (Alex)
      - track the dma-buf create and release in kernel mode. (Gerd) (Daniel)
      
      v8:
      - refine the dma-buf ioctl definition.(Alex)
      - add a lock to protect the dmabuf list. (Alex)
      
      v7:
      - release dma-buf related allocations in dma-buf's associated release
        function. (Alex)
      - refine ioctl interface for querying plane info or create dma-buf.
        (Alex)
      
      v6:
      - align the dma-buf life cycle with the vfio device. (Alex)
      - add the dma-buf related operations in a separate patch. (Gerd)
      - i915 related changes. (Chris)
      
      v5:
      - fix bug while checking whether the gem obj is gvt's dma-buf when user
        change caching mode or domains. Add a helper function to do it.
        (Xiaoguang)
      - add definition for the query plane and create dma-buf. (Xiaoguang)
      
      v4:
      - fix bug while checking whether the gem obj is gvt's dma-buf when set
        caching mode or doamins. (Xiaoguang)
      
      v3:
      - declare a new flag I915_GEM_OBJECT_IS_GVT_DMABUF in drm_i915_gem_object
        to represent the gem obj for gvt's dma-buf. The tiling mode, caching
        mode and domains can not be changed for this kind of gem object. (Alex)
      - change dma-buf related information to be more generic. So other vendor
        can use the same interface. (Alex)
      
      v2:
      - create a management fd for dma-buf operations. (Alex)
      - alloc gem object's backing storage in gem obj's get_pages() callback.
        (Chris)
      Signed-off-by: NTina Zhang <tina.zhang@intel.com>
      Cc: Alex Williamson <alex.williamson@redhat.com>
      Cc: Chris Wilson <chris@chris-wilson.co.uk>
      Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
      Cc: Gerd Hoffmann <kraxel@redhat.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      e546e281
    • T
      drm/i915/gvt: Add opregion support · b851adea
      Tina Zhang 提交于
      Windows guest driver needs vbt in opregion, to configure the setting
      for display. Without opregion support, the display registers won't
      be set and this blocks display model to get the correct information
      of the guest display plane.
      
      This patch is to provide a virtual opregion for guest. The original
      author of this patch is Xiaoguang Chen.
      
      This patch is split from the "Dma-buf support for GVT-g" patch set,
      with being rebased to the latest gvt-staging branch.
      
      v3:
      - add checking region index during intel_vgpu_rw. (Xiong)
      
      v2:
      - refine intel_vgpu_reg_release_opregion. (Xiong)
      
      Here are the previous version comments:
      
      v18:
      - unmap vgpu's opregion when destroying vgpu.
      
      v16:
      - rebase to 4.14.0-rc6.
      Signed-off-by: NBing Niu <bing.niu@intel.com>
      Signed-off-by: NTina Zhang <tina.zhang@intel.com>
      Tested-by: NXiong Zhang <xiong.y.zhang@intel.com>
      Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      b851adea
  8. 16 11月, 2017 2 次提交
  9. 08 9月, 2017 3 次提交
    • C
      drm/i915/gvt: Add support for PCIe extended configuration space · 02d578e5
      Changbin Du 提交于
      IGD is PCIe device and has extended configuration space. Checking
      the binary dump, we can see we have Caps located out of PCI compatible
      Configuration Space range.
      
      0x000: 86 80 12 19 17 04 10 00 06 00 00 03 00 00 00 00
      0x010: 04 00 00 10 08 00 00 00 0c 00 00 00 08 00 00 00
      0x020: 00 00 00 00 00 00 00 00 00 00 00 00 28 10 b9 06
      0x030: 00 f8 ff ff 40 00 00 00 00 00 00 00 0b 01 00 00
      0x040: 09 70 0c 01 71 26 01 62 c8 00 04 84 00 00 00 00
      0x050: c1 00 00 00 39 00 00 00 00 00 00 00 01 00 00 a2
      0x060: 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x070: 10 ac 92 00 00 80 00 10 00 00 00 00 00 00 00 00
      0x080: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x090: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x0a0: 00 00 00 00 00 00 00 00 00 00 00 00 05 d0 01 00
      0x0b0: 18 00 e0 fe 00 00 00 00 00 00 00 00 00 00 00 00
      0x0c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x0d0: 01 00 22 00 00 80 00 00 00 00 00 00 00 00 00 00
      0x0e0: 00 00 00 00 00 00 00 00 00 80 00 00 00 00 00 00
      0x0f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
      0x100: 1b 00 01 20 02 14 00 00 00 00 00 00 00 00 00 00
      ...
      
      Currently, we only emulate the PCI compatible Configuration Space.
      This is okay if we attach vGPU to PCI bus. But when we attach to
      a PCI Express bus (when Qemu emulates a Intel Q35 chipset which has
      PCIe slot), it will not work. Extended Configuration Space is required
      for a PCIe device.
      
      This patch extended the virtual configuration space from 256 bytes
      to 4KB bytes. So we are to be a *real* PCIe device. And for the
      Extended CapList we keep same to physical GPU.
      
      Cc: Laszlo Ersek <lersek@redhat.com>
      Tested-by: NLaszlo Ersek <lersek@redhat.com>
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      02d578e5
    • C
      drm/i915/gvt: Add emulation for BAR2 (aperture) with normal file RW approach · f090a00d
      Changbin Du 提交于
      For vfio-pci, if the region support MMAP then it should support both
      mmap and normal file access. The user-space is free to choose which is
      being used. For qemu, we just need add 'x-no-mmap=on' for vfio-pci
      option.
      
      Currently GVTg only support MMAP for BAR2. So GVTg will not work when
      user turn on x-no-mmap option.
      
      This patch added file style access for BAR2, aka the GPU aperture. We
      map the entire aperture partition of active vGPU to kernel space when
      guest driver try to enable PCI Memory Space. Then we redirect the file
      RW operation from kvmgt to this mapped area.
      
      Link: https://bugzilla.redhat.com/show_bug.cgi?id=1458032Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      f090a00d
    • C
      drm/i915/kvmgt: Sanitize PCI bar emulation · 5d5fe176
      Changbin Du 提交于
      For PCI, 64bit bar consumes two BAR registers, but this doesn't mean
      both of two BAR are valid. Actually the second BAR is regarded as
      reserved in this case. So we shouldn't emulate the second BAR.
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      5d5fe176
  10. 10 8月, 2017 1 次提交
  11. 11 7月, 2017 1 次提交
  12. 26 6月, 2017 2 次提交
    • C
      drm/i915/gvt: Fix inconsistent locks holding sequence · f16bd3dd
      Chuanxiao Dong 提交于
      There are two kinds of locking sequence.
      
      One is in the thread which is started by vfio ioctl to do
      the iommu unmapping. The locking sequence is:
      	down_read(&group_lock) ----> mutex_lock(&cached_lock)
      
      The other is in the vfio release thread which will unpin all
      the cached pages. The lock sequence is:
      	mutex_lock(&cached_lock) ---> down_read(&group_lock)
      
      And, the cache_lock is used to protect the rb tree of the cache
      node and doing vfio unpin doesn't require this lock. Move the
      vfio unpin out of the cache_lock protected region.
      
      v2:
      - use for style instead of do{}while(1). (Zhenyu)
      
      Fixes: f30437c5 ("drm/i915/gvt: add KVMGT support")
      Signed-off-by: NChuanxiao Dong <chuanxiao.dong@intel.com>
      Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
      Cc: stable@vger.kernel.org # v4.10+
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      f16bd3dd
    • C
      drm/i915/gvt: Fix possible recursive locking issue · 62d02fd1
      Chuanxiao Dong 提交于
      vfio_unpin_pages will hold a read semaphore however it is already hold
      in the same thread by vfio ioctl. It will cause below warning:
      
      [ 5102.127454] ============================================
      [ 5102.133379] WARNING: possible recursive locking detected
      [ 5102.139304] 4.12.0-rc4+ #3 Not tainted
      [ 5102.143483] --------------------------------------------
      [ 5102.149407] qemu-system-x86/1620 is trying to acquire lock:
      [ 5102.155624]  (&container->group_lock){++++++}, at: [<ffffffff817768c6>] vfio_unpin_pages+0x96/0xf0
      [ 5102.165626]
      but task is already holding lock:
      [ 5102.172134]  (&container->group_lock){++++++}, at: [<ffffffff8177728f>] vfio_fops_unl_ioctl+0x5f/0x280
      [ 5102.182522]
      other info that might help us debug this:
      [ 5102.189806]  Possible unsafe locking scenario:
      
      [ 5102.196411]        CPU0
      [ 5102.199136]        ----
      [ 5102.201861]   lock(&container->group_lock);
      [ 5102.206527]   lock(&container->group_lock);
      [ 5102.211191]
      *** DEADLOCK ***
      
      [ 5102.217796]  May be due to missing lock nesting notation
      
      [ 5102.225370] 3 locks held by qemu-system-x86/1620:
      [ 5102.230618]  #0:  (&container->group_lock){++++++}, at: [<ffffffff8177728f>] vfio_fops_unl_ioctl+0x5f/0x280
      [ 5102.241482]  #1:  (&(&iommu->notifier)->rwsem){++++..}, at: [<ffffffff810de775>] __blocking_notifier_call_chain+0x35/0x70
      [ 5102.253713]  #2:  (&vgpu->vdev.cache_lock){+.+...}, at: [<ffffffff8157b007>] intel_vgpu_iommu_notifier+0x77/0x120
      [ 5102.265163]
      stack backtrace:
      [ 5102.270022] CPU: 5 PID: 1620 Comm: qemu-system-x86 Not tainted 4.12.0-rc4+ #3
      [ 5102.277991] Hardware name: Intel Corporation S1200RP/S1200RP, BIOS S1200RP.86B.03.01.APER.061220151418 06/12/2015
      [ 5102.289445] Call Trace:
      [ 5102.292175]  dump_stack+0x85/0xc7
      [ 5102.295871]  validate_chain.isra.21+0x9da/0xaf0
      [ 5102.300925]  __lock_acquire+0x405/0x820
      [ 5102.305202]  lock_acquire+0xc7/0x220
      [ 5102.309191]  ? vfio_unpin_pages+0x96/0xf0
      [ 5102.313666]  down_read+0x2b/0x50
      [ 5102.317259]  ? vfio_unpin_pages+0x96/0xf0
      [ 5102.321732]  vfio_unpin_pages+0x96/0xf0
      [ 5102.326024]  intel_vgpu_iommu_notifier+0xe5/0x120
      [ 5102.331283]  notifier_call_chain+0x4a/0x70
      [ 5102.335851]  __blocking_notifier_call_chain+0x4d/0x70
      [ 5102.341490]  blocking_notifier_call_chain+0x16/0x20
      [ 5102.346935]  vfio_iommu_type1_ioctl+0x87b/0x920
      [ 5102.351994]  vfio_fops_unl_ioctl+0x81/0x280
      [ 5102.356660]  ? __fget+0xf0/0x210
      [ 5102.360261]  do_vfs_ioctl+0x93/0x6a0
      [ 5102.364247]  ? __fget+0x111/0x210
      [ 5102.367942]  SyS_ioctl+0x41/0x70
      [ 5102.371542]  entry_SYSCALL_64_fastpath+0x1f/0xbe
      
      put the vfio_unpin_pages in a workqueue can fix this.
      
      v2:
      - use for style instead of do{}while(1). (Zhenyu)
      v3:
      - rename gvt_cache_mark to gvt_cache_mark_remove. (Zhenyu)
      
      Fixes: 659643f7 ("drm/i915/gvt/kvmgt: add vfio/mdev support to KVMGT")
      Signed-off-by: NChuanxiao Dong <chuanxiao.dong@intel.com>
      Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
      Cc: stable@vger.kernel.org # v4.10+
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      62d02fd1
  13. 31 3月, 2017 1 次提交
  14. 30 3月, 2017 3 次提交
    • Z
      drm/i915/gvt: Activate/de-activate vGPU in mdev ops. · b79c52ae
      Zhi Wang 提交于
      This patch introduces two functions for activating/de-activating vGPU in
      mdev ops.
      
      A racing condition was found between virtual vblank emulation and KVGMT
      mdev release path. V-blank emulation will emulate and inject V-blank
      interrupt for every active vGPU with holding gvt->lock, while in mdev
      release path, it will directly release hypervisor handle without changing
      vGPU status or taking gvt->lock, so a kernel oops is encountered when
      vblank emulation is injecting a interrupt with a invalid hypervisor
      handle. (Reported by Terrence)
      
      To solve this problem, we factor out vGPU activation/de-activation from
      vGPU creation/destruction path and let KVMGT mdev release ops de-activate
      the vGPU before release hypervisor handle. Once a vGPU is de-activated,
      GVT-g will not emulate v-blank for it or touch the hypervisor handle.
      
      Fixes: 659643f7 ("drm/i915/gvt/kvmgt: add vfio/mdev support to KVMGT")
      Signed-off-by: NZhi Wang <zhi.a.wang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      b79c52ae
    • P
      drm/i915/gvt: define weight according to vGPU type · bc90d097
      Ping Gao 提交于
      The weight defines proportional control of physical GPU resource
      shared between vGPUs. So far the weight is tied to a specific vGPU
      type, i.e when creating multiple vGPUs with different types, they
      will inherit different weights.
      
      e.g. The weight of type GVTg_V5_2 is 8, the weight of type GVTg_V5_4
      is 4, so vGPU of type GVTg_V5_2 has double vGPU resource of vGPU type
      GVTg_V5_4.
      
      TODO: allow user control the weight setting in the future.
      Signed-off-by: NPing Gao <ping.a.gao@intel.com>
      Reviewed-by: NKevin Tian <kevin.tian@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      bc90d097
    • T
      drm/i915/gvt: remove the redundant info NULL check · 865f03d4
      Tina Zhang 提交于
      The variable info is never NULL, which is checked by the caller. This
      patch removes the redundant info NULL check logic.
      
      Fixes: 695fbc08 ("drm/i915/gvt: replace the gvt_err with gvt_vgpu_err")
      Signed-off-by: NTina Zhang <tina.zhang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      865f03d4
  15. 29 3月, 2017 1 次提交
  16. 20 3月, 2017 1 次提交
    • A
      drm/i915/kvmgt: Hold struct kvm reference · 93a15b58
      Alex Williamson 提交于
      The kvmgt code keeps a pointer to the struct kvm associated with the
      device, but doesn't actually hold a reference to it.  If we do unclean
      shutdown testing (ie. killing the user process), then we can see the
      kvm association to the device unset, which causes kvmgt to trigger a
      device release via a work queue.  Naturally we cannot guarantee that
      the cached struct kvm pointer is still valid at this point without
      holding a reference.  The observed failure in this case is a stuck
      cpu trying to acquire the spinlock from the invalid reference, but
      other failure modes are clearly possible.  Hold a reference to avoid
      this.
      Signed-off-by: NAlex Williamson <alex.williamson@redhat.com>
      Cc: stable@vger.kernel.org #v4.10
      Cc: Jike Song <jike.song@intel.com>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
      Cc: Zhi Wang <zhi.a.wang@intel.com>
      Reviewed-by: NJike Song <jike.song@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      93a15b58
  17. 17 3月, 2017 2 次提交
    • C
      drm/i915/kvmgt: fix suspicious rcu dereference usage · 5180edc2
      Changbin Du 提交于
      The srcu read lock must be held while accessing kvm memslots.
      This patch fix below warning for function kvmgt_rw_gpa().
      
      [  165.345093] [ ERR: suspicious RCU usage.  ]
      [  165.416538] Call Trace:
      [  165.418989]  dump_stack+0x85/0xc2
      [  165.422310]  lockdep_rcu_suspicious+0xd7/0x110
      [  165.426769]  kvm_read_guest_page+0x195/0x1b0 [kvm]
      [  165.431574]  kvm_read_guest+0x50/0x90 [kvm]
      [  165.440492]  kvmgt_rw_gpa+0x43/0xa0 [kvmgt]
      [  165.444683]  kvmgt_read_gpa+0x11/0x20 [kvmgt]
      [  165.449061]  gtt_get_entry64+0x4d/0xc0 [i915]
      [  165.453438]  ppgtt_populate_shadow_page_by_guest_entry+0x380/0xdc0 [i915]
      [  165.460254]  shadow_mm+0xd1/0x460 [i915]
      [  165.472488]  intel_vgpu_create_mm+0x1ab/0x210 [i915]
      [  165.477472]  intel_vgpu_g2v_create_ppgtt_mm+0x5f/0xc0 [i915]
      [  165.483154]  pvinfo_mmio_write+0x19b/0x1d0 [i915]
      [  165.499068]  intel_vgpu_emulate_mmio_write+0x3f9/0x600 [i915]
      [  165.504827]  intel_vgpu_rw+0x114/0x150 [kvmgt]
      [  165.509281]  intel_vgpu_write+0x16f/0x1a0 [kvmgt]
      [  165.513993]  vfio_mdev_write+0x20/0x30 [vfio_mdev]
      [  165.518793]  vfio_device_fops_write+0x24/0x30 [vfio]
      [  165.523770]  __vfs_write+0x28/0x120
      [  165.540529]  vfs_write+0xce/0x1f0
      
      v2: fix Cc format for stable
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Cc: <stable@vger.kernel.org> # v4.10+
      Reviewed-by: NXiao Guangrong <guangrong.xiao@linux.intel.com>
      Reviewed-by: NJike Song <jike.song@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      5180edc2
    • T
      drm/i915/gvt: replace the gvt_err with gvt_vgpu_err · 695fbc08
      Tina Zhang 提交于
      gvt_err should be used only for the very few critical error message
      during host i915 drvier initialization. This patch
      1. removes the redundant gvt_err;
      2. creates a new gvt_vgpu_err to show errors caused by vgpu;
      3. replaces the most gvt_err with gvt_vgpu_err;
      4. leaves very few gvt_err for dumping gvt error during host gvt
         initialization.
      
      v2. change name to gvt_vgpu_err and add vgpu id to the message. (Kevin)
          add gpu id to gvt_vgpu_err. (Zhi)
      v3. remove gpu id from gvt_vgpu_err caller. (Zhi)
      v4. add vgpu check to the gvt_vgpu_err macro. (Zhiyuan)
      v5. add comments for v3 and v4.
      v6. split the big patch into two, with this patch only for checking
          gvt_vgpu_err. (Zhenyu)
      v7. rebase to staging branch
      v8. rebase to fix branch
      Signed-off-by: NTina Zhang <tina.zhang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      695fbc08
  18. 01 3月, 2017 1 次提交
  19. 24 2月, 2017 1 次提交
  20. 14 2月, 2017 1 次提交
  21. 09 2月, 2017 1 次提交
  22. 08 2月, 2017 1 次提交
  23. 07 2月, 2017 2 次提交
  24. 25 1月, 2017 1 次提交
  25. 09 1月, 2017 1 次提交
  26. 30 12月, 2016 3 次提交
  27. 26 12月, 2016 3 次提交