kernel_optimize_test/arch/arm64
Will Deacon 1a264b3a69 arm64: mm: Don't invalidate FROM_DEVICE buffers at start of DMA transfer
commit c50f11c6196f45c92ca48b16a5071615d4ae0572 upstream.

Invalidating the buffer memory in arch_sync_dma_for_device() for
FROM_DEVICE transfers

When using the streaming DMA API to map a buffer prior to inbound
non-coherent DMA (i.e. DMA_FROM_DEVICE), we invalidate any dirty CPU
cachelines so that they will not be written back during the transfer and
corrupt the buffer contents written by the DMA. This, however, poses two
potential problems:

  (1) If the DMA transfer does not write to every byte in the buffer,
      then the unwritten bytes will contain stale data once the transfer
      has completed.

  (2) If the buffer has a virtual alias in userspace, then stale data
      may be visible via this alias during the period between performing
      the cache invalidation and the DMA writes landing in memory.

Address both of these issues by cleaning (aka writing-back) the dirty
lines in arch_sync_dma_for_device(DMA_FROM_DEVICE) instead of discarding
them using invalidation.

Cc: Ard Biesheuvel <ardb@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Russell King <linux@armlinux.org.uk>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220606152150.GA31568@willie-the-truck
Signed-off-by: Will Deacon <will@kernel.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
Link: https://lore.kernel.org/r/20220610151228.4562-2-will@kernel.org
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-06-25 15:16:09 +02:00
..
boot arm64: dts: imx8mm-beacon: Enable RTS-CTS on UART3 2022-06-22 14:13:12 +02:00
configs arm64: defconfig: build imx-sdma as a module 2022-04-08 14:40:34 +02:00
crypto crypto: poly1305 - fix poly1305_core_setkey() declaration 2021-05-14 09:50:13 +02:00
include arm[64]/memremap: don't abuse pfn_valid() to ensure presence of linear map 2022-05-18 10:23:48 +02:00
kernel arm64: ftrace: consistently handle PLTs. 2022-06-22 14:13:17 +02:00
kvm KVM: arm64: Don't read a HW interrupt pending state in user context 2022-06-22 14:13:19 +02:00
lib arm64: clear_page() shouldn't use DC ZVA when DCZID_EL0.DZP == 1 2022-01-27 10:53:54 +01:00
mm arm64: mm: Don't invalidate FROM_DEVICE buffers at start of DMA transfer 2022-06-25 15:16:09 +02:00
net bpf, arm64: Clear prog->jited_len along prog->jited 2022-06-14 18:32:40 +02:00
xen
Kbuild
Kconfig arm64: Mitigate spectre style branch history side channels 2022-03-11 12:11:53 +01:00
Kconfig.debug arm64: remove TEXT_OFFSET randomization 2020-06-15 13:10:59 +01:00
Kconfig.platforms irqchip/exiu: Fix acknowledgment of edge triggered interrupts 2022-06-09 10:21:05 +02:00
Makefile arm64: link with -z norelro for LLD or aarch64-elf 2021-01-12 20:18:24 +01:00