ARM uses the terms flush and clean to denote two basic operations on the cache

from:https://blog.csdn.net/arriod/article/details/2826959 

Clearing the cache means clearing all data stored in the cache. As far as the processor is concerned, the flush operation only needs to clear the valid bits of the corresponding cache line. When the memory configuration changes, the whole or part of the cache may need to be cleared. The term "clear" is also sometimes used in place of the term "invalidate". However, for D-cache with a write-back strategy, a clean operation is required.

    Cleaning the cache means forcing dirty (that is, overwritten) cache lines to be written to main memory and clearing the dirty bits in the cache lines. Cleaning the cache can restore the consistency between the cache and main memory, and it is only used for D-cache using a write-back strategy.
    Changes to the system's memory configuration may require clearing and clearing cache operations. Operations such as access rights, changes to cache and buffer policies, or remapping of virtual addresses all require cleaning or clearing of the cache.
    Before executing self-modifying code in a detached cache, the cache also needs to perform cleanup and purge operations. Self-modifying code involves simply copying code from one place to another. The cleaning and clearing operations are caused by two possible situations: first, the self-modifying code may not be hosted in the D-cache and, therefore, cannot be loaded from main memory as an instruction; second, the I-cache Existing instructions may mask new instructions written to main memory.
    If the cache uses a write-back strategy and the self-modifying code is written to main memory, the first step is to write the instruction as a block of data somewhere in main memory; later, the program jumps to main memory to write the instruction Streaming forms start execution at this point in main memory. Among them, when the code is written to the main memory as data, if the cache line in the cache memory representing the main memory location where the self-modifying code is written is valid, then the code may be written to the cache (without writing to the main memory). live). These cache lines are copied to the D-cache, not to main memory. If this happens, when the program jumps to the place where the self-modifying code is located (somewhere in main memory), the code represented by the original data will be executed, because the self-modifying code is actually still in the D-cache at this time. . In order to prevent this from happening, a D-cache cleaning operation can be performed to force the instruction code to be stored in the main memory as data, so that the data can be read from the main memory as an instruction stream.
    After the D-cache is flushed, new instructions are written to main memory. However, there may be valid cache lines in the I-cache to store instructions corresponding to new data (code) addresses. Next, when you read an instruction at the address where the new code is, you still get the old code in the I-cache, not the new code in main memory. Clearing the I-cache prevents this from happening.
    In the linux code, the places involved in the self-carrying code are:
1. Loading the application:
Load_aout_binary
Load_aout_libary
Load_aout_interp
Load_flat_file

2.Fiq code handling:
3. In Signal.c:
Setup_frame
Setup_rt_frame

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324588989&siteId=291194637