05.02.2013 Views

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

ARM Architecture Reference Manual ARMv7-A and ARMv7-R edition

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Virtual Memory System <strong>Architecture</strong> (VMSA)<br />

Note<br />

This condition is consistent with the maintenance required for a Virtually Indexed Physically Tagged (VIPT)<br />

instruction cache.<br />

Software can read the Cache Type Register to determine whether the IVIPT extension is implemented, see<br />

c0, Cache Type Register (CTR) on page B3-83.<br />

Functionally, the relationship between cache type <strong>and</strong> the software management requirement depends on<br />

whether the operating system uses ASIDs to distinguish processes that use different translation tables:<br />

when ASIDs are used, management is similar for a VIPT <strong>and</strong> an ASID-tagged VIVT cache<br />

when ASIDs are not used, management is similar for a VIVT <strong>and</strong> an ASID-tagged VIVT cache.<br />

A remapping policy that supports ASID changes means that translation tables can be swapped simply by<br />

updates to the TTBR0, TTBR1 <strong>and</strong> TTBCR registers, with an appropriate change of the ASID held in the<br />

CONTEXTIDR, see Synchronization of changes of ASID <strong>and</strong> TTBR on page B3-60. Such changes are<br />

transparent to an ASID-tagged VIVT instruction cache until an ASID value is reused. In contrast, a VIVT<br />

instruction cache that is not ASID-tagged must be invalidated whenever the virtual to physical address<br />

mappings change. Therefore, such a cache must be invalidated on an ASID change.<br />

Software written to rely on a VIPT instruction cache must only be used with processors that implement the<br />

IVIPT. For maximum compatibility across processors, <strong>ARM</strong> recommends that operating systems target the<br />

<strong>ARM</strong>v7 base architecture that uses ASID-tagged VIVT instruction caches, <strong>and</strong> do not assume the presence<br />

of the IVIPT extension. Software that relies on the IVIPT extension might fail in an UNPREDICTABLE way<br />

on an <strong>ARM</strong>v7 implementation that does not include the IVIPT extension.<br />

With an instruction cache, the distinction between a VIPT cache <strong>and</strong> a PIPT cache is much less visible to<br />

the programmer than it is for a data cache, because normally the contents of an instruction cache are not<br />

changed by writing to the cached memory. However, there are situations where a program must distinguish<br />

between the different cache tagging strategies. Example B3-1 describes such a situation.<br />

Example B3-1 A situation where software must be aware of the<br />

Instruction cache tagging strategy<br />

Two processes, P1 <strong>and</strong> P2, share some code <strong>and</strong> have separate virtual mappings to the same region of<br />

instruction memory. P1 changes this region, for example as a result of a JIT, or some other self-modifying<br />

code operation. P2 needs to see the modified code.<br />

As part of its self-modifying code operation, P1 must invalidate the changed locations from the instruction<br />

cache. For more information, see Ordering of cache <strong>and</strong> branch predictor maintenance operations on<br />

page B2-21. If this invalidation is performed by MVA, <strong>and</strong> the instruction cache is a VIPT cache, then P2<br />

might continue to see the old code.<br />

In this situation, if the instruction cache is a VIPT cache, after the code modification the entire instruction<br />

cache must be invalidated to ensure P2 observes the new version of the code.<br />

B3-24 Copyright © 1996-1998, 2000, 2004-2008 <strong>ARM</strong> Limited. All rights reserved. <strong>ARM</strong> DDI 0406B

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!