linux-stable/drivers/scsi/pm8001
John Garry 2fe2434392 scsi: pm8001: Fix phys_to_virt() usage on dma_addr_t
The driver supports a "direct" mode of operation, where the SMP req frame
is directly copied into the command payload (and vice-versa for the SMP
resp).

To get at the SMP req frame data in the scatterlist the driver uses
phys_to_virt() on the DMA mapped memory dma_addr_t . This is broken, and
subsequently crashes as follows when an IOMMU is enabled:

 Unable to handle kernel paging request at virtual address
ffff0000fcebfb00
	...
 pc : pm80xx_chip_smp_req+0x2d0/0x3d0
 lr : pm80xx_chip_smp_req+0xac/0x3d0
 pm80xx_chip_smp_req+0x2d0/0x3d0
 pm8001_task_exec.constprop.0+0x368/0x520
 pm8001_queue_command+0x1c/0x30
 smp_execute_task_sg+0xdc/0x204
 sas_discover_expander.part.0+0xac/0x6cc
 sas_discover_root_expander+0x8c/0x150
 sas_discover_domain+0x3ac/0x6a0
 process_one_work+0x1d0/0x354
 worker_thread+0x13c/0x470
 kthread+0x17c/0x190
 ret_from_fork+0x10/0x20
 Code: 371806e1 910006d6 6b16033f 54000249 (38766b05)
 ---[ end trace b91d59aaee98ea2d ]---
note: kworker/u192:0[7] exited with preempt_count 1

Instead use kmap_atomic().

--
Difference to v1:
- use kmap_atomic() in both locations
Difference to  v2:
- add whitespace around arithmetic (Damien)

Link: https://lore.kernel.org/r/1639390248-213603-1-git-send-email-john.garry@huawei.com
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2021-12-13 23:19:58 -05:00
..
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pm80xx_hwi.c scsi: pm8001: Fix phys_to_virt() usage on dma_addr_t 2021-12-13 23:19:58 -05:00
pm80xx_hwi.h scsi: pm80xx: Completing pending I/O after fatal error 2021-04-15 22:28:59 -04:00
pm8001_chips.h
pm8001_ctl.c scsi: pm8001: Switch to attribute groups 2021-10-16 21:45:58 -04:00
pm8001_ctl.h scsi: pm8001: Clean up white space 2021-04-12 23:21:26 -04:00
pm8001_defs.h scsi: pm80xx: Increase the number of outstanding I/O supported to 1024 2020-10-07 23:50:04 -04:00
pm8001_hwi.c scsi: pm80xx: Fix misleading log statement in pm8001_mpi_get_nvmd_resp() 2021-10-04 23:31:22 -04:00
pm8001_hwi.h scsi: pm80xx: Completing pending I/O after fatal error 2021-04-15 22:28:59 -04:00
pm8001_init.c scsi: pm80xx: Do not call scsi_remove_host() in pm8001_alloc() 2021-12-02 21:40:12 -05:00
pm8001_sas.c scsi: pm80xx: Fix incorrect port value when registering a device 2021-09-14 22:29:11 -04:00
pm8001_sas.h scsi: pm8001: Switch to attribute groups 2021-10-16 21:45:58 -04:00