OSDN Git Service

iommu/arm-smmu-v3: Ensure queue is read after updating prod pointer
authorZhou Wang <wangzhou1@hisilicon.com>
Mon, 28 Sep 2020 08:32:02 +0000 (16:32 +0800)
committerWill Deacon <will@kernel.org>
Mon, 28 Sep 2020 21:57:43 +0000 (22:57 +0100)
commita76a37777f2c936b1f046bfc0c5982c958b16bfe
treea6bf4316bf3b98330fc565fd4913d7ac076acf87
parent1226fa0e541c89af22683676b9829fce849efe31
iommu/arm-smmu-v3: Ensure queue is read after updating prod pointer

Reading the 'prod' MMIO register in order to determine whether or not
there is valid data beyond 'cons' for a given queue does not provide
sufficient dependency ordering, as the resulting access is address
dependent only on 'cons' and can therefore be speculated ahead of time,
potentially allowing stale data to be read by the CPU.

Use readl() instead of readl_relaxed() when updating the shadow copy of
the 'prod' pointer, so that all speculated memory reads from the
corresponding queue can occur only from valid slots.

Signed-off-by: Zhou Wang <wangzhou1@hisilicon.com>
Link: https://lore.kernel.org/r/1601281922-117296-1-git-send-email-wangzhou1@hisilicon.com
[will: Use readl() instead of explicit barrier. Update 'cons' side to match.]
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/barrier.h
arch/arm64/include/asm/io.h
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c