1. 13 6月, 2018 1 次提交
    • K
      treewide: kzalloc() -> kcalloc() · 6396bb22
      Kees Cook 提交于
      The kzalloc() function has a 2-factor argument form, kcalloc(). This
      patch replaces cases of:
      
              kzalloc(a * b, gfp)
      
      with:
              kcalloc(a * b, gfp)
      
      as well as handling cases of:
      
              kzalloc(a * b * c, gfp)
      
      with:
      
              kzalloc(array3_size(a, b, c), gfp)
      
      as it's slightly less ugly than:
      
              kzalloc_array(array_size(a, b), c, gfp)
      
      This does, however, attempt to ignore constant size factors like:
      
              kzalloc(4 * 1024, gfp)
      
      though any constants defined via macros get caught up in the conversion.
      
      Any factors with a sizeof() of "unsigned char", "char", and "u8" were
      dropped, since they're redundant.
      
      The Coccinelle script used for this was:
      
      // Fix redundant parens around sizeof().
      @@
      type TYPE;
      expression THING, E;
      @@
      
      (
        kzalloc(
      -	(sizeof(TYPE)) * E
      +	sizeof(TYPE) * E
        , ...)
      |
        kzalloc(
      -	(sizeof(THING)) * E
      +	sizeof(THING) * E
        , ...)
      )
      
      // Drop single-byte sizes and redundant parens.
      @@
      expression COUNT;
      typedef u8;
      typedef __u8;
      @@
      
      (
        kzalloc(
      -	sizeof(u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * (COUNT)
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(__u8) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(char) * COUNT
      +	COUNT
        , ...)
      |
        kzalloc(
      -	sizeof(unsigned char) * COUNT
      +	COUNT
        , ...)
      )
      
      // 2-factor product with sizeof(type/expression) and identifier or constant.
      @@
      type TYPE;
      expression THING;
      identifier COUNT_ID;
      constant COUNT_CONST;
      @@
      
      (
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_ID)
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_ID
      +	COUNT_ID, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * COUNT_CONST
      +	COUNT_CONST, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_ID)
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_ID
      +	COUNT_ID, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (COUNT_CONST)
      +	COUNT_CONST, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * COUNT_CONST
      +	COUNT_CONST, sizeof(THING)
        , ...)
      )
      
      // 2-factor product, only identifiers.
      @@
      identifier SIZE, COUNT;
      @@
      
      - kzalloc
      + kcalloc
        (
      -	SIZE * COUNT
      +	COUNT, SIZE
        , ...)
      
      // 3-factor product with 1 sizeof(type) or sizeof(expression), with
      // redundant parens removed.
      @@
      expression THING;
      identifier STRIDE, COUNT;
      type TYPE;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(TYPE))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * (COUNT) * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * (STRIDE)
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      |
        kzalloc(
      -	sizeof(THING) * COUNT * STRIDE
      +	array3_size(COUNT, STRIDE, sizeof(THING))
        , ...)
      )
      
      // 3-factor product with 2 sizeof(variable), with redundant parens removed.
      @@
      expression THING1, THING2;
      identifier COUNT;
      type TYPE1, TYPE2;
      @@
      
      (
        kzalloc(
      -	sizeof(TYPE1) * sizeof(TYPE2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(THING1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(THING1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * COUNT
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      |
        kzalloc(
      -	sizeof(TYPE1) * sizeof(THING2) * (COUNT)
      +	array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
        , ...)
      )
      
      // 3-factor product, only identifiers, with redundant parens removed.
      @@
      identifier STRIDE, SIZE, COUNT;
      @@
      
      (
        kzalloc(
      -	(COUNT) * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * STRIDE * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	(COUNT) * (STRIDE) * (SIZE)
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      |
        kzalloc(
      -	COUNT * STRIDE * SIZE
      +	array3_size(COUNT, STRIDE, SIZE)
        , ...)
      )
      
      // Any remaining multi-factor products, first at least 3-factor products,
      // when they're not all constants...
      @@
      expression E1, E2, E3;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(
      -	(E1) * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * E3
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	(E1) * (E2) * (E3)
      +	array3_size(E1, E2, E3)
        , ...)
      |
        kzalloc(
      -	E1 * E2 * E3
      +	array3_size(E1, E2, E3)
        , ...)
      )
      
      // And then all remaining 2 factors products when they're not all constants,
      // keeping sizeof() as the second factor argument.
      @@
      expression THING, E1, E2;
      type TYPE;
      constant C1, C2, C3;
      @@
      
      (
        kzalloc(sizeof(THING) * C2, ...)
      |
        kzalloc(sizeof(TYPE) * C2, ...)
      |
        kzalloc(C1 * C2 * C3, ...)
      |
        kzalloc(C1 * C2, ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * (E2)
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(TYPE) * E2
      +	E2, sizeof(TYPE)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * (E2)
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	sizeof(THING) * E2
      +	E2, sizeof(THING)
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * E2
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	(E1) * (E2)
      +	E1, E2
        , ...)
      |
      - kzalloc
      + kcalloc
        (
      -	E1 * E2
      +	E1, E2
        , ...)
      )
      Signed-off-by: NKees Cook <keescook@chromium.org>
      6396bb22
  2. 14 5月, 2018 5 次提交
  3. 30 4月, 2018 1 次提交
  4. 23 4月, 2018 5 次提交
  5. 19 4月, 2018 1 次提交
  6. 17 4月, 2018 1 次提交
    • C
      drm/i915/kvmgt: Check the pfn got from vfio_pin_pages · 39b4cbad
      Changbin Du 提交于
      This can fix below oops. The target pfn must be mem backed.
      
      [ 3639.109674] BUG: unable to handle kernel paging request at ffff8c44832a3000
      [ 3639.109681] IP: memcpy_erms+0x6/0x10
      [ 3639.109682] PGD 0 P4D 0
      [ 3639.109685] Oops: 0000 1 SMP PTI
      [ 3639.109726] CPU: 2 PID: 1724 Comm: qemu-system-x86 Not tainted 4.16.0-rc5+ #1
      [ 3639.109727] Hardware name: /NUC7i7BNB, BIOS BNKBL357.86A.0050.2017.0816.2002 08/16/2017
      [ 3639.109729] RIP: 0010:memcpy_erms+0x6/0x10
      [ 3639.109730] RSP: 0018:ffffb1b7c3fbbbf0 EFLAGS: 00010246
      [ 3639.109731] RAX: ffff8a44b6460000 RBX: 0000000036460000 RCX: 0000000000001000
      [ 3639.109732] RDX: 0000000000001000 RSI: ffff8c44832a3000 RDI: ffff8a44b6460000
      [ 3639.109733] RBP: 000000000006c8c0 R08: ffff8a44b6460000 R09: 0000000000000000
      [ 3639.109734] R10: ffffb1b7c3fbbcd0 R11: ffff8a4d102018c0 R12: 0000000000000000
      [ 3639.109734] R13: 0000000000000002 R14: 0000000000200000 R15: 0000000000000000
      [ 3639.109736] FS: 00007f37f6d09700(0000) GS:ffff8a4d36d00000(0000) knlGS:0000000000000000
      [ 3639.109737] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 3639.109738] CR2: ffff8c44832a3000 CR3: 000000088b7b8004 CR4: 00000000003626e0
      [ 3639.109739] Call Trace:
      [ 3639.109743] swiotlb_tbl_map_single+0x2bb/0x300
      [ 3639.109746] map_single+0x30/0x80
      [ 3639.109748] swiotlb_map_page+0x87/0x150
      [ 3639.109751] kvmgt_dma_map_guest_page+0x329/0x3a0 [kvmgt]
      [ 3639.109764] ? kvm_write_guest_offset_cached+0x84/0xe0 [kvm]
      [ 3639.109789] intel_vgpu_emulate_ggtt_mmio_write+0x1f4/0x250 [i915]
      [ 3639.109808] intel_vgpu_emulate_mmio_write+0x162/0x230 [i915]
      [ 3639.109811] intel_vgpu_rw+0x1fc/0x240 [kvmgt]
      [ 3639.109813] intel_vgpu_write+0x164/0x1f0 [kvmgt]
      [ 3639.109816] __vfs_write+0x33/0x170
      [ 3639.109818] ? do_vfs_ioctl+0x9f/0x5f0
      [ 3639.109820] vfs_write+0xb3/0x1a0
      [ 3639.109822] SyS_pwrite64+0x90/0xb0
      [ 3639.109825] do_syscall_64+0x68/0x120
      [ 3639.109827] entry_SYSCALL_64_after_hwframe+0x3d/0xa2
      [ 3639.109829] RIP: 0033:0x7f3802b2d873
      [ 3639.109830] RSP: 002b:00007f37f6d08670 EFLAGS: 00000293 ORIG_RAX: 0000000000000012
      [ 3639.109831] RAX: ffffffffffffffda RBX: 0000000000000001 RCX: 00007f3802b2d873
      [ 3639.109832] RDX: 0000000000000008 RSI: 00007f37f6d086a0 RDI: 000000000000001a
      [ 3639.109833] RBP: 00007f37f6d086c0 R08: 0000000000000008 R09: ffffffffffffffff
      [ 3639.109834] R10: 00000000008041c8 R11: 0000000000000293 R12: 00007ffd8bbf92ae
      [ 3639.109835] R13: 00007ffd8bbf92af R14: 00007f37f6d09700 R15: 00007f37f6d099c0
      
      v2: add Fixes tag.
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Fixes: cf4ee73f ("drm/i915/gvt: Fix guest vGPU hang caused by very high dma setup overhead")
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      39b4cbad
  7. 16 4月, 2018 1 次提交
  8. 12 4月, 2018 1 次提交
    • C
      drm/i915/gvt: Fix the validation on size field of dp aux header · 2f24636b
      Changbin Du 提交于
      The assertion for len is wrong, so fix it. And for where to validate
      user input, we should not warn by call trace.
      
      [ 290.584739] WARNING: CPU: 0 PID: 1471 at drivers/gpu/drm/i915/gvt/handlers.c:969 dp_aux_ch_ctl_mmio_write+0x394/0x430 [i915]
      [ 290.586113] task: ffff880111fe8000 task.stack: ffffc90044a9c000
      [ 290.586192] RIP: e030:dp_aux_ch_ctl_mmio_write+0x394/0x430 [i915]
      [ 290.586258] RSP: e02b:ffffc90044a9fd88 EFLAGS: 00010282
      [ 290.586315] RAX: 0000000000000017 RBX: 0000000000000003 RCX: ffffffff82461148
      [ 290.586391] RDX: 0000000000000000 RSI: 0000000000000001 RDI: 0000000000000201
      [ 290.586468] RBP: ffffc90043ed1000 R08: 0000000000000248 R09: 00000000000003d8
      [ 290.586544] R10: ffffc90044bdd314 R11: 0000000000000011 R12: 0000000000064310
      [ 290.586621] R13: 00000000fe4003ff R14: ffffc900432d1008 R15: ffff88010fa7cb40
      [ 290.586701] FS: 0000000000000000(0000) GS:ffff880123200000(0000) knlGS:0000000000000000
      [ 290.586787] CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 290.586849] CR2: 00007f67ea44e000 CR3: 0000000116078000 CR4: 0000000000042660
      [ 290.586926] Call Trace:
      [ 290.586958] ? __switch_to_asm+0x40/0x70
      [ 290.587017] intel_vgpu_mmio_reg_rw+0x1ec/0x3c0 [i915]
      [ 290.587087] intel_vgpu_emulate_mmio_write+0xa8/0x2c0 [i915]
      [ 290.587151] xengt_emulation_thread+0x501/0x7a0 [xengt]
      [ 290.587208] ? __schedule+0x3c6/0x890
      [ 290.587250] ? wait_woken+0x80/0x80
      [ 290.587290] kthread+0xfc/0x130
      [ 290.587326] ? xengt_gpa_to_va+0x1f0/0x1f0 [xengt]
      [ 290.587378] ? kthread_create_on_node+0x70/0x70
      [ 290.587429] ? do_group_exit+0x3a/0xa0
      [ 290.587471] ret_from_fork+0x35/0x40
      
      Fixes: 04d348ae ("drm/i915/gvt: vGPU display virtualization")
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      2f24636b
  9. 11 4月, 2018 1 次提交
  10. 30 3月, 2018 5 次提交
  11. 28 3月, 2018 2 次提交
  12. 22 3月, 2018 1 次提交
  13. 19 3月, 2018 6 次提交
  14. 16 3月, 2018 1 次提交
  15. 15 3月, 2018 2 次提交
    • Z
      drm/i915/gvt: fix user copy warning by whitelist workload rb_tail field · 850555d1
      Zhenyu Wang 提交于
      This is to fix warning got as:
      
      [ 6730.476938] ------------[ cut here ]------------
      [ 6730.476979] Bad or missing usercopy whitelist? Kernel memory exposure attempt detected from SLAB object 'gvt-g_vgpu_workload' (offset 120, size 4)!
      [ 6730.477021] WARNING: CPU: 2 PID: 441 at mm/usercopy.c:81 usercopy_warn+0x7e/0xa0
      [ 6730.477042] Modules linked in: tun(E) bridge(E) stp(E) llc(E) kvmgt(E) x86_pkg_temp_thermal(E) vfio_mdev(E) intel_powerclamp(E) mdev(E) coretemp(E) vfio_iommu_type1(E) vfio(E) kvm_intel(E) kvm(E) hid_generic(E) irqbypass(E) crct10dif_pclmul(E) crc32_pclmul(E) usbhid(E) i915(E) crc32c_intel(E) hid(E) ghash_clmulni_intel(E) pcbc(E) aesni_intel(E) aes_x86_64(E) crypto_simd(E) cryptd(E) glue_helper(E) intel_cstate(E) idma64(E) evdev(E) virt_dma(E) iTCO_wdt(E) intel_uncore(E) intel_rapl_perf(E) intel_lpss_pci(E) sg(E) shpchp(E) mei_me(E) pcspkr(E) iTCO_vendor_support(E) intel_lpss(E) intel_pch_thermal(E) prime_numbers(E) mei(E) mfd_core(E) video(E) acpi_pad(E) button(E) binfmt_misc(E) ip_tables(E) x_tables(E) autofs4(E) ext4(E) crc16(E) mbcache(E) jbd2(E) fscrypto(E) sd_mod(E) e1000e(E) xhci_pci(E) sdhci_pci(E)
      [ 6730.477244]  ptp(E) cqhci(E) xhci_hcd(E) pps_core(E) sdhci(E) mmc_core(E) i2c_i801(E) usbcore(E) thermal(E) fan(E)
      [ 6730.477276] CPU: 2 PID: 441 Comm: gvt workload 0 Tainted: G            E    4.16.0-rc1-gvt-staging-0213+ #127
      [ 6730.477303] Hardware name:  /NUC6i5SYB, BIOS SYSKLi35.86A.0039.2016.0316.1747 03/16/2016
      [ 6730.477326] RIP: 0010:usercopy_warn+0x7e/0xa0
      [ 6730.477340] RSP: 0018:ffffba6301223d18 EFLAGS: 00010286
      [ 6730.477355] RAX: 0000000000000000 RBX: ffff8f41caae9838 RCX: 0000000000000006
      [ 6730.477375] RDX: 0000000000000007 RSI: 0000000000000082 RDI: ffff8f41dad166f0
      [ 6730.477395] RBP: 0000000000000004 R08: 0000000000000576 R09: 0000000000000000
      [ 6730.477415] R10: ffffffffb1293fb2 R11: 00000000ffffffff R12: 0000000000000001
      [ 6730.477447] R13: ffff8f41caae983c R14: ffff8f41caae9838 R15: 00007f183ca2b000
      [ 6730.477467] FS:  0000000000000000(0000) GS:ffff8f41dad00000(0000) knlGS:0000000000000000
      [ 6730.477489] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [ 6730.477506] CR2: 0000559462817291 CR3: 000000028b46c006 CR4: 00000000003626e0
      [ 6730.477526] Call Trace:
      [ 6730.477537]  __check_object_size+0x9c/0x1a0
      [ 6730.477562]  __kvm_write_guest_page+0x45/0x90 [kvm]
      [ 6730.477585]  kvm_write_guest+0x46/0x80 [kvm]
      [ 6730.477599]  kvmgt_rw_gpa+0x9b/0xf0 [kvmgt]
      [ 6730.477642]  workload_thread+0xa38/0x1040 [i915]
      [ 6730.477659]  ? do_wait_intr_irq+0xc0/0xc0
      [ 6730.477673]  ? finish_wait+0x80/0x80
      [ 6730.477707]  ? clean_workloads+0x120/0x120 [i915]
      [ 6730.477722]  kthread+0x111/0x130
      [ 6730.477733]  ? _kthread_create_worker_on_cpu+0x60/0x60
      [ 6730.477750]  ? exit_to_usermode_loop+0x6f/0xb0
      [ 6730.477766]  ret_from_fork+0x35/0x40
      [ 6730.477777] Code: 48 c7 c0 20 e3 25 b1 48 0f 44 c2 41 50 51 41 51 48 89 f9 49 89 f1 4d 89 d8 4c 89 d2 48 89 c6 48 c7 c7 78 e3 25 b1 e8 b2 bc e4 ff <0f> ff 48 83 c4 18 c3 48 c7 c6 09 d0 26 b1 49 89 f1 49 89 f3 eb
      [ 6730.477849] ---[ end trace cae869c1c323e45a ]---
      
      By whitelist guest page write from workload struct allocated from kmem cache.
      Reviewed-by: NHang Yuan <hang.yuan@linux.intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      (cherry picked from commit 5627705406874df57fdfad3b4e0c9aedd3b007df)
      850555d1
    • F
      drm/i915/gvt: Correct the privilege shadow batch buffer address · ef75c685
      fred gao 提交于
      Once the ring buffer is copied to ring_scan_buffer and scanned,
      the shadow batch buffer start address is only updated into
      ring_scan_buffer, not the real ring address allocated through
      intel_ring_begin in later copy_workload_to_ring_buffer.
      
      This patch is only to set the right shadow batch buffer address
      from Ring buffer, not include the shadow_wa_ctx.
      
      v2:
      - refine some comments. (Zhenyu)
      v3:
      - fix typo in title. (Zhenyu)
      v4:
      - remove the unnecessary comments. (Zhenyu)
      - add comments in bb_start_cmd_va update. (Zhenyu)
      
      Fixes: 0a53bc07 ("drm/i915/gvt: Separate cmd scan from request allocation")
      Cc: stable@vger.kernel.org  # v4.15
      Cc: Zhenyu Wang <zhenyuw@linux.intel.com>
      Cc: Yulei Zhang <yulei.zhang@intel.com>
      Signed-off-by: Nfred gao <fred.gao@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      ef75c685
  16. 09 3月, 2018 2 次提交
    • M
      drm/i915/gvt: keep oa config in shadow ctx · fa3dd623
      Min He 提交于
      When populating shadow ctx from guest, we should handle oa related
      registers in hw ctx, so that they will not be overlapped by guest oa
      configs. This patch made it possible to capture oa data from host for
      both host and guests.
      Signed-off-by: NMin He <min.he@intel.com>
      Signed-off-by: NZhi Wang <zhi.a.wang@intel.com>
      fa3dd623
    • X
      drm/i915/gvt: Add runtime_pm_get/put into gvt_switch_mmio · b24881e0
      Xiong Zhang 提交于
      If user continuously create vgpu, boot guest, shoutdown guest and destroy
      vgpu from remote, the following calltrace exists in dmesg sometimes:
      [ 6412.954721] RPM wakelock ref not held during HW access
      [ 6412.954795] WARNING: CPU: 7 PID: 11941 at
      linux/drivers/gpu/drm/i915/intel_drv.h:1800
      intel_uncore_forcewake_get.part.7+0x96/0xa0 [i915]
      [ 6412.954915] Call Trace:
      [ 6412.954951] intel_uncore_forcewake_get+0x18/0x20 [i915]
      [ 6412.954989] intel_gvt_switch_mmio+0x8e/0x770 [i915]
      [ 6412.954996] ? __slab_free+0x14d/0x2c0
      [ 6412.955001] ? __slab_free+0x14d/0x2c0
      [ 6412.955006] ? __slab_free+0x14d/0x2c0
      [ 6412.955041] intel_vgpu_stop_schedule+0x92/0xd0 [i915]
      [ 6412.955073] intel_gvt_deactivate_vgpu+0x48/0x60 [i915]
      [ 6412.955078] __intel_vgpu_release+0x55/0x260 [kvmgt]
      
      when this happens, gvt_switch_mmio is called at vgpu destroy, host i915 is
      idle and doesn't hold RPM wakelock, igd is in powersave mode, but
      gvt_switch_mmio require igd power on to access register, so
      intel_runtime_pm_get should be added to make sure igd power on before
      gvt_switch_mmio.
      
      v2: Move runtime_pm_get/put into gvt_switch_mmio.(Zhenyu)
      Signed-off-by: NXiong Zhang <xiong.y.zhang@intel.com>
      Signed-off-by: NZhi Wang <zhi.a.wang@intel.com>
      b24881e0
  17. 06 3月, 2018 4 次提交
    • X
      drm/i915/gvt: Return error at the failure of finding page_track · 991ecefb
      Xiong Zhang 提交于
      In XenGT, ioreq copy is used to trap mmio write and ppgtt write. Both
      of them are memory write, ioreq handler couldn't distinguish them. So
      ioreq handler probe the ppgtt write handler, if it is succuess, this
      ioreq is ppgtt write, otherwise it is mmio write.
      
      So ppgtt write handler should return an error at the failure of finding
      page track, it is fatal to implement ioreq handler in XenGT.
      Signed-off-by: NXiong Zhang <xiong.y.zhang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      991ecefb
    • X
      drm/i915/gvt: Release gvt->lock at the failure of finding page track · 7e60946f
      Xiong Zhang 提交于
      page_track_handler take lock at the beginning, the lock should be released
      at the failure of finding page track. Otherwise deadlock will happen.
      
      Fixes: e502a2af ("drm/i915/gvt: Provide generic page_track infrastructure for write-protected page")
      Signed-off-by: NXiong Zhang <xiong.y.zhang@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      7e60946f
    • C
      drm/i915/kvmgt: Add kvmgt debugfs entry nr_cache_entries under vgpu · 6846dfeb
      Changbin Du 提交于
      Add a new debugfs entry kvmgt_nr_cache_entries under vgpu which shows
      the number of entry in dma cache.
      
      $ cat /sys/kernel/debug/gvt/vgpu1/kvmgt_nr_cache_entries
      10101
      
      v3: fix compiling error for some configuration. (Xiong Zhang <xiong.y.zhang@intel.com>)
      v2: keep debugfs layout flat.
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      6846dfeb
    • C
      drm/i915/gvt: Fix guest vGPU hang caused by very high dma setup overhead · cf4ee73f
      Changbin Du 提交于
      The implementation of current kvmgt implicitly setup dma mapping at MPT
      API gfn_to_mfn. First this design against the API's original purpose.
      Second, there is no unmap hit in this design. The result is that the
      dma mapping keep growing larger and larger. For mutl-vm case, they will
      consume IOMMU IOVA low 4GB address space quickly and so tons of rbtree
      entries crated in the IOMMU IOVA allocator. Finally, single IOVA
      allocation can take as long as ~70ms. Such latency is intolerable.
      
      To address both above issues, this patch introduced two new MPT API:
        o dma_map_guest_page - setup dma map for guest page
        o dma_unmap_guest_page - cancel dma map for guest page
      
      The kvmgt implements these 2 API. And to reduce dma setup overhead for
      duplicated pages (eg. scratch pages), two caches are used: one is for
      mapping gfn to struct gvt_dma, another is for mapping dma addr to
      struct gvt_dma.
      
      With these 2 new API, the gtt now is able to cancel dma mapping when page
      table is invalidated. The dma mapping is not in a gradual increase now.
      
      v2: follow the old logic for VFIO_IOMMU_NOTIFY_DMA_UNMAP at this point.
      
      Cc: Hang Yuan <hang.yuan@intel.com>
      Cc: Xiong Zhang <xiong.y.zhang@intel.com>
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NZhenyu Wang <zhenyuw@linux.intel.com>
      cf4ee73f