Re: [PATCH] mm/filemap: Implement fast short reads
From: David Hildenbrand
Date: Thu Oct 23 2025 - 08:08:47 EST
On 23.10.25 13:09, Kiryl Shutsemau wrote:
On Thu, Oct 23, 2025 at 12:54:59PM +0200, David Hildenbrand wrote:
On 23.10.25 12:31, Kiryl Shutsemau wrote:
On Wed, Oct 22, 2025 at 07:28:27PM +0200, David Hildenbrand wrote:
"garbage" as in pointing at something without a direct map, something that's
protected differently (MTE? weird CoCo protection?) or even worse MMIO with
undesired read-effects.
Pedro already points to the problem with missing direct mapping.
_nofault() copy should help with this.
Yeah, we do something similar when reading the kcore for that reason.
Can direct mapping ever be converted to MMIO? It can be converted to DMA
buffer (which is fine), but MMIO? I have not seen it even in virtualized
environments.
I recall discussions in the context of PAT and the adjustment of caching
attributes of the direct map for MMIO purposes: so I suspect there are ways
that can happen, but I am not 100% sure.
Thinking about it, in VMs we have the direct map set on balloon inflated
pages that should not be touched, not even read, otherwise your hypervisor
might get very angry. That case we could likely handle by checking whether
the source page actually exists and doesn't have PageOffline() set, before
accessing it. A bit nasty.
A more obscure cases would probably be reading a page that was poisoned by
hardware and is not expected to be used anymore. Could also be checked by
checking the page.
I don't think we can check the page. Since the page is not stabilized
with a reference, it is TOCTOU race.
Indeed :(
--
Cheers
David / dhildenb