Apparatus and method for controlling allocation of data to cache storage
By setting conditional allocation flags in cache storage and resolving event processing based on allocations, cache timing side-channel attacks caused by speculative execution are addressed, ensuring data security and maintaining performance.
Patent Information
- Application Number
- CN201980023742.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2018-04-06
- Filing Date
- 2019-03-20
- Publication Date
- 2024-10-25
- Estimated Expiration
- 2039-03-20
AI Technical Summary
Instruction-based speculative execution can lead to the disclosure of sensitive information about data allocation in the cache store, especially through cache timing side-channel attacks, where an attacker can exploit the access patterns of the cache store to obtain sensitive data.
Under sensitive allocation conditions, when the processing circuit speculatively executes a memory access instruction, it allocates data to cache storage and sets the conditional allocation flag associated with the allocated data. It determines whether to clear the flag based on the type of allocation resolution event. Invalidate the data or treat it as an unconditional assignment.
Effectively prevents cache timing side-channel attacks based on speculation, while maintaining performance advantages when determining that memory access instructions should be executed, ensuring the legality and security of data in the cache.
Smart Images

Figure CN111936980B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to techniques for controlling allocation of data into cache storage. Background Art
[0002] A data processing apparatus may support speculative execution of instructions, wherein instructions are executed before it is known whether the input operands of the instruction are correct or whether the instruction needs to be executed at all. For example, a processing apparatus may have a branch predictor for predicting the outcome of a branch instruction so that subsequent instructions may be speculatively fetched, decoded, and executed before it is known what the true outcome of the branch should be. Additionally, some systems may also support data prefetching as a form of speculation, wherein values are loaded from memory in anticipation of the values being needed by processing circuitry to allow subsequent instructions to be processed more quickly. Other forms of speculation are also possible.
[0003] It has recently been identified that, in certain instances, the allocation of data into cache storage based on speculative execution of instructions can open up attack vectors that attempt to identify sensitive data. For example, information has recently been published on speculation-based cache timing side channel attacks, where several techniques can be used such that cache timing analysis can be abused to leak information from mis-speculative execution of instructions. Summary of the invention
[0004] In a first example configuration, a device is provided, comprising: a processing circuit for executing instructions; a cache storage for storing data accessed when the instructions are executed; and a cache control circuit, arranged to allocate the data to the cache storage and set a conditional allocation flag associated with the data allocated to the cache storage in response to the processing circuit speculatively executing a memory access instruction that identifies data to be allocated to the cache storage when a sensitive allocation condition is determined to exist; the cache control circuit, in response to detecting an allocation resolution event, determines based on the type of the allocation resolution event whether to clear the conditional allocation flag so that the data is thereafter treated as unconditionally allocated, or to cause invalidation of the data in the cache storage.
[0005] In another example configuration, a method for controlling allocation of data into a cache storage is provided, the cache storage being used to store data for access by a processing circuit when executing instructions, the method comprising: when a sensitive allocation condition is determined to exist, responding to the processing circuit speculatively executing a memory access instruction that identifies data to be allocated into the cache storage by: allocating the data into the cache storage and setting a conditional allocation flag associated with the data allocated into the cache storage; and when an allocation resolution event is detected, determining based on the type of the allocation resolution event whether to clear the conditional allocation flag so that the data is thereafter considered to be unconditionally allocated, or to cause invalidation of the data in the cache storage.
[0006] In another example configuration, a device is provided, comprising: a processing device for executing instructions; a cache storage device for storing data accessed when the instructions are executed; and a cache control device for responding to the processing device's speculative execution of a memory access instruction that identifies data to be allocated to the cache storage device in the following manner when a sensitive allocation condition is determined to exist: allocating the data to the cache storage device and setting a conditional allocation flag in association with the data allocated to the cache storage device; the cache control device is used to respond to the detection of an allocation resolution event in the following manner: determining, based on the type of the allocation resolution event, whether to clear the conditional allocation flag so that the data is thereafter considered unconditionally allocated, or to cause the data in the cache storage device to be invalidated. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] The present technology will be further described by way of illustration only with reference to examples of the present technology illustrated in the accompanying drawings, in which:
[0008] Figure 1 is a block diagram of an apparatus according to an example;
[0009] Figure 2 In one example arrangement, Figure 1 The first level data cache;
[0010] Figure 3 is a flow chart illustrating steps taken by cache control circuitry in one example to determine how to allocate data into a cache;
[0011] Figure 4 is a flow chart illustrating steps taken by cache control circuitry in response to detection of an allocation resolution event according to one example arrangement;
[0012] Figure 5Aschematically illustrates a form of sensitive allocation condition in which code for performing one or more cacheable load operations is speculatively executed before a preceding branch operation is resolved, and Figure 5B is a flow chart illustrating steps taken by cache control circuitry once a conditional branch has been resolved, according to an example arrangement;
[0013] Fig. 6A illustrates an example in which the presence of a speculative barrier instruction within a sequence of instructions is used to indicate the presence of a sensitive allocation condition, and Figure 6B is a flow chart illustrating steps taken by cache control circuitry in response to an associated allocation resolution event;
[0014] Fig. 7A and Figure 7B is a flow chart illustrating how changes in processor exception levels may be used to trigger sensitive allocation conditions, and associated allocation resolution events, according to an example arrangement;
[0015] Figure 8 is a flow chart illustrating how non-speculative access to a cache line that was previously conditionally allocated may be used as an allocation resolution event according to an example arrangement;
[0016] Fig. 9 illustrates, according to one example arrangement, how the operation of a data prefetch circuit may be altered depending on whether a sensitive allocation condition exists; and
[0017] Figures 10A to 10C An example arrangement illustrates how speculative execution of memory access instructions may be handled by cache control circuitry while the outcome of an earlier memory access instruction is not yet known. DETAILED DESCRIPTION
[0018] In one example arrangement, a device is provided that includes processing circuitry for executing instructions, and cache storage for storing data accessed when the instructions are executed. Cache control circuitry is used to control how data is allocated to the cache storage, and in particular, when a sensitive allocation condition is determined to exist, it does not just allocate data in the usual manner when the port circuitry speculatively executes a memory access instruction. Instead, when the sensitive allocation condition is determined to exist, the cache control circuitry allocates the data to the cache storage in response to the processing circuitry speculatively executing a memory access instruction that identifies data to be allocated to the cache storage, but sets a conditional allocation flag in association with the data allocated to the cache storage. The conditional allocation flag may be stored in a variety of ways, and may, for example, be stored in a storage structure separate from the cache storage. However, in one example arrangement, the conditional allocation flag is stored in the cache storage in association with the cache line to which the data is allocated.
[0019] As a result of the above process, at some point in time, there will be at least some data in the cache storage that has a conditional allocation flag set associated therewith. The cache control circuitry then determines, in response to detecting an allocation resolution event associated with such data, whether to clear the conditional allocation flag for the data so that the data is thereafter treated as unconditionally allocated, or to cause invalidation of the data in the cache storage based on the type of allocation resolution event.
[0020] Therefore, in the presence of sensitive allocation conditions, rather than completely preventing data from being allocated to the cache, the above technique allows the data to continue to be allocated, but in the following manner: if the allocation resolution event indicates that the data should not be allocated to the cache, the allocation can be invalidated. However, if instead the allocation resolution event indicates that the data can be allocated to the cache, this can provide a significant performance improvement, because the data has been conditionally allocated, and can be converted to be unconditionally allocated simply by clearing the conditional allocation flag.
[0021] Sensitive allocation conditions may occur for a variety of reasons, and the above scheme may be used regardless of the form of sensitive allocation conditions. However, one specific example scenario for a sensitive allocation condition may be when speculative memory access instructions are being executed in a manner that may allow sensitive data to be derived based on a cache timing side channel attack.
[0022] In particular, Google has recently published information on speculation-based cache timing side channel attacks, where several techniques can be used so that cache timing analysis can then be abused to leak information from mis-speculative execution of instructions. The basic principle behind the cache timing side channel is that the pattern of allocations into the cache, in particular which cache sets have been used for allocations, can be determined by measuring the time it takes to access entries that were previously in the cache, or by measuring the time to access entries that have been allocated. This can then be used to determine which addresses have been allocated into the cache. The novelty of the speculation-based cache timing side channel lies in its use of speculative memory reads. Speculative memory reads are a typical feature of advanced microprocessors and are part of the overall functionality that enables high performance.
[0023] By performing a first speculative memory read of a cacheable location beyond an architecturally unresolved branch (or other change in program flow), the result of that read can itself be used to form the addresses of further speculative memory reads. These speculative reads cause entries to be allocated into the cache whose addresses indicate the values of the first speculative read. If the untrusted code can control speculation in such a way that it causes a first speculative read of a location that would otherwise be inaccessible to the untrusted code, this can become an exploitable side channel. In particular, the effects of second and subsequent speculative allocations into the cache can be measured by the untrusted code.
[0024] Assuming that measures can be taken to mitigate an attacker from deriving useful information from data evicted from the cache by such speculative memory accesses, the above techniques can also prohibit an attacker from taking steps to measure the time it takes to access entries that have been allocated. In particular, during periods when such memory accesses can be speculatively executed, data allocated to the cache due to these accesses is marked as conditionally allocated. An allocation resolution event can then occur when unresolved changes in the program flow have been resolved, and it is therefore known whether these speculative memory access instructions should be executed. If not, the conditionally allocated data can be invalidated in the cache, thereby preventing cache timing side channel attacks based on the data from being executed.
[0025] Thus, in one example, a sensitive allocation condition is determined to exist at least when a requirement to execute a memory access instruction depends on the outcome of a branch operation that was unresolved when the processing circuitry speculatively executed the memory access instruction. Additionally, an allocation resolution event may be considered to occur at least when the outcome of the branch operation is resolved.
[0026] In one example arrangement, when the result of a branch operation indicates that execution of a memory access instruction is required, the cache allocation circuitry is arranged to clear a conditional allocation flag associated with data in a cache storage accessed by speculative execution of the memory access instruction, and when the result of the branch instruction indicates that the memory access instruction will not be executed, the cache allocation circuitry is arranged to cause invalidation of the data in the cache storage accessed by speculative execution of the memory access instruction. Thus, such a scheme can effectively protect against any speculation-based cache timing side channel attacks directed to cache lines that have been allocated due to speculative memory access, while enabling the performance benefits of speculatively executing memory access instructions to be obtained in situations where it is determined that the memory access instruction should indeed be executed.
[0027] The sensitive allocation condition may be determined to exist for any type of branch operation whose result is unresolved at the time the memory access instruction is to be speculatively executed, or may be determined to exist only for certain types of branch operations. In one particular arrangement, the branch operation is a range-checking operation to determine whether the memory address identifying the data to be accessed by the memory access instruction is within an allowable range of memory addresses, and the memory access instruction will be executed when the memory address is within the allowable range. It has been found that such a range-checking operation is one of the specific types of branch operations that can be used when attempting to exploit the above-mentioned speculation-based cache timing side channel. In particular, it is common for untrusted software to pass a data value to trusted software, which data value will be used as an offset into an array or similar structure to be accessed by the trusted software. Ultimately, the trusted software may detect that the passed data value is not allowed, but due to speculative execution, the earlier mentioned memory access instruction based on the untrusted value may have been executed in the meantime and caused the data to be allocated to the cache.
[0028] Certain software techniques are used to attempt to mitigate against the speculation-based cache timing side channel attacks mentioned earlier by reducing the extent to which speculation can occur. One such software approach involves the use of speculation barrier instructions, and according to the techniques described herein, the presence of speculation barrier instructions can be used to identify sensitive allocation conditions.
[0029] For example, in one implementation, a sensitive allocation condition may be determined to exist at least when a speculative barrier instruction is encountered in a sequence of instructions, the speculative barrier instruction preventing processing circuitry from speculatively executing one or more types of instructions that appear in the sequence after the speculative barrier instruction during a barrier period, the barrier period ending when speculation is resolved for any speculatively executed instructions that appear in the sequence before the speculative barrier instruction. The types of instructions that are prevented from speculative execution may vary depending on the implementation, but in general any instruction that may cause a change in the state of an architecturally non-visible resource to occur may be prevented from speculative execution by a speculative barrier instruction. Thus, a speculative barrier instruction may be used to attempt to ensure that any instructions that are allowed to execute during the barrier period are only instructions that do not cause visible side effects due to their execution. Thus, typically, instructions that may cause updates to microarchitectural structures such as caches or branch prediction mechanisms may be prevented from speculative execution during the barrier period by a speculative barrier instruction.
[0030] However, according to the techniques described herein, the use of the techniques described earlier allows for providing some relaxation of the constraints for cache structures, as memory access instructions may be allowed to be speculatively executed during the barrier period, but data is allocated to cache storage with the conditional allocation flag set. Although the execution of the memory access instruction may cause a change in the state of an architecturally invisible resource (in this case, the cache), by invalidating the conditionally allocated data, that effect may be undone if it is determined that the memory access instruction should not be executed.
[0031] In an example scenario where a sensitive allocation condition is determined to exist when a speculative barrier instruction is encountered, an allocation resolution event may occur at least when a speculation is resolved for any speculatively executed instruction that appears in a sequence prior to the speculative barrier instruction. When the resolution of the speculation indicates that an incorrect speculation was made, the cache control circuitry is arranged to cause the conditionally allocated data to be invalidated in the cache storage. Therefore, if any incorrect speculation is made for instructions that appear prior to the speculative barrier instruction, the effect of the speculative execution of the memory access instruction may be undone. In a specific example, the speculative barrier instruction may be inserted immediately following the branch instruction mentioned earlier.
[0032] In addition to the above examples, there are other situations that may trigger a sensitive allocation condition. For example, in one implementation, the sensitive allocation condition may be determined to exist at least when the state of the processing circuit changes from a first state to a second state, in which the processing circuit is able to access data at one or more memory addresses that were not accessible when the processing circuit was in the first state. Therefore, at least for the memory addresses of interest, the processing circuit in the second state may be considered to have a higher privilege level than the processing circuit when in the first state. The data at one or more memory addresses may be sensitive data that is desired to remain secret from the processing circuit when operating in the first state. By triggering the sensitive allocation condition when the processing circuit changes from the first state to the second state, this will ensure that any speculatively executed memory access instructions have their data allocated to cache storage as conditional allocations.
[0033] In such an implementation, the allocation resolution event may occur at least when the state of the processing circuit changes from the second state to the first state, and the cache control circuit is arranged to cause invalidation of associated data within the cache storage when the conditional allocation flag is still set when the state of the processing circuit changes from the second state to the first state. Therefore, if any conditionally allocated data is still considered conditionally allocated by the time control is passed back to the processing circuit in the first state, the conditionally allocated data may be invalidated, thereby removing the possibility of the processing circuit in the first state attempting to perform any cache timing analysis on these allocated cache lines.
[0034] Data that has been conditionally allocated may be converted into fully allocated data for several reasons. For example, an allocation resolution event may also occur at least when another memory access instruction executed non-speculatively causes access to data in a cache storage in which an associated conditional allocation flag is set. In this case, the cache control circuit may clear the conditional allocation flag in response to the access caused by the execution of the other memory access instruction so that the data is then considered to be unconditionally allocated. In particular, if a non-speculative access occurs that hits conditionally allocated data in the cache storage, this means that the data should indeed be present in the cache storage, and therefore it is safe to clear the conditional allocation flag at this point in time. Then, the data will be considered to be unconditionally allocated from then on.
[0035] In one example arrangement, the apparatus may include data pre-fetch circuitry for performing a data pre-fetch operation to pre-load data in anticipation of the data being required by the processing circuitry. Typically, the data may be pre-loaded into one of the registers of the processing circuitry, but may be cached in the cache storage as part of the process. According to one example arrangement, the cache control circuitry is further arranged to set a conditional allocation flag in association with the pre-loaded data obtained by the data pre-fetch circuitry and allocated to the cache storage, at least when the sensitive allocation condition is determined to exist. This therefore enables the pre-loaded data that is allocated to the cache as a result to be treated as conditionally allocated.
[0036] In some implementations, the cache control circuit may be arranged to initially always treat the data allocated to the cache as part of the data prefetch operation as conditionally allocated. Then, according to the mechanism discussed earlier, if the data is accessed by a truly non-speculatively executed instruction, the conditional allocation flag may be cleared. However, in an alternative, the processing of pre-fetched data in this way may be limited to situations where sensitive allocation conditions exist. Then, when the associated allocation resolution event occurs, the data may be converted to unconditionally allocated data or invalidated, depending on the type of allocation resolution event. For example, if the sensitive allocation condition is the presence of a speculative barrier instruction, any pre-fetched data allocated to the cache storage during the barrier period may be marked as conditionally allocated, and then if no misprediction is detected when resolving any speculatively executed instructions that appear before the speculative barrier instruction, it may be converted to unconditionally allocated data. However, in the case of any misprediction, the pre-fetched data in the cache may be invalidated.
[0037] As another example of a sensitive allocation condition, the sensitive allocation condition may be determined to exist at least when: a preceding memory access instruction that is abortable is executed, and the memory access instruction speculatively executed by the processing circuitry is a memory access instruction that would not be executed if the preceding memory access instruction aborted.
[0038] Thus, it can be seen that the above techniques provide a great deal of flexibility when allocating data into the cache in a variety of different situations, allowing data to be conditionally allocated into the cache at certain points in time and then either converted to fully allocated data or invalidated thereafter.
[0039] In one example implementation, in the presence of a sensitive allocation condition, the processing circuitry is arranged to speculatively execute a plurality of memory access instructions such that data is allocated into a plurality of entries of cache storage and associated conditional allocation flags are set. The allocation resolution event is then a global allocation resolution event that applies equally to the data in each of the plurality of entries, and the cache control circuitry may be arranged to, depending on the type of global allocation resolution event, either clear the conditional allocation flag for each of the plurality of entries, or cause invalidation of the data in each of the plurality of entries. Thus, an allocation resolution event may involve a plurality of conditionally allocated cache lines, and may be used to trigger resolution for each of these cache lines such that they are either all treated as fully allocated cache lines, or all are invalidated.
[0040] The types of memory access instructions that are speculatively executed and treated in the aforementioned manner (with respect to how the accessed data is subsequently allocated to the cache) may take a variety of forms. For example, in one implementation, the memory access instruction that is speculatively executed by the processing circuit is a load instruction that is executed to load data from the memory into at least one register accessible to the processing circuit. In some systems, it is possible that store instructions are not speculatively executed, and therefore it is not necessary to employ the above-described mechanism for store instructions. However, in implementations where both load and store instructions may be speculatively executed, then the same techniques may also be used to speculatively execute store instructions if desired.
[0041] There are a number of ways that the cache control circuitry can invalidate a conditionally assigned cache line. For example, if the data is still clean, i.e., a copy of the data already exists in a lower level of the memory system, then it may be sufficient to simply clear the valid flag associated with the relevant data. However, when the cache control circuitry causes the data to be invalidated and the data is marked as dirty, the cache control circuitry may cause the data to be evicted from cache storage to a lower level of the memory system, in addition to the associated entry in the cache being marked as invalid. Thus, in this case, the invalidation operation actually includes both the cleaning and invalidation operations to ensure that any updates to the data are not lost within the memory system.
[0042] As described above, allocation resolution events can take many forms. However, in one implementation, an allocation resolution event occurs at least when the associated sensitive allocation event that caused the sensitive allocation condition has been resolved. Whether the associated conditionally allocated cache line is converted to a fully allocated cache line or invalidated at that point in time will depend on the nature of the resolution that occurred.
[0043] In one example implementation, the cache storage comprises a plurality of cache lines, and the cache control circuitry is arranged to mark the cache line as a conditionally allocated cache line when data is allocated into the cache line when a sensitive allocation condition exists. A plurality of sensitive allocation events may occur before an associated allocation resolution event occurs, and the apparatus may further comprise a tracking storage referenced by the cache control circuitry to identify, for each pending allocation resolution event, which conditionally allocated cache lines are associated with the allocation resolution event.
[0044] Thus, in such an arrangement, it is possible to have some degree of nesting of sensitive allocation events and associated allocation resolution events. In such an instance, a tracking store may keep track of which cache lines are associated with which levels of nesting to ensure that when a resolution is reached for a particular level of nesting, appropriate action may be taken for the associated cache lines.
[0045] Specific examples will now be described with reference to the accompanying drawings.
[0046] Figure 1An example of a data processing apparatus 2 is schematically illustrated. It will be appreciated that this is only a high-level representation of a subset of the components of the apparatus and that the apparatus may include many other components not illustrated. The apparatus 2 includes a processing circuit 4 for performing data processing in response to instructions decoded by an instruction decoder 6. The instruction decoder 6 decodes instructions retrieved from an instruction cache 8 to generate control signals 10 for controlling the processing circuit 4 to perform the corresponding processing operation represented by the instruction. The processing circuit 4 includes one or more execution units 12 to perform operations on values stored in registers 14 to generate result values to be written back to the registers. For example, the execution unit may include an arithmetic / logic unit (ALU) for performing arithmetic or logical operations, a floating point unit for performing operations using floating point operands, and / or a vector processing unit for performing vector operations on operands comprising multiple independent data elements. The processing circuit also includes a memory access unit (or load / store unit) 15 for controlling the transfer of data between the register 14 and a memory system. The memory system includes an instruction cache 8, a data cache 16, and further storage provided downstream of the data cache 16 and the instruction cache 8, such as further levels of cache (e.g., a level 2 or level 3 cache) and a main memory 18. In response to a load operation, the memory access circuit 15 controls the memory system to return the data associated with a given address and writes the loaded data to the register 14. In response to a store operation, the value from the register 14 is written to the memory system by the memory access circuit 15.
[0047] like Figure 1 As shown in , the apparatus 2 may have at least one form of speculation mechanism 20 for making predictions about the expected behavior of certain instructions to be processed by the processing circuit 4 and controlling the apparatus to speculatively execute subsequent instructions based on the predicted results of earlier instructions. For example, the speculation mechanism 20 may include a branch predictor for predicting the taken / not taken results of branch instructions and / or for predicting the target address of branch instructions so that subsequent instructions can be speculatively fetched, decoded and executed without waiting for the actual branch results to be resolved. If the branch prediction is ultimately found to be incorrect, the architectural effect of the subsequently executed speculative instructions on the register 14 can be undone and the architectural state in the register 14 can be restored to the point where the branch was encountered, and then an alternative path of executable instructions following the branch can be followed. However, if the branch is correctly predicted, this enables performance to be improved by filling the pipeline with subsequent instructions earlier.
[0048] Another example of a speculation mechanism 20 may be a data prefetch mechanism that is used to attempt to prefetch data into registers 14 in anticipation of the data being required by processing circuitry. During this process, the prefetched data may be allocated into data cache 16.
[0049] The speculative execution of these instructions by the processing circuit 4 before actually knowing whether the input to the instructions is correct or whether these instructions need to be executed at all can be extremely beneficial in providing high processor performance. However, it has recently been recognized that if such speculation causes memory accesses to be speculatively executed, the allocation to the cache 16 triggered by the speculative memory access remains visible even after the speculative instructions have been resolved as mispredicted or incorrectly speculated and the architectural effects of the speculative re-execution of the instructions have been revoked. This can then allow the subsequently executed code to investigate what data was loaded by the earlier code through the cache timing side channel. The basic principle behind the cache timing side channel is that the pattern of allocations to the cache, and, in particular, which cache sets are used for allocations, can be determined by measuring the time it takes to access entries previously in the cache, or by measuring the time to access entries that have been allocated. This can then be used to determine which addresses have been allocated to the cache.
[0050] Speculation-based cache timing side channels using speculative memory reads have recently been proposed. Speculative memory reads are a typical feature of advanced microprocessors, and are part of the overall functionality that enables very high performance. By performing speculative memory reads of cacheable locations beyond architecturally unresolved branches (or other changes in program flow), and, further, using the results of these reads themselves to form addresses of further speculative memory reads, these speculative reads cause entries to be allocated into the cache whose addresses indicate the values of the first speculative read. This becomes an exploitable side channel if untrusted code can control speculation in such a way that it causes a first speculative read of a location that would otherwise be inaccessible at the untrusted code, but the effects of a second speculative allocation within the cache can be measured by the untrusted code.
[0051] For any form of monitoring software, it is common for the untrusted software to pass a data value that will be used as an offset into an array or similar structure that will be accessed by the trusted software. For example, an application (untrusted) may request information about an open file based on a file descriptor ID. Of course, the monitoring software will check that the offset is within the appropriate range before using it, so the software for this example may be written as follows:
[0052]
[0053]
[0054] In modern microprocessors, processor implementations may typically perform data access speculatively (implied by line 9 in the code above) to establish the value before executing the branch associated with the untrusted_offset_from_user range check (implied by line 7). A processor running this code at a certain monitoring level (e.g., an OS kernel or hypervisor) may speculatively load from anywhere in normal memory accessible to that monitoring level as determined by the out-of-range value of untrusted_offset_from_user passed by untrusted software. This is not an architectural problem because the loaded value will be discarded by the hardware if the speculation is incorrect.
[0055] However, advanced processors can use the value of the speculative load for further speculation. It is this further speculation that is exploited by the speculation-based cache timing side channel. For example, the previous example can be extended to have the following form:
[0056]
[0057]
[0058] In this example, "value" loaded from memory using an address calculated from arr1->data in combination with untrusted_offset_from use (line 10) is then used as the basis for further memory accesses (line 13). Therefore, the speculative load of value2 comes from an address derived from the data speculatively loaded for value. If the processor's speculative load of value2 causes an allocation into cache, then a portion of the address of the load can be inferred using a standard cache timing side channel. Since the address depends on the data in value, a portion of the data of value can then be inferred using a side channel. By applying this scheme to different bits of value (in several speculative executions), the entirety of value's data can be determined. Therefore, untrusted software can access anywhere accessible to monitoring software by providing an out-of-range amount for untrusted_offset_from_user, and therefore, this scheme can be used by untrusted software to recover the value of any memory accessible to monitoring software.
[0059] Modern processors have multiple caches of different types, including instruction caches, data caches, and branch prediction caches. In principle this side channel can be stimulated if the allocation of entries in these caches is determined by the value of any part of some data loaded based on untrusted input.
[0060] As a generalization of this mechanism, it should be understood that the underlying hardware technology means that code that branches can be executed speculatively, and therefore any sequence of accesses to memory after the branch can be executed speculatively. In such speculation, where a value that is speculatively loaded is subsequently used to construct an address for a second load or indirect branch that can also be executed speculatively, then the second load or indirect branch can leave an indication of the value loaded by the first speculative load in a way that makes it readable using timing analysis of the cache by code that would otherwise not be able to read the value. This generalization implies that many code sequences that are commonly generated will leak information into patterns of cache allocations that can be read by other, less privileged software. The most severe form of this problem is the one described earlier in this section, in which less privileged software can choose what values are leaked in this way.
[0061] Therefore, it is desirable to provide countermeasures against such attacks. According to the techniques described herein, the operation of the cache control circuit 34 is modified so that, in the presence of a sensitive allocation condition, it changes the manner in which at least some data is allocated to the data cache 16. In particular, when the processing circuitry speculatively executes a memory access instruction that identifies data to be allocated to the cache, and the sensitive allocation condition is determined to exist, the data is still allowed to be allocated to the cache, but a conditional allocation flag is set in association with the data allocated to the cache. Then, when an allocation resolution event is detected regarding the conditionally allocated data, a determination is made based on the type of allocation resolution event whether to clear the conditional allocation flag so that the data is thereafter treated as unconditionally allocated, or to cause the data in the cache to be invalidated.
[0062] It will be clear from the examples discussed herein that there are multiple possible sensitive allocation conditions that can be detected, and they can have associated allocation resolution events. In addition, additional allocation resolution events that are not directly linked to sensitive allocation conditions can occur. An example of this latter case is that the data that is conditionally allocated to the cache is subsequently accessed via a non-speculative access instruction, indicating that the data should be legally in the cache, and this event causes the conditionally allocated cache line to be converted into a fully allocated cache line.
[0063] Although in some implementations, only a single sensitive allocation event may exist at a time, in some instances, multiple sensitive allocation events may occur before an associated allocation resolution event occurs. In this case, a tracking store 40 may be provided in association with the cache control circuit 34, wherein the contents of the tracking store are maintained by the cache control circuit to identify, for each pending allocation resolution event, which conditionally allocated cache lines are associated with the allocation resolution event. Thus, when an allocation resolution event is received, it may be determined which conditionally allocated cache lines are affected by the allocation resolution event, and depending on the form of the allocation resolution event, appropriate action may be taken for those identified cache lines. As previously described, this may involve converting all of those associated cache lines into fully allocated cache lines by clearing their conditional allocation flags, or may require invalidation of the data in those affected cache lines.
[0064] The conditional allocation flag information may be maintained in a variety of ways as long as it is possible to determine which cache lines are conditionally allocated to the cache. Figure 2 An example arrangement is illustrated in which a conditional allocation flag is provided in association with each cache line entry by using additional information bits within the associated tag RAM entry. In particular, for each cache line 75 within the cache's data RAM 80, a corresponding tag RAM entry 52 is provided within the cache's tag RAM 50. Those skilled in the art will appreciate that the tag RAM entry will include a tag portion 55, which is the portion of the address that is compared to the address of the lookup request in order to determine whether there is a hit in the entry, i.e., whether the address specified by the lookup request is attempting to access the data stored in the associated cache line 75. Additional information may also be provided within the tag RAM entry 52, including a valid flag 60 that identifies whether the corresponding cache line contents are valid, and a dirty flag 65 that may be set to indicate that the contents of the cache line 75 are more up-to-date than the corresponding data in the memory system. In the event that the dirty flag is set, then when the cache line is to be invalidated, for example to make room for a new data line to be allocated into the cache, the current cache line contents will first need to be evicted to the memory system.
[0065] like Figure 2 As shown in , an additional field 70 may be provided in each tag RAM entry 52 to identify whether the data in the corresponding cache line 75 is conditionally allocated. In a specific example, when the flag 70 is set to a logic 1 value, this indicates that the data is conditionally allocated, and when it is set to a logic 0 value, this indicates that the data is unconditionally allocated.
[0066] Although Figure 2 One specific manner in which conditional allocate flag information may be maintained is illustrated, but it will be appreciated that other structures may be used to maintain conditional allocate information for affected cache lines.
[0067] Figure 3 is a flow chart illustrating the operation of the cache control circuit 34 in an example arrangement. At step 100, it is determined whether speculative execution of a memory access instruction has identified data to be allocated to the cache 16. If so, then at step 105 it is determined whether a sensitive allocation condition exists, and if not, the process proceeds to step 110, where the data is allocated to the cache in the usual manner. However, if the sensitive allocation condition exists, the process proceeds to step 115, where the data is allocated to the cache line, but the conditional allocation flag is set for the cache line. In one example implementation, the valid flag is set at the time of such conditional allocation to allow subsequent hits to occur for the conditionally allocated data. In other implementations, the valid and conditional flag information may be combined into a particular encoding and hits for conditionally allocated valid cache lines may be treated slightly differently than hits for unconditionally allocated cache lines.
[0068] Figure 4 1 is a flow chart illustrating how the cache control circuit handles allocation resolution events. In step 150, it is determined whether an allocation resolution event is detected for at least one conditionally allocated cache line. When such an allocation resolution event is detected, then in step 155, it is determined whether the type of the allocation resolution event indicates that the data should be kept in the cache. As will be discussed with reference to the remaining figures, there are a variety of different types of allocation resolution events that can be used, and depending on the information associated with the allocation resolution event, it can be determined whether the relevant conditionally allocated data should be kept in the cache. If it is determined that the data should be kept in the cache, the process proceeds to step 160, where the conditional allocation flag is cleared for each cache line associated with the allocation resolution event, so that each of these cache lines becomes a normal allocation cache line. As previously described, in one embodiment, the valid flag is set when conditionally allocated, so that all that is required is to clear the allocation flag. However, in the case where the valid flag and the conditional flag information are contained in a single encoding, the state of the encoding will change to identify that the data is no longer conditionally allocated and is now considered as fully allocated valid data.
[0069] If it is determined at step 155 that the type of allocation resolution event indicates that the data should not be retained in the cache, then the process proceeds to step 165 where each conditionally allocated cache line associated with the allocation resolution event is invalidated.
[0070] As previously described, in one implementation, there may be only one level of speculation associated with a conditional allocation of a cache line into a cache at any point in time, and thus when the associated resolution event occurs, action may be taken for all conditionally allocated cache lines. However, in other implementations, a level of nesting may be supported, wherein multiple sensitive allocation events that would trigger the presence of a sensitive allocation condition may occur before the associated allocation resolution event occurs. As previously described with reference to Figure 1 As described, in this case tracking storage 40 may be maintained by cache control circuitry 34 to keep track of which conditionally allocated cache lines are associated with each level of nesting, so that for each pending allocation resolution event, it can be determined which conditionally allocated cache lines are associated with the allocation resolution event, and therefore which should undergo step 160 or step 165 in response to receiving each allocation resolution event. However, it will be appreciated that there are several different mechanisms that can be used to link each allocation resolution event with the associated conditionally allocated cache line. For example, a linked table operating within the processor may be used (in conjunction with a record buffer, an exception FIFO, or whatever other mechanism for tracking speculative execution and associated event sets).
[0071] Figure 5A A scenario that may give rise to detection of the presence of a sensitive allocation condition is schematically illustrated. In particular, assume that a conditional branch instruction 200 is to be executed, but the outcome of the associated branch operation is unresolved when the processing circuitry begins speculatively executing a block of code 205, where the block of code includes one or more load instructions to a cacheable memory address that may cause data to be allocated into a cache. The branch target of the conditional branch instruction 200 may be a branch target 210, such that if the branch is determined to be taken, instruction flow will branch to the branch target 210. However, if it is not taken, then execution of the block of code 205 will be correct. The conditional branch may take a variety of forms, but in one scenario may be a bounds checking operation, and therefore Figure 5A The example of is an example of the type of scenario that may be used to attempt to speculatively load data into the cache to enable untrusted code to perform speculation-based cache timing side channel attacks. However, according to the techniques described earlier, when a sensitive allocation condition is determined to exist, in this case when the outcome of the conditional branch has not yet been resolved, the cache control circuitry will ensure that any cache line allocated into the cache as a result of executing the block of code 205 will be marked as conditionally allocated.
[0072] Figure 5Bis a flow chart illustrating how cache control circuitry responds to an associated allocation resolution event (in this case when a conditional branch is resolved). At step 220, the conditional branch is waited for to be resolved, after which at step 225, a determination is made that an allocation resolution event has now been detected. At step 230, a determination is made whether the branch is taken. Figure 5A In the example of , if the branch is not taken, then the block code 205 should indeed be executed, and therefore it is acceptable to keep any conditionally allocated data in the cache. Therefore, in step 240, the conditional allocation flag is cleared for the cache line that is conditionally allocated due to the speculative execution of the code block 205.
[0073] Conversely, if the branch is taken, the block of code 205 should not be executed, and in step 235, the cache lines that are conditionally allocated due to the speculative execution of the code block 205 are invalidated. If any of these cache lines are marked as dirty, this may require cleaning and invalidation operations to be performed to drive the data back to the lower level of the memory system. Although the processor will generally be arranged so that it will not speculatively write into the cache, there are certain scenarios in which the data allocated into the cache during speculative execution may be dirty, and therefore need to undergo cleaning and invalidation operations in the above situation. For example, in a multi-processor system, cache lines may migrate between caches of different processors while being in a dirty state. Therefore, a first processor may speculatively perform a line fill operation in its local cache and receive a dirty cache line from the local cache of a second processor during this process (because the cache line has been previously modified but has not yet been written back to the memory). Therefore, dirty data is legal data that is not generated by speculative execution on the first processor but is generated by legal execution on the second processor. Thus, when a decision is made to flush a cache line from the first processor's cache in the scenario described above, the dirty data is written back to memory.
[0074] Fig. 6A Another example scenario that may give rise to the presence of a sensitive allocation condition is illustrated. In this case, substantially the same code sequence is considered, but in this case it is assumed that a speculative barrier instruction 215 immediately follows a conditional branch instruction 200. The purpose of the speculative barrier instruction is to ensure that the processing circuitry is prevented from speculatively executing at least certain types of instructions that appear after the speculative barrier instruction during the barrier period, and the barrier period ends when the speculation is resolved for any speculatively executed instructions that appear in the sequence before the speculative barrier instruction. Therefore, in this example, any earlier instructions involving speculative execution before the speculative barrier, including the conditional branch instruction 200, will need to be resolved before such instructions that appear after the speculative barrier are allowed to execute. This can prohibit an attacker from performing the speculation-based cache timing side channel attack mentioned earlier.
[0075] The goal of a speculation barrier is to ensure that the only subsequent instructions that can be speculatively executed during the barrier period are those that will not produce visible side effects as a result of their execution. In practice, this means that any instructions that can change the state of architecturally invisible resources such as the contents of a cache will generally not be allowed to be speculatively executed during the barrier period. However, according to the techniques described earlier, speculative memory accesses are allowed to execute due to the fact that they will be conditionally allocated into the cache, and if it is determined that these instructions should not be executed when all previous speculations are resolved, the effects within the cache can be undone by invalidating these conditionally allocated cache lines.
[0076] Figure 6B 2 is a flow chart illustrating the steps performed by the cache control circuitry once all prior speculations prior to the speculation barrier are resolved. At step 250, the process waits until all speculations prior to the speculation barrier are resolved. At this point, it is determined at step 255 that an allocation resolution event has been detected, and then it is determined at step 260 whether there are any incorrect speculations regarding speculatively executed instructions that occurred prior to the speculation barrier. If not, then at step 265, the conditional allocation flag is cleared for any conditionally allocated cache lines within the cache. However, if some degree of mis-speculation has occurred, then the process proceeds to step 270 where any conditionally allocated cache lines are marked as invalid.
[0077] Figure 7B and Figure 7B The diagram illustrates how, in one example implementation, a sensitive allocation condition may be determined to exist when a transition from a lower to a higher exception level occurs, and then a corresponding allocation resolution event may be detected when the processor changes back to a lower exception level (a change in the processor exception level is considered an example of a change in the state of the processor). In particular, if Fig. 7A As shown, if the processor changes to a higher exception level 300, then it is determined at step 305 that a sensitive allocation condition exists. When the processor is at a higher exception level, it is possible that the processor will be able to access sensitive data that is not available to the processor when executing in a lower exception level. Since the speculation-based cache timing side channel attack mentioned earlier is based on untrusted code controlling speculation in a manner that causes monitoring software to perform a sequence of speculative memory accesses, then by triggering the sensitive allocation condition when transitioning from a lower exception level to a higher exception level, this ensures that any data allocated to the cache when processing at the higher exception level is initially conditionally allocated to the cache.
[0078] During the time when the processor is executing at a higher exception level, some conditionally allocated cache lines may be converted to unconditionally allocated cache lines by activities performed at the higher exception level. For example, a non-speculative access may hit within a conditionally allocated cache line, thereby indicating that the cache line should be present in the cache. At this point, the conditionally allocated flag may be cleared to convert the cache line to a fully allocated cache line.
[0079] However, when the processor changes from a higher exception level back to a lower exception level, then Figure 7B In particular, when the processor changes back to a lower exception level at step 310, this is treated as an allocation resolution event, and any cache lines that were conditionally allocated to the cache that still have the conditional allocation flag are invalidated at step 315. This will remove the prospect of the lower exception level code subsequently attempting to perform timing analysis on cache lines that were allocated while the processor was executing in a higher exception level. Fig. 7A and 7B As an alternative to the scheme shown in , the process can be arranged so that when moving from a given exception level to a higher privileged exception level, any conditionally allocated data is converted to unconditionally allocated data. Figure 7B The invalidation performed at step 315 in when moving from a given exception level to a less privileged exception level will only invalidate data that was speculatively accessed at the given exception level.
[0080] Figure 8 3 is a flow chart schematically illustrating how a non-speculative access may be treated as another type of allocation resolution event with respect to a particular cache line. In particular, at step 350, when a non-speculative access hits on a conditionally allocated cache line, the process proceeds to step 355, where the conditional allocation flag of the cache line is cleared to convert the cache line into a fully allocated cache line.
[0081] The behavior of conditionally allocating cache lines described above may also be extended to the activity of any data prefetch circuitry that attempts to prefetch data from memory in anticipation of the data being requested by processing circuitry. In particular, when a sensitive allocation condition exists, the behavior of the data prefetch circuitry may be as follows: Fig. 9 . At step 400, it is determined whether a sensitive allocation condition exists, and if not, the process proceeds to step 405, where the data prefetch circuit prefetches data as usual, which may result in the data being allocated to the cache in a standard manner. However, if the sensitive allocation condition exists, the process proceeds to step 410, where any allocations made in the cache due to the activity of the data prefetch circuit are marked as conditionally allocated.
[0082] According to the reference Figure 8According to the described mechanism, once the prefetched data has been conditionally allocated to the cache, if the real access request executed unconditionally hits the cache line, the data can be converted to the unconditionally allocated format by clearing the conditional allocation flag. In addition, when an allocation resolution event associated with a sensitive allocation condition occurs, the action taken for the conditionally allocated prefetched data can be the same as that taken for any other conditionally allocated data. Therefore, depending on the type of allocation event, the associated cache line containing the prefetched data can be invalidated or converted to a fully allocated cache line.
[0083] Although in Fig. 9 , it is assumed that prefetched data is conditionally allocated only when a sensitive allocation condition exists, but in an alternative implementation, the system may initially always treat prefetched data as conditionally allocated, and accordingly always set the conditional allocation flag when a cache line is allocated into the cache for data prefetched by the prefetch circuitry.
[0084] Figures 10A to 10C Another example scenario in which conditional allocation of cache lines may occur is illustrated. Fig. 10A As shown in , it is assumed that the first memory access instruction is in the process of being executed, but can be aborted, and when the second memory access instruction is executed, it is not known whether the first memory access instruction will be aborted. The second memory access instruction is required to be executed only if the first memory access instruction is not aborted. As a result, the second memory access instruction is speculatively executed.
[0085] like Fig. 10B As shown in , at step 450, it is determined whether the state of the first memory access is unknown when the second memory access is executed. If not, then at step 455, normal processing is performed, and any cacheable data accessed by the second memory access instruction can be allocated to the cache in a normal manner. However, if the state of the first memory access is unknown, then the process proceeds to step 460, where any data accessed by the second memory access instruction is conditionally allocated to the cache.
[0086] Fig. 10C The associated allocation resolution event is illustrated. In particular, when it is determined at step 465 that the status of the first memory access has been resolved, the process proceeds to step 470, where it is determined whether the first memory access is aborted. If not, the process proceeds to step 475, where the conditional allocation flag is cleared for the cache line associated with the second memory access. However, if the first memory access is aborted, the process proceeds to step 480, where the cache line associated with the second memory access is invalidated.
[0087] It will be appreciated that the above-described techniques provide an improved mechanism for controlling the allocation of data into cache storage, which may provide some protection against certain types of cache timing analysis attacks.
[0088] In this application, the word "configured to" is used to mean that elements of a device have a configuration that can perform a defined operation. In this context, "configuration" refers to the arrangement or interconnection of hardware or software. For example, a device may have dedicated hardware that provides a defined operation, or a processor or other processing device may be programmed to perform the function. "Configured to" does not mean that the elements of the device need to be changed in any way in order to provide the defined operation.
[0089] Although illustrative embodiments of the present invention have been described in detail herein with reference to the accompanying drawings, it is to be understood that the present invention is not limited to these exact embodiments and that various changes, additions and modifications may be implemented therein by those skilled in the art without departing from the scope and spirit of the present invention as defined in the appended claims. For example, the features of the dependent claims may be variously combined with the features of the independent claims without departing from the scope of the present invention.
Claims
1. A device for controlling the allocation of data into a cache storage, include: processing circuitry for executing instructions; Cache storage for storing data accessed when executing the instructions; as well as cache control circuitry arranged to, in response to said processing circuitry speculatively executing a memory access instruction identifying data to be allocated in said cache storage, allocate said data into said cache storage and set a conditional allocation flag in association with said data allocated in said cache storage when a sensitive allocation condition is determined to exist; The cache control circuitry, in response to detecting an allocation resolution event, determines which option to perform based on a type of the allocation resolution event from among: clearing the conditional allocation flag so that the data is thereafter considered to be unconditionally allocated, and causing invalidation of said data in said cache storage; wherein, to cause invalidation of the data in the cache storage, the cache control circuitry is configured to mark any cache line to which the data is conditionally allocated as invalid; and The sensitive allocation condition is determined to exist at least when a requirement to execute the memory access instruction depends on an outcome of an unresolved branch operation at the time the processing circuitry speculatively executes the memory access instruction.
2. The apparatus as claimed in claim 1, wherein the allocation resolution event occurs at least when a result of the branch operation is resolved.
3. Apparatus as claimed in claim 2, wherein when the result of the branch operation indicates that execution of the memory access instruction is required, the cache control circuitry is arranged to clear the conditional allocation flag associated with the data in the cache storage accessed by speculative execution of the memory access instruction, and when the result of the branch operation indicates that the memory access instruction is not to be executed, the cache control circuitry is arranged to cause invalidation of the data in the cache storage accessed by speculative execution of the memory access instruction.
4. An apparatus as claimed in any one of claims 1 to 3, wherein the branch operation is a range checking operation to determine whether a memory address identifying data to be accessed by the memory access instruction is within an allowable range of memory addresses, and the memory access instruction will be executed when the memory address is within the allowable range.
5. An apparatus as claimed in any one of claims 1 to 3, wherein the sensitive allocation condition is determined to exist at least when a speculative barrier instruction is encountered in a sequence of instructions, the speculative barrier instruction preventing the processing circuit from speculatively executing one or more types of instructions that appear after the speculative barrier instruction in the sequence during a barrier period, the barrier period ending when speculation is resolved for any speculatively executed instructions that appear in the sequence before the speculative barrier instruction.
6. Apparatus as claimed in claim 5, wherein said memory access instructions are permitted to be speculatively executed during said barrier period, but said data is allocated into said cache storage if said conditional allocation flag is set.
7. A device as claimed in claim 6, in: The allocation resolution event occurs at least when speculation is resolved for any speculatively executed instruction that occurs before the speculation barrier instruction in the sequence; and When resolution of the speculation indicates that an incorrect speculation was made, the cache control circuitry is arranged to cause conditionally allocated data to be invalidated in the cache store.
8. An apparatus as claimed in any one of claims 1 to 3, wherein the sensitive allocation condition is determined to exist at least when the state of the processing circuit changes from a first state to a second state in which the processing circuit is able to access data at one or more memory addresses that were not accessible when the processing circuit was in the first state.
9. An apparatus as claimed in claim 8, wherein the allocation resolution event occurs at least when the state of the processing circuit changes from the second state to the first state, and the cache control circuit is arranged to cause invalidation of associated data within the cache storage when the conditional allocation flag is still set when the state of the processing circuit changes from the second state to the first state.
10. An apparatus as claimed in any one of claims 1 to 3, wherein the allocation resolution event occurs at least when another memory access instruction executed non-speculatively causes access to data in the cache storage whose associated conditional allocation flag is set, and the cache control circuit clears the conditional allocation flag in response to the access caused by the execution of the other memory access instruction so that the data is thereafter considered to be unconditionally allocated.
11. The device as claimed in any one of claims 1 to 3, further comprising: include: data prefetch circuitry for performing a data prefetch operation to preload data into the cache storage in anticipation of data being required by the processing circuitry; and The cache control circuitry is further arranged to set the conditional allocation flag in association with preload data obtained by the data prefetch circuitry and allocated into the cache storage, at least when the sensitive allocation condition is determined to exist.
12. An apparatus as claimed in any one of claims 1 to 3, wherein the sensitive allocation condition is determined to exist at least when: a previous memory access instruction that is abortable is executed, and the memory access instruction speculatively executed by the processing circuit is a memory access instruction that would not be executed if the previous memory access instruction was aborted.
13. A device as claimed in any one of claims 1 to 3, in: The processing circuitry is arranged to speculatively execute a plurality of memory access instructions when the sensitive allocation condition exists such that data is allocated into a plurality of entries stored in the cache and an associated conditional allocation flag is set; and When the allocation resolution event is a global allocation resolution event that applies equally to the data in each of the multiple entries, the cache control circuit is arranged to, depending on the type of the global allocation resolution event, either clear the conditional allocation flag for each of the multiple entries or cause invalidation of the data in each of the multiple entries.
14. Apparatus as claimed in any one of claims 1 to 3, wherein the memory access instruction speculatively executed by the processing circuitry is a load instruction executed to load data from a memory into at least one register accessible to the processing circuitry.
15. Apparatus as claimed in any one of claims 1 to 3, wherein when the cache control circuitry causes the data to be invalidated and the data is marked as dirty, the cache control circuitry causes the data to be evicted from the cache storage before an associated entry in the cache is marked as invalid.
16. Apparatus as claimed in any one of claims 1 to 3, wherein said allocation resolution event occurs at least when an associated sensitive allocation event that gave rise to said sensitive allocation condition has been resolved.
17. A device as claimed in claim 16, in: The cache storage comprises a plurality of cache lines, and the cache control circuitry is arranged to mark the cache line as a conditionally allocated cache line when allocating data into the cache line when the sensitive allocation condition exists; Multiple sensitive allocation events can occur before the associated allocation resolution event occurs; and The apparatus also includes a tracking store referenced by the cache control circuitry to identify, for each pending allocation resolution event, which conditionally allocated cache lines are associated with the allocation resolution event.
18. A method for controlling the allocation of data to a cache storage for storing data for access by a processing circuit when executing an instruction, the method include: in response to the processing circuit speculatively executing a memory access instruction identifying data to be allocated in the cache storage when a sensitive allocation condition is determined to exist by: allocating the data in the cache storage and setting a conditional allocation flag in association with the data allocated in the cache storage; and When an allocation resolution event is detected, which option to execute is determined from the following based on the type of allocation resolution event: clearing the conditional allocation flag so that the data is thereafter considered to be unconditionally allocated, and causing invalidation of said data in said cache storage; Wherein causing the invalidation of the data in the cache storage comprises: marking any cache line to which the data is conditionally allocated as invalid; and The sensitive allocation condition is determined to exist at least when a requirement to execute the memory access instruction depends on an outcome of an unresolved branch operation at the time the processing circuitry speculatively executes the memory access instruction.
19. A device for controlling the allocation of data into a cache storage, include: a processing device for executing instructions; a cache storage device for storing data accessed when executing the instruction; as well as cache control means, when a sensitive allocation condition is determined to exist, for responding to the processing means speculatively executing a memory access instruction identifying data to be allocated in the cache storage means by: allocating the data in the cache storage means and setting a conditional allocation flag in association with the data allocated in the cache storage means; The cache control means is configured to respond to the detection of an allocation resolution event by determining which option to execute from the following items based on the type of the allocation resolution event: clearing the conditional allocation flag so that the data is thereafter considered to be unconditionally allocated, and causing invalidation of the data in the cache storage device; Wherein, in order to cause invalidation of the data in the cache storage device, the cache control device is configured to mark any cache line to which the data is conditionally allocated as invalid; and The sensitive allocation condition is determined to exist at least when a requirement to execute the memory access instruction depends on an outcome of an unresolved branch operation at the time the processing device speculatively executes the memory access instruction.
