Apparatus and method for managing capabilities
By using marking indicator fields and tracking structures in the processing circuit and capability tracking circuit, distinguishing and tracking memory capabilities, the problem of capability use after de-allocation of memory blocks is solved, and the security and stability of the system are improved.
Patent Information
- Application Number
- CN202380034638.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-04-21
- Filing Date
- 2023-03-15
- Publication Date
- 2024-11-26
AI Technical Summary
In the prior art, the ability to still be used after de-allocation of memory blocks may lead to "release use" problems that may cause undefined software behavior or information security leakage and remote code execution.
Using processing circuits and capability tracking circuits, distinguish static and dynamic capabilities through marking indicator fields, and maintain the tracking structure in the memory area, tracking the ability to specify marking values to ensure subsequent revocation.
It effectively alleviates the problem of post-release use, improves the security and stability of memory management, and prevents potential information leakage and remote code execution risks.
Smart Images

Figure CN119032348A_ABST
Abstract
Description
Background Art
[0001] The present technology relates to the field of data processing, and more particularly to technology for managing capacity.
[0002] There is growing interest in capability-based architectures, where specific capabilities are defined for a given process, and errors can be triggered if an attempt is made to perform an operation outside of the defined capabilities. Capabilities can take many forms, but one type of capability is a bounded pointer (which may also be referred to as a "fat pointer").
[0003] Each capability may include constraint information for limiting operations that may be performed when using this capability. For example, considering bounded pointers, this may provide information for identifying an inextensible range of memory addresses that can be accessed by the processing circuitry when using this capability, and one or more permission tags identifying associated permissions.
[0004] When allocating a memory block, for example, so that this memory block can be used by a processing circuit when performing a data processing operation, one or more capabilities can be provided for use when accessing the allocated memory block. The problem that may arise is that when the memory block is deallocated later, this memory space is released for reallocation, and one or more capabilities mentioned above may still be available for the processing circuit. The potential use of such capabilities after the associated memory block has been deallocated is referred to as the "use-after-free" problem. Specifically, the use of capabilities after the associated memory block has been deallocated may cause undefined software behavior in the case of this use occurring due to programming errors. In addition, when such use of capabilities occurs as an action intentionally caused by a security attacker, this may potentially lead to information security leakage and / or remote code execution.
[0005] It would therefore be desirable to provide a technique that alleviates the post-release use problem. Summary of the invention
[0006] In one example arrangement, a device is provided that includes: a processing circuit that performs an operation during which an access request to a memory is generated, wherein the processing circuit is arranged to generate a memory address for the access request using capabilities, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to the memory using the memory address derived from the pointer value, and wherein a tag indication field is stored in association with each capability to provide a tag value for distinguishing between a static capability for accessing statically allocated memory and a dynamic capability for accessing dynamically allocated memory; and a capability tracking circuit that maintains a tracking structure that provides a tracking field for each of a plurality of memory regions, wherein the capability tracking circuit is arranged to set the tracking field for a given memory region of the plurality of memory regions when at least one capability whose associated tag indication field has a specified tag value is written to the given memory region, wherein the specified tag value indicates that writes of the associated capability to the memory are to be tracked by the capability tracking circuit to facilitate subsequent revocation of the associated capability.
[0007] In another example arrangement, a method of operating a device to track capabilities for revocation is provided, the method comprising: employing a processing circuit to perform an operation during which an access request to a memory is generated, wherein the processing circuit uses capabilities to generate a memory address for the access request, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to the memory using the memory address derived from the pointer value; storing a tag indication field in association with each capability to provide a tag value for distinguishing between static capabilities for accessing statically allocated memory and dynamic capabilities for accessing dynamically allocated memory; using a capability tracking circuit to maintain a tracking structure that provides a tracking field for each of a plurality of memory regions; and setting the tracking field for a given memory region of the plurality of memory regions when at least one capability whose associated tag indication field has a specified tag value is written to the given memory region, wherein the specified tag value indicates that writes of the associated capability to the memory are to be tracked by the capability tracking circuit to facilitate subsequent revocation of the associated capability.
[0008] In yet another example arrangement, a computer program for controlling a host data processing device to provide an instruction execution environment is provided, the computer program comprising: a handler logic to perform an operation during which an access request to a memory is generated, wherein the handler logic is arranged to generate a memory address for the access request using a capability, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to the memory using a memory address derived from the pointer value, and wherein a tag indication field is stored in association with each capability to provide a tag value for distinguishing between a static capability for accessing statically allocated memory and a dynamic capability for accessing dynamically allocated memory; and a capability tracker logic to maintain a tracking structure providing a tracking field for each of a plurality of memory regions, wherein the capability tracker logic is arranged to set the tracking field for a given memory region of the plurality of memory regions when at least one capability whose associated tag indication field has a specified tag value is written to the given memory region, wherein the specified tag value indicates that writes of the associated capability to the memory are to be tracked by the capability tracker logic to facilitate subsequent revocation of the associated capability. The computer program may be provided in non-transitory or transitory form. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] The present technology will be further described, by way of example only, with reference to examples of the present technology as shown in the accompanying drawings, in which:
[0010] Figure 1 is a block diagram of an apparatus according to an example implementation;
[0011] Figure 2 is a block diagram of an apparatus according to an example implementation;
[0012] Figure 3A and Figure 3B Different ways in which effective capability indications (which in one example take the form of tag bits) and flag indications may be stored in association with capabilities according to some example implementations are shown;
[0013] Figure 4 is a flow chart showing a capability allocation process according to an example implementation;
[0014] Figure 5A is a flowchart illustrating steps taken when determining capabilities are written to memory according to one example implementation, and Figure 5B According to an example implementation, when executing Figure 5A An example arrangement of a tracking structure that may be used when performing the process;
[0015] Figure 6is a flow chart illustrating steps performed when a revocation trigger is detected according to one example implementation;
[0016] Figure 7 is shown in one example implementation that can be used to implement Figure 6 A flowchart of a sequence of steps of step 310, wherein according to Figure 3B An example arrangement of, the valid capability indication and the tag indication are stored in separate memory areas;
[0017] Figure 8 is a flow chart illustrating how an attempt to change a flag value in a flag indication field of a capability is handled according to one example implementation;
[0018] Fig. 9 is a flow chart illustrating how capabilities may be generated from existing capabilities according to one example implementation;
[0019] FIG. 10A to FIG. 10C Various different formats of a tag indication field according to some example implementations are shown;
[0020] Fig.11A shows how different tag values can be associated with different memory allocation generations in one example implementation, while Fig. 11B Steps that may be performed when revoking a capability for a particular memory allocation generation are shown according to one example implementation;
[0021] Fig. 12A and Fig. 12B Other example scenarios in which different tag values may be used in association with capabilities to be tracked are shown;
[0022] Fig.13 is a diagram schematically illustrating the use of multiple capability trackers in one example implementation;
[0023] Fig.14 is a flow chart illustrating steps that may be performed when a capability determination instruction is detected to be executed according to one example implementation;
[0024] Fig.15 is a flow chart illustrating steps that may be taken upon detecting that access to a capability is being sought, according to one example implementation; and
[0025] Fig.16 Examples of simulator implementations that can be used are provided. DETAILED DESCRIPTION
[0026] According to the technology described herein, a device is provided, the device having a processing circuit for performing an operation during which an access request to a memory is generated. The processing circuit is arranged to generate a memory address for the access request using capabilities, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to the memory using a memory address derived from the pointer value. In some specific implementations, in addition to the constraint information, the capability may also include additional metadata. The memory address generated by the processing circuit may be a virtual address in a system in which address translation is performed, or alternatively may be a physical address in a system that does not support address translation.
[0027] There are a number of ways in which the constraint information (and indeed any additional metadata provided in addition to the constraint information) may be identified by an associated capability. For example, in one example implementation, the capability may directly contain the constraint information. However, in alternative implementations, the capability may instead indicate (directly or indirectly) the location in memory where the constraint information is located.
[0028] Software executing on a data processing apparatus may use pointers to control access to memory. However, pointers may sometimes provide a path by which a malicious attacker may attack victim software, for example, by exploiting a buffer overflow to use a pointer to identify a location in a buffer, thereby accessing an area of memory outside the buffer that the attacker would not otherwise be permitted to access. As previously mentioned, some processor architectures may support the use of a capability that associates a pointer with constraint information that specifies one or more usage restrictions that limit the scenarios in which the pointer may be effectively used. This may help protect against certain forms of attack.
[0029] Although the use of capabilities can provide strong spatial memory protection related to memory access, capabilities do not naturally provide temporal protection. This means that once a capability has been issued, it cannot usually be de-issued, and therefore the capability retains the right to access memory. For example, if software issues a capability as part of a dynamic memory allocation process (e.g., "malloc()"), then regardless of any future deallocation process (e.g., "free()"), the capability will retain the right to access memory. This is usually undesirable, and as mentioned above, such "use after release" effects may potentially be abused by attackers to cause software to behave in a problematic manner, potentially leading to system vulnerabilities. The technical purpose described herein is to alleviate such problems.
[0030] According to the techniques described herein, a tag indication field is stored in association with each capability to provide a tag value for distinguishing between a static capability for accessing statically allocated memory and a dynamic capability for accessing dynamically allocated memory. Capabilities for use by processing circuits may be established in various ways. For example, in one example implementation, a set of root capabilities may be provided in memory, and other capabilities may then be derived from those root capabilities (generally only when such capabilities are derived will it be possible to arrange such derived capabilities to have constraint information that is more restrictive and at least not less restrictive than the capabilities from which the derived capabilities are derived). Capabilities that can be used to access statically allocated memory areas (which may take a variety of forms, such as flash memory, statically allocated stack objects, SRAM data structures, or peripheral devices) (such capabilities are referred to herein as static capabilities) may be arranged according to the techniques used herein to have a tag value indicating this fact, while capabilities that can be used to access dynamically allocated memory areas (e.g., memory areas that can be allocated using a memory allocation process such as malloc) (such capabilities are referred to herein as dynamic capabilities) may be arranged according to the techniques used herein to have a tag value different from the tag value used in association with static capabilities.
[0031] It should be noted that while in one example implementation, the tag indication field may be a single bit field used to distinguish between static capabilities and dynamic capabilities, in alternative implementations, the tag indication field may be a multi-bit field, for example to enable distinction between various different forms of dynamic capabilities.
[0032] In addition to the above-mentioned flag indication fields stored in association with each capability, the apparatus described herein also provides capability tracking circuitry that can be used to maintain a tracking structure that provides tracking fields for each of a plurality of memory regions. The size of the memory regions for which the tracking structure provides tracking fields can vary depending on the specific implementation, thus allowing the capability tracking circuitry to track at a coarse-grained level or a fine-grained level, or indeed to track for a mixture of memory regions of different sizes.
[0033] The capability tracking circuitry is arranged to set a tracking field for a given memory region of the plurality of memory regions when at least one capability whose associated tag indication field has a specified tag value is written to the given memory region, wherein the specified tag value indicates that the writing of the associated capability to the memory is to be tracked by the capability tracking circuitry to facilitate subsequent revocation of the associated capability. The specified tag value may, for example, indicate that the associated capability is a dynamic capability, and in a specific implementation where the tag value may be a multi-bit value to distinguish between different forms of dynamic capabilities, the capability tracking circuitry may, for example, be arranged to track only specific forms of dynamic capabilities if desired.
[0034] The tracking field may take a variety of forms, and thus in one example implementation may be a single bit field that is set when a capability having a specified tag value is written to a memory area associated with this tracking field. However, in alternative implementations, the tracking field may be a multi-bit field to allow more detailed information to be captured. For example, the tracking field may take the form of a saturation counter that can be used to track the number of instances of a capability having a specified tag value that has been written to an associated memory area, where, for example, the capability tracking circuit increments the saturation counter for a given memory area whenever a capability having a specified tag value whose associated tag indication field is written to this given memory area. In such implementations, it will be understood that the "set" state of the tracking field will not only indicate that a capability having a specified tag value has been written to the associated memory area, but will also give an indication of the number of capabilities having a specified tag value that have been written to this memory area. In some implementations, the tracking structure may be arranged to monitor multiple different tag values, and implement a different saturation counter for each tag value being monitored.
[0035] By using a tracking structure as discussed above, it is possible to keep track of one or more memory areas to which capabilities having specified tag values are written. Furthermore, it is not necessary to track the writing of all capabilities to memory, as only capabilities having specific associated tag values need to be tracked, and other capabilities may be written to memory without being tracked. By tracking the writing of capabilities of interest to memory in this manner, this can significantly increase the efficiency with which such capabilities can be revoked later when necessary.
[0036] For example, in one example implementation, the processing circuitry may be arranged to implement a revocation process in response to a revocation trigger with respect to each memory region whose tracking field in the tracking structure is set, to identify each stored capability within the memory region whose associated tag indication field has a specified tag value, and for each identified stored capability, if the revocation condition is satisfied for the identified stored capability, then revoke the identified stored capability. For any memory region monitored by the tracking structure whose associated tracking field is not set, thereby indicating that no relevant capability is stored in the memory region, then the memory region may be skipped during the revocation process, thereby providing improved performance when searching for revocation candidate capabilities.
[0037] The revocation trigger may take a variety of forms, but in one example implementation may be an indication that one or more previously allocated memory blocks have now been deallocated, at which point it would be desirable to seek to identify any dynamic capabilities that would allow access to such deallocated memory blocks.
[0038] For each memory region whose tracking field in the tracking structure is set, indicating that at least one capability with a specified tag value has been written to this memory region, each such capability can be identified, and if the revocation condition is met for this identified capability, this identified capability can be revoked.
[0039] The manner of determining whether the revocation condition is satisfied may vary depending on the specific implementation. However, in one example specific implementation, for each capability, the constraint information includes range constraint information indicating at least an allowed range of memory addresses that can be accessed using the pointer value, and for a given identified stored capability, when the allowed range of memory addresses includes one or more memory addresses within a memory block that has been deallocated, the revocation condition is determined to be satisfied.
[0040] There are several strategies that can be adopted to evaluate whether the revocation condition is met. For example, when only a portion of the memory address range that can be accessed using a given capability is within the memory block identified for revocation, it is possible to choose to revoke this capability. However, on the contrary, an alternative strategy can be to revoke only the capabilities whose memory address allowed range is completely included in the memory block identified for revocation. In fact, in some specific implementations, it is possible to choose to perform only a "fast" check on this, and therefore only check whether the base boundary, current address or upper boundary (or any combination thereof) is included in the memory block being deallocated.
[0041] There are various different ways in which a tag indication field can be stored in association with each capability. For example, in one specific implementation, the tag indication field can be regarded as part of the capability and stored in a memory together with the capability. However, in an alternative specific implementation, the tag indication field can be stored in a separate memory area that can be accessed independently of the memory address space that stores the associated capability. When the tag indication field is stored in this way, this can provide some performance improvements when performing the revocation process mentioned above. For example, the processing circuit can be arranged to obtain the tag indication field associated with each capability stored in this given memory area from a separate memory area for a given memory area in which the tracking field in its tracking structure is set. Then, for each obtained tag indication field whose tag value is a specified tag value, the processing circuit can be arranged to read the associated capability from the given memory area and determine whether the revocation condition is met for this associated capability. Therefore, by such a method, it can be seen that the revocation process can be implemented as a two-stage process, wherein the tag indication field is first obtained so that only the capability whose associated tag indication field has the specified tag value needs to be read from the memory area and evaluated to determine whether the revocation condition is met.
[0042] In one example implementation, the separate memory area may be further arranged to store a valid capability indication field associated with each data block of the capability size in the memory, wherein each valid capability indication field is used to identify whether the data block of the associated capability size in the memory stores a valid capability. Then, for a given memory area whose tracking field in the tracking structure is set, the processing circuit may be arranged to identify each valid capability with a specified tag value based on the valid capability indication field and the tag indication field stored in the separate memory area. Although in one such example implementation, both the valid capability indication field and the value of the tag indication field associated with each capability stored in the given memory area are retrieved from the separate memory area, so that the values in those fields can then be evaluated to determine which capabilities need to be reviewed, in an alternative implementation, the separate memory area may be arranged to return only the combined conditions indicating instances in which the valid capability indication field indicates that the associated capability is valid and the tag indication field indicates that the associated capability has a specified tag value associated therewith, so that the information returned from the separate memory area directly indicates the capabilities that need to be evaluated for the presence of the revocation condition.
[0043] In one example implementation, the apparatus further comprises a memory handling circuit for allocating one or more memory blocks for use by the processing circuit, and for subsequently deallocating a previously allocated memory block when the processing circuit no longer requires access to the previously allocated memory block. The memory handling circuit may be implemented in a variety of ways, and thus may be implemented, for example, by dedicated hardware, or may be implemented by software executed on the processing circuit. In response to the memory handling circuit allocating a given memory block for use by the processing circuit, the processing circuit may be arranged to be provided with one or more capabilities for use by the processing circuit when accessing the given memory block. The capabilities provided may be pre-existing capabilities, or may be, for example, capabilities derived from pre-existing capabilities (as previously mentioned, such derived capabilities will typically be restricted so that the constraint information is at least as restricted as the constraint information provided by the capability from which the derived capability is generated).
[0044] In an example implementation, each tag indication field is constrained so that once a tag value has been stored in this tag indication field, it is prohibited to modify the tag value in the tag indication field unless the associated capability is invalidated. Therefore, although in some implementations, the initial tag value stored in the tag indication field can be set by software, once the initial tag value has been set, the initial tag value cannot be changed. In an example implementation, any attempt to modify the tag value in the tag indication field will cause the associated capability to be invalidated, so that it may no longer be used as a capability. If necessary, in an alternative implementation, the above prohibition on modifying the tag value can be associated with a tag indication field, the value of which has been set to indicate that the associated capability will be tracked to the memory, so that it is impossible to subsequently identify that the capability should not be tracked without invalidating the capability. However, in such an implementation, it is possible to modify the tag value of the tag indication field indicating that the associated capability will not be tracked to indicate that the associated capability should be tracked.
[0045] In one example implementation, each tag indication field is constrained so that once a tag value has been stored in this tag indication field, any attempt to modify the tag indication field causes the fault signal to be asserted. This enables marking the fact that an attempt to modify the tag indication field has occurred to allow any desired further action to be taken.
[0046] As previously mentioned, if desired, in one example implementation, the processing circuitry may be enabled in at least one operating mode to perform capability generation operations to derive new capabilities from existing capabilities, and in this event, may be constrained when deriving new capabilities to ensure that the new capabilities inherit tag values associated with existing capabilities. The skill of performing such capability derivation procedures may be allowed in all operating modes of the processing circuitry, or alternatively may be restricted to specific modes, such as a mode in which privileged or trusted software is executed.
[0047] In an example implementation, the specified tag value is only used to control the tracking of the writing of certain capabilities to the memory in the manner discussed above. However, in an alternative implementation, the specified tag value can also be used for additional purposes. For example, in an example implementation, the capability tracking circuit can be arranged to prevent the capability with the specified tag value from being written to the memory address in one or more restricted memory areas. This may be useful in many cases. For example, the situation may be that certain forms of capabilities (such as the dynamic capabilities mentioned above) will only be legally written to the defined memory area, and any attempt to write them to other memory areas outside those defined memory areas will represent suspicious behavior. By associating the specified tag value with the capability of interest, the capability tracking circuit can also regulate such activities, and prevent such writing from occurring in the case of attempting to write to one or more restricted memory areas (that is, a memory area other than one of the defined areas to which such capabilities are expected to be written). There are various ways to prevent such write operations. For example, the capability tracking circuitry may prevent memory access from occurring (such behavior may be associated not only with write accesses, but also with read accesses, if desired), may cause some form of memory failure if an attempt is made to write such capabilities to a restricted memory area, or alternatively may allow the access to occur in some circumstances but then clear the valid capability indication field to identify that the capability is invalid.
[0048] With respect to memory areas that may be considered restricted memory areas, and by way of specific example only, such methods may be used to allow capabilities having specified tag values to be written to a stack memory area (but where tracking fields within a tracking structure are set in the manner discussed previously) while preventing capabilities having the specified tag values from being written to one or more other memory areas, such as temporary data buffers, scratchpads, or peripheral memory.
[0049] In one example implementation, the tag indication field is a single bit value, the specified tag value is a first value that can be set in the tag indication field, and the second value that can be set in the tag indication field is used to identify that the storage of the associated capability to the memory is not tracked by the capability tracking circuit. This can provide a simple implementation in which the storage requirements for the tag indication field are minimized. In addition, such an approach enables a distinction between dynamic capabilities that are provided for use in association with a memory area that can be dynamically allocated and deallocated, and static capabilities that are permanently available to the processing circuit (e.g., capabilities that can be provided by a compiler).
[0050] However, if desired, the tag indication field may alternatively be a multi-bit field, and the tag value used to indicate that a given capability is to be tracked may be selected based on the allocation conditions that exist when the given capability is provided for use by the processing circuitry. This may provide additional enhancement and flexibility in the use of the tag indication field, for example enabling differentiation between different forms of dynamic capabilities.
[0051] For example, the allocation condition may be arranged to depend on the current memory allocation generation for which the capability is being allocated, wherein the memory handling circuitry is arranged to allocate one or more memory blocks for use by the processing circuitry in a range of memory allocation generations. In such an arrangement, different tag values may be associated with different memory allocation generations, thereby allowing, for example, the writing of dynamic capabilities to be tracked separately according to the memory allocation generations associated with those capabilities. Such an approach then facilitates intergenerational revocation of capabilities, wherein the revocation process described above may be restricted to dynamic capabilities associated with a particular memory allocation generation and subsequent deallocation.
[0052] As another example, the allocation condition may be arranged to depend on the execution thread of the processing circuitry to which the capability is being allocated, and thus different tag values may be associated with different execution threads, allowing writing of such capabilities to be tracked separately for different threads if required.
[0053] As a further example, the allocation condition may be arranged to depend on an allocation identifier associated with a capability allocation process, wherein the capability allocation process is arranged to implement a plurality of capability allocator instances, and the allocation identifier indicates the current capability allocator instance. Thus, this would, for example, allow revocation procedures to be performed in relation to capabilities that have been allocated by a particular capability allocator instance, where appropriate.
[0054] In an example implementation, the capability tracking circuit may include multiple capability trackers, each of which has at least one associated tag value. Each capability tracker may then be arranged to maintain a separate tracking structure that provides tracking fields for each of a plurality of memory areas, and may be arranged to set the tracking field for a given memory area when at least one capability whose associated tag indication field has at least one associated tag value is written to a given memory area in the plurality of memory areas. Such methods provide great flexibility in how to track capabilities for subsequent revocation. For example, several separate capability trackers may be provided, each of which may track the same memory, but with different tag values. As another example, there may be several capability trackers, wherein different memories are associated with each capability tracker. As yet another example, there may be several capability trackers, each of which tracks different memories and uses multiple tag values.
[0055] In the case where the tag indication field is a multi-bit field, there are multiple ways to implement the tag indication field. In an example implementation, the tag indication field can be formed by a single-bit tag indication subfield and a pre-existing field of the associated capability, and the tag value provided by the tag indication field can be determined from a combination of the value of the single-bit tag indication subfield and the value of the pre-existing field. The pre-existing field can take various forms, and in an example implementation, it can be an object type field provided for each capability to indicate the type of the associated capability. In a specific example, the object type field is traditionally used to identify whether the associated capability is a normal capability or a sealed capability. Many capability architectures have introduced the concept of sealed capabilities. By sealing the capability, this allows the capability to be marked as non-cancellable (meaning that the capability cannot be used to access a memory address) and unchangeable, thereby causing a hardware exception in the case of attempting to modify or cancel a reference to such a capability. In the example implementation above, the information in the object type field can be reused in combination with the single-bit tag indication subfield to provide a tag value. Therefore, for example, this will allow the tag value to change according to the capability type indicated by the object type field.
[0056] There are various ways to provide capabilities for processing circuits to use when accessing a specific allocated memory block. In one example implementation, the processing circuit may be arranged to execute a capability determination instruction to determine the capabilities for use by the processing circuit, wherein the execution of the capability determination instruction causes the tag value of the determined capability to be derived from the control value in the system control register of the device. The execution of the capability determination instruction may cause the generation of new capabilities (in one example, this may be conceptually viewed as deriving capabilities from implicit maximum privilege capabilities), or may cause the capabilities to be derived from existing capabilities. According to the example implementation mentioned above, the tag value associated with the capability determined due to the execution of the capability determination instruction is set according to the control value stored in the system control register. The control value may be a single bit value, which allows a distinction between static capabilities and dynamic capabilities as previously noted, or may be a multi-bit value, which allows additional information to be captured within the tag value. Such a method may allow, for example, the tag value to be set according to a thread identifier or a current address space identifier (ASID) value being used by the processing circuit. It should be noted that control values within system control registers may be used directly to form tag values, or alternatively, tag values may be derived from the control values, such as by performing a predetermined calculation using the control values to determine the tag values.
[0057] In one example implementation, in addition to using the control value in the system control register to derive the tag value for the determined capabilities, this control value can also be used to control the specified tag value that the capability tracking circuit is looking for when viewing the capabilities written to the memory. Thus, this enables both the tag values that are set in association with the capabilities when they are provided for use by the processing circuitry and the tag values that the capability tracking circuitry is monitoring to be set according to the control value in the system control register.
[0058] If desired, tag values may also be used to limit capabilities that may be accessed with respect to at least one or more defined memory areas. For example, in one example implementation, the capability tracking circuit may be arranged to permit only valid capabilities whose tag values match one or more predefined values to perform at least one type of memory access for at least one or more defined memory areas. Thus, if the tag value of a capability that the processing circuit is seeking to access matches one or more predefined values, the capability tracking circuit may be arranged to allow the access to proceed, and if the access is a write access, the above-mentioned technique for setting the tracking field when the capability has a specified tag value may be employed. However, if the tag value does not match one or more predefined values, the capability tracking circuit may be arranged to prevent the access from occurring. Such mechanisms for preventing access may be applied to write access, read access, or both.
[0059] The one or more predefined values may take a variety of forms. For example, such predefined values may be, for example, all zero values (which may be used, for example, in association with static capabilities that are not tracked) or one or more other specific non-zero values that the processing circuit is currently allowed to use. Through such methods, access to old / obsolete capabilities can be prevented, thereby enhancing the generational revocation method discussed above. Alternatively, such schemes may be used, for example, to prevent access to capabilities associated with threads different from the thread currently being executed by the processing circuit. The manner of preventing access may vary depending on the specific implementation. For example, a fault may be triggered so that the software can handle the situation, or the capability may be invalidated (for example, by allowing access to the capability to continue but clearing the valid capability indication field for the capability).
[0060] The above-described method of selectively preventing access to capabilities whose tag values do not match one or more predefined values may be applied generally, or its application may be limited to one or more defined memory regions. Thus, by way of example, the functionality may be limited to a specific memory management unit (MMU) or memory protection unit (MPU) region of memory.
[0061] In one specific example implementation, the capability tracking circuitry may be arranged to prevent loading of a valid capability from memory unless the capability has an associated tag value that matches one or more predefined values. This therefore enables preventing loading of an outdated capability, or any attempt to load such an outdated capability, for example, may cause the loaded capability to be invalidated.
[0062] In one example implementation, the capability tracking circuitry may be permanently enabled, but if desired, the device may also include an enable tag storage device whose value can be set to selectively enable and disable the capability tracking circuitry. The ability to enable and disable the functionality of the capability tracking circuitry may provide additional flexibility in the operation of the device. For example, the capability tracking circuitry may be disabled in situations where no dynamic memory allocation is occurring and therefore any capabilities being used are static capabilities.
[0063] In one example implementation, the capability tracking circuitry may be arranged to clear the tracking field for a given memory region when all capabilities written to the given memory region whose associated tag indication field has a specified tag value are invalidated. Thus, once the aforementioned revocation process has been performed in relation to the given memory region, and any capabilities that have had their associated tracking fields set have therefore been invalidated, the tracking field may be cleared. In implementations where the aforementioned saturation counter approach is used for the tracking field, the value of the saturation counter in the tracking field may then be decremented following the invalidation of each capability that had previously had the saturation counter incremented.
[0064] Specific example implementations will now be discussed with reference to the drawings.
[0065] Figure 1 An example of a data processing apparatus 2 according to an example implementation is schematically shown. It should be understood that this is a simplified diagram for ease of explanation and that in practice the apparatus may have many features that are not shown in the figure for simplicity. Figure 1. The apparatus 2 includes a processing circuit 4 for implementing data processing in response to instructions decoded by an instruction decoder 6. Program instructions are extracted from a memory system 8 and decoded by an instruction decoder to generate a control signal that controls the processing circuit 4 to process the instruction in a manner defined by the architecture. For example, the decoder 6 may interpret the opcode of the decoded instruction and any additional control fields of the instruction to generate a control signal that causes the processing circuit 4 to activate an appropriate hardware unit to perform an operation such as an arithmetic operation, a load / store operation, or a logical operation. The apparatus has a set of scalar registers 10 and a set of capability registers 12. Although the capability registers 12 are shown as being different from the scalar registers 10, in an example implementation, the capability registers may at least partially reuse some scalar registers (e.g., by storing a pointer value of the capability in the scalar register). The apparatus may also have other registers, such as one or more system control registers 28 for storing control information for configuring the operation of the processing circuit, and / or vector registers (not shown) for providing vector operands in an implementation in which the processing circuit may be configured to perform vector processing operations.
[0066] In response to an arithmetic or logic instruction, the processing circuitry typically reads source operands from registers 10 and writes the results of the instruction back to registers 10. In response to a load / store instruction, data values are transferred between registers 10 and memory system 8 via a load / store unit 18 within processing circuitry 4. Capabilities may also be loaded from memory into capability registers 12, or stored from capability registers 12 back to memory 8 via a load / store unit 18. Memory system 8 may include one or more levels of cache as well as main memory.
[0067] The processing circuitry 4 may include a number of different hardware blocks for processing different classes of instructions. For example, load / store instructions interacting with the memory system 8 may be processed by a dedicated load / store unit 18, while arithmetic or logic instructions may be processed by an arithmetic logic unit (ALU). The ALU itself may be further divided into a multiply-accumulate unit (MAC) for performing operations involving multiplication and additional units for processing other kinds of ALU operations. A floating point unit may also be provided for handling floating point instructions.
[0068] like Figure 1 As shown, the processing circuit 4 may include a memory handling circuit 22 for allocating one or more memory blocks for use by the processing circuit, and for subsequently de-allocating previously allocated memory blocks when the processing circuit no longer requires access to the previously allocated memory blocks. The memory handling circuit may be implemented by dedicated hardware, or may be implemented by software executing on the processing circuit 4 (e.g., software that performs malloc() and free() operations).
[0069] The processing circuitry 4 may also be arranged to execute a process 20 in order to allocate capabilities for use by the processing circuitry, and also to execute a revocation process to seek to revoke capabilities that are no longer required. As discussed previously, the capabilities used by the apparatus may be both static capabilities for accessing statically allocated memory and dynamic capabilities for accessing dynamically allocated memory. Both types of capabilities may in principle be allocated by the capability allocation process 20 running on the processing circuitry 4, but in one example implementation, static capabilities may be allocated by the compiler as a literal pool in the program code, and therefore it may be the only dynamic capabilities that are provided for use by the processing circuitry 4 using the capability allocation process 20, and therefore in such a scenario it will be only those dynamic capabilities that need to be revoked later when they are no longer required.
[0070] As discussed previously, capabilities may be used when generating a memory address for an access request to a memory, rather than using a standard pointer value, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to the memory using a memory address derived from the pointer value. The device 2 may be provided with a capability access check circuit 16 that may perform a capability check operation associated with an access request whose memory address is generated using a specified capability, so as to determine whether to grant this access request based on the constraint information identified by the capability. This may be performed, for example, with reference to the scope information and restriction / permission information forming the constraint information of the capability. Thus, by way of example only, if a write access request to a memory address is being sought to be performed using a capability that indicates that the capability can only be used for reading and not for writing, the capability check circuit 16 may determine that the access request cannot proceed, and may, for example, issue a fault signal in such circumstances.
[0071] As will be discussed in more detail herein, capability tracking circuitry 24 may be provided to monitor the writing of capabilities to the memory system 8 and optionally also the reading of capabilities from the memory system 8, and to maintain a tracking structure 26 that may later be used to improve the efficiency of the revocation process 20 performed by the processing circuitry 4. According to the techniques described herein, a tag indication field may be stored in association with each capability to provide a tag value for distinguishing between static capabilities for accessing statically allocated memory and dynamic capabilities for accessing dynamically allocated memory, and the capability tracking circuitry 24 may be arranged to monitor the tag value of each capability written to memory so as to keep track of capabilities written to memory having one or more particular tag values.
[0072] The capability tracking circuitry 24 is arranged to maintain a tracking structure 26 which provides a tracking field for each of a plurality of memory regions (as previously mentioned, the size of the memory regions for which the tracking structure provides the tracking fields may vary depending on the specific implementation). The capability tracking circuitry is arranged to set the tracking field for a given memory region of the plurality of memory regions when at least one capability whose associated tag indication field has a specified tag value is written to the given memory region, wherein the specified tag value indicates that the writing of the associated capability to the memory is to be tracked by the capability tracking circuitry to facilitate subsequent revocation of the associated capability. The specified tag value may, for example, indicate that the associated capability is a dynamic capability, and in specific implementations where the tag value may be a multi-bit value to distinguish between different forms of dynamic capabilities, the capability tracking circuitry may, for example, be arranged to track only specific forms of dynamic capabilities if desired.
[0073] The tracking field may take a variety of forms, and thus in one example implementation may be a single bit field that is set when a capability with a specified tag value is written to a memory area associated with this tracking field. However, in alternative implementations, the tracking field may be a multi-bit field to allow more detailed information to be captured. For example, as previously discussed, the tracking field may take the form of a saturating counter.
[0074] Capability tracking circuit 24 may be coupled to a plurality of processing circuits ( Figure 1 Only one of the multiple processing circuits is shown in FIG. 1 ), and in addition different tracking circuits may be associated with different memory controllers, such as Figure 2 Specifically, as shown in FIG. Figure 2 As shown, a plurality of processing circuits 50, 52, 54 in the form of central processing units (CPUs) are connected to memory controllers 58 and 60 via interconnects 56, each of which controls access to associated memory. According to this example implementation, a separate capability tracker 62, 64 may be provided in association with each memory controller 58, 60.
[0075] Moreover, although Figure 1 , the tracking structure 26 is shown as being provided internal to the capability tracking circuit 24, but in alternative implementations it may be a dedicated hardware storage unit, or provided by a data structure within the memory system 8.
[0076] Figure 3ASchematically illustrates how tag bits T (an example of a valid capability indication field) may be used in association with individual data blocks to identify whether those data blocks represent capabilities or represent normal data, and how a tag indication field M may also be used in association with individual data blocks to provide a tag value for distinguishing between static capabilities and dynamic capabilities when the tag bits indicate that the data block represents a valid capability. Specifically, a memory address space 110 will store a series of data blocks 115, which will typically have a specified size. For purposes of illustration only, it is assumed in this example that each data block includes 64 bits, but in other example implementations, data blocks of different sizes may be used, such as 128-bit data blocks when capabilities are defined by 128 information bits. Associated with each data block 115, a tag field 120 is provided, which in one example is a single bit field referred to as a tag bit, which is set to identify that the associated data block represents a capability, and is cleared to indicate that the associated data block represents normal data and therefore cannot be considered a capability. It should be understood that the actual value associated with the set or clear state may vary depending on the specific implementation, but by way of example only, in one example implementation, if the tag bit has a value of 1, then the tag bit indicates that the associated data block is a capability, and if the tag bit has a value of 0, then the tag bit indicates that the associated data block contains normal data.
[0077] like Figure 3A As also shown in FIG. 1 , a tag indication field 125 is also provided in association with each data block 115 to store a tag value for identifying whether the associated capability is a static capability or a dynamic capability. As mentioned previously, a single-bit tag indication field may be used in one example implementation, but in alternative implementations, a multi-bit tag indication field may be used, for example, to distinguish between different forms of dynamic capabilities.
[0078] When the capability is loaded into a register 100 accessible to the processing circuit (e.g., Figure 112) in the capability registers 12 shown in the figure, the tag bits move with the capability information. Thus, when an effective capability is loaded into the register 100, an address indication 102 (which may also be referred to herein as a pointer) and metadata 104 providing constraint information (such as the scope information and permission information mentioned above) will be loaded into the register. In some specific implementations, additional metadata may also be provided. In addition, in association with this register, or as a specific field therein, a tag bit 106 will be set to identify that the content represents an effective capability, and a tag indication field 108 will be provided to distinguish between static capabilities and dynamic capabilities (by copying a tag value from an associated tag indication field 125 in the memory). Similarly, when an effective capability is stored back to the memory, the associated tag bit 120 will be set in association with the data block in which the capability is stored, and the tag value in the tag indication field 108 of the register will be copied to the tag indication field 125 in the memory. By such methods, it is possible to distinguish between capabilities and normal data and thereby ensure that normal data cannot be used as capabilities, and for valid capabilities, the tag indication field can be used to provide information about the capability which can be used to track this capability for later revocation.
[0079] Although in Figure 3A In the example shown, the tag bits and flag values are stored in the normal memory address space 110, but this is not required, and in alternative example implementations, such as Figure 3B As shown, the tag bits may alternatively be stored "out-of-band", for example in a different memory area. Thus, while each data block 115' is stored in the normal memory address space 110', the tag field 120' and the tag indication field 125' are stored in a separate memory area 127 that is accessible independently of the memory address space 110' for storage capacity and general data. As will be referenced later Figure 7 As discussed in more detail in the flowchart of , such an arrangement can achieve improvements in efficiency and performance when performing the revocation process with respect to capabilities.
[0080] Figure 4 It shows that you can use Figure 1 2 is a flow chart of a capability allocation process performed according to one example implementation. Such a capability allocation process may be performed for a variety of reasons, but may be performed, for example, in response to memory handling circuitry 22 allocating a memory block to processing circuitry 4, whereupon the allocation process may be used to provide one or more capabilities for use by the processing circuitry when accessing the memory block. Figure 4 As an example, a set of root capabilities may be provided in memory and then used Figure 4The process of deriving other capabilities from those root capabilities.
[0081] At step 150, it is determined whether the capability will be allocated for use by the processing circuit, and if so, processing proceeds to step 155, where it is determined whether the capability will be tracked for later revocation. In an example implementation, this may be the case if the capability is provided in association with dynamically allocated memory, but this will not be the case if the capability is provided in association with statically allocated memory. In some implementations, it is also possible that tracking certain dynamic capabilities rather than other dynamic capabilities is considered appropriate. If it is determined that the capability will not be tracked, then at step 165, the tag value is cleared in association with the allocated capability to indicate that the capability is an untracked capability. However, if the capability is to be tracked, then the tag value is set at step 160 to indicate that the capability is a tracked capability. In the case where the tag value is a single bit value, the set and clear states can be indicated by logical one and zero values (wherein a logical one value indicates a set state or a clear state, and a logical zero value indicates another state). However, if a multi-bit tag value is used, there may be a plurality of different tag values that may each indicate a capability to be tracked, and an appropriate one of those tag values will be selected at step 160 .
[0082] Although Figure 4 The process of can in principle be performed for both static and dynamic capabilities, but in one example implementation, it may be the case that static capabilities have been allocated as literal pools in the program code by the compiler, and thus Figure 4 The process of may not be performed with respect to static capabilities in such implementations, and it will only be performed by Figure 4 Dynamic capabilities of the process allocation shown.
[0083] Figure 5A 2 is a flow chart showing a sequence of steps that may be performed when determining that a capability is to be written to memory according to one example implementation. At step 200, once it is determined that a capability is being written to memory, it is determined at step 205 whether a tag value associated with the capability indicates that the capability is to be tracked. If not, the process may proceed to step 210, where the tracking structure 26 maintained by the capability tracking circuit 24 is not updated, and the write operation is permitted to proceed if any conditions controlling the skill of performing the write operation are satisfied.
[0084] However, if it is determined at step 205 that the flag value indicates that the capability is to be tracked, then at step 215 the memory area to which the capability is to be written is identified from the memory address specified by the write access request. Figure 5AIn the example shown, step 205 and step 215 are shown as separate steps, but in alternative implementations, they may be implemented as a single step. Specifically, whether writes to a given capability will be tracked may depend on the configuration of the tracker associated with the memory region to which the given capability is being written, and thus a circular dependency may exist between step 205 and step 215.
[0085] In one example implementation, the process may then proceed directly to step 230, where the write operation is permitted to proceed if any other conditions controlling the capability to perform the write operation are satisfied, and assuming the write operation is performed, the tracking fields for this memory area are set if they were not already set due to the capability to be tracked previously being written to this memory area.
[0086] In the above examples, it is assumed that the tracking field is a single bit field that is only set or cleared. However, as mentioned above, in alternative implementations, it is possible for the tracking field to take a multi-bit form to allow more information to be captured within the tracking field. For example, in one example, as mentioned above, the tracking field can be a saturation counter, and in this event, at step 230, the value of the saturation counter will be incremented.
[0087] In another alternative implementation, in addition to setting the tracking field at step 230, the tracking structure 26 within the capability tracking circuit 24 may be extended so that the addresses of tracked capabilities that have been written to the memory area (i.e., those addresses having a tag value indicating that those capabilities should be tracked) can be stored within the tracking structure to provide a dense list of relevant addresses that can be queried later. Although this increases the size of the tracking structure, it can enable the execution of subsequent revocation processes to be further improved.
[0088] As shown by dashed boxes 220 and 225, Figure 5AThe process may optionally include some additional steps. Specifically, according to such alternative specific implementations, tag values may also be used to restrict access to certain memory areas, and specifically, one or more restricted memory areas to which the tracked capability should not be written may be specified. Therefore, once the memory area to which the capability is to be written is determined at step 215, it may be determined at step 220 whether the memory area is a restricted memory area. If not, the process may proceed to step 230 as discussed above, but if the memory area is a restricted memory area, the process may alternatively proceed to step 225, where the writing of the capability is prevented. There are various ways in which write operations can be prevented. For example, the capability tracking circuit 220 may prevent memory access from occurring, may cause some form of memory failure, or may alternatively allow the write operation to occur but clear the tag bit to invalidate the capability.
[0089] One or more restricted memory areas may be established, such as memory areas that it is not expected that dynamic capabilities should be legally written to. By way of example only, such restricted memory areas may be temporary data buffers, scratchpads, or peripheral memory.
[0090] Figure 5B A tracking structure 250 according to one example implementation is schematically shown. The tracking structure may include a plurality of entries, and each entry may have a first field 255 to identify a memory region and a second field 260 to form the aforementioned tracking field. The size of the memory region for which the tracking structure provides the tracking field may vary depending on the implementation, thus allowing the capability tracking circuit to track at a coarse or fine granularity level, or indeed for a mixture of memory regions of different sizes.
[0091] Figure 6 3 is a flow chart illustrating steps that may be performed to selectively revoke capabilities upon the occurrence of a revocation trigger. At step 300, a determination is made as to whether a revocation trigger has been detected. A revocation trigger may take a variety of forms, but in one example implementation, may occur once one or more previously allocated memory blocks have been deallocated, thereby indicating that any dynamic capabilities that have been allocated for use by processing circuitry to access those now deallocated memory blocks are candidates for revocation.
[0092] Having to scan the entire memory system to locate capabilities that may need to be revoked is a very resource intensive process. However, by using the capability tracking circuit 24 described herein, and in particular by using the tracking structure 26 maintained by the capability tracking circuit, it is possible to perform a more targeted process when seeking to identify capabilities that may need to be revoked.
[0093] Specifically, once the revocation trigger is detected at step 300, at step 305, the capability tracking circuit 24 may be consulted to determine each memory region whose tracking field has been set (i.e., where the tracking field has a value indicating that one or more capabilities whose tag indication field indicates that those capabilities should be tracked have been written to this memory region). As mentioned previously, in some systems, there may be multiple capability tracking circuits, and which capability tracking circuit is consulted at this time may depend on a variety of factors, such as which portions of the memory each capability tracking circuit is associated with (in an example implementation in which different capability tracking circuits are associated with different portions of the memory), which tag values the various capability tracking circuits are tracking (e.g., in a generational memory allocation implementation in which different capability tracking circuits track capabilities associated with different memory allocation generations, in which case reference may be made to one or more capability tracking circuits that track capabilities associated with the memory allocation generation associated with the memory block being deallocated), etc.
[0094] Once each memory region whose tracking field is set has been identified at step 305, for each identified memory region, the memory region may be scanned to locate each stored capability whose tag value indicates that it is a candidate for revocation (i.e., its tag value indicates that it is being tracked for revocation) at step 310. In a specific implementation using multi-bit tag values, the memory may then be scanned at this time to identify capabilities having one or more particular tag values of interest (i.e., tag values indicating that the associated capability is a candidate for revocation in response to the current revocation trigger).
[0095] In implementations where the tracking structure is extended to enable addresses of relevant capabilities to be captured directly within the tracking structure, then performance of the scanning process of step 310 may be improved because the addresses stored within the tracking structure may be used to retrieve each capability that is a candidate for revocation.
[0096] Once each stored capability whose tag value indicates that the capability is a candidate for revocation has been located, it can be determined whether the revocation condition is met for each located capability. There are various ways in which the revocation condition can be evaluated. In one example implementation, if the range constraint information associated with a given capability falls at least partially within a memory block that has been deallocated, it can be determined that the revocation condition has been met for this given capability. However, an alternative strategy may be to only revoke capabilities whose memory address allowable range is completely included in the memory block identified for revocation.
[0097] Finally, at step 315, each capability for which it has been determined that the revocation conditions are met may be revoked, for example, by clearing a tag bit associated with the capability.
[0098] Figure 7is shown in a specific implementation in which separate memory areas are used for tag bits and marker bits, such as e.g. Figure 3B In the example shown above, it can be implemented to achieve Figure 6 Flowchart of the sequence of steps of step 310 of step 310. At step 350, a separate memory area may be accessed to read the tag and marker values of each capacity-sized data block within the identified memory area. Figure 6 If more than one memory region is identified at step 305 of the query, the process may be repeated for each memory region. At step 355, based on the accessed tags and tag values, each valid capability having a tag value of interest may be identified that is considered a candidate for revocation. While the tags and tag values may be retrieved "as is" from the separate memory region and then evaluated at step 355, in an alternative implementation, the query performed with respect to the separate memory region may return only an indication for each valid capability having a tag value of interest.
[0099] At step 360, the valid capabilities for each identification of the candidate for revocation (as determined by step 355) may be retrieved from memory and then may be used to determine the capabilities of the candidate for revocation using the previously referenced Figure 6 The process discussed above evaluates whether the revocation conditions are met. Thereafter, the process can continue as discussed above. Figure 6 Step 315, where each capability for which the revocation condition is met may be revoked.
[0100] Figure 8 is a flow chart illustrating how attempts to change a tag value may be handled according to one example implementation. At step 400, any attempt may be detected when an attempt is made to change a tag value in a tag indication field associated with a valid capability. When such an attempt is detected, then at step 405, the capability may be invalidated, for example by clearing the tag bit. Optionally, the tag field may also be cleared if desired, but this is not necessary as clearing the tag bit will always be sufficient as it will render the capability invalid and therefore unusable in association with any subsequent memory access. In one particular example implementation, a particularly robust mechanism for clearing the tag bit is to write an all-zero value to the memory location containing the capability, which has the effect of clearing the tag bit as well as the other bits that actually specify the capability. As shown in FIG. Figure 8 It is also indicated that, as an alternative to disabling the capability, a fault signal may instead be asserted at step 405 to trigger the software to evaluate how to proceed.
[0101] Fig. 94 is a flow chart illustrating restrictions that may be applied when seeking to generate a capability from an existing capability. As indicated by step 410, when such a situation is detected, then at step 415, assuming any checks required to allow the capability generation process to be performed are satisfied, a new capability may be created from the existing capability, with the tag value inherited from the existing capability. Thus, when capabilities are derived from existing capabilities, they may be forced to inherit the tag value of the existing capability. If desired, the skill of deriving capabilities from existing capabilities may be limited to certain operating modes, such as when the processing circuit is executing certain privileged or trusted code.
[0102] FIG. 10A to FIG. 10C Different arrangements of the tag indication fields that can be used are shown. Fig. 10A In the example, a single bit field 420 is used, and in the illustrated example, a logic one value in this field indicates that the associated capability should be tracked, while a logic zero value indicates that the associated capability should not be tracked. It should be understood that in alternative implementations, the meaning of the logic one and zero values can be reversed.
[0103] exist Fig. 10B , a multi-bit tag indication field 425 is used, and a K-bit tag value is specifically shown. One particular value (e.g., an all-zero value) may be used to indicate that the associated capability should not be tracked. However, various other different non-zero tag values may be used to indicate capabilities to be tracked, where the tag value used in association with any given capability may depend, for example, on the allocation conditions that exist when the given capability is allocated for use by the processing circuit.
[0104] The allocation condition may take various forms. For example, as discussed above, the allocation condition may be arranged to depend on the current memory allocation generation for which the capability is allocated, such that different tag values may be associated with different memory allocation generations. As other examples, the allocation condition may be arranged to depend on the execution thread of the processing circuit for which the capability is allocated, and therefore different tag values may be associated with different execution threads, or the allocation condition may be arranged to depend on an allocation identifier associated with a capability allocation process, wherein the capability allocation process is arranged to implement multiple capability allocator instances and the allocation identifier indicates the current capability allocator instance.
[0105] Fig. 10C Yet another alternative implementation for a tag indication field is shown, where the tag indication field is formed of two separate subfields. For example, a single bit subfield 430 may be provided that is used in conjunction with the contents of a pre-existing field 435 to form a multi-bit tag value. The pre-existing field may take various forms, but in one example is an object type field that may have been provided in association with a capability to identify the capability type, such as whether the capability is a normal capability or a sealed capability. Thus, for example, this would allow the tag value to vary depending on the capability type indicated by the object type field.
[0106] Fig.11A and Fig. 11B Schematically illustrates how different tag values can be used with different memory allocation generations to allow inter-generational revocation of capabilities. Fig.11A As shown, a first memory allocation algebra process 450 may be used to allocate memory blocks, and those memory blocks may then be used when executing code 455. Thereafter, another memory allocation algebra 460 may be performed, for example to obtain and allocate another portion of memory for use by subsequent code. Fig.11A As shown, different tag values (X and Y in the illustrated example) may be used for capabilities to be tracked, depending on whether those capabilities are associated with memory regions allocated by the first memory allocation generation or the second memory allocation generation. In one example implementation, a single capability tracking circuit may maintain one or more tracking structures to separately track writes of capabilities having tag value X and capabilities having tag value Y for each of a plurality of memory regions, or alternatively, different memory tracking circuits may be provided that are each arranged to track writes of capabilities having one of those different tag values.
[0107] As Fig. 11B As indicated by the flowchart of , if a revocation trigger is detected at step 470 that causes a revocation process to be performed with respect to the capabilities associated with the first memory allocation generation, then at step 475, the process described above may be used to locate those valid capabilities having a tag value X (which is a tag value associated with the tracked capabilities for accessing memory allocated by the first memory allocation generation). Then, at step 480, for each of the located capabilities, if a revocation condition is met, the capability may be revoked, which is evaluated using any of the techniques described above.
[0108] Fig. 12A Different example situations in which a plurality of different tag values may be used are shown. In this particular example, tag value X is used in association with capabilities allocated for use by the processing circuitry when executing execution thread 1 500, while tag value Y is used in association with capabilities allocated for use by the processing circuitry when executing execution thread 2 505. Such an approach may allow capability tracking circuitry to track certain capabilities associated with a particular execution thread, such as dynamic capabilities used by such an execution thread, so that such capabilities may be more easily revoked later using the revocation process described above, for example, once the execution thread is no longer being executed.
[0109] Fig. 12BYet another example of using different tag values is shown, where tag value X is used for capabilities allocated by first capability allocation instance 510, and tag value Y is used for capabilities allocated by second capability allocation instance 515. There are a variety of scenarios where using different capability allocation instances may be appropriate. For example, a system may provide different permissions or associated memory areas to different allocators. For example, there may be an operating system level allocator that can allocate privileged memory and associated capabilities for use by kernel code, and different thread level allocators that operate with lower permissions and can allocate memory and associated capabilities for use by individual execution threads. As a specific example use case, one such allocator may be associated with kmalloc (kernel malloc in Linux), while another allocator may be associated with malloc in user space.
[0110] Fig.13 Schematically illustrates how different capability trackers may be used in one example implementation. In this example, three capability trackers 520, 530, 540 are provided, each of which has its own associated tracking structure 525, 535 and 545. These different capability trackers may be used in various ways, but in the example shown, each capability tracker is provided to monitor capabilities having different tag values, and thus a first capability tracker 520 monitors capabilities having tag value X, a second capability tracker 530 monitors capabilities having tag value Y, and a third capability tracker 540 monitors capabilities having tag value Z. Each capability tracker will maintain information for a plurality of different memory regions within its associated tracking structure, and in particular will identify for each memory region when one or more capabilities having a monitored tag value are written to that memory region.
[0111] Fig.14 5 is a flow chart illustrating one example implementation in which capability determination instructions are provided for execution by processing circuitry. At step 550, once such instructions are being executed, then at step 555, execution of the instructions will cause capabilities to be determined for allocation to the processing circuitry. Such determined capabilities may, for example, be derived from pre-existing capabilities. However, in addition to this, at step 555, a capability determination may be performed from a system control register (such as Figure 1 The flag value used in association with the determined capability is obtained by accessing one of the system control registers 28 shown in the figure. This provides great flexibility in the selection of the flag value, because this flag value (or information used to derive it) can be stored in the system control register and updated when required by software executing at the required privilege level. It may also be the case that the value in the relevant system control register changes upon context switching, and therefore different flag values may be used in association with different execution contexts.
[0112] like Fig.14 As shown, if desired, at step 560, the value in the system control register may also be used to control a tag value, which the capability tracking circuit is configured to monitor within its associated tracking structure to control which capabilities are tracked based on the information stored in the system control register.
[0113] While the contents of the system control register may directly identify the tag value, in alternative implementations, the information in the system control register may be used to derive the tag value, such as by performing some calculation on the value in the system control register.
[0114] Fig.15 is a flow chart illustrating how tag values may be used to control access to specific capabilities in some implementations in addition to using tag values in association with the previously described tracking mechanism for tracking writes of capabilities having specific tag values to memory. Fig.15 , when it is determined at step 600 that access to a capability in memory is being sought, it is determined at step 605 whether the access is within a defined memory area. Specifically, one or more defined areas in memory may be established where certain restrictions on access to capabilities will apply. If the access is not within a defined memory area, then at step 610, the access is allowed to proceed.
[0115] If it is determined at step 605 that the access is within one or more defined zones, then it is determined at step 615 whether the tag value of the capability matches the allowed tag value. For example, one or more allowed tag values may be associated with each defined zone so that only capabilities having one of the allowed tag values may be accessed within those defined zones. If it is determined at step 615 that the tag value of the capability matches the allowed tag value, then the process proceeds to step 610, where the access is allowed. If the access is a read access, then the capability may simply be read from memory. Conversely, if the access is a write access, then in the event that a write access is performed to a defined zone and the tag value indicates that the capability should be tracked, then the appropriate tracking structure 26 will be updated by the relevant capability tracking circuit 24 to keep track of the fact that the write operation has been performed.
[0116] If it is determined at step 615 that the tag value is not an allowed tag value, then access to the memory is prevented at step 620. Access may be prevented in a variety of ways. For example, a fault may be raised to trigger software to evaluate a fault condition. Alternatively, steps may be taken to invalidate the capability. For example, for a write access, the capability may be written to the memory, but the tag bit may be cleared to effectively invalidate the capability. For a read access, the underlying value in the memory may remain unchanged, but the value read into the register may clear the tag bit to invalidate the already loaded copy. Such a mechanism may be useful for a variety of reasons, such as to prevent a processing circuit from attempting to utilize an obsolete capability that is no longer relevant to the processing being performed by the processing circuit.
[0117] Fig.16 A usable simulator is shown. Although the example implementation described previously implements the invention in terms of the apparatus and method for operating the specific processing hardware supporting the technology involved, it is also possible to provide an instruction execution environment implemented by using a computer program according to the examples described herein. Such computer programs are generally referred to as simulators, to a certain extent because such computer programs provide a software-based implementation of the hardware architecture. The types of simulator computer programs include emulators, virtual machines, models, and binary converters, which include dynamic binary converters. Typically, the simulator implementation can be run on a host processor 715 supporting the simulator program 705, optionally running a host operating system 710. In some arrangements, there may be multiple simulation layers between the hardware and the provided instruction execution environment and / or a plurality of different instruction execution environments provided on the same host processor. Historically, a powerful processor is required to provide a simulator implementation that is executed at a reasonable speed, but this approach may be reasonable in certain circumstances, such as when it is desired to run another processor local code for compatibility or reuse reasons. For example, the simulator implementation can provide additional functionality that is not supported by the host processor hardware to the instruction execution environment, or provide an instruction execution environment that is generally associated with different hardware architectures. An overview of simulation is given in: "Some Efficient Architecture Simulation Techniques", Robert Bedichek, Winter 1990 USENIX Conference, pages 53-63.
[0118] To the extent that examples have been previously described with reference to specific hardware constructs or features, in a simulated implementation, equivalent functionality may be provided by suitable software constructs or features. For example, a specific circuit may be provided as computer program logic in a simulated implementation. Similarly, memory hardware (such as registers or caches) may be provided as software data structures in a simulated implementation. In addition, the physical address space for accessing the memory 8 in the hardware device 2 may be simulated as a simulated address space, which is mapped by the simulator 705 to a virtual address space used by the host operating system 710. One or more of the hardware elements referenced in the previously described examples are present in an arrangement on the host hardware (e.g., the host processor 715), and some simulated implementations may utilize the host hardware where appropriate.
[0119] The simulator program 705 may be stored on a computer-readable storage medium (which may be a non-transitory medium) and provides a virtual hardware interface (instruction execution environment) to the target code 700 (which may include an application, an operating system, and a hypervisor) that is identical to the hardware interface of the hardware architecture modeled by the simulator program 705. Thus, the simulator program 705 may be used to execute program instructions of the target code 700 from within the instruction execution environment so that a host computer 715 that does not actually have the hardware features of the apparatus 2 discussed above may simulate these features. The simulator program may include a processing program logic 720 for simulating the behavior of the processing circuit 4, and a processing program logic 720 for simulating the behavior of the processing circuit 4. Figure 1 The capability tracking circuit 24 of the hardware device 2 acts as the capability tracking program logic 725. Therefore, in Fig.16 In an example of , the techniques described herein for managing capabilities may be performed in software by simulator program 705 .
[0120] The technology described herein provides a particularly effective and well-functioning mechanism for tracking certain capabilities for subsequent revocation. According to the described technology, a capability tracking circuit can be used to track capabilities, especially to keep track of the writes of certain capabilities to one or more memory areas. In addition, by using a tag value in association with each capability, the tracking functionality can be limited to certain capabilities of interest, such as certain dynamic capabilities that have been provided for use in association with a dynamically allocated memory area for processing circuitry. By such methods, when such dynamically allocated memory is subsequently deallocated, a more targeted method can be used to identify capabilities that should be invalidated within the memory in order to mitigate the possibility that such obsolete capabilities remain available and may be misused.
[0121] In this application, the words "configured to..." are used to mean that elements of a device have a configuration that enables the performance of a defined operation. In this context, "configuration" means the arrangement or manner of interconnection of hardware or software. For example, the device may have dedicated hardware that provides the defined operation, or a processor or other processing device may be programmed to perform the function. "Configured to" does not mean that the device elements need to be changed in any way in order to provide the defined operation.
[0122] Although exemplary embodiments of the present invention have been described in detail herein in conjunction with the accompanying drawings, it should be understood that the present invention is not limited to those precise embodiments, and that various changes, additions and modifications may be implemented therein by those skilled in the art without departing from the scope and spirit of the present invention as defined in the appended claims. For example, the features of the dependent claims may be combined in various ways with the features of the independent claims without departing from the scope of the present invention.
Claims
1. A device, comprising: processing circuitry to perform operations during which access requests to memory are generated, wherein the processing circuitry is arranged to generate a memory address for the access request using capabilities, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to memory using a memory address derived from the pointer value, and wherein a tag indication field is stored in association with each capability to provide a tag value for distinguishing between a static capability for accessing statically allocated memory and a dynamic capability for accessing dynamically allocated memory; as well as A capability tracking circuit is used to maintain a tracking structure that provides a tracking field for each of a plurality of memory areas, wherein the capability tracking circuit is arranged to set the tracking field for a given memory area when at least one capability whose associated tag indication field has a specified tag value is written to the given memory area of the plurality of memory areas, wherein the specified tag value indicates that the writing of the associated capability to the memory is to be tracked by the capability tracking circuit to facilitate subsequent revocation of the associated capability.
2. The device according to claim 1, wherein: The processing circuit is arranged to implement a revocation process in response to a revocation trigger with respect to each memory region whose tracking field in the tracking structure is set, to identify each stored capability within the memory region whose associated tag indication field has the specified tag value, and for each identified stored capability, revoke the identified stored capability if a revocation condition is satisfied for the identified stored capability.
3. An apparatus according to claim 2, wherein, for each capability, the constraint information includes range constraint information indicating at least an allowed range of memory addresses that can be accessed using the pointer value, and for a given identified storage capability, when the allowed range of memory addresses includes one or more memory addresses within a memory block that has been deallocated, it is determined that the revocation condition is satisfied.
4. The device according to claim 2 or claim 3, wherein: The tag indication field is stored in a separate memory area accessible independently of the memory address space storing the associated capability; The processing circuit is arranged to, for a given memory area whose tracking field in the tracking structure is set, obtain from the separate memory area the tag indication field associated with each capability stored within the given memory area, and then, for each obtained tag indication field whose tag value is the specified tag value, is arranged to read the associated capability from the memory area and determine whether the revocation condition is satisfied for the associated capability.
5. An apparatus according to claim 4, wherein the separate memory area is further arranged to store a valid capability indication field associated with each data block of capability size in the memory, wherein each valid capability indication field is used to identify whether the associated data block of the capability size in the memory stores a valid capability, and the processing circuit is arranged to identify each valid capability having the specified tag value based on the valid capability indication field and the tag indication field stored in the separate memory area for the given memory area whose tracking field in the tracking structure is set.
6. The apparatus according to any preceding claim, further comprising: memory handling circuitry to allocate one or more memory blocks for use by the processing circuitry and to subsequently de-allocate previously allocated memory blocks when the processing circuitry no longer requires access to the previously allocated memory blocks; Wherein in response to the memory handling circuitry allocating a given memory block for use by the processing circuitry, the processing circuitry is arranged to be provided with one or more capabilities for use by the processing circuitry in accessing the given memory block.
7. An apparatus according to any preceding claim, wherein each tag indication field is constrained such that once the tag value has been stored in the tag indication field, modification of the tag value within the tag indication field is prohibited unless the associated capability is disabled.
8. An apparatus according to any one of claims 1 to 6, wherein each flag indication field is constrained such that once the flag value has been stored in the flag indication field, any attempt to modify the flag indication field causes a fault signal to be asserted.
9. An apparatus according to any preceding claim, wherein the processing circuit is enabled in at least one operating mode to perform a capability generation operation to derive a new capability from an existing capability, and is constrained when deriving the new capability to ensure that the new capability inherits the tag value associated with the existing capability.
10. An apparatus as claimed in any preceding claim, wherein the capability tracking circuitry is arranged to prevent capabilities having the specified tag value from being written to memory addresses within one or more restricted memory regions.
11. An apparatus according to any preceding claim, wherein the tag indication field is a single bit value, the specified tag value is a first value that can be set within the tag indication field, and a second value that can be set within the tag indication field is used to identify that storage of the associated capability to the memory is not tracked by the capability tracking circuit.
12. An apparatus according to any one of claims 1 to 10, wherein the tag indication field is a multi-bit field, and the tag value used to indicate that a given capability is to be tracked is selected based on an allocation condition that exists when the given capability is provided for use by the processing circuit.
13. An apparatus according to claim 12, wherein the allocation condition is arranged to depend on at least one of: a current memory allocation generation for which capacity is being allocated, wherein the memory handling circuitry is arranged to allocate one or more memory blocks for use by the processing circuitry in a sequence of memory allocation generations; an execution thread of the processing circuitry to which capabilities are being allocated; An allocation identifier associated with a capability allocation process, wherein the capability allocation process is arranged to implement a plurality of capability allocator instances, and the allocation identifier indicates a current capability allocator instance.
14. An apparatus according to claim 12 or claim 13, wherein: The capability tracking circuit includes a plurality of capability trackers; Each capability tracker has at least one associated tag value; and Each capability tracker is arranged to maintain a separate tracking structure providing tracking fields for each of a plurality of memory areas, and is arranged to set the tracking field for a given memory area when at least one capability whose associated tag indication field has the at least one associated tag value is written to the given memory area of the plurality of memory areas.
15. An apparatus according to any one of claims 12 to 14, wherein the tag indication field is formed by a single-bit tag indication subfield and a pre-existing field of the associated capability, and the tag value provided by the tag indication field is determined from a combination of the value of the single-bit tag indication subfield and the value of the pre-existing field.
16. An apparatus according to any preceding claim, wherein the processing circuit is arranged to execute capability determination instructions to determine capabilities for use by the processing circuit, wherein execution of the capability determination instructions causes the tag value of the determined capability to be derived from a control value in a system control register of the apparatus.
17. The apparatus of claim 16, wherein the control value in the system control register is also used to control the specified tag value that the capability tracking circuit is looking for when looking at capabilities written to memory.
18. An apparatus as claimed in any preceding claim, wherein the capability tracking circuitry is arranged to permit, for at least one or more defined memory regions, at least one type of memory access only in relation to valid capabilities whose tag values match one or more predefined values.
19. An apparatus as claimed in claim 18, wherein the capability tracking circuitry is arranged to prevent loading of a valid capability from memory unless the capability has an associated tag value that matches the one or more predefined values.
20. An apparatus as claimed in any preceding claim, further comprising an enable flag storage means, a value of which can be set to selectively enable and disable the capability tracking circuitry.
21. An apparatus according to any preceding claim, wherein the tracking field is a saturating counter and the capability tracking circuit is configured to increment the saturating counter for the given memory region each time a capability whose associated tag indication field has the specified tag value is written to the given memory region.
22. An apparatus according to any preceding claim, wherein the capability tracking circuit is arranged to clear the tracking field for the given memory region when all capabilities written to the given memory region whose associated tag indication field has the specified tag value are invalid.
23. A method of operating a device to track capabilities for revocation, the method comprising: employing processing circuitry to perform operations during which access requests to memory are generated, wherein the processing circuitry generates a memory address for the access request using capabilities, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to the memory using a memory address derived from the pointer value; storing a tag indication field in association with each capability to provide a tag value for distinguishing between a static capability for accessing statically allocated memory and a dynamic capability for accessing dynamically allocated memory; maintaining, using capability tracking circuitry, a tracking structure providing a tracking field for each of a plurality of memory regions; as well as The tracking field is set for a given memory area when at least one capability whose associated tag indication field has a specified tag value is written to a given memory area among the multiple memory areas, wherein the specified tag value indicates that the writing of the associated capability to the memory is to be tracked by the capability tracking circuit to facilitate subsequent revocation of the associated capability.
24. A computer program for controlling a host data processing device to provide an instruction execution environment, the computer program comprising: handler logic to perform operations during which access requests to memory are generated, wherein the handler logic is arranged to generate a memory address for the access request using capabilities, wherein each capability is arranged to indicate a pointer value and constraint information for constraining access to memory using a memory address derived from the pointer value, and wherein a tag indication field is stored in association with each capability to provide a tag value for distinguishing between a static capability for accessing statically allocated memory and a dynamic capability for accessing dynamically allocated memory; as well as Capability tracker logic for maintaining a tracking structure that provides tracking fields for each of a plurality of memory areas, wherein the capability tracker logic is arranged to set the tracking field for a given memory area when at least one capability whose associated tag indication field has a specified tag value is written to the given memory area of the plurality of memory areas, wherein the specified tag value indicates that the writing of the associated capability to memory is to be tracked by the capability tracker logic to facilitate subsequent revocation of the associated capability.
