Device, method and computer program product for data processing

By using memory protection tables and static cache entries in the memory system, the problem of low access control efficiency of MMU and MPU in real-time applications and limited memory systems is solved, achieving more efficient memory access and performance optimization.

CN112424758BActive Publication Date: 2024-11-29ARM LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN201980045774.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-06-06
Publication Date
2024-11-29
Estimated Expiration
2039-06-06

AI Technical Summary

Technical Problem

Existing MMUs and MPUs cannot efficiently control memory access permissions in real-time applications and systems with limited memory capacity, resulting in performance degradation and wasted memory resources.

Method used

By employing a memory protection table stored in the memory system, which allows for the definition of access permissions for variable-sized address regions, and by combining static and cached memory protection entries, memory access requests are optimized.

Benefits of technology

It improves the flexibility and efficiency of memory access, reduces the frequency of exception handling, lowers interrupt latency, and optimizes the performance of real-time applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112424758B_ABST
    Figure CN112424758B_ABST
Patent Text Reader

Abstract

An apparatus includes: a processing circuit to issue a memory access request specifying a target address, the target address identifying a location in a memory system to be accessed; and a memory protection unit (MPU) including a permission checking circuit to check whether the memory access request issued by the processing circuit satisfies access rights specified in a memory protection table stored in the memory system. The memory protection table includes memory protection entries, each memory protection entry specifying access rights for a corresponding address region of a variable size within an address space, wherein the number of bytes of the variable size may not be a power of 2.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of data processing, and more particularly to a device having a memory protection unit (MPU). Background Art

[0002] The data processing device may have a processing circuit for performing data processing operations. The processing circuit may issue a memory access request that specifies a target address that identifies a location to be accessed in a memory system. It is desirable to define access rights that control whether certain software processes are allowed to access certain areas of the address space. For example, access rights may specify whether a certain address area is read-only or may be both readable and writable, or may specify which privilege levels are allowed to access the corresponding address area. It is also desirable to control whether an area of ​​memory is executable. Such execution rights may depend on the privilege level, for example, it is desirable to allow non-privileged execution of a memory area but prohibit execution in a privileged mode. When granting access rights, it is also desirable to perform access according to attributes associated with a certain address area (e.g., whether access to the address area by caching, buffering, or a combination of the two is allowed). Summary of the invention

[0003] At least some examples provide an apparatus comprising:

[0004] processing circuitry for issuing a memory access request specifying a target address identifying a location in a memory system to be accessed; and

[0005] Memory Protection Unit (MPU), including:

[0006] a permission checking circuit for checking whether a memory access request issued by the processing circuit satisfies access rights specified in a memory protection table stored in the memory system, the memory protection table comprising a plurality of memory protection entries, each memory protection entry specifying: access rights of a corresponding address region of a variable size within an address space, and a region identification parameter for identifying a start address and an end address of the corresponding address region, wherein the MPU is configured to: allow the number of bytes of the variable size to be not a power of 2; and

[0007] The MPU memory access circuit is used to initiate at least one MPU memory access request to access the memory protection table from the memory system.

[0008] At least some examples provide a method including:

[0009] issuing a memory access request specifying a target address identifying a location in the memory system to be accessed; and

[0010] Checking whether the memory access request satisfies access rights specified in a memory protection table including a plurality of memory protection entries, each memory protection entry specifying: access rights of a corresponding address region of a variable size in an address space, and a region identification parameter for identifying a start address and an end address of the corresponding address region, wherein the variable size is allowed to be a number of bytes that is not a power of 2;

[0011] in:

[0012] A memory protection table is stored in the memory system.

[0013] At least some examples provide a computer program for controlling a host data processing device to provide an instruction execution environment for executing instructions; the computer program comprising:

[0014] handler logic to issue a memory access request specifying a target address identifying a location to be accessed within a simulated address space simulated by the instruction execution environment; and

[0015] Memory Protection Unit (MPU) program logic, including:

[0016] a permission checker logic to check whether a memory access request issued by the processing program logic satisfies access rights specified in a memory protection table including a plurality of memory protection entries, each memory protection entry specifying: access rights of a corresponding address region of variable size in the simulated address space, and a region identification parameter for identifying a start address and an end address of the corresponding address region, wherein the MPU program logic is configured to: allow the number of bytes of the variable size to be not a power of 2; and

[0017] The MPU memory access program logic is configured to initiate at least one MPU memory access request specifying an address from the emulated address space to access the memory protection table. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0019] Figure 1 Schematically illustrates an example of a data processing device having an MPU;

[0020] Figure 2 An example of a memory protection table stored in a memory system is shown;

[0021] Figure 3 An example of an MPU cache storage device for caching memory protection entries from a memory protection table is shown;

[0022] Figure 4 An example of a register storage device of an MPU is shown;

[0023] Figure 5 shows how memory-based MPU entries or static MPU entries can cover different address regions of the address space;

[0024] Figure 6 is a flow chart illustrating a method of controlling access to a memory system using an MPU;

[0025] Figure 7 is a flow chart showing a method for searching a control table based on a binary search process;

[0026] Figure 8 A specific example of a binary search process for a table including up to 16 entries is shown;

[0027] Fig. 9 shows a sample of the binary search process;

[0028] Fig.10 shows an example of lazy state saving;

[0029] FIG. 11A to FIG. 12B A flow chart illustrating an example of controlling lazy saving is shown; and

[0030] Fig.13 An example of a simulator that can be used is shown. DETAILED DESCRIPTION

[0031] Controlling access to memory

[0032] A method for controlling access to a memory system may be to provide a memory management unit (MMU) that checks whether a memory access request satisfies access permissions specified in a page table stored in the memory system. The address space is typically divided into regions called pages, each page having a size corresponding to a number of bytes that is a power of two (e.g., 4 kilobytes), wherein the start and end addresses of each page are aligned with N-byte address boundaries, where N is the size of the corresponding address region. Each page entry specifies access permissions for a corresponding page in the address space, and typically also specifies an address translation map for mapping a target address in a first address space (e.g., a virtual address space) to a corresponding address page in a second address space (e.g., a physical address space). The page table may be implemented as a hierarchical table structure including many levels of page tables, wherein a first bit subset of an input address indexes a corresponding entry in a first level page table, and the indexed entry specifies a base address of a second level page table, based on which entries may be indexed based on a second bit subset of the input address, and so on for each subsequent level of the table until finally reaching a final level of the page table, where the indexed entry is selected based on a specified number of address bits. The indexed entry contains the actual address translation attributes and access permissions required for memory accesses targeting the page. The MMU may have a cache (referred to as a translation lookaside buffer (TLB)) that may cache certain entries of the page table that have been more recently accessed from the memory system so that these entries may be accessed again more quickly when the processing circuit issues multiple memory access requests requiring the same page entry. An MMU may be used in a processor designed to handle relatively high performance workloads, for which it is acceptable to set controls for access to many different address regions (e.g., such controls may be performed at a 4 kilobyte granularity), and for which arbitrary address translation mappings from any page in a first address space to any page in a second address space may be required in order to handle accesses triggered by many different software processes (which use the same virtual addresses but need to be mapped to different physical addresses used by the memory system).

[0033] However, for processors targeting more energy efficient workloads or designed for real-time applications, an MMU may not be suitable because the large page table structure and granularity of control used to define access permissions to individual pages may be too large for the constrained memory environments typically seen in systems targeting more energy efficient, lower performance applications (which may have only a couple of kilobytes of random access memory (RAM)). In addition, to facilitate the use of a subset of input address bits as an index into the page table, the MMU typically restricts each page to have a size corresponding to a power-of-two byte number. This means that if a certain access permission group needs to be set only for a certain address region having a size other than a power-of-two byte number, this would need to be represented using many separate page entries (each corresponding to a smaller page having a size of a power-of-two byte number), where each of these entries defines exactly the same access permission, so that the group of page entries as a whole corresponds to a larger non-power-of-two sized address region. This artificial division of the address region into multiple pages is the result of restricting the pages to be aligned with address boundaries corresponding to the page size (such restrictions are required to achieve an efficient indexing process, in which the full number of bits from the input address is used to index the hierarchical page structure used to cover the large address space).

[0034] However, for real-time code, this approach can cause some problems because it means that, within a code segment or data intended to be governed by a given set of access rights, memory accesses may cross page boundaries between pages corresponding to different page entries in the page table, and therefore if the page entry for the new page has not yet been cached in the MMU, this may require a page table lookup to be performed midway through the execution of the code segment to fetch the required page entry from memory. In addition, if upon reaching a page boundary, it is found that the page entry for the next page has not yet been defined in the page table, this may cause an error, which may be handled slowly because a software exception handler may be required to trigger an operating system or other supervisory process to set up a page entry to map the required page, resulting in a long delay. Such delays may be highly variable in duration, and in the worst case may be extremely long, and if a code segment issues a memory access to an address that spans more than two different pages, such a delay may be incurred again at each page boundary. This makes it very difficult for the MMU to meet the requirements of having a deterministic response time in real-time applications.

[0035] Another method for controlling access to memory may be to provide a memory protection unit (MPU) that checks whether a memory access request issued by a processing circuit satisfies the access rights specified in a number of memory protection entries. Each memory protection boundary 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 bounded by a start address and an end address (identified by a parameter of a given memory protection entry). Unlike the page table used by the MMU, for the MPU, the region corresponding to the memory protection entry may have a variable size (may be allowed to be a number of bytes that is not a power of two). With this method, it can be ensured that a single memory protection entry can be used to define a memory address region of arbitrary (non-power of 2) size to avoid the risk of page lookups and page faults that occur each time 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 typically stores each of the memory protection entries in registers provided locally within the MPU, which can be accessed quickly, thereby 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.

[0036] However, in a system including an MPU, a disadvantage is that because the configuration data for controlling access to memory is specified using registers that are typically directly connected to a column of parallel comparators that are used to compare a target address to be accessed with a region identification parameter for each memory protection entry stored in the registers, the power and area associated with the MPU increases severely in proportion to the number of memory protection entries supported by the MPU. In practice, this may mean that the number of supported memory protection entries may be limited to a relatively small number, such as 8 or 16. The limited number of memory protection entries in a typical MPU may have a severe impact on the performance achieved by software executing on the processing system.

[0037] For example, a portion of the software may need to define a larger number of different address regions as having different access permissions than supported by hardware, in terms of the number of protection entries supported by the MPU. In this case, at any given time, at least some portions of the address space required for access by the software do not currently have corresponding memory protection entries defined for these portions. This would mean that access to addresses in currently undefined regions of the address space would trigger an exception, which would then require software intervention and reconfiguration of the MPU's registers to overwrite the parameters previously defined for different regions with the parameters required to access the required region now. If a subsequent instruction then accesses a previously defined region that has been overwritten, this may then cause the MPU configuration to switch back. Such constant switching of the contents of the MPU registers (requiring an exception each time to trigger the switch) greatly impairs performance.

[0038] Another example may be that the processor needs to execute multiple software parts that do not trust each other, but these software parts need to share data between them. In order to achieve the sharing of data, a given software part may want to split the parts of the address space so that only a limited part of the address space can be accessed by other processes, but in order to provide such a fine degree of control over access to the address space, this may require defining additional address areas, and there may not be enough free memory protection entries supported by the MPU in the hardware to allow such fine-grained control. Therefore, in practice, the same data may end up being copied to multiple parts of the address space, one copy in the part accessed by the first software, and another copy in the part accessed by the second software, which results in a waste of time in performing the copy and inefficient use of available memory capacity, which is a more particular problem in systems with limited memory resources.

[0039] Thus, typical MMUs and MPUs currently do not provide an efficient solution for controlling access to a memory system based on per-region defined access permissions in systems having real-time requirements and / or relatively limited memory capacity.

[0040] MPU with memory-based memory protection table

[0041] In the technology discussed below, an MPU is provided, the MPU including a permission check circuit, the permission check circuit is used to check whether a memory access request issued by a processing circuit satisfies the access rights specified in a memory protection table stored in a memory system. The memory protection table includes a plurality of memory protection entries, each memory protection entry specifying access rights for a corresponding address region of variable size within an address space. Each entry also specifies region identification parameters, which are used to identify the starting address and the ending address of the corresponding address region. The MPU allows the number of bytes of variable size to be not a power of 2. An MPU memory access circuit is provided to initiate at least one memory access request to access the memory protection table from the memory system.

[0042] Therefore, by providing a memory protection table in the same memory system that is governed by the MPU, this provides the flexibility to provide a larger number of memory protection entries, which is practical for a typical MPU (which is based on registers that store region definition data that is compared to the target address in parallel for each entry). It may be counterintuitive that moving the memory protection table into the memory system (access to which is typically slower than registers) provides improved software performance. However, while accessing a single memory protection entry from the memory system may be slower, overall performance can be improved by avoiding the software workaround discussed above for handling situations where the number of entries supported by the MPU in hardware is insufficient to handle software requirements (otherwise a large performance cost would be incurred due to frequent exceptions caused by access to undefined areas of the address space). With a memory protection table provided in memory, the hardware cost increases much more slowly with the number of entries.

[0043] Furthermore, by allowing each region to have an arbitrary size corresponding to a number of bytes that is not a power of 2, this means that each region can cover a large amount of memory without having to subdivide regions that are intended to have the same access rights into multiple separate entries, which would lead to the risk of memory protection errors when addresses cross region boundaries. This makes the MPU better than the MMU at servicing real-time applications that need to process critical operations with fast and / or deterministic response times.

[0044] The entries of the memory protection table may be arranged in the address space in the order of the starting address of the corresponding address region of each entry. This may be different from the page table structure used by the MMU, for which each level of the page table may include an entry with a pointer to a page table of another level, and thus within the entire page table structure, the page entries of the final level (which actually provides access rights to the corresponding pages) may be arranged in the address space in an order different from the order of the starting address of each corresponding address page. By implementing the memory protection entries of the memory protection table as a linear access table arranged in the order of the starting addresses, this may make it easier to search the memory protection table for the relevant memory protection entries for a given target address.

[0045] Each memory protection entry corresponds to a given address region of an address space. In some embodiments, the address space may be a physical address space. Thus, the memory protection table may be queried based on a physical address specified by a memory access request issued by the processed circuit, wherein the physical address directly corresponds to a corresponding location accessed in the memory system. This may be suitable for real-time applications because, by avoiding address translation, this may make access to memory faster because access to memory may be performed in parallel with access to the memory protection table. If it is subsequently determined that the permissions are not satisfied, the data returned by the access to the memory will not be forwarded to the processing circuit.

[0046] When the MPU memory access circuit initiates at least one MPU memory access request to access the memory protection table from the memory system, this may require accessing multiple memory protection entries of the memory protection table, rather than just accessing the memory protection entries corresponding to the address region including the target address. This is because, when each entry can correspond to a variable-sized region of a non-power-of-two number of bytes, the address of the entry associated with a given address region in the memory system may not be known in advance, and therefore it may actually be necessary to search the table to find an entry for the region including the target address, which may require accessing more than one entry to compare the target address with the region identification parameter of the entry. Therefore, if the target address is located in the corresponding address region of a given memory protection entry of the table, at least one MPU memory access request may be issued, and at least one of the issued (one or more) MPU memory access requests may target the given memory protection entry (and there will typically also be MPU memory access requests for other memory protection entries).

[0047] For each memory protection entry, the MPU may allow the start and end addresses of the corresponding address region to be not aligned with N-byte address boundaries, where N bytes is the size of the corresponding address region. This enables the MPU to manage access rights to any single address region of arbitrary size starting at an unaligned address, which helps avoid artificially splitting regions with shared properties into multiple entries, which is required in systems that constrain regions to start at aligned address boundaries, which can help improve the performance of real-time code for the reasons discussed above.

[0048] The MPU may have a static MPU register storage device for storing at least one static memory protection entry. The at least one static memory protection entry may provide further definition of an address region with specified access rights to supplement the rights defined in the memory protection entry of the memory protection table stored in the memory system. Providing some configuration options to provide additional MPU regions defined in the static register storage device can be used to keep interrupt latency low and provide deterministic interrupt behavior. For example, the static MPU register storage device may define access rights for certain key address regions to be accessed by performance-critical code so as to provide a faster response than when these access rights need to be checked by memory protection entries loaded from the memory system. Therefore, in an embodiment with a static MPU register storage device, the MPU may actually be a hybrid MPU that uses both register-based entries defining some address regions and memory-based entries defining other address regions. This can provide a good balance between interrupt latency and the real-time guarantees required by some systems, and between the hardware cost of implementing the MPU and the performance achieved by software (which needs to define a large total number of memory protection entries at a given time).

[0049] The static MPU register storage device is static in the following sense: in the absence of a system reset or power-off event, once configured by at least one MPU parameter configuration operation processed by the processing circuit, the static memory protection entries stored in the static MPU register storage device remain stored in the static MPU register storage device until the processing circuit processes another MPU parameter configuration operation to trigger reconfiguration of the static memory protection entries. An MPU parameter configuration operation can be any operation that changes the attributes specified for a given address region (e.g., changing the access rights or changing the boundary address of the region) so that the manner in which memory accesses are processed for a portion of the address space can be changed. An MPU parameter configuration operation can be a dedicated MPU configuration instruction executed by the processing circuit, or can be a storage instruction that specifies an address of the static MPU register storage device mapped to the MPU as the target address of the storage instruction. An MPU parameter configuration operation can also be an operation performed by the processing circuit requested by a debugger or other entity external to the processing circuit. Thus, while a static memory protection entry is active in the static MPU register storage, this differs from a cache in that the static memory protection entry will remain until it is reconfigured, regardless of which addresses are accessed by the system. In contrast, a cache will evict a cached entry when the entry has not been used for a period of time or based on some other eviction policy, in order to make room for an entry for a different address that may be needed, without requiring any MPU configuration operations to be performed by the processing circuitry. In the case of a cache, while the particular entries of the cache may change over time, this does not imply any change in the underlying attributes specified by a given memory protection entry of the memory protection table, as changes in cache occupancy only affect the latency with which a given memory protection entry can be obtained, and do not change the functional definition of how memory accesses to a given address are handled.

[0050] In response to a memory access request issued by a processing circuit, the MPU memory access circuit may suppress at least one MPU memory access request from being issued to a memory system when the target address is within a corresponding address region of a static memory protection entry stored in a static MPU register storage device and the issued memory access request satisfies the access rights specified by the static memory protection entry. Thus, when there is a hit in a static memory protection entry, no MPU memory access request for retrieving a memory protection entry of a memory protection table needs to be triggered. This helps to reserve memory bandwidth that can be used for other operations and means that performance-critical software using static entries stored in a static MPU register storage device will not be paused due to memory-based region lookups. In practice, static memory protection entries may take precedence over memory-based entries of a memory protection table.

[0051] The situation where the target address of a memory access request hits a static memory protection entry but the access request cannot satisfy the access rights specified by the static memory protection entry can be handled in different ways. In some cases, at least one MPU memory access request can also be suppressed when the memory access request cannot satisfy the access rights specified in the static memory protection entry for which the target address is in the corresponding address region. Thus, in this case, if there is any hit in the static MPU register storage device, there is no need to access the memory protection table in the memory system.

[0052] Alternatively, for a memory access request that hits a static memory protection entry but does not pass the access permission in the static memory protection entry, the access permission can be allowed to be overridden by the access permission specified by the matching memory protection entry in the memory protection table stored in the memory system (the matching memory protection entry includes the following entry: the corresponding address area for the entry includes the target address). Therefore, a hit in the static MPU register storage device overrides any permission group in the memory-based memory protection entry when the request is allowed, but a hit in the static MPU register storage device can be overridden by other access permissions specified in the matching memory protection entry of the memory protection table when the request is not allowed by the static entry. This method can be used to reduce the total number of areas that need to be defined to allow a first software process to access a specific sub-area of ​​an address area accessed by a second software process. For example, a static MPU entry can be set for a wider address area to allow the second software process to access the area but deny access to the first software process. Then, a memory-based memory protection entry covering a smaller address area within the wider area can be specified only for the sub-range allowed to be accessed by the first software. This may avoid the need to provide separate entries for the wider range portions either side of the sub-range accessed by the first software, thereby reserving other static memory protection entries for other uses or achieving a reduction in the overall size of the memory protection table.

[0053] Each static memory protection entry may be associated with an unused indication that indicates whether the static memory protection entry is an unused static memory protection entry. When a given static memory protection entry is indicated as being an unused static memory protection entry, the MPU may cache the memory protection entry from the memory protection table in a portion of the static MPU register storage device corresponding to the given static memory protection entry. Therefore, when the software does not require as many static memory protection entries as supported in the hardware, a portion of the hardware register storage device may be reused as a cache to enable local storage of memory protection entries from the memory protection table, so that the entries may be accessed more quickly than when the entries need to be retrieved from the memory system. This may improve performance. When a given static memory protection entry is marked as unused, which particular memory protection entry is cached in the static MPU register storage device may vary over time according to a cache replacement policy, even when the processing circuit has not yet performed any MPU parameter configuration operations.

[0054] Thus, when a static memory protection entry is marked as used (i.e., the entry does not have an unused indication set), then the data in that portion of the static MPU register storage device may remain stored until reconfigured by an MPU parameter configuration operation, but when a static memory protection entry is indicated as unused, then the static memory protection entry may be used as a cache, in which case the particular entry provided in the static MPU register storage device may be changed according to an address access pattern as performed by the processing circuit. For static memory protection entries that are not marked as unused, there may also be a separate enable / disable indication, which when set to enabled means that the entry is valid and can be hit by a target address of a memory access request, while for disabled entries, the MPU will always return a miss even if the target address matches an area defined by the disabled entry. Disabled entries may differ from unused entries in that the portion of the static MPU register storage device corresponding to the disabled static memory protection entry cannot be used as a cache for caching entries from a memory protection table in memory. Software can temporarily disable a specific static memory protection entry so that access to the address range is denied, but continue to keep the static memory protection entry in the static MPU register storage device so that it can be re-enabled later if necessary. In the case of an unused static memory protection entry, it means that the corresponding register storage device can be used as a cache to improve performance, but there is no guarantee that the contents of the static MPU register storage device before the unused indication is set can be retained.

[0055] The MPU may include an MPU cache storage device to cache at least one memory protection entry of a protection table. In the case where the entry is marked as unused as discussed above, the MPU cache storage device may be a static MPU register storage device. However, it may also be useful to provide a dedicated MPU cache storage device provided to cache entries from the memory protection table, the dedicated MPU cache storage device acting as a cache regardless of how the static memory protection entries (if provided) have been configured. The MPU cache storage device may be implemented using another set of registers within the MPU similar to the static MPU register storage device, or the MPU cache storage device may be implemented using different types of data storage devices (e.g., SRAM). In some cases, the static MPU register storage device and the MPU cache storage device may be parts of the same storage structure, with some parts being partitioned for use as cache storage devices and other parts being partitioned to store statically configured memory protection entries.

[0056] Thus, the MPU cache storage is provided to cache at least one memory protection entry of the memory protection table. The MPU memory access circuitry may use a cache replacement strategy (e.g. least recently used, round robin, etc.) to determine which set of memory protection entries from the memory protection table to cache in the MPU cache storage at a given time. This means that, compared to the portion of the static MPU register storage storing static memory protection entries not marked as unused, the MPU cache storage may be updated even if the processing circuitry has not performed any MPU parameter configuration operations.

[0057] In response to a memory access request issued by the processing circuit, the MPU memory access circuit may determine whether to initiate at least one MPU memory access request based on whether the target address is within a corresponding address region specified for any memory protection entry stored in the MPU cache. For example, the MPU cache storage device may be searched first, and if there is a hit in the MPU cache storage device, no MPU memory access request may need to be initiated. The cache replacement strategy may be intended to retain memory protection entries that are predicted to be most useful in the future so as to reduce the portion of the memory access request for which an MPU memory access request needs to be issued. Therefore, if there is a hit in the MPU cache storage device, at least one MPU memory access request may be suppressed.

[0058] The processing circuit may retrieve an entry identifier in response to an entry identifier query instruction, the entry identifier identifying the location in the memory protection table where a given memory protection entry is obtained. For example, the entry identifier query instruction may specify a target address, and in response, the processing circuit and / or the MPU may return an indication of the entry identifier of the memory protection entry that matches the target address. The entry identifier may be made accessible to software executed on the processing circuit by writing the retrieved entry identifier to an architectural register of the processing circuit. The MPU cache storage device may specify, for each cached memory protection entry, an entry identifier associated with the location in the memory protection table where the cached memory protection entry is obtained. This means that, for cached memory protection entries, the processing circuit may service the entry identifier query instruction more quickly because there is no need to initiate an MPU memory access request to the memory system to identify the entry identifier associated with the address hit in the cached memory protection entry. Instructions capable of retrieving the entry identifier of a given memory protection entry (rather than just returning access rights) may be used to accelerate certain types of security checks or provide confidence that a code segment will run in a deterministic time. By executing an entry identification query instruction for a given address pair, and then if both entry identifier query instructions return the same entry identifier, it can be determined that the entire address range between the address pair corresponds to the same memory protection entry, so that it can be guaranteed that there will be no errors caused by accessing unmapped address regions between the specified address pairs. This can also improve performance because it means that when it has been determined that the entire address range falls entirely within a single memory protection region, a single access permission check can be performed for the range, rather than requiring each individual address within the range to be checked separately. Therefore, caching the entry identifier associated with the cached memory protection entry in addition to any parameters of the entry itself in the MPU cache storage device can be used to speed up the execution of the processing circuit when executing such an entry identifier query instruction.

[0059] The processing circuitry may allow operation in multiple security states, each of which may be subdivided into multiple privilege levels. The processing circuitry may allow rapid transitions between security states, such as by allowing code to branch to other security states. Each of the multiple security states may have an associated memory protection table to be used when the processing circuitry executes instructions in that security state. In order to reduce the amount of MPU cache storage required, an MPU cache storage device may be shared between multiple security states, wherein each entry in the cache specifies a security state identifier that is used to identify the security state used by the processing circuitry when obtaining a protection entry from the memory protection table. The MPU may suppress the use of the following cached entries stored in the MPU cache storage device: for these cached entries, the security state identified by the security state identifier is different from the security state currently active for the processing circuitry. Therefore, entries associated with inactive security states may be kept cached in the MPU cache storage device, but are not detected as matching a target address when the current active security state table is different from the security state identified by the security state identifier. This achieves improved performance when switching between different security states because even if the active security state is reconfigured by the processing circuitry, if the active security state is subsequently switched back to the previous active security state, some cached memory protection entries associated with that security state will still be present in the cache and can therefore be accessed more quickly to improve performance.

[0060] Alternatively, instead of marking cached memory protection entries with a security state identifier, another approach may be to invalidate all entries in the MPU cache storage in response to the active security state being modified by the processing circuitry. While this may require repopulating the cache with entries from the memory protection table associated with the new active security state after the active security state is switched, this approach may make the MPU cache storage smaller because a security state identifier field need not be provided for each cached memory protection entry.

[0061] The MPU cache storage device may specify for each cached protection entry a table identifier associated with a memory protection table from which the cached memory protection entry was obtained. A plurality of separate memory protection tables may be established within the memory system, such as different tables corresponding to different software parts. Each memory protection table may be identified by a given table identifier. For example, the table identifier may be an arbitrary numerical value assigned to the table, or an indication of a base address of the memory protection table may be used as the table identifier. The device may have an active table identifier register for storing an active table identifier, which identifies the active memory protection table that is currently to be used to check access rights to the memory. The MPU may suppress the use of the following cached memory protection entries stored in the MPU cache storage device: for the cached memory protection entry, the table identifier associated with the cached memory protection entry is different from the active table identifier stored in the active table identifier register. Thus, entries associated with an inactive memory protection table may be kept cached in the MPU cache storage device, but are not detected as matching a target address when the currently active table is a different memory protection table. This allows improved performance when switching between different software processes using different memory protection tables because even if the active table identifier register is reconfigured by the processing circuitry to switch to a different memory protection table, if the active memory protection table is later switched back to a previously accessed table, some cached memory protection entries associated with that table will still exist in the MPU cache storage device and can therefore be accessed more quickly to improve performance.

[0062] Alternatively, instead of marking cached memory protection entries with corresponding table identifiers, another approach may be to cause all entries in the MPU cache storage to be replaced in response to the active table identifier register being modified by the processing circuitry. While this may require refilling the cache with entries from the newly active memory protection table after the active table is switched, this approach may make the MPU cache storage smaller because a table identifier field need not be provided for each cached memory protection entry.

[0063] In response to a memory protection cache invalidation operation, the processing circuit may trigger the MPU to invalidate one or more cached memory protection entries stored in the MPU cache storage device that meet the invalidation condition. For example, the memory protection cache invalidation operation may be a specific instruction executed by the processing circuit. The memory protection cache invalidation operation may specify one of many different criteria for the invalidation condition. For example, a first type of cache invalidation operation may specify that all entries in the MPU cache storage device should be invalidated. A second type of memory protection cache invalidation operation may identify a specific address or address range of a cached memory protection entry to be invalidated, wherein the cached memory protection entry defines an area that does not partially or completely overlap with a reserved specified address range. Other options for the invalidation condition may be that if the cached memory protection entries correspond to at least one of a specific table identifier, a security state identifier, or have an entry identifier within a specific range, then these cached memory protection entries should be invalidated. Therefore, there are many different options for controlling the invalidation of entries from the cache. This is useful because when the processing circuitry, under software control, reconfigures part of the memory protection table to change parameters specified for a particular address region, then it may also trigger invalidation of corresponding entries from the MPU cache storage device to ensure that old values ​​of access permissions are not retained in the cache.

[0064] The memory protection entries stored in the memory protection table in the memory system may include an indication of whether the memory protection entry is an enabled entry that provides valid access rights or a disabled entry that provides invalid access rights. This can be used to temporarily disable access to certain address regions while retaining the region parameters in the disabled memory protection entry so that once the region is enabled later, there is no need to reconfigure these region parameters. The MPU cache storage device may be prohibited from caching the disabled entries of the memory protection table. For example, the MPU memory access circuit may return a hit signal only for the enabled entry when looking up the table, and the memory protection entry may be assigned to the MPU cache storage device only when a hit is detected in the memory protection table in the memory. This can be used to avoid caching disabled entries from the memory system because it means that dummy entries can be inserted into the memory protection table in the memory for potential use later, and these entries can be configured and enabled without invalidating any cached entries.

[0065] The table identifier of the active memory protection table can be represented in different ways. In one example, the base address can be used alone to identify the table identifier. Alternatively, in some cases, a combination of the base address and the size can be used to identify the table. If the memory protection tables to be accessed by two different software processes overlap, this can be useful so that the shared portion of the memory protection table can be stored at an address starting at the base address, and then the portion of the memory protection table that will be used only for a specific software process can be located at the subsequent portion of the address space, so that the switching between different memory protection tables accessed by different software parts can be achieved simply by changing the size indication to indicate how big the active memory protection table is. In some cases, the base address and size can be specified in a single register of the MPU. However, in systems that support relatively large addresses, the base address and size indication may not fit in one register, and therefore sometimes a separate register may be required. Therefore, a base address register can be provided to store the base address of the active memory protection table to be accessed by the MPU memory access circuit in response to a memory access request issued by the processing circuit, and a size register can be provided to store an indication of the size of the active memory protection table. It should be understood that both the base address register and the size register may also specify other parameters in addition to the base address and size, respectively.

[0066] When the base address and size of the active memory protection table are specified in different registers, then this means that separate MPU configuration operations may need to be performed by the processing circuitry to update the base address and size of the active memory protection table, respectively. This may present a risk of a race condition where undefined behavior occurs in the period between a first configuration operation to update one of the base address and size and a second configuration operation to update the other of the base address and size, because changing one of the base address and size but not the other may present a risk of a region being indicated as an active table that includes information intended to be a memory protection entry.

[0067] To reduce this risk, in response to a predetermined type of MPU configuration operation that specifies that one of a base address and a size of an active memory protection table is to be updated, in addition to updating the one of the base address and the size, the processing circuitry also updates the other of the base address and the size to an invalid value indicating that there is no active memory protection table. By effectively completely disabling access to the memory protection table when one of the base address and the size has been updated until the other has also been updated, there will not be any improper operation caused by an MPU memory access request that accesses a portion of the address space that is not intended to be part of the memory protection table.

[0068] In one embodiment, the predetermined type of MPU configuration operation may be an operation that specifies that the base address is to be updated, and may specify that the size is to be cleared to an invalid value indicating that there is no active memory protection table. Therefore, one of the base address and the size that is specified to be updated by the predetermined type of MPU configuration operation may be the base address. This is easier to implement. The predetermined type of MPU configuration operation may be a dedicated instruction or command, but may also be simply the following conventional storage instruction executed by the processing circuit: the conventional storage instruction specifies the address mapped to the base address register or the size register that specifies one of the base address and the size that will not be set to an invalid value as the target address of the conventional storage instruction. In some cases, all MPU configuration operations that update the base address or size may also clear the other to an invalid value. Alternatively, this may not always be required, and only certain types of MPU configuration operations may clear the other of the base address and the size to an invalid value. For example, a specific type of instruction for triggering an MPU configuration operation may signal whether the other of the base address and the size that is not configured as a specified value by the operation should also be cleared to invalid. In other examples, the "clear size to invalid" control can be activated by a bit in the base address register itself, so that if the base address register is written and the "clear size to invalid" flag is set in the new value to be written to the base address register, the MPU will also clear the size to an invalid value.

[0069] The MPU memory access request issued by the MPU to obtain an entry from the memory protection table may itself need to be checked for certain access rights. However, it may not be desirable to check whether the MPU memory access request is allowed based on the memory detection table itself, because this may result in a recursive lookup group of the memory protection table, which may result in a potentially non-deterministic response time or a never-ending request loop causing a deadlock. Different methods can be used to handle the check of the MPU memory access request itself. In one example, the permission check circuit can determine whether at least one MPU memory access request is allowed based on a preset group of access rights that is independent of the memory protection table. Therefore, by using a preset group of permissions (which can be, for example, hardwired or specified in a configurable register of the MPU), there is no need to look up the memory protection table in the memory to determine whether the MPU is allowed to issue a memory access request to a specific address. This can help improve real-time processing.

[0070] Alternatively, or in addition to checking the MPU memory access request against a preset group of access rights, the permission checking circuit may also determine whether the MPU memory access request is allowed based on whether the address of at least one MPU memory access request is in at least one of a plurality of address ranges specified by a plurality of memory security configuration registers. For example, the memory security configuration register may specify information defining which address ranges may be accessed from a given one of the plurality of security states discussed above. For example, some systems may support defining a secure portion of an address space that may only be accessed by certain secure processes and a non-secure portion of an address space that may be accessed by either secure or non-secure processes, and therefore require checking the MPU memory access request against the secure / non-secure regions defined by the memory security configuration register. In this case, if the target of the MPU memory access request triggered by non-secure code is an area defined as part of the secure address space in the memory security configuration register, these MPU memory access requests may be denied. The permissions defined by the memory security configuration register may be orthogonal to the permissions provided by the memory protection table and the static MPU entries. Therefore, in addition to checking the MPU memory access requests against the memory security configuration register, the memory access requests issued by the processing circuit in response to instruction fetch requests or regular load / store instructions can also be checked against the memory security configuration register to check whether these memory access requests are allowed.

[0071] In some examples, the entry may be marked as "locked" by setting a lock indication associated with the cached memory protection entry. The MPU may prevent the locked cached memory protection entry from being evicted from the cache. For example, the MPU may prevent the locked cached memory protection entry corresponding to the address region including the stack data structure (used to save the architectural state in response to an exception and restore the saved state in response to an exception return). By locking the entry corresponding to the stack so that the entry cannot be evicted, this ensures a fast exception handling response by reducing the delay of state save / restore. The MPU may use the stack pointer address stored in the stack pointer register of the processing circuit to determine which entry corresponds to the stack. The locking of the MPU entry associated with the stack may be performed at any time. However, in one example, in response to an exception return when the state is restored from the stack, the MPU entry associated with the current stack pointer address may be locked so that if another exception or interrupt occurs during or just after the exception return, the entry of the stack may still be obtained in the MPU cache storage device, and thus the state may be saved more quickly for another exception or interrupt.

[0072] In other embodiments, the use of a lock indication associated with each cached memory protection entry may be avoided by having a dedicated entry within the MPU cache storage that is used only to store entries from the memory protection table associated with the stack data structure. This dedicated entry may be populated at any time. However, in one example, in response to an exception return when the state is restored from the stack, the MPU entry associated with the current stack pointer address may be populated into the dedicated entry.

[0073] In some embodiments, in response to an exception, the processing circuit may use lazy saving. When an exception occurs, the processing circuit may need to save some architectural states associated with the outgoing process executed before the exception occurs to the memory system, so that even if the process executed after the exception rewrites the architectural state, the saved state is retained. The state associated with the outgoing process can be restored later when the process returns from the handling exception. Saving the state from the architectural register to the memory system can be relatively slow, and therefore in order to reduce interrupt processing delays, some systems may save only the first part of the architectural state to the memory system in response to the exception itself. The second part of the architectural state may not be saved directly in response to the exception, but the second part of the architectural state may be saved only when the subsequent software process executed after the exception actually accesses the second part of the architectural state. For example, the second part of the architectural state may be the content of a floating point register for storing floating point values, and the first part of the architectural state may be the content of an integer register. This is useful because many software processes may not use any floating point registers, and therefore if a subsequent software process executing after an exception condition never accesses the floating point registers, the state associated with the previously executed process will be preserved and therefore there is no need to perform state save and restore for those floating point registers.

[0074] While such lazy saving may be useful for performance, it may cause some complexity when the MPU uses memory protection tables stored in the memory system. In order to allow a consistent stack frame to be used in memory to retain the first and second parts of the architectural state (regardless of whether the second part of the architectural state has actually been saved to the memory), in response to an exception, the processing circuit may record an indication of the second part state save address area: if a subsequent software process accesses the second part of the architectural state, the second part of the architectural state will be saved at the second part state save address area. Therefore, when a subsequent software process initiates access to the register storing the second part of the architectural state, the processing circuit may then read the recorded address identifying the second part state save address area and then save the second part of the architectural state to the identified address area. By reserving space for the second part of the architectural state even when it has not been saved, this means that the size of the stack frame is the same for each exception, so that when exceptions are nested, the location of subsequent stack frames is the same regardless of whether the second part of the architectural state is actually saved. This makes control state recovery much simpler.

[0075] However, because the memory access itself for saving the second portion of the architectural state to the memory system may need to be checked against the MPU, and the active memory protection table often changes in response to an exception situation, the relevant access rights for checking whether a process executing prior to the exception situation was allowed to save the second portion of the architectural state of the process to the address specified for the second portion state save address area may no longer be available.

[0076] Thus, in response to an exception, the MPU may record MPU check information for enabling the MPU to determine during execution of a subsequent software process whether a memory access for saving the second portion of the architectural state to the memory system will satisfy the access rights specified by the memory protection entry of the memory protection table that was active when the exception occurred. The MPU check information may include many different types of information. In some cases, the MPU check information may include a table identifier (e.g., a base address and an optional size) of the memory protection table that was active when the exception occurred, so that during execution of a subsequent software process, the previously active associated memory protection table may be identified, and the appropriate entry may be accessed to check whether the process executed prior to the exception has been allowed to save the state to the address specified for the second portion of the state save address area. The MPU check information may also include an indication of whether the start address and the end address of the second portion of the state save address area correspond to the same memory protection entry in the memory protection table that was active when the exception occurred. When the start address and the end address of the second partial state preservation address area both correspond to the same memory protection entry, this means that a single access permission check may be sufficient to determine that the entire second partial state preservation address area is allowed to be accessed, thereby avoiding the need to check each individual portion of the second partial state preservation address area against the entry of the memory protection table that is active when the abnormal situation occurs. In some embodiments, a single access permission check can be performed when the abnormal situation occurs, and the check result is saved, while in other embodiments, the access permission can be saved so that the check can be performed later even if the memory protection table has changed. Therefore, by saving some information about the memory protection table that was active when the abnormal situation occurred, this enables lazy preservation to work even if the active memory protection table changes in response to the abnormal situation.

[0077] A corresponding computer program may be provided for controlling a host data processing device to provide an instruction execution environment for instruction execution. The computer program may include a processing program logic and an MPU program logic corresponding to the processing circuit and MPU discussed above in function. Therefore, the memory access instructions in the program executed in the instruction execution environment simulated by the computer program may be processed in a manner similar to the memory access instructions in the program executed on the hardware actually including the processing circuit and MPU discussed above. The simulator computer program may present an instruction environment similar to the instruction environment provided by the actual hardware device to the software executed on the simulator computer program, even if there may not be any actual hardware providing these features in the host computer executing the simulator computer program. The functions of the hardware architecture discussed above may be simulated by providing program logic (such as an instruction set or data structure), which enables a general host computer to execute the code intended to be executed on a device with MPU support discussed above in a manner compatible with the results achieved on a device actually having such an MPU. The simulator computer program for controlling the host data processing device may be stored on a storage medium. This storage medium may be a non-transitory storage medium.

[0078] Table Lookup

[0079] The memory protection table discussed above is an example of a control table stored in a memory system that provides information used by a processing component to perform a given operation. In the case of a memory protection table, the processing component may be an MPU, and the operation performed may be to determine whether a given memory access is allowed. Another example of such a control table may be a table that defines which areas of an address space are secure areas or non-secure areas, and the operation performed based on the control table may be to determine whether the processing circuit should operate in a secure mode or a less secure mode, wherein the secure mode is selected when the address of the instruction being processed is within one of the secure address areas defined in the control table. Another example may be a control table that defines, for each address area represented by the control table, an identifier of a software library associated with the area, which may be used by the processing circuit to determine whether a given software library is allowed to call another software library.

[0080] Therefore, in the scope of processing situations, it is useful to provide a control table with many entries, each entry specifies any one of a first limit address and a second limit address and a size, so that the first limit address and the second limit address / size identify the limits of a corresponding address area of ​​variable size in the address space. The entries can be arranged in the control table in the order of the first limit address. Although supporting variable-sized areas for each entry can be used to reduce the number of entries required to represent a certain property set for an address area of ​​a given size (avoiding the need to artificially divide a larger address area into many separate fixed-sized entries), allowing variable-sized entries can make the implementation of the search of the control table more complicated. This is because, when supporting variable-sized areas, the position corresponding to a given address in the table may not be fixed, and therefore in practice in order to locate the entry corresponding to the given address, it may be necessary to perform some searching through the entries of the table to compare the query address with the parameters defining the limits of the corresponding address area (one of the first limit address and the second limit address and the size). Because the address space is sparsely allocated with entries in the control table, so that there may be some addresses that do not have any corresponding entries defined for the address region that includes the address, one can expect that a search of the control table will require a comparison of the first boundary address and the second boundary address used to define the other boundaries of each address region with one of the sizes, and therefore may require a large number of comparisons.

[0081] In the technology discussed below, a table lookup circuit is provided to perform a binary search process to identify whether a control table includes an entry corresponding to a query address. The binary search process includes a number of search window narrowing steps for narrowing a current search window of candidate entries of the control table to a narrower search window that includes fewer candidate entries. In a given search window narrowing step, the table lookup circuit narrows the current search window based on a comparison of the query address with a first boundary address of a selected candidate entry of the current search window, independent of a second boundary address or size of a selected candidate entry of the current search window. After a final search window narrowing step that narrows the current search window to a single candidate entry of the control table, the table lookup circuit can determine that the single candidate entry is the entry corresponding to the query address when the query address is within a corresponding address region defined by a first boundary address and a second boundary address or size of the single candidate entry.

[0082] Thus, with this method, each search window narrowing step only requires comparing the query address with the first limit address of a given selected candidate entry of the control table, so there is no need to load the second limit address or size from the memory system. The second limit address or size only needs to be compared for a single candidate entry resulting from the final search window narrowing step. Thus, for a given number of entries N in the control table, this method allows the number of comparisons to correspond to log2(N)+1 rather than to log2(N)*2, as would be the case if the second limit address or size needed to be checked for each search window narrowing step. This can represent a significant reduction in the number of comparisons required and the amount of data that needs to be loaded from the memory system to obtain the corresponding limits of the candidate entry being searched during the binary search. Thus, this can provide a search procedure that enables a control table stored in memory to be searched with better performance, thereby speeding up access to the control table and therefore speeding up the performance of operations that rely on information from the control table.

[0083] In the binary search process, the single candidate entry identified after the final search window narrowing step may be the only entry of the control table for which, as a result of performing the binary search process for the query address, the table lookup circuit triggers a memory access request to obtain the second limit address or size from the memory system. Therefore, there is no need to implement any load for any entry other than the single candidate entry of the control table in order to obtain the second limit address or size from the memory system. This reduces the number of required loads and thus improves performance. Please note that it is not excluded that while performing the binary search process to look up the table based on the first query address, there may still be a load performed to obtain the second limit address or size of the candidate entry other than the single candidate entry from the memory as part of a further lookup to find out whether a second query address different from the first query address has a corresponding entry in the table. Multiple lookups to the table may be processed in parallel for different query addresses, in which case the second lookup may still require the second limit address or size of the candidate entry other than the single candidate entry identified in the lookup for the first query address. Therefore, limiting the loading of the second limit address or size to only a single candidate entry identified after the final search window narrowing step applies only to the group of memory access requests triggered by the binary search process performed for the current query address, and does not exclude the loading of other entries in the table for obtaining the second limit address or size that may be triggered by other operations being performed in parallel with the binary search process of the current query address.

[0084] In some embodiments, there may be a cache in the memory system between the table lookup circuit and the memory containing the control table. The table lookup circuit makes a request to the cache, and if the request cannot be satisfied by the cache, the cache may make a request to the memory in response to retrieve the requested data. In some embodiments, the cache may request more data than originally requested, for example, it may request data sufficient to fill an entire cache line. Therefore, when the table lookup circuit performs a request to the cache only for the first boundary address, the cache may perform a request to the memory for a cache line that includes both the first boundary address and the second boundary address or size. It should be understood that even if the cache is requesting both the first boundary address and the second boundary address or size, the table lookup circuit may need to receive the first boundary address and compare it against the first boundary address (except for a single candidate entry identified after the final search window narrowing step), and thus reduce the power used and circuit complexity.

[0085] When the query address is outside the corresponding address region defined by the first and second limit addresses or the size of the single candidate entry identified after the final search window narrowing step, the table lookup circuitry may determine that the query address does not hit in the control table. That is, it may be determined that the control table does not include any entries associated with the address region including the query address. When the query address does not hit in the control table, the table lookup circuitry may perform at least one of the following steps: signaling an abnormal condition, and returning preset information to control the operation to be performed by the processing component.

[0086] The comparison performed at each search window narrowing step can be implemented in different ways. In some examples, the comparison can be a less-than comparison of the query address and a lower limit address representing the lower limit of the corresponding address region. Therefore, in this case, the first limit address can include the starting address of the corresponding address region. When the starting address of each region is compared, then when the comparison identifies that the query address is less than the starting address of the selected candidate entry, the search window can be narrowed so that at least one entry in the search window exclusion control table having a starting address greater than or equal to the starting address of the selected candidate entry is excluded from the search window.

[0087] Alternatively, the comparison at each search window narrowing step may compare the end address identifying the upper limit of the corresponding address region with the query address. In this case, the comparison may be a greater than comparison. In this case, when the query address is greater than the upper limit address (end address) of the selected candidate entry, the current search window may be narrowed to exclude at least one entry from the narrower search window exclusion control table having an end address equal to or less than the end address of the selected candidate entry.

[0088] Different options may be selected for determining whether the selected candidate entry itself is still part of the narrower search window after a given search window narrowing step. When the first boundary address is the starting address and the comparison determines that the query address is greater than or equal to the starting address, then it is possible that the query address may be within the corresponding address region of the selected candidate entry, and therefore the selected candidate entry may still be part of the narrower search window after the search window narrowing step. Similarly, if the first boundary address is the ending address and the comparison indicates that the query address is less than or equal to the ending address of the selected candidate entry, then again, the selected candidate entry may still be part of the narrower search window.

[0089] In some embodiments, when a given search window narrowing step determines in comparison that the query address is outside the corresponding address region of the selected candidate entry (e.g., because the query address is less than the starting address or greater than the ending address of the selected candidate entry), then for some embodiments, the selected candidate entry may be excluded from the narrower search window obtained by the given search window narrowing step. That is, because it is already known that the selected candidate entry will not be the entry corresponding to the query address, it may be necessary to exclude the selected candidate entry from the narrow search window, so that subsequent search window narrowing steps can more quickly identify the specific entry corresponding to the query address because fewer entries need to be considered in the remaining search window narrowing steps.

[0090] However, in other embodiments, when it is known that the query address is outside the corresponding address area of ​​the selected candidate entry, the selected candidate entry can still remain included in the narrower search window. This seems counterintuitive, because people may not think that it is useful to include candidate entries that are known not to correspond to the query address in the narrower search window. However, in fact, including the selected candidate entry in the narrower search window regardless of the comparison result can allow a more efficient circuit implementation with reduced critical path timing. For example, the corresponding entry identifier can be used in some embodiments to track the limits of the current search window and the position of the selected candidate entry. Therefore, if the selected candidate entry is to be excluded from the narrower search window, it may be necessary to calculate the start and end of the narrower search window to be used for the next search window narrowing step from the selected candidate entry identifier by adding or subtracting one to the identifier of the selected candidate entry. This ±1 operation may require additional hardware to add 1 or subtract 1 and may be on the critical timing path. Therefore, in some embodiments, if the selected candidate entry is still included in the narrow search window regardless of the comparison result, it is faster to identify the entry to be included in the narrow search window. In practice, this is less likely to result in the need for any additional search window narrowing steps than when the selected case of the selected candidate entry is excluded, because in practice, subsequent search window narrowing steps that perform comparisons for different candidate entries of the narrowed search window may later result in the exclusion of the selected candidate entry identified in the previous search window narrowing step anyway. Therefore, in some embodiments, by providing for setting the narrower search window to a logical start or end at the selected candidate entry, this can allow for more efficient control logic with shorter critical timing paths.

[0091] The candidate entry selected within a given search window narrowing step can be any entry of the current search window (including an entry at one of the outer boundaries of the search window in some cases). However, if the selected candidate entry is an entry at the midpoint of the current search window provided for the search window narrowing step, the binary search process may be more efficient. The midpoint does not need to be at the exact midpoint of the entry included in the current search window. In fact, when the current search window includes an even number of entries, it is impossible to select an entry at the exact midpoint, because no matter which entry is selected as the selected candidate entry, the entry will be closer to one end of the search window than the other end. If at each search window narrowing step, the selected candidate entry is as close to the midpoint of the current search window as possible, the maximum limit of the total search window narrowing step number required for a given number of entries in the table can be reduced. However, this is not necessary, and in some embodiments, any entry at the midpoint of the current search window can be used, which can lead to a reduction in power and circuit complexity.

[0092] Please note that in the search window narrowing step, when the search window includes only 2 candidate entries, one of the 2 entries is selected as the selected candidate entry, that is, the selected candidate entry will be at one of the outer boundaries of the search window. Therefore, in some cases, only for the search window narrowing step where the current search window includes at least 3 candidate entries, the selected candidate entry can be at the middle point of the current search window.

[0093] In some embodiments, the device may have an entry storage device storing at least one entry. The entry storage device may be an entry cache for caching at least one entry of a control table previously obtained from a memory system, and / or a static register storage device for storing at least one additional entry that can be configured by a static entry parameter configuration operation (wherein each additional entry specifies control information for a corresponding address region of variable size within an address space, for which the corresponding address region, the limit is identified by one of a first limit address and a second limit address and a size). For example, in the case where the control table is a memory protection table, the entry cache may correspond to the MPU cache storage device discussed above, and the static register storage device may correspond to the static MPU register storage device discussed above. Therefore, in addition to having access to the control table stored in the memory system, the lookup circuit may also have access to some entries stored locally to provide faster access to some entries.

[0094] If at least one control entry is stored in the entry storage device, the table lookup circuit can check whether the query address corresponds to at least one entry stored in the entry storage device, and determine whether to perform a binary search process based on whether the query address corresponds to any entry stored in the entry storage device. For example, in the case where the query address corresponds to an entry stored in the entry storage device, the binary search process can be completely omitted. For example, if the required entry is already cached in the entry cache, it may not be necessary to perform any access to the memory, and therefore the binary search process can be omitted. For entries in the static register storage device, as discussed above for the MPU example, different options can control whether the binary search process needs to be performed when there is a hit in the static register storage device. If there is any hit in the static register storage device, the binary search process can be suppressed in some cases. Alternatively, other examples may consider particular parameters specified within a matching entry in a statically registered storage device to determine whether to perform a binary search process (e.g., as discussed above by utilizing the MPU example, searching a table within memory may only be necessary when parameters of a matching statically configured entry indicate that memory access is not allowed, but the binary search process may be omitted when there is a hit in a statically configured entry indicating that memory access is allowed).

[0095] In the case of performing a binary search process, in some embodiments, the table lookup circuitry can use information derived from at least one entry stored in the entry storage device to improve the efficiency of the binary search process. For example, even when a given query address misses an entry in the entry cache or static register storage device, the fact that the entry does not match any required comparisons required to hit these locally stored entries can provide the following information: allowing the results of some comparisons performed within the binary search process to be known without the need to load any information from memory. For example, the table lookup circuitry can limit the current search window of an initial search window narrowing step of the binary search process based on information derived from at least one entry stored in the entry storage device. In addition, in a given search step of the binary search process, when the result of the comparison of the query address with the first limit address of the selected candidate entry can be derived from information in at least one entry stored in the entry storage device, a memory access request for obtaining the first limit address of the selected candidate entry from the memory system can be suppressed. Therefore, by using information that is already available from locally stored entries to guide the binary search process, this can avoid unnecessary memory accesses to obtain information that may already be implicit in the locally stored information, thereby providing faster performance for the binary search process.

[0096] For example, in one embodiment, when searching the entry storage device for a given query address, all entries in the entry storage device can be queried in parallel to determine which entries (and therefore which indexes in the table) are greater than / less than the query address. At this time, the lower boundary of the initial search window used for the first search window narrowing step can be the index of the nearest entry in the address area smaller than the query address, and the upper boundary of the initial search window can be the index of the nearest entry in the address area larger than the query address. Alternatively, a method that allows the binary search process to start with a smaller search window (possibly speeding up the binary search) but requires some additional circuit logic to add 1 or subtract 1 can be to set the lower boundary of the initial search window to the index of the nearest entry in the address area smaller than the query address plus 1; and set the upper boundary to the index of the nearest entry in the address area smaller than the query address minus 1.

[0097] The binary search process can be designed so that each search window narrowing step provides a binary division of the current search window to obtain a narrower search window. For example, the narrower search window obtained from a given search window narrowing step can be either the upper portion or the lower portion of the current search window, wherein the upper portion and the lower portion of the search window are selected based on a comparison of the query address with the first boundary address of the selected candidate entry.

[0098] The binary search process can be designed to handle the case where the control table has a number of entries N corresponding to a power of 2. However, sometimes, the control table may have a number of entries N that is not an exact power of 2. In this case, the table lookup circuitry may perform a binary search process assuming that the current search window of the initial search window narrowing step includes a number of candidate entries corresponding to the smallest power of 2 greater than N. In this case, it may be the case that, in a particular search window narrowing step, the selected candidate entry of the current search window corresponds to a position outside the range of the N entries of the control table. If this occurs, the table lookup circuitry may suppress a memory access request for obtaining the first limit address of the selected candidate entry from the memory system, and, due to the comparison to be performed for the particular search window narrowing step, determine an implicit result that causes the narrower search window to include at least one candidate entry at a position within the range of the N entries of the control table. Therefore, if the number of entries in the control table is not a power of 2, the binary search process may be performed in the same manner as if the region table were the next largest power of 2, but for comparisons to entries outside the valid range of the table, an implicit result may be returned without actually loading values ​​from memory. This enables the control table to support any arbitrary number of entries while still enabling the position of the selected candidate entry to be determined (e.g., at a midpoint) by performing a division by 2 on the current window size. Because the division by 2 can be performed by a bit shift operation, this can reduce circuit complexity.

[0099] For control tables where the variable size is allowed to be a number of bytes that is not a power of 2 and / or the start and end addresses of the corresponding address regions are allowed to be not aligned with address boundaries of X bytes (where X is the size of the corresponding address region), the binary search process discussed above can be particularly useful. It may be difficult to index a table with one of these properties because it is not possible to simply add the index to the required entry based on the query address. Instead, a search process may be needed to search multiple entries of the table and compare boundary addresses. The technology discussed above enables faster searching of such tables.

[0100] In some embodiments, the first limit address can be stored in the same data word within the memory system as the data word used to store the second limit address and the size used to define the other limit of the corresponding address area. "Data word" refers to the size of a portion of data that can be returned from the memory in a single memory access request. Even if the first limit address and the second limit address or size are stored in the same data word, it is still useful to use the binary search process discussed above to avoid the need to return the second limit address or size for each selected candidate entry checked in each search window narrowing step. This is because, by requiring only the first limit address in each search window narrowing step of the binary search process, it means that a memory access request specifying a narrower target data portion can be used, which can allow more efficient memory bandwidth usage, because this can reserve space in the registers within the memory system, or reserve wires on the bus that are not used for memory access requests, which can be reused for other memory accesses later, thereby improving the overall efficiency of the memory system. Only needing to compare against the first limit address in the search window narrowing step also reduces the amount of required comparison circuits and can reduce the energy consumed.

[0101] However, in an example where, for a given entry in a control table, the first limit address is stored in a different word in the memory system than the data word used to store the second limit address or size of the given entry, the technique is particularly useful. In some systems, the size of the data word may be comparable to the size of the first limit address or the second limit address, and therefore, it may not be practical to store both the first limit address and the second limit address or size in the same data word. In this case, if both the first limit address and the second limit address or size need to be obtained at each search window narrowing step, this will require two separate memory access requests for each search window narrowing step, which will increase the pressure on the memory bandwidth. In contrast, by using the binary search process discussed above, memory requests for accessing the second limit address or size of each selected candidate entry can be avoided, where the only entry that needs to load the second limit address or size from the memory is the single candidate entry that leads to the final window narrowing step.

[0102] While the techniques discussed above can be used with any type of control table that supports variable-sized address regions defined by first and second boundary addresses or sizes as discussed above, it is particularly useful for a memory protection table that specifies access rights for a corresponding address region of an address space for each entry of the memory protection table, and an operation performed based on information in the control table includes checking whether a memory access request that specifies a query address satisfies the access rights in the corresponding entry for the region that includes the query address. Such a memory protection table may need to be accessed frequently (e.g., at each memory access request if the required entry is not already stored in a local storage circuit), and thus improving the efficiency of the lookup process for accessing a memory protection table from memory can have a significant impact on the overall processing performance of a processing system that uses the memory protection table.

[0103] Again, similar to the MPU example discussed above, in some cases, the system may be implemented using hardware logic. However, such a binary search process may also be implemented within a simulator computer program that is used to control a host data processing device to provide an instruction execution environment for instruction execution, wherein the processing program logic and table lookup program logic provide the same functionality as the processing components and table lookup circuits discussed above. The storage medium may store the simulator computer program. The storage medium may be a non-transitory storage medium.

[0104] Specific MPU Example

[0105] Figure 1 The schematic diagram shows a data processing system 2 having a processing circuit 4 for performing data processing in response to instructions. For example, the processing circuit 4 may be a CPU, a DSP, a GPU, or other processing element of the data processing system. The processing circuit 4 may include: an instruction fetch unit 5 for fetching instructions from a memory system 10 for processing by the processing circuit; 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 logical 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 the registers 12, 14 and the memory system 10. The registers may include many different types of registers, including: general (integer) registers 12 for storing integer values ​​for processing by the processing circuit 4; and floating point registers 14 for storing values ​​represented using floating point representation. The registers accessible to the processing circuit 4 may also include registers not shown in the figure for the sake of brevity. Figure 1Other types of registers shown in the figure, for example: vector registers for storing vector operands containing multiple independent data elements; and / or control registers for storing various control parameters for controlling the operation of the processing circuit 4, for example: conditional flags, which can be checked by conditional instructions to determine whether to perform conditional operations; a program counter, which stores an address representing the current execution point; and control registers, for example, for controlling exception handling.

[0106] The memory system 10 may include one or more levels of cache and main memory. The memory system 10 is accessible to the processing circuit 4 by executing a load instruction, which triggers the load / store unit 8 to issue a memory access request for loading data from the memory system 10 into the registers 12, 14, or a store instruction, which triggers the load / store unit 8 to issue a memory access request for storing data from the registers 12, 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 no address translation is required.

[0107] A memory protection unit (MPU) 20 is provided for checking whether the memory system 10 is allowed to service a memory access request based on the target address. Access rights for controlling whether the processing circuit 4 is allowed to access a given address region may be defined in two ways. A memory protection table 22 may be stored within the memory system, the memory protection table comprising a number of entries, each entry defining access rights for a corresponding address region. The MPU 20 has an MPU memory access circuit 24 for initiating a memory access request to the memory system 10 to obtain information from the MPU table 22. The MPU memory access circuit 24 has a table lookup circuit 26 for performing the comparison required to identify whether the MPU table 22 includes an entry for the following address region: the address region includes the target address specified by the memory access request received from the processing circuit 4. The memory system 10 may store more than one MPU table, each table 22 being associated with a corresponding software process. An active table identifier (identifying which particular MPU table is to be accessed using the MPU memory access circuit 24) is stored in an active table identifier register (or register set) 28. For example, the active table identifier register 28 may specify the base address 30 of the currently active MPU table, and may also optionally specify the size of the active table. An MPU cache storage 32 is provided within the MPU for caching selected entries of the MPU table(s) 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 storage may include a set of registers for locally storing entries of the MPU table with reduced access latency compared to restoring to the MPU table 22 in the memory system 10.

[0108] Another way to provide access rights to control access to the memory system 10 may be to define statically configured memory protection entries within the static MPU register storage device 36. The processing circuitry 4 may support instructions for configuring the contents of the static MPU register storage device 36 (e.g., a dedicated type of instruction specifically intended to access the static MPU register storage device), or may use a more conventional store operation performed by the load / store unit 8 that specifies as the target address an address that has been mapped to a memory-mapped register provided for the static MPU register storage device 36. Generally speaking, once an MPU parameter reconfiguration operation (e.g., one of these memory-mapped load / store operations or a dedicated type of reconfiguration instruction) has been performed to populate the contents of the static MPU register storage device 36 to define a given memory protection entry corresponding to a given address region, in the absence of a reset or power-off event that results in a loss of information stored in the static register storage device 36, the given memory protection entry remains in the static MPU memory 36 until another MPU parameter reconfiguration operation changes the contents of the entry. This is unlike the MPU cache storage 32, for which the contents of the MPU cache storage 32 may change over time according to a cache replacement policy even without an MPU parameter reconfiguration operation to change the actual parameter set for a given address region. For example, the MPU cache storage 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 needed to make more recently accessed entries of the memory protection table 22 in the memory system 10.

[0109] Although Figure 1 The static MPU register storage 36 is shown as being separate from the MPU cache storage 32, but in other examples these may also be 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 and should not be evicted via a cache replacement policy. However, in practice, providing separate storage structures 32, 36 may allow for more efficient indexing of the cache storage 32.

[0110] The MPU includes a permission checking circuit 40, which is used to read the access permission data specified in any of the searched entries of the memory protection table 22 stored in the memory system 10 (or cached in the MPU cache storage device 32) or the statically configured MPU entries specified in the static MPU register storage device 36, and determine whether the nature of the memory access request issued by the processing circuit 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 may specify whether the area is a read-only area (for a read-only area, any write request triggered by a storage instruction executed by the processing circuit 4 should be rejected) or is allowed to read and write. The access permission can also specify whether the fetch unit 5 is allowed to fetch 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 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 restriction conditions defined in the access permission.

[0111] The memory protection table 22 and the static MPU register storage device 36 in the memory system 10 may not be the only source of control information that affects whether the permission check circuit 40 allows memory access. For example, the device 2 may also include a security attribute unit (SAU) 42, which includes a memory security configuration register that defines secure and non-secure areas in the address space. The security check circuit 46 checks the target address of the memory access request against the area definition data in the register 44, and when operating in the secure operating mode, the processing circuit 4 is only restricted to access the secure area (the non-secure area is accessible in either the secure mode or the non-secure mode). Therefore, the memory security configuration register 44 can represent another example of a control data structure for controlling access to memory, which can impose permissions orthogonal to the permissions of the MPU table or the static MPU register storage device 36. That is, access that would be allowed by the MPU may still be denied by the SAU 42, and vice versa. Both memory access requests initiated by the fetch unit 5 or load / store unit 8 of the processing circuit and any MPU memory access requests issued by the MPU memory access circuit 24 to access the memory protection table 22 in the memory system 10 may be subjected to security checks by the SAU 42. Figure 1 In the example of , the definition of which memory regions are considered secure or non-secure is defined solely by the contents of the memory security configuration register 44, but in other examples, a memory security table similar to the MPU table 22 may be maintained within the memory system 10 to provide additional entry definitions that define address regions as secure or non-secure. This would enable support for a large number of simultaneously defined regions. Although Figure 1The MPU 20 and SAU 42 are shown in FIG. 1 as operating sequentially, but some embodiments may provide for parallel lookups of the MPU and SAU for memory accesses issued by the processing circuitry to improve performance.

[0112] Figure 2 An example of a memory protection table 22 stored in the memory system 10 is shown. The memory protection table includes a number of entries 50. In this example, each memory protection entry 50 includes data stored in two adjacent data words 52 of the memory address space. The first data word RBARi provides a base address (starting address) 54 of the corresponding address region, while the end address (LIMIT) 56 of the corresponding address region is defined in the second data word (RLARi) of the entry 50. In this example, the access rights (AP) 58 are specified in the RLAR data word of the entry, while the enable flag 60 indicating whether the entry defines an enabled address region or a disabled address region is in the RBAR data word, however this information 58, 60 may also be switched to other data words or represented within the same data word. In addition, each data word 52 of the entry 50 may optionally include a flag not specified in the RLAR data word. Figure 2 Other information shown in Figure 2 An example is shown where the start address 54 and end address 56 of each address region are represented in separate data words in the memory, but this is not required, and in some embodiments, these addresses may fit within a single data word, in which case multiple data words are not necessarily provided for each entry. Figure 2 The start address 54 and the end address 56 are used to represent the variable size address region, but in other examples, one of the boundary addresses may be represented by a size parameter that defines the size of the corresponding address region relative to the other boundary address. The active table ID register 28 identifies the base address 30 of the memory protection table and may optionally identify a size parameter 62 that identifies the total number of entries in the memory protection table. Although in Figure 2 In FIG. 5 , data words 52 of entries 50 are adjacent, but this is not required, and in some embodiments, all RBARi data words may be clustered together in one part of the table, while RLARi data words are clustered together in another part of the table.

[0113] The entries 50 of the memory protection table 22 are assigned to addresses within the same address space 64 that is used for addresses of conventional memory accesses issued by the load / store unit 8 or instruction fetch unit 5 of the processing circuit 4. The memory protection entries 50 are ordered within the address space according to their starting location 54 (and also according to their ending address 56, as overlapping address regions defined by memory protection entries within the memory protection table 22 may not be allowed). Thus, entry 0 would be the entry corresponding to the address region with the smallest starting address, entry 1 would correspond to the address region with the next smallest starting address, and so on. Note that Figure 2 What is shown in the address space 64 is the address location of each memory protection entry 50 of the storage table, rather than the location of the corresponding address area for which the entry defines the access rights. It should be understood that Figure 2 The specific format of each entry 50 shown in is merely an example, and other formats may be used to represent the same information.

[0114] Figure 3 An example of an MPU cache storage device 32 is shown, which includes a number of cache entries 34, each cache entry 34 is used to cache one of the memory protection entries 50 from the memory protection table 22. Figure 3 As shown in , in addition to the parameters of the corresponding memory protection entry 50, the cache entry 34 may also specify a valid bit 70 and a table identifier 72, wherein the valid bit indicates whether the contents of the cache entry 34 are valid, and the table identifier identifies the specific memory protection table 22 from which the memory protection entry 50 cached in the cache entry 34 is extracted (this may correspond to the current value of the active table ID register 28 when the cached memory protection entry is assigned to the cache 32). Because it is likely that multiple cache entries 34 will have the same table identifier 72, some embodiments may choose to reduce the amount of storage required by storing only the unique table identifier 72 in a separate table identifier table within the MPU cache storage device 32. In such an embodiment, each cache entry 34 may store an index of the full table identifier in the table identifier table. In addition, each cache entry 34 may specify an entry identifier 74 that identifies the location within the corresponding memory protection table 22 from which the memory protection entry 50 cached in the particular cache entry 34 is extracted. For example, in Figure 2In the example shown in , if entry ID 1 is extracted from the table and placed in the cache, the entry ID field 74 may specify a value of 1. The entry ID field 74 may be used in processing instructions executed by the processing circuitry 4 to check which entry ID of the memory protection table a given address maps to. By including an indication of the entry ID within each cache entry 34, this means that if the address specified by the instruction matches one of the regions defined by the memory protection entries cached within the cache storage 32, then the entry ID 74 of that entry may simply be read from the cache without the need to determine the entry ID from an access to memory.

[0115] Table ID 72 is used to qualify a lookup in the cache. When looking up the cache to determine if the cache contains a memory protection entry corresponding to a given address, only cache entries 34 whose table ID field 72 matches the active ID stored in active table ID register 28 will generate a hit. A cache entry 34 containing a table ID different from the active table ID will generate a miss even if the query address supplied to the cache is between the base address and the limit address in the parameters cached for the corresponding memory protection entry 50.

[0116] Note that the cache entry 34 need not have space for the enable flag 60 that is provided in each memory protection entry 50 stored in the memory within the memory protection table 22. This is because the cache 32 may be prohibited from caching disabled memory protection entries. When all memory protection entries cached in the MPU cache storage device 32 should be enabled entries, then the enable flag 60 would be redundant information within the cache entry 34. By prohibiting caching disabled entries, this means that the software executing the processing circuit can include disabled memory protection entries within the MPU table 22, which disabled memory protection entries define regions that can be activated later, and then when it is necessary to activate these regions so that address access will then become allowed, this can be done simply by setting the enable flag 60 in the corresponding memory protection entry of the memory protection table 22 without triggering an invalidation of any cache from the MPU cache storage device 32.

[0117] The cache indication from the MPU cache storage device 32 may be triggered by the processing circuitry 4 executing an MPU cache invalidate command. Variations of the MPU cache invalidate command may trigger invalidation of all cached entries, or trigger invalidation of entries that meet a condition specified by any one or more of an address or address range, a table ID, or an entry ID.

[0118] Figure 4 Examples of static MPU register storage 36 and various control registers 80 provided within MPU 20 are shown.

[0119] For the static MPU register storage device 36, Figure 4 A set of three registers provided for each static MPU entry is shown. That is, for each static MPU entry supported in hardware within the MPU register storage device, a separate instance of the three registers 82, 84, 86 may be provided. Register 86 is optional. Registers 82 and 84 together represent a corresponding static MPU entry having content similar to a given memory protection entry 50 of the memory protection table 22. Thus, registers 82, 84 may specify a base address (starting address) 54 and a limit address (ending address) or size 56, access permissions 58, and an enable flag 60 that controls whether the entry is enabled (capable of being used to check permissions for memory access requests) or disabled (so that memory access requests cannot be made valid based on the contents of this entry, however, when disabled, the remaining parameters of registers 82, 84, 86 should be retained until subsequently reconfigured). It should be understood that the specific format of registers 82, 84 is only an example, and the same information may be rearranged or represented by different fields. In addition, registers 82, 84 may store information not in Figure 4 In addition, in some cases, the contents of a statically configured MPU entry may be represented by a single register.

[0120] Therefore, when a static MPU entry defines an address region that matches the target address of an access request sent by processing circuit 4 and the entry is enabled, the access permission 58 defined in the matching static MPU entry may be used to verify whether access is allowed. In this case, it may not be necessary to access the memory system 10 to make the access request valid.

[0121] The additional metadata register 86 associated with the corresponding static MPU entry represented by the register 82, 84 is optional, but if provided, can allow for more efficient performance. The metadata register 86 specifies a register disabled and unknown (RDU) field 88, which, if set to 1, indicates that the register 82, 84 associated with the corresponding static MPU entry is not currently used to store the static MPU entry. If the RDU field 88 is set to 1, this indicates that the register 82, 84 can be used as an extension of the MPU cache storage device 32 to cache the contents of the corresponding memory protection entry from the MPU table 22 stored in the memory system 10. This can allow for better performance by effectively increasing the capacity of the MPU cache storage device 32 when the software does not need the full number of static MPU entries supported in the hardware. The remainder of the metadata register 86 can specify additional cache fields 70, 72, 74, which are provided for each cache entry 34 in the cache storage device 32 that would not otherwise be provided in the static registers. Note that when the RDU flag 88 is used to set a particular entry in the static registers to unknown, this is different from setting the entry to disabled using the enable flag 60. When the entry is disabled but marked as unknown, the contents of registers 82 and 84 are retained and these registers cannot be used as cache storage. For example, software may wish to temporarily disable a particular static entry so that the entry cannot be used to enable memory access to that region of the address space, but retain the parameters in these registers 82, 84 so that the region can be enabled again later without reprogramming the static MPU registers (except for setting the enable flag 60). When the RDU flag 88 is used to set the static region to unknown, the enable flag 60 may not be required for entries cached in the static region that is set to unknown, because the cache may be prohibited from caching disabled memory protection entries, as discussed above. Therefore, some embodiments may choose to have a single shared valid / enabled flag instead of separate enable flags 60 and valid flags 70.

[0122] The control registers 80 include a region programming register 90 for programming the contents of the static MPU entries. Each of the control registers 80 is a memory mapped register that can be accessed by performing a load / store operation that specifies as the target address the memory address mapped to that particular register. To avoid the need to individually assign addresses to each individual entry of a provided set of static MPU entries (e.g., for each of the 8 or 16 static MPU entry storage devices provided in hardware), the first static MPU registers 82 for respective versions of each of the entries supported in the static MPU register storage device can share the same memory mapped address (and similarly for the address sharing registers 84). To select which particular version of register 82 or 84 to write, software may first write a region identifier 92 to region programming register 90 that corresponds to a particular one of the static MPU entries to be written, and then a subsequent MPU reconfiguration operation (a store instruction specifying the address mapped to register 82 or 84 as the target address) may be performed, and the region number 92 that has been placed in programming register 90 may specify which static MPU entry is to be updated. Programming register 90 may also include an RDU field 94 that specifies whether the region specified by region identifier 92 in programming register 90 via RDU field 88 of metadata register 86 is to be set to disabled and unknown. Again, using a programming register 90 that is shared between a group of static MPU register entries to set the RDU field means that a separate memory-mapped address need not be provided for each metadata register 86.

[0123] like Figure 4 As shown in FIG. 1 , the control registers also include an active table ID register 28, which in this example specifies the base address 30 of the active table as the active table identifier. The size of the active table is specified in a separate size parameter 62, which is specified in another control register 96. The registers can be used in Figure 4 The remaining fields marked with dots in the table are used to store other information. In this example, the register 28 containing the base register 30 of the table also includes a clear active table size field 98. Figure 4In the example of , the base address 30 and size 62 of the active MPU table 22 are stored in different registers, which may mean that different MPU parameter configuration operations may be required to set the base address and size respectively. Therefore, if the base address and size need to be changed, there may be a period of time between changing one of the base address and size and changing the other, during which time the parameters defining the active table within the control register 80 effectively define an address space region that may include data words that have not yet been programmed with memory protection entries 50. This may risk checking memory access operations against data that is not intended to define memory protection entries, which may lead to uncertain results that may interrupt the security checks implemented by the memory protection table. Some embodiments of the MPU cache storage device 32 may allow entries to be pre-fetched from the memory protection table 22. Because such pre-fetching can occur at any point in time and may not be directly triggered by instructions executed by the processing circuit 4, it may be difficult to ensure that invalid entries outside the protection table 22 are not cached. This problem can be solved by providing a clear active table size field (CLRATSIZE) 98 in the register 28 containing the base address 30. When reconfiguring the active table ID register 28, if the new data to be placed in the register specifies the CLRATSIZE field to be equal to 1, then in addition to updating the contents of the register, the active table size 62 in register 96 is cleared to 0, which effectively indicates that there is no active table 22 in the memory system 10. This prevents any memory access request from being inappropriately allowed based on a data word that is incorrectly assumed to be part of the memory protection table 22 after only the base address has been updated but the size has not been updated. A subsequent MPU reconfiguration operation can then update the address translation size within register 96 to the appropriate value for the new active table. On the other hand, if the new value to be written to register 28 has the CLRATSIZE field 98 set to 0, then in response to this operation, only the contents of the specified base address 30 of the active table ID register 28 will be updated, and in this case, the size 62 in register 96 will remain unchanged. This would be more appropriate when switching between two memory protection tables of the same size.

[0124] Figure 5 The diagram schematically illustrates a portion of the address space covered by different memory-based MPU entries 50 of the memory protection table 22 or statically configured MPU entries within the static MPU register storage 36. In this example, the address space is a physical address space, so memory access requests issued by the processing circuitry 4 specify physical addresses that directly correspond to corresponding locations within the memory system, and these memory access requests are checked against the memory protection entries that define the corresponding region of the physical address space. Figure 5The regions 100 marked in correspond to three different memory-based memory protection entries 50 of the memory protection table 22. Note that the memory protection table 22 may define sparsely arranged regions of the address space, and that there may be gaps between corresponding address regions defined by consecutive entries of the memory protection table.

[0125] On the other hand, region 102 corresponds to two corresponding static MPU entries represented by static MPU register storage device 36. Therefore, the access latency for locating a given memory-based MPU entry from the memory protection table 22 may vary depending on whether the entry is in the MPU cache storage device 32, but access to the static region 102 corresponding to the static MPU entry can be deterministic because the static region will remain configured until the processing circuit 4 executes the following instructions: the instructions are used to reconfigure the parameters that define the access rights or scope of the static region defined by the given static MPU entry. Therefore, software can determine certain critical areas of the address space for which accesses may need to be processed quickly and / or with deterministic latency, and by using static MPU areas to process these accesses, this may be more optimal for real-time applications. At the same time, by supporting a variable number of memory protection entries 50 within the memory protection table 22 stored in the memory, this enables a larger number of total memory regions to be defined simultaneously, thereby reducing the frequency of errors caused by the lack of defined memory protection entries for a given address. Therefore, this hybrid approach provides a better balance between performance and hardware cost, especially for systems involving real-time processing or requiring deterministic access latency but with constrained memory capacity.

[0126] like Figure 5 As shown in , the area covered by the memory protection entries of the memory protection table 22 may overlap with the statically configured address area corresponding to the static MPU entries. In this case, the overlap can be handled in different ways. In some embodiments, if the target address of the memory access request hits in the static MPU register storage device 36, the access rights defined by its matching static MPU entry may take precedence and overrule any conflicting attributes specified in the matching memory-based MPU entry of the MPU table 22. In this case, once there is a hit in the static MPU register storage device 36, no memory access request may need to be initiated by the MPU memory access circuit 24.

[0127] Alternatively, in the event that there is a hit in the static MPU register storage device and the memory access request satisfies the access rights specified by the matching static MPU entry, then the MPU memory access may be suppressed so that there is no access to the memory protection table 22, but if the memory access request fails to satisfy the access rights specified in the matching static MPU entry, then the MPU memory access may still be triggered by the MPU memory access circuit 24. If the memory protection table 22 includes a matching MPU entry for the address region including the target address, then if the matching memory-based MPU entry allows the execution access, then the memory access may be allowed even if the static MPU entry for the same address does not allow the memory access. The overlap between static and memory-based MPU entries thus achieved can be used to set permissions for more privileged processes to access a wider range of address space, and can also be used to allow less privileged processes to access only a limited subset of the address range available to more privileged processes. For example, region 102-1 represented by a static MPU entry may restrict access to higher privileged processes such that addresses within sub-range 100-2 accessed by less privileged code fail to satisfy the access rights specified by the static MPU entry, but may pass a permission check based on a corresponding memory-based MPU entry associated with region 100-2. This avoids any need to separate region 102-1 into separate entries representing portions of region 102-1 on either side of region 100-2.

[0128] Figure 6 1 is a flow chart illustrating a method for checking whether a memory access is allowed by the MPU. At step 120, the processing circuit 4 issues a memory access request specifying a target address. The memory access request may be an instruction fetch request issued by the instruction fetch circuit 5, or may be a data access request (load or store operation) issued by the load / store unit 8. At step 122, the MPU 20 determines whether the target address hits a static MPU entry stored in the static MPU register storage device 36. That is, the permission check circuit 40 detects whether the target address is within the corresponding address region of any of the static MPU entries. If so, at step 124, the permission check circuit determines whether the access rights specified in the hit static MPU entry are satisfied. If the access rights are satisfied by the memory access request, then at step 126, the memory access request is allowed by the MPU. In a system including the SAU 42, there may also be an additional security check performed by the security check circuit 46 of the SAU 42 to determine whether the memory access request is allowed, so even if the MPU allows the memory access request at step 126, the request may still be rejected by the SAU 42. However, subject to the SAU check, the memory access request is permitted by the MPU 20 .

[0129] If at step 124, the access rights are not satisfied by the memory access request, there are alternative options for how the MPU can respond. In a first option, when the target address hits a static MPU entry but the static MPU entry specifies access rights that are not satisfied by the memory access request, then at step 128, the memory access request can be denied. In this case, the MPU can trigger signaling of an error condition or exception. Alternatively, in a second option, the method can continue to step 130, as when the target address does not hit in the static MPU register storage at step 122.

[0130] Thus, if there is a miss for the target address in the entry in the static MPU register storage 36, or there is a hit but the memory access request cannot satisfy the access rights and the system implements Option 2, the method proceeds to step 130 where the permission checking circuit 40 detects whether there is any hit for the target address in the MPU cache storage 32. Note that while some systems may only search the MPU cache storage 32 (i.e., when there is not yet a hit in the static MPU register storage 36 (or there is not yet a hit with satisfied access rights), Figure 6 ), but in some alternatives, to improve performance, the cache may be searched in parallel with the static MPU register storage device, so that in the event that a cache search is needed where the static MPU register storage device cannot clearly provide a determination of whether a memory access request should be allowed or denied, a cache search has already been initiated, thereby enabling a cache response to be obtained earlier. Nevertheless, static MPU entries may be prioritized relative to cache MPU entries even if these MPU entries are searched in parallel.

[0131] Thus, if the target address hits (i.e., is within the corresponding address region) a cached MPU entry, and the cached MPU entry is valid within the MPU cache storage device and corresponds to the same MPU table as currently identified as the active table in the active table ID register 28, then at step 132, the permission checking circuit determines whether the access rights specified in the hit entry of the MPU cache storage device are satisfied. If so, then again at step 126, the memory access request is allowed and subject to any SAU checks that may be required. If the access rights specified in the hit entry of the MPU cache storage device 32 are not satisfied at step 132, then at step 134, the memory access request is denied and an error may be signaled.

[0132] If at step 130, the target address is determined to be a miss in all entries of the MPU cache storage device 32 (i.e., there is no cache entry that specifies the same table ID as the active table ID and corresponds to the memory address region including the target address), then at step 136, the table lookup circuitry 26 triggers the MPU memory access circuitry 24 to initiate one or more MPU memory access requests to look up the memory-based MPU table 22 based on the target address. Figure 7 The lookup process is discussed in more detail. MPU memory access requests triggered by the MPU memory access circuitry during the lookup may be verified against a set of preset access rights and / or may be checked by the SAU 42 against security regions defined in the memory security configuration register 44. Thus, for MPU memory access requests initiated as part of an MPU table lookup, there is no need to check these memory accesses against the static MPU register storage device 36 or the memory protection table 22. Based on the table lookup process, at step 138, the table lookup circuitry 26 determines whether a hit already exists in the memory-based memory protection table 22. If so, then again at step 132, it is determined whether the access rights specified in the hit entry in the memory detection table are satisfied, and depending on whether the access rights are satisfied, the method then proceeds to step 126 or step 134 as appropriate to allow or deny memory access. In addition to checking the access rights in the hit entry of the memory detection table 22, the cache controller associated with the MPU cache storage device 32 may also assign the hit entry of the memory protection table 22 to the cache. If a previously cached entry in the memory protection table 22 needs to be evicted, a victim entry, such as the least recently used entry, may be selected by a cache replacement policy.

[0133] On the other hand, if at step 138, the table lookup circuit 26 determines that there is a miss for the target address in the memory-based MPU table 22, then the address region corresponding to the target address is not defined in the memory protection table, so the miss is signaled. In response to a miss in the memory protection table, different options are available for handling the memory access request. In some cases, the request may be simply denied and the error may be signaled. Alternatively, a set of preset attributes may be defined that is intended to handle any memory access request that does not have a specific memory protection entry defined in either the static MPU register storage device 36 in the memory or the memory protection table 22. Thus, if there is a miss in the memory protection table 22, the memory access request may be checked against the preset attributes, and then the preset attributes may be used to determine whether the memory access request is allowed or denied by the MPU 20.

[0134] Figure 7 is shown in more detail Figure 6Flow chart of the search process at step 136 of . Figure 7 A method for searching a control table is shown, the control table comprising a plurality of entries, each of which specifies any one of a first limit address and a second limit address and a size of a corresponding address region of variable size. The size of the region may be allowed to be a number of bytes that is not an exact power of 2. The limit of the corresponding address region may not be aligned with an N-byte address boundary, where N is the size of the corresponding address region. Figure 6 In step 136, the control table is the memory protection table 22, and the query address used to look up the table is the target address specified by the memory access request issued by the processing circuit 4. Figure 7 The lookup process of is used for other forms of control tables. For example, they can be used in a control table that specifies secure or non-secure address areas, or a control table that is used to track which code belongs to a specific software library being executed, which control table can be used by processing circuits to limit which code segments can call other software libraries, which can provide protection from return directed programming attacks. Therefore, it should be understood that Figure 7 The method shown in is applied to other forms of control tables, not just the memory protection table 22 .

[0135] exist Figure 7 At step 150, the lookup circuit 26 receives the query address. The table lookup circuit 26 determines an initial search window that includes a number of entries of the control table 22 that are to be searched to determine whether the lookup address corresponds to a corresponding address region of any of the entries. In some cases, the search window may include all entries of the control table 22. Alternatively, in some embodiments, the table lookup circuit 26 may determine a narrower search window that does not include all entries of the control table as the initial search window, wherein the particular narrowing of the search window is determined based on information derived from any cached entries stored in the static MPU register storage unit 36 ​​that are marked as unknown or cached memory protection entries of the MPU cache storage device 32. For example, if, when searching the MPU cache storage device 32, it has been determined that the query address is less than the base address of a given cache entry 34, it can be known that matching entries of the memory protection table 22 may only have entry identifiers that are smaller than the entry ID 74 specified in the cache entry 34 because the entries of the control table 22 are sorted by base address.

[0136] At step 152, the table lookup circuit 26 begins the first binary search step which is performed as a binary search process of the lookup table. The binary search step (also called the search window narrowing step) includes the following steps: Figure 7Many steps 152-170 shown in , these steps can be repeated many times in the continuous binary search steps. At step 152, a candidate entry of the control table 22 is selected, for example, at the midpoint of the current search window. Although not necessary, for performance, it is preferred to position the midpoint as close as possible to the midpoint of the current search window, but for an even number of entries in the search window, it may not be possible to have a candidate entry that is exactly in the middle between the start and end of the search window. For example, if the search window includes 16 entries, either entry 8 or entry 9 of the 16 entries can be selected as a candidate entry. In addition, for a search window that includes only 2 entries, one of the entries at the outer boundary of the search window will be selected as a candidate entry.

[0137] At step 154, it is determined whether the selected candidate entry is outside the valid range of the table. Because sometimes the control table 22 may include many entries that do not exactly correspond to powers of 2, at step 150, for tables that do not have a number of entries that are powers of 2, the search window may be constructed as if the number of entries is equal to the next highest power of 2, and therefore sometimes at step 152, the selected candidate entry may actually be outside the valid range of the table. If so, then at step 156, the table lookup circuit 26 suppresses any load operation issued by the MPU memory access circuit 24 for loading the first limit address of the selected candidate entry. Here, the first limit address may be either the starting address or the ending address of the corresponding address region, depending on which of the starting address and the ending address is compared in each binary search step in a given implementation. For the MPU example discussed above, it may be simplest to have the first limit address be the starting address of the corresponding address region. At step 156, the table lookup circuit determines that when the selected candidate entry is outside the range of the table, the result of the comparison of the query address with the first limit address can be implicitly determined so that when the search window is narrowed based on the comparison, the narrower window includes at least one entry in the table. For example, if the comparison performed at step 164 is to determine whether the query address is less than the base address of the corresponding address region, the implicit result of the comparison can be that, in the case where the selected candidate entry is outside the range of the table, the query address is less than the base address, because this will tend to mean that the narrower window will exclude a portion of the table that is outside the valid range and will include at least one entry in the table.

[0138] If it is determined that the selected candidate entry at step 154 ​​is within the valid range of the table, the method proceeds to step 158, where the table lookup circuit 26 may determine whether the result of a comparison of the query address with the first limit address of the selected candidate entry is already known based on information cached in the MPU cache storage device 22 or the static MPU memory 36 (if a static entry marked as RDU is retained as a cache). For example, if it has been determined that the query address is less than the base address of a given cache entry, it may be implicit that when the selected candidate entry has an entry ID greater than the entry ID 74 of a given cache entry, the query address must also be less than the first limit address of the selected candidate entry. Alternatively, in a system where the first limit address is the upper end address of the corresponding address region, if the search of the cache 32 has determined that the query address is greater than the limit address of a given cache entry 34, then when the selected candidate entry has an entry ID equal to or less than the entry ID 74 of the given cache entry 34, it may be implicit that the query address must be greater than the first limit address (end address) of the selected candidate entry. Thus, if the result of the comparison that would normally be performed between the query address and the first limit address of the selected candidate entry is known based on cached information, then at step 160, the load MPU memory access request for loading the first limit address of the selected candidate entry is suppressed by the table lookup circuit 26, and instead the comparison result determined by the cached information may be used instead of actually performing an operation to compare the query address against the first limit address loaded from the memory system 10. Note that step 158 is optional, and thus some embodiments may not use cached information to guide the search process. Furthermore, in a system where the search window is narrowed at step 150 based on cached entries stored within the MPU 20, the narrowed window at this stage may already exclude unwanted entries known by the cache storage device, and thus in this case, step 158 may not be necessary, as this may have effectively been considered at step 150. Thus, it should be understood that the cached information may be considered at one of the two steps, either when formulating the initial search window and / or when checking the comparison result of a given binary search step, but it is not necessary to perform either of the above steps. For completeness, in Figure 7 Both are shown in .

[0139] If the comparison result between the query address and the first boundary address of the selected candidate entry cannot be determined based on the cached information, then at step 162, the table lookup circuit 26 triggers the MPU memory access circuit 24 to trigger a load MPU memory access request to load the first boundary address of the selected candidate entry from the memory system. Therefore, a load request can be issued, which specifies the address corresponding to the sum of the base address 30 of the active MPU table and the offset determined based on the entry identifier of the selected candidate entry as the target address of the load request. This load operation can be subjected to a permission check based on a preset attribute group and / or a memory security configuration specified by the SAU 42. When the first boundary address (the starting or ending address of the corresponding address area) is returned for the selected candidate entry, then at step 164, the query address is compared with the returned first boundary address. Regardless of whether the comparison is actually performed at step 164 or whether the comparison result is implicitly determined based on the cached information at step 160, at step 166, the search window is narrowed to exclude entries that do not meet the comparison result. For example, in the case where the first limit address is the starting (base) address of the corresponding address region, the comparison at step 164 can determine whether the query address is less than the first limit address. If the query address is less than the first limit address, then at step 166, the narrower search window can be determined to include the portion of the previous search window that includes entries with entry identifiers that are smaller than the entry identifier of the selected candidate entry. Optionally, the selected candidate entry itself can also be included in the narrower search window, which can sometimes make the circuit implementation faster by reducing the length of the critical timing path because this avoids the need for an additional subtraction operation to reduce the entry identifier of the selected candidate entry by one to identify the top of the narrower search window. If the query address is greater than the starting address of the selected candidate entry, the narrower search window can exclude entries with entry identifiers that are smaller than the entry identifier of the selected candidate entry.

[0140] On the other hand, if the first limit address is the end address of the corresponding address region, and at step 164, the comparison is to determine whether the query address is greater than the first limit address, then if the query address is greater than the first limit address, then at step 166, the narrower search window may include those entries having entry identifiers greater than the entry identifier of the selected candidate entry. On the other hand, when the query address is less than the upper limit address of the corresponding address region, the search window may be narrowed to include the selected candidate entry and any remaining entries having entry identifiers less than the entry identifier of the selected candidate entry.

[0141] At step 168, the table lookup circuit determines whether, after the narrowing performed either at step 156 or at step 166, the narrower search window now includes only a single candidate entry of the control table. If not, a further binary search step is still required, and at step 170, the method proceeds to the next binary search step, which uses as the current search window the narrowed search window brought about by step 166 or step 158. The method then moves back to step 152 to repeat steps 152 to 168 for another binary search step.

[0142] If at step 168, it is determined that the narrower search window does include a single entry, no further binary search steps are required. In this case, at step 172, the second limit address or size specified by the single entry remaining in the narrower search window is loaded from the memory system. Again, the load MPU memory access request issued to retrieve the second limit address or size of the single entry from the memory can be subjected to checks by the SAU 42 and / or checks based on preset memory access attributes. In some cases, the MPU memory access circuit 24 may also need to trigger a load to obtain the first limit address of the single candidate entry from the memory system, even when the first limit address has been checked at a previous binary search step. Other embodiments may provide a cache of the first limit addresses of one or more selected candidate entries read in an earlier binary search step, and thus the load used to obtain the first limit address of the single entry can be suppressed if the first limit address of the single entry remaining at step 172 is still cached.

[0143] At step 174, the lookup circuit 26 determines whether the query address is within the limits defined for the corresponding address region for the single remaining candidate entry. Thus, if the second limit is specified by address, the lookup circuit determines whether the query address is between the first limit address and the second limit address (whether the first limit address and the second limit address are considered to be part of the corresponding address region or whether one of these addresses may be considered to be outside the corresponding address region may be an implementation-dependent choice). On the other hand, if a size is used to define the second limit, the lookup circuit may add or subtract the size from the first limit address to determine the second limit address, and then again determine whether the query address is between the first limit and the second limit. If the query address is within the limits defined for the region corresponding to the single remaining entry, then at step 176, a hit is detected in the memory protection table. The attributes specified in the single remaining entry may then be returned and used to control a given operation performed by the processing component. For example, for the MPU example shown above, the operation performed using the hit entry may be in Figure 6Access permissions are checked at step 132 of , but for other types of control tables, different operations may be performed using the return attributes. On the other hand, if the query address is not within the bounds of the corresponding address region of the single remaining entry, a miss is detected at step 178 because there is no matching entry corresponding to the address region including the query address.

[0144] Therefore, in using Figure 7 In the case of the binary search process defined in , the parameters defining the second limit address or size need only be loaded from memory for the single entry remaining after step 168. For each binary search step, only the first limit address needs to be loaded from memory at step 162 (and sometimes this load can be suppressed anyway if cached information may have been used to determine what the result of comparing the query address with the first limit address of the selected candidate entry would be). This approach helps reduce the number of accesses to memory required to look up the control table, allowing faster performance because the maximum memory overhead can be proportional to the number of entries N and log2(N)+1, rather than log2(N)*2.

[0145] Figure 8 A specific example of the binary search process for an example in which a table has 16 entries is shown. Each step marked 200 represents Figure 7 Specific binary search steps 152-170 are performed and are marked with specific comparisons, which are performed at step 164 of the corresponding binary search step. In this example, the first boundary address is the base address of the corresponding address area, and therefore at each binary search step, a less-than comparison is made between the query address and the base address of the selected candidate entry at that step. For example, notation B6 refers to the base address of candidate entry 6. Therefore, in the first binary search step 200-0, the initial search window (SW) may include all 16 entries 0-15, and the selected candidate entry is, for example, entry 8. Based on the less-than comparison between the query address and the base address B8 of the selected candidate entry 8, the search window is then narrowed to entries 0-7 if the query address is less than the base address of entry 8, or the search window is narrowed to entries 8-15 if the query address is equal to or greater than the base address of entry 8. Similarly, the subsequent binary search steps again make a binary separation of the candidate entries so that the search window is narrowed by half at each binary search step, and thus in a maximum of four binary search steps, the search window of 16 entries can be reduced to Figure 8The single entry identified at step 202 marked in . The comparison result of some of the comparisons at the binary search steps 200 can be determined implicitly, rather than actually by loading the first limit address and comparing the first limit address with the query address, if the comparison result can be known based on cached information, or if the actual number of entries in the table is not a power of 2 and therefore some of the upper entries may not actually have valid entries provided. For example, if the table only includes 13 entries, the binary search step marked as 200-1 and used to compare the query address with the base address of entry 14 can implicitly provide a "yes" result to then proceed directly to the binary search step that acts on a narrower search window including entries 12 and 13. Similarly, for N=13 (i.e., there are 13 entries 0 to 12), because the top entry is entry 12 and there is no entry 13, the binary search step marked as 200-2 can also produce an implicit "yes" result to identify that the single entry remaining in the search window should be entry 12.

[0146] Thus, in the case where a single remaining candidate entry has been identified in one of steps 202, this means that either the query address hits the single remaining entry, or the query address misses completely. To determine which of these situations is true, in step 204 (i.e. Figure 7 At step 174), the lookup circuit determines whether the query address is between the base address and the limit address of the region defined by the single remaining entry. It should be understood that one or the other of the base and the limit can be determined by a size parameter, which is applied to the other limit of the region. Therefore, if the query address is between the base address and the end address of the corresponding entry, then at step 206, a hit is detected in the particular entry, and if the query address is not between these limits, then a miss is detected at step 208.

[0147] Fig. 9A specific example of finding a specific query address in a table is shown. In this example, the initial search window is determined to include seven entries (entries 0-6) because existing cached information or static MPU register information is used, or because the table initially includes only seven entries. Entry 3 is selected at the midpoint of the search window in the first binary search step 200-8, and it is determined that the query address 0x00880 is less than the starting address 0x07500 of entry 3, and therefore the search window is narrowed to exclude entries 4-6 (and optionally, depending on the specific implementation used, entry 3 can also be excluded or included as needed). In the second binary step 200-10, the selected candidate entry is entry 1, and at this time, the query address is determined to be greater than the starting address of the area after entry 1. Therefore, the search window can now exclude entry 0. Therefore, it is now known that the query address must correspond to entry 1 or entry 2, or not to any of the entries in the table. Therefore, the binary search continues, and now entry 2 becomes the selected candidate entry at step 200-12 and loads the base address of area 2. At this point, a comparison of the query address with the base address of region 2 indicates that the query address is less than the base address of region 2. Therefore, it is determined that region 1 is the correct load region, and this entry is returned, and the boundary address defining the end address of the region is loaded from memory. If the processor has cached the value of the base address of region 1 at the previous binary search step, the need to reload the base address of region 1 can be avoided. In this particular case, the query address is then proven to be between the start address and the end address of region 1, and a hit is therefore detected in the memory detection table. However, if the query address is not yet between the boundaries of the final entry identified in the final binary search step, a miss will be detected.

[0148] Fig.10 shows an example of lazy saving, which can be used to process Figure 1 The abnormality in the processing system 2 shown in FIG. Figure 1As shown in , the processing circuit may include general registers 12 and floating-point registers 14. When encountering an exception, it may be necessary to save the contents of register 12 to a stack data structure provided in memory 10, so that the architectural state of the software executed before the exception can be retained, so that the software executed after the exception (such as an exception handler or a process that has been context-switched) can rewrite the data to register 12 and then reuse these registers. However, although it may also be necessary to retain the floating-point architectural state in register 14, in fact, not all software processes use floating-point registers. In a process that does not include any floating-point instructions, floating-point registers may not be needed. It takes some time to save the state from registers 12, 14 to the stack data structure in memory system 10. Therefore, if any of the first software process executed before the exception or the second software process executed after the exception does not need a floating-point register, the time spent on saving the floating-point state from the memory may actually be wasted.

[0149] Therefore, if Fig.10 As shown in , a lazy save method can be used, in which the integer registers 12 are saved to a stack in memory in response to an exception, but the floating point state in the registers 14 is not saved in response to the exception. Instead, in the case where it has been determined that the first software has used the floating point registers, the saving of the floating point registers can only be triggered when the second software subsequently executes a floating point instruction to trigger access to the floating point registers 14. Although the floating point registers are not actually saved in response to the exception, nonetheless, in response to the exception, some space is reserved for the floating point registers on the stack in the memory 10, and the address of the saved area on the stack is recorded. This ensures that, regardless of whether the floating point registers have been saved, the layout of the stack frame used to retain the state saved for the first software process executed before the exception can be consistent, which can make subsequent state recovery simpler.

[0150] However, when reserving an address to save the floating point registers, this address may be an address in the stack data structure that is accessible to the first software process that was executing before the exception occurred. Before actually saving the floating point registers to the reserved space in the stack, the permission checking circuit 40 of the MPU 20 may need to check whether the memory access used to save the floating point state to the reserved space in the stack is allowed, however because the active table identifier register 28 may have been reconfigured for use by the second software process, the MPU 20 may no longer have access to the MPU table used by the first software that defines whether the first software is allowed to save the state to that area on the stack.

[0151] To address this issue, when an exception occurs, in addition to recording the address of the space reserved on the stack for floating-point registers, the exception handling logic associated with the processing circuit 4 may also record the MPU check information that enables the hardware to verify during the execution of the second software process whether the address of the reserved space on the stack satisfies the access rights defined in the corresponding entry of the MPU table 22 used during the execution of the first software. This recorded MPU check information may take different forms. In some cases, the recorded MPU check information may include an active table identifier that was present in register 28 when the exception occurred, so that the MPU may then later check whether the address satisfies the access rights specified in that particular memory protection table when saving the floating-point registers, even when the active table has been changed due to the exception. Alternatively, the MPU may pre-verify the area reserved for storing floating-point state at the time of the exception itself, and record information indicating whether the verification was successful. Fig.11A and Fig. 11B An example using the first option is shown, while Fig. 12A and 12B An example using the second of these options is shown.

[0152] It should be understood that Fig.10 The lazy state shown in is only one option for handling exceptions. In some systems, control data in the control registers may specify whether lazy save is actually to be used to handle exceptions, so lazy save mode may not always be applied to every exception, and some exceptions may still be handled by saving both integer and floating point state at the time of the exception. Therefore, the techniques shown in Figures 11a to 12b may be used when lazy save is allowed by control data.

[0153] Fig.11A and Fig. 11B An example of a lazy save is shown where verification of the address of reserved space on the stack for floating point state is performed when a floating point instruction to be executed after an exception is encountered. Fig.11A shows the actions triggered in response to the exception itself, and Fig. 11B Actions triggered by subsequent floating-point instructions are shown.

[0154] like Fig.11AAs shown in, at step 250, in response to the exception, the exception handling hardware triggers saving the integer registers to the stack data structure. At step 252, space is allocated on the stack for saving the floating point state (e.g., updating the stack pointer data so that any subsequently saved data will be saved to a stack location outside the space allocated for the floating point state, even when the floating point state itself has not been saved). Alternatively, some embodiments may reverse steps 252 and 250 so that the integer registers are saved to the stack outside the space allocated for the floating point state. The lazy floating point save operation is marked as pending by setting a flag in the control register. In addition, the address identifying the floating point save area is saved to the memory or control register. At step 254, the exception handling hardware triggers to save the MPU check information again to any of the structures or registers in the memory, and the MPU check information is used to enable the hardware to later check whether the address of the retained floating point save area can be effectively accessed by the process executed before the exception. In this example, the MPU check information may be, for example, the active table ID provided in register 28 when the exception occurred, or may be some other identifier that enables determination of the location of the required entry in the MPU table associated with the process executing prior to the exception. It will be appreciated that Fig.11A Not all operations that may occur in response to an exception are shown, but only operations related to lazy saving are shown.In some cases, MPU entries that may be associated with a stack may be locked in a cache to prevent eviction.

[0155] like Fig. 11B As shown in , in the case where the exception has been handled and execution of the second software process begins after the exception, a floating-point instruction is then encountered. At step 260, it is determined whether the flag stored in the control register indicates whether a floating-point save operation is still pending. If the floating-point save operation is no longer pending, then at step 262, the floating-point instruction is executed. However, if the floating-point save operation is still pending, then at step 264, the address of the reserved floating-point save area is obtained and the address is checked by the MPU using the saved MPU check information. It may be necessary to detect whether the entire address area reserved for floating-point saves can be verified based on the MPU table identified by the MPU check information. If both the starting address and the ending address of the area reserved for saving the floating-point state correspond to the same memory protection entry of the MPU table, this can simplify the check because a single check of the access rights for one address within the area may be sufficient to determine whether all accesses for saving the floating-point state to the stack are allowed. Therefore, in some cases, in Fig.11AThe MPU check information stored at step 254 may also include an indication of whether the start address and the end address of the reserved area correspond to the same memory protection entry.

[0156] Therefore, at step 264, the MPU 20 obtains one or more memory protection entries corresponding to the reserved area, and checks at step 266 whether the access rights specified by these entries are satisfied by the memory access request issued to save the floating point state. If the access rights are satisfied, then at step 268, the floating point state is saved to the stack structure in the memory, and the floating point save pending instruction is cleared to indicate that the state save does not need to be performed again for the subsequent floating point instruction. However, if the rights are not satisfied for any access request for saving the floating point state, then at step 270, an error is signaled. In some cases, an error can prevent the execution of a floating point instruction. However, in other cases, a floating point instruction can be executed despite an error because if the error has a lower priority than an exception that is already being processed, the error may still be pending until the previous exception has been processed and the error can be processed next. Fig. 11B The dashed line between steps 270 and 262 indicates that sometimes, despite the error, the floating point instruction can still be executed.

[0157] Fig. 12A and 12B The diagram shows Fig.11A and Fig. 11B An alternative solution, where Fig. 12A shows state preservation in response to an exception, and Fig. 12B The operations performed for state preservation in response to the encountered floating point instruction are shown. In this example, in response to an exception, step 250 and Fig.11A In step 282, space is allocated in the stack structure for storing floating point registers. Again, some embodiments may retain these steps and allocate space on the stack for floating point registers before allocating space for storing integer registers. In this example, in Fig. 12AThe address of the allocated area on the stack is pre-verified during the exception handling at step 284. That is, the address of the location within the allocated space in the stack is verified for the active memory protection table identified by the active table ID register 28. Based on the access rights specified in any matching MPU entry, it is determined whether access for saving the floating-point state will be allowed, and if so, at step 286, the address of the floating-point save area is stored to the memory or register. In some cases, the fact that the address of the floating-point save area itself has been stored may be sufficient to indicate that the pre-verification at step 284 is successful, so it may not be necessary to also store a flag indicating that the pre-verification is successful. Alternatively, a separate flag may also be provided to confirm that the verification is successful. In the case where the address of the area allocated for saving the floating-point state has been saved at step 286, at step 288, a floating-point save pending instruction is set to indicate that a floating-point save operation will need to be performed on the first floating-point instruction executed after the exception.

[0158] Thus, in this example, the MPU check information may be an indication that the pre-verification at step 284 was successful.

[0159] If the pre-verification at step 284 determines that access to save floating point state is not allowed, there may be two options. In the first option, at step 290, the exception handling circuit or MPU may set a control flag specifying that access to store floating point state would be invalid, but nonetheless, no error is triggered, and then at step 288, the floating point save operation is marked as pending. It may be preferable to allow subsequent processing to continue without an error even if the pre-verification is unsuccessful, because this means that if the code executed after the exception never accesses the floating point registers, performance is improved because errors are not triggered unnecessarily, because invalid accesses to the save area for storing floating point state are never performed. Alternatively, in the second option, at step 292, an error may be triggered in the event that it is determined in the pre-verification that access is not allowed.

[0160] Fig. 12B 260, a floating point state save operation is determined to be pending, and if Fig. 11B, if there is no pending floating point save operation, then at step 262, the floating point instruction is executed as described above. If a floating point save operation is pending, then at step 294, it is determined whether the address of the floating point save area has been saved and whether the access has been marked as invalid in the pre-verification. In some cases, the fact that the address itself has been stored can be used as an indication that the access has not been marked as invalid, or if a particular control flag specifies whether the pre-verification at step 284 is successful, this can be used to determine whether to continue with the floating point save. If the address of the floating point save area has been saved and the access is not invalid, then at step 296, the floating point state is saved to an area previously reserved on the stack as identified by the address of the floating point state save area. In addition, the floating point save operation is cleared as pending so that any subsequent floating point instruction will not trigger a floating point save operation. On the other hand, if the access is marked as invalid or the address of the floating point save area has not been saved, then at step 298, an error is triggered. Note that this is different from Fig. 12A The example above corresponds to option 1, because if option 2 has already been chosen, processing never reaches Fig. 12B .

[0161] Thus, in general, this is accomplished by saving some information to either locate the relevant MPU entries associated with the process executing before the exception or to confirm that the pre-verification performed in response to the exception was successful, which enables the hardware-triggered lazy save to be safely verified while the process is executing after the exception, even when active memory protections are changed in response to the exception.

[0162] Fig.13The diagram shows a usable simulator implementation. Although the previously described embodiments implement the present invention from the aspect of the apparatus and method for operating specific processing hardware supporting related technologies, it is also possible to provide an instruction execution environment according to the embodiments described herein, which is implemented by using a computer program. Such computer programs are generally referred to as simulators, as long as they provide software-based implementations of the hardware architecture. Variants of simulator computer programs include simulators, virtual machines, models, and binary translators (including dynamic binary translators). Generally speaking, the simulator implementation can be run on a host processor 330 (optionally running a host operating system 320) that supports the simulator program 310. The host processor 330 includes a host processing circuit 332, a memory management unit (MMU) 334, and a memory system 336, which supports address translation and memory access permission checks based on a hierarchical page table stored in a memory. In some arrangements, there may be multiple layers of simulation between the hardware and the provided instruction execution environment, and / or there are multiple different instruction execution environments provided on the same host processor. Historically, powerful processors have been required to provide simulator implementations that execute at reasonable speeds, but such an approach may be justified in certain circumstances, such as when it is desirable to run code that is native to another processor for reasons of compatibility or reuse. For example, a simulator implementation may provide an instruction execution environment with additional functionality not supported by the host processor hardware, or provide an instruction execution environment that is normally associated with a different hardware architecture. Robert Bedichek gives an overview of simulation in "Some Efficient Architecture Simulation Techniques", Winter 1990 USENIX Conference, pp. 53-63.

[0163] Where embodiments have previously been described for specific hardware constructs or features, in simulated embodiments, equivalent functionality may be provided by suitable software constructs or features. For example, specific circuits may be implemented as computer program logic in simulated embodiments. Similarly, memory hardware (e.g., registers or caches) may be implemented as software data structures in simulated embodiments. Where one or more of the hardware elements referred to in the previously described embodiments are present in an arrangement on host hardware (e.g., host processor 330), some simulated embodiments may utilize host hardware where appropriate.

[0164] The simulator program 310 may be stored on a computer-readable storage medium (which may be a non-transitory medium) and provides a program interface (instruction execution environment) with the target code 300 (which may include an application, an operating system, and a hypervisor) that is the same as the application programming interface of the hardware architecture being modeled by the simulator program 310. Therefore, the simulator program 310 may be used to enable a host computer 330 that does not actually have the hardware features of the apparatus 2 discussed above to emulate these features by executing the program instructions of the target code 300 within the instruction execution environment.

[0165] like Fig.13 As shown in FIG. 1 , the simulator program 310 may include a program that is functionally similar to Figure 1 The processing program logic 340, MPU program logic 350, and SAU program logic 360 corresponding to the processing circuit 4, MPU 20, and SAU 42 of the host hardware 330. The MPU program logic 350 includes a permission check program logic 352, an MPU memory access program logic 354, and a table lookup program logic 356 that are functionally corresponding to the permission check circuit 40, the MPU memory access circuit 24, and the table lookup circuit 26, respectively. The MPU program logic 350 also includes program logic for managing a static MPU entry storage structure 357 and an active ID data structure 358 that correspond to the static MPU register storage device 36 and the active table ID register 28, respectively. The actual data of the data structures 357, 358 is stored in the memory system 336 of the host hardware 330, but the simulator program includes logic for defining the data structures 357, 358 and accessing the data on the data structures 357, 358. It is not necessary to provide logic corresponding to Figure 1 The simulator 310 may also include program logic corresponding to the MPU cache storage device 32 because, when emulating, all underlying data is stored in the memory system 336 of the host hardware 330, and therefore emulating the cache is unlikely to provide any performance improvement. Nevertheless, emulating the static MPU entry data structure 357 separately from the MPU table 22 allows the simulator to remain compatible with code designed to interact with statically defined MPU entries. In some embodiments, the simulator 310 may also include program logic for emulating the MPU cache storage device 32 because, while this may not benefit the performance of the simulation, it may be necessary if the simulator is intended to accurately simulate the number of frequency cycles that the emulated MPU 350 would use to respond to memory access requests. The SAU program logic 360 includes functionality that is similar to Figure 1 The memory security configuration register 44 and the security check circuit 46 correspond to the memory security configuration data structure 362 and the security check program logic 364.

[0166] The simulator program 310 manages the simulation of a simulated address space 370, which corresponds to the physical address space that would be provided on the processor simulated by the simulator program 310. The target code 300 to be executed, and the memory protection table 22 are associated with addresses within the simulated address space 370. The target code 300 includes memory access instructions that specify physical addresses within the simulated address space 370, which are subject to permission checks by the MPU program logic 350 based on the access permissions defined in the static MPU entry data structure 357 and / or the MPU table 22, and if they pass the permission check, they are mapped to virtual addresses of the host platform under the control of the simulator program 310, which virtual addresses can then be converted by the MMU 334 of the host hardware into physical addresses used to access the host memory system 336 (the MMU 334 can apply further permission checks to check whether memory access to the memory system is allowed based on the page table defined by the host operating system 320).

[0167] Thus, simulator 310 allows a host platform that does not have hardware support for an MPU with a memory-based memory protection table to execute code designed for a platform with such hardware support.

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

[0169] 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 these precise embodiments and that various changes and modifications may be made in these embodiments 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: processing circuitry to issue a memory access request specifying a target address identifying a location in a memory system to be accessed; as well as Memory protection unit MPU, including: a permission checking circuit for checking whether a memory access request issued by the processing circuit satisfies access rights specified in a memory protection table stored in the memory system, the memory protection table comprising a plurality of memory protection entries, each memory protection entry specifying: access rights of a corresponding address region of a variable size within an address space, and a region identification parameter for identifying a start address and an end address of the corresponding address region, each memory protection entry specifying a separate region identification parameter for identifying the start address and the end address, wherein the MPU is configured to allow the number of bytes of the variable size to be not a power of 2; and an MPU memory access circuit for initiating at least one MPU memory access request to access the memory protection table from the memory system; The MPU memory access circuit is configured to use the separate region identification parameter identifying the start address and end address of the corresponding address region specified by the given memory protection entry to determine whether a memory access request specifying a given target address hits the given memory protection entry.

2. The device according to claim 1, wherein: The plurality of memory protection entries in the memory protection table are arranged in the address space in an order of the start addresses of the corresponding address regions of the plurality of memory protection entries.

3. The device according to claim 1 or 2, wherein: For each memory protection entry, the MPU is configured to allow the start address and the end address of the corresponding address region to be not aligned with an N-byte address boundary, where N bytes is the size of the corresponding address region.

4. The device according to claim 1 or 2, wherein: The MPU includes a static MPU register storage device for storing at least one static memory protection entry, and the at least one static memory protection entry, once configured by at least one MPU parameter configuration operation processed by the processing circuit, remains stored in the static MPU register storage device until another MPU parameter configuration operation is processed by the processing circuit to trigger reconfiguration of the at least one static memory protection entry.

5. The device according to claim 4, wherein: In response to the memory access request issued by the processing circuit, the MPU memory access circuit is configured to: suppress the at least one MPU memory access request from being issued to the memory system when the target address is within the corresponding address area of ​​one of the at least one static memory protection entries stored in the static MPU register storage device and the memory access request issued by the processing circuit satisfies the access permission specified by the one of the at least one static memory protection entries.

6. The device according to claim 5, wherein: The MPU memory access circuit is also configured to: when the memory access request issued by the processing circuit cannot satisfy the access permission specified by the one of the at least one static memory protection entry, suppress the at least one MPU memory access request from being issued to the memory system.

7. The device according to claim 5, wherein: When the memory access request issued by the processing circuit cannot satisfy the access permission specified by the one of the at least one static memory protection entries, the MPU is configured to: allow the access permission specified by the one of the at least one static memory protection entries to be overridden by the access permission specified by the matching memory protection entry in the memory protection table stored in the memory system, and the matching memory protection entry includes the following entry: the corresponding address area for the entry includes the target address.

8. The device according to any one of claims 5 to 7, wherein: Each static memory protection entry is associated with an unused indication indicating whether the static memory protection entry is an unused static memory protection entry.

9. The device of claim 8, wherein: When a given static memory protection entry is indicated as the unused static memory protection entry, the MPU is configured to cache a memory protection entry from the memory protection table in a portion of the static MPU register storage device corresponding to the given static memory protection entry.

10. The device according to claim 1 or 2, wherein: The MPU comprises an MPU cache storage device for caching at least one memory protection entry of the memory protection table.

11. The device of claim 10, wherein: In response to the memory access request issued by the processing circuit, the MPU memory access circuit is configured to determine whether to initiate at least one MPU memory access request based on whether the target address is within the corresponding address area specified for any memory protection entry stored in the MPU cache storage device.

12. The device of claim 10, wherein: The MPU cache storage device is configured to: for each cached memory protection entry, specify an entry identifier associated with a location in the memory protection table where the cached memory protection entry is obtained, and the processing circuit retrieves the entry identifier in response to an entry identifier query instruction.

13. The device of claim 10, wherein: The MPU cache storage device is configured to: for each cached memory protection entry, specify a table identifier associated with the memory protection table from which the cached memory protection entry was obtained; The apparatus comprises an active table identifier register for storing an active table identifier identifying an active memory protection table; and The MPU is configured to refrain from using a cached memory protection entry stored in the MPU cache storage for which a table identifier is different from the active table identifier stored in the active table identifier register.

14. The apparatus of claim 10, comprising an active table identifier register for storing an active table identifier identifying an active memory protection table; in, The MPU is configured to invalidate all entries in the MPU cache storage device in response to the active table identifier register being modified.

15. The device of claim 10, wherein: In response to a memory protection cache invalidation operation, the processing circuit is configured to trigger the MPU to invalidate one or more cached memory protection entries stored in the MPU cache storage device that meet an invalidation condition.

16. The device of claim 10, wherein: Each memory protection entry in the memory protection table stored in the memory system specifies whether the memory protection entry is an enabled entry providing valid access rights or a disabled entry providing invalid access rights; and The MPU cache storage device is prohibited from caching disabled entries of the memory protection table stored in the memory system.

17. The device according to claim 1 or 2, comprising: a base address register for storing a base address of an active memory protection table to be accessed by the MPU memory access circuitry in response to a memory access request issued by the processing circuitry; as well as A size register is used to store an indication of the size of the active memory protection table.

18. The device of claim 17, wherein: In response to a predetermined type of MPU configuration operation specifying that one of the base address and the size of the active memory protection table is to be updated, the processing circuit is configured to: update the one of the base address and the size, and also update the other of the base address and the size to an invalid value indicating that an active memory protection table does not exist.

19. The device according to claim 1 or 2, wherein: The permission checking circuit is configured to determine whether the at least one MPU memory access request is allowed based on a preset access permission group specified independently of the memory protection table.

20. The device according to claim 1 or 2, wherein: The permission checking circuit is configured to determine whether the at least one MPU memory access request is allowed based on whether an address of the at least one MPU memory access request is within at least one of a plurality of address ranges specified by a plurality of memory security configuration registers.

21. The device according to claim 1 or 2, wherein: In response to the exception condition, the processing circuitry is configured to: perform a state save of a first portion of an architectural state to the memory system and record an indication of a second portion of the state save address region, the second portion of the state save address region being a region at which the processing circuitry will save the second portion of the architectural state to the memory system in response to an access to the second portion of the architectural state by a subsequent software process executed after the exception condition; and In response to the exception condition, the MPU is configured to record MPU check information that enables the MPU to determine during execution of the subsequent software process whether a memory access for saving the second portion of the architectural state to the memory system would satisfy access permissions specified by a memory protection entry of the memory protection table that was active when the exception condition occurred.

22. The device of claim 21, wherein: The MPU check information includes a base address and size of the memory protection table that was active when the exception occurred.

23. The device of claim 21, wherein: The MPU check information includes an indication of whether the start address and the end address of the second partial state preservation address area correspond to the same memory protection entry of the memory protection table that was active when the exception occurred.

24. A method for data processing, comprising: issuing a memory access request specifying a target address, the target address identifying a location in the memory system to be accessed; and Checking whether the memory access request satisfies access rights specified in a memory protection table including a plurality of memory protection entries, each memory protection entry specifying: access rights of a corresponding address region of a variable size in an address space, and a region identification parameter for identifying a start address and an end address of the corresponding address region, each memory protection entry specifying a separate region identification parameter for identifying the start address and the end address, wherein the variable size is allowed to be a number of bytes that is not a power of 2; wherein: The memory protection table is stored in the memory system; The checking includes using the separate region identification parameter identifying the start address and the end address of the corresponding address region specified by the given memory protection entry to determine whether a memory access request specifying a given target address hits the given memory protection entry.

25. A computer program product, comprising a computer program for controlling a host data processing device to provide an instruction execution environment for executing instructions; the computer program comprising: handler logic to issue a memory access request specifying a target address identifying a location to be accessed within a simulated address space simulated by the instruction execution environment; as well as Memory protection unit MPU program logic, including: a permission checker logic for checking whether a memory access request issued by the processing program logic satisfies access rights specified in a memory protection table including a plurality of memory protection entries, each memory protection entry specifying: access rights for a corresponding address region of a variable size within the simulated address space, and a region identification parameter for identifying a start address and an end address of the corresponding address region, each memory protection entry specifying a separate region identification parameter for identifying the start address and the end address, wherein the MPU program logic is configured to: allow the number of bytes of the variable size to be not a power of 2; and MPU memory access program logic to initiate at least one MPU memory access request specifying an address from the emulated address space to access the memory protection table; The MPU memory access program logic is configured to use the separate region identification parameter identifying the start address and end address of the corresponding address region specified by a given memory protection entry to determine whether a memory access request specifying a given target address hits the given memory protection entry.

Citation Information

Patent Citations

  • Programmable memory transfer request units

    CN107995978A