1. 28 Dec, 2022 24 commits
    • Cindy Lu's avatar
      vhost_vdpa: fix the crash in unmap a large memory · e794070a
      Cindy Lu authored
      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: default avatarCindy Lu <lulu@redhat.com>
      Message-Id: <20221219073331.556140-1-lulu@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      e794070a
    • Dawei Li's avatar
      virtio: Implementing attribute show with sysfs_emit · c8e82e38
      Dawei Li authored
      Replace sprintf with sysfs_emit or its variants for their
      built-in PAGE_SIZE awareness.
      Signed-off-by: default avatarDawei Li <set_pte_at@outlook.com>
      Message-Id: <TYCP286MB23232A999FE7DBDF50BA0FAACA0F9@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      c8e82e38
    • Wei Yongjun's avatar
      virtio-crypto: fix memory leak in virtio_crypto_alg_skcipher_close_session() · b1d65f71
      Wei Yongjun authored
      '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: default avatarWei Yongjun <weiyongjun1@huawei.com>
      Message-Id: <20221114110740.537276-1-weiyongjun@huaweicloud.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarGonglei <arei.gonglei@huawei.com>
      Acked-by: zhenwei pi<pizhenwei@bytedance.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      b1d65f71
    • wangjianli's avatar
      tools/virtio: Variable type completion · a4722f64
      wangjianli authored
      Replace "unsigned" with "unsigned int"
      Signed-off-by: default avatarwangjianli <wangjianli@cdjrlc.com>
      Message-Id: <20221113070742.48271-1-wangjianli@cdjrlc.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      a4722f64
    • Stefano Garzarella's avatar
      vdpa_sim: fix vringh initialization in vdpasim_queue_ready() · 794ec498
      Stefano Garzarella authored
      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: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221110141335.62171-1-sgarzare@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Acked-by: default avatarEugenio Pérez <eperezma@redhat.com>
      794ec498
    • Angus Chen's avatar
      virtio_blk: use UINT_MAX instead of -1U · f4e468f7
      Angus Chen authored
      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: default avatarAngus Chen <angus.chen@jaguarmicro.com>
      Message-Id: <20221110030124.1986-1-angus.chen@jaguarmicro.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
      f4e468f7
    • Stefano Garzarella's avatar
      vhost-vdpa: fix an iotlb memory leak · c070c191
      Stefano Garzarella authored
      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: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109154213.146789-1-sgarzare@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      c070c191
    • Stefano Garzarella's avatar
      vhost: fix range used in translate_desc() · 98047313
      Stefano Garzarella authored
      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: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109102503.18816-3-sgarzare@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      98047313
    • Stefano Garzarella's avatar
      vringh: fix range used in iotlb_translate() · f85efa9b
      Stefano Garzarella authored
      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: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221109102503.18816-2-sgarzare@redhat.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      f85efa9b
    • Yuan Can's avatar
      vhost/vsock: Fix error handling in vhost_vsock_init() · 7a4efe18
      Yuan Can authored
      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: default avatarYuan Can <yuancan@huawei.com>
      Message-Id: <20221108101705.45981-1-yuancan@huawei.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      7a4efe18
    • ruanjinjie's avatar
      vdpa_sim: fix possible memory leak in vdpasim_net_init() and vdpasim_blk_init() · aeca7ff2
      ruanjinjie authored
      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: default avatarruanjinjie <ruanjinjie@huawei.com>
      Reviewed-by: default avatarStefano Garzarella <sgarzare@redhat.com>
      Message-Id: <20221110082348.4105476-1-ruanjinjie@huawei.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      aeca7ff2
    • Shaomin Deng's avatar
      tools: Delete the unneeded semicolon after curly braces · 75e4ab97
      Shaomin Deng authored
      Unneeded semicolon after curly braces, so delete it.
      Signed-off-by: default avatarShaomin Deng <dengshaomin@cdjrlc.com>
      Message-Id: <20221105155151.12155-1-dengshaomin@cdjrlc.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      75e4ab97
    • Angus Chen's avatar
      virtio_pci: modify ENOENT to EINVAL · b66ead2d
      Angus Chen authored
      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: default avatarAngus Chen <angus.chen@jaguarmicro.com>
      Message-Id: <20221101111655.1947-1-angus.chen@jaguarmicro.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      b66ead2d
    • Colin Ian King's avatar
      RDMA/mlx5: remove variable i · a9f0a19f
      Colin Ian King authored
      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: default avatarColin Ian King <colin.i.king@gmail.com>
      Message-Id: <20221024133756.2158497-1-colin.i.king@gmail.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      a9f0a19f
    • Shaoqin Huang's avatar
      virtio_ring: use helper function is_power_of_2() · b9d978a8
      Shaoqin Huang authored
      Use helper function is_power_of_2() to check if num is power of two.
      Minor readability improvement.
      Signed-off-by: default avatarShaoqin Huang <shaoqin.huang@intel.com>
      Message-Id: <20221021062734.228881-3-shaoqin.huang@intel.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      b9d978a8
    • Shaoqin Huang's avatar
      virtio_pci: use helper function is_power_of_2() · 34468613
      Shaoqin Huang authored
      Use helper function is_power_of_2() to check if num is power of two.
      Minor readability improvement.
      Signed-off-by: default avatarShaoqin Huang <shaoqin.huang@intel.com>
      Message-Id: <20221021062734.228881-2-shaoqin.huang@intel.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@linaro.org>
      Reviewed-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      34468613
    • Eli Cohen's avatar
      vdpa/mlx5: Avoid overwriting CVQ iotlb · 38fc462f
      Eli Cohen authored
      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: default avatarEugenio Pérez <eperezma@redhat.com>
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-6-elic@nvidia.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Acked-by: default avatarEugenio Pérez <eperezma@redhat.com>
      38fc462f
    • Eli Cohen's avatar
      vdpa/mlx5: Avoid using reslock in event_handler · 0dbc1b4a
      Eli Cohen authored
      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: default avatarEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-5-elic@nvidia.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      0dbc1b4a
    • Eli Cohen's avatar
      vdpa/mlx5: Fix wrong mac address deletion · 1ab53760
      Eli Cohen authored
      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: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-4-elic@nvidia.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      1ab53760
    • Eli Cohen's avatar
      vdpa/mlx5: Return error on vlan ctrl commands if not supported · 5aec8049
      Eli Cohen authored
      Check if VIRTIO_NET_F_CTRL_VLAN is negotiated and return error if
      control VQ command is received.
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-3-elic@nvidia.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      Acked-by: default avatarEugenio Pérez <eperezma@redhat.com>
      5aec8049
    • Eli Cohen's avatar
      vdpa/mlx5: Fix rule forwarding VLAN to TIR · a6ce72c0
      Eli Cohen authored
      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: default avatarJason Wang <jasowang@redhat.com>
      Signed-off-by: default avatarEli Cohen <elic@nvidia.com>
      Message-Id: <20221114131759.57883-2-elic@nvidia.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      a6ce72c0
    • Dmitry Fomichev's avatar
      virtio-blk: use a helper to handle request queuing errors · 258896fc
      Dmitry Fomichev authored
      Define a new helper function, virtblk_fail_to_queue(), to
      clean up the error handling code in virtio_queue_rq().
      Signed-off-by: default avatarDmitry Fomichev <dmitry.fomichev@wdc.com>
      Message-Id: <20221016034127.330942-2-dmitry.fomichev@wdc.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      258896fc
    • Ricardo Cañuelo's avatar
      tools/virtio: initialize spinlocks in vring_test.c · c262f75c
      Ricardo Cañuelo authored
      The virtio_device vqs_list spinlocks must be initialized before use to
      prevent functions that manipulate the device virtualqueues, such as
      vring_new_virtqueue(), from blocking indefinitely.
      Signed-off-by: default avatarRicardo Cañuelo <ricardo.canuelo@collabora.com>
      Message-Id: <20221012062949.1526176-1-ricardo.canuelo@collabora.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Reviewed-by: default avatarXuan Zhuo <xuanzhuo@linux.alibaba.com>
      c262f75c
    • Si-Wei Liu's avatar
      vdpa: merge functionally duplicated dev_features attributes · b9e05399
      Si-Wei Liu authored
      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: default avatarSi-Wei Liu <si-wei.liu@oracle.com>
      Message-Id: <1665422823-18364-1-git-send-email-si-wei.liu@oracle.com>
      Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
      Acked-by: default avatarJason Wang <jasowang@redhat.com>
      b9e05399
  2. 25 Dec, 2022 2 commits
    • Linus Torvalds's avatar
      Linux 6.2-rc1 · 1b929c02
      Linus Torvalds authored
      1b929c02
    • Steven Rostedt (Google)'s avatar
      treewide: Convert del_timer*() to timer_shutdown*() · 292a089d
      Steven Rostedt (Google) authored
      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: default avatarSteven 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: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      292a089d
  3. 23 Dec, 2022 14 commits
    • Linus Torvalds's avatar
      Merge tag 'spi-fix-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi · 72a85e2b
      Linus Torvalds authored
      Pull spi fix from Mark Brown:
       "One driver specific change here which handles the case where a SPI
        device for some reason tries to change the bus speed during a message
        on fsl_spi hardware, this should be very unusual"
      
      * tag 'spi-fix-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi:
        spi: fsl_spi: Don't change speed while chipselect is active
      72a85e2b
    • Linus Torvalds's avatar
      Merge tag 'regulator-fix-v6.2-rc1' of... · 0a023cbb
      Linus Torvalds authored
      Merge tag 'regulator-fix-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator
      
      Pull regulator fixes from Mark Brown:
       "Two core fixes here, one for a long standing race which some Qualcomm
        systems have started triggering with their UFS driver and another
        fixing a problem with supply lookup introduced by the fixes for devm
        related use after free issues that were introduced in this merge
        window"
      
      * tag 'regulator-fix-v6.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/regulator:
        regulator: core: fix deadlock on regulator enable
        regulator: core: Fix resolve supply lookup issue
      0a023cbb
    • Linus Torvalds's avatar
      Merge tag 'coccinelle-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux · 2c91ce92
      Linus Torvalds authored
      Pull coccicheck update from Julia Lawall:
       "Modernize use of grep in coccicheck:
      
        Use 'grep -E' instead of 'egrep'"
      
      * tag 'coccinelle-6.2' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux:
        scripts: coccicheck: use "grep -E" instead of "egrep"
      2c91ce92
    • Linus Torvalds's avatar
      Merge tag 'hardening-v6.2-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · 51094a24
      Linus Torvalds authored
      Pull kernel hardening fixes from Kees Cook:
      
       - Fix CFI failure with KASAN (Sami Tolvanen)
      
       - Fix LKDTM + CFI under GCC 7 and 8 (Kristina Martsenko)
      
       - Limit CONFIG_ZERO_CALL_USED_REGS to Clang > 15.0.6 (Nathan
         Chancellor)
      
       - Ignore "contents" argument in LoadPin's LSM hook handling
      
       - Fix paste-o in /sys/kernel/warn_count API docs
      
       - Use READ_ONCE() consistently for oops/warn limit reading
      
      * tag 'hardening-v6.2-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
        cfi: Fix CFI failure with KASAN
        exit: Use READ_ONCE() for all oops/warn limit reads
        security: Restrict CONFIG_ZERO_CALL_USED_REGS to gcc or clang > 15.0.6
        lkdtm: cfi: Make PAC test work with GCC 7 and 8
        docs: Fix path paste-o for /sys/kernel/warn_count
        LoadPin: Ignore the "contents" argument of the LSM hooks
      51094a24
    • Linus Torvalds's avatar
      Merge tag 'pstore-v6.2-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux · edb23125
      Linus Torvalds authored
      Pull pstore fixes from Kees Cook:
      
       - Switch pmsg_lock to an rt_mutex to avoid priority inversion (John
         Stultz)
      
       - Correctly assign mem_type property (Luca Stefani)
      
      * tag 'pstore-v6.2-rc1-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
        pstore: Properly assign mem_type property
        pstore: Make sure CONFIG_PSTORE_PMSG selects CONFIG_RT_MUTEXES
        pstore: Switch pmsg_lock to an rt_mutex to avoid priority inversion
      edb23125
    • Linus Torvalds's avatar
      Merge tag 'dma-mapping-2022-12-23' of git://git.infradead.org/users/hch/dma-mapping · 59d2c635
      Linus Torvalds authored
      Pull dma-mapping fixes from Christoph Hellwig:
       "Fix up the sound code to not pass __GFP_COMP to the non-coherent DMA
        allocator, as it copes with that just as badly as the coherent
        allocator, and then add a check to make sure no one passes the flag
        ever again"
      
      * tag 'dma-mapping-2022-12-23' of git://git.infradead.org/users/hch/dma-mapping:
        dma-mapping: reject GFP_COMP for noncoherent allocations
        ALSA: memalloc: don't use GFP_COMP for non-coherent dma allocations
      59d2c635
    • Linus Torvalds's avatar
      Merge tag '9p-for-6.2-rc1' of https://github.com/martinetd/linux · e3b862ed
      Linus Torvalds authored
      Pull 9p updates from Dominique Martinet:
      
       - improve p9_check_errors to check buffer size instead of msize when
         possible (e.g. not zero-copy)
      
       - some more syzbot and KCSAN fixes
      
       - minor headers include cleanup
      
      * tag '9p-for-6.2-rc1' of https://github.com/martinetd/linux:
        9p/client: fix data race on req->status
        net/9p: fix response size check in p9_check_errors()
        net/9p: distinguish zero-copy requests
        9p/xen: do not memcpy header into req->rc
        9p: set req refcount to zero to avoid uninitialized usage
        9p/net: Remove unneeded idr.h #include
        9p/fs: Remove unneeded idr.h #include
      e3b862ed
    • Linus Torvalds's avatar
      Merge tag 'sound-6.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound · a27405b2
      Linus Torvalds authored
      Pull more sound updates from Takashi Iwai:
       "A few more updates for 6.2: most of changes are about ASoC
        device-specific fixes.
      
         - Lots of ASoC Intel AVS extensions and refactoring
      
         - Quirks for ASoC Intel SOF as well as regression fixes
      
         - ASoC Mediatek and Rockchip fixes
      
         - Intel HD-audio HDMI workarounds
      
         - Usual HD- and USB-audio device-specific quirks"
      
      * tag 'sound-6.2-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (54 commits)
        ALSA: usb-audio: Add new quirk FIXED_RATE for JBL Quantum810 Wireless
        ALSA: azt3328: Remove the unused function snd_azf3328_codec_outl()
        ASoC: lochnagar: Fix unused lochnagar_of_match warning
        ASoC: Intel: Add HP Stream 8 to bytcr_rt5640.c
        ASoC: SOF: mediatek: initialize panic_info to zero
        ASoC: rt5670: Remove unbalanced pm_runtime_put()
        ASoC: Intel: bytcr_rt5640: Add quirk for the Advantech MICA-071 tablet
        ASoC: Intel: soc-acpi: update codec addr on 0C11/0C4F product
        ASoC: rockchip: spdif: Add missing clk_disable_unprepare() in rk_spdif_runtime_resume()
        ASoC: wm8994: Fix potential deadlock
        ASoC: mediatek: mt8195: add sof be ops to check audio active
        ASoC: SOF: Revert: "core: unregister clients and machine drivers in .shutdown"
        ASoC: SOF: Intel: pci-tgl: unblock S5 entry if DMA stop has failed"
        ALSA: hda/hdmi: fix stream-id config keep-alive for rt suspend
        ALSA: hda/hdmi: set default audio parameters for KAE silent-stream
        ALSA: hda/hdmi: fix i915 silent stream programming flow
        ALSA: hda: Error out if invalid stream is being setup
        ASoC: dt-bindings: fsl-sai: Reinstate i.MX93 SAI compatible string
        ASoC: soc-pcm.c: Clear DAIs parameters after stream_active is updated
        ASoC: codecs: wcd-clsh: Remove the unused function
        ...
      a27405b2
    • Linus Torvalds's avatar
      Merge tag 'drm-next-2022-12-23' of git://anongit.freedesktop.org/drm/drm · 55c7d6a9
      Linus Torvalds authored
      Pull drm fixes from Dave Airlie:
       "Holiday fixes!
      
        Two batches from amd, and one group of i915 changes.
      
        amdgpu:
         - Spelling fix
         - BO pin fix
         - Properly handle polaris 10/11 overlap asics
         - GMC9 fix
         - SR-IOV suspend fix
         - DCN 3.1.4 fix
         - KFD userptr locking fix
         - SMU13.x fixes
         - GDS/GWS/OA handling fix
         - Reserved VMID handling fixes
         - FRU EEPROM fix
         - BO validation fixes
         - Avoid large variable on the stack
         - S0ix fixes
         - SMU 13.x fixes
         - VCN fix
         - Add missing fence reference
      
        amdkfd:
         - Fix init vm error handling
         - Fix double release of compute pasid
      
        i915
         - Documentation fixes
         - OA-perf related fix
         - VLV/CHV HDMI/DP audio fix
         - Display DDI/Transcoder fix
         - Migrate fixes"
      
      * tag 'drm-next-2022-12-23' of git://anongit.freedesktop.org/drm/drm: (39 commits)
        drm/amdgpu: grab extra fence reference for drm_sched_job_add_dependency
        drm/amdgpu: enable VCN DPG for GC IP v11.0.4
        drm/amdgpu: skip mes self test after s0i3 resume for MES IP v11.0
        drm/amd/pm: correct the fan speed retrieving in PWM for some SMU13 asics
        drm/amd/pm: bump SMU13.0.0 driver_if header to version 0x34
        drm/amdgpu: skip MES for S0ix as well since it's part of GFX
        drm/amd/pm: avoid large variable on kernel stack
        drm/amdkfd: Fix double release compute pasid
        drm/amdkfd: Fix kfd_process_device_init_vm error handling
        drm/amd/pm: update SMU13.0.0 reported maximum shader clock
        drm/amd/pm: correct SMU13.0.0 pstate profiling clock settings
        drm/amd/pm: enable GPO dynamic control support for SMU13.0.7
        drm/amd/pm: enable GPO dynamic control support for SMU13.0.0
        drm/amdgpu: revert "generally allow over-commit during BO allocation"
        drm/amdgpu: Remove unnecessary domain argument
        drm/amdgpu: Fix size validation for non-exclusive domains (v4)
        drm/amdgpu: Check if fru_addr is not NULL (v2)
        drm/i915/ttm: consider CCS for backup objects
        drm/i915/migrate: fix corner case in CCS aux copying
        drm/amdgpu: rework reserved VMID handling
        ...
      55c7d6a9
    • Linus Torvalds's avatar
      Merge tag 'mips_6.2_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux · 06d65a6f
      Linus Torvalds authored
      Pull MIPS fixes from Thomas Bogendoerfer:
       "Fixes due to DT changes"
      
      * tag 'mips_6.2_1' of git://git.kernel.org/pub/scm/linux/kernel/git/mips/linux:
        MIPS: dts: bcm63268: Add missing properties to the TWD node
        MIPS: ralink: mt7621: avoid to init common ralink reset controller
      06d65a6f
    • Linus Torvalds's avatar
      Merge tag 'mm-hotfixes-stable-2022-12-22-14-34' of... · 699aee7b
      Linus Torvalds authored
      Merge tag 'mm-hotfixes-stable-2022-12-22-14-34' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
      
      Pull hotfixes from Andrew Morton:
       "Eight fixes, all cc:stable. One is for gcov and the remainder are MM"
      
      * tag 'mm-hotfixes-stable-2022-12-22-14-34' of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm:
        gcov: add support for checksum field
        test_maple_tree: add test for mas_spanning_rebalance() on insufficient data
        maple_tree: fix mas_spanning_rebalance() on insufficient data
        hugetlb: really allocate vma lock for all sharable vmas
        kmsan: export kmsan_handle_urb
        kmsan: include linux/vmalloc.h
        mm/mempolicy: fix memory leak in set_mempolicy_home_node system call
        mm, mremap: fix mremap() expanding vma with addr inside vma
      699aee7b
    • Luca Stefani's avatar
      pstore: Properly assign mem_type property · beca3e31
      Luca Stefani authored
      If mem-type is specified in the device tree
      it would end up overriding the record_size
      field instead of populating mem_type.
      
      As record_size is currently parsed after the
      improper assignment with default size 0 it
      continued to work as expected regardless of the
      value found in the device tree.
      
      Simply changing the target field of the struct
      is enough to get mem-type working as expected.
      
      Fixes: 9d843e8f ("pstore: Add mem_type property DT parsing support")
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLuca Stefani <luca@osomprivacy.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20221222131049.286288-1-luca@osomprivacy.com
      beca3e31
    • John Stultz's avatar
      pstore: Make sure CONFIG_PSTORE_PMSG selects CONFIG_RT_MUTEXES · 2f4fec59
      John Stultz authored
      In commit 76d62f24 ("pstore: Switch pmsg_lock to an rt_mutex
      to avoid priority inversion") I changed a lock to an rt_mutex.
      
      However, its possible that CONFIG_RT_MUTEXES is not enabled,
      which then results in a build failure, as the 0day bot detected:
        https://lore.kernel.org/linux-mm/202212211244.TwzWZD3H-lkp@intel.com/
      
      Thus this patch changes CONFIG_PSTORE_PMSG to select
      CONFIG_RT_MUTEXES, which ensures the build will not fail.
      
      Cc: Wei Wang <wvw@google.com>
      Cc: Midas Chien<midaschieh@google.com>
      Cc: Connor O'Brien <connoro@google.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Anton Vorontsov <anton@enomsg.org>
      Cc: Colin Cross <ccross@android.com>
      Cc: Tony Luck <tony.luck@intel.com>
      Cc: kernel test robot <lkp@intel.com>
      Cc: kernel-team@android.com
      Fixes: 76d62f24 ("pstore: Switch pmsg_lock to an rt_mutex to avoid priority inversion")
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Signed-off-by: default avatarJohn Stultz <jstultz@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20221221051855.15761-1-jstultz@google.com
      2f4fec59
    • Sami Tolvanen's avatar
      cfi: Fix CFI failure with KASAN · cf801640
      Sami Tolvanen authored
      When CFI_CLANG and KASAN are both enabled, LLVM doesn't generate a
      CFI type hash for asan.module_ctor functions in translation units
      where CFI is disabled, which leads to a CFI failure during boot when
      do_ctors calls the affected constructors:
      
        CFI failure at do_basic_setup+0x64/0x90 (target:
        asan.module_ctor+0x0/0x28; expected type: 0xa540670c)
      
      Specifically, this happens because CFI is disabled for
      kernel/cfi.c. There's no reason to keep CFI disabled here anymore, so
      fix the failure by not filtering out CC_FLAGS_CFI for the file.
      
      Note that https://reviews.llvm.org/rG3b14862f0a96 fixed the issue
      where LLVM didn't emit CFI type hashes for any sanitizer constructors,
      but now type hashes are emitted correctly for TUs that use CFI.
      
      Link: https://github.com/ClangBuiltLinux/linux/issues/1742
      Fixes: 89245600 ("cfi: Switch to -fsanitize=kcfi")
      Reported-by: default avatarMark Rutland <mark.rutland@arm.com>
      Signed-off-by: default avatarSami Tolvanen <samitolvanen@google.com>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Link: https://lore.kernel.org/r/20221222225747.3538676-1-samitolvanen@google.com
      cf801640