]> www.infradead.org Git - users/dwmw2/linux.git/commit
iommu/arm-smmu-v3: Avoid memory corruption from Hisilicon MSI payloads
authorZhen Lei <thunder.leizhen@huawei.com>
Wed, 31 Oct 2018 04:02:07 +0000 (12:02 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 19:02:17 +0000 (20:02 +0100)
commite738e753a68f4909df200d1f32a33cadb5a1804b
tree338a080237f2fb0e622c30fe43e219d3dabbc0ae
parent2de23f52a08a57d91a6a38d411505ea44a61fe87
iommu/arm-smmu-v3: Avoid memory corruption from Hisilicon MSI payloads

[ Upstream commit 84a9a75774961612d0c7dd34a1777e8f98a65abd ]

The GITS_TRANSLATER MMIO doorbell register in the ITS hardware is
architected to be 4 bytes in size, yet on hi1620 and earlier, Hisilicon
have allocated the adjacent 4 bytes to carry some IMPDEF sideband
information which results in an 8-byte MSI payload being delivered when
signalling an interrupt:

MSIAddr:
 |----4bytes----|----4bytes----|
 |    MSIData   |    IMPDEF    |

This poses no problem for the ITS hardware because the adjacent 4 bytes
are reserved in the memory map. However, when delivering MSIs to memory,
as we do in the SMMUv3 driver for signalling the completion of a SYNC
command, the extended payload will corrupt the 4 bytes adjacent to the
"sync_count" member in struct arm_smmu_device. Fortunately, the current
layout allocates these bytes to padding, but this is fragile and we
should make this explicit.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com>
[will: Rewrote commit message and comment]
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/arm-smmu-v3.c