mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
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)
This commit is contained in:
parent
14b7cf92e7
commit
d87ebf35c8
1 changed files with 8 additions and 2 deletions
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in a new issue