1. Field of the Invention
This invention relates to the field of data processing systems. More particularly, this invention relates to memory management units for data processing systems.
2. Description of the Prior Art
It is known to provide data processing systems with memory management units which serve to manage access to memory. For example, a memory management unit may be responsible for translating virtual addresses to physical addresses and for managing access permissions and other attributes, such as cacheability and bufferability. In typical systems it is the responsibility of the operating system software to program the necessary data and configuration to be used by the memory management unit. For example, the operating system may control the mapping between virtual addresses and physical addresses to be used by different application programs that are executed in conjunction with the operating system.
Some devices, such as direct memory access units, graphics processing units, input/output devices and the like may generate physical addresses not requiring virtual-to-physical translation, but may nevertheless require other services, such as those controlling access permissions. Providing such additional devices are appropriately configured (usually under control of the operating system) they may operate successfully in combination with the other elements within the system. In other situations, some devices may require the illusion of a contiguous memory space which is unavailable in the system due to fragmentation of memory. Such devices may require virtual-to-physical translation or scatter gather DMA functionality.
It is also known in the field of data processing systems to virtualise the execution environment. For example,
Viewed from one aspect the present invention provides a memory management unit for managing memory accesses using a plurality of different memory management contexts, each of said plurality of different memory management contexts defining how memory access is controlled for memory transactions associated therewith, said memory management unit comprising:
a translation buffer unit having a translation lookaside buffer configured to store a plurality of memory management attributes entries to be applied to transactions received from one or more transaction masters prior to being sent to one or more transaction slaves, said memory management attributes comprising at least one of address translation attributes, memory access attributes and access permission attributes; and
context disambiguation circuitry configured to respond to one or more characteristics of a memory transaction received from one of said one or more transactions masters to form a stream identifier and to determine which of said plurality of different memory management contexts is a matching context to be used with memory transactions having said stream identifier such that memory management attributes entries stored within said translation lookaside buffer for use with said memory transaction are formed under control of said matching context; wherein
said translation buffer unit is configured to store at least a portion of said stream identifier produced by said context disambiguation circuitry, to respond to one or more characteristics of a further memory transaction received by said translation buffer unit to form a further stream identifier therefrom and, if said further stream identifier matches said stream identifier, then to use for said further memory transaction any memory management attributes entries stored within said translation lookaside buffer corresponding to said stream identifier.
The present technique utilises context disambiguation circuitry to form a stream identifier from a received transaction and to match this with a memory management context which is then used to control forming of the memory management attribute entries to be stored within the translation lookaside buffer of the memory management unit. When a further transaction is received, then a further stream identifier may be formed therefrom and if this stream identifier matches a stream identifier already associated with some memory attribute entries stored within the transaction lookaside buffer, then those memory management attribute entries may be used for the further transaction assuming that they match in other respects (e.g. relate to the same regions of virtual address space).
The context disambiguation circuitry and the translation buffer unit may be formed together as part of the memory management unit. However, in some embodiments the context disambiguation circuitry is part of a translation control unit with that translation control unit being devolved certain tasks, such as performing a page table walk operation using page table data stored in a memory to determine at least part of the memory management attribute entries.
The context disambiguation circuitry may further comprise a stream mapping table containing entries that provide a mapping between at least one stream identifier and a memory management context to be used with memory transactions matching that stream identifier. The memory management context may provide data such as pointers to a page table base address, memory management unit configuration parameters and the like.
The stream identifier which is stored within the translation buffer unit may in some embodiments comprise a stream identifier value and a stream mask value with the stream mask value controlling which parts of the stream identifier value are significant in determining a match with the stream identifier value. Accordingly, the stream mask value may indicate that certain bits are not significant and need not match when a further stream identifier is compared with a stream identifier stored within the translation buffer unit to determine whether or not that further stream identifier matches the stream identifier stored within the translation buffer unit. This increases the flexibility with which stream identifiers may be formed and matched against one another.
In some embodiments each memory management attribute entry within the translation lookaside buffer may store its own stream identifier associated with that memory management attribute entry. In other embodiments the translation buffer unit may store a plurality of stream identifiers each associated with one or more memory attribute entries within the translation lookaside buffer and at least one of the plurality of stream identifiers being associated with a plurality of memory management attribute entries. In further embodiments a translation buffer unit may store a single stream identifier which is associated with all memory management attribute entries within the translation lookaside buffer of that memory management unit such that if a further stream identifier does not match the stored stream identifier then an option to flush the translation lookaside buffer may be provided or the transaction corresponding to the further stream identifier may be passed to the translation control unit for further processing. These different possibilities provide a spectrum in the granularity with which the stream identifier is stored in relation to the memory management attribute entries, i.e. for individual entries, for groups of entries or for all entries.
In a similar way the granularity of storage may be varied for one or more of a context index value identifying a memory management context associated with memory management attribute entries, an application space identifier identifying a thread of program execution associated with memory management attribute entries or a virtual machine identifier identifying a virtual machine execution environment associated with memory management attribute entries. The granularity may be varied from individual storage with each entry, with a group of entries or all entries within a translation buffer unit.
It will be appreciated that a memory management unit could be dedicated to an individual transaction master, however, in other embodiments a plurality of transaction masters may be coupled to an individual memory management unit.
In some embodiments a plurality of translation buffer units, each associated with a different transaction master, may be coupled with a shared translation control unit connected via a communication channel to all of the translation buffer units. This allows a single translation control unit to control multiple translation buffer units thereby reducing the circuit and configuration overhead.
Viewed from another aspect the present invention provides memory management unit for managing memory accesses using a plurality of different memory management contexts, each of said plurality of different memory management contexts defining how memory access is controlled for memory transactions associated therewith, said memory management unit comprising:
translation buffer means for buffering translation data and having translation lookaside buffer means for storing a plurality of memory management attributes entries to be applied to transactions received from one or more transaction masters prior to being sent to one or more transaction slaves, said memory management attributes comprising at least one of address translation attributes, memory access attributes and access permission attributes; and
context disambiguation means for responding to one or more characteristics of a memory transaction received from one of said one or more transactions masters to form a stream identifier and to determine which of said plurality of different memory management contexts is a matching context to be used with memory transactions having said stream identifier such that memory management attributes entries stored within said translation lookaside buffer means for use with said memory transaction are formed under control of said matching context; wherein
said translation buffer means is configured to store at least a portion of said stream identifier produced by said context disambiguation means, to respond to one or more characteristics of a further memory transaction received by said translation buffer unit to form a further stream identifier therefrom and, if said further stream identifier matches said stream identifier, then to use for said further memory transaction any memory management attributes entries stored within said translation lookaside buffer corresponding to said stream identifier.
Viewed from a further aspect the present invention provides a method of operating a memory management unit for managing memory accesses using a plurality of different memory management contexts, each of said plurality of different memory management contexts defining how memory access is controlled for memory transactions associated therewith, said method comprising the steps of:
buffering translation data within a translation buffer unit having a translation lookaside buffer storing a plurality of memory management attributes entries to be applied to transactions received from one or more transaction masters prior to being sent to one or more transaction slaves, said memory management attributes comprising at least one of address translation attributes, memory access attributes and access permission attributes;
responding to one or more characteristics of a memory transaction received by context disambiguation circuitry from one of said one or more transactions masters by forming a stream identifier and determining which of said plurality of different memory management contexts is a matching context to be used with memory transactions having said stream identifier such that memory management attributes entries stored within said translation lookaside buffer for use with said memory transaction are formed under control of said matching context;
storing at least a portion of said stream identifier produced by said context disambiguation circuitry within said translation buffer unit;
responding to one or more characteristics of a further memory transaction received by said translation buffer unit to form a further stream identifier therefrom; and
if said further stream identifier matches said stream identifier, then using for said further memory transaction any memory management attributes entries stored within said translation lookaside buffer corresponding to said stream identifier.
Viewed from a further aspect the present invention provides a memory management unit for managing memory accesses using a plurality of different memory management contexts, each of said plurality of different memory management contexts defining how memory access is controlled for memory transactions associated therewith, said memory management unit comprising:
a translation buffer unit having a translation lookaside buffer configured to store a plurality of memory management attributes entries to be applied to transactions received from one or more transaction masters prior to being sent to one or more transaction slaves, said memory management attributes comprising at least one of address translation attributes, memory access attributes and access permission attributes; wherein
said translation buffer unit stores one or more context parameter data entries at least partially identifying memory management attributes associated with a plurality memory management attributes entries within said translation lookaside buffer and, if a context parameter data entry is modified, then at least one of: all memory management attributes entries associated with said context parameter data entry within said translation lookaside buffer are flushed; and a memory transaction associated with said context parameter data entry that is modified is sent elsewhere for processing.
In some embodiments the translation buffer unit stores one or more context parameter data entries which at least partially identify memory management attributes associated with a plurality of memory management attribute entries within a translation lookaside buffer. For example, all of the memory management attribute entries may share the same virtual machine identifier and accordingly this virtual machine identifier may be saved as context parameter data associated with the translation buffer unit as a whole. In such a system, if a change is made to context parameter data then the translation buffer unit is configured to flush all memory management attribute entries that are associated with that changed context parameter data entry.
The context parameter data may take a wide variety of different forms and in some embodiments may include a context index value identifying a memory management context associated with a plurality of memory management attribute entries within the translation lookaside buffer, an application space identifier identifying a thread of program execution associated with a plurality of memory management attribute entries within the translation lookaside buffer, and a virtual machine identifier, identifying a virtual machine execution environment associated with a plurality of memory management attribute entries within the translation lookaside buffer.
Viewed from a further aspect the present invention provides a memory management unit for managing memory accesses using a plurality of different memory management contexts, each of said plurality of different memory management contexts defining how memory access is controlled for memory transactions associated therewith, said memory management unit comprising:
translation buffer means for buffering translation data and having translation lookaside buffer means for storing a plurality of memory management attributes entries to be applied to transactions received from one or more transaction masters prior to being sent to one or more transaction slaves, said memory management attributes comprising at least one of address translation attributes, memory access attributes and access permission attributes; wherein
said translation buffer means stores one or more context parameter data entries at least partially identifying memory management attributes associated with a plurality of memory management attributes entries within said translation lookaside buffer means and, if a context parameter data entry is modified, then at least one of: all memory management attributes entries associated with said context parameter data entry said within said translation lookaside buffer means are flushed; and a memory transaction associated with said context parameter data entry that is modified is sent elsewhere for processing.
Viewed from a further aspect the present invention provides a method of operating a memory management unit for managing memory accesses using a plurality of different memory management contexts, each of said plurality of different memory management contexts defining how memory access is controlled for memory transactions associated therewith, said method comprising the steps of:
buffering translation data within a translation buffer unit having a translation lookaside buffer for storing a plurality of memory management attributes entries to be applied to transactions received from one or more transaction masters prior to being sent to one or more transaction slaves, said memory management attributes comprising at least one of address translation attributes, memory access attributes and access permission attributes;
storing within said translation buffer unit one or more context parameter data entries at least partially identifying memory management attributes associated with a plurality of memory management attributes entries within said translation lookaside buffer; and
if a context parameter data entry is modified, then at least one of: flushing all memory management attributes entries associated with said context parameter data entry within said translation lookaside buffer means; and sending elsewhere for processing a memory transaction associated with said context parameter data entry that is modified.
The above, and other objects, features and advantages of this invention will be apparent from the following detailed description of illustrative embodiments which is to be read in connection with the accompanying drawings.
As an example, an operating system 14, 16, 18 may provide virtual-to-physical address translation on behalf of its associated application programs 2, 4, 6, 8, 10, 12 and then the hypervisor program 20 provides address translation from the addresses generated by the operating system programs 14, 16, 18, which are in fact intermediate physical addresses, to real physical addresses to be applied to the underlying hardware.
The memory management unit 24 supports two stages of memory management. The first stage S1 is configured by one of the operating system programs 14, 16, 18 and controls the memory management on behalf of that operating system program 14, 16, 18. As an example, the S1 management may perform address translation from virtual addresses (VA) as generated by the application programs 2, 4, 6, 8, 10, 12 to intermediate physical addresses (IPA) as generated by the operating system program 14, 16, 18 and applied to the virtual machine execution environment provided to that operating system program 14, 16, 18 by the hypervisor program 20.
The second stage S2 of memory management provided by the memory management unit 24 is configured by the hypervisor program 20 and maps between the virtual machine execution environment provided to the operating system program 14, 16, 18 and the real physical environment provided by the underlying hardware. Thus, for example, the stage two S2 management may map between intermediate physical addresses (IPA) and real physical addresses (PA). The stage one S1 management is configured by the operating system program 14, 16, 18 and the stage two S2 management is configured by the hypervisor program 20.
If it is the first time that a memory transaction with a stream identifier SID matching the received stream identifier has been encountered by the memory management unit 28 (including the possibility that such a stream identifier has been previously encountered but its data flushed), then there will not be a hit within the translation lookaside buffer 32. The context disambiguation circuitry 34 will accordingly form the new stream identifier (including a stream identifier value and an associated mask value as will be discussed later) which is used to identify memory transactions from a particular transaction master which should be managed using the same context of memory management data, e.g. using the same parameters pointing to the associated page table, permission data, memory management unit configuration etc. Context fetch circuitry 36 fetches this context parameter data from the memory where a plurality of translation context 38 are stored. Page walker circuitry 40 performs a page table walk through page table data 42 stored within the memory to determine memory management attribute data to be stored within the translation lookaside buffer 32. This memory management attribute data may comprise one or more of address translation attributes, memory access attributes and access permission attributes. It is also possible that the memory management attribute data may contain further information.
When a further memory transaction is received by the memory management unit 28, it is passed to the translation lookaside buffer where its stream identifier is compared with all of the stream identifiers stored within the translation lookaside buffer. If there is a match between the stream identifier of the further memory transaction and a stream identifier stored within the translation lookaside buffer, then the memory management attribute data for that entry may be used if it matches in other respects to the further memory transaction (e.g. the input address is one for which the memory management data is stored within the translation lookaside buffer 32). It is possible that even if the stream identifiers match, then there may be a miss within the translation lookaside buffer 32 as the particular input address of the further memory transaction does not match an address for which the memory management attribute data is stored within the translation lookaside buffer 32 even though the source of the further memory transaction using the stream identifier has been encountered before and the memory management unit 28 is already storing some of the memory management attribute data for that source in association with the context parameter data relevant to that source.
The dual core processor 46 executes application programs using a plurality of operating system programs and a hypervisor program. Accordingly, the memory management units within the dual core processor 46 which are provided for each of the cores, are configured to perform both stage one and stage two S1+S2 translations and management in order to move from the virtual addresses produced by the application programs into the real physical addresses for addressing the memory 62. The devices 50, 52, 54 are programmed under control of one of the operating system programs such that they generate what may be considered to be intermediate physical addresses. These intermediate physical addresses are translated into real physical addresses by memory management units performing a stage two translation. The graphics processing unit 48 has its own memory management unit for performing memory management operations prior to memory transactions reaching its local cache 70. If the memory transactions need to progress further, then a memory management unit applies a second stage of memory management and translation before the memory transactions reach the memory 62.
It will be appreciated that in the examples of
It will be appreciated that there is a spectrum provided in the embodiments of
In the example of
The next stage is context disambiguation. This may be performed by context disambiguation circuitry which includes a stream mapping table. Each entry within the stream mapping table is capable of providing a mapping between at least one stream identifier and a memory management context (context parameter data) to be used within memory transactions matching that stream identifier.
The stream identifier may comprise a stream identifier value and a stream mask value. The stream mask value may be used to control which parts of a stream identifier value are significant when determining a match with that stream identifier value. The stream mask value may accordingly be a bit mask to be applied to received stream identifier values and the stored stream identifier values when comparing these to determine whether or not they match.
The processing proceeds using one or more of a stage one or a stage two translation contexts with associated page table data. A management bypass and a memory access fault route are also provided. Translation and translation lookaside buffer translation operations are performed before the final output transaction from the memory management unit is generated.
If a match occurs at step 88, then step 90 determines whether or not there is a hit within the translation lookaside buffer for the memory address of the received memory transaction. If there is a hit, then step 92 determines whether or not the application permission data for that memory management attribute entry within the translation lookaside buffer matches the received memory transaction. If there is not a permission pass, then processing proceeds to step 94 where a fault indication is sent to the translation control unit and a fault response, such recording the fault and/or raising an interrupt request is triggered.
If the permissions pass then step 96 serves to use the translation lookaside buffer entry in which a hit was found to generate the output memory transaction which is output from the memory management unit.
If the determination at step 88 was that the stream identifier did not match or the determination at step 90 was that there was no hit within the translation lookaside buffer, then processing proceeds to step 98 where a request is sent to the translation control unit to return memory management attribute data that may be used to form the output address for the received memory transaction. At step 100 the memory management attribute data is received back from the translation control unit and at step 102 the memory management attribute data is stored within the translation buffer unit associated with the stream identifier for the memory transaction. Processing then proceeds to step 90 where a translation buffer hit will occur.
Although illustrative embodiments of the invention have been described in detail herein with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments, and that various changes and modifications can be effected therein by one skilled in the art without departing from the scope and spirit of the invention as defined by the appended claims.