From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796303593; b=lgLVg5yi6NwfvlUyhECoul8S34D6duQDdJe8Edp9NIvuzgzXJiPgyLWnqPnMPlmeVwrK HbIBNk0yrtI3zSBPX/jPInfamgGa0ajr1KNozMNP12OQuul7VinQ+BuDAgbO6RtJvrM+v wDClAZiDx9SbywjvaBFSVH929BmeP3/7KGWXr2i55OcvZ9WMPEodrvVLQZBM8E9yjuaAA Muhoze3nzefOFLPsTA/WiF8GhHdgbbSWYHVF58Zti+ZDQmoGyH/QPtKxl0smCtgaqBDfm 1//nWZp++vBYsKtPrD7WSqa5acMUVUOMCWJr88CjRFP+RGkBoOfAI5+95OmaDXcKhOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796303593; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=7mDetniSQU3Sn5mP+6WqjQ0eOfF0CsaLrMKNztzEDUw=; b=xZpmlD8mkYCJSRYYTA8v1jtv4OdW1m4vD2euC9S1Vo18Bt0uALhGW3EPW9HmZdo1D1xg 9iUUwdV09Pz0UyVkNTREl9zRrEBJaaf1YuSN06x0R48RQu4VmtonwbDQYAjQCR6dvmzEJ nuSwLTVeh1lLUWEwcNAId4MkTp2PRE6WI9mE9NFzcGo0i9jcDlHbJVHozN4SZkdgMDsZW sBNxPDmVn1PHVfxUlq/PkibjppuQyStHA/3cERJpC87nFL1pekwL6CuHTgO2o3gagSR/D JjE/UQxn2myWGvEtkd7J+HPjIVTUc/Dyu+1RtToDIRKITBSA5vxYULgkVczWqmUAaCQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ot5U5Qz+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16770606A322; Thu, 3 Dec 2026 13:13:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Ot5U5Qz+ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 794771F000C1; Thu, 3 Dec 2026 13:13:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796303592; bh=7mDetniSQU3Sn5mP+6WqjQ0eOfF0CsaLrMKNztzEDUw=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Ot5U5Qz+96XnuD7/gSiXlONfTa+RKj51m7H9L71ZXKLAjyjFx6rLoFjpaETKxuDc2 xuLlvNgHWXhz1KhjdG/IPPSSDClWDGE07O94RleUzGn6daQCAnG5HdAdw5WWq2AF3l uppEQqMHOhbmc9s9UFejbAGOF+ApmgTp21KUyA2lL5jUNZamay21+lQxm8cC2mP23b 9NUb3X7ORE6afu8dpEejFGNV3rs/R3hrUMXjkh9Nc+L8NkjuziyET7Tp1wp9ky5d4z /doc/kyvu/rc7YMZa59pP79bWzGon2jebey6HpaLW3YOGAfUIfXouW/9t7hknNW6BH WhvI3amvBxJhQ== Subject: Re: [PATCH net] net/mlx5: Fix divide by zero when a function has no completion EQs From: netdev-bot+sashiko@kernel.org To: tariqt@nvidia.com Cc: andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, willemb@google.com, dtatulea@nvidia.com, gal@nvidia.com, jiri@resnulli.us, leon@kernel.org, linux-rdma@vger.kernel.org, mbloch@nvidia.com, parav@nvidia.com, saeedm@nvidia.com, shshitrit@nvidia.com, shayd@nvidia.com, yishaih@nvidia.com Date: Thu, 03 Dec 2026 13:13:10 +0000 Message-ID: <179630359095.3146.11442998864309690747@kernel.org> In-Reply-To: <20261202130435.3442321-1-tariqt@nvidia.com> References: <20261202130435.3442321-1-tariqt@nvidia.com> X-sashiko-severity: High Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 1 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The fix is incomplete: a function with zero completion EQs can still load, and the divide by zero is still reachable. - [Low] The new -EINVAL in alloc_rmap() (eq.c:933-934) does more than disable aRFS. -- net/mlx5: Fix divide by zero when a function has no completion EQs This patch adds a zero check on max_comp_eqs to the aRFS version of alloc_rmap(). The check stops a divide by zero in alloc_irq_cpu_rmap() when an administrator sets max_io_eqs to 0 and ODP is enabled. For non-SF functions, alloc_rmap() now returns -EINVAL in that case. > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c > index d11ec263d53c9..0795ee24ad7f2 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c > @@ -930,6 +930,9 @@ static int alloc_rmap(struct mlx5_core_dev *mdev) > if (mlx5_core_is_sf(mdev)) > return 0; > > + if (!eq_table->max_comp_eqs) > + return -EINVAL; [Severity: High] Does this check close the divide by zero for every function that has zero completion EQs? The check is only compiled into the CONFIG_RFS_ACCEL variant of alloc_rmap(). The other stub still accepts the zero value: #else static int alloc_rmap(struct mlx5_core_dev *mdev) { return 0; } The check also comes after the mlx5_core_is_sf() early return, so SFs never reach it, whatever the build config. With max_io_eqs=0 and CONFIG_INFINIBAND_ON_DEMAND_PAGING=y, get_num_eqs() computes max_num_eqs_24b (0 + 4) minus MLX5_MAX_ASYNC_EQS (4), which is 0. mlx5_eq_table_create() still succeeds for SFs on any build, and for PFs/VFs on CONFIG_RFS_ACCEL=n builds. The exported mlx5_comp_vectors_max() then returns 0 to callers that divide by it: drivers/vfio/pci/mlx5/cmd.c:mlx5vf_create_cq() { ... vector = raw_smp_processor_id() % mlx5_comp_vectors_max(mdev); ... } Here mdev is the PF core dev returned by mlx5_vf_get_core_dev(). This code runs when VFIO dirty page tracking starts. For example, the ECPF admin sets max_io_eqs=0 for the host PF, and the host kernel is built without CONFIG_RFS_ACCEL. The host kernel would then hit a divide error here. mlx5_ib does the same in drivers/infiniband/hw/mlx5/main.c: dev->ib_dev.num_comp_vectors = mlx5_comp_vectors_max(mdev); That value then reaches ib_cq_pool_get(), which is used by nvme-rdma, nvmet-rdma, iser, isert and srpt: vector = comp_vector_hint % num_comp_vectors; It also reaches ipoib_transport_dev_init() in legacy IPoIB: cq_attr.comp_vector = req_vec % priv->ca->num_comp_vectors; Would it be better to reject max_comp_eqs == 0 where it is set, in mlx5_eq_table_create() or get_num_eqs()? That would cover every config and every user of mlx5_comp_vectors_max(). The check in this patch only protects alloc_irq_cpu_rmap(), on aRFS builds, for non-SFs. [Severity: Low] The commit message says: Handle the zero case by returning an error for non SFs: aRFS can't function without it. This -EINVAL does more than disable aRFS. mlx5_eq_table_create() treats it as fatal and destroys the async EQs: err = alloc_rmap(dev); if (err) { mlx5_core_err(dev, "Failed to allocate rmap\n"); goto err_rmap; } mlx5_load() then aborts with "Failed to create EQs". As a result, a VF or host PF with max_io_eqs=0 no longer loads at all. Meanwhile, mlx5_devlink_port_fn_max_io_eqs_set() still accepts 0 with only an overflow check. Failing the load seems reasonable, because returning 0 here would leave max_comp_eqs == 0 visible to the mlx5_comp_vectors_max() users mentioned above. Could the commit message say that the whole function fails to load? And could the error message be more specific than "Failed to allocate rmap"? Nothing actually failed to allocate here; the real cause is the devlink max_io_eqs setting. -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202130435.3442321-1-tariqt%40nvidia.com