WSL2-Linux-Kernel/drivers/nvme/host
Serge Semin c94b7f9bab nvme-hwmon: kmalloc the NVME SMART log buffer
Recent commit 52fde2c07d ("nvme: set dma alignment to dword") has
caused a regression on our platform.

It turned out that the nvme_get_log() method invocation caused the
nvme_hwmon_data structure instance corruption.  In particular the
nvme_hwmon_data.ctrl pointer was overwritten either with zeros or with
garbage.  After some research we discovered that the problem happened
even before the actual NVME DMA execution, but during the buffer mapping.
Since our platform is DMA-noncoherent, the mapping implied the cache-line
invalidations or write-backs depending on the DMA-direction parameter.
In case of the NVME SMART log getting the DMA was performed
from-device-to-memory, thus the cache-invalidation was activated during
the buffer mapping.  Since the log-buffer isn't cache-line aligned, the
cache-invalidation caused the neighbour data to be discarded.  The
neighbouring data turned to be the data surrounding the buffer in the
framework of the nvme_hwmon_data structure.

In order to fix that we need to make sure that the whole log-buffer is
defined within the cache-line-aligned memory region so the
cache-invalidation procedure wouldn't involve the adjacent data. One of
the option to guarantee that is to kmalloc the DMA-buffer [1]. Seeing the
rest of the NVME core driver prefer that method it has been chosen to fix
this problem too.

Note after a deeper researches we found out that the denoted commit wasn't
a root cause of the problem. It just revealed the invalidity by activating
the DMA-based NVME SMART log getting performed in the framework of the
NVME hwmon driver. The problem was here since the initial commit of the
driver.

[1] Documentation/core-api/dma-api-howto.rst

Fixes: 400b6a7b13 ("nvme: Add hardware monitoring support")
Signed-off-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Signed-off-by: Christoph Hellwig <hch@lst.de>
2022-10-19 12:43:13 +02:00
..
Kconfig nvme-auth: Diffie-Hellman key exchange support 2022-08-02 17:14:49 -06:00
Makefile nvme: don't always build constants.o 2022-08-02 17:22:48 -06:00
apple.c nvme-apple: don't limit DMA segement size 2022-10-19 10:36:39 +02:00
auth.c nvme-auth: Diffie-Hellman key exchange support 2022-08-02 17:14:49 -06:00
constants.c nvme-pci: print the command name of aborted commands 2022-08-02 17:22:48 -06:00
core.c nvme-hwmon: consistently ignore errors from nvme_hwmon_init 2022-10-19 12:42:58 +02:00
fabrics.c nvme: consider also host_iface when checking ip options 2022-09-19 17:55:24 +02:00
fabrics.h nvme: implement In-Band authentication 2022-08-02 17:14:49 -06:00
fault_inject.c block: remove the ->rq_disk field in struct request 2021-11-29 06:41:29 -07:00
fc.c nvme-fc: use the tagset alloc/free helpers 2022-09-27 14:44:17 +02:00
fc.h
hwmon.c nvme-hwmon: kmalloc the NVME SMART log buffer 2022-10-19 12:43:13 +02:00
ioctl.c for-6.1/block-2022-10-03 2022-10-07 09:19:14 -07:00
multipath.c nvme-multipath: fix possible hang in live ns resize with ANA access 2022-10-12 11:42:58 +02:00
nvme.h for-6.1/block-2022-10-03 2022-10-07 09:19:14 -07:00
pci.c nvme-pci: disable write zeroes on various Kingston SSD 2022-10-19 10:36:39 +02:00
rdma.c nvme-rdma: fix possible hang caused during ctrl deletion 2022-10-12 11:35:46 +02:00
tcp.c nvme-tcp: fix possible hang caused during ctrl deletion 2022-10-12 11:35:46 +02:00
trace.c nvme: implement In-Band authentication 2022-08-02 17:14:49 -06:00
trace.h nvme: use command_id instead of req->tag in trace_nvme_complete_rq() 2022-08-02 17:22:46 -06:00
zns.c block: pass a gendisk to blk_queue_max_open_zones and blk_queue_max_active_zones 2022-07-06 06:46:26 -06:00