1. 28 12月, 2022 21 次提交
    • C
      vhost_vdpa: fix the crash in unmap a large memory · e794070a
      Cindy Lu 提交于
      While testing in vIOMMU, sometimes Guest will unmap very large memory,
      which will cause the crash. To fix this, add a new function
      vhost_vdpa_general_unmap(). This function will only unmap the memory
      that saved in iotlb.
      
      Call Trace:
      [  647.820144] ------------[ cut here ]------------
      [  647.820848] kernel BUG at drivers/iommu/intel/iommu.c:1174!
      [  647.821486] invalid opcode: 0000 [#1] PREEMPT SMP PTI
      [  647.822082] CPU: 10 PID: 1181 Comm: qemu-system-x86 Not tainted 6.0.0-rc1home_lulu_2452_lulu7_vhost+ #62
      [  647.823139] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.15.0-29-g6a62e0cb0dfe-prebuilt.qem4
      [  647.824365] RIP: 0010:domain_unmap+0x48/0x110
      [  647.825424] Code: 48 89 fb 8d 4c f6 1e 39 c1 0f 4f c8 83 e9 0c 83 f9 3f 7f 18 48 89 e8 48 d3 e8 48 85 c0 75 59
      [  647.828064] RSP: 0018:ffffae5340c0bbf0 EFLAGS: 00010202
      [  647.828973] RAX: 0000000000000001 RBX: ffff921793d10540 RCX: 000000000000001b
      [  647.830083] RDX: 00000000080000ff RSI: 0000000000000001 RDI: ffff921793d10540
      [  647.831214] RBP: 0000000007fc0100 R08: ffffae5340c0bcd0 R09: 0000000000000003
      [  647.832388] R10: 0000007fc0100000 R11: 0000000000100000 R12: 00000000080000ff
      [  647.833668] R13: ffffae5340c0bcd0 R14: ffff921793d10590 R15: 0000008000100000
      [  647.834782] FS:  00007f772ec90640(0000) GS:ffff921ce7a80000(0000) knlGS:0000000000000000
      [  647.836004] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  647.836990] CR2: 00007f02c27a3a20 CR3: 0000000101b0c006 CR4: 0000000000372ee0
      [  647.838107] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [  647.839283] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [  647.840666] Call Trace:
      [  647.841437]  <TASK>
      [  647.842107]  intel_iommu_unmap_pages+0x93/0x140
      [  647.843112]  __iommu_unmap+0x91/0x1b0
      [  647.844003]  iommu_unmap+0x6a/0x95
      [  647.844885]  vhost_vdpa_unmap+0x1de/0x1f0 [vhost_vdpa]
      [  647.845985]  vhost_vdpa_process_iotlb_msg+0xf0/0x90b [vhost_vdpa]
      [  647.847235]  ? _raw_spin_unlock+0x15/0x30
      [  647.848181]  ? _copy_from_iter+0x8c/0x580
      [  647.849137]  vhost_chr_write_iter+0xb3/0x430 [vhost]
      [  647.850126]  vfs_write+0x1e4/0x3a0
      [  647.850897]  ksys_write+0x53/0xd0
      [  647.851688]  do_syscall_64+0x3a/0x90
      [  647.852508]  entry_SYSCALL_64_after_hwframe+0x63/0xcd
      [  647.853457] RIP: 0033:0x7f7734ef9f4f
      [  647.854408] Code: 89 54 24 18 48 89 74 24 10 89 7c 24 08 e8 29 76 f8 ff 48 8b 54 24 18 48 8b 74 24 10 41 89 c8
      [  647.857217] RSP: 002b:00007f772ec8f040 EFLAGS: 00000293 ORIG_RAX: 0000000000000001
      [  647.858486] RAX: ffffffffffffffda RBX: 00000000fef00000 RCX: 00007f7734ef9f4f
      [  647.859713] RDX: 0000000000000048 RSI: 00007f772ec8f090 RDI: 0000000000000010
      [  647.860942] RBP: 00007f772ec8f1a0 R08: 0000000000000000 R09: 0000000000000000
      [  647.862206] R10: 0000000000000001 R11: 0000000000000293 R12: 0000000000000010
      [  647.863446] R13: 0000000000000002 R14: 0000000000000000 R15: ffffffff01100000
      [  647.864692]  </TASK>
      [  647.865458] Modules linked in: rpcsec_gss_krb5 auth_rpcgss nfsv4 dns_resolver nfs lockd grace fscache netfs v]
      [  647.874688] ---[ end trace 0000000000000000 ]---
      
      Cc: stable@vger.kernel.org
      Fixes: 4c8cf318 ("vhost: introduce vDPA-based backend")
      Signed-off-by: NCindy Lu <lulu@redhat.com>
      Message-Id: <20221219073331.556140-1-lulu@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      e794070a
    • D
      virtio: Implementing attribute show with sysfs_emit · c8e82e38
      Dawei Li 提交于
      Replace sprintf with sysfs_emit or its variants for their
      built-in PAGE_SIZE awareness.
      Signed-off-by: NDawei Li <set_pte_at@outlook.com>
      Message-Id: <TYCP286MB23232A999FE7DBDF50BA0FAACA0F9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      c8e82e38
    • W
      virtio-crypto: fix memory leak in virtio_crypto_alg_skcipher_close_session() · b1d65f71
      Wei Yongjun 提交于
      'vc_ctrl_req' is alloced in virtio_crypto_alg_skcipher_close_session(),
      and should be freed in the invalid ctrl_status->status error handling
      case. Otherwise there is a memory leak.
      
      Fixes: 0756ad15 ("virtio-crypto: use private buffer for control request")
      Signed-off-by: NWei Yongjun <weiyongjun1@huawei.com>
      Message-Id: <20221114110740.537276-1-weiyongjun@huaweicloud.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NGonglei <arei.gonglei@huawei.com>
      Acked-by: zhenwei pi<pizhenwei@bytedance.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      b1d65f71
    • S
      vdpa_sim: fix vringh initialization in vdpasim_queue_ready() · 794ec498
      Stefano Garzarella 提交于
      When we initialize vringh, we should pass the features and the
      number of elements in the virtqueue negotiated with the driver,
      otherwise operations with vringh may fail.
      
      This was discovered in a case where the driver sets a number of
      elements in the virtqueue different from the value returned by
      .get_vq_num_max().
      
      In vdpasim_vq_reset() is safe to initialize the vringh with
      default values, since the virtqueue will not be used until
      vdpasim_queue_ready() is called again.
      
      Fixes: 2c53d0f6 ("vdpasim: vDPA device simulator")
      Signed-off-by: NStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221110141335.62171-1-sgarzare@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      Acked-by: NEugenio Pérez <eperezma@redhat.com>
      794ec498
    • A
      virtio_blk: use UINT_MAX instead of -1U · f4e468f7
      Angus Chen 提交于
      We use UINT_MAX to limit max_discard_sectors in virtblk_probe,
      we can use UINT_MAX to limit max_hw_sectors for consistencies.
      
      No functional change intended.
      Signed-off-by: NAngus Chen <angus.chen@jaguarmicro.com>
      Message-Id: <20221110030124.1986-1-angus.chen@jaguarmicro.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NStefan Hajnoczi <stefanha@redhat.com>
      f4e468f7
    • S
      vhost-vdpa: fix an iotlb memory leak · c070c191
      Stefano Garzarella 提交于
      Before commit 3d569879 ("vhost-vdpa: introduce asid based IOTLB")
      we called vhost_vdpa_iotlb_unmap(v, iotlb, 0ULL, 0ULL - 1) during
      release to free all the resources allocated when processing user IOTLB
      messages through vhost_vdpa_process_iotlb_update().
      That commit changed the handling of IOTLB a bit, and we accidentally
      removed some code called during the release.
      
      We partially fixed this with commit 037d4305 ("vhost-vdpa: call
      vhost_vdpa_cleanup during the release") but a potential memory leak is
      still there as showed by kmemleak if the application does not send
      VHOST_IOTLB_INVALIDATE or crashes:
      
        unreferenced object 0xffff888007fbaa30 (size 16):
          comm "blkio-bench", pid 914, jiffies 4294993521 (age 885.500s)
          hex dump (first 16 bytes):
            40 73 41 07 80 88 ff ff 00 00 00 00 00 00 00 00  @sA.............
          backtrace:
            [<0000000087736d2a>] kmem_cache_alloc_trace+0x142/0x1c0
            [<0000000060740f50>] vhost_vdpa_process_iotlb_msg+0x68c/0x901 [vhost_vdpa]
            [<0000000083e8e205>] vhost_chr_write_iter+0xc0/0x4a0 [vhost]
            [<000000008f2f414a>] vhost_vdpa_chr_write_iter+0x18/0x20 [vhost_vdpa]
            [<00000000de1cd4a0>] vfs_write+0x216/0x4b0
            [<00000000a2850200>] ksys_write+0x71/0xf0
            [<00000000de8e720b>] __x64_sys_write+0x19/0x20
            [<0000000018b12cbb>] do_syscall_64+0x3f/0x90
            [<00000000986ec465>] entry_SYSCALL_64_after_hwframe+0x63/0xcd
      
      Let's fix this calling vhost_vdpa_iotlb_unmap() on the whole range in
      vhost_vdpa_remove_as(). We move that call before vhost_dev_cleanup()
      since we need a valid v->vdev.mm in vhost_vdpa_pa_unmap().
      vhost_iotlb_reset() call can be removed, since vhost_vdpa_iotlb_unmap()
      on the whole range removes all the entries.
      
      The kmemleak log reported was observed with a vDPA device that has `use_va`
      set to true (e.g. VDUSE). This patch has been tested with both types of
      devices.
      
      Fixes: 037d4305 ("vhost-vdpa: call vhost_vdpa_cleanup during the release")
      Fixes: 3d569879 ("vhost-vdpa: introduce asid based IOTLB")
      Signed-off-by: NStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109154213.146789-1-sgarzare@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      c070c191
    • S
      vhost: fix range used in translate_desc() · 98047313
      Stefano Garzarella 提交于
      vhost_iotlb_itree_first() requires `start` and `last` parameters
      to search for a mapping that overlaps the range.
      
      In translate_desc() we cyclically call vhost_iotlb_itree_first(),
      incrementing `addr` by the amount already translated, so rightly
      we move the `start` parameter passed to vhost_iotlb_itree_first(),
      but we should hold the `last` parameter constant.
      
      Let's fix it by saving the `last` parameter value before incrementing
      `addr` in the loop.
      
      Fixes: a9709d68 ("vhost: convert pre sorted vhost memory array to interval tree")
      Acked-by: NJason Wang <jasowang@redhat.com>
      Signed-off-by: NStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109102503.18816-3-sgarzare@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      98047313
    • S
      vringh: fix range used in iotlb_translate() · f85efa9b
      Stefano Garzarella 提交于
      vhost_iotlb_itree_first() requires `start` and `last` parameters
      to search for a mapping that overlaps the range.
      
      In iotlb_translate() we cyclically call vhost_iotlb_itree_first(),
      incrementing `addr` by the amount already translated, so rightly
      we move the `start` parameter passed to vhost_iotlb_itree_first(),
      but we should hold the `last` parameter constant.
      
      Let's fix it by saving the `last` parameter value before incrementing
      `addr` in the loop.
      
      Fixes: 9ad9c49c ("vringh: IOTLB support")
      Acked-by: NJason Wang <jasowang@redhat.com>
      Signed-off-by: NStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109102503.18816-2-sgarzare@redhat.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      f85efa9b
    • Y
      vhost/vsock: Fix error handling in vhost_vsock_init() · 7a4efe18
      Yuan Can 提交于
      A problem about modprobe vhost_vsock failed is triggered with the
      following log given:
      
      modprobe: ERROR: could not insert 'vhost_vsock': Device or resource busy
      
      The reason is that vhost_vsock_init() returns misc_register() directly
      without checking its return value, if misc_register() failed, it returns
      without calling vsock_core_unregister() on vhost_transport, resulting the
      vhost_vsock can never be installed later.
      A simple call graph is shown as below:
      
       vhost_vsock_init()
         vsock_core_register() # register vhost_transport
         misc_register()
           device_create_with_groups()
             device_create_groups_vargs()
               dev = kzalloc(...) # OOM happened
         # return without unregister vhost_transport
      
      Fix by calling vsock_core_unregister() when misc_register() returns error.
      
      Fixes: 433fc58e ("VSOCK: Introduce vhost_vsock.ko")
      Signed-off-by: NYuan Can <yuancan@huawei.com>
      Message-Id: <20221108101705.45981-1-yuancan@huawei.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      7a4efe18
    • R
      vdpa_sim: fix possible memory leak in vdpasim_net_init() and vdpasim_blk_init() · aeca7ff2
      ruanjinjie 提交于
      Inject fault while probing module, if device_register() fails in
      vdpasim_net_init() or vdpasim_blk_init(), but the refcount of kobject is
      not decreased to 0, the name allocated in dev_set_name() is leaked.
      Fix this by calling put_device(), so that name can be freed in
      callback function kobject_cleanup().
      
      (vdpa_sim_net)
      unreferenced object 0xffff88807eebc370 (size 16):
        comm "modprobe", pid 3848, jiffies 4362982860 (age 18.153s)
        hex dump (first 16 bytes):
          76 64 70 61 73 69 6d 5f 6e 65 74 00 6b 6b 6b a5  vdpasim_net.kkk.
        backtrace:
          [<ffffffff8174f19e>] __kmalloc_node_track_caller+0x4e/0x150
          [<ffffffff81731d53>] kstrdup+0x33/0x60
          [<ffffffff83a5d421>] kobject_set_name_vargs+0x41/0x110
          [<ffffffff82d87aab>] dev_set_name+0xab/0xe0
          [<ffffffff82d91a23>] device_add+0xe3/0x1a80
          [<ffffffffa0270013>] 0xffffffffa0270013
          [<ffffffff81001c27>] do_one_initcall+0x87/0x2e0
          [<ffffffff813739cb>] do_init_module+0x1ab/0x640
          [<ffffffff81379d20>] load_module+0x5d00/0x77f0
          [<ffffffff8137bc40>] __do_sys_finit_module+0x110/0x1b0
          [<ffffffff83c4d505>] do_syscall_64+0x35/0x80
          [<ffffffff83e0006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      (vdpa_sim_blk)
      unreferenced object 0xffff8881070c1250 (size 16):
        comm "modprobe", pid 6844, jiffies 4364069319 (age 17.572s)
        hex dump (first 16 bytes):
          76 64 70 61 73 69 6d 5f 62 6c 6b 00 6b 6b 6b a5  vdpasim_blk.kkk.
        backtrace:
          [<ffffffff8174f19e>] __kmalloc_node_track_caller+0x4e/0x150
          [<ffffffff81731d53>] kstrdup+0x33/0x60
          [<ffffffff83a5d421>] kobject_set_name_vargs+0x41/0x110
          [<ffffffff82d87aab>] dev_set_name+0xab/0xe0
          [<ffffffff82d91a23>] device_add+0xe3/0x1a80
          [<ffffffffa0220013>] 0xffffffffa0220013
          [<ffffffff81001c27>] do_one_initcall+0x87/0x2e0
          [<ffffffff813739cb>] do_init_module+0x1ab/0x640
          [<ffffffff81379d20>] load_module+0x5d00/0x77f0
          [<ffffffff8137bc40>] __do_sys_finit_module+0x110/0x1b0
          [<ffffffff83c4d505>] do_syscall_64+0x35/0x80
          [<ffffffff83e0006a>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
      
      Fixes: 899c4d18 ("vdpa_sim_blk: add support for vdpa management tool")
      Fixes: a3c06ae1 ("vdpa_sim_net: Add support for user supported devices")
      Signed-off-by: Nruanjinjie <ruanjinjie@huawei.com>
      Reviewed-by: NStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221110082348.4105476-1-ruanjinjie@huawei.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      aeca7ff2
    • A
      virtio_pci: modify ENOENT to EINVAL · b66ead2d
      Angus Chen 提交于
      Virtio_crypto use max_data_queues+1 to setup vqs,
      we use vp_modern_get_num_queues to protect the vq range in setup_vq.
      We could enter index >= vp_modern_get_num_queues(mdev) in setup_vq
      if common->num_queues is not set well,and it return -ENOENT.
      It is better to use -EINVAL instead.
      Signed-off-by: NAngus Chen <angus.chen@jaguarmicro.com>
      Message-Id: <20221101111655.1947-1-angus.chen@jaguarmicro.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      b66ead2d
    • C
      RDMA/mlx5: remove variable i · a9f0a19f
      Colin Ian King 提交于
      Variable i is just being incremented and it's never used
      anywhere else. The variable and the increment are redundant so
      remove it.
      Signed-off-by: NColin Ian King <colin.i.king@gmail.com>
      Message-Id: <20221024133756.2158497-1-colin.i.king@gmail.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      a9f0a19f
    • S
      virtio_ring: use helper function is_power_of_2() · b9d978a8
      Shaoqin Huang 提交于
      Use helper function is_power_of_2() to check if num is power of two.
      Minor readability improvement.
      Signed-off-by: NShaoqin Huang <shaoqin.huang@intel.com>
      Message-Id: <20221021062734.228881-3-shaoqin.huang@intel.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NXuan Zhuo <xuanzhuo@linux.alibaba.com>
      b9d978a8
    • S
      virtio_pci: use helper function is_power_of_2() · 34468613
      Shaoqin Huang 提交于
      Use helper function is_power_of_2() to check if num is power of two.
      Minor readability improvement.
      Signed-off-by: NShaoqin Huang <shaoqin.huang@intel.com>
      Message-Id: <20221021062734.228881-2-shaoqin.huang@intel.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: NPhilippe Mathieu-Daudé <philmd@linaro.org>
      Reviewed-by: NXuan Zhuo <xuanzhuo@linux.alibaba.com>
      34468613
    • E
      vdpa/mlx5: Avoid overwriting CVQ iotlb · 38fc462f
      Eli Cohen 提交于
      When qemu uses different address spaces for data and control virtqueues,
      the current code would overwrite the control virtqueue iotlb through the
      dup_iotlb call. Fix this by referring to the address space identifier
      and the group to asid mapping to determine which mapping needs to be
      updated. We also move the address space logic from mlx5 net to core
      directory.
      Reported-by: NEugenio Pérez <eperezma@redhat.com>
      Signed-off-by: NEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-6-elic@nvidia.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      Acked-by: NEugenio Pérez <eperezma@redhat.com>
      38fc462f
    • E
      vdpa/mlx5: Avoid using reslock in event_handler · 0dbc1b4a
      Eli Cohen 提交于
      event_handler runs under atomic context and may not acquire reslock. We
      can still guarantee that the handler won't be called after suspend by
      clearing nb_registered, unregistering the handler and flushing the
      workqueue.
      Signed-off-by: NEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-5-elic@nvidia.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      0dbc1b4a
    • E
      vdpa/mlx5: Fix wrong mac address deletion · 1ab53760
      Eli Cohen 提交于
      Delete the old MAC from the table and not the new one which is not there
      yet.
      
      Fixes: baf2ad3f ("vdpa/mlx5: Add RX MAC VLAN filter support")
      Acked-by: NJason Wang <jasowang@redhat.com>
      Signed-off-by: NEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-4-elic@nvidia.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      1ab53760
    • E
      vdpa/mlx5: Return error on vlan ctrl commands if not supported · 5aec8049
      Eli Cohen 提交于
      Check if VIRTIO_NET_F_CTRL_VLAN is negotiated and return error if
      control VQ command is received.
      Signed-off-by: NEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-3-elic@nvidia.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      Acked-by: NEugenio Pérez <eperezma@redhat.com>
      5aec8049
    • E
      vdpa/mlx5: Fix rule forwarding VLAN to TIR · a6ce72c0
      Eli Cohen 提交于
      Set the VLAN id to the header values field instead of overwriting the
      headers criteria field.
      
      Before this fix, VLAN filtering would not really work and tagged packets
      would be forwarded unfiltered to the TIR.
      
      Fixes: baf2ad3f ("vdpa/mlx5: Add RX MAC VLAN filter support")
      Acked-by: NJason Wang <jasowang@redhat.com>
      Signed-off-by: NEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-2-elic@nvidia.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      a6ce72c0
    • D
      virtio-blk: use a helper to handle request queuing errors · 258896fc
      Dmitry Fomichev 提交于
      Define a new helper function, virtblk_fail_to_queue(), to
      clean up the error handling code in virtio_queue_rq().
      Signed-off-by: NDmitry Fomichev <dmitry.fomichev@wdc.com>
      Message-Id: <20221016034127.330942-2-dmitry.fomichev@wdc.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      258896fc
    • S
      vdpa: merge functionally duplicated dev_features attributes · b9e05399
      Si-Wei Liu 提交于
      We can merge VDPA_ATTR_VDPA_DEV_SUPPORTED_FEATURES with
      VDPA_ATTR_DEV_FEATURES which is functionally equivalent.
      While at it, tweak the comment in header file to make
      user provioned device features distinguished from those
      supported by the parent mgmtdev device: the former of
      which can be inherited as a whole from the latter, or
      can be a subset of the latter if explicitly specified.
      Signed-off-by: NSi-Wei Liu <si-wei.liu@oracle.com>
      Message-Id: <1665422823-18364-1-git-send-email-si-wei.liu@oracle.com>
      Signed-off-by: NMichael S. Tsirkin <mst@redhat.com>
      Acked-by: NJason Wang <jasowang@redhat.com>
      b9e05399
  2. 26 12月, 2022 1 次提交
    • S
      treewide: Convert del_timer*() to timer_shutdown*() · 292a089d
      Steven Rostedt (Google) 提交于
      Due to several bugs caused by timers being re-armed after they are
      shutdown and just before they are freed, a new state of timers was added
      called "shutdown".  After a timer is set to this state, then it can no
      longer be re-armed.
      
      The following script was run to find all the trivial locations where
      del_timer() or del_timer_sync() is called in the same function that the
      object holding the timer is freed.  It also ignores any locations where
      the timer->function is modified between the del_timer*() and the free(),
      as that is not considered a "trivial" case.
      
      This was created by using a coccinelle script and the following
      commands:
      
          $ cat timer.cocci
          @@
          expression ptr, slab;
          identifier timer, rfield;
          @@
          (
          -       del_timer(&ptr->timer);
          +       timer_shutdown(&ptr->timer);
          |
          -       del_timer_sync(&ptr->timer);
          +       timer_shutdown_sync(&ptr->timer);
          )
            ... when strict
                when != ptr->timer
          (
                  kfree_rcu(ptr, rfield);
          |
                  kmem_cache_free(slab, ptr);
          |
                  kfree(ptr);
          )
      
          $ spatch timer.cocci . > /tmp/t.patch
          $ patch -p1 < /tmp/t.patch
      
      Link: https://lore.kernel.org/lkml/20221123201306.823305113@linutronix.de/Signed-off-by: NSteven Rostedt (Google) <rostedt@goodmis.org>
      Acked-by: Pavel Machek <pavel@ucw.cz> [ LED ]
      Acked-by: Kalle Valo <kvalo@kernel.org> [ wireless ]
      Acked-by: Paolo Abeni <pabeni@redhat.com> [ networking ]
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      292a089d
  3. 22 12月, 2022 2 次提交
  4. 21 12月, 2022 8 次提交
    • W
      net: fec: check the return value of build_skb() · 19e72b06
      Wei Fang 提交于
      The build_skb might return a null pointer but there is no check on the
      return value in the fec_enet_rx_queue(). So a null pointer dereference
      might occur. To avoid this, we check the return value of build_skb. If
      the return value is a null pointer, the driver will recycle the page and
      update the statistic of ndev. Then jump to rx_processing_done to clear
      the status flags of the BD so that the hardware can recycle the BD.
      
      Fixes: 95698ff6 ("net: fec: using page pool to manage RX buffers")
      Signed-off-by: NWei Fang <wei.fang@nxp.com>
      Reviewed-by: NShenwei Wang <Shenwei.wang@nxp.com>
      Reviewed-by: NAlexander Duyck <alexanderduyck@fb.com>
      Link: https://lore.kernel.org/r/20221219022755.1047573-1-wei.fang@nxp.comSigned-off-by: NJakub Kicinski <kuba@kernel.org>
      19e72b06
    • T
      drm/amdgpu: skip mes self test after s0i3 resume for MES IP v11.0 · 8660495a
      Tim Huang 提交于
      MES is part of gfxoff and MES suspend and resume are skipped for S0i3.
      But the mes_self_test call path is still in the amdgpu_device_ip_late_init.
      it's should also be skipped for s0ix as no hardware re-initialization
      happened.
      
      Besides, mes_self_test will free the BO that triggers a lot of warning
      messages while in the suspend state.
      
      [   81.656085] WARNING: CPU: 2 PID: 1550 at drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:425 amdgpu_bo_free_kernel+0xfc/0x110 [amdgpu]
      [   81.679435] Call Trace:
      [   81.679726]  <TASK>
      [   81.679981]  amdgpu_mes_remove_hw_queue+0x17a/0x230 [amdgpu]
      [   81.680857]  amdgpu_mes_self_test+0x390/0x430 [amdgpu]
      [   81.681665]  mes_v11_0_late_init+0x37/0x50 [amdgpu]
      [   81.682423]  amdgpu_device_ip_late_init+0x53/0x280 [amdgpu]
      [   81.683257]  amdgpu_device_resume+0xae/0x2a0 [amdgpu]
      [   81.684043]  amdgpu_pmops_resume+0x37/0x70 [amdgpu]
      [   81.684818]  pci_pm_resume+0x5c/0xa0
      [   81.685247]  ? pci_pm_thaw+0x90/0x90
      [   81.685658]  dpm_run_callback+0x4e/0x160
      [   81.686110]  device_resume+0xad/0x210
      [   81.686529]  async_resume+0x1e/0x40
      [   81.686931]  async_run_entry_fn+0x33/0x120
      [   81.687405]  process_one_work+0x21d/0x3f0
      [   81.687869]  worker_thread+0x4a/0x3c0
      [   81.688293]  ? process_one_work+0x3f0/0x3f0
      [   81.688777]  kthread+0xff/0x130
      [   81.689157]  ? kthread_complete_and_exit+0x20/0x20
      [   81.689707]  ret_from_fork+0x22/0x30
      [   81.690118]  </TASK>
      [   81.690380] ---[ end trace 0000000000000000 ]---
      
      v2: make the comment clean and use adev->in_s0ix instead of
      adev->suspend
      Signed-off-by: NTim Huang <tim.huang@amd.com>
      Reviewed-by: NMario Limonciello <mario.limonciello@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org # 6.0, 6.1
      8660495a
    • E
      drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics · e73fc71e
      Evan Quan 提交于
      For SMU 13.0.0 and 13.0.7, the output from PMFW is in percent. Driver
      need to convert that into correct PMW(255) based.
      Signed-off-by: NEvan Quan <evan.quan@amd.com>
      Acked-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org # 6.0, 6.1
      e73fc71e
    • E
      drm/amd/pm: bump SMU13.0.0 driver_if header to version 0x34 · 272b9814
      Evan Quan 提交于
      To fit the latest PMFW and suppress the warning emerged on driver loading.
      Signed-off-by: NEvan Quan <evan.quan@amd.com>
      Acked-by: NAlex Deucher <alexander.deucher@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      Cc: stable@vger.kernel.org # 6.0, 6.1
      272b9814
    • A
      drm/amdgpu: skip MES for S0ix as well since it's part of GFX · afa6646b
      Alex Deucher 提交于
      It's also part of gfxoff.
      
      Cc: stable@vger.kernel.org # 6.0, 6.1
      Reviewed-by: NMario Limonciello <mario.limonciello@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      afa6646b
    • A
      drm/amd/pm: avoid large variable on kernel stack · d118b18f
      Arnd Bergmann 提交于
      The activity_monitor_external[] array is too big to fit on the
      kernel stack, resulting in this warning with clang:
      
      drivers/gpu/drm/amd/amdgpu/../pm/swsmu/smu13/smu_v13_0_7_ppt.c:1438:12: error: stack frame size (1040) exceeds limit (1024) in 'smu_v13_0_7_get_power_profile_mode' [-Werror,-Wframe-larger-than]
      
      Use dynamic allocation instead. It should also be possible to
      have single element here instead of the array, but this seems
      easier.
      
      v2: fix up argument to sizeof() (Alex)
      
      Fixes: 334682ae ("drm/amd/pm: enable workload type change on smu_v13_0_7")
      Signed-off-by: NArnd Bergmann <arnd@arndb.de>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      d118b18f
    • P
      drm/amdkfd: Fix double release compute pasid · 1a799c4c
      Philip Yang 提交于
      If kfd_process_device_init_vm returns failure after vm is converted to
      compute vm and vm->pasid set to compute pasid, KFD will not take
      pdd->drm_file reference. As a result, drm close file handler maybe
      called to release the compute pasid before KFD process destroy worker to
      release the same pasid and set vm->pasid to zero, this generates below
      WARNING backtrace and NULL pointer access.
      
      Add helper amdgpu_amdkfd_gpuvm_set_vm_pasid and call it at the last step
      of kfd_process_device_init_vm, to ensure vm pasid is the original pasid
      if acquiring vm failed or is the compute pasid with pdd->drm_file
      reference taken to avoid double release same pasid.
      
       amdgpu: Failed to create process VM object
       ida_free called for id=32770 which is not allocated.
       WARNING: CPU: 57 PID: 72542 at ../lib/idr.c:522 ida_free+0x96/0x140
       RIP: 0010:ida_free+0x96/0x140
       Call Trace:
        amdgpu_pasid_free_delayed+0xe1/0x2a0 [amdgpu]
        amdgpu_driver_postclose_kms+0x2d8/0x340 [amdgpu]
        drm_file_free.part.13+0x216/0x270 [drm]
        drm_close_helper.isra.14+0x60/0x70 [drm]
        drm_release+0x6e/0xf0 [drm]
        __fput+0xcc/0x280
        ____fput+0xe/0x20
        task_work_run+0x96/0xc0
        do_exit+0x3d0/0xc10
      
       BUG: kernel NULL pointer dereference, address: 0000000000000000
       RIP: 0010:ida_free+0x76/0x140
       Call Trace:
        amdgpu_pasid_free_delayed+0xe1/0x2a0 [amdgpu]
        amdgpu_driver_postclose_kms+0x2d8/0x340 [amdgpu]
        drm_file_free.part.13+0x216/0x270 [drm]
        drm_close_helper.isra.14+0x60/0x70 [drm]
        drm_release+0x6e/0xf0 [drm]
        __fput+0xcc/0x280
        ____fput+0xe/0x20
        task_work_run+0x96/0xc0
        do_exit+0x3d0/0xc10
      Signed-off-by: NPhilip Yang <Philip.Yang@amd.com>
      Reviewed-by: NFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      1a799c4c
    • P
      drm/amdkfd: Fix kfd_process_device_init_vm error handling · 29d48b87
      Philip Yang 提交于
      Should only destroy the ib_mem and let process cleanup worker to free
      the outstanding BOs. Reset the pointer in pdd->qpd structure, to avoid
      NULL pointer access in process destroy worker.
      
       BUG: kernel NULL pointer dereference, address: 0000000000000010
       Call Trace:
        amdgpu_amdkfd_gpuvm_unmap_gtt_bo_from_kernel+0x46/0xb0 [amdgpu]
        kfd_process_device_destroy_cwsr_dgpu+0x40/0x70 [amdgpu]
        kfd_process_destroy_pdds+0x71/0x190 [amdgpu]
        kfd_process_wq_release+0x2a2/0x3b0 [amdgpu]
        process_one_work+0x2a1/0x600
        worker_thread+0x39/0x3d0
      Signed-off-by: NPhilip Yang <Philip.Yang@amd.com>
      Reviewed-by: NFelix Kuehling <Felix.Kuehling@amd.com>
      Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
      29d48b87
  5. 20 12月, 2022 8 次提交