From nobody Thu Feb 1 14:02:57 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TQgbP6PNdz58j7F; Thu, 1 Feb 2024 14:02:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TQgbP5s8yz4f4W; Thu, 1 Feb 2024 14:02:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706796177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rrIXF4xainR631Tcu2vGApvSgJJHwWo2Y3l9IwXhmOo=; b=nMm+VW0UFKVZrR1rmjJYAlFjbLzHyzdqEJcR2x/j+C8mWMtcjx6vD3GAE3I/qeHA/CvslE FM/NtrGi6cXOTSXVq6ZJR5fvVXQx6O8TLW3embyzuyUpm44E/3ANGtjXVfqkXUPgrK+MJv aAWMRa8eejK1R6QvihlV8zG+gcsrWYbcVxfbnngHej5FWu3A7M6i2urykjdbHNT1WMUsnJ DIVxFkCjZuiBQXnEEw23mQJphtJCdjFQ3e/v0Frfk7wUD8AB1NyrrLYAtopaAP8ePLF+2x 5ZicF5kG7BdFcpy/jwjdJ2i+wW86irMeBcI247PJ0wzNzfd+BlZpVdQiYtGl3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1706796177; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=rrIXF4xainR631Tcu2vGApvSgJJHwWo2Y3l9IwXhmOo=; b=Ri8PklFA8drqAh5D71pq146mi/Neao3gfRRDH0gsuRKOypxi306SPOK4NWFITOBL0bZkr1 HK9eTBtvJFga5FtfOvEPMREQQaA1Zh023/B2tT+lN2pZ6bI9EXMSxcRXkQBbciHJfKue5i y7rwUuJ2nw+G3lRj0RLt0+nKfjAPi93PiE4HQMHur2xAcZqdeCUDhnTIG2Z0aLhfYS/Q1l 7UwXG/q6QSqyj+TkhCdU9KG15yFsFPldgpxZK3g8U2qfG4krvfaYrFWggskE2skejWObpe 60vUcKWBqWk3J422Zj9Dl4N+O+dxJFKWiOqVOwYZpjBvxbeqsBovdAasv5dcQA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1706796177; a=rsa-sha256; cv=none; b=V+BPh9gCjOncWleq9dyD2vuR/ftgZUX2PhqDNoY0a2/ZYLQjvrJVueq03V+FfEIXduLUG2 h7reXtMJZx0cK6S5mz6BZaO2wv0GJ2ts4gs0spM02h0hukCCg72IKpheOxLzsaLeOvE4GY SGLFNoEJ46nLoyQCKquAZ6xpXxT0E14bK91V2HambIXp7VxtMytOtYD9beb2qzVbFAhZJo ykp2mElLZ5N70U7XWk4DIWKLlhlPEYkD3qFifOKgtP3FQ09DKOR0IB7oY1oqwIqE8n6+ve ko3B4fgvkY4950SEfZP1KKKBSXlU/boPxSPGsEFgoi6n6bnFcrkp3w9OUMo3og== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TQgbP4wHWz155k; Thu, 1 Feb 2024 14:02:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 411E2vB5030022; Thu, 1 Feb 2024 14:02:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 411E2v4o030019; Thu, 1 Feb 2024 14:02:57 GMT (envelope-from git) Date: Thu, 1 Feb 2024 14:02:57 GMT Message-Id: <202402011402.411E2v4o030019@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: d87ebf35c828 - stable/14 - mlx5: Zero DMA memory mlx5_alloc_cmd_msg() and alloc_cmd_page() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: d87ebf35c82843874e2b84e454ba4fbcea4b16b7 Auto-Submitted: auto-generated The branch stable/14 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=d87ebf35c82843874e2b84e454ba4fbcea4b16b7 commit d87ebf35c82843874e2b84e454ba4fbcea4b16b7 Author: Mark Johnston AuthorDate: 2024-01-18 21:47:52 +0000 Commit: Mark Johnston CommitDate: 2024-02-01 14:02:48 +0000 mlx5: Zero DMA memory mlx5_alloc_cmd_msg() and alloc_cmd_page() These functions may map more memory for DMA than is actually used, since the allocator operates on multiples of a 4KB page size. Thus, bus_dmamap_sync() can trigger KMSAN reports when the unused portion of a page is not zero-ed. Reported by: KMSAN Reviewed by: kib MFC after: 2 weeks Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D43133 (cherry picked from commit 47a6fb9d5a2ebec12114a604053ffbd2929f0021) --- sys/dev/mlx5/mlx5_core/mlx5_cmd.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sys/dev/mlx5/mlx5_core/mlx5_cmd.c b/sys/dev/mlx5/mlx5_core/mlx5_cmd.c index 721b27b9120c..d46feb4b9e5b 100644 --- a/sys/dev/mlx5/mlx5_core/mlx5_cmd.c +++ b/sys/dev/mlx5/mlx5_core/mlx5_cmd.c @@ -1113,11 +1113,16 @@ mlx5_alloc_cmd_msg(struct mlx5_core_dev *dev, gfp_t flags, size_t size) block = mlx5_fwp_get_virt(msg, i * MLX5_CMD_MBOX_SIZE); - memset(block, 0, MLX5_CMD_MBOX_SIZE); - if (i != (n - 1)) { + memset(block, 0, MLX5_CMD_MBOX_SIZE); + u64 dma = mlx5_fwp_get_dma(msg, (i + 1) * MLX5_CMD_MBOX_SIZE); block->next = cpu_to_be64(dma); + } else { + /* Zero the rest of the page to satisfy KMSAN. */ + memset(block, 0, MLX5_ADAPTER_PAGE_SIZE - + (i % MLX5_NUM_CMDS_IN_ADAPTER_PAGE) * + MLX5_CMD_MBOX_SIZE); } block->block_num = cpu_to_be32(i); } @@ -1508,6 +1513,7 @@ alloc_cmd_page(struct mlx5_core_dev *dev, struct mlx5_cmd *cmd) } cmd->dma = mlx5_fwp_get_dma(cmd->cmd_page, 0); cmd->cmd_buf = mlx5_fwp_get_virt(cmd->cmd_page, 0); + memset(cmd->cmd_buf, 0, MLX5_ADAPTER_PAGE_SIZE); return (0); failure_alloc_page: