Apparatus and method for handling exceptions - Patents.com

The system addresses the challenge of integrating untrusted exception handling routines by categorizing them based on configuration information, reducing interrupt latency and ensuring secure execution through selective register state saving.

JP7576094B2Active Publication Date: 2024-10-30ARM LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
JP2022532806
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2019-12-11
Filing Date
2020-11-03
Publication Date
2024-10-30
Estimated Expiration
2040-11-03

AI Technical Summary

Technical Problem

Modern systems face challenges in handling exceptions, particularly with the integration of untrusted exception handling routines, which require state preservation of additional registers and increase interrupt latency, while ensuring security and efficiency in both trusted and untrusted environments.

Method used

A system with exception control circuitry that categorizes exception handling routines as trusted or untrusted based on configuration information, saving data from both first and second subsets of registers only when necessary, thereby reducing interrupt latency and ensuring secure execution.

Benefits of technology

The system effectively reduces interrupt latency and enhances security by selectively saving register states, allowing efficient handling of both trusted and untrusted exception handling routines without performance degradation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007576094000001
    Figure 0007576094000001
  • Figure 0007576094000002
    Figure 0007576094000002
  • Figure 0007576094000003
    Figure 0007576094000003
Patent Text Reader

Abstract

An apparatus and method for handling exceptions are provided. The apparatus includes a processing circuit operable in at least one security domain to execute program code including a plurality of exception handling routines that are executed in response to corresponding exceptions, and a plurality of registers for storing data accessed by the processing circuit when executing the program code. The exception control circuit is configured to trigger a state save operation in response to occurrence of a given exception from background processing to save data from the plurality of registers before triggering the processing circuit to execute the given exception handling routine. A configuration storage provides configuration information used to categorize the exception handling routines. The exception control circuit is configured to refer to the configuration information to determine whether the given exception handling routine is in a first category or a second category within the security domain in which the given exception handling routine executes. Then, when triggering the state save operation, the exception control circuit triggers saving data from a first subset of registers when the given exception handling routine is in the first category, but triggers saving data from both the first subset of registers and the second subset of registers when the given exception handling routine is in the second category. Such an approach can significantly reduce interrupt latency in systems that support the execution of both trusted and untrusted exception handling routines.
Need to check novelty before this filing date? Find Prior Art

Description

[Background technology]

[0001] The present technique relates to an apparatus and method for handling exceptions.

[0002] When a processor is executing program code, the processor typically has access to a number of registers that are used to store data used by the processor when executing the program code. When taking an exception from a background process, it is known to provide exception control circuitry in hardware, which is arranged to perform a state save of data from a first subset of registers before triggering the processor to execute an exception handling routine to handle the exception. By taking such an approach, the exception handling routine can use these registers without having to perform a state save of the data in the first subset of registers, and would need to perform a state save for these registers if the exception handling routine needs to interact with any additional registers that are not in the first subset.

[0003] When taking an exception, typically, an exception handler may run with the same or higher privileges as the background code, and therefore it was not thought to be a problem that the contents of registers outside the first subset (i.e., data in registers that have not undergone state saving by the exception control circuit hardware) may be visible to the exception handler. However, in modern systems, it has become desirable to also support the use of untrusted exception handlers, for example, because untrusted exception handlers are provided by third-party vendors. In such cases, steps need to be taken to prevent untrusted exception handlers from gaining access to data that they should not have access to. However, interrupt latency has also become a significant issue in modern systems, and therefore it is desirable to provide a system that supports the use of both trusted and untrusted exception handlers while mitigating interrupt latency issues. Summary of the Invention

[0004] In a first exemplary arrangement, a processing circuit operable in at least one security domain to execute program code including a plurality of exception handling routines that are executed in response to corresponding exceptions; a plurality of registers for storing data accessed by the processing circuit when executing the program code, the plurality of registers including a first subset of the registers and a second subset of the registers that do not overlap with the first subset; an exception control circuit for triggering a state save operation in response to occurrence of a given exception from a background process to save data from the plurality of registers before triggering the processing circuit to execute a given exception handling routine corresponding to the given exception; An apparatus is provided comprising: a configuration storage for storing configuration information used to categorize exception handling routines among the routines; wherein the exception control circuit is arranged to determine, by referring to the configuration information, whether a given exception handling routine is in a first category or a second category within a security domain in which the given exception handling routine executes; and wherein the exception control circuit is arranged, when triggering a state save operation, to trigger saving of data from a first subset of registers when the given exception handling routine is in the first category, and to trigger saving of data from both the first subset of registers and the second subset of registers when the given exception handling routine is in the second category.

[0005] In another exemplary arrangement, a method of handling exceptions in a device includes: executing, by a processing circuit operable in at least one security domain, program code including a plurality of exception handling routines that are executed in response to corresponding exceptions; storing data accessed by the processing circuit when executing the program code in a plurality of registers, the registers including a first subset of the registers and a second subset of the registers that do not overlap with the first subset; and triggering, in response to occurrence of a given exception from background processing, a state save operation to preserve data from the plurality of registers prior to triggering the processing circuit to execute a given exception handling routine corresponding to the given exception. To achieve this, a method is provided that includes using an exception control circuit, storing configuration information used to categorize exception handling routines of a plurality of exception handling routines, determining whether a given exception handling routine is in a first category or a second category within a security domain in which the given exception handling routine executes by referring to the configuration information, and causing the exception control circuit to trigger saving of data from a first subset of registers when the given exception handling routine is in the first category and to trigger saving of data from both the first subset of registers and the second subset of registers when the given exception handling routine is in the second category, when triggering a state save operation.

[0006] In a still further exemplary arrangement, a processor for executing, in at least one security domain, program code including a plurality of exception handling routines that are executed in response to corresponding exceptions; a plurality of register means for storing data accessed by the processor when executing the program code, the plurality of register means including a first subset of the register means and a second subset of the register means that does not overlap with the first subset; exception control means for triggering a state save operation in response to occurrence of a given exception from a background process to save data from the plurality of register means before triggering the processor to execute a given exception handling routine corresponding to the given exception; and a plurality of register means for storing data accessed by the processor when executing the program code, the plurality of register means including a first subset of the register means and a second subset of the register means that does not overlap with the first subset. An apparatus is provided which comprises: a configuration storage means for storing configuration information used to categorize exception handling routines among the exception handling routines; exception control means for determining, by referring to the configuration information, whether a given exception handling routine is in a first category or a second category within a security domain in which the given exception handling routine is executed; and, when triggering a state save operation, for triggering preservation of data from a first subset of registers when the given exception handling routine is in the first category, and for preserving data from both the first subset of registers and the second subset of registers when the given exception handling routine is in the second category.

[0007] In yet a further exemplary arrangement, a host data processing system is provided to provide an instruction execution environment including: processing program logic operable in at least one security domain to execute program code including a plurality of exception handling routines that are executed in response to corresponding exceptions; data structure emulating program logic for maintaining a plurality of register data structures for storing data accessed by the processing program logic when executing the program code, the register data structures including a first subset of the data structures and a second subset of the data structures that do not overlap with the first subset; and exception control program logic for triggering a state save operation in response to occurrence of a given exception from a background process to save data from the plurality of register data structures before triggering the processing program logic to execute a given exception handling routine corresponding to the given exception. There is provided a computer program for controlling an apparatus, the data structure emulating program logic being further arranged to maintain a configuration data structure for storing configuration information used to categorize exception handling routines of a plurality of exception handling routines, the exception control program logic being arranged to determine, with reference to the configuration information, whether a given exception handling routine is in a first category or a second category within a security domain in which the given exception handling routine executes, and the data structure emulating program logic being arranged, upon triggering a state save operation, to trigger saving of data from a first subset of data structures when the given exception handling routine is in the first category, and to trigger saving of data from both the first subset of data structures and the second subset of data structures when the given exception handling routine is in the second category. A computer readable medium may be provided for storing such a computer program, the computer readable medium may be in a non-transitory or transitory form. [Brief description of the drawings]

[0008] The present technique will now be further described, by way of example only, with reference to examples of the technique illustrated in the accompanying drawings, in which: [Figure 1] 1 illustrates a schematic diagram of an example data processing system according to one exemplary arrangement. [Diagram 2] 2 illustrates examples of different domains and modes of operation of the processing circuitry of FIG. 1 according to one exemplary arrangement. [Figure 3A] 2 illustrates different exemplary implementations of the configuration storage of FIG. 1; [Figure 3B] 2 illustrates different exemplary implementations of the configuration storage of FIG. 1; [Figure 3C] 2 illustrates different exemplary implementations of the configuration storage of FIG. 1; [Figure 4] FIG. 1 is a flow diagram illustrating steps performed in taking an exception from a background process, according to one exemplary arrangement. [Diagram 5] 5 is a flow diagram illustrating a series of steps that may be performed to implement step 105 of FIG. 4 in one exemplary implementation. [Figure 6] FIG. 2 is a flow diagram illustrating steps performed to implement exception return handling in one exemplary arrangement. [Figure 7] 7 is a flow diagram illustrating in greater detail a series of steps performed to implement step 230 of FIG. 6 in one exemplary arrangement. [Figure 8] FIG. 2 is a flow diagram illustrating preemption processing in one exemplary arrangement. [Figure 9A] 1 illustrates the handling of caller and callee register state preservation for a specific example scenario. [Figure 9B] 1 illustrates the handling of caller and callee register state preservation for a specific example scenario. [Figure 9C] 1 illustrates the handling of caller and callee register state preservation for a specific example scenario. [Figure 10] 1 shows an example simulator that can be used. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0009] As mentioned above, in modern systems, some exception handling routines may be untrusted exception handling routines, e.g., untrusted exception handling routines are provided by third-party vendors, and therefore it may be desirable to allow the use of one or more untrusted exception handling routines instead. To accommodate such untrusted exception handling routines, it may be possible to provide a trusted software wrapper, such that upon entry to an exception handling routine, the wrapper software is executed first to perform some initial tasks before allowing the body of the untrusted exception handling routine to be executed. Similarly, the wrapper software may be executed to perform some additional operations before returning from such an exception handling routine. As an example of operations that may be performed by such wrapper software, the wrapper software may be responsible for saving the state of at least some other registers that are not within the aforementioned first subset where state saving was implemented by the exception control circuitry in hardware. The wrapper may also clear registers before executing the body of the exception handling routine, thereby ensuring that none of the register contents associated with background processing are visible to the untrusted exception handling routine. The wrapper software may also be used to restore the contents of such registers after completion of the untrusted body and before returning from the exception.

[0010] However, in modern systems, interrupt latency has become a significant issue, and the implementation of the above steps by the wrapper software can significantly impact interrupt latency. Therefore, it is desirable to provide a system that supports the use of both trusted and untrusted exception handling routines while mitigating interrupt latency issues.

[0011] In accordance with the techniques described herein, an apparatus is provided having a processing circuit operable in at least one security domain to execute program code including multiple exception handling routines that are executed in response to corresponding exceptions. The processing circuit may be operable in one of several different security domains, including, for example, at least a secure domain and a less secure domain, and access to memory may be controlled depending on which security domain the processing circuit is operating in. It should be noted, however, that the processing circuit need not be operable in multiple security domains and the general techniques described herein may also be used in systems with only a single security domain.

[0012] In addition to the processing circuit, the apparatus has a plurality of registers used to store data accessed by the processing circuit when executing the program code, the registers being arranged to include a first subset of the registers and a second subset of the registers that does not overlap with the first subset. Further, an exception control circuit is provided for triggering a state save operation to save data from the plurality of registers before triggering the processing circuit to execute a given exception handling routine corresponding to the given exception, in response to the occurrence of a given exception from the background processing. In particular, by default, the exception control circuit triggers a state save operation with respect to the first subset of the registers, but as discussed further herein, depending on the exception handling routine that is triggered to handle the given exception, the exception control circuit hardware may also trigger a state save with respect to the second subset of the registers.

[0013] In particular, the apparatus further comprises a configuration storage for storing configuration information used to categorize the exception handling routines of the plurality of exception handling routines, The configuration information provided in the configuration storage may be used to categorize all the exception handling routines, or alternatively, there may be a subset of the exception handling routines, which subset of the exception handling routines is in fact always in a given category, and therefore no configuration information in the configuration storage for the subset of the exception handling routines is required.

[0014] Further, the exception control circuitry is arranged to determine, with reference to the configuration information, whether a given exception handling routine is in a first category or a second category within the security domain in which the given exception handling routine executes. Then, when triggering a state save operation, the exception control circuitry is arranged to trigger saving data from a first subset of registers when the given exception handling routine is in the first category, and to trigger saving data from both the first subset of registers and the second subset of registers when the given exception handling routine is in the second category. Although the data may be saved in various ways, in one exemplary implementation, the data is saved to a stack in memory, and thus such a save operation may be referred to herein as "stacking". Furthermore, the subsequent restoration of the data into the registers may be referred to as "unstacking".

[0015] Such an approach can provide significant performance benefits in systems that support the use of both trusted and untrusted exception handlers. For example, a first category may be used to indicate trusted exception handlers, and a second category may be used to indicate exception handlers that are treated as untrusted. Depending on the form of configuration information used, in some cases a trusted exception handler may be identified as being in the second category and therefore treated as untrusted. However, this does not pose a security risk and simply means that the exception control circuitry also preserves data from the second subset of registers in situations where data from the second subset of registers is not actually needed.

[0016] By identifying untrusted exception handling routines as being in the second category, this can ensure that the exception control circuitry hardware is responsible for saving not only the state of the first subset of registers, but also the state of the second subset of registers. This can significantly reduce the tasks required by the aforementioned trusted wrapper software that may be used in association with the untrusted exception handling routine, thereby significantly reducing the interrupt latency in the processing of such untrusted exception handling routines. In some implementations, the hardware state saving of the registers can be performed at least in part in parallel with other exception entry tasks, such as fetching the address of the exception handler and fetching the first instruction of the exception handler to be executed. Such implementations can have a significant interrupt latency advantage over systems in which state saving must be performed by the exception handler itself.

[0017] Moreover, by ensuring that the exception control circuit hardware does not simply always trigger the saving of state from both the first subset registers and the second subset of registers, this avoids a performance impact with respect to trusted exception handling routines. In particular, for trusted exception handling routines identified as being in the first category, the exception control circuit simply continues to trigger saving data from the first subset of registers, given that the exception handling routine is trusted, and therefore does not trigger saving data from any further registers that do not need to be saved. Thus, such an approach maintains the speed of trusted exception handling routines while reducing the latency associated with untrusted exception handling routines by allowing the exception control hardware to save state that would otherwise need to be saved by software.

[0018] In one exemplary arrangement, the exception control circuit is further arranged to trigger the clearing of registers whose data are saved during the state save operation before triggering the processing circuit to execute the given exception handling routine, at least when the given exception handling routine is in the second category. As mentioned above, when the exception handling routine is categorized as being in the second category, the exception handling routine is treated as untrusted, and therefore the exception control circuit not only triggers saving the state of registers that were present in the background processing, but also triggers the clearing of the contents of these registers, such that these contents are suitably not visible to the exception handling routine when the processing circuit starts executing the exception handling routine. If desired, for example to simplify operation, the exception control circuit may be arranged to always trigger the clearing of the contents of the saved registers, and thus, for example, the exception control circuit may also trigger the clearing of the contents of the first subset of registers when saving the state of the first subset of registers before transitioning the processing circuit to execute an exception handling routine of the first category.

[0019] There are several ways in which the processing circuitry may be arranged to execute untrusted exception handling routines. However, in one exemplary implementation, the processing circuitry is operable in an unprivileged state and a privileged state, and the processing circuitry is operable to execute at least the body of the untrusted exception handling routine while in the unprivileged state. Thus, for example, the aforementioned wrapper software may be executed by the processing circuitry while in a privileged state, and the processing circuitry may then transition to the unprivileged state to execute the body of the untrusted exception handling routine. Because the exception control circuitry triggers saving the state of both the first and second subsets of registers before triggering the processing circuitry to execute the untrusted exception handling routine, the aforementioned technique ensures that the body of such an untrusted exception handling routine does not access data stored in any of the registers during background processing, regardless of whether the background processing was in a privileged or unprivileged state. In some implementations, the background state and the exception handler may belong to different, mutually distrusting software processes, so protecting the unprivileged background state from the unprivileged exception handler may be an important security property.

[0020] The configuration storage may be organized in a variety of ways, but in one example, the configuration storage is arranged to store, for one or more exception handling routines, a corresponding item of configuration information. In one particular exemplary implementation, for each of the exception handling routines, a corresponding item of configuration information may be provided. Alternatively, however, as previously mentioned, one or more particular categories of exception handling routines may be effectively hardwired, e.g., fault handlers or supervisor calls (SVCs), and in these cases, the configuration information may not need to be consulted to determine the category of the exception handling routine. Such fault handler and supervisor call exceptions may be associated with the operating system and therefore may always be trusted and treatable as being part of the first category.

[0021] In such an implementation, for one or more exception handling routines, the corresponding item of configuration information, when stored in the configuration storage, may take a variety of forms. However, in one exemplary implementation, the item of configuration information is set to a first value to indicate that the corresponding exception handling routine is trusted and is set to a second value to indicate that the corresponding exception handling routine is to be treated as untrusted. Thus, by reference to the associated item of configuration information in the configuration storage, the exception control circuitry can readily determine whether a given exception handling routine is in the first category or the second category, and can therefore perform the appropriate state saving operations with respect to the contents of the registers.

[0022] However, it is not a requirement that the configuration storage store a corresponding item of configuration information for each exception handling routine. For example, in some implementations, a very large number of exception handling routines may be supported, and thus size requirements for such configuration storage may be large. To attempt to reduce storage requirements, in one exemplary implementation, alternative forms of configuration information are stored, which may be consulted, for any exception handling routine, when evaluating whether the exception handling routine is in the first or second category. In particular, it is noted that in many systems, untrusted exception handling routines are inherently given a lower priority than trusted exception handling routines. Such an approach may, for example, help prevent Denial of Service (DoS) attacks by unprivileged exception handling routines. Thus, in such an implementation, priority information associated with an exception may be used as a proxy to infer whether the associated exception handling routine is trusted or untrusted. Thus, in one such exemplary implementation, the configuration storage is arranged to identify a threshold priority, and each of the exceptions has an associated priority. The exception control circuitry may then be arranged to determine whether a given exception handling routine is in the first or second category depending on a comparison of a value derived from the associated priority of the given exception with a value derived from the threshold priority. This provides significantly reduced storage requirements in terms of configuration storage, since a single piece of information, the threshold priority, may be stored and then used when evaluating each of the exceptions. Furthermore, in systems that handle exceptions, it is common for priorities to be different due to these exceptions, and therefore priority information for each of the exceptions already exists. In another implementation, the threshold priority may be fixed and configuration storage is created from the priority field associated with each of the exceptions.

[0023] In one exemplary arrangement, the exception control circuitry is arranged to determine that a given exception handling routine is in the second category when the associated priority of the exception is less than a threshold priority. Note that, depending on the implementation, a priority exception may be higher due to a higher numerical priority, while in alternative implementations, a priority exception may be higher due to a lower numerical priority. Thus, for example, in such alternative implementations, an exception having a priority of 2 may be considered a higher priority interrupt than an exception having a priority of 4.

[0024] As mentioned above, priority can often be used as a good proxy for whether an exception handler is trusted or untrusted. If the threshold priority setting creates a situation where there is a low priority exception that triggers a trusted exception handler, treating the exception handler as untrusted will not result in problematic behavior, and treating the exception handler as untrusted will simply have a small impact on performance due to the state of the second subset of registers being preserved by the exception control circuitry hardware in a situation where the state is not actually needed. Since this situation only occurs for low priority handlers, this small impact on performance may not be significant. Furthermore, in the rare event that there is a high priority exception actually associated with an untrusted exception handler, this may be addressed by an arrangement where the trusted wrapper software provided in association with the exception handler is arranged to preserve the state of the second subset of registers and clear the state from the registers before transitioning to the untrusted body of the exception handler.

[0025] In one exemplary implementation, the exception control circuitry is arranged to set a status flag to identify whether data from the second subset of registers has been saved. There are several ways in which the status flag may be set. For example, in one implementation, the status flag is provided as an additional bit in a link register used to capture the exception return address upon exception entry. In some implementations, a portion of the address space is reserved and not executable. Thus, a branch to an address within such a portion of the address space may be used to signal a special condition, such as a request for hardware to perform an exception return to a background state. In one exemplary implementation, upon entry to the exception, the exception return address captured in the link register may be set to a dummy return address that specifies an address within the reserved non-executable address space; instead, the actual return address may be saved to the stack, and the status flag may then be included in the link register along with the dummy return address.

[0026] Thus, when an exception is taken, the exception control circuitry may therefore categorize the associated exception handling routine to determine whether only the first subset of registers or both the first subset of registers and the second subset of registers are subject to a state save operation, and an indication to identify whether the state of the second subset of registers has been saved may be added in the link register. Note that the location of this status flag may then move over time, e.g., the information may move from the link register to a stack in memory, perhaps via other registers over time. However, each time a status flag is saved, the value of the status flag may be referenced in time by the exception control circuitry when taking steps to determine whether the contents of the second subset of registers need to be stacked or unstacked.

[0027] Further, it should be noted that there are a number of ways in which the status flags can identify whether data from the second set of registers has been preserved by the exception control circuitry. For example, the status flags can directly encode that information. However, in an alternative arrangement, the status flag values ​​may be used to identify whether there is a deviation from some default state preservation rules, so that again, the exception control circuitry can reference those values ​​when determining whether data in the second subset of registers has undergone a previous state preservation operation.

[0028] There are some cases where it may be useful for the exception control circuitry to refer to a status flag. For example, the exception control circuitry may be arranged to refer to a status flag upon exception return to determine whether the state of a second subset of registers needs to be restored (unstacked). Thus, when returning to background processing, if the status flag indicates that the second subset of registers has undergone a state save operation, the exception control circuitry may be arranged to trigger not only the restoration of the state of the first subset of registers, but also the restoration of the state of a second target of registers.

[0029] When the data in a register undergoes the aforementioned state-save operation by the exception control circuitry, there are several locations where the current data contents of the register may be saved. However, in one exemplary arrangement, the exception control circuitry is arranged to cause the data to be saved to a stack data structure, e.g., a stack in memory, when it triggers a state-save operation. Typically, a stack pointer is maintained to identify a particular location in such a stack, such as the top of the stack location, and the stack pointer may be used when adding new data to the stack or retrieving data from the stack. In other implementations, the stack may be a descending stack, with the top of the stack at a lower address in memory than the bottom of the stack.

[0030] In addition to handling exceptions taken from background processing, the apparatus is also arranged to handle tail-chained exceptions, which are exceptions that occur while the current exception handling routine is already running and when the tail-chained exception has a lower priority than the current exception being handled by the current exception handling routine and, as a result, is not handled until the current exception handling routine has finished. However, instead of returning to background processing only to take the exception to handle the tail-chained exception, the apparatus may instead be arranged to transition directly from completion of the current exception handling routine to processing of a further exception handling routine to handle the tail-chained exception. Alternatively, two exceptions may occur simultaneously and the exception handling circuitry may be arranged to trigger processing of the higher priority exception when the higher priority exception handler finishes, before tail-chaining to the lower priority exception. Regardless of when the tail-chained exception was pending, tail-chaining may be viewed as entering the pending exception when the exception handler returns, instead of returning to processing of the background code.

[0031] Thus, in response to a tail-chained exception corresponding to a further exception handling routine to be executed after the given exception handling routine is executed and before returning to background processing, the exception control circuitry may be arranged to determine whether the further exception handling routine is in the first category or the second category by referring to the configuration information. Then, when the exception control circuitry determines that the further exception handling routine is in the second category and the data from the second subset of registers has not yet been saved, the exception control circuitry may be further arranged to trigger saving of the data from the second subset of registers before triggering the processing circuitry to execute the further exception handling routine. There are several ways in which the exception control circuitry can determine whether the data from the second subset of registers has already been saved, for example, the exception control circuitry can refer to the aforementioned status flags.

[0032] Similar to how the exception control circuitry may be arranged when handling exceptions from background processing, the exception control circuitry may further be arranged to trigger the clearing of the registers in which their data is saved before triggering the processing circuitry to execute further exception handling routines for the tail-chained exception. In some implementations, the clearing of the registers may occur upon tail chaining even if the registers were not saved during the transition to the tail-chained exception. For example, if the entry into the previous exception or combination of exceptions caused both the first and second subsets of registers to be saved, it may not be necessary to save the registers again. However, in such a case, the registers may need to be cleared so that values ​​left in the registers by one exception handler are not exposed to the next exception handler.

[0033] By maintaining the status flag as described above, significant performance improvements can be achieved when handling tail-chained exceptions by avoiding unnecessary re-saving of state of the second subset of registers in situations where the state has already been saved. In particular, the exception control circuitry can be further arranged to refer to the status flag, such that when the exception control circuitry determines that a further exception handling routine for the tail-chained exception is in the second category, the exception control circuitry is arranged to skip triggering saving of the data from the second subset of registers when the status flag indicates that the data has already been saved. Such an approach can thus result in a very efficient implementation.

[0034] Background processing may take various forms, for example, background processing may include execution of program code other than the exception handling routine, in such a situation, the aforementioned given exception is an initial exception. However, alternatively or additionally, background processing may include execution of a current exception handling routine, the given exception may be a preemptive exception of a higher priority than the exception corresponding to the current exception handling routine. In such a scenario, processing of the current exception handling routine is interrupted to allow the higher priority exception to be handled, in which case the current exception handling routine itself is treated as a background processing, and the aforementioned mechanism of categorization of the triggered exception handling routine (i.e., the exception handling routine associated with the preemptive exception) is implemented to determine whether only the first subset of registers or the first subset of registers and the second subset of registers are subjected to a state saving operation to save the relevant state associated with the current exception handling routine.

[0035] In one exemplary implementation, the processing circuitry is arranged to execute program code in one of a number of security domains including at least a secure domain and a less secure domain. The exception control circuitry is then arranged to determine, with reference to the configuration information, whether a given exception handling routine is in the first category or the second category, independent of whether a change in the security domain occurs when transitioning from background processing to execution of the given exception handling routine. Thus, the way in which the exception handling routine is categorized does not depend on whether a change in the security domain occurs when transitioning from background processing to the exception handling routine. In one exemplary implementation, for each of the security domains there are different banked versions of the configuration information, so that when evaluating a given exception handling routine, the domain in which the processing circuitry executes the exception handling routine may affect the configuration information. However, the overall categorization is independent of the security domain associated with the background processing, and therefore independent of whether there is a change in the security domain due to taking an exception from background processing.

[0036] As mentioned above, the configuration storage may be arranged to store, for each of the security domains, configuration information used to categorize the multiple exception handling routines associated with that security domain. Some exception handling routines may be capable of executing in multiple security domains, and some exception handling routines may only be executable in a particular security domain, and thus the configuration storage only needs to maintain configuration information associated with the exception handling routine for the security domain in which such exception handling routines execute. This may be useful in implementations in which separate configuration information is provided for each of the exception handling routines, to avoid the need to provide configuration bits for each of the exception handling routines in each of the security domains.

[0037] However, in the alternative implementations discussed above, configuration information is not actually provided for each of the exception handling routines, but instead, global information such as threshold priorities are provided; in such cases, the configuration storage may provide threshold priorities for each of the security domains, and thus the associated threshold priorities are referenced taking into account the security domain in which a given exception handling routine is executed.

[0038] In summary, however, in the presence of a system supporting multiple security domains, configuration information may be located in the configuration storage, and the exception control circuitry may be arranged to determine whether a given exception handling routine is in the first category or the second category by reference to the configuration information provided for the security domain in which the given exception handling routine is to be executed.

[0039] In situations where a processing circuit may execute program code in multiple different security domains, then within a given security domain, the processing circuit may be arranged to perform data processing in one of multiple states, including a non-privileged state and a privileged state. In some implementations, the processing circuit may be operable in multiple modes, including a handler mode for executing exception handlers and a thread mode. Execution in the handler mode may always be privileged, and whether execution in the thread mode is in a privileged or non-privileged state may depend on a configuration value.

[0040] In an implementation in which the processing circuitry is arranged to execute program code in multiple different security domains, then the exception control circuitry may also be arranged to perform additional checks when determining which registers need to have their data saved before triggering execution of an exception handling routine. For example, independent of the aforementioned checks that then seek to categorize exception handling routines based on configuration information in the configuration storage to ensure that security of the secure domain is not compromised, the exception control circuitry may also take into account transitions in the security domains when determining whether data in the second subset of registers needs to be saved. In particular, the exception control circuitry may be further arranged to trigger saving data from the second subset of registers and clearing the registers before triggering the processing circuitry to execute an exception handling routine corresponding to the identified exception, in response to identifying an exception that is the first exception causing a transition from the secure domain to a less secure domain in a situation in which background processing has been performed by the processing circuitry in the secure domain. Such an approach may ensure that data of the secure domain is not unintentionally made available to an exception handling routine operating in a less secure domain.

[0041] In situations where background processing is performed by processing circuitry in the secure domain, the identified exception that is the initial exception that causes a transition from the secure domain to the less secure domain may take a variety of forms. For example, the identified exception may be the given exception mentioned above that is causing the transition from background processing, or alternatively may be a tail-chained exception. For example, the given exception that caused the transition from background processing may also have been processed in the secure domain and may be a subsequent tail-chained exception that is then processed in the non-secure domain, thus becoming the initial exception that causes a transition from the secure domain to the less secure domain.

[0042] In such implementations in which the exception control circuitry may perform an additional check to determine whether to preserve data from the second subset of registers, the exception control circuitry may be further arranged to reference the aforementioned status flag, such that, in response to an identified exception, the exception control circuitry may be arranged to skip triggering the preservation of data when the status flag indicates that data from the second subset of registers has already been preserved. Thus, again, the use of the status flags can ensure improved efficiency when dealing with the saving and restoring of the state of various registers during the handling of an exception.

[0043] A specific example will now be described with reference to the figures.

[0044] 1 illustrates generally an example of a data processing system 2 including processing circuitry 4 for performing data processing in response to instructions fetched from a memory system 26. The memory system 26 may include a cache (e.g., one or more levels of data cache and / or instruction cache) and a main memory. In some larger systems, the main memory may include a single type of memory, e.g., DRAM, while in some smaller systems (e.g., a microcontroller), the main memory may include different types of memory, such as flash memory for storing program code and constant values, and SRAM for storing stacks and other values ​​that are modified during execution. The processing circuitry 4 has a processing pipeline including several pipeline stages, including, for example, a fetch stage 12 for fetching instructions from the memory system 26 to be executed, a decode stage 14 for decoding the fetched instructions to generate control signals for controlling the remaining pipeline stages to perform data processing, and an execute stage 16 for executing the decoded instructions to perform data processing operations. Registers 6 are provided for storing source data accessed by processing circuitry 4 when executing instructions (source operands), and for storing result data produced by execution of those instructions (destination operands). In addition, control registers 18 may be provided for storing control information used to control the operation of processing circuitry 4.

[0045] 1 are shown simply, it will be understood that other types of pipeline stages may also be provided, such as a rename stage for performing register renaming, an issue stage for queuing instructions awaiting execution and issuing the instructions for execution when their required source operands are available, and a writeback stage for handling instruction commitments and writing the results back to register 6. The pipeline may be an in-order or out-of-order pipeline.

[0046] While the processing circuitry is executing the program code, one or more exceptions may occur in order to cause a corresponding exception handling routine to be executed. When an exception causes the background processing to temporarily halt to allow the corresponding exception handling routine to be executed, it is typically necessary to preserve at least some of the data currently stored in registers 6 associated with the background processing, so that the data may subsequently be restored in the registers when the processing circuitry returns to performing the background processing. While such data may be preserved for subsequent use in a variety of ways, in one exemplary arrangement it is saved in stack 28 within memory system 26.

[0047] An exception control circuit 30 is provided to control the taking of exceptions. In response to a given exception, the exception control circuit is arranged to cause the performance of a state save operation to save data from the registers 6 before triggering the processing circuit 4 to execute a given exception handling routine corresponding to the given exception. As will be discussed in more detail herein, exactly which register states are saved to the stack 28 (such save operations are also referred to herein as stacking operations) in response to the exception control circuit 30 depends on how a given exception handling routine is categorized by the exception control circuit 30, and to assist the exception control circuit 30 in this categorization process, the exception control circuit 30 accesses a configuration storage 32 that stores configuration information used to categorize the exception handling routine. As shown in FIG. 1, in some implementations, the exception control circuit may directly access the register and memory hierarchy. However, in other implementations, the exception control circuit may indirectly perform the state save by triggering the processing circuit to perform the state save on behalf of the exception control circuit. In this way the number of connections to the register and memory hierarchy may be minimized, saving circuit area and power.

[0048] 1, registers 6 may be thought of as including a first subset of registers (referred to herein as caller registers 8) and a second subset of registers (referred to herein as callee registers 10) that do not overlap with the first subset. By default, exception control circuitry 30 is responsible for directly or indirectly preserving (stacking) the caller registers when handling exceptions from background processing, and preserving (stacking) the callee registers is the responsibility of a given exception handling routine executed by the processing circuitry in response to a given exception.

[0049] However, as mentioned above, the system described herein supports the execution of untrusted as well as trusted exception handlers, and when executing an untrusted exception handler, it is necessary that all state of registers (both caller and callee) be saved to stack 28 and cleared from the registers before executing the untrusted exception handler code to ensure that the untrusted exception handler code does not access data that belongs to background processing. Trusted wrapper software may be used on entry to and exit from the untrusted exception handler code to implement the required steps to ensure that the untrusted body of exception handler code does not access data that it should not access, thus, for example, trusted wrapper software may be used to save and clear callee registers associated with background processing. However, interrupt latency has become a significant issue, and implementing such steps using wrapper software may significantly increase interrupt latency for such untrusted exception handler code.

[0050] As will be discussed in more detail herein, to mitigate this problem, the exception control circuitry 30 is arranged to determine whether a given exception handling routine associated with a given exception is treated as trusted or untrusted by reference to configuration information in the configuration storage 32. In the event that a given exception handling routine is treated as untrusted, the exception control circuitry hardware 30 may be arranged to save not only the caller registers, but also the callee registers, and to clear the contents of the saved registers before triggering the handling circuitry to execute the given exception handling routine. This can significantly reduce interrupt latency for such untrusted exception handling routines by avoiding the need for register saving and clearing to be performed by trusted wrapper software. Furthermore, by using configuration information to try to distinguish between trusted and untrusted exception handling routines, this ensures that the exception control circuitry 30 does not need to always save the state of all registers, but can continue to save only the caller registers for trusted exception handling routines, thus avoiding performance impacts in such trusted exception handling routines (which may often be time-critical routines).

[0051] The techniques described above may be used in a variety of systems. For example, the techniques may be used in a system operating in a single security domain, where the processing circuitry is capable of operating in both privileged and non-privileged states, and where configuration information may enable the exception control circuitry to attempt to categorize exceptions such that those exception handling routines executed by processing circuits whose bodies are non-privileged are treated as untrusted. Alternatively, the techniques may be used in a system having a secure domain and a less secure domain, with only a single processing state in each of the security domains, and where configuration information may enable the exception control circuitry to attempt to categorize exceptions such that those exception handling routines executed by processing circuits in the less secure domain are treated as trusted.

[0052] However, for the purposes of the examples considered herein, it is considered that in the system, the processing circuitry is capable of operating in multiple security domains, including a secure domain and a less secure domain, and within each of the security domains, the processing circuitry is capable of operating in multiple processing states, including a non-privileged state and a privileged state. Configuration information may then be specified that is used to categorize a given exception handling routine within the security domain in which it executes. Thus, while the configuration information may vary between the secure and less secure domains, within any particular security domain, the configuration information may be used to attempt to distinguish between trusted exception handling routines and exception handling routines that are treated as untrusted (e.g., as in the previous example, an exception handling routine whose body is executed while the processing circuitry is in a non-privileged state may be considered untrusted).

[0053] In such a system 2, the system may also include a memory access check circuit 20 for checking whether access to the memory system 26 is permitted based on attribute data specified for various regions of the memory address space. The memory access check circuit may include a security attribute unit (SAU) 24 for storing data defining security domains, the data defining the security domains defining the security domains associated with each of the corresponding regions of the memory address space. Based on the security attribute data, the security attribute unit 24 may check whether the memory access is permitted depending on the current security domain of the operation of the processing circuit and the security domain associated with the region containing the target address of the memory access. In other implementations, the SAU 24 may not directly store the data defining the security domains, but may instead access data defining the security domains stored elsewhere to perform the memory access check. In some systems, the data defining the security domains may be stored in the memory system 26 or may be stored in configuration registers elsewhere in the system 2.

[0054] Processing circuitry 4 may operate in a current security domain of operation, which may generally correspond to the security domain associated with the address of the currently executing instruction (though there may be some exceptions, e.g., when processing transitions between domains). When an instruction branches from an address in a region specified by SAU 24 as being in one domain to an address in a region associated with a different domain, this may trigger a transition of the current security domain in which processing circuitry 4 is operating. In other implementations, such a branch may not directly trigger a transition of the current security domain, but instead may trigger additional security checks, such as whether a gateway instruction is present. In these implementations, the gateway instruction itself may trigger a change in the current security domain. For some other types of security domain transitions, a special branch instruction may be used to branch to the execution of the instruction at the address specified by the instruction and in a different security state. In general, while operating in the secure domain, the processing circuitry can access data in regions of memory associated with both the secure domain and the less secure domain, and when operating in the less secure domain, the processing circuitry can access data in regions associated with the less secure domain, but may not be permitted to access data in regions of the address space that SAU 24 designates as associated with the secure domain. This allows protection of sensitive data against unauthorized access from code operating in the less secure domain.

[0055] The memory access checking circuitry may also include a Memory Protection Unit (MPU) 22 that checks whether a memory access to the memory system 26 satisfies access permissions, which may specify, for example, which privilege level of the processing circuitry 4 is allowed to access a given region of memory, or which memory region of the address space is a read-only region that may be accessed by both read and write operations or is write-prohibited. The access permissions used by the MPU 22 may be specified, for example, by a higher privilege process (such as a hypervisor or operating system) to control which regions of memory a lower privilege process (such as an application) is allowed to access and how (read-only or read / write). The permissions provided by the MPU 22 may be orthogonal to the permissions provided by the SAU 24, such that for a given memory access that is allowed, it should pass a check based on the access permissions defined for both the MPU 22 and the SAU 24. Although MPU 22 is shown as a single entity in FIG. 1, in some examples separate secure and less secure MPUs 22 may be provided, with each separate secure and less secure MPU 22 associated with one of the security domains, such that different memory access permissions may be specified for a given region of memory depending on whether the current domain is the secure domain or the less secure domain (e.g., the region is read-only in the less secure domain, but readable and writeable in the secure domain).

[0056] Thus, as shown in Figure 2, processing circuitry 4 is capable of supporting data processing in one of several security domains including at least a secure domain (S) and a less secure domain (LS). Although Figure 2 shows a system having only two security domains, it is possible to provide more than two domains associated with different levels of security.

[0057] Also, within a given security domain, as shown in FIG. 2, the processing circuit may perform data processing in one of several modes, including a handler mode (H) and a thread mode (T). The handler mode is typically used for exception handling, so that, for example, a trusted exception handling routine may be executed in the handler mode. The thread mode is typically used to execute a different thread, for example, a different application thread. However, in addition, the body of an untrusted exception handling routine may be executed as a thread in the thread mode, and in one exemplary implementation, the associated wrapper code is executed in the handler mode. When operating in the handler mode H, the processing circuit 4 is assumed by default to have a more privileged mode of operation, so that access to memory and control registers is controlled according to a privilege level other than a lower privilege level, and in the thread mode T, the processing circuit may have one of several different privilege levels, depending on other architectural state stored in the control registers.

[0058] Thus, as shown in Figure 2, the combination of the security domain and the mode in which processing circuitry 4 is operating may determine how processing is performed by processing circuitry 4. Figure 2 shows four different combinations of these modes, including: Secure Threading Mode (shorthand for the combination of Secure Domain and Threading Mode) Less secure threaded mode (combination of less secure domain and threaded modes) Secure Handler Mode (combination of secure domain and handler mode) and Includes a less secure handler mode (a combination of a less secure domain and handler mode).

[0059] The configuration information provided in the configuration storage 32 can take a variety of forms. Figure 3A shows an example in which separate configuration information is provided for each of at least a subset of possible exception handling routines. In one exemplary implementation, an entry may be provided for every exception handling routine, while in other implementations, the categorization of one or more particular exception handling routines may be a predetermined categorization and thus may not need to be captured in an entry in the configuration storage. For example, certain critical exceptions may always be considered to be in a first category, and thus the exception control circuitry 30 can make such a determination based on the type of exception itself, without having to refer to configuration information in the configuration storage.

[0060] For each exception handling routine for which corresponding configuration information is provided in the configuration storage, an entry in the configuration storage 30 is allocated, the entry having a first field 35 used to identify the exception handling routine and a second field 40 used to identify whether the exception handling routine is in the first or second category. In other implementations, the column of the second field 40 may be indexed by exception number, and thus separate storage for the first field 35 may not be required. The information provided in this field 40 can take a variety of forms, but in one example, the information is a single-bit field that is set to identify when the exception handling routine is in the second category and is cleared when the exception handling circuitry is in the first category. Thus, in such an implementation, when field 40 is set, this indicates that the exception control circuitry 30 will save all of the register state, rather than simply saving the caller registers.

[0061] In implementations with multiple security domains, the configuration storage may then be replicated for each of the security domains. However, it will be appreciated that some exception handling routines may be specific to a security domain, and therefore entries for such exception handling routines need only be created in the table of exception handling routines maintained for the relevant security domain. In some implementations, there may be exceptions that may be configured to target either a secure domain or a less secure domain. In such cases, replicating the configuration storage for these exceptions may be wasteful, since only one of the replicated fields 40 of the configuration storage is used (the one replicated field 40 depends on the target security domain of the exception). In such implementations, a configurable target security domain may be provided for only a single field 40 for an exception, and instead, access to the field 40 for a given exception may be prohibited from the less secure domain if the exception is configured to target a secure domain.

[0062] In some cases, there may be a large number of different exception handling routines supported by the system, and in such cases, the size of the configuration storage 32 required to capture configuration information for each of the exception handling routines may be relatively large. However, in some implementations, a more efficient form of configuration storage may be used. For example, in one exemplary implementation, untrusted exception handling routines may typically be assigned a lower priority than trusted exception handling routines, and thus the priority level of the associated exception may be used as a proxy for an indication of whether the exception handling routine should be treated as trusted or untrusted. In such a situation, the configuration storage 30 may be arranged to store a threshold priority indication, as shown in FIG. 3B. In an implementation with multiple security domains, different threshold priorities may be indicated for each of the security domains. Thus, when considering a transition from background processing to a given exception handling routine as indicated by a given associated exception, the priority of the given exception may be compared to the threshold priority indication in the configuration storage 32 to determine whether the associated exception handling routine should be considered as being in the first category or the second category. In situations where different threshold priorities are provided for different security domains, the security domain in which a given exception handling routine is executed may be taken into consideration when determining the appropriate threshold priority to compare with the priority of a given exception.

[0063] According to a third exemplary implementation, the threshold priority may be fixed and the configuration storage may be arranged to store a configurable priority for each of the exceptions, as shown in Figure 3C. Thus, each of the entries in the configuration storage 32 may be arranged to provide a first field 45 for identifying an exception handling routine and a second field 50 for identifying the priority of that exception. In other implementations, the column of the second field 50 may be indexed by the exception number, and thus separate storage for the first field 45 may not be necessary. The discussion made above in connection with Figure 3A regarding whether entries need to be replicated for different security domains applies equally to the implementation of Figure 3C.

[0064] In one particular implementation, when the associated priority of a given exception is less than a threshold priority, the associated exception handling routine is determined to be in the second category, i.e., to be treated as an untrusted exception handling routine. As a result, this triggers the exception control circuitry 30 to trigger the saving and clearing of the state of both the caller and callee registers before triggering the processing circuitry to execute the given exception handling routine. However, if the priority is the same or greater than the threshold priority, the exception handling routine is considered to be in the first category, and the exception control circuitry simply saves (and optionally clears) the state of the caller registers before triggering the processing circuitry to execute the given exception handling routine. In other implementations, an exception may be considered to be in the second category (where both the caller and callee registers need to be saved) if the priority of the exception is less than or equal to the threshold. In such a system, an exception may be considered to be in the first category if the priority of the exception is greater than the threshold.

[0065] In other implementations, the priority of an exception to be entered may be modified before it is compared to the threshold. The threshold priority may also undergo such modification before the comparison. Modifying the priority of an exception may take the form of restricting the priority to be within a certain range, or mapping the priority from one priority range to another. These types of priority modification may be useful in systems with multiple security domains to ensure that even the highest priority exception for a less secure domain cannot preempt a security critical exception associated with a secure domain. However, it will be understood that different comparisons may be used and / or various priority modification and remapping schemes may be applied, but these do not prevent the modified / remapped priority of an exception from being used as a proxy for whether the associated exception handler should be treated as trusted.

[0066] Although providing a priority configuration field for each exception would be very expensive, this is a process commonly used in modern systems, and therefore reusing that existing information to categorize exception handling routines adds no additional cost, and therefore can provide a very efficient mechanism for implementing such categorization.

[0067] 4 is a flow diagram illustrating the handling of an exception from a background process. In step 100, it is determined whether an exception from a background process has occurred. The background process may, for example, include the execution of program code other than an exception handling routine by the processing circuit, for example the execution of a particular application thread, in which event the exception is an initial exception from that background process. However, it may often be the case that the background process itself is the execution of a particular exception handling routine, and the exception detected in step 100 is a preemptive exception of higher priority than the exception corresponding to the current exception handling routine. In this case, the current exception handling routine needs to be interrupted (and thus treated as a background process) in order to execute the exception handling routine required by the higher priority exception detected in step 100.

[0068] In the situation where an exception from a background process is detected in step 100, then in step 105, the exception control circuitry 30 is arranged to determine whether the required exception handling routine (i.e., the exception handling routine required to handle the exception detected in step 100) is in the first category or the second category by referring to the configuration storage 32. As mentioned above, the configuration information maintained in the configuration storage 32 is such that trusted exception handling routines are typically considered to be in the first category, and exception handling routines in the second category are considered to be untrusted exception handling routines. In an implementation in which a threshold priority indication is used, then, in some cases, a trusted exception handling routine may in fact have a sufficiently low priority for the exception handling routine to be considered as being in the second category, and therefore untrusted. This does not cause incorrect behavior in the operation of the system, but merely incurs a slight performance penalty by having the callee registers saved and cleared in addition to the caller registers. Furthermore, if the system were to provide a particularly high priority untrusted exception handler, then a determination made with reference to the configuration storage may identify the exception handler as being in the first category and therefore trusted, in which event the exception control circuitry would simply preserve the caller register state. However, the aforementioned wrapper software provided in the processing mode may then be used to preserve and clear the callee registers before handing execution over to the body of the untrusted exception handler.

[0069] At step 110, it is determined whether the required exception handling routine is in the first category, and if so, the process proceeds to step 115. In some implementations, step 115 is not required, while in other implementations, other checks may also be performed by the exception control circuitry 30 to determine whether the callee registers need to be preserved. As a particular example, as described in commonly owned U.S. Pat. No. 9,202,071, the entire contents of which are incorporated herein by reference, the exception control circuitry may be arranged to detect a situation where background processing is in a secure domain and the exception handling routine is executed in a less secure domain, in which case the exception control circuitry may be arranged to preserve the callee registers in addition to the caller registers. In implementations incorporating such functionality, the same exception control circuitry 30 may then be used to implement the techniques described herein based on the categorization of individual exception handling routines within a particular security domain. As is evident from the foregoing discussion, such categorization occurs independently of whether there is a transition in the security domain resulting from taking the exception.

[0070] If there are no other checks indicating that the callee registers should be saved at step 115, then the process proceeds to step 120, where only the caller registers are saved to the stack 28. In a system using multiple security domains, a different stack may be provided for each of the security domains, and the data from the caller registers is placed on the appropriate stack. Thus, if the background process is in the secure domain, then the data from the caller registers is saved to the secure stack, and if the background process is in the less secure domain, then the data from the caller registers is saved to the less secure stack. As shown by step 120, the exception control circuitry may optionally clear the caller registers, if desired. However, in other cases, given that the required exception handling routine has been determined to be in the first category, i.e., is considered to be trusted, clearing the caller registers may be considered unnecessary. At step 122, the status flag is cleared to identify that only the caller registers have been saved to the stack.

[0071] If in step 110 it is determined that the required exception handling routine is in the second category, i.e. untrusted, then the process proceeds to step 130, where the exception control circuitry 30 is arranged to trigger saving data from the caller and callee registers to the stack and to cause these registers to be cleared. The registers may be cleared after the state is saved, or in one implementation, each of the registers may be cleared when the register's data is saved to the stack. As shown in FIG. 4, step 130 may also be reached from the "Yes" path of step 115, i.e. in a situation where the required exception handling routine is in the first category, but some other check performed by the exception control circuitry determines that it is appropriate to save the callee registers. Again, in case the system supports execution in multiple security domains, the stack to which the register state is saved is the stack belonging to the security domain in which the background processing is being performed.

[0072] Following step 130, then in step 135, a status flag is set to indicate that the callee register has been saved to the stack. There are several ways in which the status flag may be set. For example, the status flag may be provided as an additional bit in the information stored in the link register that is used to indicate the return address to which processing should return after completion of the exception handling routine. In other implementations, the information stored in the link register is an exception return value. The exception return value is a reserved non-executable address that triggers the exception return process when branched to. However, in both cases, the information initially stored in the link register may subsequently be moved from the link register to other storage structures in the system, and thus may end up, for example, in one of the stacks or in another register in the memory system.

[0073] Following step 135, or following step 122 in the event that the exception handling routine is in the first category, then in step 125 the exception control circuit 30 triggers the handling circuit to execute the required exception handling routine.

[0074] Figure 5 is a flow diagram illustrating the implementation of step 105 of Figure 4 in the situation where the configuration storage takes the form shown in Figure 3B and therefore provides a threshold priority indication. At step 150, the priority of the exception detected at step 100 is determined and the corresponding exception handling routine is executed, assuming the security domain.

[0075] The exception control circuitry then obtains from the configuration storage the threshold priority that is applicable to the security domain in which the exception handling routine is to be executed, in step 155. As previously mentioned, the configuration storage 32 may store different threshold priorities for each of the security domains, if desired, and thus, in step 155, the appropriate threshold priority is determined.

[0076] At step 160 it is determined whether the priority of the exception is below the threshold priority, and if not, the exception handling routine is determined to be of a first type at step 165. However, if the priority of the exception is below the threshold priority, then at step 170 it is determined that the exception handling routine is of a second type.

[0077] 6 is a flow diagram illustrating exception return processing performed upon completion of an exception handling routine. In step 200, it is determined whether an exception return point has been reached, i.e., whether processing of the current exception handling routine has been completed. In some implementations, this is indicated by branching to a reserved non-executable exception return address, which may include the aforementioned status flag. When this is the case, the process proceeds to step 205, where the value of the aforementioned status flag is determined. As previously mentioned, this may be available in a link register, but in some cases the contents of that link register have been moved elsewhere in the system, for example to one of the stacks, and therefore at this stage the relevant information may be obtained from the stack in order to determine the value of the status flag.

[0078] At step 210, it is determined whether the exception return returns to background processing. Assuming processing returns to background processing, then at step 215, it is determined whether the status flag indicates that the callee registers were saved. In one exemplary implementation, the status flag information directly identifies whether the callee registers were saved. However, in an alternative implementation, the status flag information may encode whether a deviation occurred from the default stacking rules, and by knowing that information, it may be determined in any particular situation whether the callee registers were saved.

[0079] In the event that the callee registers have not been saved, then the process proceeds to step 220. At step 220, the exception control circuitry 30 is arranged to trigger the unstacking of the caller registers, i.e. to obtain from the associated stack any data previously saved from the caller registers, and to restore that data to the caller registers. At this point, the processing circuitry is then triggered to resume background processing.

[0080] If at step 215 it is determined that the callee registers have been saved, then the process proceeds to step 225 where the exception control circuitry 30 is arranged to trigger the unstacking of both the caller and callee registers. Again, this is achieved by reading the previously saved data for the caller and callee registers from the associated stacks and restoring that data to the associated registers. Again, the processing circuitry is then triggered to return to background processing.

[0081] However, it is not always the case that the process will return to background processing upon exception return. In particular, another exception may be pending at this time, which has a lower priority than the just-completed exception handling routine and therefore did not preempt the exception handling routine. Thus, if the pending exception has a higher priority than the background processing, rather than simply returning to background processing for another exception that is taken immediately, a tail-chaining mechanism may be used to start the execution of the pending exception that was waiting for the current exception handling routine to complete. Thus, if it is determined in step 210 that the process will not return to background processing upon exception return, then in step 230, the status flag value is used to determine whether further stacking of the contents of the background registers is required before performing the exception handling routine associated with the tail-chained exception.

[0082] Figure 7 is a flow diagram illustrating how tail-chained exceptions are handled upon exception return, and thus illustrates how, in one exemplary implementation, the process of step 230 of Figure 6 may be implemented. At step 250, configuration storage 32 is referenced by exception control circuitry 30 to determine whether the required exception handling routine for the tail-chained exception is in the first category or the second category. At step 255, it is determined whether the tail-chained exception is in the second category, and if so, the required exception handling routine is treated as untrusted, and the process proceeds to step 260.

[0083] In step 260, it is determined whether the status flag indicates that the callee registers have already been saved. In particular, since the required exception handling routine is in the second category and is therefore treated as untrusted, the callee register state needs to be saved, but it may be that the state has already been saved by a previous action of the exception control circuitry in response to a previous exception. If in step 260, it is determined that the status flag indicates that the callee registers have not yet been saved, then in step 265, the callee registers are saved by the exception control circuitry 30 to a stack and the callee registers are cleared. In particular, the contents of the callee registers are saved to a stack associated with the security domain in which the background processing was running. In addition, in step 270, the contents of the caller registers are cleared. The process then proceeds to step 285, where the processing circuitry is triggered to execute the required exception handling routine for the tail-chained exception. If, in step 260, it is determined from the status flags that the callee registers have already been saved, then step 265 may be bypassed and instead the callee registers may simply be cleared in step 267. The process then proceeds to step 270.

[0084] It is determined in step 255 that the required exception handling routine for the tail-chained exception is in the first category, the exception handling routine is known to be trusted. Furthermore, it is known that because the required exception handling routine is implemented in response to the tail-chained exception, the exception control circuitry 30 has already saved the state of the caller registers in association with the previous exception to the associated stack. Therefore, no further action is required other than optionally clearing the caller registers in step 280, and the process can proceed directly to step 285, where the handling circuitry is triggered to execute the required exception handling routine for the tail-chained exception.

[0085] 4, in some implementations, the exception control circuitry 30 may also perform additional checks to determine whether the state of the callee registers is required to be preserved, and thus, at step 275, the exception control circuitry may determine whether other checks indicate that the callee registers should be preserved. If so, the process may proceed to step 260, but if not, the process may proceed to step 280.

[0086] As an example of an implementation in which the exception control circuitry may perform additional checks, in a system using multiple security domains including a secure domain and a less secure domain, then in a situation where the background is being processed in the secure domain and an exception handling routine is executed in the less secure domain, it is appropriate for the callee registers to be preserved when such a less secure exception handling routine is executed for the first time. This may be that the initial exception taken from the background processing is for an exception that is handled in the secure domain. Thus, when handling a tail-chained exception, in a situation where the background processing was in the secure domain, it may be appropriate to also check whether the required exception handling routine for the tail-chained exception is the first exception that causes a transition to the less secure domain, and in this case, it may be appropriate to stack the callee registers if they have not been stacked yet, otherwise they were not stacked due to the required exception handling routine for the tail-chained exception being determined to be in the second category.

[0087] FIG. 8 is a flow diagram showing how preemption is handled according to one exemplary implementation. Preemption occurs when an exception occurs during the execution of a current exception handling routine, in a situation where the newly arriving exception has a higher priority than the priority associated with the currently executing exception handling routine. Such a higher priority exception occurring during the processing of a current exception handling routine is called a preemptive exception. If a preemptive exception is detected in step 300, then the process proceeds to step 305, where the current exception handling routine is treated as a background process, and the preemptive exception is treated as an exception from the background process. As a result, in step 310, the process of FIG. 4 described above is implemented to determine the register state to be saved on the stack before executing the exception handling routine to handle the preemptive exception. Thus, in practice, there may be nested levels of background processing, and the process of FIG. 4 is implemented each time an exception is taken from such a background process. An example of this is discussed below with reference to FIG. 9C.

[0088] 9A-9C illustrate the processing of exceptions in various exemplary scenarios in which the configuration information stored in the configuration storage 32 provides a threshold priority. FIG. 9A illustrates an example in which the exception arises from background processing and the exception has a priority lower than the threshold priority. As previously discussed, the priority value used to infer the priority can take a variety of forms. For example, in one implementation, a lower priority value may indicate a lower priority, while in one particular exemplary implementation, a lower priority value may actually indicate a higher priority. Similarly, as previously discussed, the priority may be modified and / or remapped before being compared. Regardless of how the priority value is encoded and processed, it will be appreciated that based on knowledge of the obtained priority associated with the exception and knowledge of the obtained threshold priority, it may be determined whether the obtained priority of the exception is below the obtained threshold priority.

[0089] In the example of Figure 9A, an interrupt is received at point 350 during processing of background processing, causing exception control circuitry 30 to process a transition from background processing to execution of the required exception handling routine. During the transition between points 350 and 355, exception control circuitry 30 references configuration storage 32 for a threshold priority and evaluates whether the priority of the exception falls below the threshold priority. In this example, it is determined that the priority of the exception falls below the threshold priority, and therefore, the exception control circuitry triggers stacking of the caller and callee registers onto associated stacks 28 in memory system 26 and sets a status flag to identify that the callee registers have been stacked.

[0090] 9A , the body of the exception handling routine is assumed to execute in an unprivileged state, and in one exemplary implementation, wrapper software is associated with the body of the exception handling routine to handle transitions to and from the body of the exception handling routine. Note that the background code may execute in a privileged or unprivileged state within the aforementioned thread mode, and in one exemplary implementation, regardless of whether the background code is in an unprivileged or privileged state, the exception handling routine entry at point 355 occurs with the processing circuitry operating in a privileged handler mode, and thus the wrapper software executes in a privileged state and may be referred to as a privileged wrapper.

[0091] Because the exception control circuitry hardware 30 has stacked the callee and caller registers, the privileged wrapper software then does not need to take the step of stacking the callee registers, but instead simply needs to take other additional steps that are required before handing off execution to the non-privileged body of the exception handling routine. Similarly, following execution of the body of the exception handling routine between points 360 and 365, the privileged wrapper is again used to take the steps necessary before handing off to the exception control circuitry 30 to manage the transition back to background processing, and again the privileged wrapper does not need to take the steps related to unstacking the callee registers, because the exception control circuitry hardware has taken care of that process. As a result, the interrupt latency associated with the execution of the exception handling routine can be significantly reduced.

[0092] During the transition between points 370 and 375, the exception control circuit detects that the status flag has been set and unstacks both the caller and callee registers. At this point, the exception control circuit may then clear the status flag. As mentioned above, the memory location of the status flag may change depending on the time the exception return is handled by the exception control circuit. For example, upon exception entry, the exception control circuit may have set the status flag as a bit in the link register, but the link register contents may have moved during this time, and the link register contents may end up, for example, on the stack itself, and thus the exception control circuit accesses the status flag from the relevant location when making an evaluation during exception return as to which registers need to be unstacked. As mentioned above, in some implementations, the status flag is set to an exception return value, which is a reserved non-executable address, and the exception return process triggers an attempt to branch to the exception return value. In such a case, the act of branching to the exception return value also has the effect of passing the status flag from an intermediate memory location (e.g., the stack) to the exception handling circuit.

[0093] In some implementations, in cases where the status flags form fields within the exception return value, it may not be necessary to actually clear the status flags upon exception return, since the exception return value is consumed upon exception return and therefore no longer exists at this point.

[0094] 9B illustrates a second exemplary scenario in which two interrupts are received simultaneously at point 400 during the processing of a background process. In this case, both a Non-Masked Interrupt (NMI) and a standard interrupt (IRQ) are received, and since the NMI has a higher priority, the NMI is processed first. Between points 400 and 405, the exception control circuit 30 evaluates the priority of the NMI against a threshold priority and determines that the NMI has a higher priority than the threshold priority. As a result, the exception control circuit simply stacks the caller registers. As previously discussed with reference to FIG. 4, the exception control circuit could also perform additional checks to determine whether the callee registers should be stacked, but for the purposes of this discussion, it is assumed that such further checks performed result in a determination that the callee registers do not need to be stacked.

[0095] Between points 405 and 410, an NMI exception handling routine is executed to handle the NMI. In this case, it is assumed that the entire exception handling routine is executing in handler mode, with the handling circuitry operating in a privileged state.

[0096] At step 410, the exception handling routine that handles the NMI is completed and it is determined that there is a tail-chained exception, i.e., the original IRQ interrupt. Note that in the example shown in Figure 9B, the NMI and IRQ interrupts were received at exactly the same time, but the process shown in Figure 9B would also occur if an IRQ exception occurred at any point prior to point 410 during the handling of the NMI.

[0097] Between points 410 and 415, the exception control circuit 30 determines whether the priority of the IRQ interrupt exceeds or falls below the threshold priority, and in this case determines that the priority of the IRQ interrupt falls below the threshold priority. Thus, referring to FIG. 7 above, in step 255 it is determined that the exception handling routine executed to handle the IRQ interrupt is in the second category, and then in step 260 it is determined that the status flag does not indicate that the callee registers have already been saved. It is recalled in particular that only the caller registers were saved during the transition between points 400 and 405. Thus, the exception control circuit now triggers stacking of the callee registers, clearing of the registers, and sets the status flag to indicate that the callee registers have been saved.

[0098] The exception handling routine required to handle the IRQ interrupt is then performed between points 415 and 430, and in accordance with the above discussion of FIG. 9A, it is assumed that the body of the exception handling routine is handled in a non-privileged state between points 420 and 425 by executing a thread in thread mode, with transitions to and from the non-privileged thread being managed by privileged wrapper software executing in handler mode.

[0099] At point 430, execution of the exception handling routine is considered to be complete, and therefore at this point the exception control circuit 30 determines that there are no further tail-chained exceptions and that processing should return to background processing at point 435. During the transition to background processing, the exception control circuit detects that the status flag has been set, and therefore triggers the unstacking of both the caller and callee registers. If necessary, the exception control circuit can also clear the status flag at this point, although as previously mentioned, this may not be necessary since the status flag may not be present after the exception return.

[0100] FIG. 9C illustrates a preemption example in which a higher priority interrupt is received during execution of an exception handling routine for an interrupt. In particular, at point 450, a standard IRQ interrupt is received, and between points 450 and 455, the exception control circuitry 30 determines that the priority of the interrupt falls below a threshold priority, thus triggering stacking of both the caller and callee registers for background processing, and setting a status flag associated with the IRQ interrupt to indicate that both the caller and callee registers have been saved. As previously discussed, the contents of these registers are then typically cleared before handing off to the exception handling routine executed to handle the IRQ interrupt. For purposes of the illustration of FIG. 9C, it is immaterial whether the exception handling routine used to handle the IRQ interrupt runs in a privileged or non-privileged state, and therefore whether there is associated wrapper software or not. However, at some point during the processing of the exception handling routine, an NMI is received at point 460, which has a higher priority than the IRQ interrupt. Therefore, an NMI is treated as a preemptive exception, and processing of the exception handling routine for the IRQ interrupt is halted while the NMI exception is being handled.

[0101] In particular, as shown in Figure 9C, between points 460 and 465, the exception control circuitry detects that the priority of the NMI exceeds a threshold priority, and therefore stacks the state of the caller registers used by the exception handling routine that handles the IRQ interrupt. The exception control circuitry also clears the status flag values ​​associated with the NMI, and the IRQ exception handling routine is treated as a new background process at this point.

[0102] The exception handling routine used to handle the NMI is performed between points 465 and 470, after which it is determined that there is an exception return to the background process (in this event, the background process is the exception handling routine that was handling the IRQ.) Between points 470 and 475, the exception control circuitry determines from the status flags for the NMI that only the caller registers have been stacked, and therefore triggers only the unstacking of the caller registers belonging to the exception handling routine for the IRQ interrupt.

[0103] Between points 475 and 480, the exception handling routine used to handle the IRQ interrupt is completed and then at step 480 it is detected that there is a return to the background process (the original background process). Thus, the exception control circuit determines that the status flag for the IRQ interrupt has been set and therefore unstacks both the caller and callee registers belonging to the background process between points 480 and 485, after which the background process is resumed.

[0104] FIG. 10 illustrates a simulator implementation that may be used. While the above examples implement the invention in terms of apparatus and methods for operating specific processing hardware that supports the technique, it is also possible to provide an instruction execution environment according to the examples described herein, which is implemented through the use of a computer program. Such computer programs are often referred to as simulators insofar as they provide a software-based implementation of a hardware architecture. Various simulator computer programs include emulators, virtual machines, models, and binary translators, including dynamic binary translators. Typically, a simulator implementation may run on a host processor 515, which optionally runs a host operating system 510, which supports the simulator program 505. In some arrangements, there may be multiple layers of simulation between the hardware and the provided instruction execution environment, and / or there may be multiple different instruction execution environments provided on the same host processor. Historically, powerful processors have been required to provide simulator implementations that run at reasonable speeds, but such an approach may be justified in some situations, for example, when it is desired to run code native to another processor for compatibility or reuse reasons. For example, a simulator implementation may provide an instruction execution environment that has additional features not supported by the host processor hardware, or that are typically associated with a different hardware architecture. An overview of simulation is given in "Some Efficient Architecture Simulation Techniques", Robert Bedichek, Winter 1990 USENIX Conference, pp. 53-63.

[0105] To the extent that examples have been described above with reference to particular hardware constructs or features, in the simulated implementations, equivalent functionality may be provided by suitable software constructs or features. For example, particular circuits may be provided as computer program logic in the simulated implementations. Similarly, memory hardware such as registers or caches may be provided as software data structures in the simulated implementations. Also, the physical address space used to access memory 26 in hardware device 2 may be emulated as a simulated address space, which is mapped by simulator 505 to a virtual address space used by host operating system 510. In arrangements where one or more of the hardware elements referred to in the preceding examples are present in host hardware (e.g., host processor 515), some simulated implementations may use the host hardware where suitable.

[0106] The simulator program 505 may be stored in a computer-readable storage medium (which may be a non-transitory medium) and provides a virtual hardware interface (instruction execution environment) to the target code 500 (which may include applications, operating systems, and hypervisors), the virtual hardware interface being the same as the hardware interface of the hardware architecture modeled by the simulator program 505. Thus, the program instructions of the target code 500 may be executed from within the instruction execution environment using the simulator program 505, so that a host computer 515 that does not actually have the hardware features of the aforementioned device 2 can emulate these features. The simulator program may include a processing program logic 520 for emulating the behavior of the processing pipeline 4 and an exception control program logic 525 for emulating the behavior of the exception control circuitry 30 of the hardware device 2 of FIG. 1. The architectural registers 6 of the system 2 may also be emulated using a data structure emulating program logic 530 maintained by the simulator code 505 for mapping the architectural registers of the target architecture to the memory space used by the host hardware 515. Such data structure emulation program logic 530 may also be used to emulate configuration storage 32 of system 2 by providing suitable memory locations within the memory space used by host hardware 515. Thus, the techniques described herein for stacking and untacking caller and callee registers based on categorization of an executed exception handling routine may be implemented in software by simulator program 505 in the example of FIG.

[0107] Use of the techniques described herein may provide a system that supports the use of both trusted and untrusted exception handling routines while allowing low interrupt latency to be maintained by selectively using the exception control circuitry hardware to manage the stacking and untacking of caller registers as well as callee registers. Through the use of suitable configuration information, the exception control circuitry may attempt to distinguish between trusted and untrusted exception handling routines and may only attempt to stack both the caller and callee registers associated with exception handling routines that the exception control circuitry determines should be treated as untrusted. This reduces the latency associated with the handling of untrusted exception handling routines without adversely affecting the speed of performance of the trusted exception handling routines.

[0108] In this application, the term "configured to..." is used to mean that elements of an apparatus have a configuration that can perform a defined operation. In this context, "configuration" refers to an arrangement or manner of interconnection of hardware or software. For example, an apparatus 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 apparatus elements need to be modified in any way to provide the defined operation.

[0109] Although illustrative examples of the invention have been described in detail herein with reference to the accompanying drawings, it will be understood that the invention is not limited to these precise examples, and that various changes, additions, and modifications may be made to these examples by those of ordinary skill in the art without departing from the scope and spirit of the invention as defined by the appended claims. For example, various combinations of the features of the independent claims may be made with the features of the dependent claims without departing from the scope of the invention.

Claims

1. a processing circuit operable in at least one security domain to execute program code including a plurality of exception handling routines that are executed in response to corresponding exceptions; a plurality of registers for storing data accessed by the processing circuit when executing the program code, the plurality of registers including a first subset of registers and a second subset of registers that do not overlap with the first subset; an exception control circuit for, in response to occurrence of a given exception from a background process, triggering a state save operation to save data from the plurality of registers before triggering the processing circuitry to execute a given exception handling routine corresponding to the given exception; a configuration storage for storing configuration information used to categorize exception handling routines of the plurality of exception handling routines; An apparatus comprising: the exception control circuit is configured to determine whether the given exception handling routine is in a first category or a second category within the security domain in which the given exception handling routine executes by referring to the configuration information, and the exception control circuit is configured, when triggering the state save operation, to trigger saving of the data from the first subset of registers when the given exception handling routine is in the first category, and to trigger saving of the data from both the first subset of registers and the second subset of registers when the given exception handling routine is in the second category.

2. and wherein, at least when the given exception handling routine is in the second category, the exception control circuitry is further arranged to trigger a clearing of the registers whose data was saved during the state save operation before triggering the handling circuitry to execute the given exception handling routine.

2. The apparatus of claim 1.

3. 3. The apparatus of claim 1, wherein the first category indicates exception handling routines that are trusted and the second category indicates exception handling routines that are treated as untrusted.

4. 4. The apparatus of claim 3, wherein the processing circuitry is operable in an unprivileged state and a privileged state, the processing circuitry being operable to execute at least a body of the untrusted exception handling routine while in the unprivileged state.

5. Apparatus as claimed in any preceding claim, wherein the configuration storage is arranged to store corresponding items of configuration information for one or more exception handling routines.

6. 6. The apparatus of claim 5, wherein the item of configuration information is set to a first value to indicate that the corresponding exception handling routine is trusted and is set to a second value to indicate that the corresponding exception handling routine is to be treated as untrusted.

7. the configuration storage is configured to identify a threshold priority; Each of the exceptions has an associated priority; the exception control circuitry is arranged to determine whether the given exception handling routine is in the first category or the second category depending on a comparison of a value derived from the associated priority of the given exception and a value derived from the threshold priority. An apparatus according to any one of claims 1 to 4.

8. 8. The apparatus of claim 7, wherein the exception control circuitry is arranged to determine that the given exception handling routine is in the second category when the associated priority of the exception is less than the threshold priority.

9. 9. The apparatus of claim 1, wherein the exception control circuitry is arranged to set a status flag to identify whether the data from the second subset of registers has been preserved.

10. the exception control circuitry is arranged to refer to the status flag upon exception return to determine whether data in the second subset of registers needs to be restored.

10. The apparatus of claim 9.

11. Apparatus according to any preceding claim, wherein the exception control circuitry is arranged to cause the data to be saved in a stack data structure when it triggers the state saving operation.

12. in response to a tail-chained exception corresponding to a further exception handling routine to be executed after the given exception handling routine is executed and before returning to the background processing, the exception control circuitry is arranged to determine, by reference to the configuration information, whether the further exception handling routine is in the first category or the second category; when the exception control circuitry determines that the further exception handling routine is in the second category and the data from the second subset of registers has not yet been saved, the exception control circuitry is arranged to trigger saving of the data from the second subset of registers before triggering the handling circuitry to execute the further exception handling routine. An apparatus according to any one of claims 1 to 11.

13. 13. The apparatus of claim 12, wherein the exception control circuitry is further arranged to trigger a clearing of the register in which that data is stored before triggering the handling circuitry to execute the further exception handling routine for the tail-chained exception.

14. 14. Apparatus according to claim 12 or 13 when dependent on claim 9, wherein the exception control circuitry is further arranged to refer to the status flag, such that when the exception control circuitry determines that the further exception handling routine for the tail-chained exception is in the second category, the exception control circuitry is arranged to skip triggering the saving of the data when the status flag indicates that the data from the second subset of registers has already been saved.

15. The apparatus of any preceding claim, wherein the background processing includes execution of program code other than an exception handling routine, and the given exception is an early exception.

16. The apparatus of any one of claims 1 to 14, wherein the background processing includes execution of a current exception handling routine, and the given exception is a preemptive exception of higher priority than the exception corresponding to the current exception handling routine.

17. the processing circuitry is arranged to execute the program code in one of a plurality of security domains including at least a secure domain and a less secure domain; the exception control circuitry is arranged to determine, by reference to the configuration information, whether the given exception handling routine is in the first category or the second category, independently of whether a change in security domain occurs when transitioning from the background processing to execution of the given exception handling routine. An apparatus according to any one of claims 1 to 16.

18. the configuration storage is arranged to store, for each security domain, configuration information used to categorize the plurality of exception handling routines associated with that security domain; the exception control circuitry is arranged to determine whether the given exception handling routine is in the first category or the second category by referring to the configuration information provided for the security domain in which the given exception handling routine is executed; 20. The apparatus of claim 17.

19. 19. Apparatus according to claim 17 or 18, wherein within a given security domain, the processing circuitry is arranged to perform data processing in one of a plurality of states including an unprivileged state and a privileged state.

20. the exception control circuitry is further arranged to, in response to identifying an exception that is an initial exception causing a transition from the secure domain to the less secure domain in a situation where the background processing was performed by the processing circuitry in the secure domain, trigger preserving the data from the second subset of registers before triggering the processing circuitry to execute an exception handling routine corresponding to the identified exception. Apparatus according to any one of claims 17 to 19.

21. 21. The apparatus of claim 20 when dependent on claim 9, wherein the exception control circuitry is further configured to reference the status flag, such that in response to the identified exception, the exception control circuitry is configured to skip triggering the saving of the data when the status flag indicates that the data from the second subset of registers has already been saved.

22. 1. A method for handling exceptions in a device, comprising: executing, by a processing circuit operable in at least one security domain, program code including a plurality of exception handling routines that are executed in response to corresponding exceptions; storing data in a plurality of registers that is accessed by the processing circuitry when executing the program code, the registers including a first subset of registers and a second subset of registers that does not overlap with the first subset; using an exception control circuit to trigger a state save operation in response to occurrence of a given exception from a background process to save data from the plurality of registers before triggering the processing circuitry to execute a given exception handling routine corresponding to the given exception; storing configuration information used to categorize exception handling routines among the plurality of exception handling routines; determining, by reference to the configuration information, whether the given exception handling routine is in a first category or a second category within the security domain in which the given exception handling routine executes; causing the exception control circuitry, when triggering the state save operation, to trigger preserving the data from the first subset of registers when the given exception handling routine is in the first category, and to trigger preserving the data from both the first subset of registers and the second subset of registers when the given exception handling routine is in the second category; The method includes:

23. processing program logic operable in at least one security domain to execute program code including a plurality of exception handling routines that are executed in response to corresponding exceptions; data structure emulating program logic for maintaining a plurality of register data structures for storing data accessed by the processing program logic when executing the program code, the register data structures including a first subset of data structures and a second subset of data structures that do not overlap with the first subset; exception control program logic for, in response to an occurrence of a given exception from a background process, triggering a state save operation to save data from the plurality of register data structures before triggering the processing program logic to execute a given exception handling routine corresponding to the given exception; A computer program for controlling a host data processing apparatus to provide an instruction execution environment, comprising: the data structure emulating program logic is further arranged to maintain a configuration data structure for storing configuration information used to categorize exception handling routines of the plurality of exception handling routines; a data structure emulating program logic arranged to, when triggering the state save operation, trigger saving of the data from the first subset of data structures when the given exception handling routine is in the first category, and trigger saving of the data from both the first subset of data structures and the second subset of data structures when the given exception handling routine is in the second category.

24. 24. A computer readable medium storing a computer program according to claim 23.

Citation Information

Patent Citations

  • Monitoring control for multi-domain processor

    JP2004171564A

  • Exception handling for data processing devices with secure and low-security domains

    JP2015506525A

  • Region identification operation for identifying the region of the memory attribute unit corresponding to the target memory address

    JP2017505492A

  • Exception handling control in a secure processing system

    US20040139346A1

  • Exception handling in a data processing apparatus having a secure domain and a less secure domain

    US20130212700A1