Data processing device and data processing method

By introducing speculative side-channel prompt instructions into the processing circuit, identifying and responding to potential information leakage risks, and dynamically adjusting mitigation measures, the problem of speculative side-channel attacks is solved, a balance between performance and security is achieved, and the processor's performance is improved. Performance and security.

CN111919197BActive Publication Date: 2024-09-13ARM LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201980022496.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-04-04
Filing Date
2019-03-12
Publication Date
2024-09-13
Estimated Expiration
2039-03-12

AI Technical Summary

Technical Problem

In existing technology systems that use speculative execution and data caching, there is a risk of speculative side-channel attacks. Attackers can obtain inaccessible memory area information by deceiving branch predictors or other speculative mechanisms, leading to information leakage, and routine Mitigation measures may reduce processing performance.

Method used

By introducing speculative side-channel hint instructions in the processing circuit, we identify instruction sequences that may have the risk of information leakage, and decide whether to trigger speculative side-channel mitigation measures based on the presence or absence of hint instructions, such as disabling speculative execution, reducing Number of speculative micro-ops, insert speculative barrier micro-ops, or slow down the pipeline to omit unnecessary mitigations when necessary to improve performance.

Benefits of technology

It effectively reduces the risk of information leakage caused by speculative side-channel attacks, while allowing more aggressive speculation and more efficient cache usage without affecting performance, improving processor performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111919197B_ABST
    Figure CN111919197B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a data processing device and a data processing method. A device includes: a processing circuit 14 for performing data processing in response to an instruction, the processing circuit supporting speculative processing of a read operation for reading data from a memory system 20, 22; and a control circuit 12, 14, 20 for identifying whether a sequence of instructions to be processed by the processing circuit includes a speculative side channel hint instruction and determining whether to trigger a speculative side channel mitigation measure based on whether the instruction includes a speculative side channel hint instruction, wherein the speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed. This can help reduce the performance impact of measures taken to prevent speculative side channel attacks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present technology relates to the field of data processing. Background Art

[0002] A data processing apparatus may support speculative execution of instructions, in which an instruction is executed before it is known whether its input operands 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 can be speculatively fetched, decoded, and executed before it is known what the true outcome of the branch should be. In addition, some systems may also support load speculation, in which a value to be loaded from memory is predicted before the true value is actually returned from memory, to allow subsequent instructions to be processed more quickly. Other forms of speculation are also possible. Summary of the invention

[0003] At least some examples provide an apparatus comprising: a processing circuit for performing data processing in response to an instruction, the processing circuit supporting speculative processing of a read operation for reading data from a memory system; and a control circuit for identifying whether a sequence of instructions to be processed by the processing circuit includes a speculative side channel hint instruction, and determining whether to trigger a speculative side channel mitigation measure based on whether the instruction includes the speculative side channel hint instruction, wherein the speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed.

[0004] At least some examples provide a data processing method, including: in response to an instruction, performing data processing using a processing circuit that supports speculative processing of a read operation, wherein the read operation is used to read data from a memory system; identifying whether a sequence of instructions to be processed by the processing circuit includes a speculative side channel hint instruction, wherein the speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed; and determining whether to trigger a speculative side channel mitigation measure based on whether the instruction includes the speculative side channel hint instruction.

[0005] At least some examples provide a computer-implemented method for generating a sequence of program instructions for processing by a processing circuit, the method comprising: analyzing input program code to identify whether operations represented by the program code include a speculative side channel activation mode of operation, wherein the speculative side channel activation mode of operation includes a read operation for reading data from a memory system, and for the speculative side channel activation mode of operation, if the read operation is speculatively processed by the processing circuit, there is a risk of information leakage; generating the sequence of program instructions based on the input program code; and selecting whether to insert at least one speculative side channel hint instruction into the generated sequence of program instructions based on whether the program code includes operations in the speculative side channel activation mode, wherein the at least one speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed.

[0006] A computer program may be provided for controlling a data processing device to perform a method for generating a sequence of program instructions as described above. The computer program may be stored on a storage medium. The storage medium may be a non-transitory storage medium. BRIEF DESCRIPTION OF THE DRAWINGS

[0007] Further aspects, features and advantages of the present technology will become apparent from the following description of examples read in conjunction with the accompanying drawings, in which:

[0008] Figure 1 An example of a data processing apparatus is schematically illustrated;

[0009] Figure 2 An example of a pattern of instructions that may be used to cause a speculative side channel attack is shown;

[0010] Figure 3 An example of using a speculative side channel hint instruction to mark a subsequent read operation as safe to perform without speculative side channel mitigation is shown;

[0011] Figure 4 An alternative situation where a hint instruction is used to flag a potentially unsafe subsequent read operation is shown;

[0012] Figure 5 Another alternative situation where a hint instruction is applied to multiple subsequent instructions is shown;

[0013] Figure 6 A method of processing instructions and controlling whether to trigger speculative side channel mitigation measures based on the presence or absence of speculative side channel hint instructions is illustrated; and

[0014] Figure 7A method of generating a sequence of program instructions for processing by a processing circuit based on an analysis of whether operations to be performed include a speculative side channel activation mode of operation is shown. DETAILED DESCRIPTION

[0015] The data processing apparatus may have a mechanism for ensuring that some data in the memory cannot be accessed by certain processes executed on the processing circuit. For example, privilege-based mechanisms and / or memory protection attributes may be used to control access to certain areas of memory. Recently, it has been recognized that in systems using speculative execution and data caching, it is possible for malicious people to obtain information from areas of memory that they cannot access by exploiting the following properties: even when any architectural effects of the speculatively executed instructions have been revoked after mis-speculation, the effects of the speculatively executed instructions can be maintained in the data cache. Such attacks can train branch predictors or other speculation mechanisms to deceive more privileged code to speculatively execute instruction sequences designed to make the privileged code access memory address patterns that rely on sensitive information, so that less privileged code that cannot access the sensitive information can use cache timing side channels to detect which addresses have been allocated to the cache or evicted from the cache by more privileged code to give some information that may allow sensitive information to be inferred. This attack may be referred to as a speculative side channel attack.

[0016] Several mitigation measures may be taken to reduce the risk of information leakage due to speculative side channel attacks. Various examples of speculative side channel mitigation measures are discussed in more detail below. However, in general, speculative side channel mitigation measures may generally reduce processing performance compared to the performance that can be achieved if speculative side channel mitigation measures are not taken. The inventors recognize that applying speculative side channel mitigation measures to all operations by default may unnecessarily sacrifice performance because in practice only certain operating modes may provide a risk of information leakage through side channel attacks. It may be possible to detect in advance instruction modes that may potentially cause the risk of speculative side channel attacks or instruction modes that may be detected as not causing such risks.

[0017] In the techniques discussed below, a processing circuit may be provided with a control circuit for identifying whether a sequence of instructions to be processed by the processing circuit includes a speculative side channel hint instruction, wherein the speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed. The control circuit may then determine whether to trigger a speculative side channel mitigation measure based on whether the instruction to be processed includes a speculative side channel hint instruction. For example, the hint instruction may be inserted by software at compile time or link time based on an analysis of the code to be executed to indicate whether data from a given read may be used as a control operand for generating an address for another read. Thus, by using a hint instruction to mark points in the code where speculative side channel mitigation measures may be needed or omitted, this may allow the processing circuit to take a less conservative approach when mitigating speculative side channel attacks. In at least some occasions, mitigation measures may be omitted when the presence or absence of a hint instruction indicates that it is safe to omit the mitigation measure. This may enable performance to be improved, for example by allowing more aggressive speculation and / or more efficient use of cache.

[0018] The speculative side channel hint instruction may be implemented in different ways. In one example, the speculative side channel hint instruction may indicate that it is safe to speculatively execute at least one subsequent read operation without the speculative side channel mitigation measure. In this case, the control circuit may determine that it is acceptable to omit the speculative side channel mitigation measure when the hint instruction is detected. On the other hand, for a given read operation that is not followed by a preceding speculative side channel hint instruction, the speculative side channel mitigation measure may be triggered. Therefore, in this case, the absence of a hint instruction (which is assumed to be the case by default) may be used to indicate that it is unsafe to perform a subsequent read without the mitigation measure.

[0019] Alternatively, in other schemes, a hint instruction may be used to mark an unsafe instruction, and any other read operation that does not follow the associated hint instruction is considered safe. Thus, the speculative side channel hint instruction may indicate that speculative execution of at least one subsequent read operation is unsafe without speculative side channel mitigation measures. In this case, when a preceding speculative side channel hint instruction is associated with a given read operation, the control circuitry may trigger speculative side channel mitigation measures for the given read operation. Otherwise, in the absence of a preceding associated hint instruction, mitigation measures may be omitted for the given read operation.

[0020] As an example of one form of a speculative side channel hint instruction, a hint may be applied to a single subsequent instruction and may indicate whether there is a risk of information leakage if at least one read operation triggered by the single subsequent instruction is speculatively processed. The subsequent instruction to which the hint is applied may be the immediately following instruction, regardless of whether the instruction triggers a read operation. Alternatively, the instruction to which the hint instruction is applied may be the next instruction that does trigger a read operation, even if there is at least one intervening instruction that does not trigger a read.

[0021] Alternatively, a hint instruction may be associated with a batch of subsequent instructions and may indicate whether there is a risk of information leakage if at least one read operation triggered by any one of the batch of subsequent instructions is speculatively processed. The batch of subsequent instructions may be defined as a predetermined number of subsequent instructions, or the batch of subsequent instructions may be defined using a memory range such that any instruction whose address is within a specified memory range (e.g., within a given address offset relative to the address of the hint instruction) may be assumed to be governed by the hint instruction.

[0022] In the case where the hint instruction is applied to a batch of subsequent hint instructions, when a hint cancellation event occurs in the middle of processing the operations corresponding to the batch of subsequent instructions, the control circuitry may determine whether to perform speculative side channel mitigation measures for the remaining instructions in the batch of instructions, as if there were no speculative side channel hint instructions before the batch of instructions. Therefore, certain events may be considered to cancel the effect of the previous hint instruction. For example, the hint cancellation event may be at least one of the following: an exception or interrupt; a branch; entering a debug state; and / or a breakpoint that triggers a diagnostic action. Any of these events may indicate that the batch of instructions is not executed continuously, and therefore there may be a risk that other instructions are executed in between, which may mean that any decision made based on the hint may not be valid. This method of canceling the effect of a previous hint may be particularly useful in such a system: reads are assumed to be unsafe by default unless they are preceded by a previous hint instruction.

[0023] In some examples, the speculative side-channel hint instruction may be interpreted as an architectural no-op instruction that does not trigger any changes to the architectural state (eg, register state) of the processor.

[0024] In some examples, the control circuit may annotate the cached instructions or micro-operations based on whether there are speculative side channel hint instructions in the sequence of instructions. Micro-operations may be instructions in such a form that the execution circuit of the processor executes these instructions. Some program instructions obtained from the memory may be decoded into multiple micro-operations, each of which performs a part of the function of the program instruction. Other program instructions may be mapped to a single micro-operation. Some micro-operations decoded from different program instructions may also be fused into a single micro-operation for processing by the execution stage. In the case where a cache is provided for caching instructions or micro-operations, speculative side channel hint instructions may occupy slots that could otherwise be occupied by other instructions or micro-operations. In some example implementations, the control circuit may annotate other instructions or micro-operations (e.g., subsequent read instructions or micro-operations to which hints are applied) to indicate whether hint instructions exist in the original instruction sequence. This may then allow the hint instruction itself to be omitted from the cache to free up the slot for another instruction or micro-operation that does provide an architectural effect on the processing state. Thus, in some cases, control over whether to perform speculative side-channel mitigation measures may initially be based on hint instructions, but may subsequently be based on annotation information assigned to the cache based on the presence or absence of hint instructions.

[0025] Multiple different forms of speculative side channel mitigation measures can be used to protect against potential speculative side channel attacks. Any of the following examples can be used alone or in combination. Hint instructions can be used to control whether any of these measures are to be taken for a given read instruction or micro-operation.

[0026] In one example, speculative side channel mitigation measures may include disabling speculative execution of read micro-ops. This ensures that an attacker cannot use mis-speculation (e.g., branch prediction or load value mis-prediction) as a means to cause more privileged code to execute instructions for loading secret information that should not have been executed.

[0027] Another example of a speculative side channel mitigation measure may be to reduce the maximum number of micro-ops that can be speculatively executed beyond the most recently resolved non-speculative micro-ops. By performing less aggressive speculation, this may reduce the window of operation available to an attacker to alter cache state based on a read access to an address derived from an incorrectly loaded secret median.

[0028] Another example of a mitigation measure may be to insert a speculation barrier micro-operation into a sequence of micro-operations to be processed by the processing circuitry to control the processing circuitry to disable speculative processing of micro-operations following the speculation barrier micro-operation until any micro-operations preceding the speculation barrier micro-operation have been resolved. For example, a barrier may be inserted between successive read instructions to ensure that if a first read is incorrectly speculated, subsequent reads (perhaps based on secret information incorrectly read by the first read) will not be executed.

[0029] Another solution for mitigating side channel attacks may be to simply slow down or pause the processing performed by the processing circuit for a period of time. By slowing down the pipeline, this significantly reduces the number of micro-ops that will be speculatively executed before the previous micro-op is resolved, effectively reducing the window of opportunity for an attacker to obtain information based on the incorrectly read secret data.

[0030] Other schemes for mitigating speculative side channel attacks may not focus on speculation, but rather on data caching of data loaded by speculative read operations. For example, a speculative side channel mitigation may be that the value loaded in response to a speculative read is not cached, or is placed in a temporary buffer or speculative area of ​​the cache that is flushed after a misspeculation occurs, or is allowed to affect the main non-speculative cache data only if the speculation is determined to be correct. In addition, speculative side channel mitigation measures may also include flushing or invalidating at least a portion of the data cache used to cache data read in response to a speculative read operation. These mitigations may not focus on reducing the aggressiveness of speculation, but rather on whether the effects of such speculation are visible to other operations, which may also mitigate the ability of an attacker to use a cache timing side channel to detect what data was speculatively loaded.

[0031] It will be appreciated that these are just some of the potential mitigations that can be taken. In general, the presence / absence of a prompt instruction can be used to control whether any of these steps are taken.

[0032] A computer-implemented method may be provided for generating a sequence of program instructions for processing by a processing circuit, including a speculative side channel hint instruction as described above. An input program code identifying an operation to be performed by the processing circuit may be analyzed to identify whether the operation represented by the program code includes a speculative side channel activation operation mode, wherein the mode includes a read operation for reading data from a memory system, for which there is a risk of information leakage if the read operation is speculatively processed by the processing circuit. Based on the input program code, a sequence of program instructions to be processed by the processing circuit may be generated. Depending on whether the program code includes a speculative side channel activation operation mode, at least one speculative side channel hint instruction may be inserted, the at least one speculative side channel hint instruction indicating whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed. For example, this method may be performed by software at compile time or link time, the software evaluating the operation to be performed and inserting hints as needed depending on whether any suspicious operation modes are identified. As described above, the hint may be inserted before a secure section of the instruction or before a potentially unsafe section. Alternatively, the method may be performed dynamically during execution of a given program code segment, such as by a just-in-time compiler or translator or by dynamic recompilation performed by profiling.

[0033] In one example, the speculative side channel activation operation mode (which is identified to determine whether to include a hint instruction) can be a sequence of operations including a producer read operation and a consumer read operation, for which speculative side channel activation operation mode, a target address of the consumer read operation depends on a data value read from the memory system in response to the producer read operation.

[0034] A computer program may be provided for controlling a data processing device to perform the method of generating program instructions. This computer program may be executed on the same processing device that will subsequently execute the generated program instructions, or on a completely separate computer (e.g., a computer running a compiler that compiles the code for execution on a target data processor). This computer program may be stored on a storage medium, which may be a non-transitory storage medium.

[0035] Figure 1An example of a data processing device 2 having a processing pipeline for processing instructions of a program to perform processing operations is schematically illustrated. The pipeline includes a fetch stage 4 for identifying the address of the next instruction to be processed in the program flow, which address is output as a fetch address to an instruction cache 6 and a micro-operation cache (or trace cache) 8. The fetch stage 4 can determine the fetch address based on a branch predictor 10 for predicting the result of a branch instruction. The instruction cache 6 caches instructions in the same form as the instructions are defined in the program code stored in the memory. Instructions from the instruction cache 6 are provided to a decode stage 12, in which the instructions are decoded into micro-operations (mop or uop) to be executed by an execution stage 14. Some program instructions can be mapped to a single micro-operation, while other program instructions can be mapped to multiple separate micro-operations, each micro-operation corresponding to a part of the function of the program instruction. For example, a load / store micro-operation for reading data from or storing data to a memory may be split into an address generation micro-operation for calculating the address of the load or store and a data access micro-operation for actually triggering access to the memory system based on the calculated address. Another example may be an arithmetic operation that may be represented by a single program instruction in memory but may be decomposed into several simpler micro-operations for separate processing by the execution stage 14.

[0036] The execution stage 14 may include a plurality of execution units for executing different types of micro-operations, for example, an arithmetic / logic unit (ALU) for processing arithmetic or logic micro-operations based on integer operands read from registers 16, a floating point unit for performing operations on floating point operands read from registers, and / or a vector processing unit for performing vector processing operations using operands from registers 16 (which specify the number of independent data values ​​within the same register). One of the execution units of the execution stage 14 may be a load / store unit 18 for processing read operations of reading data from a data cache 20 or a memory system 22 (which may include additional caches and main memory) and write operations of writing data to the data cache 20 or the memory system 22. The load / store unit may use a page table entry in a translation lookaside buffer (TLB) 24 to determine whether the processor is allowed to access a memory region identified by a target address of a read or write (load or store) operation in the current execution state. For example, the TLB may restrict access to certain memory regions to certain modes or privilege levels of the processor.

[0037] Instructions executed by the execute stage 14 are retired by the retire (or write-back) stage 26, in which the results of these instructions are written back to the registers 16. The processing pipeline can support speculative execution of micro-operations, for example, based on predictions made by the branch predictor 10 or other speculative elements such as data prefetchers or load value predictors, and thus the retire stage 26 can also be responsible for evaluating whether the prediction has been made correctly and can trigger the discarding of the results of the speculatively executed operation in the event of a misprediction. After a misprediction, the incorrectly speculated instructions can be flushed from the pipeline and execution can be resumed from the last correct execution point before the incorrect prediction was made.

[0038] A micro-operation cache (or trace cache) 8 may be provided to speed up processing and save power by eliminating the need to frequently call the decoding stage 12. Thus, micro-operations decoded by the decoding stage 12 based on program instructions from the instruction cache 6 or fused from multiple individual decoded micro-operations may be cached in the micro-operation cache or trace cache 8 for access when program execution reaches the corresponding fetch address again in the future. The micro-operation cache 8 (if provided) may cache micro-operations regardless of the sequence in which they are executed. For example, the micro-operation cache may have multiple entries that are marked based on the fetch address of the instruction corresponding to the micro-operation. Thus, in parallel with inputting the fetch address to the instruction cache 6, the fetch address may also be provided to the micro-operation cache, and if there is a hit in the micro-operation cache, this may control the multiplexer 30 to select the micro-operation output by the micro-operation cache instead of the micro-operation decoded by the decoding stage 12. In addition, a signal from the micro-operation cache may be used to place at least a portion of the decoding stage 12 in a power saving state when there is a hit in the micro-operation cache.

[0039] If a trace cache is provided, it may operate in a manner similar to a micro-op cache, with the difference that the trace cache may not only cache the micro-ops themselves, but may also track the sequence in which these micro-ops are actually executed by the execution stage 14. For example, the trace of executed micro-ops may include successive branch operations and different batches of micro-ops executed between branches may be strung together to provide a single entry in the trace, which may be fetched as a continuous block of operations for execution by the execution stage 14, without the fetch stage 4 needing to recalculate each successive fetch address individually in response to each processed micro-op. In addition, the micro-op cache may cache speculatively executed micro-ops that may subsequently be ultimately found to be incorrect, while the trace cache 8 may cache sequences of correctly executed micro-ops (traces corresponding to incorrectly speculated operations may be invalidated). It will be appreciated that some systems may have only one of a micro-op cache and a trace cache, while other systems may have both.

[0040] One benefit of providing a micro-operation cache or trace cache is that this can allow further performance optimization by fusing multiple micro-operations decoded by the decode stage 12 in response to separate program instructions into a single common micro-operation (if the processing units in the execution stage 14 support processing of combined micro-operations). By fusing micro-operations when possible, this reduces the amount of pipeline utilization required for that operation, freeing up pipeline slots to execute other operations, which can help improve performance.

[0041] 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 an integral feature of achieving very high performance. These speculative reads cause entries to be allocated into the cache whose addresses indicate the values ​​of the first speculative reads, 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. This becomes an exploitable side channel if untrusted code is able to 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.

[0042] For any form of monitoring software, it is common for untrusted code to pass data values ​​to be used as offsets into arrays or similar structures to be accessed by 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 paradigm may be written as follows:

[0043] 1 struct array {

[0044] 2 unsigned long length;

[0045] 3 unsigned char data[];

[0046] 4};

[0047] 5 struct array *arr = ...;

[0048] 6 unsigned long untrusted_offset_from_user = ...;

[0049] 7 if (untrusted_offset_from_user <arr->length) {

[0050] 8 unsigned char value;

[0051] 9 value =arr->data[untrusted_offset_from_user]; 10 ...

[0053] 11}

[0054] In modern microprocessors, processor implementations can often speculatively perform data accesses (implied by line 9 in the code above) to establish a 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) can speculatively load from any location 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 speculatively loaded value 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] 1 struct array {

[0057] 2 unsigned long length;

[0058] 3 unsigned char data[];

[0059] 4};

[0060] 5 struct array *arr1 = ...; / * Smaller array * /

[0061] 6 struct array *arr2 = ...; / *Array size is 0x400 * /

[0062] 7 unsigned long untrusted_offset_from_user = ...;

[0063] 8 if (untrusted_offset_from_user <arr1->length) {

[0064] 9 unsigned char value;

[0065] 10 value =arr1->data[untrusted_offset_from_user];

[0066] 11 unsigned long index2 =((value&1)*0x100)+0x200;

[0067] 12 if (index2 <arr2->length) {

[0068] 13 unsigned char value2 = arr2->data[index2];

[0069] 14}

[0070] 15}

[0071] In this example, "value" loaded from memory using the address calculated from arr1->data in conjunction with untrusted_offset_from_user (line 10) is then used as the basis for further memory accesses (line 13). Thus, 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 standard cache timing side channels. Because the address depends on the data in value, a portion of the data of value can be inferred using the side channel.

[0072] By applying this scheme to different bits of value (in several speculative executions), the entirety of value's data can be determined. Thus, untrusted software can access any location accessible to monitoring software by providing an out-of-range amount for untrusted_offset_from_user, and thus, this method can be used by untrusted software to recover the value of any memory accessible to monitoring software.

[0073] 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 that has been loaded based on untrusted input.

[0074] As a generalization of this mechanism, it should be recognized 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 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 may leave an indication of the value loaded by the first speculative load in such a way that the value loaded by the first speculative load can be read by code that would not otherwise be able to read the value using timing analysis of the cache. 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, where less privileged software can choose what values ​​are leaked in this way.

[0075] Therefore, it may be desirable to provide countermeasures against such attacks. Several mitigation measures may be used. For example, a read operation for reading data from the data cache 20 or the memory system 22 may be prevented from being speculatively executed, or speculation may be applied less aggressively by slowing down the pipeline or reducing the number of instructions that can be speculatively executed while waiting for the previous instruction to be resolved, which may reduce the window of opportunity for attackers to exploit the above-mentioned attack types. Other schemes may provide a speculative barrier instruction, which may be inserted when a certain number of control-related read operations are detected to separate consumer reads and producer reads, wherein the target address of the consumer read is calculated based on the previous data value read from the memory, and the producer read reads the data value from the memory, wherein the barrier instruction instructs the pipeline to prevent it from speculatively executing the second read when the first read is still speculative. This ensures that if the first read should never be executed, the barrier ensures that it will be canceled before encountering the second read. Other methods may be taken to reduce the impact of incorrectly speculatively executed read operations on the cache state. For example, data cache 20 may be partitioned into a primary cache region for non-speculative data and a speculative cache region for data read in response to speculatively executed read operations while the reads are still speculative. When the speculation has been resolved as correct, the data may be promoted to the primary region, and when an event indicating an increased risk of attack is identified (e.g., a switch to an execution mode with lesser privileges), the contents of the speculative region may be discarded. Additionally, in some cases, additional cache flushes may be performed to invalidate at least speculatively read data from the cache when an operating mode deemed to be at risk of attack is detected.

[0076] The common factor between any of these mitigations is that they tend to reduce the performance achieved by the processor because they either mean that instructions that could have been speculatively executed are suppressed, or that additional cache misses are incurred for some subsequent read operations to delay those reads and any operations that depend on them. While these mitigations can be effective in preventing attacks, they can unnecessarily hurt the performance of some program code that does not contain operating modes that can be used to trigger side-channel attacks.

[0077] In practice, it may be possible to identify instruction sequences that will not be used in any downstream control dependencies, and if this is the case, then no performance limiting precautions may need to be taken for these instructions.

[0078] For example, Figure 2 An example of a sequence of operations that may be considered to have a risk of leaking information through a speculative side channel attack is shown. This instruction sequence includes a consumer read operation 40 that reads a data value from a given address #add1 and stores the read data value in register R3. The data value at #add1 is potentially a secret value that is not accessible to some processes executing on processor 2. This is followed by one or more intermediate instructions for calculating a value based on the loaded data value, such as an AND instruction, and AND signaling combines the loaded value with a mask defined in register R2 to set an index value in target register R4. In some cases, multiple separate instructions may generate an index value based on the loaded data value. Subsequently, a consumer load 62 takes the index specified in register R4 and uses this index as an offset to combine with the base address in register R1 to obtain the address of a subsequent read operation that reads a data value from memory and places the address in target register R5.

[0079] Thus, this sequence includes a consumer load 42 whose target address depends on the value read by the preceding load 40. Therefore, if the producer load is incorrectly speculated, then even if this misspeculation is detected later when the consumer load is executed, the effects of the consumer load 42 on the data cache 20 may be visible to an attacker who does not have access to the secret data loaded by the producer load 40.

[0080] In contrast, for program code that includes read instructions whose data values ​​may never be used to compute the address of another read (e.g., because the data read, and any data dependent on the read, are overwritten before it can be used to compute the address of any subsequent read), then it may not be necessary to take measures to mitigate the risk of an attack.

[0081] Figures 3 to 5 Several examples of hint instructions are shown, which may be added by software compile time / link time or dynamically added at execution time through just in time (JIT) compilation or dynamic recompilation, or may be inserted by hardware that profiles the executed instructions to indicate whether the data from the next read or the next set of reads is likely to be used as a control operation object. This means that the processing pipeline can determine whether it is safe to speculatively execute these reads without speculative side channel mitigation measures based on the presence or absence of the hint instructions.

[0082] Figure 3 A first example of a hint instruction that can be used to mark instructions or micro-operations that are safe to execute without mitigation measures is shown. In this example, the hint instruction is assumed to apply to the immediately following read instruction. In this case, a read instruction without any preceding hint instruction can be assumed to be unsafe and therefore require the execution of mitigation measures. The hint instruction can be an architectural no-operation (NOP) instruction that has no effect on the processor state except controlling whether mitigation measures are executed.

[0083] Figure 4 A second example is shown in which a hint instruction is used instead to mark an unsafe read, where a read instruction without a preceding hint is assumed to be safe. In this case, the presence of a hint instruction (rather than a Figure 3 The absence of a hint instruction like in ) can trigger the execution of speculative side-channel mitigation measures.

[0084] Figure 5 Another example is shown where a safe speculation hint instruction is applied to a batch of N subsequent instructions to indicate whether any read operation triggered by any of the N instructions should be considered safe to execute without mitigation measures. Figure 5 Example, prompt instruction and Figure 3 The definition of (where the presence of a hint instruction indicates that any read triggered by a subsequent instruction block is safe) is similar. Figure 4 A similar batch of prompt instructions (which indicate a subsequent batch of unsafe instructions that do require mitigation measures) corresponds to the corresponding version. Figure 5 The example defines a batch of subsequent instructions as some predetermined number N of instructions or micro-operations, but another way to define a subsequent batch of instructions may be as a predetermined address offset relative to the address of the hint instruction, so that any instruction with an address within this address range is considered to be safe or unsafe as indicated by the hint instruction.

[0085] In some cases, the instruction cache 6 or micro-op cache (or trace cache) 8 may be annotated with information derived from the hint instruction. For example, an instruction that triggers a read operation may be marked with an annotation to indicate whether there was a previous hint instruction applied to the read. This may allow the hint instruction itself to be omitted from the instruction cache 6. A similar approach may be used for micro-ops in the micro-op cache 6.

[0086] Figure 6 The diagram shows the use of Figure 1 Flowchart of a method for processing instructions by a processor shown in FIG. 1. In step 100, micro-operations corresponding to instructions fetched from memory are decoded into micro-operations ready for processing by the execution stage 14. In step 102, the instruction decoder identifies whether any instruction to be processed is a speculative side channel hint instruction, wherein the speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed. In step 104, a control circuit associated with the processor 2 determines whether to trigger speculative side channel mitigation measures based on whether the speculative side channel hint instruction is included in the instruction. This control circuit can be, for example, the instruction decoder 12 itself, or it can be some circuit associated with the execution stage 14, which controls the degree of speculation or controls the stop of the pipeline as needed to ensure that a given operation is non-speculatively executed, or this control circuit can include some circuit associated with the data cache 20, which controls the way the results of the read operation are cached. Therefore, it will be appreciated that there may be a range of different components of the overall data processing system that can control some aspects of speculation / caching to control whether speculative side channel mitigation measures are performed based on whether the hint instruction is included.

[0087] Figure 7 is a flow chart illustrating a method of preparing program instructions for execution by a processor. At step 150, input program code is received that identifies operations to be performed. The input program code may be a set of instructions written in accordance with the same instruction set architecture that the processor will execute. However, the input program code may also be written in accordance with a higher level programming language (e.g., C) that is compiled into instructions from an instruction set architecture supported by the processor that is to execute the code. At step 150, the input program code is analyzed to identify whether any speculative side channel activation patterns exist. For example, the speculative side channel activation patterns may be, for example, Figure 2 , which includes a producer load 40 that reads a value from memory and a consumer load 42 with an address calculated based on the value read by the producer load. In some cases, the analysis may not attempt to find a sequence that definitely maps to a suspicious sequence that may cause an attack, but rather look for a sequence of instructions that can be guaranteed to be safe with respect to being attacked. For example, if it can be detected that the data value read by a given load instruction will never be used to generate the address of any subsequent load, it can be marked as safe. In some cases, a sequence of operations that cannot be determined to be safe with certainty may be assumed by default to contain a speculative side channel activation operating mode that may cause a risk of information leakage. Therefore, in some cases, the identified pattern may simply be any pattern that does not match the properties of a safe operating mode.

[0088] At step 152, a selection is made as to whether to insert a speculative side channel hint instruction based on the presence or absence of a speculative side channel activation pattern identified at step 150. For some forms of instructions, hint instructions may be inserted when a speculative side channel activation pattern is detected, while for other forms of hint instructions, hint instructions may be inserted in the absence of such a pattern. At step 154, the generated instructions (including any inserted hint instructions) are then output, where they may be saved to a memory or recording medium for subsequent execution by a target processor. The generated instructions may include the same instructions of the input program code, now expanded to include additional hint instructions, or may include an entirely different set of instructions, for example, translated or compiled into a different programming language or instructions.

[0089] Figure 7 The method may be performed in software by a compiler or just-in-time translator. The compiler / translator software may be stored on a recording medium. Alternatively, the trace of the executed instruction stream may be analyzed, for example, by a profiling circuit (which may generate additional hint micro-ops to be inserted into the micro-op cache to operate in the same manner as the hint instructions described above) so as to be performed by a hardware element within a processor executing the program code. Figure 7 method.

[0090] In summary, by supporting hint instructions that can be used to control whether it is necessary to perform side-channel mitigation measures, performance can be improved by enabling more aggressive speculation and / or less constrained caching when it is safe to do so. The presence of several additional hint instructions (which can sometimes occupy pipeline slots that could otherwise be used to perform actual processing operations) is unlikely to significantly reduce pipeline throughput, especially in modern processors with relatively wide fetch widths (the number of instructions fetched per cycle).

[0091] 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 to provide a defined operation, or a processor or other processing device may be programmed to perform the function. "Configured to" does not mean that the device elements need to be changed in any way in order to provide the defined operation.

[0092] Although illustrative embodiments of the present invention have been described herein in detail with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments and that various changes and modifications may be effected therein by those skilled in the art without departing from the scope and spirit of the invention as defined in the appended claims.

Claims

1. A data processing device, include: processing circuitry for performing data processing in response to the instruction, the processing circuitry supporting speculative processing of read operations for reading data from the memory system; as well as control circuitry for identifying whether a sequence of instructions to be processed by the processing circuitry includes a speculative side channel hint instruction, and determining whether to trigger a speculative side channel mitigation measure based on whether the instructions include the speculative side channel hint instruction, wherein the speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed, The control circuit is configured to trigger the speculative side channel mitigation measure for a given read operation in the absence of a preceding speculative side channel hint instruction associated with the given read operation.

2. The device according to claim 1, in, The speculative side-channel hint instruction indicates that it is safe to speculatively execute the at least one subsequent read operation without the speculative side-channel mitigation measure.

3. The device according to claim 1, in, The speculative side-channel hint instruction is associated with a single subsequent instruction, and the speculative side-channel hint instruction indicates whether there is a risk of information leakage if at least one read operation triggered by the single subsequent instruction is speculatively processed.

4. The device according to claim 1, in, The speculative side-channel hint instruction is associated with a batch of subsequent instructions, and the speculative side-channel hint instruction indicates whether there is a risk of information leakage if at least one read operation triggered by any one of the batch of subsequent instructions is speculatively processed.

5. The device according to claim 4, in, In response to a hint cancel event occurring in the middle of processing operations corresponding to the batch of subsequent instructions, the control circuit is configured to determine whether to perform the speculative side channel mitigation measures for remaining instructions in the batch of subsequent instructions as if the batch of subsequent instructions were not preceded by the speculative side channel hint instruction.

6. The device according to claim 5, in, The reminder cancellation event includes at least one of the following: anomalies or interruptions; Branches; Entering debug mode; and The breakpoint that triggers the diagnostic action.

7. The device according to claim 1, in, The processing circuit is configured to interpret the speculative side-channel hint instruction as an architectural no-operation instruction.

8. The device according to claim 1, in, The control circuitry is configured to annotate cached instructions or micro-ops based on the presence or absence of the speculative side-channel hint instruction in the sequence of instructions.

9. The device according to claim 1, in, The speculative side-channel mitigation measures include disabling speculative execution of read micro-operations.

10. The device according to claim 1, in, The speculative side-channel mitigation measures include reducing a maximum number of micro-ops that can be speculatively executed beyond the most recently resolved non-speculative micro-ops.

11. The device according to claim 1, in, The speculative side channel mitigation measure includes inserting a speculative barrier micro-operation into a sequence of micro-operations to be processed by the processing circuit to control the processing circuit to disable speculative processing of micro-operations following the speculative barrier micro-operation until any micro-operations preceding the speculative barrier micro-operation have been resolved.

12. The device according to claim 1, in, The speculative side channel mitigation measures include slowing down or stopping the processing of micro-operations by the processing circuit.

13. The device according to claim 1, in, The speculative side channel mitigation measure includes flushing or invalidating at least a portion of a data cache used to cache data read in response to a read micro-operation.

14. A data processing method, include: In response to the instruction, performing data processing using processing circuitry that supports speculative processing of a read operation for reading data from a memory system; identifying whether a sequence of instructions to be processed by the processing circuitry includes a speculative side channel hint instruction, wherein the speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed; determining whether to trigger a speculative side channel mitigation measure based on whether the instruction includes the speculative side channel hint instruction; and The speculative side-channel mitigation measure is triggered for a given read operation in the absence of a preceding speculative side-channel hint instruction associated with the given read operation.

15. A computer-implemented method for generating a sequence of program instructions for processing by a processing circuit, the method include: analyzing input program code to identify whether operations represented by the program code include a speculative side channel activation mode of operation, wherein the speculative side channel activation mode of operation includes a read operation for reading data from a memory system, and for the speculative side channel activation mode of operation, if the read operation is speculatively processed by the processing circuit, there is a risk of information leakage; generating the program instruction sequence based on the input program code; selecting whether to insert at least one speculative side channel hint instruction into the generated program instruction sequence based on whether the program code includes the speculative side channel activation operation mode, wherein the at least one speculative side channel hint instruction indicates whether there is a risk of information leakage if at least one subsequent read operation is speculatively processed, Wherein, when it is detected that the speculative side channel activation operation mode does not exist, the at least one speculative side channel hint instruction is inserted into the generated program instruction sequence.

16. The method according to claim 15, in, The speculative side channel activation mode of operation includes a sequence of operations including a producer read operation and a consumer read operation, wherein, for the speculative side channel activation mode, a target address of the consumer read operation depends on a data value read from the memory system in response to the producer read operation.

17. A storage medium storing a computer program for controlling a data processing device to execute the method according to any one of claims 15 and 16.