From nobody Thu Jan 18 21:54:35 2024 X-Original-To: dev-commits-src-all@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 4TGGk35gqLz575LG; Thu, 18 Jan 2024 21:54:35 +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 4TGGk34tSMz4qbM; Thu, 18 Jan 2024 21:54:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705614875; 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=YWTwCnCXFf404N+hifEbavLp2IyCpus9zyjBB0g2Yoo=; b=xMArUbu/kP/Y6sI4Qfqw2NYGNRQvMC8uM1C2CN7EPYeXT9kDnmU5sYrocnu9+ZzWIqZcwv JuPTrIQcuCyihi2J5syOQQzZjSMuSsSuDTCbjLPbxACgbdANSGOCeqScCI/8KEc9fgERCf vWhqI2gcH9gHsfDRc2YZwaYD7VO6/5RGJJ8vgb3SW+Woa0pcG3n+MKuEJQZVxyDXjsrahO /wYGwpxCvNz/mNVAecJ+GNqfQcvxAVBuGgyUN6UutYEjSCYFE1v0dylcGk6JTm50syMob3 C8ilQAW71V73RKN+35atTnT0fsV/0ZER2rQWE+XGokMNyZl28LN3RKoWSSH/8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705614875; 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=YWTwCnCXFf404N+hifEbavLp2IyCpus9zyjBB0g2Yoo=; b=GPzogn6/n2m/KI99MF6R9ser+UIHBLcHxU/58y6YpOlin1gSIehk0ggR3I4tLPUbVzVWAK ZDqT0XHaYB9A+/eVpkVaab73MNoqNZpHh2kA2KyealRpJFqx6vg9Focxn2fONgLg/TKnwd 9xFVcEAnqaNlLW7z5Q298wtQJ7UzVKxtx3fdh9qJd1syPxBHFR9MjIjtSApADXhZWTfSmj +jZi5Of8wjjuvSBXZ1wNLkf9pQSrSBliRCPqNBGuikoT1WsBxmCIcXDOQAgd2PIMhj06Dr rHrugQ4t7wAN5OBAw9eQFt8HBnH02R2zOKw/Qm2YpnViX/b6n2Y72Dlhcb5TJw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705614875; a=rsa-sha256; cv=none; b=JwAJcf7JoNJ/JC1744Ym1ZF+qw4XPLZVkikvOEliqcHpiB2vqRpl3x3CNsfWcwr354i+xS zf1SjKy/7bb17yefupb4nd3Z/OtKGv3lzgiFc4N/ZEL/omL1N+KPqBnQINmyXoPr4RRKtD 33vLCJUrw3cqeDxhdDA9b1M4uI1Z+X3V1+VUK3C2ygi46XilKKTB6zNTepSt/c0pk5inVg /E3uVURq4nxsOrSOV9C6FYs+DKSia9dTRn/bcBpzvmcliwKRfFE/3eyiNRsJAA7vZiSEt0 c7pxyv4xVdiefJC5dFewyBj/h5O3b0i5R2JXjUH2IuEzKAxcz1g16cUdbvfnjw== 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 4TGGk33vQ2zPNQ; Thu, 18 Jan 2024 21:54:35 +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 40ILsZU1037059; Thu, 18 Jan 2024 21:54:35 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40ILsZcT037056; Thu, 18 Jan 2024 21:54:35 GMT (envelope-from git) Date: Thu, 18 Jan 2024 21:54:35 GMT Message-Id: <202401182154.40ILsZcT037056@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mark Johnston Subject: git: 47a6fb9d5a2e - main - mlx5: Zero DMA memory mlx5_alloc_cmd_msg() and alloc_cmd_page() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: 47a6fb9d5a2ebec12114a604053ffbd2929f0021 Auto-Submitted: auto-generated The branch main has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=47a6fb9d5a2ebec12114a604053ffbd2929f0021 commit 47a6fb9d5a2ebec12114a604053ffbd2929f0021 Author: Mark Johnston AuthorDate: 2024-01-18 21:47:52 +0000 Commit: Mark Johnston CommitDate: 2024-01-18 21:52:17 +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 --- 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: