Device, method and computer-readable storage medium for data processing

By introducing a range check instruction into the memory attribute check system to identify whether the first address and the second address correspond to the same memory attribute entry, the problem of low efficiency of access permission check in the existing system is solved, and fast and accurate memory access is achieved. Licensing checks for real-time mission-critical applications.

CN112602069BActive Publication Date: 2024-09-06ARM LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN201980055295.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Priority Date
2018-10-18
Filing Date
2019-08-20
Publication Date
2024-09-06
Estimated Expiration
2039-08-20

AI Technical Summary

Technical Problem

It is difficult for existing memory attribute checking systems to effectively check whether a memory access request satisfies the specified access permissions in multiple memory attribute entries. Especially in systems that handle real-time critical missions, there are deterministic latency and efficiency issues.

Method used

Provide a device and method, including an instruction decoder, a processing circuit system and a memory attribute checking circuit system, identifying whether a first address and a second address correspond to the same memory attribute entry through a range checking instruction, and supporting a variable size address area, Simplify security checks and speed up access permission checks.

Benefits of technology

Quickly determine whether the first address and the second address correspond to the same memory attribute entry through a single range check instruction, which reduces execution time and improves the efficiency of access permission checking. It is suitable for real-time mission-critical systems and reduces code size and hardware. cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112602069B_ABST
    Figure CN112602069B_ABST
Patent Text Reader

Abstract

The present application discloses an apparatus, method and computer-readable storage medium for data processing. An apparatus (2) includes: an instruction decoder (7) for decoding instructions; a processing circuit system (4) for performing data processing in response to the instructions decoded by the instruction decoder; and a memory attribute checking circuit system (16) for checking whether a memory access request issued by the processing circuit system satisfies access permissions specified in a plurality of memory attribute entries, each memory attribute entry specifying access permissions for a corresponding address region of variable size within an address space. In response to a range check instruction for an address identification parameter for identifying a first address and a second address, the instruction decoder (7) controls the processing circuit system to set a status value in at least one software-accessible storage location (12, 13), the status value indicating whether the first address and the second address correspond to the same memory attribute entry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The technology in this article relates to the field of data processing. Background Art

[0002] The data processing apparatus may have a memory attribute checking circuit system for checking whether a memory access request satisfies access permissions specified in one of a plurality of memory attribute entries. For example, the access permissions may specify properties of corresponding regions of the address space, such as whether these regions are restricted to read-only access or can be read and written; or specify which operating modes of the processing circuit system can access the region. This can be used to enforce security constraints when accessing certain data within the memory system. Summary of the invention

[0003] At least some examples provide a device comprising: an instruction decoder for decoding instructions; a processing circuit system for performing data processing in response to the instructions decoded by the instruction decoder; and a memory attribute checking circuit system for checking whether a memory access request issued by the processing circuit system satisfies access permissions specified in multiple memory attribute entries, each memory attribute entry specifying access permissions for corresponding address regions of variable size within an address space; wherein: in response to a range checking instruction, the range checking instruction specifies address identification parameters for identifying a first address and a second address, the instruction decoder is configured to control the processing circuit system so as to set a status value in at least one software-accessible storage location that can be accessed by at least one type of instruction supported by the instruction decoder, the status value indicating whether the first address and the second address correspond to the same memory attribute entry.

[0004] At least some examples provide a data processing method, which includes: using an instruction decoder to decode a range check instruction, the range check instruction specifying address identification parameters for identifying a first address and a second address; and in response to the decoded range check instruction, controlling a processing circuit system to set a status value in at least one software-accessible storage location that can be accessed by at least one type of instruction supported by the instruction decoder, the status value indicating whether the first address and the second address correspond to the same memory attribute entry among a plurality of memory attribute entries, each memory attribute entry specifying access permissions for a corresponding address region of a variable size within a location space.

[0005] At least some examples provide a computer program for controlling a host data processing device to provide an instruction execution environment for executing instructions of a target code; the computer program includes: instruction decoding program logic for decoding the instructions of the target code and controlling the host data processing device to perform data processing in response to the decoded instructions; and memory attribute checking program logic for checking whether a memory access request triggered by the decoded instructions of the target code satisfies access permissions specified in multiple memory attribute entries, each memory attribute entry specifying access permissions for a corresponding address area of ​​variable size within a simulated address space, the simulated address space being simulated by the instruction execution environment; wherein: in response to a range checking instruction, the range checking instruction specifies an address identification parameter for identifying a first address and a second address, the instruction decoding program logic is configured to control the host data processing device to set a status value in at least one software-accessible storage location that can be accessed by at least one type of instruction supported by decoding of the instruction decoding program logic, the status value indicating whether the first address and the second address correspond to the same memory attribute entry.

[0006] At least some examples provide a computer-readable storage medium storing the above-mentioned computer program. The storage medium may be a non-transitory storage medium. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0008] Figure 1 An example of a data processing apparatus having memory attribute checking circuitry is illustrated;

[0009] Figure 2 shows in more detail an example in which the memory attribute checking circuitry includes a memory protection unit that checks memory accesses against access permissions defined in a memory protection table stored in the memory system;

[0010] Figure 3 shows an example of overlapping permissions set by a memory protection unit and a security attribute unit;

[0011] Figure 4 illustrates examples of different operating states of processing circuitry, including different domains, modes, and privilege levels;

[0012] Figure 5A and Figure 5B An example of a range checking instruction is shown;

[0013] Figure 6shows an example of information stored to a destination register of a range check instruction;

[0014] Figure 7 illustrates multiple variations of range checking instructions;

[0015] Figure 8 An example of using a comparator to find whether a first address and a second address correspond to the same memory attribute entry is shown;

[0016] Fig. 9 illustrates a method of processing a range check instruction; and

[0017] Fig.10 Picture shows the simulator example. DETAILED DESCRIPTION

[0018] A device has an instruction decoder for decoding instructions, and a processing circuit system for performing data processing in response to the instructions decoded by the instruction decoder. A memory attribute checking circuit system is provided to check whether a memory access request issued by the processing circuit system satisfies the access permissions specified in two or more memory attribute entries. Each memory attribute entry may specify access permissions for a corresponding address region of variable size within an address space. Thus, because each memory attribute entry may correspond to an address region of variable size, it is not predetermined which addresses map to a particular memory attribute entry. Support for entries of variable size may be useful to allow relatively large address regions to be covered in a single memory attribute entry, thereby reducing the number of required memory attribute entries.

[0019] The instruction decoder of the device supports decoding of a range check instruction, which specifies an address identification parameter for identifying a first address and a second address. In response, the instruction decoder controls the processing circuit system to set a state value in at least one software-accessible storage location that can be accessed by at least one type of instruction supported by the instruction decoder, and the state value indicates whether the first address or the second address corresponds to the same memory attribute entry. Thus, the instruction allows the software to gain insight into whether both the first address and the second address correspond to the same memory attribute entry or to different memory attribute entries. Such an operation may be considered less common because, typically, when checking memory attribute data for a memory access specifying a given target address, the only information visible to the software based on the memory attribute check is an indication of whether the memory access was successfully executed or a fault was triggered due to unspecified access permission. It is usually not of interest to which specific memory attribute entry a given address corresponds to.

[0020] However, it is recognized that information about whether the first address and the second address correspond to the same memory attribute entry can be useful for certain security check operations, for example, allowing a software process to check whether each word in an array defined by the first address and the second address is accessible by a particular software process. By providing a range check instruction, the range check instruction can make the software accessible to an indication of whether the first address and the second address both correspond to the same memory attribute entry, which can simplify such security checks. If the addresses do correspond to the same memory attribute entry, when the memory attribute entry indicates that the corresponding area of ​​the address space is accessible by the relevant software, this can imply that all addresses between the first address and the second address are accessible without having to check each address individually, which can greatly improve the speed of performing permission checks. Another reason why this may be useful for checking whether the first address and the second address correspond to the same memory attribute entry may be that for systems performing certain real-time critical tasks, it is very important to perform tasks with deterministic latency, because if it can be known in advance that a certain address range defined by the first address and the second address both correspond to the same memory attribute entry, it can be expected that a fault will not be triggered during the processing of the address range due to entering a different address area for which the memory attribute entry has not yet been defined.

[0021] An alternative to checking whether two addresses correspond to the same memory attribute entry is to provide an instruction in the instruction set architecture that specifies a single address, for which execution of the instruction results in an indication that the entry number of a particular memory attribute entry matching the address is returned to a storage location accessible to software. However, a range check instruction that specifies a first address and a second address as described above has a number of advantages. For example, because the instruction can simply return a status value indicating whether the first address and the second address correspond to the same memory attribute entry, rather than returning a region number identifying a particular entry that matches a given address, this means that the storage capacity required to store the results of the instruction can be better scaled by a system that supports a large number of different memory attribute entries, because (for example) the status value can be as small as a single bit and independent of the number of memory attribute entries provided, rather than needing a multi-bit value with a size that increases according to the total number of entries.

[0022] In addition, the range check instruction specifying the first address and the second address can provide information about whether the first address and the second address correspond to the same memory attribute entry in a single instruction, without the need for two separate instructions to query the entry number associated with the first address and the second address. Providing a range check instruction also avoids the need for a comparison instruction to compare the entry numbers returned by two separate area number query instructions. The search process for finding the group of memory attribute entries to check which entry corresponds to a given address may take a certain amount of time. Although such a security check operation for checking whether an address corresponds to the same memory attribute entry may account for a relatively small proportion of the overall execution time of the program, it is still on the critical path of some latency-sensitive tasks, so the reduction in workload in terms of performing related checks with fewer instructions is particularly beneficial for certain real-time critical applications. In some applications, it may be necessary to perform a license check in a large number of functions within the software. Providing a single range check instruction may be important for reducing the code size in a constrained environment.

[0023] The range check instructions described may be particularly useful for systems in which the memory attribute checking circuitry permits the variable size of the corresponding address region of a given memory attribute entry to be a non-power-of-2 number of bytes. This may be contrasted, for example, with a hierarchical page table in which each page table entry may correspond to a fixed power-of-2 number of bytes of a page for which, in some cases over a series of multi-level lookups in a page table walk operation, different portions of the address may index into a desired specific page table entry. In such a hierarchical page table, it is relatively unlikely that a data array may belong entirely to one page table entry. In contrast, using a memory attribute checking method in which a single entry may correspond to a non-power-of-2 number of bytes, this may allow an address region of arbitrary size to be defined in a single entry, for example, using information specifying the start and end addresses of the address region (e.g., using explicitly identified boundary addresses or using a base address and size). Thus, using an approach that supports variable region sizes other than powers of 2 numbers of bytes, it is more likely that system users will tend to define their address regions so that certain arrays of data belong entirely to a single region, and thus the range checking instructions described above are particularly useful on such systems which permit regions of non-power-of-2 byte sizes.

[0024] Similarly, the processing circuitry may permit the difference between the first address and the second address identified by the range checking instruction to be a number of bytes other than a power of two.

[0025] The first address and the second address may be identified by the range checking instruction in a variety of different ways. In one example, the address identification parameter may specify a base address of the first address and specify an offset for identifying the difference between the first address and the second address. The base address and the offset may be specified in a register identified by the range checking instruction. Alternatively, the base address may be specified in a register and the offset may be specified as an immediate value.

[0026] In another example, the offset can be specified as a multiple and a size value that, when multiplied, give the offset. One of the multiple and the size value can be a variable parameter specified by the range check instruction, where the variable parameter is identified, for example, by an immediate value, or by a value stored in a register specified by the range check instruction. On the other hand, the other of the multiple and the size value can be specified as any of a fixed value, an immediate value specified by the range check instruction, or a value stored in a register specified by the range check instruction.

[0027] In general, it may be useful to specify the first address via a base address and specify the second address using an offset added to the base address, because this means that there is no ambiguity about which address is the low address and the high address, which may make it easier to perform a query to determine whether the first address and the second address are mapped to the same memory attribute entry. It may be useful to specify the offset as a multiple and a size value multiplied by the product, because in some cases the software executing the instruction may find it more convenient to specify the size of the array according to the number of elements of a given size rather than according to the total offset in the address space. Thus, variants of the multiple and / or size specification of the instruction can be used to make the programming or compilation of the code simpler. This can also improve the performance and size of the executable code generated.

[0028] Alternatively, another way to identify the address identification parameter may be to specify a first register from which the first address is read and a second address from which the second address is read. Thus, in this case, both the first address and the second address may be explicitly specified by writing the first address and the second address to the first register and the second register before executing the range check instruction.

[0029] Similarly, different architectures may provide different options for which the storage location is a software accessible storage location to which the state value is written in response to a range check instruction. In some cases, the software accessible storage location may be a storage location stored in memory. However, it may be useful for embodiments to provide the software accessible storage as a register, as this may make subsequent reading of the state value faster, which may speed up security check operations of the type described above.

[0030] Thus, in one example, the at least one software accessible storage location may include a target register specified by the range checking instruction. For example, the target register may be specified as any one of a plurality of general purpose registers of the processing circuit system. The selected target register may then be used as a source register for a subsequent instruction for performing an action conditional on whether the first address and the second address correspond to the same memory attribute entry.

[0031] Alternatively, or in addition to writing the state value to the target register, another method is to set the state value by updating at least one conditional state indication in a control register. For example, the control register may store at least one conditional state indication indicating the nature of the result of the previous conditional state indicator generating instruction. For example, some instructions may trigger the setting of a conditional state flag, which may indicate a property, such as whether the processing result is zero, the processing result is a negative number, or whether a positive or negative overflow has occurred. The instruction decoder may support at least one conditional instruction, which triggers the processing circuit system to perform a conditional operation based on whether at least one conditional state indication stored in the control register satisfies a test condition. Thus, some instructions may directly access the conditional state indication so as to trigger the execution of some actions based on the result of the previous instruction. Thus, by using the conditional state indication to provide a state value (the state value indication depends on whether the first address and the second address are mapped to the same memory attribute entry), this may allow subsequent instructions to perform conditional operations directly in a single instruction, rather than requiring an intervening instruction to compare the value placed in the general register before the subsequent conditional instruction having a condition dependent on the condition obtained from the comparison instruction. This can allow security check operations to be performed faster.

[0032] In some examples of range checking instructions, the instruction may update only the target register without updating any condition status indication, or vice versa, where only the condition status indication is set without setting the value in the general target register. Other variants may update both types of registers so that a subsequent conditional instruction may directly test the condition code in the control register to determine whether a previous range checking instruction found that the first address and the second address map to the same memory attribute entry, but other information may also be derived from the target register of the range checking instruction.

[0033] In response to the range check instruction, at least when both the first address and the second address map to the same memory attribute entry, it may be useful for the processing circuit system to store attribute information derived from the matching memory attribute entry corresponding to the first address and the second address in at least one software accessible storage location. For example, the attribute information may indicate whether access to the address region corresponding to the matching memory attribute entry will be allowed in a given operating mode of the processing circuit system. Such attribute information may allow certain forms of security checks to be performed using a single instruction in addition to (or in combination with) an indication of whether the first address and the second address map to the same memory attribute entry.

[0034] In one example, the attribute information may be recorded as an additional field separate from a status value indicating whether the first address and the second address map to the same memory attribute entry.

[0035] In other examples, the indication of the attribute information can be combined with a state value indicating whether the first address and the second address are mapped to the same memory attribute entry. For example, a single state indicator can be set to a first value when the following two conditions are met: (i) both the first address and the second address are mapped to the same memory attribute entry; and (ii) the matching memory attribute entry specifies that memory access to the corresponding address region defined by the entry will be permitted, and if either of these conditions is not met, the state indicator can be set to a second value. Thus, in such an embodiment, the same state indicator can serve as both a state value and attribute information.

[0036] In one example, the processing circuit system may have a plurality of different operating states (e.g., different modes, domains, or privilege levels) in which the processing circuit system may operate. In response to at least one variant of the range check instruction, the processing circuit system may derive attribute information to be written to a storage location accessible to the software based on access permissions, which will be imposed on memory accesses to the corresponding address region of the matching memory attribute entry when in an operating state different from the current operating state of the processing circuit system. Thus, instead of checking whether access is permitted in the current operating state, the instruction instead gives an indication of whether access is permitted if the system is in a different operating state. Such variants of the range check instruction that permit cross-operation state checks may be particularly useful for preventing security attacks based on the confused agent problem in the following situations: an attacker with untrusted software may attempt to trick trusted software into performing improper operations by passing a pointer to, for example, an out-of-bounds array to trusted software. The cross-operation-state variant of the range-check instruction can therefore be used by trusted code to check whether a value passed to it by untrusted code is valid, for example, by checking whether an address calculated based on that value maps to the same memory attribute entry, and whether attribute information derived for the attacker's operating state would indicate that access would be permitted.

[0037] In one particular example, the processing circuit system may have multiple operating domains, including a secure domain and a less secure domain, and within each secure domain, the processing circuit system may operate in one of a plurality of modes and one of a plurality of privilege levels. Some modes may be associated with operations in a particular privilege level. Other modes may support operations at two or more different privilege levels, depending on a current privilege level indicator that may be stored in a particular control register. In order to allow multiple different types of security check operations, it may be useful for the instruction decoder to support at least one of the following variants of the range check instruction: a first variant, the attribute information of which specifies whether memory access to addresses in a range between a first address and a second address is permitted when the processing circuit system is in a current security domain, and a privilege level associated with a current mode; a second variant, the attribute information of which specifies whether memory access to addresses in a range between a first address and a second address is permitted when the processing circuit system is in a security domain different from the current domain, and a privilege level associated with the current mode when operating in different security domains; a third variant, the attribute information of which specifies whether memory access to addresses in a range between a first address and a second address is permitted in the current security domain, and a privilege level different from the privilege level associated with the current mode; and a fourth variant, the attribute information of which specifies whether memory access to addresses in a range between a first address and a second address is permitted when the processing circuit system is in a security domain different from the current domain, and a privilege level different from the privilege level associated with the current mode. In some embodiments, in order to provide programmers or compilers with flexibility in selection, at least two of the first to fourth variations may be supported by the instruction decoder.

[0038] Thus, the first variant allows security checks based on properties associated with the current domain and mode.

[0039] The second variant and the fourth variant allow cross-domain checks to check whether a security domain different from the current domain will be allowed to access the address range between the first address and the second address. For example, some systems may support maintaining different sets of memory attribute entries for security domains and less secure domains, respectively, and therefore for the second variant and the fourth variant of the range check instruction, the check performed to derive attribute information may be based on a set of memory attribute entries different from the set of memory attribute entries for the current domain. When the instruction decoder supports at least one of the second variant and the fourth variant of the range check instruction, it may be useful for different security domains to include less secure domains. In order to prevent the less secure domain from detecting security permissions, if there is an attempt to execute one of the second variant and the fourth variant of the instruction when operating in the less secure domain, the processing circuit system may trigger a signaling of a fault. Thus, these variants may allow a more secure domain to check whether access to addresses between the first address and the second address has been granted for the less secure domain, which may be useful to avoid confusion agent attacks.

[0040] Similarly, for the third variant and the fourth variant, the attribute information may be based on whether memory access to addresses in a range between a first address and a second address is permitted in a privilege level different from the current privilege level of the processing circuit system. In addition, if the different privilege level is a privilege level less privileged than the current privilege level, this type of variant may be particularly useful. In this case, if there is an attempt to execute one of the third variant and the fourth variant of the range check instruction when the processing circuit system is in at least one predetermined privilege level (for which there is at least one privilege level more privileged than the at least one predetermined privilege level), a fault may be triggered. These variants of the instruction may be useful to allow a more privileged code to check whether a value passed from a less privileged code to a more privileged code can be trusted.

[0041] It should be appreciated that it is not necessary for a given implementation of a processing system to support all four variants.

[0042] In some examples, the memory attribute checking circuit system can check, for a given memory access request, whether the memory access request satisfies the access permissions specified in the first memory attribute entry set and the access permissions specified in the second memory attribute entry set. For example, there can be multiple different types of memory attribute entries associated with different functions, such as a first entry set that provides memory protection information (e.g., defines read-only or readable and writable areas, or specifies which privilege levels can access corresponding address areas), and a second memory attribute entry set that can specify which security domain is associated with a given address area.

[0043] Thus, in some examples, in response to a range check instruction, the instruction decoder may control the processing circuitry to set at least one software accessible storage location: a first state value indicating whether the first address and the second address correspond to the same entry of the first set of memory attribute entries; and a second state value indicating whether the first address and the second address correspond to the same entry of the second set of memory attribute entries. Thus, in a single instruction, two sets of memory attribute entries may be looked up, and an indication of whether the entire range of addresses maps to the same entry in the two sets of memory attribute entries may be returned.

[0044] As described above, one of the memory attribute entry sets may be a set of memory protection entries. The above range check instruction may be particularly useful in an embodiment in which a memory access request targets a given memory system and a memory protection entry for controlling access to the memory system is provided in a memory protection table, which is itself stored in the memory system. This method is relatively uncommon, but allows support for a memory protection table with a relatively large number of memory protection entries without greatly increasing the hardware cost of storing and managing such a large number of entries. In a system in which a memory protection table is stored in a memory system so that the number of supported memory protection entries can be increased, the above type of range check instruction may be particularly useful, because an alternative to providing an instruction that returns which specific entry number is associated with a given address may be difficult to scale with the increase in the size of the memory protection table, especially in an embodiment in which the instruction is intended to return information about address mappings in a plurality of different memory attribute entry sets as described above. In addition, in a system in which memory protection entries are stored in a memory system, it may be useful to provide a memory protection cache storage circuit system to cache at least one memory protection entry of a memory protection table obtained from the memory system. If an alternative instruction is used that returns the entry number of the memory protection entry mapped to a given address, such an instruction will imply that the cache storage needs to cache the entry number associated with each cache entry, so that an instruction for querying the entry number associated with a given address can quickly access the entry number associated with the cached memory protection entry without searching the memory protection table within the memory system. In contrast, with the above-mentioned range checking instruction, such caching of entry numbers is not necessary because it can be determined whether a first address or a second address maps to the same entry without requiring the cache entry number itself. This can be particularly useful because entries in the memory protection cache storage circuit system can be implemented as register-based storage, and therefore by eliminating the need for cache entry numbers, this can save a large number of bits in each cached entry, which provides a significant circuit area reduction.

[0045] In systems using memory-based memory protection tables, in addition to the memory protection tables stored in memory, it is also possible to provide some configuration registers in hardware to store at least a subset of memory protection entries. Some statically allocated registers that do not act as caches (but are instead allocated to provide fixed memory protection entries of certain properties that define commonly used areas of the address space) may be useful to improve performance. Thus, in some cases, range checking instructions may also query some memory protection entries stored in such configuration registers.

[0046] Alternatively, range checking instructions may be supported in a system that does not store any memory protection entries in the memory system itself, but instead implements the entire set of memory protection entries using configuration registers.

[0047] Another example of a set of memory attribute entries may be a security attribute entry that specifies access permissions that may indicate which of a plurality of security domains are associated with a corresponding address region. These security attribute entries may be implemented in addition to the memory protection entries described above. For example, checking the security domain associated with a given address region may be useful for checking in which security domain the processing circuit system should operate when code is executed from a given address region. In addition, when a memory access request is issued from a given security domain, the security attribute entry may be checked. For example, a memory address region associated with a less secure domain may be accessible in a secure domain, while a region associated with a secure domain may be accessible in a secure domain, but may be inaccessible when in a less secure domain.

[0048] In response to at least one variant of the range check instruction, at least when the first address and the second address both correspond to the same security attribute entry, attribute information provided in at least one software-accessible storage location can be exported from the security domain designated as associated with the corresponding address region by matching security attribute entries corresponding to the first address and the second address.

[0049] As described above, in some systems, the memory attribute checking circuit system may support the above-mentioned memory protection entries and security attribute entries. In this case, it may be useful for at least one variant of the range checking instruction to derive information from a combination of a matching memory attribute entry corresponding to a first address and a second address and a matching security attribute entry corresponding to the first address and the second address. For example, in response to this variant of the range checking instruction, the instruction decoder may store at least one combined permission indicator to at least one software-accessible storage location, wherein the at least one combined permission indicator specifies in a single indicator whether the access permission in the matching memory protection entry and the access permission in the matching security attribute entry both specify that a given type of memory access is allowed. For example, such a combined permission indication may be stored in a conditional status indication in a control register as described above, so that subsequent conditional instructions can directly test the combined indicator to determine whether subsequent operations can be performed.

[0050] We can expect that checking whether both the first address and the second address are mapped to the same memory attribute entry in a single instruction can be performed relatively slowly, especially when the memory address region can have any non-power-of-2 size as described above. However, in practice, the inventors recognize that a range check operation for returning status information identifying whether the first address and the second address are mapped to the same memory attribute entry can actually be performed with a latency similar to a lookup operation, which is performed to identify the memory attribute entry corresponding to a single address. In practice, the memory attribute check circuit system can have at least one set of comparators, wherein each set of comparators includes a lower limit comparator for comparing the target address of the memory access request with the lower limit address of a given memory attribute entry; and an upper limit comparator for comparing the target address of the memory access request with the upper limit address of the given memory attribute entry. For a conventional memory access request, if both the lower limit comparator and the upper limit comparator provide a positive result, the given memory attribute entry can be identified as matching the target address of the memory access request. For example, the lower limit comparator can determine whether the target address is greater than or equal to the lower limit address, and the upper limit comparator can determine whether the target address is less than or equal to the upper limit address.

[0051] We can expect that for the range check instruction, in two separate searches, the first address and the second address must be sequentially supplied to each group of comparators as the target address. However, the inventors recognize that in response to the range check instruction, the instruction decoder can control the processing circuit system to supply the first address as the target address to the lower limit comparator in each group of comparators, and supply the second address to the upper limit comparator in each group of comparators in parallel. Thus, although it is generally expected that the two comparators in each set will compare the same address with the lower limit and upper limit addresses respectively for conventional memory access, for the range check instruction, these comparators can be adapted to receive different inputs so that the comparison based on the first address and the second address can be performed in parallel. If any one of the sets of comparators returns that both the lower limit comparator and the upper limit comparator in the same group of comparators recognize the positive result of the comparison, a hit signal can be generated to indicate that the first address and the second address are mapped to the same entry. Thus, except for the logic for supplying the first address and the second address to the lower and upper bound comparators instead of supplying the target address to two comparators, the remaining logic for looking up the memory attribute entry can be the same as the logic that would normally be provided for handling lookups for conventional memory access operations, and thus range checking instructions can actually be supported with relatively little additional area burden. This means that range checking instructions of the type described above can have a significant performance improvement over the alternative in which two separate instructions individually check which memory attribute entry maps to a single address.

[0052] A lookup method in which a lower comparator and an upper comparator compare a first address and a second address, respectively, may require a priori knowledge of which of the first address and the second address is a lower address, so that the lower address may be supplied to the lower comparator and the upper address may be supplied to the upper comparator.

[0053] Different architectural implementations may use different methods to ensure that the first address is always lower than the second address. In some examples, the encoding of the range check instruction itself may constrain the first address to be lower than the second address. For example, a variant of the above instruction (for which the second address is specified as an offset added to the first address) may ensure that the second address is higher than the first address by definition. In this case, there is no need to provide a full comparison of the first address and the second address to check which one is lower. In general, it can be assumed that the second address is higher than the first address unless adding the offset to the first address causes an overflow or regression (wraparound). For example, if the first address is relatively high in the allowed address range, adding the offset may cause the second address to regress to a relatively low address in the address range. For additions that cause such regressions, a fault may be signaled, or a status value may simply be returned with a value indicating that the first address and the second address do not correspond to the same memory attribute entry.

[0054] Alternatively, other methods may allow unconstrained specification of the first address and the second address, for example, in the above variant, two addresses are specified in the corresponding registers so that there is an opportunity to make the second address lower than the first address. In this case, one method may be to provide logic for comparing the first address and the second address, and then determine which one is lower, and supply the lower of the first address and the second address to the lower limit comparator in each set and the other address to the upper limit comparator (this logic may also be optionally provided for a variant with constrained specification of the first address and the second address, although it is not necessary). However, in practice, this logic may not be reasonable in terms of circuit area, and the opposite is true: if the instruction is defined with a second address lower than the first address, some architectures may simply define that the result of the instruction may be unpredictable.

[0055] Thus, to ensure safety by preventing any execution of instructions when the second address is lower than the first address, some embodiments may trigger the communication of a fault if an attempt is made to execute a range-check instruction where the second address is lower than the first address. Alternatively (or in addition to the communication of a fault), if an attempt is made to execute a range-check instruction where the second address is lower than the first address, the processing circuitry may return a status value indicating that the first address and the second address do not correspond to the same memory attribute entry (regardless of whether any hit signal is generated by any comparison logic used to look up the memory attribute entry).

[0056] A corresponding computer program may be provided for controlling a host data processing device to provide an instruction execution environment for executing instructions. The computer program may include instruction decoding program logic and memory attribute checking program logic that correspond functionally to the above-mentioned instruction decoder and memory attribute checking circuit system. Thus, the range checking instructions in the program executed in the instruction execution environment simulated by the computer program may be handled in a manner similar to the range checking instructions in the program executed on the hardware, and the hardware actually includes the above-mentioned instruction decoder and memory attribute checking circuit system. The emulator computer program may present an instruction environment similar to the instruction environment that may be provided by the actual hardware device to the software executed on the emulator computer program, even if there may not be any actual hardware that provides these features in the host computer executing the emulator computer program. The functions of the above-mentioned hardware architecture may be simulated by providing program logic (e.g., a set of instructions or data structures), which enables a general host computer to execute the code intended to be executed on a device with the above-mentioned memory attribute checking support in a manner compatible with the results achieved on the device actually having the hardware. The emulator computer program for controlling the host data processing device may be stored on a storage medium. The storage medium may be a non-temporary storage medium.

[0057] Figure 1A data processing system 2 is schematically illustrated, which has a processing circuit system 4 for performing data processing in response to instructions. For example, the processing circuit system 4 can be a CPU, a DSP, a GPU, or other processing components of the data processing system. The processing circuit system 4 may include an instruction fetch unit 5 for fetching instructions from a memory system 10 for processing by the processing circuit system; and an instruction decoder 7 for decoding the fetched instructions to generate control signals for controlling execution units 6, 8 to perform data processing operations in response to the decoded instructions. For example, the execution unit may include an arithmetic / logic unit (ALU) 6 for performing arithmetic or logic operations on operands fetched from registers 12, 14 to generate result values ​​that can be written back to the registers. The execution unit may also include a load / store unit 8 for performing load / store operations to transfer data between registers 12, 14 and the memory system 10. The registers may include a number of different types of registers, including general purpose (integer) registers 12 for storing integer values ​​for processing by the processing circuit system 4, and floating point registers 14 for storing values ​​represented using floating point representation. The registers accessible by the processing circuit system 4 may also include registers not shown in the figure for the sake of brevity. Figure 1 , for example, vector registers for storing vector operands comprising a plurality of independent data elements, and / or control registers 13 for storing various control parameters for controlling the operation of the processing circuit system 4, such as conditional flags that may be checked by a conditional instruction to determine whether to perform a conditional operation, a program counter that stores an address indicating a current execution point, and control registers for controlling, for example, exception handling.

[0058] The memory system 10 may include one or more levels of cache and a main memory. The memory system 10 may be accessed by the processing circuit system 4 by executing a load instruction or a store instruction, wherein the load instruction triggers the load / store unit 8 to issue a memory access request for loading data from the memory system 10 into the registers 12 and 14, and the store instruction is used to trigger the load / store unit 8 to issue a memory access request for storing data from the registers 12 and 14 into the memory system 10. In addition, the instruction fetch unit 5 issues a memory access request to fetch instructions from the memory system 10. Each memory access request may specify a target address of a location to be accessed. In this example, the target address is a physical address that directly specifies the location to be accessed, so that address translation is not required.

[0059] A memory protection unit (MPU) 20 is provided to check whether a memory access request is allowed to be serviced by the memory system 10 based on the target address. The MPU 20 may store or access a plurality of memory protection entries that define access permissions for corresponding address regions of the address space. For example, the access permissions may specify whether a given region of the address space is a read-only region or is readable and writable, and / or may define which privilege levels of the processing circuit system 4 are allowed to access the corresponding address region. Figure 1 As shown in , in some examples, the MPU 20 may include two separate MPUs: a secure MPU 21 and a less secure MPU 23 corresponding to the secure domain and the less secure domain, respectively. When the processing circuit system 4 operates in the secure domain, the secure MPU 21 may be accessed, and when operating in the less secure domain, the less secure MPU 23 may be accessed.

[0060] In addition to the MPU 20, the memory attribute checking circuit system 16 may also include a security attribute unit (SAU) 42, which includes a memory security configuration register storing security protection entries that define secure and less secure areas in the address space. The target address of the memory access request is checked by the SAU 42 against the area definition data of the security protection entry, and the processing circuit system 4 may be restricted to accessing the secure area of ​​the address space only when operating in the secure operation domain (the less secure area of ​​the address space may be accessible in the secure domain or in the less secure domain). The access permissions defined by the security protection entries of the SAU 42 may apply permissions that are orthogonal to the permissions defined by the MPU 20 in the memory protection entries. That is, access granted by the MPU 20 may still be denied by the SAU 42, or vice versa. Both the memory access request initiated by the instruction fetch unit 5 and the memory access request initiated by the load / store unit 8 may be subject to inspection by the MPU 20 and the SAU 42. Although in Figure 1 2 and 42 as operating sequentially, but some embodiments may provide for parallel lookups of the MPU 20 and SAU 42 for memory accesses issued by a process security to improve performance.

[0061] The MPU 20 checks whether a memory access request issued by the processing circuit system satisfies the access permissions specified in the plurality of memory protection entries. Each memory protection entry may correspond to a specific address region of variable size within the address space. The corresponding address region of a given memory protection entry may be defined by a start address and an end address, which are identified via parameters of the given memory protection entry. Unlike the page table used by the memory management unit (MMU), for the MPU, the region corresponding to the memory protection entry may have a variable size, which may be permitted to be a number of bytes other than a power of 2. By this method, it is ensured that a memory address region of arbitrary (non-power of 2) size can be defined using a single memory protection entry to avoid the risk of page movement and page faults whenever an address access crosses a page address boundary. This makes the MPU more suitable for systems designed to process real-time applications. In addition, the MPU may store memory protection entries in registers provided locally within the MPU, which may be quickly accessed, again assisting real-time processing, and avoiding the need to store large page tables with a hierarchical structure within the memory system, which may be important for systems with limited RAM.

[0062] In one example, a register may be used to specify memory protection entries for the MPU 20, and the register may be directly connected to a set of comparators in parallel when comparing a target address to be accessed with a region identification parameter for each memory protection entry stored in the register. This approach may be suitable for systems where only a limited number (e.g., 8 or 16) of memory protection entries need to be defined. In a system with a separate secure MPU 21 and a less secure MPU 23, a separate set of registers may be provided for defining secure memory protection entries and less secure memory protection entries, respectively, where the relevant set of entries for the current operating domain is selected when searching the MPU 20.

[0063] However, for an MPU in which all memory protection entries are stored in registers, the power and area associated with the MPU may be dramatically amplified if the number of memory protection entries supported by the MPU is increased. For systems that require a large number of memory protection entries (e.g., because the limited number of memory protection entries in a register-based MPU may have a severe impact on performance or the protection that can be provided), it may be useful to expand the number of entries, supporting this expansion by providing a memory protection table within the memory system 10. Thus, by providing the memory protection table in the same memory system to which access is governed by the MPU 20, this provides flexibility for providing a larger number of memory protection entries than is practical for a typical MPU based on a register storage area that defines the data for each entry that is compared to a target address in parallel. It may be counterintuitive that moving the memory protection table into the memory system (which is typically slower to access than registers) will provide improved software performance. However, while accessing individual memory protection entries from the memory system may be slower, overall performance can be improved by avoiding software workarounds for handling situations where the number of entries supported by the MPU in the hardware is insufficient to handle the software's requirements, which would otherwise incur a significant performance cost by encountering frequent exceptions due to accessing undefined areas of the address space. With the memory protection table provided in memory, the hardware cost drops dramatically with the number of entries.

[0064] Additionally, by allowing each region to have an arbitrary size corresponding to a number of bytes other than a power of 2, this means that each region can cover a large amount of memory, and there is no need to divide regions intended to have the same access permissions into multiple separate entries, which would otherwise risk causing memory protection failures when addresses cross region boundaries. This makes the MPU better than the MMU at servicing real-time applications, which require critical operations to be handled with fast and / or deterministic response times.

[0065] This method of using memory to store memory protection entries can be useful for multiple purposes. For example, a software may need to define a larger number of different address regions through different access permissions, which are different from the access permissions supported in the MPU's registers in terms of the number of protection entries supported. If a memory protection table is not provided in the memory, at any given time, at least some parts of the address space required for access by the software will not currently have corresponding memory protection entries defined for it. This will mean that accessing addresses in currently undefined areas of the address space will trigger an exception, which will then require software to intervene and reconfigure the MPU's registers so that the parameters previously defined for different areas are overwritten by the parameters required for the area that needs to be accessed now. If the latter instruction then accesses the previously defined area that has been overwritten, this can then cause the MPU configuration to switch back again. This constant switching of the contents of the MPU registers (which requires an exception to trigger the switch each time) can greatly impair performance.

[0066] Another example may be where a processor needs to execute multiple pieces of software that do not trust each other but need to share data between them. In order to be able to share data, a given software may wish to partition portions of the address space so that other processes can only access restricted portions of the address space, but providing this fine level of control over access to the address space may require defining other address regions, and there may not be enough spare memory protection entries supported by the MPU in the hardware to allow such fine control. Thus, in practice, the same data may end up being copied to multiple portions of the address space, with one copy in the portion accessed by a first software and another copy in the portion accessed by a second software, resulting in wasted time performing the copy and inefficient use of available memory capacity, which may be a particular problem in systems with constrained memory resources.

[0067] These problems may be avoided by providing a memory protection table in memory to support a larger number of individual memory protection entries, thereby improving performance.

[0068] thus, Figure 2A second example of a processing system 2 is shown in which a memory protection table 22 is provided in the memory system 10 for access by the MPU 20. By this example, access permissions for controlling whether the processing circuit system 4 is allowed to access a given address region can be defined by the MPU 20 in two ways. The memory protection table 22 can be stored in the memory system, including a plurality of entries, each entry defining access permissions for a corresponding address region. The MPU 20 has an MPU memory access circuit system 24 for initiating a memory access request to the memory system 10 in order to obtain information from the MPU table 22. The MPU memory access circuit system 24 has a table lookup circuit system 26 for performing the required comparison to identify whether the MPU table 22 includes an entry for an address region including a target address, which is specified by a memory access request received from the processing circuit system 4. The memory system 10 can store more than one MPU table, each table 22 being associated with a corresponding software process. An active table identifier is stored in an active table identifier register (or register set) 28, which identifies which particular MPU table is to be accessed using the MPU memory access circuitry 24. For example, the active table identifier register 28 may specify a base address 30 of the currently active MPU table, and may also optionally specify the size of the active table. An MPU cache memory 32 is provided within the MPU for caching selected entries of (one or more) MPU tables from the memory system 10 so that if the same entry is needed again, it can be accessed more quickly. For example, the MPU cache memory may include a collection of registers for locally storing entries of the MPU tables, which has reduced access latency compared to backing storage of the MPU tables 22 in the memory system 10.

[0069] Another way to provide access permissions for controlling access to the memory system 10 may be to statically define configured memory protection entries in the static MPU register store 36. The processing circuit system 4 may support instructions for configuring the contents of the static MPU register store 36, such as dedicated instructions specifically for accessing the static MPU register store, or may use a more general store operation performed by the load / store unit 8, which specifies as the target address an address that has been mapped to a memory mapped register provided for the static MPU register store 36. In general, in the absence of a reset or power-off event that results in the loss of information stored in the static register store 36, once an MPU parameter reconfiguration operation (e.g., one of these memory mapped load / store operations or a dedicated reconfiguration instruction) has been performed to fill the contents of the static MPU register store 36 so as to define a given memory protection entry corresponding to a given address region, the given memory protection entry remains in the static MPU store 36 until another MPU parameter reconfiguration operation changes the contents of the entry. This is in contrast to the MPU cache memory 32, for which the contents may change over time according to a cache replacement policy even without an MPU parameter reconfiguration operation to change the actual parameters set for a given address region. For example, the MPU cache memory 32 may be associated with a cache controller that uses a least recently used or similar replacement policy to evict entries that are predicted to be least useful in the future, when space is required for recently accessed entries of the memory protection table 22 in the memory system 10.

[0070] Although Figure 2 The static MPU register storage 36 is shown as being separate from the MPU cache storage 32, but in other examples these may be corresponding parts of a common storage structure. For example, some entries of the common storage structure may be marked with a flag to indicate that they should be treated as static entries that should not be evicted via the cache replacement policy. However, in practice, providing separate storage structures 32, 36 may allow for more efficient indexing into the cache storage 32.

[0071] The MPU includes a permission checking circuit system 40, which is used to: read access permission data, which is specified in a lookup entry of a memory protection table 22 stored in the memory system 10 (or cached in the MPU cache storage 32) or in a statically allocated MPU entry specified in the static MPU register storage 36; and determine whether the nature of the memory access request issued by the processing circuit system 4 meets the requirements specified by the access permission of the entry selected based on the target address of the memory access request. For example, the access permission can specify whether the area is a read-only area (for which any write request triggered by the storage instruction executed by the processing circuit system 4 should be denied) or whether reading and writing are allowed. The access permission can also specify whether the extraction unit 5 is allowed to extract instructions from the corresponding address area. The access permission can also limit access to the corresponding address area to certain exception levels or privilege levels of the processing circuit system 4, and the permission checking circuit 40 can check whether the current exception level or privilege level associated with the memory access request meets the restrictions defined in the access permission.

[0072] Although Figure 2 An example is not shown as Figure 1 The embodiment of the present invention provides a separation of the secure MPU 21 from the less secure MPU 23, but it will be appreciated that such a separation of MPUs may still be provided in this example, wherein each of the secure MPU and the less secure MPU is as described above. Figure 2 20. For example, the secure MPU and the less secure MPU may specify different base addresses for the corresponding MPU tables 22 in memory and may have separate registers for the static MPU register storage 36 and / or the MPU cache storage 32.

[0073] Figure 2 The example also has Figure 1 4, which includes a memory security configuration register 44 that defines security attribute entries that define secure / less secure regions of the address space; and a security check circuit system 46 that is used to check a target address against the security attribute entries to determine whether memory access is permitted. Although in this example, the security attribute entries are purely register-based, other examples may provide a security attribute table in the memory 10 similar to the MPU table 22, where the SAU includes circuits equivalent to the circuits 24, 36, 32, 28 of the MPU 20, but for looking up security attribute entries instead of memory protection entries.

[0074] Therefore, if Figure 3As shown in , both the MPU (secure or less secure depending on the current operating domain) and the SAU 42 can define orthogonal sets of access permissions for different regions of the address space. For the SAU 42, a region can be defined as being associated with a secure domain or a less secure domain. In the MPU 20, the following can be done: Figure 3 , where each region has some defined properties (e.g., read-only or readable / writable status, restrictions on privilege levels of accessible address regions), or other information such as the region type defined for the corresponding region, for example, whether the region is a device-type region, for which the memory system can restrict reordering of memory accesses. It is not necessary for the MPU 20 or SAU 42 to define memory protection entries for each portion of the address space. For example, Figure 3 There may be some areas marked 50 in the memory for which no MPU entry has been defined. If there is an access by the processing circuitry 4 to an address in one of these areas, the memory access may be denied and a fault may be triggered. Figure 3 In the example of , both the MPU 20 and the SAU 42 define memory access regions based on addresses in a physical address space that are accessed based on physical addresses that directly identify corresponding locations in the memory system 10. However, it is also possible for the MPU 20 or SAU 42 to apply a limited form of address translation, such as adding a constant offset to an address provided by the processing circuitry 4 in order to obtain a corresponding physical address to be provided to the memory 10.

[0075] In general, it is contemplated that MPU entries are defined by software to be non-overlapping. Some embodiments may provide hardware logic for checking whether a given memory attribute entry overlaps with any other entry when configuring it, and refusing to update the given memory attribute entry when it does overlap. However, this logic may be expensive in terms of hardware and performance (particularly for an MPU table 22 defined in memory). Figure 2 ), as it may need to be compared to the address range defined in each of the other MPU entries. Therefore, other implementations may deem it too expensive to provide this logic, so another approach may be to only expect software to define memory attribute entries as defined non-overlapping memory regions, and if software does not meet this requirement, the architecture may specify that safety cannot be guaranteed.

[0076] Similarly, SAUs may also be expected to be non-overlapping, which may be enforced by hardware checks, or not enforced by hardware, where software is expected to comply with this requirement, and if the software does not comply with this requirement, safety cannot be guaranteed.

[0077] for Figure 2 For embodiments of the present invention, it may be contemplated that entries of a given MPU table define non-overlapping regions, but static MPU entries in the static MPU register store 36 may be permitted to define regions that overlap with address regions defined by memory-based MPU entries in the MPU table 22. If an address hits both in the static MPU register store 36 and in a memory-based MPU entry, some embodiments may use the permissions defined in the static MPU entry from the static MPU register store 36, which may overrule any conflicting permissions defined in the matching memory-based MPU entry. Alternatively, another approach may be that if the static MPU entry permits memory access, the memory access may be permitted regardless of whether the matching memory-based MPU entry permits the memory access, but if the static MPU entry does not permit the memory access, the memory access may still be permitted when the matching memory-based MPU entry permits the memory access. However, overlap between regions associated with two static MPU entries may be prohibited, and similarly overlap between regions associated with two memory-based MPU entries may be prohibited.

[0078] like Figure 4 As shown in , the processing circuit system 4 can support multiple operating states in which instructions can be executed. These operating states can include domains, modes, and privilege levels. The processing circuit system 4 can support at least two secure operating domains, including at least a secure domain S and a less secure domain LS. In general, when processing program code stored in one of the secure areas of the address space defined by SAU 42, the system operates in the secure domain, and when executing code from the less secure area defined by SAU42, the system operates in the less secure domain. In the less secure domain, the secure area of ​​the address space is inaccessible.

[0079] In addition, the processing circuit system 4 may have multiple modes, including a thread mode T for background processing and a handler mode H for exception handling. It may be useful to separate the thread mode from the handler mode to simplify the handling of exceptions, for example, control over which registers can be accessed by the processing circuit system 4 may depend on whether the system is in thread mode or handler mode.

[0080] In addition, the system can have multiple privilege levels, including at least a privileged higher privilege level and a privileged less privilege level. For simplicity, these levels will be described as privileged and unprivileged below, but it will be appreciated that in other examples, there may be three or more different privilege levels, and therefore the term unprivileged can simply represent one of the less privileged levels, for which there is at least one other privileged level with greater privilege. In handler mode, the system can be operated in a privileged state by default. In thread mode, the current privilege level can be privileged or unprivileged according to the current privilege indicator maintained in one of the control registers 13. A separate grouped version of the current privilege indicator can be defined for safe and less safe domains, so that (for example) the thread mode can be defined as privileged when in a safe domain, and defined as unprivileged when in a less safe domain.

[0081] Figure 5A An example of a range check instruction (TT instruction) that can be used to query memory attributes defined by the MPU 20 and the SAU 42 is shown. The TT instruction specifies a target register Rd to which a status value will be written in response to the TT instruction. The TT instruction also specifies parameters that define a first address #add1 and a second address #add2. The first address and the second address can be defined in a variety of ways by the TT instruction, for example, using a register specifier indicating a general register 12 storing a value defining an address (e.g., explicitly identifying an address in a corresponding register, or specifying an address via a base address and an offset). The addresses can also be defined so that the first address #add1 is identified in a register, and the second address is identified as the product of a size value and a multiplier, wherein one or both of the multiplier and the size value are variable. The variable multiplier and / or the variable size value can be identified in a register by an immediate value, or by a configuration indicator in one of the control registers 13. In general, the encoding of the TT instruction can be constrained so that the first address #add1 is constrained to be less than the second address #add2, or, if the encoding permits the second address #add2 to be less than the first address #add1, then when it is detected for a given instance of the TT instruction that the second address #add2 is less than the first address #add1, the processing circuit system 4 can trigger a fault.

[0082] Figure 5BAnother example of a range check instruction (TT instruction) is shown, which, as described above, writes a status value to a target register specified by Rd. However, in this example, a first address is read from a general register 12 specified by the Rn parameter. Another general register 12 specified by the Rm parameter is read, and the size value (offset) read from Rm is added to the first address to produce a second address. Optionally, the size value can be shifted left by an amount specified by the immediate value #imm, effectively allowing the size values ​​read from the register specified by the Rm parameter to be multiplied (e.g., a shift of 1 corresponds to a multiplication by 2, a shift of 2 corresponds to a multiplication by 4, and so on). Thus, the value in the register specified by Rm can be the length (number of elements) of an array, and for common array element sizes (e.g., 4 bytes for an array of 32-bit words), the TT instruction can calculate the second address (i.e., the end address of the array) without requiring any additional instructions.

[0083] In response to the TT instruction, the memory attribute check circuit system 16 searches the MPU 20 and the SAU 42 based on the first address and the second address, and records in the target register Rd an indication of whether the first address and the second address are mapped to the same memory protection entry of the MPU 20 and whether the first address and the second address are mapped to the same security protection entry of the SAU 42. In addition, in the case where the first address and the second address are mapped to the same entry, the target register Rd may also be written with information derived from the matching entry of the MPU 20 or the SAU 42.

[0084] For example, Figure 6 As shown in , the target register Rd can be written with multiple pieces of information, including the following:

[0085] MVALID, which indicates whether both the first address and the second address correspond to the same memory protection entry of the MPU 20;

[0086] SVALID, which indicates whether the first address and the second address both correspond to the same security protection entry of SAU 42;

[0087] a read permission flag R which (at least when the first address and the second address correspond to the same MPU entry) specifies whether memory access to the address region corresponding to the matching entry is to be granted;

[0088] a read / write permission flag RW which (at least when the first address and the second address correspond to the same MPU entry) indicates whether the access permissions in the matching entry permit both read and write access;

[0089] a security domain flag S indicating whether the first address and the second address correspond to a secure region or a less secure region (at least when the first address and the second address correspond to the same SAU entry);

[0090] A combined indicator LSR, which is set to 1 when all of the following conditions are met: the security flag S indicates that the first address and the second address correspond to a less secure domain, the read flag R indicates that read access is granted, and both the SVALID and MVALID indicators are equal to 1. If any of these conditions are not met, LSR is set to 0.

[0091] A second combined indicator LSRW, which is set to 1 when all of the following conditions are met: the security domain associated with the first address and the second address is the less secure domain, the read / write flag RW is 1, indicating that read and write access are permitted, and both the SVALID and MVALID indicators are equal to 1. If any of these conditions are not met, LSRW is 0.

[0092] Setting the combination indicators in hardware in response to the TT instruction can be useful to allow relatively common forms of security checks to be performed quickly, by testing a single bit of information (rather than needing to test a combination of two or more values, which would otherwise require more instructions). In some cases, in addition to writing these combination indicators to the target register Rd, the processing circuit system 4 in response to the TT instruction may also be based on Figure 6 The conditional flag in the control register 13 is updated with one or more pieces of information (e.g., based on the combination indicator) shown in the control register 13, so that subsequent conditional instructions can directly trigger conditional operations based on whether the conditional flag satisfies a certain test condition. For at least some forms of security checks, this can avoid the need for subsequent comparison instructions to compare the parameters in the register Rd to determine which conditional operation should be performed, which can help improve code density.

[0093] will realize that Figure 6 The information shown in is only one example, and other combinations of information derived from matching entries of the MPU or SAU when the first address and the second address map to the same entry may be provided.

[0094] For example, in some embodiments, SVALID and MVALID may be omitted entirely, and the combined indicator fields LSRW and LSR may serve as a state value indicating whether the first address and the second address map to the same attribute entry, and indicating additional information derived from the attributes of the matching entry if the addresses do map to the same entry. For example, when LSRW or LSR=1, it may be inferred that the address maps to the same attribute entry in the SAU and the MPU. In the case of LSRW or LSR=0, it may not be considered important in some embodiments to distinguish whether this is because the addresses map to different entries (and if so, which different entries in the MPU and SAU the addresses map to), or because the matching entry specifies an attribute that prohibits access to the corresponding area.

[0095] Additionally, it is not necessary for the status value to return a separate indication of read-only or read / write permissions. In other implementations, a parameter in the instruction encoding of the TT instruction may specify whether permissions for read access or write access are to be checked, and a single permission indicator (replacing RW / R) or a combined indicator (replacing LSRW and LSR) may then indicate whether the specified type of memory access (read or write) is to be permitted in the address range between the first address and the second address.

[0096] This instruction may be useful when software checks permissions of pointers originating from untrusted software (e.g., unsecure software operating in a less secure domain, or unprivileged software operating at an unprivileged level). This may be useful, for example, to avoid confusion proxy attacks, where less secure untrusted software may attempt to trick more secure or more privileged software into performing accesses to inappropriate memory regions (which may not be accessible to the less secure untrusted software) by passing an inappropriate pointer to an array (which will then be accessed by the more secure software). By using a TT instruction (where the first address and the second address correspond to the start and end addresses of an array in memory), the trusted software may check (provided the software has not defined overlapping memory attribute regions) whether each word in the array is accessible to the untrusted software that passed the pointer to the array to the trusted software. This type of instruction may allow the processor to quickly check whether any pointer within the bounds of the array is accessible to the untrusted software.

[0097] Figure 5 and Figure 6 The instruction format shown in (which defines two addresses and checks whether the two addresses are in the same address area of ​​the MPU and / or SAU) may be particularly useful Figure 2The embodiment shown in (where the memory protection table 22 is stored in the memory system 10) is useful. By specifying MVALID or SVALID information in a register, rather than (for example) returning a region number associated with a given address, this can be better extended to a memory protection table 22 that supports a very large number of memory protection entries. In addition, returning a single bit flag indicating whether a first address and a second address map to the same entry (rather than a region number associated with a given address) means that the MPU cache memory 32 does not need to store the full region number of the corresponding memory protection entry (for querying by the TT instruction) in each cache entry. Because the entries in the MPU cache memory 32 can generally be based on registers rather than SRAM, avoiding the need to store the region number of each MPU entry in the cache memory 32 can provide a significant area reduction.

[0098] like Figure 7 As shown in , multiple variants of the TT instruction can be provided for checking access permissions defined by different combinations of operating states of the processing circuit system 4. In the first variant of the TT instruction, the MPU and SAU can be searched based on the access permissions of the current security domain and the current mode of the processing circuit system 4. Thus, in response to the TT instruction, the relevant one of the secure MPU 21 and the less secure MPU 23 can be selected based on the current operating domain, and whether to search for access permissions in the relevant MPU assuming unprivileged access or privileged access can be selected based on the current mode of the system and the current privilege level used in the current mode. For example, if the current mode is handler mode, the access can be assumed to be privileged by definition, and if the current mode is thread mode, whether to perform a privileged or unprivileged search can depend on a parameter stored in one of the control registers 13. In an unprivileged search, if the area is not allowed to be accessed by unprivileged code, the R or RW flag can be 0.

[0099] For a second variant of the TT instruction (TTA), if an attempt is made to execute the instruction while in a less secure domain, the processing circuit system 4 may trigger a fault, and if the TTA instruction is executed in the secure domain, instead of looking up the secure MPU 21 as in the first variant instruction, an MPU lookup may be performed on the less secure MPU 23. This may be useful to allow software operating in the secure domain to check whether certain memory accesses have been allowed if they have been executed by less secure code, which may be useful to clean up indicators provided by less secure code in order to prevent confusion agent attacks. For the second variant, the MPU lookup may be based on a privilege level that is associated with the current operating mode when the system is operating in a less secure domain. In some cases, when executing the TTA variant of the instruction, it is assumed that the privilege level used for the lookup may be different from the current privilege level. For example, if a TTA instruction is executed in the secure domain and thread mode when the current privilege level is privileged, but the grouped version of the thread mode privilege indicator of the less secure domain defines that the thread mode should be unprivileged in the less secure domain, the TTA instruction may trigger a search of the less secure MPU 23 based on the unprivileged state associated with the thread mode in the less secure domain, rather than based on the current privileged state associated with the thread mode in the secure domain.

[0100] Figure 7 A third variant of the instruction (TTT) is also shown which checks the MPU 21, 23 associated with the current security domain, but forces the lookup of the MPU based on an unprivileged state, regardless of the current privilege level of the processing circuit system 4. Thus, even if the processing circuit system 4 is currently in a privileged state, it can still be set Figure 6 , RW, etc. in the processing circuit system 4 to indicate whether a read or read / write operation has been granted when the processing circuit system 4 has currently entered the unprivileged state. This can be useful to allow more privileged code to check unprivileged permissions that can be accessed by less privileged code so that indicators provided by the unprivileged code can be checked. For the third variant, if the third variant is executed in the unprivileged state, a fault is triggered.

[0101] Similarly, a fourth variant of the instruction (TTAT) may be provided that combines the properties of the second and third variants of the instruction. For the fourth variant, a fault is triggered if the fourth variant is executed in an unprivileged state or a less secure domain. The fourth variant triggers a lookup of the less secure MPU 23 even when executed in the secure domain, and triggers a lookup based on the unprivileged permissions defined for unprivileged memory access even when executed in a currently privileged state.

[0102] Thus, the first variant to the fourth variant define a plurality of instructions that allow cross-operation status checks of memory access permissions, so that the more trusted code can check whether the less trusted code has been allowed to access the address defined by the first address and the second address, which can be useful for checking the indicator passed by the less trusted code to the more trusted code. It will be appreciated that it is not necessary to support all of the first to fourth variants of the instruction in the instruction set architecture of a given embodiment. Any subset of one, two or more of these variants can be supported. Different variants of the instruction can be distinguished in different ways, for example, using different opcodes, or, if the variants share the same opcode, using another parameter defined in the instruction encoding of the instruction. For example, a variant field can be provided in the instruction encoding to identify which variant is used. In other examples, the encoding of the instruction can be the same for different variants, but the parameters stored in the control register 13 can be set to indicate whether the TT instruction should be regarded as the first, second, third or fourth variant.

[0103] It can be expected that providing lookup circuitry for looking up whether a first address and a second address map to the same memory attribute entry may be relatively expensive in terms of performance and hardware, as it may require two separate lookups for each of the addresses. However, in practice this is not necessary, and a single lookup may identify whether two addresses map to the same entry. Figure 8 As shown in , the region check hardware may generally include an array of comparators 60, 62, wherein each memory attribute entry supported in the static register 36 or in the cache memory 32 may be associated with a set of two comparators 60, 62. These comparators include a lower limit comparator 60 that compares an input address with a base address 64 of a corresponding address region and outputs a hit signal 66 that is asserted when the input address 65 is greater than or equal to the base address 64. In addition, for each entry provided in the static register 36 or cache memory 32, a second upper limit comparator 62 may be provided that compares an input address 67 with a limit address 68 that defines an upper limit of the corresponding address region and asserts a hit signal 69 when the input address 67 is less than or equal to the limit address 68. A region hit signal 70 may be generated by an AND gate 71 and is set to 1 when both the lower limit hit signal 66 and the upper limit signal 69 are asserted.

[0104] For a normal memory access, the target address #add of the memory access may be supplied to the lower limit comparator 60 as input address 65 and to the upper limit comparator 62 as input address 67 .

[0105] In order to implement a TT instruction that requires comparison of two separate addresses, it is possible to supply the first address #add1 as an input address 65 to each lower limit comparator 60 and the second address #add2 as an input address 67 to each upper limit comparator 62. If the first address #add1 is less than the second address #add2, the hit signal 70 for a given entry will indicate whether both the first address and the second address are mapped to that entry. If the first address and the second address are mapped to different entries, then neither of the region hit signals 70 for the corresponding entries will be asserted. If the first address and the second address do correspond to the same entry, then only the hit signal 70 for the matching entry will be asserted. Thus, it is possible to execute the TT instruction shown in FIG. 5 with little additional performance and area impact (and little additional lookup time compared to a single address lookup) because the instruction can simply reuse the comparators 60, 62 that are typically already provided for checking existing memory accesses. Because only a single lookup of the comparator network is required, FIG. 5 and FIG. 5 are compared to alternative examples that can trigger the return of the region number associated with a single address. Figure 6 The form of the TT instruction shown in has an additional benefit because only a single TT instruction needs to be executed, rather than executing separate instructions to check the first address and the second address against the region number. This can be a significant advantage because the TT instruction can be expected to be on the critical path of some interrupt latency sensitive tasks (where every cycle is important).

[0106] Fig. 9 A flow chart illustrating a method of processing a range check instruction. At step 100, a range check instruction is decoded by an instruction decoder 7. The range check instruction identifies address identification parameters for identifying a first address #add1 and a second address #add2. In this example, the range check instruction has an encoding that constrains the first address #add1 to be less than the second address #add2, but if this is not the case, a fault may be triggered when the address identification parameters identify that the second address #add2 is less than the first address #add1 for a particular instruction.

[0107] At step 102, the decoder 7 identifies which variant of the range check instruction is being decoded. This may be based on parameters in the instruction encoding itself or parameters stored in the control register 13. Based on the variant, the instruction decoder 7 generates control signals to determine which of the secure MPU 21 and the less secure MPU 23 should be the selected MPU for lookup in response to the instruction, and which privilege level should be the selected privilege level assumed for checking access permissions in the relevant MPU.

[0108] If the instruction is of the first variant, then at step 104 , the selected MPU is determined to be one of the secure MPU 21 and the less secure MPU 23 corresponding to the current security domain of the processing circuit system 4 , and the selected privilege level is the current privilege level of the processing circuit system 4 .

[0109] If the variant is the second variant, then at step 106, the system checks whether the current security domain is a less secure domain, and if so, triggers a fault at step 108. Thus, execution of the second variant can be restricted to execution in the secure domain. If the current domain is the secure domain, then at step 110, when the processing circuit system 4 is operating in the less secure domain, it is determined that the selected MPU is the less secure MPU 23, and the selected privilege level is the privilege level associated with the current mode.

[0110] If the variant of the decoded range check instruction is identified as the third variant at step 102, then at step 112, the current privilege level is checked to be an unprivileged state, and if so, a fault is again triggered at step 108. Thus, execution of the third variant is restricted to a more privileged state. If the current privilege level is not an unprivileged state, then at step 114, the selected MPU is determined to be one of the secure MPU 21 and the less secure MPU 23 associated with the current security domain, and the selected privilege level is forced to be unprivileged, regardless of the current privilege level at which the processing circuit system 4 is operating.

[0111] If the variant of the instruction is the fourth variant, then at step 116, it is determined whether the current security domain is a less secure domain and / or whether the current privilege level is an unprivileged state. If the current domain is a less secure domain or the current privilege level is an unprivileged state, then at step 118, a fault is triggered. Thus, execution of the fourth variant is limited to when the processing circuit system is in a secure domain and in a more privileged state. If the current domain is not a less secure domain and the current privilege level is not an unprivileged state, then at step 120, it is determined that the selected MPU is a less secure MPU 23, and the selected privilege level is determined to be an unprivileged state, regardless of the current privilege level of the processing circuit system 4.

[0112] Regardless of which variant is encountered, at step 122, the memory attribute checking circuitry 16 is controlled to find the selected MPU, wherein the first address #add1 is compared with the lower limit address of each entry, and the second address #add2 is compared with the upper limit address of each entry. Figure 2In the example of , entries in the static MPU register storage 36 and the MPU cache storage 32 may be looked up, and if neither the first address nor the second address hits either of the entries, a table lookup 26 may need to be performed to obtain a memory protection entry from the MPU table 22 in memory. This table lookup may be based on either the first address or the second address, as either entry returned may then be queried to determine whether the other of the first address and the second address also matches the same entry. For executing the TT instruction where one of the first address and the second address matches one of the entries in the static MPU register storage 36 or the MPU cache storage 32, there is no need to trigger a table lookup of the memory system, as it will be known from the entry stored locally within the MPU 20 whether the second address also matches the same entry.

[0113] At step 124, it is determined whether the first address and the second address correspond to the same MPU entry of the selected MPU. If so, at step 126, the MPU state value indicator MVALID is set to 1 to indicate that the first address and the second address correspond to the same memory attribute entry, and if the first address and the second address do not correspond to the same entry, the MVALID is set to 0 at step 128. If MVALID is equal to 1, at step 130, assuming that the selected privilege level is selected at one of steps 104, 110, 114, 120, attribute information is set based on information specified in the matching MPU entry, such as R and RW flags, which indicate whether read access is permitted or whether read and write access are permitted. If at step 124 the first address and the second address do not correspond to the same MPU entry, step 130 may be omitted. Alternatively, even if the first address and the second address do not correspond to the same MPU entry, step 130 may still be performed, for example, to set attribute information based on information from an entry corresponding to the first address, regardless of whether the second address also matches the same entry. Setting the attribute information based only on the entry associated with the first address is not a problem, as it can be quantified by the MVALID flag, which indicates whether this information can be considered to also cover the second address. Thus, in some implementations, it may be simpler in the circuit logic to always set the attribute information R, RW regardless of whether the first address and the second address correspond to the same MPU entry, rather than providing logic for suppressing the update of the attribute information based on whether the first address and the second address correspond to the same entry. The two alternative dashed lines after step 128 show alternative options that can be implemented.

[0114] At step 132, SAU 42 is looked up, where the first address is again compared to the lower limit address of each security protection (SAU) entry, and the second address is compared to the upper limit address of each security protection entry. At step 134, the processing circuit system determines whether the first address and the second address correspond to the same SAU entry, and if so, the security status value SVALID is set to 1 at step 136, and if the first address and the second address do not correspond to the same SAU entry, SVALID is set to 0 at step 138. At step 140, attribute information (e.g., a security domain flag S indicating whether the matching entry is defined as a secure or less secure area of ​​the address space) is set based on information specified in the matching SAU entry. Step 140 is performed at least in the case where the first address and the second address correspond to the same SAU entry, but (for reasons similar to those for the MPU lookup) after step 138, step 140 may be performed or may be omitted. Although Fig. 9 The example shows that steps 132 to 140 are performed sequentially after steps 122 to 130, but in other examples, the SAU lookup may be performed before the MPU lookup, or the MPU and SAU lookups may be performed in parallel.

[0115] In the case of MVALID=1 and SVALID=1, provided that software has not set the SAU or MPU to have overlapping entries in the range between the first address and the second address, it is guaranteed that the permissions indicated by the S, R, RW parameters apply to the entire range between the first address and the second address. If software has defined overlapping regions, this property cannot be guaranteed. As described above, it may not be considered reasonable to incur costs in providing hardware logic to enforce that MPU regions do not overlap and SAU regions do not overlap.

[0116] At step 142, the processing circuit system may generate a combined permission indicator based on a combination of information derived from the matching SAU entry and information derived from the matching MPU entry. In addition, this step may be performed at least when MVALID is 1 and SVALID is 1, but may be omitted if MVALID or SVALID is 0, or performed in any case (for reasons similar to those described above). In this example, two combined permission indicators are generated: a first indicator LSR, which indicates whether the access is to a less secure region and whether read access to the region is permitted under a selected privileged state when the selected MPU is searched; and a second indicator LSRW, which indicates whether the matching address region is a less secure region and whether reading and writing are permitted under a selected privileged level when the selected MPU is searched. These may represent common checks, which may often be useful to perform, and therefore, by providing a single bit indicator to combine information from different parameters (the parameters are searched from various entries), this may allow subsequent checks to be performed quickly. For example, if the security flag is assumed to be 1 when the region is associated with a secure domain, and the security flag is assumed to be 0 when the region is associated with a less secure domain, then LSR may be set based on the result of (MVALID AND SVALID AND (NOT S) AND R), and LSRW may be set based on the result of (MVALID AND SVALID AND (NOT S) AND RW). Obviously, it is possible to use alternative mappings for some of these parameters (e.g., S=0 may indicate a secure domain, and S=1 may indicate a less secure domain), in which case the combination of logical operations used to generate the combined permission indicator may vary.

[0117] At step 144, the processing circuit system 4 writes at least the state values ​​MVALID and SVALID indicating whether the first address and the second address correspond to the same MPU entry to the software accessible register, for example, the target register Rd specified by the range check instruction. The attribute information determined at steps 130, 140, and 142 can also be written to the register. Optionally, at step 146, the instruction can also update the conditional flag in one of the control registers 13. These conditional flags can be updated in response to the conditional flag setting instruction to specify various conditions of the previous processing results, and these conditional flags can be tested by conditional instructions, which specify the test conditions that the conditional flags will meet, and conditionally trigger the execution of the corresponding conditional operation according to whether the current value of the conditional flag meets this test condition. For example, some of the conditional flags can be set to a value corresponding to the combined permission indicator so that subsequent conditional instructions can directly trigger the action to be executed based on the value of the combined permission indicator conditionally. The dotted line between steps 144 and 146 indicates that step 146 is optional. However, the conditional flag in the control register may represent another example of a software accessible location at which status information indicating whether the first address and the second address correspond to the same entry may be stored. In other examples, the write to the target register may be omitted, and the only result of the instruction may be to update the conditional flag (e.g., omitting step 144). In other examples, instead of writing a value to a register, a value indicating whether addresses #add1, #add2 correspond to the same memory attribute entry may be written to the memory.

[0118] exist Fig. 9 In the example shown in , the instruction queries a first set of memory attribute entries corresponding to MPU 20 and a second set of attribute entries corresponding to SAU 42. However, the TT instruction can also be used in a system that only provides a set of memory attribute entries to be checked, so it is not necessary to return the values ​​of two different sets of memory attribute entries.

[0119] Fig.10The emulator implementation scheme that can be used is shown. Although the aforementioned embodiment implements the present invention in terms of the apparatus and method for operating the specific processing hardware supporting the relevant technology, it is also possible to provide an instruction execution environment according to the embodiments described herein, and the instruction execution environment is implemented via the use of a computer program. These computer programs can often be referred to as emulators, as long as they provide a software-based implementation scheme of the hardware architecture. The types of emulator computer programs include emulators, virtual machines, models, and binary translators, including dynamic binary translators. Usually, the emulator implementation scheme can be run on a host processor 230, and the host processor 230 optionally runs a host operating system 220, which supports the emulator program 210. In some arrangements, there may be multiple simulation layers between the hardware and the instruction execution environment provided and / or a plurality of different instruction execution environments provided on the same host processor. Historically, a powerful processor is required to provide an emulator implementation scheme that is executed at a reasonable speed, but this method may be reasonable in some scenarios, for example, when it is desired to run a code native to another processor for compatibility or reuse reasons. For example, an emulator implementation may provide an instruction execution environment with additional functionality that is not supported by the host processor hardware, or provide an instruction execution environment that is normally associated with a different hardware architecture. An overview of simulation is given in "Some Efficient Architecture Simulation Techniques" (Robert Bedichek, USENIX Conference, Winter 1990, pp. 53-63).

[0120] To the extent that embodiments have been previously described with reference to specific hardware configurations or features, in simulated embodiments, equivalent functionality may be provided by suitable software configurations or features. For example, a specific circuit system may be implemented as computer program logic in simulated embodiments. Similarly, memory hardware such as registers or caches may be implemented as software data structures in simulated embodiments. In addition, the physical address space for accessing the memory 6 in the hardware device 2 may be simulated as a simulated address space 202, which is mapped to the virtual address space used by the host operating system 220 by the emulator 210. In an arrangement in which one or more of the hardware components cited in the aforementioned example embodiments are present on host hardware (e.g., a host processor 230), some simulated embodiments may use the host hardware where appropriate.

[0121] The emulator program 210 may be stored on a computer-readable storage medium (which may be a non-transitory medium), and the emulator program 210 provides a program interface (instruction execution environment) to the target code 200 (which may include applications, operating systems, and hypervisors), which is the same as the application interface of the hardware architecture modeled by the emulator program 210. Therefore, the emulator program 210 may be used to execute program instructions of the target code 210 from within the instruction execution environment, so that a host computer 230 that does not actually have the hardware features of the above-mentioned device 2 can emulate these features. The emulator program may include instruction decoding program logic 235, and memory access checking program logic 240 (including MPU program logic 242 and SAU program logic 244), which provide emulation. Figure 1 The function of the behavior of the instruction decoder 7 and the memory access check circuit system 22 (including the MPU 26 and the SAU 24) of the hardware device 2. The architectural registers 14 of the system 2 can also be simulated using the register data structure 255 maintained by the emulator code 210. Thus, memory attribute checking and support for TT instructions can be performed by the emulator program 210 in a manner corresponding to the above-mentioned technology.

[0122] In this application, the phrase "configured to..." is used to mean that components of a device have a configuration that enables the defined operation to be performed. In this context, "configuration" means the arrangement or interconnection of hardware or software. For example, a device may have dedicated hardware that provides the defined operation, or a processor or other processing device that can be programmed to perform the function. "Configured to..." does not imply that the components of the device need to be changed in any way to provide the defined operation.

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

Claims

1. A device for data processing, comprising: An instruction decoder for decoding instructions; processing circuitry for performing data processing in response to instructions decoded by the instruction decoder; as well as a memory attribute checking circuitry for checking whether a memory access request issued by the processing circuitry satisfies access permissions specified in a plurality of memory attribute entries, each memory attribute entry specifying access permissions for a corresponding address region of variable size within an address space; wherein: In response to a range check instruction specifying an address identification parameter identifying a first address and a second address, the instruction decoder is configured to control the processing circuitry to set a status value in at least one software accessible storage location that is accessible by at least one type of instruction supported by the instruction decoder, the status value indicating whether the first address and the second address correspond to the same memory attribute entry, The processing circuitry has a plurality of secure operating domains, the plurality of secure operating domains comprising a secure domain and a less secure domain, and within each secure domain, the processing circuitry is configured to operate in one of a plurality of modes and in one of a plurality of privilege levels; and The instruction decoder is configured to support variants of the range checking instruction.

2. The device according to claim 1, wherein: The memory attribute checking circuitry is configured to permit the variable size to be a number of bytes other than a power of two.

3. The device according to any one of claims 1 and 2, wherein: The processing circuitry is configured to permit a difference between the first address and the second address to be a number of bytes other than a power of two.

4. The device according to any one of claims 1 and 2, wherein: The address identification parameter identifies a base address register from which the first address is to be read and an offset for identifying a difference between the first address and the second address.

5. The device according to claim 4, wherein: The offset is specified as a multiple and size value, where: One of the multiple and the size value is a variable parameter specified by the range checking instruction, and The other of the multiple and the size value is one of: Fixed value; an immediate value, the immediate value specified by the range checking instruction; and The value stored in the register specified by the range-check instruction.

6. The device according to any one of claims 1 and 2, wherein: The address identification parameter identifies a first register from which the first address is to be read and a second register from which the second address is to be read.

7. The device according to any one of claims 1 and 2, wherein: The at least one software accessible storage location includes a target register specified by the range checking instruction.

8. The apparatus according to any one of claims 1 and 2, comprising a control register for storing at least one condition status indication, the at least one condition status indication indicating a property of a result of a previous condition status indicator generating instruction; wherein: In response to a conditional instruction, the instruction decoder is configured to control the processing circuitry to perform a conditional operation conditional on whether the at least one condition status indication stored in the control register satisfies a test condition; and In response to the range check instruction, the instruction decoder is configured to control the processing circuitry to set the state value by updating at least one of the at least one conditional state indication in the control register.

9. The device according to any one of claims 1 and 2, wherein: In response to the range check instruction, at least when both the first address and the second address correspond to the same memory attribute entry, the processing circuit system is configured to store attribute information to the at least one software accessible storage location, the attribute information being derived from matching memory attribute entries corresponding to the first address and the second address.

10. The device according to claim 9, wherein: The processing circuitry has a plurality of operating states; and In response to at least one variant of the range check instruction, the processing circuit system is configured to derive the attribute information based on access permissions, and when in an operating state different from a current operating state of the processing circuit system, the access permissions will be applied to memory accesses to the corresponding address region of the matching memory attribute entry.

11. The device according to claim 9, wherein: Variants of the range checking instruction include at least one of the following: a first variant for which the attribute information specifies whether memory access to locations in a range between the first address and the second address will be permitted when the processing circuitry is in a current security domain, and a privilege level associated with a current mode; a second variant for which the attribute information specifies whether memory access to locations in a range between the first address and the second address will be permitted when the processing circuitry is in a security domain different from the current security domain, and a privilege level associated with the current mode when operating in this different security domain; a third variation for which the attribute information specifies whether memory access to addresses in the current security domain in a range between the first address and the second address will be permitted and a privilege level different from a privilege level associated with the current mode; as well as A fourth variant, for which the attribute information specifies whether memory access to locations in a range between the first address and the second address will be permitted when the processing circuit system is in a security domain different from the current security domain, and a privilege level different from a privilege level associated with the current mode.

12. The device according to claim 11, characterized in that One of the following: the instruction decoder being configured to support at least one of the second variant and the fourth variant, the different security domains comprising the less secure domain, and the processing circuitry being configured to: trigger communication of a fault in response to an attempt to execute the at least one of the second variant and the fourth variant while the processing circuitry is in the less secure domain; as well as The instruction decoder is configured to support at least one of the third variant and the fourth variant, the different privilege levels include a privilege level that is less privileged than a current privilege level associated with the current mode, and the processing circuit system is configured to: trigger a fault signal in response to an attempt to execute at least one of the third variant and the fourth variant when the processing circuit system is in at least one predetermined privilege level, wherein the multiple privilege levels include at least one privilege level that is more privileged than the at least one predetermined privilege level.

13. The device according to any one of claims 1 and 2, wherein: The memory attribute checking circuitry is configured to check whether a memory access issued by the processing circuitry satisfies access permissions specified in a first plurality of memory attribute entries and to check whether the memory access request satisfies access permissions specified in a second plurality of memory attribute entries, and In response to the range check instruction, the instruction decoder is configured to control the processing circuitry to set the following in the at least one software accessible storage location: a first state value indicating whether the first address and the second address correspond to a same entry in the first plurality of memory attribute entries; as well as A second state value indicates whether the first address and the second address correspond to a same entry in the second plurality of memory attribute entries.

14. The device according to any one of claims 1 and 2, wherein: The plurality of memory attribute entries include a plurality of memory protection entries, each memory protection entry specifying access permissions indicating at least one of: Whether the corresponding address area is read-only or both readable and writable; Which privilege levels of a plurality of privilege levels of the processing circuitry are allowed to access the corresponding address region.

15. The device according to claim 14, wherein: The memory access request comprises a request to access a memory system; and The plurality of memory protection entries include a memory protection table, wherein the memory protection table is stored in the memory system.

16. The apparatus of claim 15, comprising memory protection cache storage circuitry for caching at least one memory protection entry of the memory protection table obtained from the memory system.

17. The device according to any one of claims 1 and 2, wherein: The processing circuitry has a plurality of operating domains, the plurality of operating domains comprising a secure domain and a less secure domain; and The plurality of memory attribute entries include a plurality of security attribute entries, each security attribute entry specifying access permissions indicating which of the plurality of domains is associated with the corresponding address region.

18. The device according to claim 17, wherein: In response to at least one variant of the range check instruction, at least when both the first address and the second address correspond to the same security attribute entry, the processing circuit system is configured to: store attribute information to the at least one software-accessible storage location via matching security attribute entries corresponding to the first address and the second address, the attribute information being derived from a security domain designated as associated with the corresponding address region.

19. The apparatus of claim 17, wherein: The plurality of memory attribute entries also include a plurality of memory protection entries, each memory protection entry specifying access permissions indicating at least one of: Whether the corresponding address area is read-only or both readable and writable; which privilege levels of the processing circuitry are allowed to access the corresponding address region; and In response to at least one variant of the range check instruction, at least when both the first address and the second address correspond to the same memory attribute entry, the processing circuit system is configured to store at least one combined permission indication to the at least one software-accessible storage location, the combined permission indication specifying in a single indicator whether both of the following specify that a given type of memory access is permitted: the access permissions in the matching memory protection entries corresponding to the first address and the second address, and the access permissions specified in the matching security attribute entries corresponding to the first address and the second address.

20. The device according to any one of claims 1 and 2, wherein: The memory attribute checking circuit system includes at least one group of comparators, each group of comparators includes: a lower limit comparator for comparing a target address of a memory access request with a lower limit address of a given memory attribute entry; and an upper limit comparator for comparing the target address of a memory access request with an upper limit address of the given memory attribute entry; and In response to the range check instruction, the instruction decoder is configured to control the processing circuit system to supply the first address as the target address to the lower limit comparator in each group of comparators, and to supply the second address as the target address to the upper limit comparator in each group of comparators.

21. The device according to any one of claims 1 and 2, wherein: The encoding of the range check instruction constrains the first address to be lower than the second address.

22. The device according to any one of claims 1 and 2, wherein: In response to the range check instruction that the second address is lower than the first address, the processing circuitry is configured to perform at least one of the following: Communications failure; and A status value is returned indicating that the first address and the second address do not correspond to the same memory attribute entry.

23. A data processing method comprising the following steps: decoding, using an instruction decoder, a range check instruction, the range check instruction specifying an address identification parameter for identifying a first address and a second address; as well as responsive to decoding the range check instruction, controlling the processing circuitry to set a status value in at least one software-accessible storage location accessible by at least one type of instruction supported by the instruction decoder, the status value indicating whether the first address and the second address correspond to the same memory attribute entry of a plurality of memory attribute entries, each memory attribute entry specifying access permissions for a corresponding address region of variable size within an address space, wherein the processing circuitry has a plurality of secure operating domains, the plurality of secure operating domains comprising a secure domain and a less secure domain, and within each secure domain, the processing circuitry is configured to operate in one of a plurality of modes and in one of a plurality of privilege levels; and The instruction decoder is configured to support variants of the range checking instruction.

24. A computer program product for controlling a host data processing device to provide an instruction execution environment for executing instructions of a target code, the computer program product comprising: instruction decoding program logic for decoding instructions of the target code and controlling the host data processing device to perform data processing in response to the decoded instructions; as well as a memory attribute checker logic for checking whether a memory access request triggered by the decoded instruction of the target code satisfies access permissions specified in a plurality of memory attribute entries, each memory attribute entry specifying access permissions for a corresponding address region of variable size within an emulated address space, the emulated address space being emulated by the instruction execution environment; wherein: In response to a range check instruction that specifies an address identification parameter for identifying a first address and a second address, the instruction decode program logic is configured to control the host data processing device to set a status value in at least one software-accessible storage location that is accessible by at least one type of instruction that the instruction decode program logic supports decoding, the status value indicating whether the first address and the second address correspond to the same memory attribute entry, The host data processing apparatus has a plurality of secure operating domains, the plurality of secure operating domains comprising a secure domain and a less secure domain, and within each secure domain, the host data processing apparatus is configured to operate in one of a plurality of modes and in one of a plurality of privilege levels; and The instruction decode program logic is configured to support variants of the range checking instruction.

25. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, performs the method according to claim 23.