Athlon/AGP issue update
Quoted 6 lines
The effect of the store is to write-allocate a cache line in the data cache and fill that cache line with data from the underlying physical memory. Because the line was write-allocated it is subsequently written back to physical memory even though the bits have not been changed by the processor.
I'm not sure if I understand you correctly:
speculative write operations always set the cache line dirty bit, even if the write operations is not executed (e.g. discarded due to a mispredicted jump)
memory mapped by GART is not cache coherent, and the write-back of the cache causes data corruptions.
Result: data corruption.
Is that correct?
Then "nopentium" only works by chance: I assume that speculative operations do not walk the page tables, thus the probability that a valid TLB entry is found for the GART mapped page is slim. But if there is an entry, then the corruption would still occur.
How could we work around it?
a) At GART mapping time, we'd have to
- flush the cache
- unmap the pte entries that point to the pages that will be mapped by GART
- create a new, uncached, ioremap mapping to the pages.
Obviously that won't work with 4 MB pages.
b) abuse highmem.
highmem memory is not mapped. If we only use highmem pages for GART, and ensure that page->virtual is 0, then we know that no valid pte points into the GART pages.
Quoted 3 lines · [email protected] said:
speculative write operations always set the cache line dirty bit,
even if the write operations is not executed (e.g. discarded due to a mispredicted jump)
How predictable is this? Dealing with non-coherent memory is perfectly normal - could we manage to work around this problem by flushing the caches when the CPU _might_ have dirtied a cache line rather than only when we know we've actually written to memory? Something like...
new.c renamed from old.c +3 -1
@@ -1,5 +1,7 @@if (condition) {writeb (); -simon_says_flush_cache_page (); } +/* Flush the cache unconditionally - a speculative write may have dirtied +the cache line even though it didn't actually happen. */ +simon_says_flush_cache_page ();
Of course, if the behaviour is completely random, and the CPU will dirty random cache lines from all over the place, even from completely unrelated code that just happens to have the 'wrong' address in a register that it doesn't actually end up dereferencing, that can never work.
--
dwmw2
From: David Woodhouse <[email protected]>
Date: Wed, 23 Jan 2002 11:44:48 +0000
Quoted 3 lines · [email protected] said:
speculative write operations always set the cache line dirty bit,
even if the write operations is not executed (e.g. discarded due to a mispredicted jump)
How predictable is this? Dealing with non-coherent memory is perfectly normal - could we manage to work around this problem by flushing the caches when the CPU _might_ have dirtied a cache line rather than only when we know we've actually written to memory? Something like...
It isn't so simple. You would have to catch every single store to every page in the 4MB mapped region that happens to contain GART mapped pages.
This isn't the way to solve this problem, trust me. :)
From: Studierende der Universitaet des Saarlandes <[email protected]>
Date: Wed, 23 Jan 2002 10:38:09 +0000
Then "nopentium" only works by chance: I assume that speculative operations do not walk the page tables, thus the probability that a valid TLB entry is found for the GART mapped page is slim. But if there is an entry, then the corruption would still occur.
This isn't true. The speculative store won't get data into the cache if there is a TLB miss.
4MB pages map the GART pages and "other stuff", ie. memory used by other subsystems, user pages and whatever else. This is the only way the bug can be thus triggered for kernel mappings, which is why turning off 4MB pages fixes this part.
The only unresolved bit is the fact that we map these GART pages cacheable into user space. That ought to cause the problem too.
Quoted 4 lines · David S. Miller
This isn't true. The speculative store won't get data into the cache if there is a TLB miss.
The Pentium III loads TLB entries speculatively, there is a Intel document how to flush tbl entries where they explicitely mention that.
Quoted 5 lines
4MB pages map the GART pages and "other stuff", ie. memory used by other subsystems, user pages and whatever else. This is the only way the bug can be thus triggered for kernel mappings, which is why turning off 4MB pages fixes this part.
We might be luky - pIII performs speculative tlb loads, and Athlon performs spurious cache line writeouts, but I don´t trust such solutions.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"David" == David S Miller <[email protected]> writes:
David> 4MB pages map the GART pages and "other stuff", ie. memory used by David> other subsystems, user pages and whatever else. This is the only David> way the bug can be thus triggered for kernel mappings, which is why David> turning off 4MB pages fixes this part.
Erm, why would the granularity of mapping matter at all ? Or, for that matter, the very existanse of address translation ?
David> The only unresolved bit is the fact that we map these GART pages David> cacheable into user space. That ought to cause the problem too.
They're mapped with 4KB pages too, right ? What makes it diferent to 4KB kernel mappings ?
From: Momchil Velikov <[email protected]>
Date: 23 Jan 2002 14:32:57 +0200
Erm, why would the granularity of mapping matter at all ?
Because on a TLB miss the speculative store would be cancelled. With 4MB pages the TLB can hit, with 4K pages it cannot.
Franks a lot,
David S. Miller
[email protected]
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"David" == David S Miller <[email protected]> writes:
David> From: Momchil Velikov <[email protected]>
David> Date: 23 Jan 2002 14:32:57 +0200
David> Erm, why would the granularity of mapping matter at all ?
David> Because on a TLB miss the speculative store would be cancelled. David> With 4MB pages the TLB can hit, with 4K pages it cannot.
Yes. But there _is_ some instruction writing into the AGP memory, and this instruction will still write there no matter what are mappings, and it can still get speculatively executed and so on, leading to the same result, no ?