An address conversion system, processor, address conversion method and electronic device
By using a combined structure of a multi-level page table query module and N L1 level translation caches in the processor, the problem of page table read delay in the multi-level page table structure is solved, the address translation efficiency is improved and the delay is reduced, achieving Improves performance without increasing cache capacity.
Patent Information
- Application Number
- CN202310446235.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2043-04-24
AI Technical Summary
The multi-level page table structure in existing processors has a large page table read delay when converting virtual addresses to physical addresses, resulting in performance loss. Increasing cache capacity to improve hit rates will increase chip area and power consumption. .
A combined structure of a multi-level page table query module and N L1-level conversion caches is used. The L1-level conversion cache stores the last level page table. The multi-level page table query module searches for and returns matching page table entries. If there is a miss, Then it is read from external memory, improving address conversion efficiency and reducing latency.
Without increasing the total cache capacity of the MMU, the page table hit rate is improved, the delay in converting virtual addresses to physical addresses is reduced, and the negative impact on chip performance is reduced.
Smart Images

Figure CN116594925B
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computers, and specifically relates to an address conversion system, a processor, an address conversion method and an electronic device. Background Art
[0002] The processor's memory management unit (MMU) is an address translation system responsible for converting virtual addresses to actual physical addresses. In order to improve the efficiency of memory management, most of the current mainstream MMUs use a multi-level page table structure to convert virtual addresses to physical addresses. For example, the 4-level page table structure is currently more commonly used. This page table structure contains 4 levels of page tables, among which the 1 / 2 / 3-level page tables are actually directory page tables, which are used to generate the physical address for obtaining the next-level page table, and the 4-level page table is used to generate the final physical address. The page tables at each level are usually stored in an external memory. In the complete 4-level page table search process, the page table data needs to be read from the external memory 4 times. Since the delay of reading data from the external memory is very large, in order to reduce the impact of the page table data read delay on performance, the conversion of virtual addresses and physical addresses in the MMU can be achieved through translation lookaside buffers (TLB). Each level of the page table in the multi-level page table structure will be assigned a corresponding translation buffer, which is used to store the corresponding level of page table and extract the physical address of the next level of page table. The physical address is used to read data from the external memory and fill it into the translation buffer where the next-level page table is located when the corresponding page table data is not found in the next-level page table.
[0003] When the MMU performs virtual-to-real address conversion, it first performs a matching search for page table entries in the corresponding conversion buffer. If a hit entry is found, the physical address of the next-level page table is obtained based on the page size of the hit entry and the offset of the virtual address to be checked. The physical address and the virtual address to be checked are then sent to the next-level conversion buffer for similar operations until the last-level conversion buffer obtains the corresponding physical address. After obtaining the corresponding physical address, the final physical address is calculated in combination with the offset of the virtual address. In the process of the MMU searching for page table entries in the conversion buffers at various levels, there may be a no-hit situation. If there is no hit, the corresponding conversion buffer needs to trigger the refilling of the current page table entry, that is, the corresponding page table entry data needs to be read from the external memory and filled into the conversion buffer.
[0004] There are a large number of hardware access units in the processor (such as cache, DMA (Direct Memory Access), HUB, etc.) that need to access external memory. The virtual address needs to be converted to the physical address through the MMU and then sent to the external memory. Usually each hardware access unit is assigned an MMU for virtual and real address conversion. The schematic diagram is as follows Figure 1 As shown, Figure 1 Each MMU in the processor includes a multi-level translation buffer. In a complete 4-level page table structure, the 4-level translation buffer is required to realize the conversion from virtual address to physical address. If the page table data is not hit in the translation buffer, the page table data needs to be read from the external memory. Generally speaking, the delay cost of reading data from the external memory is very high, which will cause a large negative performance impact on the entire processor.
[0005] In order to reduce the negative impact on performance, a relatively large cache is usually configured in each level of MMU translation memory to store the respective page tables to increase the probability of a hit. A larger cache capacity in the translation cache means a higher hit rate, but it will bring other problems, such as a larger chip area, greater power consumption, and worse chip yield. Summary of the invention
[0006] In view of this, the purpose of the present application is to provide an address translation system, a processor, an address translation method and an electronic device, so as to improve the hit rate of the page table while keeping the total capacity of the MMU cache unchanged.
[0007] The embodiment of the present application is implemented as follows:
[0008] In a first aspect, an embodiment of the present application provides an address translation system, comprising: a multi-level page table query module and N L1-level translation buffers; each L1-level translation buffer stores the last-level page table in the M-level page table structure, and each L1-level translation buffer is used to search from the page table stored in itself whether there is a page table entry that matches the virtual address translation request; and when there is no page table entry that matches the virtual address translation request in the page table, a page table read request is issued, wherein the page table read request includes key information in the virtual address translation request, and N and M are greater than or equal to 1; a multi-level page table query module is connected to each L1-level translation buffer, and the multi-level page table query module is used to search from the M-level page table structure stored in itself whether there is a page table entry that matches the page table read request when receiving the page table read request. If a page table entry that matches the page table read request is found, the matching page table entry is returned to the corresponding L1-level translation buffer; each L1-level translation buffer is also used to determine the physical memory address based on the physical address in the matching page table entry and the offset of the virtual address to complete the conversion of the virtual address to the physical address.
[0009] In an embodiment of the present application, an address translation system with the above structure is configured with N L1 translation buffers so that virtual address translation requests of N hardware access units at the same time can be processed simultaneously. Since the L1 translation buffer stores the last level page table, if the corresponding page table entry is matched in the L1 translation buffer, the address translation can be performed directly, which can improve the address translation efficiency. At the same time, N L1 translation buffers share a multi-level page table query module, so that the cache capacity of the multi-level page table query module can be set larger (relative to 1 L1 translation buffer corresponding to one multi-level page table query module). In this way, while ensuring that the total cache capacity of the MMU remains unchanged, the hit efficiency can be improved and the page table read delay can be reduced, thereby reducing the negative impact of the virtual address to physical address conversion delay on the chip system performance.
[0010] In combination with a possible implementation method of the first aspect, if M is an integer greater than or equal to 2, the multi-level page table query module is also used to determine whether the matching page table entry can be used directly before returning the matching page table entry to the corresponding L1 level translation buffer. If the matching page table entry cannot be used directly, continue to search for a page table entry that matches the page table read request in the M-level page table structure until a page table entry that can be used directly is found.
[0011] In the embodiment of the present application, before returning the matching page table entry to the corresponding L1 translation buffer, it is further determined whether the page table entry can be used directly. If it can be used directly, the matching page table entry is returned to the corresponding L1 translation buffer. If it cannot be used directly, it is necessary to continue to search in the next level page table whether there is a page table entry that matches the page table read request until a page table entry that can be used directly is found. By further determining whether the matching page table entry can be used directly, it can be applied to address translation of various page table structures, which greatly increases the applicability of the solution.
[0012] In combination with a possible implementation manner of the first aspect, if there is no page table entry matching the page table read request in any target-level page table of the M-level page table structure, the multi-level page table query module is also used to read the target-level page table entry from the external memory based on the starting address of the target-level page table entry and the address offset of the target-level page table entry, and update the target-level page table entry in the multi-level page table query module based on the read target page table entry.
[0013] In an embodiment of the present application, if a page table entry matching the page table read request is not found in any target-level page table of the M-level page table structure, the target-level page table entry will be read from the external memory to ensure that the entire solution can be performed sequentially.
[0014] In combination with a possible implementation manner of the embodiment of the first aspect, the multi-level page table query module includes: M-level translation buffers, each level of translation buffer is used to cache a specified level of page table in the M-level page table structure; when each level of translation buffer receives the page table read request, it searches from the page table stored in its own storage whether there is a page table entry that matches the page table read request. If a page table entry that matches the page table read request is found, it is determined whether the page table entry can be used directly. If the page table entry can be used directly, the matching page table entry is returned to the corresponding L1 level translation buffer.
[0015] In an embodiment of the present application, when searching from a multi-level page table query module whether there is a page table entry that matches a page table read request, the above-mentioned logical structure is used to ensure that the search order between the page tables at each level is sequential, thereby ensuring the accuracy of the search.
[0016] In combination with a possible implementation method of the first aspect, each of the L1 level translation buffers is specifically used to read the virtual address and process number in the virtual address translation request, and use the specified address range in the virtual address as the address identification number, and search from the page table stored in itself whether there is a page table entry that matches the address identification number and the corresponding process number.
[0017] In an embodiment of the present application, by using the specified address range in the virtual address as the address identification number, a search is performed from the page table stored in itself to see whether there is a page table entry that matches the address identification number and the corresponding process number. This can improve the search efficiency while ensuring accuracy.
[0018] In combination with a possible implementation manner of the first aspect embodiment, the address conversion system also includes: an L2-level conversion buffer, the multi-level page table query module is connected to each L1-level conversion buffer through the L2-level conversion buffer, the L2-level conversion buffer stores the last level page table in the M-level page table structure, and the number of stored page table entries is greater than the number of page table entries stored in each L1-level conversion buffer; the L2-level conversion buffer is used to send the page table read request to the multi-level page table query module when there is no page table entry matching the page table read request in the page table stored in itself, and send the page table entry matching the page table read request returned by the multi-level page table query module to the corresponding L1-level conversion buffer.
[0019] In an embodiment of the present application, an L2-level translation cache having a storage capacity greater than that of the L1-level translation cache is further provided to cache more page table entries belonging to the last-level page table to improve the hit rate. At the same time, the number of queries for accessing the multi-level page table query module can be reduced, thereby further improving the search efficiency while ensuring that the total cache capacity of the MMU remains unchanged.
[0020] In combination with a possible implementation manner of the first aspect embodiment, the L2 level translation cache is also used to directly send the matching page table entry to the corresponding L1 level translation cache when there is a page table entry matching the page table read request in the page table stored in the cache.
[0021] In the embodiment of the present application, if there is a page table entry matching the page table read request in the L2 translation buffer, there is no need to access the multi-level page table query module, which can further improve the search efficiency.
[0022] In a second aspect, an embodiment of the present application further provides a processor, including an address conversion system provided by the embodiment of the first aspect above and / or any possible implementation method in combination with the embodiment of the first aspect.
[0023] In the third aspect, an embodiment of the present application also provides an address conversion method, including: searching from an L1-level conversion buffer whether there is a page table entry that matches the virtual address conversion request, wherein the L1-level conversion buffer stores the last level page table in the M-level page table structure, and M is an integer greater than or equal to 1; when there is no page table entry that matches the virtual address conversion request in the L1-level conversion buffer, issuing a page table read request, and the page table read request includes the virtual address in the virtual address conversion request; searching from a multi-level page table query module whether there is a page table entry that matches the page table read request, wherein the multi-level page table query module stores an M-level page table structure; if a page table entry that matches the page table read request is found, determining the physical memory address based on the physical address in the matching page table entry and the offset of the virtual address to complete the conversion of the virtual address to the physical address.
[0024] In combination with a possible implementation manner of the third aspect embodiment, before searching from the multi-level page table query module whether there is a page table entry that matches the page table read request, the method also includes: determining that a page table entry that matches the page table read request is not found from the L2-level translation buffer, wherein the L2-level translation buffer stores the last level page table in the M-level page table structure, and the number of stored page table entries is greater than the number of page table entries stored in each L1-level translation buffer.
[0025] In combination with a possible implementation manner of the third aspect embodiment, if there is no page table entry matching the page table read request in any target level page table in the multi-level page table query module, the method further includes: based on the starting address of the target level page table entry and the address offset of the target level page table entry, reading the target level page table entry from an external memory, and updating the target level page table entry in the multi-level page table query module based on the read target level page table entry.
[0026] In combination with a possible implementation method of the third aspect, searching the L1 level translation cache for whether there is a page table entry that matches the virtual address translation request includes: reading the virtual address and process number in the virtual address translation request, and using the specified address range in the virtual address as the address identification number, and searching the L1 level translation cache for whether there is a page table entry that matches the address identification number and the corresponding process number.
[0027] In combination with a possible implementation method of the third aspect, if M is greater than or equal to 2, searching whether there is a page table entry that matches the page table read request from the multi-level page table query module, including: searching whether there is a page table entry that matches the page table read request from each level of page table stored in the multi-level page table query module in turn; if there is a page table entry that matches the page table read request, determining whether the page table entry can be used directly; if the page table entry can be used directly, returning the matching page table entry to the corresponding L1 level conversion buffer; if the page table entry cannot be used directly, searching whether there is a page table entry that matches the page table read request from the next level page table of the page table where the page table entry is located, until a page table entry that can be directly used and matches the page table read request is found.
[0028] In a fourth aspect, an embodiment of the present application further provides an electronic device, comprising: a memory and a processor, the processor being connected to the memory; the memory being used to store programs; the processor being used to call the programs stored in the memory to execute the method provided in the above-mentioned third aspect embodiment and / or any possible implementation method in combination with the third aspect embodiment. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings without creative work. As shown in the drawings, the above and other purposes, features and advantages of the present application will be clearer. The same reference numerals indicate the same parts in all the drawings. The drawings are not deliberately scaled to the actual size, and the focus is on showing the main purpose of the present application.
[0030] Figure 1 A schematic diagram of the connection between a virtual address translation system, a hardware access unit and an external memory in the prior art.
[0031] Figure 2 A schematic diagram showing the connection between an address translation system (MMU) and a hardware access unit and an external memory provided in an embodiment of the present application is shown.
[0032] Figure 3 A schematic diagram of the structure of an L1TLB provided in an embodiment of the present application is shown.
[0033] Figure 4 A schematic diagram of the structure of a multi-level page table query module provided in an embodiment of the present application is shown.
[0034] Figure 5A schematic diagram of the query principle of a multi-level page table query module provided in an embodiment of the present application is shown.
[0035] Figure 6 A schematic diagram showing a connection principle between another address translation system (MMU) provided in an embodiment of the present application, a hardware access unit, and an external memory.
[0036] Figure 7 A flow chart of an address conversion method provided in an embodiment of the present application is shown.
[0037] Figure 8 A schematic structural diagram of an electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0038] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.
[0039] It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it is not necessary to further define and explain it in the subsequent drawings. At the same time, in the description of this application, relational terms such as "first", "second", etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements includes not only those elements, but also includes other elements that are not clearly listed, or also includes elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements limited by the sentence "including one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements.
[0040] Furthermore, the term "and / or" in this application is merely a term used to describe the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone.
[0041] The present application provides an address conversion system, a processor, an address conversion method and an electronic device, which are used to improve the hit rate of cache page table queries and reduce page table read latency while keeping the total capacity of the MMU cache unchanged, thereby reducing the negative impact of the virtual address to physical address conversion delay on the chip system performance.
[0042] The following will be combined Figure 2, the address translation system provided by the embodiment of the present application is described. The address translation system (MMU) includes: a multi-level page table query module and N L1 translation buffers (abbreviated as L1TLB), each L1 translation buffer is connected to the multi-level page table query module, and one L1 translation buffer corresponds to a hardware access unit (such as cache, DMA, HUB, etc.). N is an integer greater than or equal to 1, and the maximum value of N can be the maximum value of physical address translation supported by the processor at the same time.
[0043] The bus structure may be a crossbar structure, a grid structure, a series structure, a ring structure, etc. A suitable bus structure may be selected based on the design's requirements for data return delay and the impact on chip area.
[0044] In addition to being responsible for the conversion of virtual addresses to actual physical addresses, the MMU can also have the following functions:
[0045] (1) User-mode programs are restricted to accessing data in specific memory areas, while other memory areas are accessed by core programs. With the virtual memory management mechanism, different programs have independent memory areas and are guaranteed not to interfere with each other. The paging-based storage management mechanism can set separate read-write protection attributes for each page, and the core-mode driver and operating system can prevent other applications from accidentally modifying code segments.
[0046] (2) Allocate a continuous address memory space for the program. The MMU can map discontinuous physical pages to continuous virtual memory space.
[0047] (3) The virtual memory management mechanism can also expand the address space by using a direct mapping virtual-to-real address mapping method, that is, the virtual address is the physical address. Then a 32-bit address can access up to 4GB of physical memory space. After address conversion through the MMU, the physical address bit width can be expanded to access a larger physical memory space.
[0048] By configuring N L1 translation buffers, each hardware access unit can correspond to one L1 translation buffer, so that the virtual address translation requests of N hardware access units at the same time can be processed simultaneously. Each hardware access unit can run multiple processes for address translation at the same time, and these multiple processes share the L1 translation buffer corresponding to the hardware access unit.
[0049] Each L1-level translation buffer stores the last level page table in the M-level page table structure, where M is an integer greater than or equal to 1. For example, if the M-level page table structure is a 3-level page table structure, then each L1-level translation buffer stores a 3-level page table; if the M-level page table structure is a 4-level page table structure, then each L1-level translation buffer stores a 4-level page table.
[0050] Each L1 translation buffer is used to search from its own stored page table whether there is a page table entry matching the virtual address translation request when receiving a virtual address translation request from the hardware access unit, and issue a page table read request when there is no page table entry matching the virtual address translation request in the page table, wherein the page table read request includes key information in the virtual address translation request, such as the virtual address, process number and other related information (such as the hardware access unit ID). If there is a page table entry matching the virtual address translation request in the page table, the physical memory address (final physical address) can be directly determined based on the physical address in the matching page table entry and the offset of the virtual address (such as the address range of the 11th to 0th bits in the 48-bit virtual address) to complete the conversion from the virtual address to the physical address without issuing a page table read request.
[0051] It can be understood that different values of M correspond to different offset pages of the virtual address. For example, if the L1 translation buffer stores the last page table in the 4-level page table structure, the offset of the virtual address is the address range of bits 11 to 0. If the L1 translation buffer stores the last page table in the 3-level page table structure, the offset of the virtual address can be the address range of bits 19 to 0, but is not limited to 19-0. This offset can be reasonably determined by hardware designers and software designers based on the page table size of the system.
[0052] When each L1-level translation buffer searches its own stored page table for a page table entry that matches the virtual address translation request, it is specifically used to read the virtual address and process number in the virtual address translation request, and uses a specified address range in the virtual address (such as the address range of bits 47 to 12 in a 48-bit virtual address) as the address identifier, and searches its own stored page table for a page table entry that matches the address identifier and the corresponding process number, that is, compares the address identifier and the corresponding process number with the address identifier and the process number corresponding to each page table entry in the page table. If there is a page table entry in the page table whose address identifier and process number match, then it indicates that a page table entry has been hit.
[0053] In an optional implementation, the structure of the L1 level translation buffer is as follows: Figure 3As shown, it includes: a virtual address request stack to be converted, a virtual address information identification code cache, a page table entry cache, an address conversion unit, and an external read request interface. Among them, the L1 level conversion cache can adopt a set-associative cache structure or a fully associative cache structure. The set-associative cache structure and the fully associative cache structure are common cache structures in the art and will not be described in detail here.
[0054] The virtual address request stack to be converted is used to store virtual address conversion requests from the hardware access unit, wherein the virtual address conversion request includes key information such as the virtual address and the process number.
[0055] The virtual address information identification code cache is used to read the virtual address and process number in the virtual address translation request, and use the specified address range in the virtual address as the address identification number, and also match the address identification number and process number with the cached address identification number and process number. If there is a matching address identification number and process number, the storage location corresponding to the matching address identification number and process number is sent to the page table entry cache so that the page table entry cache reads the page table entry corresponding to the storage location. If there is no hit, a page table read request is issued to the external read request interface.
[0056] The virtual address information identification code cache stores mapping relationships between multiple different address identification numbers and process numbers and storage addresses of page table entries. Different address identification numbers and process numbers correspond to different storage addresses, so different page table entry pages are read.
[0057] The page table entry cache is used to cache the mapping relationship between the storage location and the page table entry. The page table entry cache can read the page table entry of the corresponding location based on the storage location sent by the virtual address information identification code cache and send it to the address translation unit.
[0058] The address translation unit is used to determine the physical memory address based on the matching page table entry and the offset of the virtual address to complete the translation from the virtual address to the physical address.
[0059] The multi-level page table query module stores an M-level page table structure. When receiving a page table read request, the multi-level page table query module is used to search the M-level page table structure stored in itself for a page table entry that matches the page table read request. If a page table entry that matches the page table read request is found, the matching page table entry is returned to the corresponding L1-level translation buffer. In addition, if a page table entry that matches the page table read request is not found, the corresponding page table needs to be read from the external memory, and the page table in the multi-level page table query module is updated based on the read page table.
[0060] If M is an integer greater than or equal to 2, the multi-level page table query module is also used to determine whether the matching page table entry can be used directly before returning the matching page table entry to the corresponding L1-level translation buffer (if the page table where the matching page table entry is located is a directory page table, the corresponding page table entry cannot be used directly; if the page table where the matching page table entry is located is a page table that generates the final physical address (the last-level page table), the corresponding page table entry can be used directly, and an identifier can be added to the page table to indicate whether the page table is a directory page table or a last-level page table). If the matching page table entry cannot be used directly, continue to search for a page table entry that matches the page table read request in the M-level page table structure until a page table entry that can be used directly is found.
[0061] Taking into account that not all address translations are based on a fixed-level page table structure to translate virtual addresses into physical addresses, for example, some are based on the 1-level page table structure to translate virtual addresses into physical addresses, and some are based on the 2-level page table structure to translate virtual addresses into physical addresses, the current maximum supported address translation is a 4-level page table structure. For the 4-level page table, the 1 / 2 / 3-level page tables are actually directory page tables, which are used to generate the physical address of the next-level page table, and the 4-level page table is used to generate the final physical address.
[0062] In order to be compatible with address translation based on various page table structures, when a page table entry matching a page table read request is found, it is necessary to further determine whether the page table entry can be used directly. If it can be used directly, the matching page table entry is returned to the corresponding L1 translation buffer. If it cannot be used directly, it is necessary to continue searching in the next level page table to see if there is a page table entry matching the page table read request until a page table entry that can be used directly is found. By further determining whether the matching page table entry can be used directly, it can be applied to address translation of various page table structures.
[0063] It is understandable that if address conversion compatible with various page table structures is not required, there is no need to further determine whether the matching page table entry can be used directly. For example, if a fixed page table structure (such as a 4-level page table structure) is used for address conversion, then as long as the page table entry that matches the page table read request is not found in the last level page table (4-level page table), the matching page table entry cannot be returned directly. That is, when a page table entry that matches the page table read request is found in the 1 / 2 / 3 level page table, it is necessary to continue to search for a page table entry that matches the page table read request in the next level page table. In an optional implementation, the M-level page table structure of the multi-level page table query module is used to search in turn from each level of page table stored in itself whether there is a page table entry that matches the page table read request. If there is a page table entry that matches the page table read request in the current level page table, it is determined whether the page table entry can be used directly. If the page table entry can be used directly, the matching page table entry is returned to the corresponding L1 level translation buffer. If the page table entry cannot be used directly, the remaining page tables are continued to be searched to see whether there is a page table entry that matches the page table read request until the search of the last level page table is completed.
[0064] If there is no page table entry matching the page table read request in any target-level page table in the M-level page table structure, the multi-level page table query module is also used to read the target-level page table entry from the external memory based on the starting address of the target-level page table entry and the address offset of the target-level page table entry (the content from the starting address to the starting address + the address offset is the target-level page table entry), and update the target-level page table entry in the multi-level page table query module based on the read target-level page table entry.
[0065] Among them, the target level page table can be any level page table in the M-level page table structure, and the page table entries in the target level page table are the target level page table entries. For example, the page table entries in the level 1 page table are the level 1 page table entries, the page table entries in the level 2 page table are the level 2 page table entries, and so on.
[0066] It can be understood that the starting address and address offset of target-level page table entries at different levels are different. Taking the 4-level page table (corresponding to the 4-level page table entry) as an example, for a 48-bit virtual address, if there is no page table entry in the 1-level page table that matches the page table read request, the starting address of the corresponding target-level page table entry is the pre-configured base address (used to indicate the starting address of the 1-level page table entry in the external memory), and the corresponding address offset is the address of the 47th to 39th bits (47:39) in the 48-bit (47:0) virtual address; if there is no page table entry in the 2-level page table that matches the page table read request, the starting address of the corresponding target-level page table entry is the physical address of the page table entry hit in the 1-level page table (used to indicate the starting address of the 2-level page table entry in the external memory), and the corresponding address offset is the pre-configured base address (used to indicate the starting address of the 2-level page table entry in the external memory). The address offset is the address of the 38th to 30th bits in the 48-bit virtual address (38:30); if there is no page table entry matching the page table read request in the 3-level page table, the starting address of the corresponding target-level page table entry is the physical address of the page table entry hit in the 2-level page table (used to indicate the starting address of the 3-level page table entry in the external memory), and the corresponding address offset is the address of the 29th to 21st bits in the 48-bit virtual address (29:21); if there is no page table entry matching the page table read request in the 4-level page table, the starting address of the corresponding target-level page table entry is the physical address of the page table entry hit in the 3-level page table (used to indicate the starting address of the 4-level page table entry in the external memory), and the corresponding address offset is the address of the 20th to 12th bits in the 48-bit virtual address (20:12). Among them, the physical address in the 4-level page table is used to obtain the final physical address.
[0067] The multi-level page table query module includes M-level translation buffers, which are used to cache the first-level page table in the M-level page table. In an optional implementation, taking a 4-level page table structure (currently supports a maximum of 4-level page table structures) as an example, the structure diagram of the multi-level page table query module is as follows: Figure 4 As shown, it includes: 4 fully associative cache structure translation buffers (TLBs), page table entry return interface, and external memory read interface. It can be understood that Figure 4 The conversion buffer in can also adopt a set-associative cache structure.
[0068] Each level of translation buffer is used to cache a specified level of page table in the M-level page table structure. For example, TLB0 is used to cache level 1 page table, TLB1 is used to cache level 2 page table, TLB2 is used to cache level 3 page table, and TLB3 is used to cache level 4 page table.
[0069] When receiving a page table read request, each level of translation buffer searches its own stored page table for a page table entry that matches the page table read request. If a page table entry that matches the page table read request is found, it determines whether the page table entry can be used directly. If the page table entry can be used directly, the matching page table entry is returned to the corresponding L1 level translation buffer. If the page table entry cannot be used directly, the physical address of the next level page table is extracted based on the matching entry, and then the page table read request and the physical address are sent to the next level translation buffer. If no page table entry that matches the page table read request is found, the corresponding page table is read from the external memory through the external memory read interface, and the stored page table is updated accordingly.
[0070] For example, when the multi-level page table query module receives a page table read request from L1TLB, it first queries whether there is a page table entry that matches the page table read request in the first-level page table translation buffer TLB0. If the page table entry is matched, it determines whether the current page table entry can be directly returned to L1TLB. If it can be returned to L1LTLB, the matched page table entry is sent to L1TLB through the page table entry return interface, and the page table search ends. If it cannot be directly returned to L1TLB, then the physical address of the next-level page table entry is extracted based on the matched page table entry, and then the page table read request and the physical address are input into the second-level page table translation buffer TLB1. If the page table entry is not matched, then the corresponding page table entry is read from the external memory through the external memory read interface, and then the physical address is extracted and input into the second-level page table translation buffer TLB1 together with the page table read request. In the same way, the page table read request is always sent to the last-level page table translation buffer TLB3, and the search is performed in the last-level page table translation buffer TLB3.
[0071] Among them, when searching in each level of the page table whether there is a page table entry that matches the page table read request, it is similar to the process of searching for a matching page table entry in the L1TLB mentioned above. For example, by reading the virtual address and process number in the page table read request, and using the specified address range in the virtual address as the address identification number, search from the corresponding page table whether there is a page table entry that matches the address identification number and the corresponding process number.
[0072] For a better understanding, the following Figure 5 The page table entries in the level 1 page table are level 1 page table entries, the page table entries in the level 2 page table are level 2 page table entries, the page table entries in the level 3 page table are level 3 page table entries, and the page table entries in the level 4 page table are level 4 page table entries.
[0073] Bits 47 to 39 of the virtual address are used to query the level 1 page table entry, bits 38 to 30 are used to query the level 2 page table entry, bits 29 to 21 are used to query the level 3 page table entry, bits 20 to 12 are used to query the level 4 page table entry, and bits 11 to 0 are used as address offsets to generate the final physical address. The configuration base address specifies the starting address of the level 1 page table entry in the external memory. The physical address in the level 1 page table entry specifies the starting address of the level 2 page table entry corresponding to the current level 1 page table entry in the external memory. The physical address of the level 2 page table entry specifies the starting address of the level 3 page table entry corresponding to the current level 2 page table entry in the external memory. The physical address of the level 3 page table entry specifies the starting address of the level 4 page table entry corresponding to the current level 3 page table entry in the external device.
[0074] During the page table search process, the virtual address ranges actually used as address identifiers by each level of the page table are different. Figure 5 In the example shown, the virtual address range corresponding to the level 1 page table is 47~39, that is, when searching for a matching page table entry in the level 1 page table, 47~39 in the virtual address is used as the address identification number for search; the virtual address range corresponding to the level 2 page table is 47~30, that is, when searching for a matching page table entry in the level 2 page table, 47~30 in the virtual address is used as the address identification number for search; the virtual address range corresponding to the level 3 page table is 47:21, that is, when searching for a matching page table entry in the level 3 page table, 47~21 in the virtual address is used as the address identification number for search; the range corresponding to the level 4 page table is 47~12, that is, when searching for the corresponding matching page table entry in the level 4 page table, 47~12 in the virtual address is used as the address identification number for search.
[0075] In the page table search process, first search in the level 1 page table to see if there is a page table entry that matches the page table read request. If a page table entry is matched, determine whether the page table entry can be used directly. If it can be used directly, the search ends. If it cannot be used directly, the physical address in the matching page table entry (used to indicate the starting address of the level 2 page table entry in the external memory) and the page table read request are sent to TLB1. After that, search in the level 2 page table to see if there is a page table entry that matches the page table read request. If a page table entry is matched, determine whether the page table entry can be used directly. If it can be used directly, the search ends. If it cannot be used directly, the physical address in the matching page table entry (used to indicate the starting address of the level 3 page table entry in the external memory) and the page table read request are sent to TLB2. After that, the 3-level page table is searched for a page table entry that matches the page table read request. If a page table entry is matched, it is determined whether the page table entry can be used directly. If it can be used directly, the search ends. If it cannot be used directly, the physical address in the matching page table entry (used to indicate the starting address of the 4-level page table entry in the external memory) and the page table read request are sent to TLB3. After that, the 4-level page table is searched for a page table entry that matches the page table read request. If a page table entry is matched, it is determined whether the page table entry can be used directly. If it can be used directly, the search ends.
[0076] If there is no page table entry matching the page table read request in the level 1 page table, the level 1 page table entry is read from the external memory based on the configuration base address and bits 47 to 39 of the virtual address, filled into the level 1 page table, and the physical address of the read level 1 page table entry (used to indicate the starting address of the level 2 page table entry in the external memory) and the page table read request are sent to TLB1.
[0077] If there is no page table entry matching the page table read request in the level 2 page table, the level 2 page table entry is read from the external memory based on the physical address of the level 1 page table entry and bits 38 to 30 of the virtual address, filled into the level 2 page table, and the physical address of the read level 2 page table entry (used to indicate the starting address of the level 3 page table entry in the external memory) and the page table read request are sent to TLB2.
[0078] If there is no page table entry matching the page table read request in the level 3 page table, the level 3 page table entry is read from the external memory based on the physical address of the level 2 page table entry and bits 29 to 21 of the virtual address, and filled into the level 3 page table. The physical address of the read level 3 page table entry (used to indicate the starting address of the level 4 page table entry in the external memory) and the page table read request are sent to TLB3.
[0079] If there is no page table entry matching the page table read request in the level 4 page table, the level 4 page table entry is read from the external memory based on the physical address of the level 3 page table entry and bits 20 to 12 of the virtual address, filled into the level 4 page table, and the physical address of the read level 4 page table entry (used to generate the final physical address) is returned to the LITLB.
[0080] In order to further improve the efficiency of address translation, in one implementation, the address translation system further includes: an L2 translation buffer (L2TLB), and the multi-level page table query module is connected to each L1 translation buffer through the L2 translation buffer, and its principle diagram is as follows Figure 6 As shown. The L2-level translation buffer stores the last-level page table in the M-level page table structure, and the number of page table entries stored is greater than the number of page table entries stored in each L1-level translation buffer. Since the cache capacity of the L2TLB is greater than the cache capacity of the L2TLB, the L2TLB can store more page table entries, thereby improving the search efficiency, and adopting a structure in which N L1TLBs share one L2TLB, cache space can be saved. It can be understood that under this implementation, the cache space of the multi-level page table query module can be appropriately reduced to ensure that the total cache capacity of the MMU remains unchanged when the L2TLB is increased.
[0081] The L2-level translation buffer is used to send a page table read request to the multi-level page table query module when there is no page table entry matching the page table read request in the page table stored in the L2-level translation buffer, and to send the page table entry matching the page table read request returned by the multi-level page table query module to the corresponding L1-level translation buffer.
[0082] The L2-level translation buffer is also used to search from the page table stored in its own storage whether there is a page table entry that matches the page table read request when receiving the page table read request sent from the L1-level translation buffer. When there is a page table entry that matches the page table read request, the matching page table entry is directly sent to the corresponding L1-level translation buffer.
[0083] The process of the L2 translation buffer searching for a page table entry that matches the page table read request in its own stored page table is consistent with the process of the L1 translation buffer searching for a page table entry that matches the page table read request in its own stored page table. For example, the specified address range in the virtual address (such as the address range of the 47th to 12th bits in the 48-bit virtual address) is used as the address identification number to search for a page table entry that matches the address identification number and the corresponding process number in its own stored page table.
[0084] The structure of the L2 translation buffer is similar to the structure of the L1 translation buffer described above, except that the address translation unit is missing.
[0085] Based on the same inventive concept, an embodiment of the present application further provides a processor, the processor including the above-mentioned address translation system (MMU). The MMU is used to implement the translation from virtual address to physical address.
[0086] The processor may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a graphics processor (GPU), and an image processor may be a general-purpose image processor (GPGPU), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), and a field programmable gate array (FPGA). The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
[0087] The address conversion system provided by the processor embodiment has the same implementation principle and technical effects as those of the aforementioned address conversion system embodiment. For the sake of brief description, for matters not mentioned in the processor embodiment, reference can be made to the corresponding contents in the aforementioned address conversion system embodiment.
[0088] Based on the same inventive concept, the present application embodiment also provides an address conversion method applied in a processor. Figure 7 Explain it.
[0089] S1: Check the L1 translation cache to see if there is a page table entry that matches the virtual address translation request.
[0090] Upon receiving a virtual address translation request from the hardware access unit, a page table entry matching the virtual address translation request is searched in the L1 translation buffer. When there is no page table entry matching the virtual address translation request in the L1 translation buffer, S2 is executed. When there is a page table entry matching the virtual address translation request in the L1 translation buffer, S4 is executed.
[0091] The L1 translation buffer stores the last level page table in the M level page table structure, where M is an integer greater than or equal to 1.
[0092] The specific implementation process of S1 can be to read the virtual address and process number in the virtual address conversion request, and use the specified address range in the virtual address as the address identification number, and search from the L1 level conversion buffer whether there is a page table entry that matches the address identification number and the corresponding process number.
[0093] S2: issuing a page table read request, wherein the page table read request includes the virtual address in the virtual address conversion request.
[0094] S3: Searching from a multi-level page table query module whether there is a page table entry matching the page table read request, wherein the multi-level page table query module stores an M-level page table structure.
[0095] After receiving the page table read request, a page table entry matching the page table read request is searched in the multi-level page table query module, and if a page table entry matching the page table read request is found, S4 is executed. If a page table entry matching the page table read request does not exist in any target-level page table in the multi-level page table query module, the address conversion method further includes: based on the starting address of the target-level page table entry and the address offset of the target-level page table entry, the target-level page table entry is read from the external memory, and the target-level page table entry in the multi-level page table query module is updated based on the read target-level page table entry.
[0096] If M is greater than or equal to 2, the process of searching the multi-level page table query module for whether there is a page table entry that matches the page table read request is as follows: searching each level of the page table stored in the multi-level page table query module in turn for a page table entry that matches the page table read request; if there is a page table entry that matches the page table read request, determining whether the page table entry can be used directly; if the page table entry can be used directly, returning the matching page table entry to the corresponding L1-level conversion buffer; if the page table entry cannot be used directly, searching the next level of the page table where the page table entry is located for a page table entry that matches the page table read request, until a page table entry that can be used directly and matches the page table read request is found.
[0097] S4: Determine the physical memory address based on the physical address in the matching page table entry and the offset of the virtual address to complete the conversion from the virtual address to the physical address.
[0098] In an optional implementation, when the MMU also includes an L2-level translation cache, before S3, the address conversion method also includes: determining that a page table entry matching the page table read request is not found in the L2-level translation cache, wherein the L2-level translation cache stores the last level page table in the M-level page table structure, and the number of stored page table entries is greater than the number of page table entries stored in each L1-level translation cache.
[0099] The implementation principle and technical effects of the method embodiment are the same as those of the aforementioned address conversion system embodiment. For the sake of brief description, for matters not mentioned in the method embodiment, reference may be made to the corresponding contents in the aforementioned address conversion system embodiment.
[0100] like Figure 8 As shown, Figure 8 The electronic device 200 provided in the embodiment of the present application is shown in the structural block diagram. The electronic device 200 comprises: a transceiver 210, a memory 220, a communication bus 230 and a processor 240.
[0101] The transceiver 210, the memory 220, and the processor 240 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses 230 or signal lines. Among them, the transceiver 210 is used to send and receive data. The memory 220 is used to store a computer program, which includes at least one software function module that can be stored in the memory 220 in the form of software or firmware or solidified in the operating system (OS) of the electronic device 200. The processor 240 is used to execute the computer program stored in the memory 220. For example, processor 240 is used to search from an L1-level translation buffer whether there is a page table entry that matches the virtual address translation request, wherein the L1-level translation buffer stores the last level page table in an M-level page table structure, and M is an integer greater than or equal to 1; when there is no page table entry that matches the virtual address translation request in the L1-level translation buffer, a page table read request is issued, and the page table read request includes the virtual address in the virtual address translation request; search from a multi-level page table query module whether there is a page table entry that matches the page table read request, wherein the multi-level page table query module stores an M-level page table structure; if a page table entry that matches the page table read request is found, a physical memory address is determined based on the physical address in the matching page table entry and the offset of the virtual address to complete the conversion of the virtual address to the physical address.
[0102] Among them, the memory 220 can be, but is not limited to, a random access memory (Random Access Memory, RAM), a read only memory (Read Only Memory, ROM), a programmable read-only memory (Programmable Read~Only Memory, PROM), an erasable programmable read~only memory (Erasable Programmable Read~Only Memory, EPROM), an electrically erasable read-only memory (Electric Erasable Programmable Read~Only Memory, EEPROM), etc.
[0103] The processor 240 may be an integrated circuit chip with signal processing capabilities. The above-mentioned processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The various methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor 240 may also be any conventional processor, etc.
[0104] The electronic device 200 mentioned above includes but is not limited to a mobile phone, a tablet, a computer, a server, etc.
[0105] It should be noted that the various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0106] In several embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0107] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0108] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An address translation system, characterized in that: include: N L1-level translation buffers, each L1-level translation buffer stores the last-level page table in the M-level page table structure, and each L1-level translation buffer is used to search from the page table stored in itself whether there is a page table entry matching the virtual address translation request; and when there is no page table entry matching the virtual address translation request in the page table, issue a page table read request, wherein the page table read request includes key information in the virtual address translation request, and N and M are integers greater than or equal to 1; A multi-level page table query module is connected to each L1-level translation buffer, and is used for searching whether there is a page table entry matching the page table read request from the M-level page table structure stored in the module when receiving the page table read request, and if a page table entry matching the page table read request is found, returning the matching page table entry to the corresponding L1-level translation buffer; Each L1 translation buffer is further used to determine the physical memory address based on the offset of the physical address and the virtual address in the matching page table entry to complete the translation from the virtual address to the physical address.
2. The address translation system according to claim 1, characterized in that: If M is an integer greater than or equal to 2, the multi-level page table query module is also used to determine whether the matching page table entry can be used directly before returning the matching page table entry to the corresponding L1-level translation buffer. If the matching page table entry cannot be used directly, continue to search for a page table entry that matches the page table read request in the M-level page table structure until a page table entry that can be used directly is found.
3. The address conversion system according to claim 1, characterized in that: If there is no page table entry matching the page table read request in any target-level page table of the M-level page table structure, the multi-level page table query module is also used to read the target-level page table entry from the external memory based on the starting address of the target-level page table entry and the address offset of the target-level page table entry, and update the target-level page table entry in the multi-level page table query module based on the read target page table entry.
4. The address conversion system according to claim 1, characterized in that: The multi-level page table query module includes: M-level translation buffers, each level of translation buffer is used to cache a specified level of page table in the M-level page table structure; when each level of translation buffer receives the page table read request, it searches from the page table stored in itself whether there is a page table entry that matches the page table read request, and if a page table entry that matches the page table read request is found, it is determined whether the page table entry can be used directly, and if the page table entry can be used directly, the matching page table entry is returned to the corresponding L1 level translation buffer.
5. The address translation system according to claim 1, characterized in that: Each of the L1 level translation buffers is specifically used to read the virtual address and process number in the virtual address translation request, and use the specified address range in the virtual address as the address identification number to search from the page table stored in itself whether there is a page table entry that matches the address identification number and the corresponding process number.
6. The address conversion system according to any one of claims 1 to 5, characterized in that: The address translation system further includes: an L2 translation buffer, the multi-level page table query module is connected to each L1 translation buffer through the L2 translation buffer, the L2 translation buffer stores the last level page table in the M level page table structure, and the number of page table entries stored is greater than the number of page table entries stored in each L1 translation buffer; The L2-level translation buffer is used to send the page table read request to the multi-level page table query module when there is no page table entry matching the page table read request in the page table stored in the L2-level translation buffer, and to send the page table entry matching the page table read request returned by the multi-level page table query module to the corresponding L1-level translation buffer.
7. The address conversion system according to claim 6, characterized in that: The L2 level translation buffer is further used for directly sending the matching page table entry to the corresponding L1 level translation buffer when there is a page table entry matching the page table read request in the page table stored in the L2 level translation buffer.
8. A processor, characterized in that: It comprises the address conversion system as described in any one of claims 1 to 7.
9. An address conversion method, characterized in that: include: Searching an L1 translation buffer for a page table entry that matches the virtual address translation request, wherein the L1 translation buffer stores a last-level page table in an M-level page table structure, where M is an integer greater than or equal to 1; When there is no page table entry matching the virtual address translation request in the L1 level translation buffer, issuing a page table read request, wherein the page table read request includes the virtual address in the virtual address translation request; Searching from a multi-level page table query module whether there is a page table entry matching the page table read request, wherein the multi-level page table query module stores an M-level page table structure; If a page table entry matching the page table read request is found, the physical memory address is determined based on the physical address in the matching page table entry and the offset of the virtual address to complete the conversion from the virtual address to the physical address.
10. The method according to claim 9, characterized in that Before searching the multi-level page table query module to see whether there is a page table entry matching the page table read request, the method further includes: It is determined that no page table entry matching the page table read request is found in an L2 translation buffer, wherein the L2 translation buffer stores a last level page table in an M level page table structure, and the number of stored page table entries is greater than the number of page table entries stored in each L1 translation buffer.
11. The method according to claim 9, characterized in that If there is no page table entry matching the page table read request in any target level page table in the multi-level page table query module, the method further includes: Based on the starting address of the target-level page table entry and the address offset of the target-level page table entry, the target-level page table entry is read from the external memory, and the target-level page table entry in the multi-level page table query module is updated based on the read target-level page table entry.
12. The method according to claim 9, characterized in that Check the L1 translation cache to see if there is a page table entry that matches the virtual address translation request, including: The virtual address and process number in the virtual address translation request are read, and a specified address range in the virtual address is used as an address identification number, and a page table entry matching the address identification number and the corresponding process number is searched from the L1 translation buffer.
13. The method according to claim 9, characterized in that If M is greater than or equal to 2, searching from a multi-level page table query module whether there is a page table entry matching the page table read request, including: Searching in turn from each level of the page table stored in the multi-level page table query module whether there is a page table entry matching the page table read request; If there is a page table entry matching the page table read request, determining whether the page table entry can be used directly; If the page table entry can be used directly, the matching page table entry is returned to the corresponding L1 translation buffer; If the page table entry cannot be used directly, a page table matching the page table read request is searched in the next level page table of the page table where the page table entry is located until a page table entry matching the page table read request that can be used directly is found.
14. An electronic device, characterized in that: include: A memory and a processor, wherein the processor is connected to the memory; The memory is used to store programs; The processor is used to call the program stored in the memory to execute the method according to any one of claims 9 to 13.
