iommu/arm-smmu-v3: Fix big-endian CMD_SYNC writes
authorRobin Murphy <robin.murphy@arm.com>
Wed, 17 Oct 2018 20:32:58 +0000 (21:32 +0100)
committerWill Deacon <will.deacon@arm.com>
Mon, 10 Dec 2018 14:55:57 +0000 (14:55 +0000)
commit3cd508a8c1379427afb5e16c2e0a7c986d907853
treea7a484823e7c60a32358c18c03eb6b76b2235573
parent9ff01193a20d391e8dbce4403dd5ef87c7eaaca6
iommu/arm-smmu-v3: Fix big-endian CMD_SYNC writes

When we insert the sync sequence number into the CMD_SYNC.MSIData field,
we do so in CPU-native byte order, before writing out the whole command
as explicitly little-endian dwords. Thus on big-endian systems, the SMMU
will receive and write back a byteswapped version of sync_nr, which would
be perfect if it were targeting a similarly-little-endian ITS, but since
it's actually writing back to memory being polled by the CPUs, they're
going to end up seeing the wrong thing.

Since the SMMU doesn't care what the MSIData actually contains, the
minimal-overhead solution is to simply add an extra byteswap initially,
such that it then writes back the big-endian format directly.

Cc: <stable@vger.kernel.org>
Fixes: 37de98f8f1cf ("iommu/arm-smmu-v3: Use CMD_SYNC completion MSI")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
drivers/iommu/arm-smmu-v3.c