Enabling branch recording when a branch recording configuration value meets a predetermined condition
A branch recording system with warm and cold configuration values addresses the challenge of capturing diagnostic information during warm resets, enhancing diagnostic capabilities without increasing circuit area or power usage.
Patent Information
- Application Number
- JP2024519476
- Authority / Receiving Office
- JP · JP
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2021-10-05
- Filing Date
- 2022-08-11
- Publication Date
- 2024-10-04
- Estimated Expiration
- 2042-08-11
AI Technical Summary
Existing data processing systems face challenges in controlling branch recording during warm resets, making it difficult to capture diagnostic information effectively due to asynchronous reset signals and the unpredictability of when resets will occur.
Implementing a branch recording system with warm and cold branch recording configuration values that enable branch recording only when predetermined conditions are met, allowing for controlled branch recording before and after warm resets without significantly increasing circuit area or power usage.
Enables efficient capture of diagnostic information around warm resets, improving diagnostic capabilities while minimizing circuit cost and power consumption.
Smart Images

Figure 2024536202000001_ABST
Abstract
Description
[Technical field]
[0001] The present technique relates to the field of data processing. [Background technology]
[0002] The data processing apparatus may be configured to perform branch recording, which is a technique for capturing information about processed branch instructions and allowing subsequent software to perform processes (e.g., diagnostic, debugging, and / or profiling processes) using the captured information. Summary of the Invention
[0003] As an example of this technique, a processing circuit for processing the instructions; a reset circuit that, in response to a cold reset trigger event, performs a cold reset by resetting the processing circuitry, and that, in response to a warm reset trigger event, performs a warm reset by resetting a subset of the states that are reset in response to the cold reset trigger event; a branch record circuit for performing branch record and storing information regarding the processed branch instruction in a branch record storage circuit; The branch recording circuit is determining whether the warm branch record configuration value and the cold branch record configuration value held in the at least one register satisfy a predetermined condition; configured to enable branch recording when the warm branch recording configuration value and the cold branch recording configuration value satisfy a predetermined condition; the branch record storage circuitry is configured to make information regarding processed branch instructions available for diagnostic analysis; An apparatus is provided in which a cold reset includes resetting both warm branch record configuration values and cold branch record configuration values, and a warm reset includes resetting the warm branch record configuration values and leaving the cold branch record configuration values unchanged.
[0004] Another example of this technique is processing instructions on a processing circuit; performing a cold reset by resetting the processing circuitry in response to a cold reset trigger event; performing a warm reset in response to a warm reset trigger event by resetting a subset of the states that are reset in response to a cold reset trigger event; determining whether the warm branch record configuration value and the cold branch record configuration value maintained in at least one register satisfy a predetermined condition; and enabling a branch record when a warm branch record configuration value and a cold branch record configuration value satisfy a predetermined condition, the enabling including storing information regarding a processed branch instruction in a branch record storage circuit, the enabling comprising: The method includes making information regarding processed branch instructions available for diagnostic analysis; A method is provided in which a cold reset includes resetting both warm branch record configuration values and cold branch record configuration values, and a warm reset includes resetting the warm branch record configuration values and leaving the cold branch record configuration values unchanged. [Brief description of the drawings]
[0005] Further aspects, features, and advantages of the present technique will become apparent from the following description of examples, read in conjunction with the accompanying drawings. [Figure 1] 1 illustrates generally a data processing system in which the present techniques may be implemented; [Diagram 2] 1 illustrates a schematic representation of a warm reset domain, a non-warm reset domain, and a cold reset domain. [Diagram 3] 1 is a table illustrating an example of how warm and cold branch recording configuration values (BREW, BREC) can be configured to control the operation of branch recording circuitry. [Figure 4]FIG. 4 illustrates what happens to the warm and cold branch record configuration values (BREW, BREC) after configuration by software and after a warm reset according to the example shown in FIG. 3. [Diagram 5] 11 is a table illustrating another example of how warm and cold branch recording configuration values (BREW, BREC) can be configured to control the operation of the branch recording circuitry. [Figure 6] 4 is a flow diagram illustrating an example of a method performed by the branch recording circuitry under control of warm and cold branch recording configuration values (BREW, BREC). [Figure 7] FIG. 13 is a flow diagram illustrating an example of a reset process. [Figure 8] 1 illustrates generally various processes that may be executed in a data processing system. [Figure 9] FIG. 10 is a flow diagram illustrating an example of determining whether to allow a process at a less privileged execution level than a given execution level (EL3 in the example of FIG. 9) to access information stored in a branch record buffer. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0006] Before discussing example implementations with reference to the accompanying drawings, the following description of example embodiments and associated advantages is provided.
[0007] According to one exemplary configuration, an apparatus is provided that includes processing circuitry for processing instructions. For example, the processing circuitry may be a central processing unit (CPU), a processing pipeline within a CPU, or any other circuitry within an apparatus capable of processing instructions.
[0008] The apparatus also includes a reset circuit that, in response to a cold reset trigger event, performs a cold reset by resetting the processing circuitry, and that, in response to a warm reset trigger event, performs a warm reset by resetting a subset of the states that are reset in response to the cold reset trigger event. For example, a reset may involve setting the values of any states subject to reset to a default (reset) value (e.g., this may be 0 or 1 - in some cases there may be some items of states that are reset to 0 and other items of states that are reset to 1). A warm reset may be considered to be a partial reset that involves resetting some (e.g., a suitable subset) but not all of the states that are reset in a cold reset. In this context, "state" may be understood to refer to information stored (e.g., stored) by a component of the processing circuitry; for example, this may include data stored in a storage circuitry such as a register, cache, or memory, but may also include any information recorded by a flip-flop within a component of the processing circuitry.
[0009] The apparatus also provides a branch record circuit that performs branch recordation to store information about processed branch instructions in the branch record storage circuit, the branch record circuit being configured to determine whether the warm branch record configuration value and the cold branch record configuration value held in the at least one register satisfy a predetermined condition, and to enable branch recordation when the warm branch record configuration value and the cold branch record configuration value satisfy the predetermined condition.
[0010] For example, when branch recording is enabled, the branch recording circuitry may detect that a branch instruction (e.g., a program flow altering instruction that, when executed, causes the processing circuitry to branch to another instruction other than an instruction that consecutively follows the program flow altering instruction in program order) is being processed when it is fetched by a fetch circuit in the processing circuit, decoded by a decode circuit in the processing circuit, issued by an issue circuit in the processing circuit, or executed by an execute circuit in the processing circuit. However, it will be appreciated that these are all merely examples and that the branch recording circuitry may be configured to detect that a branch instruction is being processed at any stage / portion of the processing circuit. When a particular branch instruction is detected, when branch recording is enabled, whether or not information about the branch is stored in the branch recording circuitry may depend on factors other than the warm branch recording configuration values and the cold branch recording configuration values (e.g., whether or not the branch is taken, or whether or not a filter criterion is met as further described below). Thus, when branch recording is enabled, this means that branch recording is generally enabled to allow information about particular processed branches to be recorded, but this does not mean that all branches that are processed while branch recording is enabled must have information recorded in the branch record storage circuitry.
[0011] The warm branch recording configuration value and the cold branch recording configuration value may be, for example, a pair of values held in one or more registers and may be any value (e.g., 1, 0, or any other value), although it will be understood that the warm branch recording configuration value and the cold branch recording configuration value may include more than two values. The predetermined condition may depend on the values to which the warm branch recording configuration value and the cold branch recording configuration value are set, and in some examples, the predetermined condition includes a condition that should be satisfied by both the warm branch recording configuration value and the cold branch recording configuration value (e.g., a condition that should be satisfied together by a pair of branch recording configuration values). In at least some states of the processing circuit, satisfaction of the predetermined condition indicates that the branch recording circuit should enable branch recording. When the predetermined condition is not satisfied, branch recording is disabled.
[0012] When branch recording is enabled, information about processed branch instructions is stored in a branch record storage circuit, which may be, for example, a dedicated storage structure or a data structure in memory (e.g., a circular buffer). The branch record storage circuit is configured to make information about processed branch instructions available for diagnostic analysis. Information stored in the branch record buffer may be useful in diagnostic processes such as debugging or code profiling, and the branch record buffer may be configured to make this information available to diagnostic processes that perform such analysis. Information about branches may be made available for diagnostic analysis by allowing diagnostic software or debugging tools to read information from the branch record storage circuit, or by outputting the recorded branch information via a trace port to an external debugger or computer to perform diagnostic analysis.
[0013] In the apparatus of the present technique, a cold reset includes resetting both the warm branch record configuration value and the cold branch record configuration value, and a warm reset includes resetting the warm branch record configuration value and leaving the cold branch record configuration value unchanged. For example, the states reset in response to a cold reset trigger may include both the cold branch record configuration value and the warm branch record configuration value, and the states reset in response to a warm reset trigger (e.g., a subset of the states reset in response to a cold reset trigger) may include the warm branch record configuration value but not the cold branch record configuration value. Thus, the value of the warm branch record configuration value may be reset to its default / reset value during a warm reset, but the cold branch record configuration value maintains the value it had before the warm reset trigger was received / detected (which may be its default / reset value, but may also be a different value), and the cold branch record configuration value is not affected by the warm reset.
[0014] The inventors of the present technique have recognized that being able to inspect information about branches processed around a warm reset can be useful to the diagnostic process. For example, this can enable post-mortem diagnostics (e.g., inspecting information captured about branches executed before the reset to identify the cause of the reset), or even diagnostics against any reset firmware that may be executed by the processing circuit immediately after a warm reset. However, reset signals are typically asynchronous, which means that they can occur at any time, making it difficult to predict when a reset will occur. This can make it difficult to control whether branch recording is performed around a warm reset.
[0015] The present technique addresses these issues by providing two control values, a warm branch recording configuration value and a cold branch recording configuration value, which may be used to control whether branch recording is enabled or disabled before and after a reset (by determining whether a pair of branch recording configuration values meets a predetermined condition). In particular, by providing two control values, one that is reset in response to both a warm reset and a cold reset (the warm branch recording configuration value) and one that is reset in response to a cold reset but not in response to a warm reset (the cold branch recording configuration value), the warm branch recording configuration value and the cold branch recording configuration value may be set to control when branch recording starts and stops around a warm reset (e.g., by setting the warm branch recording configuration value and the cold branch recording configuration value taking into account a predetermined condition and the fact that the warm branch recording configuration value is reset at a warm reset). Furthermore, the present technique may be implemented without a significant increase in circuit area and power usage. Thus, the present apparatus allows for the capture of more useful diagnostic information around a warm reset without a significant increase in circuit cost in terms of increased circuit area.
[0016] In some examples, the branch recording circuitry is configured to determine whether the warm branch recording configuration value and the cold branch recording configuration value maintained in the at least one register satisfy a predetermined condition based on a comparison of the warm branch recording configuration value and the cold branch recording configuration value.
[0017] This may be a particularly advantageous way of implementing the branch recording circuitry of the present technique, since performing a simple comparison of a pair of values requires less circuit area (e.g., as compared to a more complex set of logic to decode any state of the bits in each of the branch recording configuration values) and therefore incurs less cost.
[0018] In some examples, the predetermined condition includes one of the warm branch record configuration value and the cold branch record configuration value being equal, and the warm branch record configuration value and the cold branch record configuration value being different. For example, the predetermined condition may be considered to be met when both the warm branch record configuration value and the cold branch record configuration value have the same value (e.g., both may have a value of 1, or both may have a value of 0, although it will be understood that in other examples the branch record configuration values may have values other than 0 or 1). Alternatively, the predetermined condition may be considered to be met when the warm branch record configuration value has a different value than the cold branch record configuration value (e.g., one of the values may be 1 and the other may be 0, although it will be understood (again) that in other examples the branch record configuration values may have values other than 0 or 1).
[0019] In this manner, the technique can be implemented using simple comparison circuitry and therefore requires only a small increase in circuit area.
[0020] Another advantage of evaluating a predetermined condition based on whether the warm and cold branch record configuration values are equal or unequal is that it means that there can be multiple different combinations of settings of the warm and cold branch record configuration values that each either meet or do not meet the predetermined condition. For example, an equal condition can be met when the two configuration values are either both 0 or both 1, and an unequal condition can be met when the two configuration values are either 0 and 1, or 1 and 0. Providing multiple settings corresponding to "enable" or multiple settings corresponding to "disable" can be useful because it means that a user can configure configuration values with different settings that provide different enable / disable statuses for branch records after a warm reset, even if the enable / disable status before a warm reset is the same for each of those settings (or conversely, a user can configure configuration values with different settings for the enable / disable status before a warm reset, even if the desired behavior for the enable / disable status of branch records after a warm reset is the same). In contrast, an approach that provides only a single configuration setting corresponding to enabled branch records and a single configuration setting corresponding to disabled branch records (e.g., using a single enable / disable bit) does not provide much flexibility in configuring different options before and after a warm reset.
[0021] In some examples, the at least one register is configurable by software to set the warm branch record configuration value and the cold branch record configuration value to one of a plurality of states, the warm branch record configuration value having one of a warm configuration value and a warm reset value, and both the warm reset and the cold reset including resetting the warm branch record configuration value to the warm reset value. For example, a programmer may configure the warm branch record configuration value and the cold branch record configuration value by including in the software one or more instructions for updating a value stored in the at least one register. A warm reset value is the value that the warm branch record configuration value reverts to after a warm or cold reset (e.g., if the warm reset and cold reset include resetting the warm branch record configuration value to 0, then the warm reset value is 0; similarly, if the warm reset and cold reset include resetting the warm branch record configuration value to 1, then the warm reset value is 1. However, it will be understood that other examples of warm reset values are possible. The warm configuration value can be a different value than the warm reset value. Furthermore, it will be understood that the "states" above describe what software writes to at least one register before a warm reset occurs, and that the value of the warm branch record configuration value can be changed at a warm reset (e.g., from a warm configuration value to a warm reset value), and thus the state set by software does not necessarily remain through a warm reset.
[0022] By allowing software to set warm and cold branch recording configuration values, this allows the programmer to set control over whether or not branch recording is performed before and after a warm reset, which can be particularly useful because it allows the programmer to control the diagnostic information collected by the branch recording circuitry.
[0023] In some examples, the plurality of states includes a reset entry state, and the branch recording circuit is responsive to the warm branch recording configuration value and the cold branch recording configuration value indicating the reset entry state to enable branch recording in response to the reset circuit performing a warm reset. For example, the reset entry state (e.g., mode or configuration) of the warm branch recording configuration value and the cold branch recording configuration value causes the branch recording circuit to not perform branch recording before a warm reset (e.g., a predetermined condition is not met before a warm reset) and to perform branch recording after a warm reset (e.g., the warm branch recording configuration value is reset at a warm reset such that a predetermined condition is met following a warm reset).
[0024] The reset entry state may be advantageous because it allows the branch recording circuitry to populate the reset process itself (e.g., record information about branches in the reset firmware executed after a warm reset to identify or respond to the cause of a warm reset event) without wasting power or degrading performance by performing branch recording before a warm reset that may not be necessary, and can be overwritten (at least in the case of a small circular branch recording buffer) with any more recent information collected after a warm reset (because in some implementations enabling branch recording may limit the maximum performance achievable by the processing circuitry than when branch recording is disabled, e.g., when branch recording is enabled, the branch recording circuitry may impose a limit on the number of branches that can be processed in one cycle by the processing circuitry). For example, a developer may wish to select the reset entry state when performing diagnostic analyses to analyze the performance or correct functioning of the reset firmware.
[0025] In some examples, the reset entry state is indicated by a warm branch record configuration value having a warm configuration value and a cold branch record configuration value having a first value, and the branch record circuitry is configured to determine that the predetermined condition is met when the warm branch record configuration value has a warm reset value and the cold branch record configuration value has the first value, and to determine that the predetermined condition is not met when the warm branch record configuration value has a warm configuration value and the cold branch record configuration value has the first value. In this configuration, assuming the cold branch record configuration value retains the first value after a warm reset event, transitioning from the warm configuration value to the warm reset value at a warm reset causes the predetermined condition to be met after a warm reset when the predetermined condition was not met before the warm reset, resulting in branch record being enabled at a warm reset.
[0026] for example, When the warm reset value is 0 and the warm branch record configuration value and the cold branch record configuration value are different (not equal), a reset start state can be configured by setting the cold branch record configuration value to 1 (e.g., the first value is 1) and setting the warm branch record configuration value to 1 (e.g., the warm configuration value is 1); When the warm reset value is 1 and a predetermined condition is met in which the warm branch record configuration value and the cold branch record configuration value are different (not equal), a reset start state can be configured by setting the cold branch record configuration value to 0 (e.g., the first value is 0) and setting the warm branch record configuration value to 0 (e.g., the warm configuration value is 0); the warm reset value is 1 when the warm branch record configuration value and the cold branch record configuration value are the same (equal), and when a predetermined condition is met, a reset start state can be configured by setting the cold branch record configuration value to 1 (e.g., the first value is 1) and setting the warm branch record configuration value to 0 (e.g., the warm configuration value is 0); and When a predetermined condition is met where the warm reset value is 0 and the warm branch record configuration value and the cold branch record configuration value are the same (equal), a reset start state can be configured by setting the cold branch record configuration value to 0 (e.g., the first value is 0) and setting the warm branch record configuration value to 1 (e.g., the warm configuration value is 1).
[0027] In some examples, the plurality of states includes a reset stop state, and the branch recording circuit disables branch recording in response to the warm branch recording configuration value and the cold branch recording configuration value indicating the reset stop state and in response to the reset circuit performing a warm reset. For example, the reset stop state (e.g., mode or configuration) of the warm branch recording configuration value and the cold branch recording configuration value causes the branch recording circuit to perform branch recording until a warm reset (e.g., a predetermined condition is satisfied prior to a warm reset), but not to perform branch recording after a warm reset (e.g., the warm branch recording configuration value is reset at a warm reset such that the predetermined condition is no longer satisfied following a warm reset).
[0028] The reset halt state can be advantageous because it allows information about the program flow immediately prior to the warm reset (e.g., information about any firmware configured to execute after the reset) to be reconstructed, allowing any problems in the code that executed immediately prior to the warm reset (e.g., including the problem that caused the warm reset) to be diagnosed. By invalidating branch records after a warm reset, this prevents branch records recorded before the warm reset from being overwritten by branch records associated with branches executed after the warm reset.
[0029] In some examples, the reset stop state is indicated by a warm branch record configuration value having a warm configuration value and a cold branch record configuration value having a second value, the branch record circuitry is configured to determine that the predetermined condition is met when the warm branch record configuration value has the warm configuration value and the cold branch record configuration value has the second value, and the branch record circuitry is configured to determine that the predetermined condition is not met when the warm branch record configuration value has the warm reset value and the cold branch record configuration value has the second value. For example, the second value may be any value different from the first value. In this configuration, assuming that the cold branch record configuration value retains the second value after a warm reset event, a transition from the warm configuration value to the warm reset value at a warm reset invalidates the branch record at a warm reset because the predetermined condition is no longer met (e.g., stops being met) after a warm reset when the predetermined condition was met before the warm reset.
[0030] for example, When the warm reset value is 0 and the warm branch record configuration value and the cold branch record configuration value are different (not equal), a reset stop state can be configured by setting the cold branch record configuration value to 0 (e.g., the second value is 0) and setting the warm branch record configuration value to 1 (e.g., the warm configuration value is 1); When the warm reset value is 1 and a predetermined condition is met when the warm branch record configuration value and the cold branch record configuration value are different (not equal), a reset stop state can be configured by setting the cold branch record configuration value to 1 (e.g., the second value is 1) and setting the warm branch record configuration value to 0 (e.g., the warm configuration value is 0); When a predetermined condition is met when the warm reset value is 1 and the warm branch record configuration value and the cold branch record configuration value are the same (equal), a reset stop state can be configured by setting the cold branch record configuration value to 0 (e.g., the second value is 0) and setting the warm branch record configuration value to 0 (e.g., the warm configuration value is 0); and When a predetermined condition is met when the warm reset value is 0 and the warm branch record configuration value and the cold branch record configuration value are the same (equal), a reset stop state can be configured by setting the cold branch record configuration value to 1 (e.g., the second value is 1) and setting the warm branch record configuration value to 1 (e.g., the warm configuration value is 1).
[0031] In some examples, the plurality of states includes a recording through reset state, and the branch recording circuitry is responsive to a warm branch recording configuration value and a cold branch recording configuration value indicating the recording through reset state to perform branch recording both before and after the reset circuitry performs a warm reset. For example, the recording through reset state (e.g., mode or configuration) of the warm branch recording configuration value and the cold branch recording configuration value causes the branch recording circuitry to perform branch recording until a warm reset (e.g., a predetermined condition is satisfied prior to the warm reset) and then continue branch recording after the warm reset (e.g., the warm reset does not change any of the branch recording configuration values, such that the predetermined condition continues to be satisfied following the warm reset). For example, the recording through reset state instructs the branch recording circuitry to enable branch recording on both sides (before and after) a warm reset.
[0032] The record over reset configuration can be useful to a developer if there is diagnostic information of interest that should be captured both before and after a warm reset (e.g., if a developer wants to test whether the reset firmware behaves correctly if some particular condition occurs in software that runs before a warm reset, and therefore the developer needs some information about branches in the software before the warm reset to probe whether that event occurred).
[0033] In some examples, the recording state via reset is indicated by a warm branch recording configuration value having a warm reset value and a cold branch recording configuration value having a first value, and the branch recording circuitry is configured to determine that the predetermined condition is met when the warm branch recording configuration value has the warm reset value and the cold branch recording configuration value has the first value. In this configuration, assuming that the cold branch recording configuration value retains the first value after a warm reset event and the warm branch recording configuration value retains the warm reset value after a warm reset event, the warm reset does not change whether the predetermined condition is met. Thus, the predetermined condition remains satisfied after a warm reset when it was satisfied before the warm reset, and as a result, branch recording is enabled both before and after the warm reset.
[0034] for example, When the warm reset value is 0 and the warm branch record configuration value and the cold branch record configuration value are different (not equal), a predetermined condition is met, by setting the cold branch record configuration value to 1 (e.g., a first value is 1) and setting the warm branch record configuration value to 0, thereby configuring a record state via reset; When the warm reset value is 1 and a predetermined condition is met where the warm branch record configuration value and the cold branch record configuration value are different (not equal), a record state via reset can be configured by setting the cold branch record configuration value to 0 (e.g., the first value is 0) and setting the warm branch record configuration value to 1; When a predetermined condition is met when the warm reset value is 1 and the warm branch record configuration value and the cold branch record configuration value are the same (equal), a record state through reset can be configured by setting the cold branch record configuration value to 1 (e.g., the first value is 1) and setting the warm branch record configuration value to 1; and When a predetermined condition is met where the warm reset value is 0 and the warm branch record configuration value and the cold branch record configuration value are the same (equal), a record state via reset can be configured by setting the cold branch record configuration value to 0 (e.g., the first value is 0) and setting the warm branch record configuration value to 0.
[0035] Although specific examples of how the warm branch record configuration value and the cold branch record configuration value may be configured are given above for each of the reset start, reset stop, and record via reset states, it is understood that these are merely examples in which it is assumed that the warm branch record configuration value and the cold branch record configuration value may each take on a value of either 1 or 0. In other examples, such as when the warm branch record configuration value and the cold branch record configuration value are not limited to a single bit, other predetermined conditions may be set.
[0036] In some examples, the cold branch record configuration value has one of a cold configuration value and a cold reset value, and the cold reset includes resetting the cold branch record configuration value to the cold reset value.
[0037] In some examples, the branch recording circuitry is configured to determine that the predetermined condition is not met when the warm branch recording configuration value has a warm reset value and the cold branch recording configuration value has a cold reset value. This means that a default state of the warm branch recording configuration value and the cold branch recording configuration value after a cold reset may be to disable branch recording. For example, in a system in which a reset-stop state, a reset-start state, and / or a recording state via reset are implemented as described above, the cold configuration value may be a first value and the cold reset value may be a second value so that the default state after a cold reset is to disable branch recording.
[0038] However, in other examples where the cold branch record configuration value has one of a cold configuration value and a cold reset value, if it is deemed acceptable to enable branch record after a cold reset, then in a system in which the reset-stop state, reset-start state, and / or record-through-reset state are implemented as described above, the cold configuration value may be the second value and the cold reset value may be the first value.
[0039] In this manner, the device may be configured to default to no branch recording (e.g., branch recording is disabled) after a cold reset to avoid recording branch information before software has had a chance to set the warm and cold branch recording configuration values. This may reduce the amount of power wasted (e.g., in performing branch recording when not needed) and may also be more secure in systems where branch recording around a reset is controlled by higher privileged software. In this configuration, assuming the cold branch recording configuration value retains its cold reset value after a warm reset event and the warm branch recording configuration value retains its warm reset value after a warm reset event, a warm reset does not change whether the predetermined condition is met or not. Thus, if the predetermined condition was not met before the warm reset, the predetermined condition will not be met after a warm reset and branch recording will not be performed.
[0040] In some examples, the value to which the cold branch record configuration value is set in response to a cold reset may be fixed and predetermined, and is either the first value or the second value as described above.
[0041] However, in other examples, in response to a cold reset trigger event, the reset circuit may reset the cold branch record configuration value to one of a first value and a second value specified by the reset value select signal. Thus, whether branch record is enabled or disabled after a cold reset may vary depending on the signal provided at the time of the cold reset trigger event. This allows control over whether branch record is enabled by default or disabled by default after a cold reset. For example, the reset value select signal may be connected to circuit logic outside the cold reset domain and may be connected via a pin on the integrated circuit to an external circuit that provides the reset value select signal.
[0042] In some examples, the processing circuit is responsive to a control value held in a control register having a first value to prevent a branch record storage circuit from being accessed while the processing circuit is operating at a privileged execution level less than a given execution level. For example, the processing circuit may be configured to operate at one of a plurality of execution levels (e.g., which may also be referred to as privilege levels or exception levels), with processes executing at each execution level permitted to access a different subset of information / state stored within or accessible to the processing circuit. For example, processes executing at a more privileged execution level may be permitted to access storage structures or memory regions that are not accessible to less privileged processes (e.g., processes executing at a lower execution level). These storage structures may, in some examples, include branch record storage circuitry that may be made inaccessible to processes executing at a privileged execution level less than a given privilege level, at least some time, under control of a control value stored in a control register. For example, the control register may hold states that control various functions of the processing circuit, and the control value may be a single value (e.g., a single bit) of the states stored in the control register, or may be a multi-bit field in which an encoding of at least one of the fields indicates that the branch record storage circuitry should not be accessible from less privileged execution levels. Alternatively, the control register may be a dedicated register for holding the control value. The first value of the control value may not necessarily be the same as the first value of the cold branch record configuration value in the above example, and the control value may be set (e.g., by software operating at a given execution level) to control whether the branch record storage circuitry may be accessed by less privileged processes operating at an execution level that has less privilege than the given execution level.
[0043] In this way, the security of the system can be improved by preventing processes operating (running) with lower privileges than a given execution level from accessing the branch records generated at that execution level (e.g., reset firmware can be executed at a given execution level), thus making it more difficult for untrusted code to obtain information about higher privileged code (e.g., a malicious program may be able to infer sensitive information using information stored in the branch record storage circuit, in particular since the information recorded by the branch record circuit may be sufficient to allow the program flow to be reconstructed). This means that information about branch instructions processed at a given execution level can still be recorded in response to need without compromising the security of the system, which may be useful in diagnostics.
[0044] In some examples, the branch recording circuitry is responsive to the processing circuitry operating at a given execution level to determine whether to enable branch recording based on the warm branch recording configuration value and the cold branch recording configuration value, and is responsive to the processing circuitry operating at a less privileged execution level than the given execution level to determine whether branch recording is enabled or disabled independent of the warm branch recording configuration value and the cold branch recording configuration value. For example, the warm branch recording configuration value and the cold branch recording configuration value may control branch recording only for branches processed at the given execution level (or a more privileged execution level) and may implement some other control to control branch recording when executing at a less privileged execution level than the given execution level. For example, the control mechanism utilizing the warm branch recording configuration value and the cold branch recording configuration value may be specific to a particular execution level, and less privileged execution levels may have a different control mechanism (e.g., using a single enable value that specifies whether branch recording is enabled or disabled).
[0045] By providing a separate mechanism for controlling branch recording at more privileged levels, it is not necessary to allow access to the warm and cold branch recording configuration values to less privileged execution levels. Furthermore, providing warm and cold branch recording configuration values may not be justified for less privileged execution levels since less privileged code does not execute immediately after a warm reset, and therefore it is acceptable for software to configure enable / disable values after a warm reset to control branch recording behavior (which means simpler configuration options such as a single enable / disable value may be used). The use of warm / cold branch recording configuration values is particularly useful for more privileged code that executes immediately after a warm reset, and therefore by the time the more privileged code can make configuration changes to the branch recording configuration information, it may have already executed a reasonable number of instructions (e.g., instructions in the reset firmware that executes immediately after a warm reset) for which it would be useful to be able to provide diagnostic information. By using warm / cold reset configuration values, it becomes practical to diagnose problems associated with code executing immediately after a warm reset, which may not be practical if software configuration of enable values was required after a warm reset before branch recording could begin. Furthermore, in some particular examples, the warm and cold branch recording configuration values may also be made inaccessible to processes executing at a lower privileged execution level than a given execution level, such that a lower privileged (and potentially untrusted) program cannot control whether branch recording is performed for a process at a given execution level.
[0046] In some examples, the information about processed branch instructions includes information that allows the program flow of the processed instructions to be reconstructed. For example, the information held in the branch record storage circuitry may allow the program flow to be reconstructed by a program flow analyzer having a copy of the program (e.g., by providing information indicating which branch instructions were executed, as well as the outcomes and / or targets of the executed branches), and the stored information need not, itself, be a complete record of the program flow.
[0047] In this manner, the branch recording performed by the branch recording circuitry can provide information that is useful for diagnosis (eg, to help identify any problems in the code or processor).
[0048] In some examples, the information about the processed branch instruction includes at least one of an instruction address of the instruction at which the processed branch was taken and a target address of the instruction at which the processed branch was taken. The information stored in the branch record storage circuitry for the processed branch instruction may include either one of these pieces of information, or both of these pieces of information. It will be appreciated that there may also be other information stored in the branch record circuitry, and the selection of exactly which information to record will depend on the particular implementation, for example, on the diagnostic or debug program intended to be used.
[0049] In this way, the behavior of processed branch instructions can be identified, thus making it possible, for example, to reconstruct the program flow, which is useful for diagnostics.
[0050] In some cases, the filter criteria can be set to control which types of branches have information recorded in the branch record storage circuit. For example, the types can include indirect branches, branch-with-link instructions that cause an indication of a return address to be stored in a link register, or function-return branch instructions that branch to a return address indicated in the link register. The filter criteria can specify which of these types should have information recorded in the branch record storage circuit when branch recording is enabled. Thus, even when branch recording is enabled using warm branch record configuration values and cold branch record configuration values, it is not mandatory that all branches have information recorded in the branch record storage circuit.
[0051] In some examples, the branch record storage circuit is configured to make information about processed branch instructions available to at least one of external diagnostic hardware and a diagnostic process running on the processing circuit. There are many different ways to perform diagnostics or debugging of a processor, which may include providing a diagnostic program run by the processing circuit itself, or providing external (e.g., external (separate) from the processing circuit itself, e.g., off-chip) diagnostic hardware (e.g., circuitry) to run a diagnostic program, which may include an external diagnostic hardware component of the processing hardware that includes the branch record storage circuit. For example, the external diagnostic hardware may include dedicated diagnostic (e.g., debug) hardware or an external computer running diagnostic software. In either situation, the information stored in the branch record storage circuit may be made available to the diagnostic process.
[0052] Using external hardware dedicated to diagnostics may allow a larger amount of branch information (and indeed any other information that may be captured by the processing circuitry and provided to the external hardware) to be analyzed (e.g., if the external hardware has more storage space for diagnostic information such as branch records than is available to the processing circuitry), may provide greater functionality (as it is not dependent on resources available to the processing circuitry), and may allow diagnostic processes to be performed even when a catastrophic error means that the processing circuitry is unusable. Thus, making the information stored in the branch record storage circuitry available to external diagnostic hardware may be very useful. However, diagnostic processes may also be performed on-chip (e.g., by the processing circuitry), and thus it may be advantageous to allow such processes running on the processing circuitry to access the stored branch information.
[0053] In some examples, both the warm branch record configuration value and the cold branch record configuration value are held in the same register. While it is possible for each of the warm branch record configuration value and the cold branch record configuration value to be held in a separate register (e.g., they may each be held in a dedicated register), in some implementations, both values may be held in the same register. For example, this may be a dedicated register for storing the warm branch record configuration value and the cold branch record configuration value, or a control register that also stores other control state. For example, the warm branch record configuration value and the cold branch record configuration value may be held in the same control register that stores the above-mentioned control value in implementations where this control value is provided. Although the warm branch record configuration value and the cold branch record configuration value may each have any size or take any value, in some specific examples, each of the warm branch record configuration value and the cold branch record configuration value may comprise a single bit in the same register.
[0054] This approach of recording both the warm branch record configuration value and the cold branch record configuration value in the same register may be particularly advantageous by allowing these values to be configured more quickly. In particular, a single system register update instruction may specify new values for multiple bits stored in a single system register, whereas if the warm branch record configuration value and the branch record configuration value were held in multiple different registers, this may require two separate system register update instructions, each specifying one of the registers, to be executed to update the values. This approach may also simplify access control in implementations where access to the warm branch record configuration value and the cold branch record configuration value is restricted to a particular execution level.
[0055] The reset circuit may inhibit resetting the branch record storage circuit in response to a warm reset trigger event. Thus, the branch record storage circuit may be left unchanged in response to a warm reset. The branch record storage circuit may be in a cold reset domain that is reset in response to a cold reset trigger event but is not reset in response to a warm reset trigger event. This allows any branch information recorded in the branch record storage circuit to remain accessible following a warm reset.
[0056] In some examples, the cold reset trigger event includes a power on event, which may be in response to a power button being pressed to turn on the processing circuitry after the processing circuitry has been shut down, although other examples of cold trigger events are possible.
[0057] In some examples, the warm reset trigger event includes a timeout signal generated in response to the expiration of a watchdog counter. For example, a watchdog counter (e.g., a watchdog timer) may be used to check whether the processing circuit is operating properly. The timer may be set to a given value and allowed to count down over time. When the processing circuit is operating properly, the processing circuit may periodically reset the counter (e.g., set the counter to its initial value), so that the watchdog counter will only expire if the computer is not operating properly. If the watchdog timer expires, the watchdog timer may trigger the processing circuit to generate an interrupt and take corrective or diagnostic actions, including performing a warm reset. However, it will be understood that a watchdog event (e.g., the expiration of a watchdog counter) is just one example of a warm reset trigger event and other examples are possible.
[0058] In some examples, the reset circuitry resets a different subset of the states reset in response to a cold reset trigger event in response to each of a plurality of different warm reset trigger events, for example, there may be two or more warm reset domains that include different subsets of the states reset in a cold reset, and these two or more reset domains may be provided in addition to a cold domain that encompasses all of the states reset in a cold reset.
[0059] Specific embodiments will now be described with reference to the drawings.
[0060] Figure 1 illustrates a data processing system in which the present technique may be implemented. The data processing system illustrated in Figure 1 includes a central processing unit (CPU) 102 in communication with a memory 104 and an external diagnostic circuit 106, although it will be understood that there may be other elements in the data processing system that are not illustrated.
[0061] The CPU 102 includes a processor pipeline 108 with several pipeline stages for processing instructions. In particular, the pipeline 108 includes a fetch stage (fetch circuitry) 110, which fetches (e.g., reads) instructions from a cache 112 and passes them to a decode stage 114. For example, the cache 112 may include multiple levels of caches, each holding a subset of the data and instructions stored in the memory 104. When the fetch stage 110 fetches an instruction from the cache 112, the instruction may already be stored in a highest-level cache (e.g., the cache closest to the fetch stage 110 - this may be a "level 1" cache, although it is also possible that cache levels are labeled differently and that the level 1 cache is the cache closest to the memory 104), e.g., when the instruction was previously fetched or when it was previously prefetched into the cache. Alternatively, the instruction may not be present in the highest level cache, in which case it may need to be fetched from memory or a lower level cache into the highest level cache before being returned to the fetch stage 110.
[0062] When the fetch stage receives an instruction, it passes the instruction to a decode stage (decode circuit / decoder) 114, which decodes the instruction and generates control signals that control an execution stage (execution circuit) 116 to execute the instruction. An issue stage (issue circuit) 118 then controls when the decoded instructions (e.g., the control signals generated by the decode circuit) are issued to the execution stage 116 for execution, and the execution stage 116 executes the instructions in response to the decoded instructions (e.g., in response to the control signals).
[0063] The execution stage 116 includes: An arithmetic logic unit (ALU) 120 for performing arithmetic operations in response to arithmetic instructions such as ADD, SUBTRACT, etc. a floating point unit (FPU) 122 for performing operations on floating point operands; A branch unit (Br) 124 that executes branch instructions; and Includes a number of execution units, such as a load / store unit (ld / st) 126, which performs load operations to load data from memory 104 (optionally via cache 112) into a set of registers 128 and store operations to store data from registers 128 into memory. For example, load / store unit 126 may load data into registers 128 in response to a decoded load instruction and may store data in response to a decoded store instruction.
[0064] The pipeline 108 also includes a writeback stage (writeback circuit) 130 for writing results of the data processing operations performed by the execution stage 116 to the registers 128. The pipeline 108 is an example of a processing circuit that processes instructions.
[0065] The register file 128 comprises a number of registers, each of which is a temporary storage structure for storing data of a given size. In the example of Figure 1, the register file 128 includes one or more control registers 136 that store information for controlling the operation of one or more elements of the CPU. The register file also stores two branch record configuration values 138, 140, which are examples of a warm branch record configuration value (BREW) 140 and a cold branch record configuration value (BREC) 138. Other registers (not shown) are also provided within the register file 128 to hold input and result operands for operations executed by the execution circuitry 116.
[0066] CPU 102 also includes a branch predictor 132 that makes predictions regarding branch instructions based on branch prediction information stored in one or more branch predictor caches 134. For example, branch predictor 132 may predict the outcome of a branch instruction (e.g., the branch is taken or not taken) and / or may predict the target of the branch instruction (e.g., the target address of the target instruction). Branch predictor cache 134 may be updated in response to signals received by branch unit 124 that indicate the outcome and target address of an executed branch instruction.
[0067] The CPU 102 is also provided with a branch record circuit 142 configured to read the branch record configuration values 138, 140 and enable branch record when the branch record configuration values meet a predetermined condition (e.g., have a given value). When branch record is enabled, information about executed branch instructions may be recorded in a branch record buffer 144. In particular, the branch record buffer 144 may store, for a given branch instruction whose outcome is taken, the instruction address of the processed branch instruction (e.g., a memory address indicating where the instruction is stored) and / or the target address of the processed branch instruction. Since a branch that does not appear in the branch record can be implied to have not been taken, it is not necessary for the branch to have information stored in the branch record buffer 144. Such information about processed branch instructions may be useful in diagnostic operations (e.g., operations for determining the cause of an error that has occurred, such as a debug operation). The branch record buffer 144 is therefore configured to make its contents available for inspection by the external diagnostic circuit 106, which uses the stored information to diagnose problems encountered by the CPU. Branch record buffer 144 may also (or alternatively) make its contents available to a diagnostic process being performed by execution circuit 116. Branch record buffer 144 is one example of a branch record storage circuit, as discussed above, that is configured to make information about processed branch instructions available for diagnostic analysis. In another example, the recorded branch records may be written to a memory system when branch recording is enabled, and thus cache 112 and memory 104 may function as a branch record storage circuit.
[0068] One example of a situation in which information about executed branch instructions may be useful to the external diagnostic circuit 106 or diagnostic process is around a warm reset of all or part of the CPU 102. For example, this may be a warm reset where a subset of state stored in components of the CPU (including the warm branch record configuration value (BREW) 140) is reset (e.g., this may be in response to the expiration of a watchdog timer or in response to the occurrence of some kind of error). Considering information about branch instructions executed in cycles preceding a warm reset trigger (e.g., the event that triggers the warm reset) may be useful to the diagnostic process, as it may give an indication of the events that lead to the warm reset being triggered. It may also be useful to record information about branch instructions processed immediately after the reset (e.g., branch instructions in the reset firmware) to diagnose problems with the reset code itself.
[0069] However, the branch record buffer 144 may have a limited size, for example implemented as a small circular buffer, and expanding the size of the branch record buffer 144, which may only be used for diagnostic processes and not for normal processing by the processor pipeline 108, may not be justified considering the additional cost this incurs in terms of increased circuit area. Thus, the number of branch instructions for which information can be stored in the branch record buffer 144 is limited. It may therefore be useful to control when branch recording by the branch record circuitry is enabled. For example, it may be useful to control whether branch recording should be stopped when a reset is triggered (e.g., not recording information about branch instructions processed after the reset), so that more branch instructions executed in the time preceding the reset may be recorded (by preventing information about older branch instructions from being overwritten by information about branch instructions processed after the reset signal). This also avoids wasting power by performing branch recording when it is not needed. On the other hand, it may also be useful to start branch recording at reset. For example, if the intent is to diagnose a problem in the reset procedure itself, performing branch recording before a reset occurs may be a waste of power, and thus controlling the branch recording circuitry 142 to start branch recording at reset may save power. Also, in some cases, performing branch recording may be invasive and affect the behavior of the processing circuit. For example, if the branch recording circuitry 142 can handle recording of a limited number of branches at a time, then when branch recording is enabled, the number of branches that may be executed by the branch unit 124 in a single cycle may be limited to the number that can be supported by the branch recording circuitry 142, in order to avoid missing recorded information regarding executed branches. Thus, in order to avoid unnecessarily limiting performance, it may be desirable to avoid enabling branch recording when the information being collected by the branch recording circuitry 142 is not of interest to the user.
[0070] However, in some situations, a programmer may find it beneficial to record branch information both before and after reset, or may actually determine that branch recording can be disabled (e.g., to save power).
[0071] Thus, BREC value 138 and BREW value 140 are provided to control branch recording around a warm reset. BREW value 140 is configured to be reset by both warm and cold resets, while BREC value 138 is configured to be reset only by a cold reset, and a programmer can set the value of each register to control when branch recording circuitry 142 performs branch recording.
[0072] The BREC value 138 and the BREW value 140 may each be stored in a separate register or both may be stored in the same register. For example, the BREC value and the BREW value may each be a single bit (e.g., a 1 or 0) provided in one of the control registers 136.
[0073] 2 illustrates a warm reset domain, a non-warm reset domain, and a cold reset domain. As shown in the figure, the CPU may be divided into a warm domain 202, which is reset during a warm reset (in response to a signal provided by a warm reset pin 208), and a non-warm domain 204, which is not reset during a warm reset, but is reset during a cold reset (in response to a signal provided by a non-warm reset pin 210). Since in a cold reset, all state in the warm domain 202 and all state in the non-warm domain 204 are reset, the cold domain 206 of states may be considered to be a domain that encompasses both the warm domain 202 and the non-warm domain 204.
[0074] The data processing system also includes a reset circuit 201 that drives a warm reset pin 208 and a non-warm reset pin 210. In particular, the reset circuit 210 drives the warm reset pin 208 in response to both a warm reset signal (generated in response to a warm reset trigger event) and a cold reset signal (generated in response to a cold reset trigger event) such that all of the states in the warm domain 202 are reset. Meanwhile, the reset circuit 210 drives the cold non-warm reset pin 210 in response to a cold reset signal (but not a warm reset signal) to reset the states in the non-warm domain 204. The reset circuit may also include a reset tree in each of the warm domain 202 and the non-warm domain 204 that branches from either the warm reset pin 208 or the cold reset pin 210 to provide a set of reset signal paths that propagate corresponding reset signals to each component in the corresponding reset domain (e.g., warm domain or non-warm domain) and trigger the reset of the states of those components. Reset circuit 201 is an example of a reset circuit that, in response to a cold reset trigger event, performs a cold reset by resetting the processing circuitry, and, in response to a warm reset trigger event, performs a warm reset by resetting a subset of the states that are reset in response to the cold reset trigger event.
[0075] In the example of FIG. 2, the warm reset domain 202 includes a warm reset configuration value (BREW) 140 and various other warm domain states, such as a watchdog timer 212. The watchdog timer (also referred to as a properly operating computer or COP timer) is a timer used to detect malfunctions. In particular, the CPU is configured to periodically restart the watchdog timer during normal operation to prevent the watchdog timer from elapsed (counting down to 0). If the CPU fails to restart the watchdog timer (e.g., due to an error), the timer will elapse and generate a timeout signal. The timeout signal is used to initiate corrective actions, for example, the elapse of the watchdog timer may be a warm reset trigger and thus trigger a warm reset. For example, in a warm reset, power to the integrated circuit may remain on, so that states not in the warm reset domain retain their current values.
[0076] On the other hand, the non-warm reset domain 204 of FIG. 2 includes cold reset configuration values 138, branch record buffer 144, and various other warm domain states such as debug state 214 (e.g., state associated with a debug process executed by the CPU).
[0077] In general, the non-warm reset domain 204 may include state that needs to be maintained after a warm reset, but not after a cold reset. For example, the branch record buffer 144 is in the non-warm domain 204 because it may store branch records generated before a warm reset, which may be needed for a diagnostic process to diagnose the cause of the warm reset (e.g., the cause of the expiration of the watchdog timer 212). Similarly, the debug state 214 is also in the non-warm domain 214 because debugging after a warm reset may require access to debug state that was stored before the warm reset.
[0078] The state in each of the reset domains may comprise a flip-flop that is reset to a default state (e.g., this may be a value of 0, but this is merely one example and in other examples the default state may be, for example, 1). Similarly, each of the warm and cold reset configuration values 138, 140 may be reset to a default value in response to a reset signal (again, this may be, for example, 1 or 0 depending on the particular implementation).
[0079] It will be understood that each of the warm domain 202 and the non-warm domain 204 may include other states not shown in FIG.
[0080] 2, a reset value select signal may be optionally provided to control whether the cold reset branch record configuration value 138 is reset to 1 or 0. The reset value select signal may be provided at the cold reset branch record configuration signal pin 216 from an external device outside the integrated circuit comprising the cold domain 206, or may be generated by logic on another portion of the integrated circuit outside the cold domain 206. This allows for configuration of whether branch record is enabled by default or disabled by default after a cold reset in the period between the cold reset and the time that software executed by the processing circuit configures the values of BREC 138 and BREW 140. Providing a reset value select signal is optional, and in other examples, BREC 138 may simply be reset to a fixed value of 0 or 1, so that branch record is fixed as to whether it is enabled or disabled after a cold reset.
[0081] As mentioned above, the BREC value 138 and the BREW value 140 can be set by a programmer to control branch recording by the branch recording circuitry 142 before and after a warm reset. Figure 3 shows one example of how this can be implemented.
[0082] 3, the BREC and BREW values can each be set to either 1 or 0, and are each configured to be reset to 0 in response to a reset signal. Branch recording circuit 142 is configured to enable branch recording when the BREC and BREW values are different (e.g., when BREC!=BREW) and to disable branch recording when the BREC and BREW values are equal (BREC==BREW).
[0083] The table of FIG. 3 shows values to which a programmer can set the BREC and BREW values to select various branch recording configurations. In other words, the table shows what the BREC and BREW values will be from when they are set by the programmer until a warm reset occurs, at which point the BREW value is reset to 0. As shown in the first row of the table of FIG. 3, a programmer can control the branch recording circuitry to set the BREC value to 0 and the BREW value to 1 to enable branch recording until a warm reset, and disable branch recording after a warm reset (e.g., a "warm reset stop" configuration). In particular, branch recording is enabled before the reset because the programmer has set the BREC and BREW values to different values (0 and 1). However, branch recording is disabled after a warm reset because the BREW value is reset to 0 at the warm reset such that the BREC and BREW values are equal (both 0) after the reset.
[0084] As shown in the second row of the table in Figure 3, to control the branch recording circuitry to enable branch recording on a warm reset (e.g., the "Start with Warm Reset" configuration), a programmer sets both the BREC and BREW values to 1. In this way, branch recording is disabled before a warm reset because the BREC and BREW values are equal (both are 1), but branch recording is enabled after a warm reset because the BREW value is reset to 0 and the BREC and BREW values are no longer equal (1 and 0).
[0085] Thus, for both the "stop on warm reset" and "start on warm reset" configurations, the BREW value is set to 1 (or, more generally, a non-reset value), and as a result, the states indicated by the BREC and BREW values are changed at the warm reset value (e.g., because the BREW value is changed to a reset value (e.g., 0) at a warm reset). However, it will be understood that these values are specific to the implementation in which branch recording is enabled when BREC!=BREW.
[0086] 3, to control the branch recording circuitry to record through a warm reset (e.g., to enable branch recording both before and after a warm reset, referred to as "record through warm reset"), the programmer sets the BREC value to 1 and the BREW value to 0. In this manner, branch recording is enabled both before and after a warm reset, since the BREW and BREC values are unequal (1 and 0) and neither value changes upon a warm reset.
[0087] Finally, to control the branch recording circuitry so that no branch recording is performed at all, the programmer sets both the BREC and BREW values to 0. In this way, branch recording is disabled both before and after a warm reset, since the BREC and BREW values are equal (both 0) and neither value changes on a warm reset. Since both the BREC and BREW values are reset to 0 on a cold reset, the default state after a cold reset is to disable branch recording.
[0088] Thus, for both the "record via warm reset" and "no record" configurations, the BREW value is set to 0 (or, more generally, the reset value), so that the state indicated by the BREC and BREW values does not change at the warm reset value (e.g., because the BREW value is already at the reset value (e.g., 0) prior to the warm reset). However, it will be appreciated that this is only true in implementations where branch recording is disabled when BREC==BREW.
[0089] As noted above, the table of Figure 3 shows how a programmer can control branch recording before and after a reset in an implementation where branch recording is performed when BREC!=BREW and both the BREC and BREW values are reset to 0 on a cold reset (and also on a warm reset, in the case of the BREW value). In an alternative implementation where both the BREC and BREW values are reset to 1, the 0 and 1 values in the table are simply replaced with 1 and 0, respectively.
[0090] Figure 4 shows how software can set each of the configurations shown in Figure 3, and how a warm reset affects the BREC and BREW values. In the diagram of Figure 4, the BREC and BREW values (identified in Figure 4 as "E3BREC" and "E3BREW" to indicate that these values control only branch recording for processes running at exception level 3, as described in more detail below) are initially both 0; this could be, for example, following a cold reset where both values are reset to 0, or because a programmer has turned off branch recording by setting both values to 0.
[0091] In an "enable" step, the software enables branch recording in one of the configurations described above. In particular, to select the "reset down" state, the software sets the BREW value to 1, which enables branch recording since BREC!=BREW. To select the "record through reset" configuration, the software sets the BREC value to 1, which also enables branch recording since BREC!=BREW. To select the "reset enter" state, the software sets both BREC and BREW to 1, which disables branch recording since BREC==BREW (or rather, does not enable branch recording since it is already disabled). Finally (not shown in FIG. 4 for simplicity), the software can maintain the "no recording" configuration by leaving the BREC and BREW values alone (e.g., setting them both to 0).
[0092] At a warm reset, the BREW value is reset to 0, but the BREC value remains unchanged. This means that the BREC and BREW values indicate one of two possible states after a warm reset: BREC=1 and BREW=0, and thus BREC!=BREW, and branch recording is enabled; or BREC=0 and BREW=0, and thus BREC==BREW, and branch recording is disabled. In particular, when software selects the reset-stop configuration (BREC=0 and BREW=1 before a warm reset), branch recording is disabled following a reset. When software selects recording via a reset configuration (BREC=1 and BREW=0 before a warm reset), branch recording remains enabled after a warm reset. When software selects the reset-enter configuration (BREC=1 and BREW=1 before a warm reset), branch recording is enabled at a warm reset. Finally, although not shown in the figure, it will be understood that if software selects a record-disable configuration (e.g., leaves both the BREC and BREW values at 0 before a warm reset), branch recording will remain disabled after a warm reset.
[0093] 5 illustrates yet another exemplary implementation in which the branch recording circuitry is configured to enable branch recording when the BREC and BREW values are equal (unlike FIGS. 3 and 4 in which branch recording is performed when the BREC and BREW values are not equal). In this example, because branch recording is enabled when the BREC and BREW values are equal, the BREW value is set to a non-reset value (e.g., such that the value of BREW is changed on a warm reset) to configure both a warm reset start state and a warm reset stop state, and the BREW value is set to a reset value (e.g., such that the value of BREW is not changed on a warm reset) to configure both a record state and a no record state via warm reset.
[0094] In the particular example shown in the table of Figure 5, the BREC value is reset to 0 on a cold reset, and the BREW value is reset to 1 on both a warm reset and a cold reset. Thus, a warm reset stop state is configured by setting BREC==BREW==1, starting in a warm reset state is configured by setting BREC==1 and BREW==0, recording through a warm reset state is configured by setting BREC==BREW==1, and a no recording state is configured by leaving both BREC and BREW at their reset values (0 and 1, respectively).
[0095] Note that in an alternative implementation where the BREC values are reset to 1 and the BREW values are reset to 0, the 0 and 1 values in the table are simply replaced with 1 and 0 respectively.
[0096] In each of the examples shown in Figures 3-5, four different configurations are possible (stop at warm reset, start at warm reset, record through warm reset, and do not record), and branch recording both before and after a warm reset can be controlled using only two values (BREC and BREW) even when the branch recording circuitry is configured to operate differently before and after a warm reset (e.g., start or stop branch recording at warm reset). This is possible because (1) a pair of values provides four different states (e.g., 00, 01, 10, 11), (2) the BREW value is reset at both a warm reset and a cold reset, and the BREC value is reset only at a cold reset (two of the four states can control the branch recording circuitry to operate differently on either side of a warm reset), and (3) the BREC and BREW values can be used to determine whether or not to perform branch recording by comparing the values (e.g., to see if the values are equal or unequal). Thus, branch recording both before and after a warm reset can be implemented in a configurable manner without requiring any software configuration after a warm reset, allowing the programmer to tailor the process to the particular needs of the system (e.g., in response to the requirements of diagnostic software running on the CPU or in an external diagnostic circuit, and in response to the relative importance of power savings versus performance improvement). Furthermore, because only two values (BREC and BREW) are required to represent all four states, and it is possible to determine whether or not to perform branch recording at any given time by comparing the BREC and BREW values (e.g., to determine whether they are equal), it is possible to provide these advantages without a significant increase in cost. In particular, the present technique utilizes two configuration values to be programmed to control branch recording, and the circuitry required to determine whether or not to perform branch recording at any given time can be implemented using a simple comparison circuit to compare the two values.
[0097] Figure 6 is a flow diagram illustrating the method of operation of the branch recording circuit under control of the BREC and BREW values. In the method illustrated in Figure 6, it is determined whether a branch instruction is processed (S610). The branch recording circuit waits until the branch instruction is processed (e.g., by the processor pipeline of Figure 1) (the "N" branch).
[0098] When the branch recording circuit determines that the processing circuit is processing a branch instruction ("Y" arrow, e.g., the branch recording circuit may detect when the branch instruction is fetched by the fetch circuit, decoded by the decode circuit, or issued by the issue circuit, or executed by the execution circuit), it then determines whether the BREC and BREW values satisfy a predetermined condition (S620). For example, as in the examples of Figures 3 to 5, the predetermined condition can be based on whether the BREC and BREW values are equal (e.g., in Figures 3 and 4, the predetermined condition is BREC!=BREW, and in Figure 5, the predetermined condition is BREC==BREW). Alternatively, any other predetermined condition can be specified for the BREC and BREW values to indicate that branch recording should be performed.
[0099] If the BREC and BREW values do not satisfy the predetermined condition ("N" arrow), the method returns to step S610 and the branch recording circuitry waits until another branch instruction is processed.
[0100] On the other hand, if the predetermined condition is met ("Y" arrow), the branch recording circuit determines in step S622 whether the processed branch was taken. If the branch was not taken, the method returns again to step S610 to await processing of another branch.
[0101] If, in step S622, it is determined that the branch is taken, then, in step S624, the branch recording circuitry determines whether any filter criteria (for determining whether a particular branch should have information recorded in the branch record buffer) are satisfied. For example, the filter criteria may specify one or more types of branches for which branch records should be stored (or one or more types of branches for which branch records should not be stored). The filter criteria may also specify one or more address ranges, within which branches with instruction addresses (or target addresses) should or should not be stored in the branch record buffer. It is not required that filter criteria be specified, and if no filter criteria are currently specified, the result in step S622 may always be Y (yes).
[0102] Thus, if any filter criteria are met in step S622, then in step S630 the branch recording circuit records information about the processed branch instruction in the branch recording buffer. Step S630 is omitted if the imposed filter criteria are not met for the current branch. Regardless of whether any information is stored in the branch recording buffer, the method returns to step S610 and the branch recording circuit waits until another branch instruction is processed.
[0103] Although FIG. 6 shows a series of steps in a certain order, it will be appreciated that the various checks in steps S620, S622, S624 may be performed in a different order or may be performed at least partially in parallel.
[0104] Figure 7 is a flow diagram illustrating a method for performing a warm or cold reset in response to a corresponding reset trigger. In the method of Figure 7, it is determined (S710) whether a cold reset trigger (e.g., a power on operation) is detected. If a cold reset trigger is detected ("Y (Yes)" arrow), a cold reset S730 is performed. In particular, the cold reset S730 includes a step S740 of resetting the "non-warm" domain (including the BREC value) and a step S760 of resetting the warm domain. The method then returns to step S710.
[0105] On the other hand, if it is determined in step S710 that a cold reset trigger has occurred, it is determined whether a warm reset trigger has occurred (step S720). If a warm reset trigger has not occurred ("N" arrow), the method returns to step S710. On the other hand, if it is determined that a warm reset trigger has occurred ("Y" arrow), the warm domain (including the BREW value) is reset (S750) before the method returns to step S710.
[0106] Referring now to FIG. 8, this diagram illustrates generally one example of a process that may be executed by a data processing apparatus. A hypervisor 802 may manage several virtual machines (also known as VMs, guest operating systems, or guest OSs) 804. Each VM 804 may manage one or more applications 806. For example, the hypervisor 802 may control which regions of address space are assigned to each virtual machine 804 and control switching between the virtual machines 804 (e.g., scheduling interrupts to time-share processing resources between the respective virtual machines 804). Similarly, each VM 804 may control which regions of address space are assigned to each application 806 executing under that VM 804 and control switching between applications as needed.
[0107] As shown in Figure 8, each process is associated with a given privilege level EL0, EL1, EL2, EL3. In this example, the higher numbered privilege levels are more privileged than the lower numbered privilege levels, but in other examples they may be numbered in other ways (e.g., EL0 may instead indicate the most privileged exception level). In this example, application 806 runs at privilege level EL0, VM 804 runs at privilege level EL1, and hypervisor 802 runs at privilege level EL2. Typically, processes running at higher privilege levels have rights that are not available to processes running at lower privilege levels.
[0108] As shown in FIG. 8, hypervisor 802, VM 804, and device 806 may run in the normal domain. Additionally, the device may support a secure domain that is separated from the normal domain such that processes running in the normal domain cannot access data or instructions associated with the secure domain. Thus, there may also be processes running in the secure domain, such as a secure operating system (OS) 810 and a trusted application 812 running in the secure domain under the control of the secure OS 810. The secure OS 810 and the trusted application 812 run at privilege levels S-EL1 and S-EL0, respectively. To manage the transition between the normal domain and the secure domain, a secure monitor process 814 is also provided at privilege level EL3. The secure monitor process 814 may, for example, manage which regions of the address space are associated with the secure domain or the non-secure domain, and some protection hardware is provided to prevent non-secure processes in the normal domain from accessing data or instructions in the secure domain. The secure monitor 814 may also control the execution of reset code following a warm or cold reset. One example of a technique for splitting normal and secure domains is the Trustzone® technique offered by ARM® Limited of Cambridge, UK, although other examples can be used. Providing a secure domain as shown in Figure 8 is optional, and other embodiments may not support, for example, secure monitor 814, secure OS 810, and trusted applications 812. The normal and secure domains are independent of reset domains, such as warm reset domain and non-warm reset domain.
[0109] Data associated with a higher privilege level (e.g., data modified by a process executing at a higher privilege level) may be inaccessible to processes executing at a lower privilege level, such that, for example, less trusted programs cannot access sensitive code and data. For example, it may be desirable to prevent lower privilege code from accessing branch records generated by the branch record circuitry while the processing circuitry was executing at a higher privilege level. This may be particularly true in the case of branch records generated before and after a warm reset, since reset firmware (e.g., code executed immediately after reset) typically executes at a higher privilege level. Thus, it may be useful to provide some mechanism to control whether processes executing at a lower privilege level than a given privilege level can access the branch record buffer.
[0110] For example, the BREC and BREW values may be accessible only to processes executing at EL3, and branch recording is controlled by some other mechanism (e.g., independent of the BREC and BREW values) at a lower privilege level. This improves security by preventing lower privilege processes from controlling whether information about branches executed at EL3 is stored in the branch record buffer.
[0111] Additionally, processes executing at EL0, EL1, or EL2 may be prevented from accessing the branch record buffer. For example, a control value may be provided (e.g., in one of the control registers 136 shown in FIG. 1 ) and the processing circuitry may be configured to prevent processes executing at EL0, EL1, or EL2 from accessing the branch record buffer when the control value is set to a given value. This also leads to improved security while also providing flexibility to allow less privileged processes to access the branch records in situations where it is useful and safe to do so. On the other hand, in some implementations, no control value is provided and processes executing at EL0, EL1, or EL2 may be completely prevented from accessing the branch records.
[0112] 9 is a flow diagram illustrating an example of a method for determining whether a currently executing process should be permitted to access the branch record. In this method, it is determined whether the currently executing process is executing in EL3 (S902). If the current exception level is EL3, the processing circuit is permitted to access the branch record (S904). Furthermore, when the processing circuit is executing in EL3, it is determined whether to enable the branch record by determining whether the BREC value and the BREW value satisfy a predetermined condition (as described above, for example, the predetermined condition may be BREC!=BREW or BREC==BREW) (S906). If the predetermined condition is satisfied, the branch record circuit enables the branch record (S908).
[0113] On the other hand, if the current exception level is not EL3 (e.g., if the current exception level is a lower exception level such as EL0, EL1, or EL2), the branch record circuitry is configured to determine (S910) whether to enable branch record independently of the BREC and BREW values (e.g., based on some other condition). Further, when not executing at EL3, it is determined (S912) whether a given control value in the control register has a first value, and if so, the processing circuitry is prevented from accessing the branch record (S914). On the other hand, if the control value has a different (e.g., second) value, the processing is not prevented from accessing the branch record buffer (e.g., the processing circuitry is allowed to access the branch record buffer). The control value is accessible to code operating at EL3 and inaccessible to code operating at a lower privilege exception level, such that updates of the given control value are restricted to instructions executing at EL3.
[0114] In this application, the term "configured to..." is used to mean that an element of an apparatus has a configuration capable of performing a defined operation. In this context, "configuration" refers to a method of arrangement or 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 imply that an apparatus element needs to be modified in any way to provide the defined operation.
[0115] Although exemplary embodiments of the present invention are described in detail herein with reference to the accompanying drawings, it will be understood that the invention is not limited to these precise embodiments, and that various changes and modifications can be made to the embodiments by those skilled in the art without departing from the scope of the present invention as defined by the appended claims.
Claims
1. An apparatus comprising: a processing circuit for processing the instructions; a reset circuit that, in response to a cold reset trigger event, performs a cold reset by resetting the processing circuitry, and that, in response to a warm reset trigger event, performs a warm reset by resetting a subset of states that are reset in response to the cold reset trigger event; a branch record circuit for performing branch record and storing information regarding the processed branch instruction in a branch record storage circuit; The branch recording circuit includes: determining whether the warm branch record configuration value and the cold branch record configuration value held in the at least one register satisfy a predetermined condition; configured to enable the branch record when the warm branch record configuration value and the cold branch record configuration value satisfy the predetermined condition; the branch record storage circuitry is configured to make the information regarding the processed branch instructions available for diagnostic analysis; the cold reset includes resetting both the warm branch record configuration value and the cold branch record configuration value, and the warm reset includes resetting the warm branch record configuration value and leaving the cold branch record configuration value unchanged.
2. 2. The apparatus of claim 1, wherein the branch recording circuitry is configured to determine whether the warm branch recording configuration value and the cold branch recording configuration value held in the at least one register satisfy the predetermined condition based on a comparison of the warm branch recording configuration value and the cold branch recording configuration value.
3. The predetermined condition is: the warm branch record configuration value and the cold branch record configuration value are equal; The apparatus of claim 1 or 2, further comprising one of: the warm branch record configuration value and the cold branch record configuration value being different.
4. the at least one register is configurable by software to set the warm branch record configuration value and the cold branch record configuration value to one of a plurality of states; 4. The apparatus of claim 1, wherein the warm branch record configuration value has one of a warm configuration value and a warm reset value, and wherein the warm reset and the cold reset both include resetting the warm branch record configuration value to the warm reset value.
5. 5. The apparatus of claim 4, wherein the plurality of states includes a reset entry state, and the branch recording circuitry is responsive to the warm branch recording configuration value and the cold branch recording configuration value indicating the reset entry state to enable the branch recording in response to the reset circuitry performing the warm reset.
6. the reset start state is indicated by the warm branch record configuration value having the warm configuration value and the cold branch record configuration value having a first value; the branch recording circuitry is configured to determine that the predetermined condition is satisfied when the warm branch recording configuration value has the warm reset value and the cold branch recording configuration value has the first value; 6. The apparatus of claim 5, wherein the branch recording circuitry is configured to determine that the predetermined condition is not met when the warm branch recording configuration value has the warm configuration value and the cold branch recording configuration value has the first value.
7. 7. The apparatus of claim 4, wherein the plurality of states includes a reset-stop state, and the branch recording circuitry invalidates the branch recording in response to the warm branch recording configuration value and the cold branch recording configuration value indicating the reset-stop state, and in response to the reset circuit performing the warm reset.
8. the reset stop state is indicated by the warm branch record configuration value having the warm configuration value and the cold branch record configuration value having a second value; the branch recording circuitry is configured to determine that the predetermined condition is satisfied when the warm branch recording configuration value has the warm configuration value and the cold branch recording configuration value has the second value; 8. The apparatus of claim 7, wherein the branch recording circuitry is configured to determine that the predetermined condition is not met when the warm branch recording configuration value has the warm reset value and the cold branch recording configuration value has the second value.
9. 9. The apparatus of claim 4, wherein the plurality of states includes a recording state via reset, and the branch recording circuitry is responsive to the warm branch recording configuration value and the cold branch recording configuration value indicative of the recording state via reset to enable the branch recording both before and after the reset circuitry performs the warm reset.
10. a recording state via the reset is indicated by the warm branch recording configuration value having the warm reset value and the cold branch recording configuration value having a first value; 10. The apparatus of claim 9, wherein the branch recording circuitry is configured to determine that the predetermined condition is met when the warm branch recording configuration value has the warm reset value and the cold branch recording configuration value has the first value.
11. the cold branch record configuration value having one of a cold configuration value and a cold reset value, the cold reset including resetting the cold branch record configuration value to the cold reset value; 11. The apparatus of claim 4, wherein the branch recording circuitry is configured to determine that the predetermined condition is not satisfied when the warm branch recording configuration value has the warm reset value and the cold branch recording configuration value has the cold reset value.
12. 11. The apparatus of claim 4, wherein in response to the cold reset trigger event, the reset circuit is configured to reset the cold branch record configuration value to one of a first value and a second value specified by a reset value selection signal.
13. 13. Apparatus according to any preceding claim, wherein the processing circuitry is responsive to a control value held in a control register having a first value to prevent the branch record storage circuitry from being accessed while the processing circuitry is operating at a privileged execution level less than a given execution level.
14. 14. The apparatus of claim 1, wherein the branch recording circuitry is responsive to the processing circuitry operating at a given execution level to determine whether to enable the branch recording based on the warm branch recording configuration value and the cold branch recording configuration value, and is responsive to the processing circuitry operating at a less privileged execution level than the given execution level to determine whether the branch recording is enabled or disabled independent of the warm branch recording configuration value and the cold branch recording configuration value.
15. Apparatus according to any preceding claim, wherein the information about processed branch instructions comprises information that enables a program flow of processed instructions to be reconstructed.
16. The information regarding the processed branch instruction includes: the instruction address of the taken instruction for the processed branch; The apparatus of any preceding claim, wherein the processed branch includes at least one of: a target address of a taken instruction;
17. The branch record storage circuitry further comprises: External diagnostic hardware; and a diagnostic process executed on the processing circuit.
18. Apparatus as claimed in any preceding claim, wherein both the warm branch record configuration value and the cold branch record configuration value are held in the same register.
19. 19. Apparatus according to any preceding claim, wherein the reset circuitry is responsive to the warm reset trigger event to inhibit resetting of the branch record storage circuitry.
20. The apparatus of any preceding claim, wherein the cold reset trigger event comprises a power on event.
21. Apparatus according to any preceding claim, wherein the warm reset trigger event comprises a timeout signal generated in response to the expiration of a watchdog counter.
22. 22. Apparatus according to any preceding claim, wherein the reset circuitry is responsive to each of a plurality of different warm reset triggering events to reset a different subset of the states reset in response to the cold reset triggering event.
23. 1. A method comprising: processing instructions on a processing circuit; performing a cold reset by resetting the processing circuitry in response to a cold reset trigger event; in response to a warm reset trigger event, performing a warm reset by resetting a subset of states that are reset in response to the cold reset trigger event; determining whether the warm branch record configuration value and the cold branch record configuration value maintained in at least one register satisfy a predetermined condition; and enabling a branch record when the warm branch record configuration value and the cold branch record configuration value satisfy the predetermined condition, the enabling of the branch record including storing information regarding processed branch instructions in a branch record storage circuit, The method includes making the information about the processed branch instructions available for diagnostic analysis; The method, wherein the cold reset includes resetting both the warm branch record configuration value and the cold branch record configuration value, and the warm reset includes resetting the warm branch record configuration value and leaving the cold branch record configuration value unchanged.
Citation Information
Patent Citations
Method for detecting runaway of program
JP1986033548A
Testing system for self-testing circuit board
JP2000221238A
Portable electronic equipment and method of outputting initial response
JP2003099740A
