aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2023-12-18 22:45:24 +0000
committerMark Johnston <markj@FreeBSD.org>2023-12-25 16:58:19 +0000
commitdcd747fda58a4669c897822b10d4a53b802c4bb2 (patch)
tree78d8b24ce1f8f38502e232509736dc088ccd5f8f
parent2bc5d0db67e07e38f8068f062368dd1c382f236c (diff)
downloadsrc-dcd747fda58a4669c897822b10d4a53b802c4bb2.tar.gz
src-dcd747fda58a4669c897822b10d4a53b802c4bb2.zip
nvme: Initialize HMB entries before loading them into the controller
struct nvme_hmb_desc contains a pad field which was not getting initialized before being synced. This doesn't have much consequence but triggers a report from KMSAN, which verifies that host-filled DMA memory is initialized before it is made visible to the device. So, let's just initialize it properly. Reported by: KMSAN Reviewed by: mav, imp MFC after: 1 week Sponsored by: Klara, Inc. Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D43090 (cherry picked from commit d9b7301bb791faab48b6c7733c34078427b9a374)
-rw-r--r--sys/dev/nvme/nvme_ctrlr.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 3eca24f1f6a5..5a57bbbd53af 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1037,6 +1037,8 @@ again:
}
for (i = 0; i < ctrlr->hmb_nchunks; i++) {
+ memset(&ctrlr->hmb_desc_vaddr[i], 0,
+ sizeof(struct nvme_hmb_desc));
ctrlr->hmb_desc_vaddr[i].addr =
htole64(ctrlr->hmb_chunks[i].hmbc_paddr);
ctrlr->hmb_desc_vaddr[i].size = htole32(ctrlr->hmb_chunk / ctrlr->page_size);