Exclusive return state lock parameters

By using the combination of exception return status lock parameters and GCS exception return status push/fetch instructions in the processing circuit system, the problem of tampering with exception return status information in ROP attacks is solved, and strong protection of exception return status is achieved to prevent attackers from Exception to modify status information between entry and return.

CN119072684APending Publication Date: 2024-12-03ARM LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380035796.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-04-28
Filing Date
2023-03-17
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

The prior art is difficult to effectively prevent tampering with exception return status information in ROP attacks, especially in the time window between exception entry and return. Attackers may modify the information in the exception return status register to bypass GCS-based data. Structural protection.

Method used

By introducing exception return status lock parameters in the processing circuit system, setting them to lock or unlocked state, detecting instructions that try to modify exception return status information, and sending errors in the locked state to prevent information tampering and entering the exception and when returning, perform GCS exception status push and fetch instructions respectively to eliminate the time window.

Benefits of technology

Effectively prevent the exception return status information from tampering between the exception entry and return, improves the protection strength of ROP attacks, and ensures the integrity and security of the exception return status.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119072684A_ABST
    Figure CN119072684A_ABST
Patent Text Reader

Abstract

An apparatus includes an exception return state register memory and processing circuitry. In response to a protection control stack (GCS) exception return state push instruction, the processing circuitry obtains exception return state information from the exception return state register memory and pushes the state information to a GCS data structure. In response to a GCS exception return state fetch instruction, the processing circuitry obtains exception return state information for GCS protection from the GCS data structure. In at least one operating state, the processing circuitry, in response to an attempt to modify the exception return state information stored in the exception return state register memory, detects whether an exception return state lock parameter is in a locked state or an unlocked state, and signals an error when it is in the locked state.
Need to check novelty before this filing date? Find Prior Art

Description

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

[0002] The data processing apparatus may store exception return state information in response to taking an exception. The exception return state information indicates the processor state at the time the exception was taken so that when exception processing is completed, the processor may return to processing that was being executed before the exception was taken.

[0003] At least some examples provide a device comprising: an exception return status register memory for storing exception return status information; and a processing circuit system for performing a processing operation in response to an instruction; wherein: the processing circuit system is configured to, in response to a protection control stack (GCS) exception return status push instruction, obtain the exception return status information from the exception return status register memory and push the exception return status information to a GCS data structure; the processing circuit system is configured to, in response to a GCS exception return status fetch instruction, obtain GCS protected exception return status information from the GCS data structure; the device includes a memory management circuit system to, in response to determining that the address corresponds to a target address The processing circuit system is configured to, in at least one operating state of the processing circuit system, detect, in response to an attempt to modify the exception return state information stored in the exception return state register memory, whether an exception return state lock parameter is in a locked state or an unlocked state, and, when detecting that the exception return state lock parameter is in the locked state, send an error with a signal.

[0004] At least some examples provide a method that includes storing exception return status information in an exception return status register memory; and using a processing circuit system, in response to an instruction, performing a processing operation; in response to a protection control stack (GCS) exception return status push instruction, obtaining the exception return status information from the exception return status register memory and pushing the exception return status information to a GCS data structure; in response to a GCS exception return status fetch instruction, obtaining GCS protected exception return status information from the GCS data structure; in response to determining that a memory area corresponding to a target address is designated as a GCS area for storing the GCS data structure domain, and the write request is a request other than a GCS memory access request triggered by a restricted subset of a restricted subset of GCS access types of instructions, the restricted subset of GCS access types of instructions including at least the GCS exception return status push instruction; and in at least one operating state of the processing circuit system, in response to an attempt to modify the exception return status information stored in the exception return status register memory, detecting whether an exception return status lock parameter is in a locked state or an unlocked state, and when detecting that the exception return status lock parameter is in the locked state, sending an error with a signal.

[0005] At least some examples provide a computer program including instructions that, when executed by a host data processing device, control the host data processing device to provide an instruction execution environment for executing a target code, the computer program including: register emulation program logic, the register emulation program logic being used to control the host data processing device to simulate an exception return status register memory for storing exception return status information; and handler logic, the handler logic being used to control the host data processing device to simulate the execution of the instructions of the target code; wherein: the handler logic is configured to, in response to a protection control stack (GCS) exception return status push instruction of the target code, control the host data processing device to obtain the exception return status information from the simulated exception return status register memory and push the exception return status information to a GCS data structure; the handler logic is configured to, in response to a GCS exception return status fetch instruction of the target code, obtain the exception return status information from the GCS data structure the computer program comprising memory management program logic to reject a write request specifying a target address in response to determining that a memory region corresponding to the target address is designated as a GCS region for storing the GCS data structure, and the write request is a request other than a GCS memory access request triggered by a restricted subset of a restricted subset of GCS access types of instructions, the restricted subset of GCS access types of instructions including at least the GCS exception return status push instruction; and the handler logic is configured to, in at least one simulated operating state of the handler logic, control the host data processing device to, in response to an attempt to modify the exception return status information stored in the simulated exception return status register memory, detect whether an exception return status lock parameter is in a locked state or an unlocked state, and signal an error when the exception return status lock parameter is detected to be in the locked state.

[0006] The computer program may be stored on a storage medium. The storage medium may be a non-transitory storage medium.

[0007] Further aspects, features, and advantages of the present technology will be 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 device having processing circuitry and memory management circuitry is shown;

[0009] Figure 2 An example of an execution state of a processing circuit system is shown;

[0010] Figure 3 shows a two-stage address translation;

[0011] Figure 4 An example of a register showing processing circuitry;

[0012] Figure 5 shows examples of instructions executed upon entry to and upon return from a taken exception;

[0013] Figure 6 shows the use of a guarded control stack (GCS) structure to protect return status information retrieved in response to exception entry;

[0014] Figure 7 shows an example of instructions executed upon entry to and upon return from a taken exception when using the GCS structure;

[0015] Figure 8 A flowchart showing a method for checking whether a memory access request is allowed;

[0016] Fig. 9 is a flow chart showing the steps performed upon exception entry;

[0017] Fig.10 A flowchart showing steps performed in response to a GCS exception return status push instruction;

[0018] Fig.11 A flow chart showing the steps performed in response to a GCS exception return status fetch instruction;

[0019] Fig.12 A flowchart showing steps performed in response to an exception return instruction;

[0020] Fig.13 and Fig.14 a flowchart showing two alternative examples of steps performed in response to an instruction requesting modification of exception return status information stored in an exception return status register memory; and

[0021] Fig.15 The simulator implementation is shown.

[0022] An apparatus has an exception return status register memory to store exception return status information and processing circuitry to perform processing operations in response to instructions.

[0023] Return-oriented-programming (ROP) attacks are common attack categories on data processing systems. ROP attacks are attacks that attempt to make a program behave in an unexpected manner by damaging the return status information used to return from a function call or exception. Typically, software stores return status information to a memory, for example, to facilitate the nesting of function calls or exceptions, where the return status information that can be used for an internal function call or exception is stored in a memory to save it before the return status information for an external function call or exception (of a nested set of function calls or exceptions) is overwritten in a register. A successful ROP attack can cause a function return or an exception return to return the program flow to an instruction other than the next instruction after the point at which the function is called or the exception is taken, which can allow an attacker to control the processing circuit system to perform any operation other than the sequence of operations expected by the programmer.

[0024] In order to protect against ROP-based attacks that tamper with the exception return status information, it is useful to provide a protection control stack (GCS) data structure that is used to protect the return status information for returning from the exception. In response to a protection control stack (GCS) exception return status push instruction, the processing circuit system obtains the exception return status information from the exception return status register memory and pushes the exception return status information to the GCS data structure. In response to a GCS exception return status fetch instruction, the processing circuit system obtains the GCS protected exception return status from the GCS data structure. Protection for the GCS data structure can be provided by a memory management circuit system that supports specifying a memory area as a GCS area intended for storing the GCS data structure. When a write request for a specified target address is a request other than a GCS memory access request triggered by a restricted subset of a restricted subset of the GCS access type of the instruction (the restricted subset of the GCS access type of the instruction includes at least the GCS exception return status push instruction), the memory management circuit system rejects the write request in response to determining that the memory area corresponding to the target address is designated as a GCS area. Thus, protected regions of memory may be defined that cannot be written to by all types of write requests (e.g., general purpose (non-GCS specific) store instructions may be excluded from a restricted subset of GCS access types of instructions). This limits the attack surface available to attackers attempting to corrupt GCS protected exception return states stored in GCS data structures. Thus, stronger protection may be provided for exception return states than using a general purpose stack maintained by software in a standard readable / writable memory region.

[0025] However, the inventors have recognized that there may be a time window between exception entry (when the exception return status is retrieved in the exception return status register memory) and the execution of the GCS exception return status push instruction, and another time window between the execution of the GCS exception return status fetch instruction and the exception return, where the exception return status information may be vulnerable to tampering in the registers, which if a successful attack can bypass the check of the protected exception return status information stored in the GCS data structure. If an attacker can modify the exception return status in the exception return status register memory between exception entry and the execution of the GCS exception return status push instruction, then the erroneous exception return status can be pushed to the GCS data structure and thus mistakenly considered to be trusted on the GCS data structure. Similarly, some attacks can be based on modifying the exception return status in the exception return status register memory after the execution of the GCS exception return status fetch instruction but before the execution of the exception return.

[0026] One approach to solving this problem may require that the operation of the GCS exception return status push instruction be performed in hardware instead in response to the exception entry itself, and the operation of the GCS exception return status fetch instruction be performed in response to the same instruction that triggers the exception return, to eliminate these time windows. However, this approach may increase the number of operations that need to be triggered by a single event (exceptions entry and return). Such an overload of actions required in response to a single triggering event may make it more complicated for processor microarchitecture designers to implement circuit hardware that supports such operations while meeting circuit timing requirements. Furthermore, separating the GCS exception return status push instruction from exception entry and separating the GCS exception return status fetch instruction from exception return also has the advantage that software has more flexibility in determining which exception entry / return events to protect or not protect, so it may not be desirable to combine such operations.

[0027] In the examples discussed below, an exception return state lock parameter is provided that can be set to a locked state or an unlocked state. In at least one operating state of the processing circuit system, the processing circuit system detects whether the exception return state lock parameter is in a locked state or an unlocked state in response to an attempt to modify the exception return state information stored in the exception return state register memory, and signals an error when the exception return state lock parameter is detected to be in the locked state. By providing an architectural mechanism to lock the exception return state information to prevent it from being modified, this can prevent tampering of the exception return state information in the window between exception entry and exception return state push to the GCS data structure and between the fetch of GCS protected exception return state information and a subsequent exception return, to improve the security provided by GCS-type checking of the exception return state information.

[0028] The processing circuit system may support the execution of instructions in one of a plurality of exception levels, the plurality of exception levels being associated with different privilege levels. In the at least one operating state of the processing circuit system, the processing circuit system may set the exception return state lock parameter to the locked state in response to taking an exception, wherein the exception is taken at the same exception level as the current exception level before taking the exception. Thus, for an exception taken in the same exception level as the processing executed before taking the exception, exception entry may cause the processing circuit system to lock the exception return state information from modification to protect the exception return state information retrieved in response to the exception entry from tampering before the retrieved exception return state information can be pushed to the GCS data structure. The setting of the exception return state lock parameter to the locked state may occur automatically in response to taking the exception, without requiring execution of an explicit software instruction after exception entry to set the exception return state lock parameter to the locked state.

[0029] The exception return state lock parameter is not necessarily set to the locked state in response to an exception entry, because the exception is taken in a higher privileged exception level than the current exception level before taking the exception. When an exception is taken in a higher privileged level, the higher privileged exception handling code can be trusted to properly manage the exception return. When exceptions are taken at the same exception level, attacks are more likely to occur. However, other implementations may choose to also lock the exception return state information when an exception is taken at a higher privileged exception level.

[0030] In the at least one operating state of the processing circuitry, the processing circuitry may set the exception return state lock parameter to the unlocked state in response to the GCS exception return state push instruction. Thus, once the exception return state information has been pushed to the GCS data structure, there is no longer a need to prevent modification of the exception return state information in the exception return state register memory, and thus by switching the lock parameter to the unlocked state, this allows subsequent operations that require information in the exception return state register memory to be effectively changed to proceed. Unlocking the exception return state lock parameter in response to the GCS exception return state push instruction also helps to improve security by allowing detection of situations when an instruction (e.g., an exception return instruction) executed at a time when exception return state modifications should be locked is executed in an incorrect program flow sequence at a time when exception return state modifications are currently unlocked.

[0031] In the at least one operating state of the processing circuit system, the processing circuit system may set the exception return state lock parameter to the locked state in response to the GCS exception return state fetch instruction. The GCS exception return state fetch instruction may mark the beginning of a window in which the exception return state fetched from the GCS data structure is vulnerable to tampering attacks, so locking the exception return state in response to the GCS exception return state fetch instruction helps to give confidence that, in subsequent exception returns, the exception return state information for the exception return is still the same as that obtained from the GCS data structure.

[0032] In the at least one operating state of the processing circuitry, the processing circuitry may, in response to an exception return instruction for triggering an exception return based on the exception return state information stored in the exception return state register memory (where the exception return is a return of a process at the same exception level as a current exception level prior to the exception return), check whether the exception return state lock parameter is set to the locked state, and signal an error in response to detecting that the exception return state lock parameter is set to the unlocked state. This may help protect against attacks that attempt to control program flow so that an exception return instruction is executed without first obtaining GCS-protected exception return state information using a GCS exception return state fetch instruction.

[0033] Different approaches may be taken to determine whether an error should be signaled when an instruction is executed (which may result in modification of information in the exception return status register memory when the exception return status lock parameter is set to the locked state).

[0034] In one example, in the at least one operating state of the processing circuitry, the processing circuitry may, in response to an attempt to execute an instruction requesting modification of information in the exception return status register memory when the exception return status lock parameter is set to the lock state, signal an error regardless of whether a new value to be written to the exception return status register memory is the same as or different from an old value previously stored in the exception return status register memory. Thus, in this case, when such modifications are locked, an error will be signaled if an instruction attempts to modify information in the exception return status register memory, even if the new value to be written by the instruction will be the same as the old value previously stored in the exception return status register memory. Even if the new value is the same as the old value, the exception return status information has not been modified, and it may be simpler (from the perspective of a hardware designer seeking to implement control circuit logic for controlling the signaling of errors in accordance with the exception return status lock parameter) to make the signaling of an error independent of any comparison between the old and new values, since there is no need to read the value currently stored in the exception return status register memory to determine whether an error has been triggered.

[0035] In another example, in the at least one operating state of the processing circuit system, in response to an attempt to execute an instruction requesting modification of information in the exception return state register memory when the exception return state lock parameter is set to the lock state, the processing circuit system may check whether the new value to be written to the exception return state register memory is the same or different from the old value previously stored in the exception return state register memory, and when it is determined that the new value is different from the old value, the error is sent with a signal. This method may be useful for speeding up the processing of certain fast exception program code paths, for which the exception handler is so close that it is not necessary to store / restore the exception return state to / from the stack in the memory. In this case, the exception handler may be biased not to execute any GCS exception return state push / take instructions, because the exception return state initially retrieved may be maintained in the exception return state register memory throughout the execution of the exception handler. This may mean that the exception return state lock parameter may be maintained in the lock state throughout the exception handler. There may be some legitimate reasons why the exception handler may still attempt to modify the exception return state register memory. Although when the lock parameter is in the locked state, if an attempt is made to modify the exception return status information stored in the exception return status register memory, an error should be triggered, but sometimes an attempt to modify can actually write the same value stored in the exception return status register memory, in which case the exception return status is not at risk of being damaged. For example, although there is no intention to change the exception return status information because in the fast exception program code path as discussed above, if the exception handler program code includes a common program code path shared with other use cases (wherein the exception return status information really needs to be modified), this may occur, and in any case, it is preferred (by avoiding conditional branches to speed up performance, that is) to execute an instruction that writes to the exception return status register, but in the case where the instruction is used together with the fast exception program code path, the operand for the instruction is set so that it writes the same value previously stored in the exception return status register. Therefore, at the time when the modification instruction will not change the value in the exception return status register memory, by not signaling an error at this time, this can improve performance by eliminating the delay caused by the signaling error (otherwise the signaling error will interrupt the current processing and cause another exception handler to execute).

[0036] The GCS exception return status fetch instruction can be implemented in different ways.

[0037] In some examples, the GCS exception return status fetch instruction may simply fetch the GCS protected exception return status information into register memory (either directly to the exception return status register memory, or to a general purpose register from which a subsequent instruction may move the GCS protected exception return status information to the exception return status register memory). Then, when a subsequent exception return instruction is executed, the GCS protected exception return status information may be used directly to control the exception return. In this case, there is no need for software managed storage / restoration of the exception return status information to a software managed stack structure in normal memory, because execution of the GCS exception return status push / fetch instruction means that the GCS data structure is sufficient to track the exception return status, even if nested exceptions cause the exception return status in the exception return status register memory to be overwritten.

[0038] In other examples, rather than being used to directly control exception returns, the GCS-protected exception return status may be used to verify whether the expected exception return status information stored in the exception return status register memory is safe to use for subsequent exception returns. In this case, software may use its normal mechanisms to manage the exception return status information in the exception return status register memory (e.g., if exceptions are nested, software stores / restores the exception return status to a stack data structure maintained in non-GCS memory). The GCS exception return status push / pop instructions additionally store / restore the exception return status to the GCS data structure to allow the expected exception return status information obtained by software to be checked before it is used to control exception returns.

[0039] Thus, in this example, in addition to causing the GCS protected exception return status information to be fetched from the GCS data structure, in response to the GCS exception return status fetch instruction, the processing circuitry also signals an error when a mismatch is detected between the expected exception return status information obtained from the exception return status register memory and the GCS protected exception return status information obtained from the GCS data structure. Thus, the GCS protected exception return status information is used to verify the expected exception return status information, rather than being used directly to control the exception return.

[0040] In another example, although the GCS-protected exception return state information may be used to verify whether the expected exception return state information is correct, this verification may not occur in response to the GCS exception return state fetch instruction itself, but instead, a subsequent GCS exception return state verification instruction may verify whether the expected exception return state information in the exception return state register memory matches the previously fetched GCS exception return state information obtained by the GCS exception return state fetch instruction.

[0041] The exception return status information stored in the exception return status register memory may take various forms. Generally speaking, the exception return status register memory may include one or more registers storing the exception return status information. For example, the exception return status register memory may include an exception return address register to store the exception return address of the instruction to be executed after returning from the exception; and / or a stored processor state register to store the processor state to be restored when returning from the exception. In response to the GCS exception return status push instruction, the information stored in one or both of these registers may be stored to the GCS structure.

[0042] The stored processor state register may be a register, wherein in response to taking an exception, the current processor state of the processing circuit system is copied from the processor state register to the stored processor state register. Since taking an exception may cause the current processor state to change, by copying the current processor state to the stored processor state register, the processing circuit system can then freely update the current processor state according to the state when the exception is taken, and the current processor state can be retrieved. The exception handler executed in software can then read the stored processor state register and store the retrieved state to the memory to ensure that the stored processor state is retained, even if another exception occurs and the processing of the previous exception is pre-empted. Using the GCS exception state push instruction, the stored processor state can also be pushed to the GCS data structure to enable verification of the exception return state information under the corresponding exception return.

[0043] It can be useful that the exception return state lock parameter is a parameter specified in the processor state register. This means that when taking an exception, the exception return state lock parameter itself will be automatically stored, because in response to taking an exception, the exception return state lock parameter can be copied to the stored processor state register together with the other contents of the processor state register. Similarly, in response to the exception return instruction, copying the stored processor state to the processor state register from the stored processor state register causes the previous value of the exception return state lock parameter to be restored. Therefore, this method means that if a new exception is taken during the window between the exception entry and the GCS exception return state push instruction or during the window between the GCS exception return state fetch instruction and the exception return, the current state of the exception return state lock parameter (which should be in the locked state during those windows) is retrieved and therefore can be restored as part of the normal recovery of the stored processor state when returning from the new exception, to return to the previous state of the exception return state lock parameter when the time of taking the new exception. Therefore, an attacker cannot use the mechanism of triggering a new exception as an attempt to bypass the protection provided by the exception return state lock parameter.

[0044] Modifications to the exception return status register memory based on exception return status lock parameter supervision need not be used in all operating states of the processing circuit system. For example, some control state information stored in one or more control registers can be used to determine whether the various checks of the exception return status lock parameter described above should be performed. Disabling such checks can be useful for backward compatibility with software that has been written for legacy systems that do not support the exception return status lock parameter. Such legacy software may require more vigilance by software developers to ensure that there are no vulnerabilities that can be exploited by an attacker to mount a ROP attack.

[0045] Thus, in one example, the at least one operating state of the processing circuit system includes an operating state in which the exception return state lock enable control parameter is set to an enabled state, indicating that locking of the exception return state information using the exception return state lock parameter is enabled. If the exception return state lock enable control parameter is set to a disabled state, then there is no need to update or check the exception return state lock parameter as discussed above.

[0046] In some examples, architectural mechanisms that support the use of GCS data structures (e.g., GCS exception return status push / pull instructions, other instructions that interact with GCS data structures, and various errors that are triggered to protect GCS data structures from unauthorized access) may be completely disabled depending on the state of the GCS enable parameter. Again, this may provide support for software written for legacy systems that do not support such GCS-type architectural mechanisms. Thus, at least one operating state of the processing circuitry (in which the various measures described above involve exception return status lock parameter taking) may include an operating state in which: the exception return status lock enable control parameter is set to an enabled state, which indicates that locking of exception return status information using the exception return status lock parameter is enabled; and the GCS enable parameter is set to an enabled state, which indicates that a GCS mode for supporting the use of the GCS data structure is enabled.

[0047] As discussed above, in response to determining that the memory region corresponding to the target address is designated as a GCS region and the write request is a request other than a GCS memory access request triggered by a restricted subset of the GCS access type of instructions that are allowed to access the GCS region, the memory management circuit system rejects the write request that specifies the target address. The memory management circuit system may also reject the memory access request in response to determining that the memory access request is the GCS memory access request and the memory region corresponding to the target address is not the GCS region. This reduces the attack surface available to attackers because it means that GCS memory access requests can only be used to access GCS regions and cannot be used to access regular memory regions used to store other data. This means that if the address operand of an instruction of the GCS access type is modified by an attacker (e.g., caused to be incorrect by the attacker, forcing an incorrect sequence of program flow) so that the GCS memory access request accesses a non-GCS region, this is detected as an error, and the request to access memory will be rejected. This improves security by preventing an attacker from being able to forge a GCS-protected exception return status by replacing a GCS data structure with another area of ​​memory.

[0048] Although the GCS data structure is described above as being used to protect exception return status information from ROP attacks, the same data structure may also be used to protect function return status information, such as a function return address. A mechanism may be provided for detecting whether information obtained from the GCS data structure is exception return status information or function return status information (e.g., by distinguishing between encodings of valid exception return status records and valid function return status records so that they can be distinguished), such that a GCS exception return status verification instruction may cause the processing circuit system to check whether the obtained GCS record used as exception return status information protected by the GCS corresponds to a valid exception return status record, and thus supervise against attempts to cause incorrect behavior by using the function return status record to verify the exception return status information used for the exception return.

[0049] In other examples, the GCS data structure may be used to protect exception return status information, but not to protect function return status information (e.g., a different mechanism may be used to protect function return status from ROP attacks, or protection from ROP attacks is not provided at the architectural level for function return status information (instead, the responsibility for protecting function returns from ROP attacks may fall on the software developer)). Thus, the GCS data structure is not necessarily shared between exception return status and function return status.

[0050] The techniques discussed above may be implemented within a data processing apparatus having hardware circuitry provided for implementing the processing circuitry and memory management circuitry discussed above.

[0051] However, the same techniques may also be implemented in a computer program that is executed on a host data processing device to provide an instruction execution environment for the execution of a target code. Even if the host data processing device itself does not support the architecture, this computer program can control the host data processing device to simulate the architecture environment that it will provide on a hardware device that actually supports the target code according to a certain instruction set architecture. The computer program may have a handler logic, a register emulator logic, and a memory management program logic (which emulates the functions of the processing circuit system), the exception return status register memory and memory management circuit system discussed above, including support for GCS exception return status push instructions and GCS exception return status fetch instructions, and exception return status lock parameters, as discussed above. For example, when legacy code written for one instruction set architecture is executed on a host processor that supports a different instruction set architecture, this simulator may be useful. Furthermore, since the execution of software on a simulated execution environment can enable software testing to be parallel to the ongoing development of hardware devices that support the new architecture, simulation can allow software development for a newer version of an instruction set architecture to begin before the processing hardware supporting the new architecture version is ready. The simulation program may be stored on a storage medium, which may be a non-transitory storage medium.

[0052] Specific examples of data processing equipment

[0053] Figure 1An example of a data processing device 2 is schematically shown. The data processing device has a processing pipeline 4 including several pipeline stages. In this example, the pipeline stages include an extraction stage 6 for extracting instructions from an instruction cache 8; a decoding stage 10 for decoding the extracted program instructions to produce micro-operations (decoded instructions) to be processed by the remaining stages of the pipeline; an issue stage 12 for checking whether the operands required for the micro-operation are available in the register file 14, and issuing the micro-operation for executing the required operands of the given micro-operation once as available; an execution stage 16 for executing the data processing operation corresponding to the micro-operation by processing the operands read from the register file 14 to produce a result value; and a write-back stage 18 for writing the processed results back to the register file 14. It should be understood that this is only one example of a possible pipeline architecture, and other systems may have additional stages or different stage configurations. For example, in an out-of-order processor, a register renaming stage for mapping architectural registers specified by program instructions or micro-operations to physical register descriptors identifying physical registers in the register file 14 may be included. In some examples, there may be a one-to-one relationship between program instructions decoded by decode stage 10 and corresponding micro-operations processed by execute stage 10. There may also be a one-to-many or many-to-one relationship between program instructions and micro-operations, such that, for example, a single program instruction may be split into two or more micro-operations, or two or more program instructions may be fused to be processed as a single micro-operation.

[0054] The execution stage 16 includes a number of processing units for performing different types of processing operations. For example, the execution units may include a scalar arithmetic / logic unit (ALU) 20 for performing arithmetic or logic operations on scalar operands read from registers 14; a floating point unit 22 for performing operations on floating point values; a branch unit 24 for evaluating the results of branch operations and adjusting the program counter, which indicates the current execution point accordingly; and a load / store unit 26 for performing load / store operations to access data in the memory system 8, 30, 32, 34. A memory management unit (MMU), which is an example of a memory management circuit system 28, is provided for performing address translation between virtual addresses specified by the load / store unit 26 based on operands of data access instructions and physical addresses identifying storage locations of data in the memory system. The MMU has a translation lookaside buffer (TLB) 29, which is used to cache address translation data from paging tables stored in the memory system, where paging table entries define address translation mappings and access permissions that control, for example, whether a given program executing on the pipeline is allowed to read, write or execute instructions from a given memory area.

[0055] In this example, the memory system includes a level 1 data cache 30, a level 1 instruction cache 8, a shared level 2 cache 32, and a main system memory 34. It will be appreciated that this is only one example of a possible memory hierarchy, and other arrangements of cache memories may be provided. The specific type of processing units 20 through 26 shown in the execution stage 16 is only one example, and other implementations may have different groups of processing units or may include multiple instances of the same type of processing unit so that multiple micro-operations of the same type may be processed in parallel. It will be appreciated that Figure 1 This is only a simplified representation of some components of a possible processor pipeline implementation, and the processor may include many other elements that are not shown for the sake of brevity. Figure 1 While a single processor core is shown accessing the memory 34 , the device 2 may also have one or more additional processor cores sharing access to the memory 34 , with each core having a respective cache memory 8 , 30 , 32 .

[0056] The apparatus also includes an exception handling circuit system 40 to control the handling of exceptions. In response to an exception signal 42, the exception handling circuit system 40 interrupts the processing being performed by the pipeline 4 and controls the pipeline 4 to switch to the processing of an exception handler corresponding to the type of exception indicated by the exception signal 42. For example, the exception may be an interrupt triggered by an external event that is not directly caused by the software being executed by the processing pipeline 4, for example, an interrupt that signals an external event, such as a user pressing a button on an electronic device including the processing device, a processor reset being asserted, a message being received from a network interface or other input / output device, etc. In addition, the exception may be a software-triggered exception caused directly by the instruction being executed by the pipeline 4. For example, a software-triggered exception may be automatically triggered by the software by executing an instruction, and the execution of the instruction causes a "supervisor call" interrupt to be taken to trigger a switch to a higher-privileged execution state. Alternatively, a software-triggered exception may be an exception that is not automatically triggered by the software, which occurs due to an error in at least the instruction executed by the software, such as an undefined instruction error or an address error.

[0057] Figure 2 1 is a diagram showing different execution states (also referred to as exception levels) in which the processing circuit system 4 can operate when executing instructions. In this example, there are four exception levels EL0, EL1, EL2, EL3, where exception level EL0 is the least privileged exception level and exception level EL3 is the most privileged exception level. Generally speaking, when executing in a higher privileged exception level, the processing circuit system can access some memory locations or registers 14 that are not accessible to lower, less privileged exception levels.

[0058] In this example, exception level EL0 is used to execute application programs, which are managed by the corresponding operating system or virtual machine executed at exception level EL1. In the case where multiple virtual machines coexist on the same physical platform, a virtual machine monitor operating at EL2 may be provided to manage the corresponding virtual machines. Figure 2 The example shows a hypervisor managing virtual machines and virtual machines managing applications, but it is also possible that the hypervisor directly manages applications at EL0.

[0059] Although not required, some implementations may implement different hardware partitions of secure and non-secure domains of operation of the processing circuit system. The data processing system 2 may have hardware features implemented in the processor and memory system to ensure that data and program code associated with software programs operating in the secure domain are isolated from access by programs operating in the non-secure domain. For example, a hardware architecture such as that developed by Cambridge, England, may be used. Provided by Limited Alternatively, other hardware-enforced secure segmentation architectures may be used. Secure applications (trusted services) may operate in exception level EL0 in the secure domain, and secure (trusted) operating systems or virtual machines may operate in exception level EL1 in the secure domain. In some implementations, EL2 in the secure state is not supported, and the hypervisor may only execute in the non-secure EL2. In other implementations, secure hypervisors executing in secure EL2 may be supported, such as Figure 2 Indicated by the asterisk in . In some examples, a security monitor program for managing the transition between the non-secure domain and the secure domain may be provided to execute in the exception level EL3. Other implementations may hardware supervise the transition between the secure domains so that a security monitor program may not be required.

[0060] If an exception is taken while processing at the current exception level ELx, the exception may be taken in the same exception level Elx or in a higher privilege exception level Ely, where y>x. Characteristics associated with an exception type may indicate a target exception level for the exception.

[0061] Address Translation

[0062] One task performed by the MMU 28 is address translation between virtual addresses (VA) and physical addresses (PA). Software executed on the processing circuit system 4 uses virtual addresses to specify memory locations, but these virtual addresses can be converted by the MMU 28 into physical addresses that identify the memory system locations to be accessed. The benefit of using virtual addresses is that it allows management software (such as an operating system (OS)) to control the view of memory presented to the software. The OS can control what memory is visible, the virtual addresses that are visible to the memory, and what access is allowed to the memory. This allows the OS to sandbox applications (hide the resources of an application from another application) and provide an abstraction of the underlying hardware. Another benefit of using virtual addresses is that the OS can present physical regions of multiple fragments of memory as a single continuous virtual address space to the application. Virtual addresses are also beneficial to software developers, who will not know the exact memory addresses of the system when writing their applications. With virtual addresses, software developers do not need to care about physical memory. The application knows that the OS and the hardware are responsible for working together to perform address translation.

[0063] In practice, each application can use its own set of virtual addresses, which will be mapped to different locations in the physical system. When the operating system switches between different applications, it reprograms the mapping. This means that the virtual address for the current application will be mapped to the correct physical location in memory.

[0064] Virtual addresses are converted to physical addresses via mapping. The mapping between virtual addresses and physical addresses is stored in a translation table (sometimes called a paging table). The translation table is stored in memory and managed by software (usually an OS or a hypervisor). The translation table is not static and can be updated as the software changes requirements. This changes the mapping between virtual and physical addresses.

[0065] For memory accesses performed when processing circuitry 4 is in a particular subset of execution states (specifically, when processing circuitry 4 is in non-secure EL0 or non-secure EL1), the following are used: Figure 3 The two-stage address translation shown (for other execution states, a one-stage address translation using the stage 1 paging table is sufficient). Therefore, virtual addresses from non-secure EL0 and non-secure EL1 are translated using two sets of tables. These tables support virtualization and allow the hypervisor to virtualize the view of physical memory seen by a given virtual machine (VM) (the virtual machine corresponds to the guest operating system and the applications controlled by the guest operating system). The set of translations controlled by the OS is called stage 1. The stage 1 table translates virtual addresses into intermediate physical addresses (IPA). In stage 1, the OS considers IPA to be a physical address space. However, the hypervisor controls a second set of translations, which is called stage 2. This second set of translations converts IPA into physical addresses.

[0066] The stage 1 and stage 2 translation tables are implemented as a hierarchical table structure, which includes multiple levels of translation tables, respectively for stage 1 and stage 2. Both stage 1 and stage 2 can have up to 4 levels of paging tables, namely, level 0 (L0), level 1 (L1), level 2 (L2) and level 3 (L3).

[0067] To locate the physical address for a given address mapping, a translation table walk is performed, which includes one or more translation table lookups. A translation table walk is the set of lookups required to convert a virtual address to a physical address. For the non-secure EL1 and 0 translation scheme, this set includes lookups for both stage 1 translations and stage 2 translations. The information returned by a successful translation table walk using both stage 1 and stage 2 lookups is:

[0068] • Required physical address (translated based on stage 1 mapping to intermediate address and stage 2 mapping to physical address).

[0069] Access permissions and / or memory attributes for the target memory region, which provide information about how access to that memory region is controlled. These may include stage 1 access permissions and / or attributes defined in the stage 1 table structure and stage 2 access permissions and / or attributes defined in the stage 2 table structure.

[0070] To traverse a given one of the Stage 1 and Stage 2 structures, the walk begins with an initial lookup of the top level (L0) translation table, based on the address specified in the Translation Table Type Address Register (TTBR for Stage 1, VTTBR_EL2 for Stage 2). Each translation table lookup returns a descriptor indicating one of the following:

[0071] The entry is the final entry of a traverse of the stage 1 or stage 2 structure, which provides the address mapping being sought. If the entry is in the final L3, this entry is called a page descriptor (D_Page), and if the entry providing the final entry of the walk is at one of the higher levels, it is called a block descriptor (D_Block). The final entry of the traverse contains the output address (OA - i.e., IPA for stage 1 or PA for stage 2), and the permissions and attributes for access. If a block descriptor is found at a higher level of the translation table structure, this means that the block descriptor represents a memory region of a larger size than the 4kB memory page represented by a single entry in the L3 (the specific size represented by the block descriptors in the L1 and L2 depends on the number of index bits used to index into the L1 or L2 tables - in this example, the L1 and L2 block descriptors represent 1GB and 2MB regions, respectively).

[0072] An additional level of lookup is required. In this case, the entry is called a table descriptor (D_Table) because it provides the conversion table type address for the lookup in the further level of the table. The table descriptor may optionally also provide other hierarchical attributes that may be applied to the final conversion. The encoding of the conversion table entries at levels 1 and 2 distinguishes between block descriptors and table descriptors.

[0073] The descriptor is invalid. In this case, the memory access generates a conversion error.

[0074] Register Status

[0075] Figure 4An example of a subset of registers 14 of a data processing device is shown, including registers for storing architectural states for handling exception returns and registers for protecting exception return states from tampering. Registers 14 include a set of general purpose registers (GPRs) 50, which are used to store general operands and the results of data processing instructions and load / store instructions. A program counter (PC) register 52 is provided to store a program counter value, which indicates the address of the instruction representing the current point of program flow. A processor state (PSTATE) register 54 stores one or more values ​​indicating the current state of the processing circuit system 4. For example, the PSTATE register 54 includes an indication 56 of the current exception level EL. The PSTATE register 54 may also include an indication of the current instruction set for decoding instructions at the decoding stage 10, an indication of the current security state, other indications of the processor mode in which the processing circuit system 4 operates, and a conditional code flag for indicating the result of a previously processed instruction, which can be used to evaluate whether a test condition is satisfied for a subsequent conditional instruction (the conditional instruction controls the processing circuit system to perform a function under the condition that the test condition is satisfied). Furthermore, as discussed further below, PSTATE register 54 includes an exception return state lock parameter (EXLOCK) 58 for locking exception return state information from updates.

[0076] Registers 14 include several exception return registers, in this example, including a stored processor state register (SPSR) 60 and an exception link register (ELR) 62. In this example, SPSR 60 and ELR 62 are protected registers, which means that multiple separate instances of these registers are provided corresponding to different exception levels EL1 to EL3. When an exception is taken to be processed in a given exception level Elx (where Elx is one of EL1, EL2, and EL3), the current program counter stored in program counter register 52 is copied to ELR_Elx 62, and the current processor state stored in PSTATE register 54 is copied to SPSR_Elx 60 (that is, copied to the ELR 62 and SPSR 60 corresponding to the given exception level Elx). The copy value of the program counter can be referred to as the exception return address. The copy value of the current processor state can be referred to as the stored processor state. The exception return address and the stored processor state can be collectively referred to as the exception return state information. When returning from an exception handled in a given exception level Elx, the stored processor state is copied from SPSR_Elx 60 to PSTATE register 54, and the exception return address is copied from ELR_Elx 62 to program counter register 52 to restore the processor to the state it was in when the exception was taken. The register subscript Elx indicates that the lowest privilege exception level that allows instructions to write to these registers is exception Elx. Thus, for example, SPSR_EL2 will be writable when in EL2 or EL3, but not when in EL0 or EL1.

[0077] Registers 14 also include a protected control stack pointer register (GCSPR) 64, which is also protected at each exception level so that each of the associated exception levels EL1, EL2, EL3 has a version GCSPR_Elx. The GCS pointer register 64 is used to store a stack pointer, which points to a data structure in memory called a protection control stack (GCS), which is used to protect the exception return status stored in SPSR 60 and ELR 62 when an exception occurs. This is discussed in more detail below. Furthermore, registers include a GCS control register (GCSCR) 66, which is also protected at each exception level to provide a version GCSCR_Elx corresponding to the exception level EL1, EL2, EL3. When the processing circuit system 4 operates in a given exception level Elx, the corresponding stack pointer and GCS control registers GCSPR_Elx and GCSCR_Elx provide stack pointers and control states for controlling the use of the GCS data structure. The GCS control registers 66 include at least a GCS enable parameter 68 for controlling whether architectural measures for protecting the use of GCS data structures are enabled or disabled, and an exception return status lock enable parameter (EXLOCKEN) 69 for controlling whether the use of the exception return status lock parameter (EXLOCK) 58 for preventing modification of the exception return registers 60, 62 is enabled or disabled. It should be appreciated that the GCS control registers 66 may also store other status information for controlling the behavior of the processing circuitry when in a GCS mode in which the use of the GCS data structures is enabled as indicated by the enable parameter 68.

[0078] Although Figure 4 An example of registers 60, 62, 64, 66 being protected to provide multiple versions of these registers corresponding to different exception states of the processing circuit system 4 is shown, this is not necessary, and in other examples, a single version of any of these registers can be provided, shared between the exception states. In this case, when switching between exception states, the software can switch the values ​​stored in the shared registers so that the values ​​stored in the shared registers in a given exception state may be different from the values ​​stored in the shared registers in different exception states. It is also possible that a subset of registers 60, 62, 64, 66 is protected, while another subset of registers 60, 62, 64, 66 is shared between exception states.

[0079] Figure 5 An example of instructions executed upon exception entry and return in a system that does not support the use of GCS is shown. Figure 5The left hand side of shows the exception entry sequence. In response to the exception handling circuit system 40 taking the exception, the exception handling circuit system 40 triggers the processing circuit system 4 to copy the current program counter value and the current processor state from the program counter register 52 and the PSTATE register 54 to the exception link register 62 and SPSR60 associated with the exception state Elx where the exception will be taken. The copying of the exception return state of the exception is triggered by hardware, so there is no need to execute any specific instructions to cause the copying of the exception return state. The exception handling circuit system 40 then controls the processing circuit system to execute the exception handling routine. For example, the exception handling routine initially executed in response to the exception entry can be a general exception wrapper data processor that performs some general control functions before branching to a more specific processor for handling the specific cause of the exception. Therefore, before branching to a particular processor, in order to ensure that the stored exception return state is preserved even if another exception occurs causing a new exception return state to be copied to registers 60, 62, the exception handling routine executes instruction 72 to push register state information (including at least the exception return state information from SPSR 60 and ELR 62) to a software maintained data structure in memory, such as a stack. The particular manner in which the data structure used to save the exception return state is organized may be selected in a software specific manner, and there may be no architectural definition of how this exception return state will be saved. After the exception return state has been stored in memory, the exception handling software program code executes a function known as branch instruction 74, which branches to the specific processor program code that handles the cause of the exception.

[0080] After returning from the exception, the exception handling software program code executes instruction 76 to read the previously stored register state from the data structure in memory (e.g., to fetch the register state from the stack data structure); instruction 77 to restore the register state to the exception return registers 60, 62 (e.g., this may be a system register modification instruction, allowing writes to system control registers); and exception return instruction 78 to trigger an exception return based on the exception return state stored in registers 60, 62. Thus, the exception return instruction 78 causes the previously stored processor state to be copied from SPSR_Elx 60 to the PSTATE register 54, and the previously stored exception return address to be copied from ELR_Elx 62 to the program counter register 52. This results in a branch to the instruction indicated by the previously stored exception return address, which will be executed with the processor state as indicated in the previously stored processor state value in SPSR_Elx.

[0081] An attacker may attempt to mount a return-oriented programming (ROP) attack by tampering with the exception return state information while the exception return state information is held in memory between being written by instruction 72 and read by instruction 76. If the attacker successfully corrupts the exception return state, this may allow the exception return to return to a different program point than the program point at which the exception was taken; or return the processor state represented by PSTATE register 54 to a different state than when the exception was taken (e.g., a state with greater privileges), both of which may result in undesirable behavior that may potentially risk compromising secure information or software program code.

[0082] Figure 6 A technique for protecting against such ROP attacks on the exception return state is shown. Upon exception entry, additional instructions are executed to push the exception return state retrieved in registers 60, 62 for the exception to a protection data structure called a protection control stack (GCS) data structure 80. Based on the GCS stack pointer register 64 associated with the current exception state Elx, the address to which the exception return state is to be pushed is determined. The access permissions specified by the paging table (used by the MMU 28 to control address translation) define the address area used to store the GCS data structure 80 as a special "GCS" memory type, whose access is limited only to a restricted subset of GCS access instructions, and cannot be accessed using instructions of other types that are not in the restricted subset. Therefore, when the instruction is not one of the special GCS access instructions, an attacker who tampers with the address operand of a general load / store instruction of the program being executed cannot make the instruction access the GCS data structure 80. For example, the GCS memory type may be indicated within stage 1 access permissions specified directly or indirectly by a corresponding stage 1 translation table entry used to provide a mapping between the virtual address space and the intermediate address space (e.g., the GCS memory type permissions may be indicated in the encoding of the stage 1 translation table entry itself, or in a register referenced by the stage 1 translation table entry). Conversely, if a GCS access instruction attempts to access a memory region that is not specified as a GCS memory type, an error may be signaled to prevent an attacker from tricking a GCS access instruction into accessing a region outside of the GCS data structure 80.

[0083] In the case of an exception return, unlike Figure 5The discussed software controlled restoration of the exception return state from any software specific data structure in memory (expected to be subsequently used by the exception return state instruction 78 to control the exception return), executing an additional GCS fetch instruction to fetch the protected exception return state from a location on the GCS data structure 80 determined based on the GCS stack pointer in GCSPR_Elx64, comparing the protected exception return state to the expected exception return state, and signaling an error if a mismatch is detected. This provides a means to detect whether the expected return state has been tampered with in memory before being fetched by instruction 76. If the expected exception return state matches the protected exception return state obtained from the GCS data structure 80, the exception return instruction 78 can trigger an exception return based on the expected exception return state.

[0084] Therefore, if Figure 7 As shown, the exception entry and return code is expanded to include additional GCS exception status push instructions 81 on exception entry and GCS exception status verification (fetch and compare) instructions 82 on exception return to provide additional protection for the exception return status pushed to memory by instruction 72 and read back by instruction 76. Figure 7 While a single instruction 82 is shown fetching the protected exception return state from the GCS data structure 80 and verifying the expected exception return state in registers 60, 62 with the protected exception return state, other examples may separate this into two different instructions, one for fetching the protected exception return state from memory, and another for verifying that the expected exception return state matches the fetched exception return state. Further, in some examples, the GCS exception return state fetch instruction 82 may simply fetch the exception return state from the GCS data structure 80, but not verify it with the exception return state in the exception return state registers 60, 62 (e.g., the GCS exception return state fetch instruction 82 may fetch the GCS protected exception return state directly into the exception return state registers 60, 62, and the exception return instruction 78 may use the GCS protected exception return state from registers 60, 62 to directly control the exception return - in this case, software would not need to execute instructions 72, 76 to push / fetch the exception return state to a separate software managed stack in normal non-GCS memory).

[0085] Instructions 81, 82 provided for pushing exception return status to and fetching exception return status from the GCS structure 80 are considered GCS access instructions, allowing access to a memory region designated as a GCS region of memory in the stage 1 access permissions.

[0086] It should be appreciated that when the GCS enable parameter 68 is set to an enabled state indicating that the GCS mode is enabled, the various GCS-related functions discussed above may be performed. When the GCS enable parameter 68 is set to a disabled state to indicate that the GCS mode is disabled (e.g., this may be used for compatibility with legacy code that is not designed for the GCS mode), then GCS access instructions may be processed as operation instructions without an architectural function (resulting in a signaling error if the GCS access instruction is executed), and additional checks that may be performed for certain non-GCS access instructions when the GCS mode is enabled may be omitted (see the exemplary flow chart discussed below).

[0087] GCS mode may be used to support a protected area in memory for maintaining a copy of the valid exception return state retrieved for a given exception, which may be used to directly control the exception return, or to verify the "expected" exception return state that will be used to control the exception return.

[0088] However, because the GCS exception status push instruction 80 is separated from the hardware triggered retrieval of the exception return status that should be performed upon exception entry 70, there is a time window 90 (in Figure 7 80) where an attacker may attempt to modify the contents of exception return status registers 60, 62 such that the exception return status pushed to GCS data structure 80 in response to instruction 81 is different from the exception return status retrieved in response to taking the exception. Similarly, upon an exception return, there is a time window 92 (labeled "window B") between the execution of GCS exception return status fetch instruction 82 and the execution of exception return instruction 78 where the exception return status information may be modified in registers 60, 62, which may allow an exception return to be triggered to a program counter value and processor state that is not obtained from GCS 80 or is verified with the state obtained from GCS 80.

[0089] To address this issue, an exception return state lock parameter (EXLOCK) 58 is provided in the PSTATE register 54. EXLOCK 58 can be set to a locked state and an unlocked state. In one example, EXLOCK=1 is in a locked state, and EXLOCK=0 is in an unlocked state. Other examples may use the opposite mapping, or EXLOCK 58 may be a multi-bit parameter that encodes the exception return state lock parameter and other information, where a first subset of the states of EXLOCK 58 may be considered a locked state, and a second subset of the states of EXLOCK 58 may be considered an unlocked state. Thus, there are various ways in which EXLOCK 58 may be encoded to indicate locked and unlocked states.

[0090] When EXLOCK is in the unlocked state, modification of the exception return status registers may be permitted (provided any other checks are satisfied, such as that the current exception level 56 is sufficiently privileged to update the particular protected version of the exception return status registers 60, 62 being attempted to be modified). When EXLOCK 58 is in the locked state, modification of the information in the exception return status stored in registers 60, 62 is prohibited, even if an attempt is made to use instructions that would allow modification of the exception return status information if EXLOCK 58 were executed in the unlocked state. EXLOCK parameter 58 may be set to lock the exception return status registers 60, 62 from being modified, at least for exceptions taken in the same current exception level before the exception was taken. Figure 7 The modifications during window A 90 and window B 92 are shown to prevent the exception return state from being tampered with between the time it is retrieved and pushed to the GCS data structure 80 upon exception entry and between the time it is verified with the protected exception return state restored from the GCS data structure 80 and used for the exception return 78. It can be assumed that exceptions taken at a higher privilege exception level than the current exception level do not need to set the lock parameter when the exception is taken because the higher privilege program code executing after the exception is taken can be trusted to properly manage its return state.

[0091] Thus, an architectural mechanism is provided to prevent the exception return state from being modified before it is stored in the GCS data structure 80 and after it is restored from the GCS data structure 80. When an exception is taken, the state is locked and cannot be modified. PSTATE.EXLOCK 58 can lock write access to the ELR 62 and SPSR 60 (at least for writes that attempt to change the value stored in register 60 or 62), and is set when an exception is taken. When the push routine 81 is executed to store the exception return state to the GCS buffer 80, PSTATE.EXLOCK is not locked, allowing future writes to registers 60, 62. When the pop routine 82 is executed to restore the exception return state from the GCS buffer 80, PSTATE.EXLOCK is re-locked, preventing future writes and ensuring that the state restored from the GCS is immutable. When locked, an attempt to write to the state (ELR / SPSR) results in a signaling error (which can cause another exception to be taken). Alternatively, this error can only occur if the value written to one or both of the registers 60, 62 is different from the current value in the register. This allows for fast code paths in situations where the return state remains unchanged.

[0092] An additional check of the EXLOCK parameter 85 may be performed so that an error may be triggered if any of the following occurs:

[0093] Exception entry 70 when the EXLOCK parameter 85 is currently in the locked state;

[0094] · GCS exception status push procedure 81 when the EXLOCK parameter 85 is currently in the unlocked state;

[0095] GCS exception state extraction procedure 82 when the EXLOCK parameter 85 is currently in the locked state; and

[0096] Exception return 78 when the EXLOCK parameter 85 is currently in the unlocked state.

[0097] Any of these events may indicate that an attacker has corrupted the control flow to omit one of the GCS protected instructions or cause program code to execute in an order different from that expected, which may be a sign of an attempted ROP attack.

[0098] The exceptional return state lockout enable control parameter EXLOCKEN 69 may be set to an enabled state or a disabled state (which again may be encoded in a manner similar to those discussed above for EXLOCK 58), with the enabled state indicating that the exceptional return state lockout features discussed above using the exceptional return state lockout parameters 58 are enabled, and the disabled state indicating that such exceptional return state lockout features are disabled. As will be described below, if the GCS mode is disabled or EXLOCKEN 69 is set to a disabled state using the GCS enable parameter 68 set to a disabled state, the various checks based on the EXLOCK parameter 58 (and the actions that set the EXLOCK parameter 58 to a locked or unlocked state) may be disabled.

[0099] Figure 8 FIG. 1 is a flow chart showing the access permission check performed by the MMU 28 for issued memory accesses when the GCS mode is enabled by the GCS enable parameter 68 stored in the GCS control register 66 for the current exception level Elx. At step 100, a memory access request is issued, which specifies a target virtual address corresponding to a target memory region. At step 102, based on the following example, Figure 3The MMU 28 initiates address translation based on the relevant stage 1 (and if necessary, stage 2) address mappings defined in the stage 1 and stage 2 address translation structures shown. Any known address translation techniques can be used to define the address mappings used for translation. In step 104, the MMU 28 determines whether the stage 1 permission information (directly or indirectly specified by the target stage 1 translation table entry that provides the address mapping of the target virtual address) specifies that the target memory area is a GCS area. For example, the stage 1 permission information can be encoded in the target stage 1 translation table entry itself, or stored in a register field referenced by the target stage 1 translation table entry. Other examples can define the GCS area using the stage 2 permission information specified by the stage 2 translation table entry (directly or indirectly via reference registers), and the stage 2 translation table entry corresponds to the intermediate address mapped to the target VA by the target stage 1 translation table entry. In addition, which memory areas are GCS areas can be defined for different data structures (different from the translation table structure).

[0100] If the target memory region is a GCS region, then at step 106, the MMU 28 determines whether the memory access request is a GCS memory access request triggered by one of a restricted subset of GCS access types that allow instructions to access GCS regions. If not, then at step 107, the MMU 28 determines whether the memory access request is a write request. If the memory access request is a write request, then at step 108, an error is signaled to prevent other general load / store instruction types from being able to access the GCS structure 80. If the memory access request is a read request, then no error needs to be signaled, and the method continues to step 110 (other examples may choose to also signal an error for non-GCS read requests to GCS memory regions, but this is optional because read requests will not corrupt GCS protected exception return status information).

[0101] If the memory access request is a GCS memory access request, then at step 110, the MMU 28 determines whether the memory access request satisfies any other access permissions. For example, this may be based on other parameters specified in the stage 1 or stage 2 translation table entry corresponding to the target region, or other security checks, such as based on the security state, exception level, or other operating mode of the processing circuit system 4. If any other required access permissions are not satisfied, an error is again signaled in step 108. If any other access permissions that the memory access request needs to satisfy are determined to be satisfied, then at step 112 the memory access request may be allowed.

[0102] If at step 104, the MMU 28 determines that the target memory region is not a GCS region, then at step 114, the MMU 28 determines whether the memory access request is a GCS memory access request triggered by one of a restricted subset of the instruction's GCS access type. This is the same check as at step 106, but with the opposite result compared to step 106. At step 114, if the memory access request is a GCS memory access request, then an error is signaled at step 108. This ensures that GCS memory access requests cannot be used to access non-GCS regions of memory (which will prevent software developers from being induced to use the GCS access type of instructions for non-GCS access (which will increase the attack surface available to attackers)), and allows detection of address operands of the GCS access type of instructions being modified by an attacker to point to regions outside of the GCS. By restricting the GCS access type of instructions to access GCS regions and the non-GCS access type of instructions to access non-GCS regions, security can be improved.

[0103] If at step 114, it is determined that the memory access request is not a GCS memory access request, then at step 116, the MMU 28 determines whether the memory access request satisfies any other access privileges. For example, this may include checks based on security state, exception level, or operating mode, as discussed above. If all required access conditions are met, at step 118, the memory access request is allowed. If any access privileges are violated, an error is signaled at step 108.

[0104] Although Figure 8 A single step 108 is shown signaling an error in response to several different check failures, but it will be appreciated that some implementations may signal different error types depending on the cause of the error.

[0105] Figure 8 The checks performed are shown if a memory access request is received while GCS mode is enabled by the GCS mode enable parameter 68 in the GCS control register 66 for the current exception level Elx. If GCS mode is currently disabled, steps 104, 106, 107, 114 may be omitted and the checks performed may be based on other access permissions not related to the use of the GCS data structure 80 as described at steps 110, 116.

[0106] like Figure 8 As shown, protection for the GCS data structure 80 is provided at the architectural level by the MMU 28 supporting the definition of a dedicated GCS memory region type (e.g., using a translation table) indicating that addresses in this region are subject to additional protection because they are required to be accessed by a restricted subset of the GCS access types of instructions and not by other load / store instructions. The GCS access types of instructions may include at least the GCS access types described above in Figure 7 8 and 9. Other types of GCS access types of instructions may also be provided, such as a standalone GCS exception return status fetch instruction that fetches an exception return status from the GCS data structure 80 without also verifying it against an expected exception return status. Other GCS access types of instructions may be provided for pushing and restoring function return status to protect, for example, a return address for a function return.

[0107] Fig. 9 Flowchart showing the steps performed in response to exception entry. At step 120, the exception handling circuit system 40 detects that an exception will be taken based on the exception signal 42, and triggers the exception entry program. In response to the exception entry, at step 122, the program counter and the current processor state are copied from registers 52, 54 to the exception link register 62 and the stored version of the processor state register 60 corresponding to the exception level Elx where the exception is taken. At step 124, the processing circuit system 4 or the exception handling circuit system 40 updates the program counter register 52 to indicate the address of the first instruction to be executed from the exception entry program code, and updates the PSTATE register 54 to indicate the processor state where the exception will be taken, so as to cause a branch to the exception entry program code, which will then be executed in the new state indicated by the PSTATE register 54. At step 126, the processing circuit system 4 determines (based on the GCS enable parameter 68) whether the GCS mode is currently enabled, and determines (based on the GCS exception return state lock enable parameter EXLOCKEN 69) whether the lock of the exception return state is enabled (the version of parameters 68, 69 to be used is the version stored in one of the protection versions of the GCS control register 66 corresponding to the current exception level Elx). Furthermore, the processing circuit system 4 determines whether the exception is to be taken at the same exception level (Elx) as the current exception level before the exception is taken. When the GCS mode is enabled and the lock of the exception return state is enabled, and the exception is taken at the same exception level as the current exception level before the exception is taken, then at step 128, the processing circuit system 4 sets the exception return state lock parameter EXLOCK 58 to the locked state. Otherwise, at step 129, EXLOCK 58 is set to the unlocked state. Although Fig. 9 An example is shown in which the EXLOCK 58 is set to the locked state only for exceptions taken in the same exception level EL, but other examples may also set the EXLOCK 58 to the locked state for exceptions taken in a higher-authority exception level.

[0108] Fig.101 is a flow chart showing an exception return status push procedure to push the protected exception return status to the GCS data structure 80. At step 130, the instruction decoder 10 decodes the GCS exception return status push instruction, while the GCS enable parameter 68 is in the enable state, indicating that the GCS mode is enabled (if the GCS mode is disabled, the GCS exception return status push instruction may be interpreted as a no-op instruction or an undefined instruction, and is not executed). Fig.10 132, the processing circuitry 4 is controlled via the instruction decoder 10 to check whether EXLOCKEN 69 indicates that the exception return state lock is enabled (if the guard version of the GCS control register 66 is provided for a different exception level, the version of parameter 69 checked at step 132 is the version corresponding to the current exception level). If so, then at step 134, the processing circuitry 4 is controlled to check whether the exception return state lock parameter (EXLOCK 58) is currently in the unlocked state. If EXLOCK 58 is in the unlocked state, then at step 136 an error is signaled because a valid exception entry sequence with the exception return state lock enabled, such as Figure 7 As shown, when the exception return status is pushed to the GCS data structure 80, the exception return status lock parameter 58 should be currently locked (for exceptions taken at a higher privilege exception level, where the EXLOCK 58 was not locked when the exception was taken, such as Fig. 9 As described above, there is no need to execute the GCS exception return status push instruction at all, because higher privilege exception handlers can be trusted to manage the exception return status, and therefore, the requirement for EXLOCK 58 to be locked when executing the GCS exception return status push instruction does not cause a problem for those higher privilege exception handlers. If EXLOCK 58 is currently in an unlocked state, signaling an error can provide a countermeasure against attacks that are based on tampering with program flow to cause the GCS push procedure to be executed in circumstances other than immediately following exception entry. Therefore, the check at step 134 reduces the risk of an attacker controlling an arbitrary exception return status (which is not the exception return status retrieved in response to exception entry) to push the GCS data structure 80.

[0109] If, at step 132, it is found that the exception return status lock is disabled (EXLOCKEN 69 is set to the disabled state) or at step 134, it is found that EXLOCK 58 is in the locked state, then at step 138, the processing circuit system 4 obtains the exception return status information from the exception return status registers 60, 62, and at step 140, the processing circuit system 4 issues one or more memory access requests to push the obtained exception return status information to a location on the GCS data structure 80, which is determined based on the current stack pointer stored in the GCS pointer register GCSPR_Elx 64 corresponding to the current exception level Elx.

[0110] At step 140, processing circuit system 4 checks whether EXLOCKEN 69 indicates that the lock of the exception return state is enabled, and if the lock of the exception return state is enabled, it proceeds to step 144 (or alternatively, the same check performed at step 132 can also cause step 144 to be performed conditionally, depending on whether the lock of the exception return state is enabled or disabled, so there may be no need to check EXLOCKEN parameter 69 again). If the lock of the exception return state is enabled, then at step 144, the exception return state lock parameter 58 is set to the unlocked state (if the lock of the exception return state is disabled, this step is skipped). Regardless of whether the lock of the exception return state is enabled or disabled, at step 146, processing circuit system 4 updates the stack pointer in GCS pointer register 64 corresponding to the current execution state (e.g., exception level) Elx to take into account the push of the stacked exception return state (e.g., the stack pointer may be decremented or incremented by an amount corresponding to the size of the exception return state record formed based on the contents of registers 60, 62).

[0111] Fig.11 1 is a flow chart showing the steps performed to fetch an exception return status from the GCS data structure 80. At step 150, the instruction decoder 10 decodes a GCS exception return status fetch instruction while the GCS mode is indicated as enabled by the GCS enable parameter 68 (again, if the GCS mode is disabled, the GCS exception return status fetch instruction may be processed as a NOP (no operation instruction) or undefined instruction and may not be executed). Fig.11 remaining steps).

[0112] In response to the GCS exception return state fetch instruction, at step 152, processing circuitry 4 checks whether EXLOCKEN 69 is set to an enabled state indicating that locking of the exception return state is enabled (if the protected version of GCS control register 66 is provided for a different exception level, the version of parameter 69 checked at step 152 is the version corresponding to the current exception level). If locking of the exception return state is enabled, then at step 154, processing circuitry 4 checks whether EXLOCK parameter 58 is set to a locked state. If EXLOCK 58 is currently in a locked state, then at step 156 an error is signaled because this indication deviates from the intended use, where the exception return state fetch instruction should not be executed at a time when EXLOCK is locked. This error may signal a possible attack that attempts to corrupt program flow to result in incorrect verification of the protected exception return state from GCS data structure 80.

[0113] If it is determined at step 152 that locking of the exception return state is enabled or at step 154 ​​that EXLOCK 58 is currently in an unlocked state, then at step 158 processing circuitry 4 issues one or more memory access requests to retrieve GCS protected exception return information from a location on GCS data structure 80 that is determined based on the stack pointer in GCS pointer register 66 corresponding to the current exception level Elx. At step 160, the GCS stack pointer in register GCSPR_Elx 66 is updated to account for the retrieval of the exception return state from GCS data structure 80 (e.g., the stack pointer is incremented or decremented in the opposite direction (but by a corresponding amount) to the stack pointer in register GCSPR_Elx 66). Fig.10 146).

[0114] Steps 162, 164 and 166 are steps that may be selectively performed in response to a GCS exception return status fetch instruction. In one implementation, at step 158, the GCS exception return status fetch instruction also controls the processing circuit system 4 to verify whether the expected exception return status information currently stored in the exception return registers 60, 62 matches the GCS protected exception return status information fetched from the GCS data structure 80. At step 162, the processing circuit system 4 reads the expected exception return status information represented by the current values ​​in the exception link register 62 and SPSR 60 corresponding to the current exception level Elx. The term "expected" exception return status information is used to refer to the current values ​​of the exception return status in the registers 62, 60 when the GCS exception return status fetch instruction is executed (which may or may not be the same as the values ​​written to these registers when the corresponding exception entry occurs). At step 164 , the processing circuitry 4 determines whether the expected exception return status information obtained from the registers 60 , 62 matches the GCS protected exception return status information read from the GCS data structure 80 stored in the protected GCS area of ​​memory, and if not, signals an error at step 166 .

[0115] If at step 164 the expected exception return state information matches the GCS protected exception return state information, or if steps 162, 164, 166 are not performed because the GCS exception return state fetch instruction did not trigger verification (but instead fetched the GCS protected return state information directly into the exception return state registers 62, 60, for example), then at step 168 the processing circuitry 4 checks whether EXLOCKEN 69 indicates that the lock of the exception return state is enabled, and if the lock of the exception return state is enabled, proceeds to step 170 (or alternatively, the same check performed at step 152 may also cause step 170 to be conditionally performed, depending on whether the lock of the exception return state is enabled or disabled). If the lock of the exception return state is enabled, then at step 170 the exception return state lock parameter 58 is set to the locked state (if the lock of the exception return state is disabled, this step is skipped).

[0116] Fig.12Flowchart showing the steps performed in response to an exception return instruction. At step 180, the instruction decoder 10 decodes the exception return instruction and responsively generates control signals for controlling the processing circuit system 4 (specifically, the execution stage 16) to perform subsequent steps. At step 182, the processing circuit system 4 determines whether the GCS enable parameter 68 indicates that the GCS mode is enabled, whether the EXLOCKEN parameter 69 indicates that the locking of the exception return state is also enabled (again, if the guard version of the GCS control register 66 is provided for a different exception level, the version of the parameters 68, 69 used for checking at step 182 is the version corresponding to the current exception level), and whether the exception return is a return to be processed in the same exception level as the current exception level. If both the GCS mode and the locking of the exception return state are enabled, and the exception return causes the return to be processed in the current exception level, then at step 184, the processing circuit system 4 checks whether the EXLOCK parameter 58 is currently in an unlocked state. If EXLOCK 58 is currently in the unlocked state, an error is signaled at step 186 because this indicates that the exception return may not follow the previous exception return state fetch instruction 82 and therefore it may not be safe to perform the exception return using the potentially unsafe exception return state specified in registers 60, 62.

[0117] If GCS mode is currently disabled, or the EXLOCKEN parameter 69 is set to disable locking of the exception return state, or the exception return is to an exception level less privileged than the current exception level, or the EXLOCK parameter 58 is currently in the locked state, then the exception return may proceed, followed by copying the exception return address from the ELR_Elx 62 to the program counter register 52, and copying the stored processor state from the SPSR_Elx 60 to the PSTATE register 54 in step 188. It should be noted that because the EXLOCK parameter 58 is part of the processor state stored at the time of the exception and restored at the time of the exception return, step 188 may change the exception return state lock parameter 58 to the same state indicated by the EXLOCK 58 at the time the corresponding exception was taken. Therefore, whether the EXLOCK 58 is in the locked state or the unlocked state after the exception return will depend on the state of the EXLOCK at the time the corresponding exception was taken.

[0118] Fig.132 is a flow chart showing steps for controlling whether modification of the exception return state information in registers 60, 62 is permitted. At step 200, the instruction decoder 10 decodes an instruction requesting modification of the exception return state information (e.g., the exception return address or the stored processor state) in one or both of the exception link register 62 or the stored processor state register 60 associated with the target exception level (the target exception level may or may not be the current exception level 56, as it may be that an instruction executed in a higher privileged exception level is to modify the exception return state associated with a lower privileged exception level). At step 202, the processing circuit system 4 determines whether the GCS mode is indicated as enabled by the enable parameter 68 and the EXLOCKEN parameter 69 indicates that the locking of the exception return state is disabled. If the GCS mode is disabled or the locking of the exception return state is disabled, then at step 204, provided that any other checks are satisfied (e.g., checking whether the current exception level has sufficient privileges to allow modification of the specified register), modification of the exception return state information may be permitted. If at step 202 it is determined that both GCS mode and locking of the exception return state are enabled, then at step 206 the processing circuitry 4 determines whether the exception return state lock parameter EXLOCK 58 is currently in the locked state. If EXLOCK 58 is in the unlocked state, then at step 204, again, assuming any other checks are satisfied, modification may be permitted. If at step 206 the EXLOCK parameter 58 is in the locked state, then at step 208 an error is signaled to prevent modification of the exception return state information (and thus supervise against attempts to modify the exception return state information in the example above). Figure 7 90 or window B 92 as shown).

[0119] exist Fig.13 In the example of , the signaling of an error at step 208 is independent of whether the value of the exception return status information to be written to one of the registers 60, 62 is the same as or different from the previous value stored in that register. Thus, an error will be signaled even if the execution of the instruction encountered at step 200 will not in fact result in a change in the exception return status. This method can be implemented more simply in hardware because it does not require the provision of circuit logic to use signaling errors that depend on the read value of the register 60, 62 and the comparison with the new value to be written.

[0120] Alternative solutions are shown in Fig.14 middle. Fig.14 Steps 200, 202, 204, 206 and 208 and Fig.13 The corresponding steps are the same as in . Fig.14Including the extra check at step 210, it checks whether the new value to be written into one of registers 60, 62 is different from the old value of the exception return status information in the register. If the new value is different from the old value, an error is sent with a signal at step 208. If the new value is the same as the old value, then in step 204, the "modification" attempted can be allowed because it will not change the exception return status information. This method can speed up some program code paths, such as fast exception paths, which use very short exception handling routines (to return from the exception almost immediately after taking the exception), and therefore do not need to store / restore the exception return status to the memory, reducing the risk of being tampered by the attacker. For such fast exception program code paths, GCS exception return status push / take instructions can not be used, and therefore EXLOCK can be kept set in the entire exception routine. However, if the exception handling routine executes a system register modification instruction (unlikely, but there is a chance) that attempts to modify the exception return status in registers 60, 62, then when the new value written by the system register modification instruction is actually the same as the old value so that there is no risk of damaging the exception return status, the corresponding error that will be triggered when EXLOCK is locked can be avoided. This can help improve performance of such code paths.

[0121] Although the flowcharts discussed above show steps performed in a certain sequential order, it should be appreciated that the same functions may also be performed in a different order, or at least partially in parallel.

[0122] Fig.15Useable simulator implementation is shown. Although the embodiment described earlier implements the present invention with the equipment and method for operating the specific processing hardware of the technology concerned, it is also possible to provide an instruction execution environment according to the embodiment described herein, which is implemented by using a computer program. Such computer programs are often referred to as simulators because they provide software-based implementations of hardware architectures. The types of simulator computer programs include emulators, virtual machines, models, and binary converters (including dynamic binary converters). In general, simulator implementations can be run on a host processor 330 that optionally runs a host operating system 320 and supports simulator programs 310. In some arrangements, there can be multiple layers of simulation between the hardware and the provided instruction execution environment and / or the multiple different instruction execution environments provided on the same host processor. Historically, powerful processors have been needed to provide simulator implementations, which are executed at reasonable speeds, but such methods may be justified in some cases, such as when the native program code of another processor needs to be executed because of compatibility or reuse reasons. For example, a simulator implementation can provide an instruction execution environment with additional functionality that is not supported by the host processor hardware, or provide an instruction execution environment that is generally associated with different hardware architectures. An overview of simulation is given in "Some Efficient Architecture Simulation Techniques", Robert Bedichek, Winter 1990 USENIX Conference, pp. 53-63.

[0123] Where embodiments have been previously described with reference to particular hardware architectures or features, equivalent functionality may be provided in simulated embodiments by suitable software architectures or features. For example, particular circuitry may be implemented as computer program logic in simulated embodiments. Similarly, memory hardware (e.g., registers or cache memory) may be implemented as software data structures in simulated embodiments. Where one or more of the hardware elements mentioned in the previously described embodiments are present in an arrangement on host hardware (e.g., host processor 330), some simulated embodiments may utilize host hardware (where appropriate).

[0124] The simulator program 310 may be stored on a computer-readable storage medium (which may be a non-transitory medium) and provides a program interface (instruction execution environment) to the target code 300 (which may include an application, an operating system, and a virtual machine monitor) that is the same as the program interface of the hardware architecture modeled by the simulator program 310. Thus, program instructions of the target code 300, including GCS access instructions as described above, may be executed within the instruction execution environment using the simulator program 310, so that a host computer 330 that does not actually have the hardware features of the device 2 discussed above may emulate such features. Similarly, checks based on the EXLOCK parameter 58 may be simulated using the simulator program 310 (e.g., using portions of the processing program logic 312 or the instruction decoding program logic 314).

[0125] Thus, the simulator program 310 may have a handler logic 312 that simulates the state of the processing circuit system 4 described above. For example, the handler logic 312 may control the transition of the execution state EL0-EL3 in response to events occurring during the simulated execution of the target code 300. The instruction decoder logic 314 decodes the instructions of the target code 300 and maps these instructions to corresponding instruction sets in the native instruction set of the host device 330. The register emulator logic 316 maps the register access requested by the target code into access to the corresponding data structure maintained on the host hardware of the host device 330, for example by accessing the registers of the host device 330 or the data in the memory 332. The memory manager logic 318 implements address translation, paging table access, and access control checks in a manner corresponding to the MMU 28 described in the hardware-implemented embodiment described above, but also has the additional function of mapping simulated physical addresses (which are obtained by stage 2 mapping in address translation based on the paging table defined for the target code 300) to host virtual addresses for accessing the host memory 332. Such host virtual addresses may themselves be converted to host physical addresses using standard address translation mechanisms supported by the host (the conversion of host virtual addresses to host physical addresses is outside the control of simulator program 310). Exception handler logic 320 controls the handling of simulated exceptions generated during execution of target code 300 (including errors triggered by EXLOCK-type checks described above).

[0126] In this application, the phrase "configured to..." is used to mean that the elements of a device have a configuration that is capable of performing the defined operation. In this context, "configuration" means the arrangement or manner of interconnection of hardware or software. For example, the device may have dedicated hardware that provides the 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 to provide the defined operation.

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

Claims

1. A device comprising: An exception return status register memory, wherein the exception return status register memory is used to store exception return status information; as well as A processing circuit system, the processing circuit system is used to perform processing operations in response to instructions; wherein: the processing circuitry being configured to, in response to a protection control stack (GCS) exception return status push instruction, obtain the exception return status information from the exception return status register memory and push the exception return status information to a GCS data structure; The processing circuitry is configured to obtain GCS protected exception return status information from the GCS data structure in response to a GCS exception return status fetch instruction; The apparatus includes memory management circuitry to deny a write request specifying a target address in response to determining that a memory region corresponding to the target address is designated as a GCS region for storing the GCS data structure, and the write request is other than a GCS memory access request triggered by a restricted subset of a restricted subset of GCS access types for instructions, the restricted subset of GCS access types for instructions including at least the GCS exception return status push instruction; and The processing circuit system is configured to, in at least one operating state of the processing circuit system, detect whether an exception return state lock parameter is in a locked state or an unlocked state in response to an attempt to modify the exception return state information stored in the exception return state register memory, and to signal an error when the exception return state lock parameter is detected to be in the locked state.

2. The apparatus according to claim 1, wherein: The processing circuitry is configured to perform the processing operation in one of a plurality of exception levels, the plurality of exception levels being associated with different privilege levels; and The processing circuitry is configured to, in the at least one operating state of the processing circuitry, set the exception return state locking parameter to the locked state in response to taking an exception, wherein the exception is taken at the same exception level as a current exception level before taking the exception.

3. An apparatus according to any preceding claim, wherein the processing circuit system is configured to set the exception return state locking parameter to the unlocked state in response to the GCS exception return state push instruction in the at least one operating state of the processing circuit system.

4. An apparatus according to any preceding claim, wherein the processing circuitry is configured to, in the at least one operating state of the processing circuitry, set the exception return state locking parameter to the locked state in response to the GCS exception return state fetch instruction.

5. An apparatus as claimed in any preceding claim, wherein the processing circuitry is configured to, in the at least one operating state of the processing circuitry, check whether the exception return state locking parameter is set to the locked state in response to an exception return instruction for triggering an exception return based on the exception return state information stored in the exception return state register memory, wherein the exception return is a return of processing at the same exception level as a current exception level before the exception return, and signal an error in response to detecting that the exception return state locking parameter is set to the unlocked state.

6. An apparatus according to any preceding claim, wherein the processing circuitry is configured to, in the at least one operating state of the processing circuitry, in response to an attempt to execute an instruction requesting modification of information in the exception return status register memory when the exception return status lock parameter is set to the locked state, signal an error regardless of whether a new value to be written to the exception return status register memory is the same as or different from an old value previously stored in the exception return status register memory.

7. An apparatus according to any one of claims 1 to 5, wherein the processing circuit system is configured to, in the at least one operating state of the processing circuit system, in response to an attempt to execute an instruction requesting modification of information in the exception return status register memory when the exception return status lock parameter is set to the locked state, check whether a new value to be written to the exception return status register memory is the same as or different from an old value previously stored in the exception return status register memory, and when it is determined that the new value is different from the old value, send the error with a signal.

8. An apparatus as claimed in any preceding claim, wherein the processing circuitry is configured to, in response to the GCS exception return status fetch instruction, signal an error upon detecting a mismatch between expected exception return status information obtained from the exception return status register memory and the GCS protected exception return status information obtained from the GCS data structure.

9. Apparatus as claimed in any preceding claim, wherein the exception return status register memory comprises an exception return address register to store an exception return address of an instruction to be executed following an exceptional return from an exception.

10. Apparatus as claimed in any preceding claim, wherein the exception return state register store comprises a stored processor state register to store processor state to be restored on return from an exception.

11. The apparatus of claim 10, wherein the processing circuitry is configured to, in response to taking an exception, copy a processor state from a processor state register to the stored processor state register; and The exception return status lock parameters are parameters specified in the processor status register.

12. The apparatus of claim 11 , wherein the processing circuitry is configured to, in response to an exception return instruction, copy a stored processor state from the stored processor state register to the processor state register to restore the exception return state lock parameter to a value indicated by the stored exception return state lock parameter, the stored processor state including the stored exception return state lock parameter.

13. An apparatus according to any preceding claim, wherein the at least one operating state of the processing circuit system comprises an operating state in which an exception return state lock enable control parameter is set to an enabled state, indicating that locking of exception return state information using the exception return state lock parameter is enabled.

14. An apparatus according to any one of claims 1 to 12, wherein the at least one operating state of the processing circuitry comprises an operating state wherein: an exception return status lock enable control parameter is set to an enabled state, which indicates that locking of exception return status information using said exception return status lock parameter is enabled; and The GCS Enable parameter is set to an enabled state, indicating that a GCS mode for supporting use of the GCS data structure is enabled.

15. An apparatus as claimed in any preceding claim, wherein the memory management circuitry is configured to respond to a determination that a memory region corresponding to a given target address is not designated as the The GCS region is used to deny a GCS memory access request specifying the given target address.

16. A method comprising: storing the exception return status information in an exception return status register memory; as well as Using processing circuitry, performing processing operations in response to the instructions; In response to a protection control stack (GCS) exception return status push instruction, obtaining the exception return status information from the exception return status register memory and pushing the exception return status information to a GCS data structure; In response to a GCS exception return status fetch instruction, obtaining GCS protected exception return status information from the GCS data structure; in response to determining that a memory region corresponding to the target address is designated as a GCS region for storing the GCS data structure, denying a write request that specifies the target address, and the write request is other than a GCS memory access request triggered by a restricted subset of a restricted subset of GCS access types for instructions, the restricted subset of GCS access types for instructions including at least the GCS exception return status push instruction; and In at least one operating state of the processing circuit system, in response to an attempt to modify the exception return state information stored in the exception return state register memory, detecting whether an exception return state lock parameter is in a locked state or an unlocked state, and signaling an error when the exception return state lock parameter is detected to be in the locked state.

17. A computer program comprising instructions which, when executed by a host data processing device, control the host data processing device to provide an instruction execution environment for executing object code, the computer program comprising: register emulation program logic for controlling the host data processing device to emulate an exception return status register memory for storing exception return status information; as well as processing program logic, the processing program logic is used to control the host data processing device to simulate the execution of instructions of the target code; wherein: the handler logic being configured to, in response to a protection control stack (GCS) exception return status push instruction of the object code, control the host data processing device to obtain the exception return status information from an emulated exception return status register memory and push the exception return status information to a GCS data structure; The handler logic is configured to obtain GCS protected exception return status information obtained from the GCS data structure in response to a GCS exception return status fetch instruction of the target code; The computer program includes memory management program logic to deny a write request specifying a target address in response to determining that a memory region corresponding to the target address is designated as a GCS region for storing the GCS data structure, and the write request is other than a GCS memory access request triggered by a restricted subset of a restricted subset of GCS access types for instructions, the restricted subset of GCS access types for instructions including at least the GCS exception return status push instruction; and The handler logic is configured to, in at least one simulated operating state of the handler logic, control the host data processing device to, in response to an attempt to modify the exception return status information stored in the simulated exception return status register memory, detect whether an exception return status lock parameter is in a locked state or an unlocked state, and signal an error when the exception return status lock parameter is detected to be in the locked state.

18. A storage medium storing the computer program according to claim 17.