Definition/meaning of Aliasing? (CPU cache architectures)

wuxb picture wuxb · May 10, 2011 · Viewed 14k times · Source

I'm a little confused by the meaning of "Aliasing" between CPU-cache and Physical address. First I found It's definition on Wikipedia :

However, VIVT suffers from aliasing problems, where several different virtual addresses may refer to the same physical address. Another problem is homonyms, where the same virtual address maps to several different physical addresses.

but after a while I saw a different definition on a presentation(ppt) of DAC'05: "Energy-Efficient Physically Tagged Caches for Embedded Processors with Virtual Memory"

Cache aliasing and synonyms:

Alias: Same virtual address from different contexts mapped to different physical addresses Synonym: Different virtual address mapped to the same physical address (data sharing)

As I'm not a native speaker, I don't know which is correct, though I feel the Wiki's definition is correct.

Edit:

Concept of "aliasing" in CPU cache usually means "synonym", on the contrary is "homonym". In a more generic level, "aliasing" is "confusing" or "chaos" or something like that. So In my opinion, "aliasing" exactly means the mapping of (X->Y) is "not bijective", where

"X" = the subset of physical addresses units which has been cached. (each element is a line of byte)

"Y" = the set of valid cache lines. (elements a also "line")

Answer

user541686 picture user541686 · May 10, 2011

You'd need to learn about Virtual Memory first, but basically it's this:

  • The memory addresses your program uses aren't the physical addresses that the RAM uses; they're virtual addresses mapped to physical addresses by the CPU.

  • Multiple virtual addressses can point to the same physical address.

That means that you can have two copies of the same data in separate parts of the cache without knowing it... and they wouldn't be updated correctly, so you'd get wrong results.


Edit:

Exerpt of reference:

Cache aliasing occurs when multiple mappings to a physical page of memory have conflicting caching states, such as cached and uncached. Due to these conflicting states, data in that physical page may become corrupted when the processor's cache is flushed. If that page is being used for DMA by a driver, this can lead to hardware stability problems and system lockups.


For those who are still unconvinced:

On ARMv4 and ARMv5 processors, cache is organized as a virtual-indexed, virtual-tagged (VIVT) cache in which both the index and the tag are based on the virtual address. The main advantage of this method is that cache lookups are faster because the translation look-aside buffer (TLB) is not involved in matching cache lines for a virtual address. However, this caching method does require more frequent cache flushing because of cache aliasing, in which the same physical address can be mapped to multiple virtual addresses.