git: d9b7301bb791 - main - nvme: Initialize HMB entries before loading them into the controller

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Mon, 18 Dec 2023 22:45:56 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=d9b7301bb791faab48b6c7733c34078427b9a374

commit d9b7301bb791faab48b6c7733c34078427b9a374
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2023-12-18 22:45:24 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2023-12-18 22:45:24 +0000

    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
---
 sys/dev/nvme/nvme_ctrlr.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sys/dev/nvme/nvme_ctrlr.c b/sys/dev/nvme/nvme_ctrlr.c
index 836d13eaa16d..771e5cd1251b 100644
--- a/sys/dev/nvme/nvme_ctrlr.c
+++ b/sys/dev/nvme/nvme_ctrlr.c
@@ -1007,6 +1007,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);