From: "Arnd Bergmann" <arnd@arndb.de>
To: "Karl Mehltretter" <kmehltretter@gmail.com>,
"Russell King" <linux@armlinux.org.uk>
Cc: "Hans Ulli Kroll" <ulli.kroll@googlemail.com>,
"Robin Murphy" <robin.murphy@arm.com>,
"Marek Szyprowski" <m.szyprowski@samsung.com>,
"Will Deacon" <will@kernel.org>, "Christoph Hellwig" <hch@lst.de>,
"Ard Biesheuvel" <ardb@kernel.org>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
"Linus Walleij" <linusw@kernel.org>
Subject: Re: [PATCH 0/2] ARM: preserve DMA_FROM_DEVICE buffer contents
Date: Thu, 10 Sep 2026 11:14:28 +0200 [thread overview]
Message-ID: <2ea28a17-f36f-4dfb-8e2a-375e7a3a4d6b@app.fastmail.com> (raw)
In-Reply-To: <20260910063620.17768-1-kmehltretter@gmail.com>
On Thu, Sep 10, 2026, at 08:36, Karl Mehltretter wrote:
> This series prevents a DMA_FROM_DEVICE map from discarding CPU-written
> buffer contents on non-coherent 32-bit ARM. It is based on
> v7.3-rc1-324-g986c24e0fe44.
>
> ARM currently invalidates these buffers before the device writes them.
> If the device writes only part of a buffer, discarded dirty cache lines
> can expose older memory contents in the untouched bytes. A stock USB
> webcam demonstrated this through usbfs. Short isochronous packets left
> gaps, and usbfs returned non-zero data to userspace from bytes it had
> cleared.
>
> arm64 changed this handoff from invalidate to clean in 2022 with commit
> c50f11c6196f ("arm64: mm: Don't invalidate FROM_DEVICE buffers at start
> of DMA transfer"). Arnd Bergmann's 2023 ARM32 cache-maintenance series
> left DMA_FROM_DEVICE preservation unresolved [1]. This series keeps the
> existing ownership hooks.
Hi Karl,
I think the main problem here is that we remain inconsistent about the
rules across CPU architectures, and changing Arm on its own does not
mean we have a solution if another architecture decides to change it
in the opposite direction at some point.
I see this as a tradeoff that can go either way:
- the current 32-bit Arm approach (also arc, hexagon, microblaze, mips,
nios2, openrisc, powerpc32, sh) is obviously faster as it avoids
the writeback, but it relies on device drivers to ensure no stale
data can leak back into userspace.
- Will's patch changed arm64 (later copied into riscv) to avoid that
risk by adding the overhead out of caution, and avoid having to
audit and fix all drivers.
Clearly the current state is suboptimal, as most drivers are shared
across architectures and should expect a clear interface. Portable
drivers now get extra overhead on arm64/riscv for doing both the
zero-pad and writeback.
If we decide to align with arm64/riscv and take your series, I think
we need two more parts:
- actually measure the performance overhead: you already did the
work to test this on three separate arm implementations but did
not share performance numbers.
Can you quantify how much this costs us on the hardware you used?
- change the remaining architectures the same way: right now, both
variants are common enough across supported embedded systems
on all architectures, but changing over arm32 means that all
only a vanishingly small set of users gets the invalidate-only
version and we're much more likely to miss future driver bugs
when driver writes assume the arm/riscv behavior is universal.
Arnd
next prev parent reply other threads:[~2026-09-10 9:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-10 6:36 [PATCH 0/2] ARM: preserve DMA_FROM_DEVICE buffer contents Karl Mehltretter
2026-09-10 6:36 ` [PATCH 1/2] ARM: dma-mapping: " Karl Mehltretter
2026-09-10 6:36 ` [PATCH 2/2] ARM: dma-mapping: flush FROM_DEVICE buffers on legacy backends Karl Mehltretter
2026-09-12 6:55 ` Karl Mehltretter
2026-09-10 6:48 ` [PATCH 0/2] ARM: preserve DMA_FROM_DEVICE buffer contents Karl Mehltretter
2026-09-10 9:14 ` Arnd Bergmann [this message]
2026-09-10 10:55 ` Will Deacon
2026-09-10 13:15 ` Arnd Bergmann
2026-09-12 6:59 ` Karl Mehltretter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2ea28a17-f36f-4dfb-8e2a-375e7a3a4d6b@app.fastmail.com \
--to=arnd@arndb.de \
--cc=ardb@kernel.org \
--cc=hch@lst.de \
--cc=kmehltretter@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=ulli.kroll@googlemail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox