A. Technical Field
The present invention relates generally to microcontrollers, and more particularly, to the secure management of block data within an integrated microcontroller cache sub-system and external memory device(s).
B. Background of the Invention
Content protection within a processor or microcontroller has been a challenge for the electronic industry for some time. As semiconductor technology has advanced, many microcontrollers have become complex integrated systems-on-chip. However, systems-on-chip technology is often time limited by the amount of memory space that can be effectively integrated and managed internally within the microcontroller. Integrating a larger memory within a microcontroller requires that additional space, timing, power and control issues be addressed when the microcontroller is designed. This issue of integrating internal memory within a microcontroller will become even more significant as future microcontroller applications are developed which demand larger memory to store both data and instructions.
In addressing these issues, one approach is to move memory to a location external to the integrated microcontroller. This allows for both power and space constraints to be transitioned outside of the integrated microcontroller circuit. For many microcontroller systems, the use of external memory is a preferred solution for storage of both data and program code in terms of both size and cost. However, the protection of stored content within external memory is problematic, especially for secure transactions with highly sensitive information, because this stored data resides outside of the secure environment of the integrated microcontroller. The use of external memory may potentially reduce the performance of the microcontroller because data coherency must be maintained between memory devices within the microcontroller system.
The use of external memory may also introduce latency within the microcontroller read/write command execution that drives the microcontroller performance below an acceptable level. The use of external memory further complicates a microcontroller because of the time requirements for accessing content from an external memory as well as securing that traffic between the microcontroller and external memory. In particular, the time required to read and/or write to an external memory may be burdensome to certain applications and significantly reduce the performance of the microcontroller. Additionally, because content within an external memory is secure, a microcontroller would need to decrypt content each time the content is processed within the microcontroller and re-encrypt each time content is stored within the external memory.
In many real-time applications, the time constraints caused by encryption and decryption functions, as well as associated read and write operations, may significantly reduce the performance of the microcontroller. Accordingly, what is needed is a microcontroller and external memory system that is able to more efficiently manage encryption and decryption operations within a real-time environment as well as manage stored content within this system. Additionally, the microcontroller must maintain data coherency within its memory and cache systems to ensure proper operation.
The present invention relates to a microcontroller that securely manages stored information within an integrated cache subsystem, an integrated buffer subsystem and external memory. Various embodiments of the microcontroller include structures and methods that ensure data coherency between the cache and buffer subsystems and the external memory. Additionally, data security is maintained within the entire microcontroller system by providing block-level encryption that secures data within the external memory as well as during transmission between the integrated microcontroller and external memory.
In certain embodiments of the invention, the integrated microcontroller comprises a bi-directional data path and an instruction path that provides strong, block-level encryption to content traversing the two paths. Both data and instructions are encrypted by a crypto engine or crypto engines that ensure data integrity when being stored in I/O buffers or memory external to the microcontroller. Read operations are provided that allow the microcontroller to be resource sensitive in identifying and reading blocks of data across the cache subsystem, the buffer subsystem and the external memory.
In various embodiments of the invention, the secure microcontroller system is provided with user-programmable write policies that allow an individual to balance data integrity and system performance relative to the microcontroller's intended application. In a write-through mode, data coherency is prioritized such that consistency between the integrated cache subsystem and external memory is highly ranked within the system write policy. In a write-back mode, system performance is prioritized such that write operations to the external memory are queued and await the memory bus to go idle or a total queued write operation count to exceed a threshold before stalling the memory bus and performing the write operations.
One skilled in the art will recognize the relative strength of block-level, cache-based encryption that is provided within the microcontroller. This encryption security and data management between cache subsystems and external memory allow the microcontroller to effectively operate in a number of different applications and environments
Certain features and advantages of the present invention have been generally described in this summary section; however, additional features, advantages, and embodiments are presented herein or will be apparent to one of ordinary skill in the art in view of the drawings, specification, and claims hereof. Accordingly, it should be understood that the scope of the invention shall not be limited by the particular embodiments disclosed in this summary section.
Reference will be made to embodiments of the invention, examples of which may be illustrated in the accompanying figures. These figures are intended to be illustrative, not limiting. Although the invention is generally described in the context of these embodiments, it should be understood that it is not intended to limit the scope of the invention to these particular embodiments.
FIG. (“FIG.”) 1 generally illustrates a system including an integrated microcontroller and an external memory according to various embodiments of the invention.
Embodiments of the present invention provide systems, devices and methods for secure microcontrollers. In the following description, for purposes of explanation, specific details are set forth in order to provide an understanding of the invention. It will be apparent, however, to one skilled in the art that the invention can be practiced without these details. One skilled in the art will recognize that embodiments of the present invention, described below, may be performed in a variety of ways and using a variety of means. Those skilled in the art will also recognize additional modifications, applications, and embodiments are within the scope thereof, as are additional fields in which the invention may provide utility. Accordingly, the embodiments described below are illustrative of specific embodiments of the invention and are meant to avoid obscuring the invention.
Reference in the specification to “one embodiment” or “an embodiment” means that a particular feature, structure, characteristic, or function described in connection with the embodiment is included in at least one embodiment of the invention. The appearance of the phrase “in one embodiment,” “in an embodiment,” or the like in various places in the specification are not necessarily all referring to the same embodiment.
A. Secure Microcontroller
A secure microcontroller system comprising an integrated cache sub-system, crypto-engine, buffer sub-system and external memory is described according to various embodiments of the invention. The secure microcontroller incorporates block encryption methods to ensure that content communicated between the integrated microcontroller and external memory is protected and real-time performance of the system is maintained. Additionally, the microcontroller system provides a user-configurable memory write policy in which memory write protocols may be selected to balance data coherency and system performance.
The secure microcontroller is implemented with an on-chip cache sub-system for instruction and data that allows for dynamic read/write command execution within the cache sub-system and the external memory. During operation, the secure microcontroller uses a bi-directional data path that provides real-time decryption for read operations and real-time encryption for write operations to the external data memory. The microcontroller uses block-level cache-based encryption and decryption of both data and instructions stored within the external memory. A description of block encryption is described within U.S. Pat. No. 6,996,725, which patent is incorporated by reference in its entirety. A memory management unit is provided that controls the timing and execution of these operations within the integrated cache sub-system and the external memory.
In various embodiments, the processor uses the Harvard memory architecture with separate program and data memories. This memory architecture improves system bandwidth by allowing simultaneous access to program and data memories; it also permits using different word lengths for data storage. In certain embodiments of the invention, both program and data memories are integrated within a single external memory. However, one skilled in the art will recognize that multiple external memory device may also be used.
One skilled in the art will recognize that various processor architectures, clocking schemes and addressing methods may be implemented in accordance with embodiments of the invention.
The system memory, including both the cache subsystem and the external memory, stores various types of data and instructions within the microcontroller system including both the cache subsystem and external memory. One skilled in the art will recognize that the data memory can be implemented with a variety of memory technologies, such as SRAM, DRAM, Flash, etc.
The crypto-engine 202 works on-demand of the data cache subsystem and implements strong cryptographic algorithm(s) that are recognized by one of skill in the art. The crypto-engine 202 employs a block cipher to perform block encryption along both the bi-directional data path and the instruction path. In particular, the crypto-engine 202 employs block ciphers and process data in blocks of multiple bytes/words that is generally greater than the data width for a processor and its internal storage elements. Examples of the block ciphers include DES, Triple DES, AES and others known to those of skill in the art. The actual implemented block cipher may affect the time required to perform block encryption.
For many applications, the crypto-engine 202 can be shared between instruction and data paths since cache line replacement is on-demanded only and the hit rate for both instruction and data caches are high. A system stall occurs when both caches and their associated buffers are missed at the same time. At this condition, data write-back has the priority of instruction and data cryptographic operations. For applications having heavy data traffic, dedicated crypto engines may be incorporated for a distinct data path and a distinct instruction path. One skilled in the art will recognize that various cryptographic structures, such as crypto engine implementations, as well as associated methods may be used to manage data and instruction paths within the microcontroller system.
In regards to the data path, the external memory 110 stores the encrypted data used by the microcontroller. The external memory 110 may also store unprotected data or clear data. If unprotected data is being retrieved, the microcontroller architecture supports a by-pass path on which the unprotected data is directly stored to the D-cache 204 and read by the microprocessor 250. In certain embodiments, this unprotected data is stored within a defined region of the external memory 110 so that the MMU 205 recognizes this as unprotected and causes it to be transmitted on the by-pass path 260.
For protected data, the encrypted data block is transmitted through the data path so that the crypto engine 202 can decrypt it prior to be processed by the CPU 250. The encrypted data block is retrieved from the external memory 110 via the data bus and stored within the data I/O buffer 201. The crypto-engine retrieves this buffered, encrypted data block and decrypts it using the keys stored within the key registers and generated from the random number generator 220, which is hardware on the chip in certain embodiments. The keys are typically generated during an initial set-up or calibration of the microcontroller. Additionally, the system may support functionality that filters weak keys from the random generator.
The key registers are usually battery-backed to ensure that power is maintained to the registers and key integrity is not lost. If a tamper attack is detected, the contents within the register will self-destruct. To further enhance security, the contents of the key registers can be periodically flipped to remove potential memory residue from the registers. Key bits may also be organized in small groups and group flipping is performed in an orderly fashion to minimize switching current. Correction logic may be placed between the key registers and crypto engine for maintaining data consistency.
After the protected data is decrypted, it is buffered within the decrypted buffer-in 203 which temporarily stores the decrypted data block and subsequently cached within the D-cache 204. The decrypted data is stored within the D-cache 204 according to management protocol such that it is made available to the CPU 250 for a certain period of time.
If data is being written to the external memory 110, then the data block is cached within the D-cache 204 and transmitted to the decrypted buffer-out 203. The data block is then encrypted by the crypto-engine 202 and subsequently buffered within the data I/O buffer 201. Finally, the encrypted data block is stored within the external memory 110 via the data bus. This writing of encrypted data blocks to the external memory 110 may be timed so that these operations occur during periods of time the controller is less active. In one embodiment, a write policy may be defined so that the data blocks are written into the D-cache 202 and maintained until activity on the data path is idle such that encryption operations may then be triggered. Additionally, the amount of buffered data blocks may be monitored so that if the total amount of buffered data blocks awaiting encryption exceeds a particular threshold, then the microcontroller operations are stalled so that these blocks may be encrypted and written to the external memory 110. Data consistency is maintained by managing data write-through and write-back operations within the controller memory architecture.
The MMU 205 manages the storage and retrieval of data stored within both the D-cache 204 and the external memory 110. The MMU 205 coordinates the flow of data through the data path including timing control, security checking, cache control, etc. The MMU 205 also monitors which data is being loaded within the D-cache 204 so that data access may be coordinated between the cache subsystem, buffer subsystem and the external memory 110. For example, in response to a data request, the MMU 205 may first determine whether the data is stored within the D-cache 204 as decrypted data. If the data is not cached, then it is retrieved from the external memory 110, subsequently decrypted and cached.
B. Integrated Microcontroller Cache Sub-System
The following description of a microcontroller cache sub-system is intended to illustrate certain embodiments of the invention. One skilled in the art will recognize that other cache subsystems and memory segmentation architectures may be realized in accordance with embodiments of the present invention.
The cache subsystem can be arranged in accordance with specific system requirements. For certain applications, separating instruction and data cache can significantly reduce potential resource conflicts and simply flow control of the MMU 205. It may also relax memory requirements for cache implementation.
To ensure system data integrity while maintaining optimal performance, the cache subsystem may support user selectable write-through and write-back functionality for write operations. For write-through operation, data coherency is maintained when new data is always updated to both data cache and external memory. However, performance may be at issue for certain applications that involve substantial data operations if data is frequency written back to the external memory. In this case, the user has the option to enable a write-back operation. To achieve data coherency, the cache tag includes an modify “m” status bit to signify modified data blocks that must be written back to the external memory before cache line replacement (or other bus master requesting data containing in the same block). Setting the modify bit actually creates a memory request to the MMU for memory write back. One skilled in the art will recognize that providing a user the option of calibrating the microcontroller to operate in a write-back or write-through mode allows a balance between data reliability and performance.
Actual data write-back is dependent on the updating policy of the system and is controlled by the MMU 205. In certain cases, the MMU 205 will push a modified data block to the external memory as soon as the I/O bus is idle. For some applications dealing with critical data, the MMU 205 incorporates an M counter that counts the number of the modified data blocks with a user programmable threshold value. If this feature is enabled and the M count is greater than the threshold value, the MMU 205 will stall the CPU operation and push modified data back to the external memory.
The MMU 205 also monitors warning signals from environmental circuits and tamper detectors, and push modified data back to the external memory in case of emergency. The crypto system can be powered by backup power in case of power fail until all data has been saved. The cache and its buffers are self-destructed on tamper attacks.
The tag 340 provides the MMU 205 with information to identify a cache match or miss. The tag 340 also includes the modify bit 345 which identifies whether the cached data (stored within the cache way) has been modified within the cache memory.
One skilled in the art will recognize that the number of cache ways may vary, effectively increasing or decreasing the depth of the cache, all in accordance of the present invention. In one embodiment of the invention, the D-cache comprised two cache ways, each being 64 words and each way having 64 tags.
C. Management of Data Access across Cache Sub-System and External Memory
If the data block is encrypted data 545 and the decrypted buffer-in is empty 550, then the data block is decrypted 555 by the crypto-engine. The resulting decrypted data block is subsequently saved 560 within the decrypted buffer-in memory.
If the block to be read is not in the cache, then a search may be performed across the buffers within the integrated microcontroller system. A check is performed to identify whether the address is stored 645 within the decrypted buffer in. If it is and the command is a read command 680, then the block is read from the decrypted buffer-in and forwarded to the processor 690 and the data block is written to the cache 695 and the corresponding tag is updated.
If the block is not within the decrypted buffer-in, then a search of the I/O buffer is performed. If the address of the block matches an address within the I/O buffer address table, then a determination is made as to whether the block is encrypted 660. If the block is not encrypted, then if the command is a read command 680, the block is forwarded to the processor 690 and written to the cache 695. If the block is encrypted, the block is decrypted 670 by the crypto engine and saved in the decrypted buffer-in 675. If the command is a read command 680, then the block is forwarded to the processor 690 and written to the cache 695.
If the command address is not found in either the decrypted buffer-in or the I/O buffer, then the operation is a cache and buffer miss 655, and the data block is read from the external memory 665. If the block is not encrypted 660 and the command is a read command 680, then the block is forwarded 690 to the processor and written to cache 695. However, if the block is encrypted 660, then the block is decrypted 670 by the crypto engine and saved 675 in the decrypted buffer-in. If the command is a read command 680, then the decrypted block is forwarded 690 to the processor and written to cache 695.
In accordance with various embodiments of the invention, a write policy may define either a write-through mode or a write-back mode. If the write-through mode is selected 720, then the updated data block in cache will automatically be written to the external memory. If the data block is not encrypted data 750, then the data block is written directly to the external memory 775. If the data block is encrypted data 750, then the data block is pushed 755 to the decrypted buffer-out. Thereafter, the data block is encrypted 760 and pushed to the I/O buffer 770. The encrypted block is then written to the external memory 775.
If the write-back mode is selected 720, then the memory bus is checked 775 to determine if it is idle. If the bus is idle and the data block is not encrypted data 750, then the data block is written directly to the external memory 775. If the data block is encrypted data 750, then the data block is pushed 755 to the decrypted buffer-out. Thereafter, the data block is encrypted 760 and pushed to the I/O buffer 770. The encrypted block is then written to the external memory 775.
However, if the bus is active, then the cache block modify bit is set and the M count is incremented 730 and a check is performed to see if the M count 735 is over the threshold. If it is under the threshold, then the data block waits for either the threshold to be crossed or the bus to become idle. If the count is over the threshold, the processor is stalled 740 and the block is read 745 from the cache. Thereafter, the block is written to memory 775, the particular steps depending on whether the block is encrypted or not encrypted data.
If the microcontroller is operating in a write-back mode 778, then the system will monitor both the memory bus and the number of external memory write commands awaiting execution. As previously discussed, the queued write commands are executed during a processor stall if the total number of write commands exceeds a threshold value. However, if the memory bus becomes idle, then the queued commands are continually executed 792 until they have all completed 790 or until the memory bus becomes active with other operations.
Once the queued operations have completed, then the system checks to see if there are any warnings 795 and may take corrective actions 797 if necessary.
The microcontroller system also includes environmental and tamper monitoring 785 in which warnings 782 are identified in which a tampering event is occurring, the system is being reset or shutdown, or if the stability of the microcontroller system is jeopardized. In these instances, the queued memory writes are executed 792 until all are complete 790. It is important to note that the system recognizes the time or clock cycles required to exercise these commands and manages accordingly.
The foregoing description of the invention has been described for purposes of clarity and understanding. It is not intended to limit the invention to the precise form disclosed. Various modifications may be possible within the scope and equivalence of the appended claims. For example, the structures and functions described herein may also be applied to microcontroller systems that use integrated memory instead of or in cooperation with external memory.