Memory page paging method, device, CPU chip and computer
By introducing variable search series and addressing width into the page table structure, dynamically adjusting the page table structure using identification bits and index registers, the problem of fixed paging size in the existing technology is solved, and flexible memory page paging and Improve memory usage efficiency.
Patent Information
- Application Number
- CN202010534352.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-06-12
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2040-06-12
Smart Images

Figure CN111881062B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a memory page paging method, a device, a CPU chip and a computer. Background Art
[0002] A page table is a special data structure that is usually used in an operating system to store the correspondence between logical addresses and physical addresses. A page is the minimum granularity for defining a continuous address space when dividing a page table. For example, assuming a computer system with a 32-bit logical address space, if the system's page size is 4KB, then the page table can have up to 1 million entries (2^32 / 2^12). Assuming that each entry has 4 bytes, each process requires 4MB of physical address space to store the page table itself, and the page table itself also needs to use a continuous address space to store it. Obviously, if you don't want to allocate this page table continuously in memory, a simple solution is to divide the page table into smaller blocks, that is, the structure of a hierarchical page table. Summary of the invention
[0003] Problems to be solved by the invention
[0004] The object of the present invention is to provide a memory page paging method, device, CPU chip and computer, which can query memories of different sizes.
[0005] Means for solving problems
[0006] In view of the above problems existing in the prior art, a technical solution of the present invention provides a paging method for memory pages, characterized in that the method comprises the following steps:
[0007] Searching according to the base address of the current level-one page table directory table in the memory page table structure and the addressing address corresponding to the current level-one page table directory table in the linear address to obtain the current level-one page table directory entry, and obtaining type information for describing the type of the next level table from the current level-one page table directory entry, wherein the type includes a page table directory table and a page table;
[0008] Repeating the steps until the type information indicates that the next level table is a page table;
[0009] Searching according to the base address of the page table and the addressing address corresponding to the page table in the linear address to obtain a page table entry in the page table, and obtaining a page base address from the page table entry;
[0010] A page address is determined according to the page base address and the physical page offset.
[0011] A technical solution of the present invention provides a paging device for a memory page, characterized in that the device comprises:
[0012] A traversal module searches according to a base address of a current level page table directory table in a memory page table structure and an addressing address corresponding to the current level page table directory table in a linear address to obtain a current level page table directory entry, and obtains type information for describing a type of a next level table from the current level page table directory entry, wherein the type includes a page table directory table and a page table, and repeats the steps until the type information indicates that the next level table is a page table, searches according to a base address of the page table and an addressing address corresponding to the page table in a linear address to obtain a page table entry in the page table, and obtains a page base address from the page table entry; and
[0013] The address determination module determines the page address according to the page base address and the physical page offset.
[0014] A technical solution of the present invention provides a CPU chip, characterized in that it includes a plurality of crystal grains DIE, each crystal grain DIE includes at least one processor core;
[0015] The processor core executes the above-mentioned memory page paging method.
[0016] A technical solution of the present invention provides a computer, characterized in that it includes the above-mentioned CPU.
[0017] Effects of the Invention
[0018] The memory page paging method according to the present invention can perform paging on memory pages of different sizes. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1 The structure of a system according to one embodiment of the present invention is shown.
[0020] Figure 2 The diagram shows a hierarchical page table structure for implementing 2MB pages in a memory management unit in the prior art.
[0021] Figure 3 The following shows a hierarchical page table structure for implementing 1GB pages using 2-level addressing in the prior art.
[0022] Figure 4 The following shows the hierarchical page table structure of a 4MB page implemented by a memory management unit in the prior art.
[0023] Figure 5 A schematic flow chart of the memory page paging method of the present invention is shown.
[0024] Figure 6 A page table structure that supports multiple page sizes is shown.
[0025] Figure 7 A block diagram of a computer device of the present invention is shown. DETAILED DESCRIPTION
[0026] The exemplary embodiments of the present invention will be specifically described below in conjunction with the accompanying drawings. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present invention, and are not intended to limit the scope of the present invention in any way. Exemplary embodiments are provided in the present invention to illustrate various aspects of the present invention and should not be construed as limiting the scope of the present invention. When describing exemplary embodiments with reference to block diagrams or flow charts, each box may represent a method step or a device element for performing a method step. Depending on the implementation, the corresponding device element may be configured as hardware, software, firmware, or a combination thereof.
[0027] [System Structure]
[0028] First, the structure of a system according to an embodiment of the present invention is described. Figure 1 As shown, the system structure 100 may include terminal devices 101, 102, 103, 104, a network 105 and a server 106. The network 105 is used to provide a medium for communication links between the terminal devices 101, 102, 103, 104 and the server 106.
[0029] In this embodiment, the memory page paging method is executed on an electronic device (eg Figure 1 The terminal devices 101, 102, 103 or 104 shown in the figure can transmit various information through the network 105. The network 105 can include various connection types, such as wired, wireless communication links or optical fiber cables, etc. It should be noted that the above-mentioned wireless connection methods may include but are not limited to 3G / 4G / 5G connections, Wi-Fi connections, Bluetooth connections, WiMAX connections, Zigbee connections, UWB connections, local area networks ("LAN"), wide area networks ("WAN"), Internet (e.g., the Internet) and peer-to-peer networks (e.g., ad hoc peer-to-peer networks) and other network connection methods currently known or developed in the future. The network 105 can communicate using any currently known or future developed network protocol such as HTTP (HyperTextTransfer Protocol), and can be interconnected with digital data communications (e.g., communication networks) of any form or medium.
[0030] The user can use the terminal devices 101, 102, 103, 104 to interact with the server 106 through the network 105 to receive or send messages, etc. Various client applications can be installed on the terminal devices 101, 102, 103 or 104, such as video live broadcast and playback applications, web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.
[0031] Terminal devices 101, 102, 103 or 104 can be various electronic devices with touch screens and / or support for web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Compressed Standard Audio Layer 3), MP4 (Moving Picture Experts Compressed Standard Audio Layer 4) players, head-mounted display devices, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PMPs (portable multimedia players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., as well as mobile terminals such as digital TVs, desktop computers, etc.
[0032] The server 106 may be a server that provides various services, such as a background server that provides support for pages displayed on the terminal device 101 , 102 , 103 or 104 .
[0033] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0034] Here, the terminal device can implement the embodiment method of the present invention by running applications in the Android system independently or in cooperation with other electronic terminal devices, and can also run applications in other operating systems such as iOS system, Windows system, Hongmeng system, etc. to implement the embodiment method of the present invention.
[0035] [Memory page paging method]
[0036] In the prior art, when the operating system of an electronic device executes a process, it accesses the memory. The process finds the highest level page table directory table that needs to access the memory through the base address (i.e., physical address) of the highest level page table directory table (PDT) of the accessed memory pre-stored in a register (e.g., CR3 register). In the hierarchical page table structure, the page table directory table includes multiple page table directory entries (PDEs), each of which stores the base address of the next level page table. The last level is the page table, i.e., the page table uses page table entries (PTEs) to store the base address of the page. Figure 2 The following figure shows a hierarchical page table structure for implementing 2MB pages in the memory management unit (MMU). Each level of the table has 512 entries and uses 9 bits of address for addressing. In order to support different paging sizes, the number of page addressing levels can be changed, for example, Figure 3As shown, in the prior art, for example, 1GB paging can be achieved by using 2-level addressing. The table structure using 512 entries determines that this page table structure can only achieve 4kb, 2MB, 1GB, 512GB, and 1TB paging.
[0037] If you need to implement paging of other sizes, such as 4MB paging, Figure 4 As shown, in the prior art, some changes need to be made to the above page table structure in the IO memory management unit (IOMMU). For example, a flag bit 7 is added to the PTE table entry to indicate that the PTE points to a 4MB page. In order to ensure that the PTE still uses a 9-bit address for addressing, the 4MB page base address occupies two PTEs. Although this page table structure expands the supported paging size, it does not reduce the page table entries. In addition, this mechanism for implementing 4MB paging can be extended to implement 8MB, 16MB, and other paging, and only needs to change the PTE flag bit, but the flag bit cannot be increased indefinitely. The supported page size is still limited by the defined flag bit, and it is necessary to occupy multiple 2MB page table entries, which is not conducive to reducing the page table storage space. Therefore, the existing traditional page table structure has the following shortcomings: the supported paging size is relatively fixed, and a page table structure can only use one paging size. Even if the supported paging becomes larger, the page table entries are not reduced, which is not conducive to reducing the page table storage space.
[0038] As mentioned above, a page is the minimum granularity for defining a continuous address space when dividing the page table. If the paging size is defined too small and the execution of the process requires the use of memory in larger units, or if the paging size is defined too large and the execution of the process only requires the use of memory in smaller units, it will cause inefficient memory usage. Therefore, the memory usage status, such as whether there is a large continuous space in the memory, and the program access method, such as how large the unit is used by the program, will cause the same page table structure (the same size of paging) to show different efficiencies in the operating system. On the other hand, it can also be said that the memory usage status and program access method determine the most appropriate size of paging.
[0039] In view of the above point, the present invention provides a paging method for memory pages. Figure 5 1 is a schematic flow chart showing the paging method of the memory page of the present invention. Figure 5 As shown, the following steps are included.
[0040] Step 501, search according to the base address of the current first-level page table directory table in the memory page table structure and the addressing address corresponding to the current first-level page table directory table in the linear address to obtain the current first-level page table directory entry, and obtain type information for describing the type of the next level table from the current first-level page table directory entry, wherein the type includes a page table directory table and a page table.
[0041] Step 502, repeat the steps until the type information indicates that the next level table is a page table;
[0042] Step 503, searching according to the base address of the page table and the addressing address corresponding to the page table in the linear address to obtain a page table entry in the page table, and obtaining a page base address from the page table entry;
[0043] Step 504: determine the page address according to the page base address and the physical page offset.
[0044] Specifically, it is assumed that the memory page table structure includes an n-level table, n is a positive integer greater than 1, and the n-level table includes at least one level of page table directory table, and the page table is located at the m-th level, m<n, and m is a positive integer greater than 1. For the n-th level page table directory table, the base address is obtained from the above-mentioned CR3 register; for the n-1-th to m+1-th level page table directory tables, the base address is obtained from the previous level page table directory entry; for the m-th level page table, the base address is obtained from the m+1-th level page table directory entry. Starting from the n-th level table, the page table directory table is read from the base address, and the page table directory entry is searched in the page table directory table. From the found page table directory entry, information describing the type of the next level table and the base address of the next level table are obtained. The page table directory entry uses an identification bit to describe the type of the next level table. For example, if a flag bit in the page table directory entry is 1, it means that the next level table is a page table directory table, and if the flag bit is 0, it means that the next level table is a page table. Next, when the flag is 1, the page table directory table is read from the base address of the next-level table, and the page table directory entry is searched in the page table directory table, and the information describing the type of the next-level table and the base address of the next-level table are obtained from the found page table directory entry... Repeat this step until the flag is 0. At this time, the current first-level table is the page table directory table of the m+1th level, and the page table directory entry is searched in the page table directory table of the m+1th level, and the base address of the next-level page table is obtained from the found page table directory entry. Next, the page table is read from the page table base address, and the page table entry is searched in the page table, and the page base address is obtained from the found page table entry.
[0045] In addition, the physical page offset can be calculated according to the formula: physical page offset=storage address width-(nm)*addressing width of page table directory entry-addressing width of page table entry.
[0046] In addition, for the page table directory tables at the nth level to the m+1th level, the addressing width is a fixed value.
[0047] According to the above-mentioned memory page paging method, because the value of the flag pointing to the next level table in the page table directory entry of the page table directory table is variable, the level of the page table structure is not fixed, and the physical page offset is also not fixed. Therefore, by changing the value of the flag, the level of the page table structure can be changed, and then the physical page offset can be changed, thereby changing the size of the page.
[0048] In addition, the addressing width of the page table in the memory page table structure is a non-fixed value. An index register can be set for each page table to identify the addressing width of the page table entry in the page table. When searching for a page table entry in the m-th level page table, the addressing width indicated by the index value in the index register is used. For example, a page table directory table at the m+1th level points to multiple m-th level page tables, and the addressing widths of multiple m-th level page tables can be the same or different. Therefore, by changing the addressing width of the page table, the physical page offset can be changed, and then the size of the paging can be changed.
[0049] Therefore, in the present invention, the size of the paging can be changed not only by changing the number of levels of the page table structure, but also by changing the page table addressing width. When paging memory pages, pages of different sizes can be found according to the number of levels of the page table structure and the page table addressing width.
[0050] Corresponding to the above method, refer to Figure 6 Describe the page table structure when using this method for paging.
[0051] In the page table structure, each PDE entry has an identification bit to indicate whether the next level points to a PDE or a PTE. 1 can be used to indicate that the next level is a PDE, and 0 can be used to indicate that the next level is a PTE. Since the identification bits carried by the PDE entry are different, the number of page table search levels is not fixed. In addition, the identification bit is not limited to 1 and 0, and the opposite setting or other identification methods can also be used, as long as it can indicate the direction of the next level.
[0052] All PDEs use the same addressing width, for example, 9 bits are used to address PDEs, so each group of PDEs has 512 entries.
[0053] In the present invention, PTE can use different addressing widths, and the memory manager sets an index register for each group of PTEs pointed to by PDE to identify the addressing width used to address the PTE. Figure 6 , the addressing widths used by the three PTEs are respectively set to index = 8 bits, index = 9 bits, and index = 8 bits. Since the addressing widths indicated by index are different, the number of entries in each group of PTEs is different.
[0054] PTE points to the base address of the page, and the page offset addressing width is obtained by subtracting the sum of all PDE and PTE addressing widths from the storage address width.
[0055] According to the above-mentioned hierarchical page table structure, using the memory page paging method of the present invention, it is possible to satisfy the search for memory pages of different sizes by changing the page table search level and the addressing width used by the PTE.
[0056] The memory page paging method of the present invention is further described in detail below in conjunction with embodiments.
[0057] Example 1
[0058] In Example 1, based on Figure 6 Describes how to implement a 4MB paging query.
[0059] Using a 3-level page table search structure, two levels of PDE plus one level of PTE, the base address of the 4th level page table directory table is obtained from the register. The 4th level is PDE, using 9-bit addressing, address bit [47:39] is used as the index to search for PDE, and a PDE table entry is obtained. From this table entry, the base address of the 3rd level table and the attributes of the 3rd level table are read. Here 1 means that the 3rd level table is the page table directory table.
[0060] Read the third-level table from the base address of the third-level table obtained above. Since the third-level table is a page table directory, 9-bit addressing is still used. Use address bit [38:30] to find the third-level PDE and get a PDE table entry. From this table entry, read the base address of the second-level table and the attributes of the second-level table. Here, 0 means that the second-level table is a page table.
[0061] Read the second-level PTE at the base address of the second-level table obtained above, and read the index from the index register, which indicates how many bits the PTE uses for addressing. Here, index = 8 bits, indicating that the PTE uses 8 bits for addressing. So use the address bit [29:22] to address the PTE and get the base address of the page.
[0062] In the first three levels (level 4, level 3, level 2) of page table lookup, a total of 26 bits of address are used, and there are 22 bits of address left in the 48-bit address space as page offset, so the page size is 2^22=4MB. The page address is obtained by adding the offset of address bit [21:0] to the page base address obtained above.
[0063] Example 2
[0064] In Example 2, based on Figure 6 Describes how to implement a 2MB paging query.
[0065] Using a 3-level page table search structure, two levels of PDE plus one level of PTE, the base address of the 4th level page table directory table is obtained from the register. The 4th level is PDE, using 9-bit addressing, address bit [47:39] is used as the index to search for PDE, and a PDE table entry is obtained. From this table entry, the base address of the 3rd level table and the attributes of the 3rd level table are read. Here, 1 indicates that the 3rd level table is the page table directory table.
[0066] Read the third-level table from the base address of the third-level table obtained above. Since the third level is PDE, 9-bit addressing is still used. Use address bit [38:30] to find the third-level PDE and get a PDE table entry. From this table entry, read the base address of the second-level table and the attributes of the second-level table. Here, 0 means that the second-level table is a page table.
[0067] Read the second-level PTE from the base address of the second-level table obtained above, and read the index from the index register. The index indicates how many bits the PTE uses for addressing. Here, index = 9, indicating that the PTE uses 9 bits for addressing. Therefore, address bits [29:21] are used to address the PTE and obtain the base address of the page.
[0068] In the previous 3-level page table search, a total of 27 bits of address are used, and there are 21 bits of address left in the 48-bit address space as the page offset, so the page size is 2^21=2MB. The page address is obtained by adding the offset of the address bit [20:0] to the page base address obtained above.
[0069] Example 3
[0070] In Example 3, based on Figure 6 This section describes how to implement 8KB paging queries.
[0071] Use a 4-level page table search structure, three-level PDE plus one-level PTE, and get the base address of the 4th-level page table directory from the register.
[0072] The fourth level is PDE, which uses 9-bit addressing, and the address bit [47:39] is used as the index to find PDE, and a PDE table entry is obtained. From this table entry, the base address of the third-level table and the attributes of the third-level table are read. Here, 1 indicates that the third-level table is a page table directory.
[0073] Read the third-level table from the base address of the third-level table obtained above. Since the third level is PDE, 9-bit addressing is still used. Use address bit [38:30] to find the third-level PDE and get a PDE table entry. From this table entry, read the base address of the second-level table and the attributes of the second-level table. Here, 1 means that the second-level table is a page table directory.
[0074] The second-level PDE is read from the base address of the second-level table obtained above. PDE uses 9-bit addressing, so the address bit [29:21] is used to address PDE and obtain a PDE table entry. From this table entry, the base address of the first-level table and the attributes of the first-level table are read. Here, 0 indicates that the first-level table is a page table.
[0075] Read the first-level PTE from the base address of the first-level table obtained above, and read the index from the index register, which indicates how many bits the PTE uses for addressing. Here, index = 8, indicating that the PTE uses 8 bits for addressing. So use the address bit [20:13] to address the PTE and get the base address of the page.
[0076] In the previous 4-level page table search, a total of 35 bits of address are used, and 13 bits of address are left in the 48-bit address space as the page offset, so the page size is 2^13=8KB. The page address is obtained by adding the offset of the address bit [12:0] to the page base address obtained above.
[0077] The above-mentioned embodiments 1 to 3 illustrate how to implement 4MB, 2MB, and 8KB paging queries in the present invention. Moreover, the implementation methods of the above three paging queries can be extended to the implementation of other paging sizes. It is only necessary to modify the attributes of the PDE pointing to the next level table and the number of address bits required to find the PTE to flexibly implement the query of memory pages of different sizes.
[0078] In addition, because the number of entries of a PTE can be redefined, it is no longer necessary to use fixed entries. For example, a PTE with attribute index=8 has only 256 entries, which reduces the space required to store PTEs.
[0079] In addition, in the above description, the case where the storage address width is 48 bits and the addressing width used by the page table directory table is 9 bits is used as an example for description, but it is not limited to this. The storage address width and the addressing width used by the page table directory table may be different from the above values according to the operating system, user settings, device hardware support, etc. For example, the storage address width determined by the hardware may be 32 bits, 48 bits, 64 bits, etc. The above description of the storage address width of 48 bits is adopted for the convenience of understanding the embodiment and should not be interpreted in a limiting sense. Even for the same memory, when it is used in different environments, the storage address width actually used may be different.
[0080] In addition, in the above description, the case where the operating system of the electronic terminal manages the hierarchical page table structure through the memory management unit is taken as an example, but the present invention is not limited to this. Regardless of the presence or absence of an operating system, the type of operating system, and the type of processor, as long as the page table structure is used to implement the address division of the memory, the paging method of the memory page of the present invention can be applied.
[0081] In addition, in the above description, the case where each PDE table entry carries an identification bit to determine whether the next level points to a PDE or a PTE is used as an example for explanation, but it is not limited to this, and the identification bit method may not be used. For example, as a method of distinguishing PDE and PTE, they can be distinguished by address, and the page table directory table and the page table can have different address segments respectively. In addition, they can also be distinguished by the number of entries. PDE and PTE can use different numbers of entries. For example, PDE is fixed to 512 entries, while PTE stipulates that the number of entries used cannot be 512. The 512 here is only an example and is not restrictive. In addition, they can also be distinguished by the format of the entries. The entry formats stored in PDE and PTE are distinguished by different header flags, such as using 0 and 1 to distinguish, or the sizes used for each entry are different.
[0082] The above describes the memory page paging method of the present invention based on the embodiment. In addition, the present invention also provides a memory page paging device. The device is described below.
[0083] The paging device of the memory page of the present invention comprises:
[0084] A traversal module searches according to a base address of a current level page table directory table in a memory page table structure and an addressing address corresponding to the current level page table directory table in a linear address to obtain a current level page table directory entry, and obtains type information for describing a type of a next level table from the current level page table directory entry, wherein the type includes a page table directory table and a page table, and repeats the steps until the type information indicates that the next level table is a page table, searches according to a base address of the page table and an addressing address corresponding to the page table in a linear address to obtain a page table entry in the page table, and obtains a page base address from the page table entry; and
[0085] The address determination module determines the page address according to the page base address and the physical page offset.
[0086] The above-mentioned traversal module and address determination module may be hardware, software, or a combination of software and hardware. For their specific actions and functions, reference may be made to the various steps of the above-mentioned memory page paging method, and detailed description is omitted here.
[0087] In addition, the present invention also provides a computer device (electronic device), which is described below.
[0088] Reference below Figure 7 , which shows an electronic device (eg Figure 1 The terminal device in the embodiment of the present invention may be any of the terminal devices in the above system. Figure 6 The electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0089] like Figure 7 As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701 for controlling the overall operation of the electronic device. The processing device may include one or more processors to execute instructions to complete all or part of the steps of the above method. In addition, the processing device 701 may also include one or more modules for processing and interacting with other devices.
[0090] The storage device 702 is used to store various types of data. The storage device 702 may include various types of computer-readable storage media or combinations thereof, such as electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or components, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, device or component.
[0091] The sensor device 703 is used to sense the specified measured information and convert it into a usable output signal according to a certain rule, and may include one or more sensors. For example, it may include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor or a temperature sensor, etc., for detecting changes in the opening / closing state, relative positioning, acceleration / deceleration, temperature, humidity and light of the electronic device.
[0092] The processing device 701, the storage device 702, and the sensor device 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0093] The multimedia device 706 may include input devices such as a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, etc. for receiving input signals from the user. The various input devices may cooperate with the various sensors of the above-mentioned sensor device 703 to complete, for example, gesture operation input, image recognition input, distance detection input, etc. The multimedia device 706 may also include output devices such as a liquid crystal display (LCD), a speaker, a vibrator, etc.
[0094] The power supply device 707 is used to provide power to various devices in the electronic device, and may include a power management system, one or more power supplies, and components for distributing power to other devices.
[0095] The communication device 708 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data.
[0096] The above-mentioned devices can also be connected to the I / O interface 705 to implement the application of the electronic device 700.
[0097] Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0098] In particular, according to an embodiment of the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present invention includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device. When the computer program is executed by a processing device, the above-mentioned functions defined in the method of the embodiment of the present invention are executed.
[0099] In the context of the present invention, a machine-readable medium may be a tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.
[0100] It should be noted that the above-mentioned computer-readable medium of the present invention can be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. In the present invention, the computer-readable signal medium may include a data signal propagated in the baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal can take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate or transmit a program for use by or in combination with an instruction execution system, device or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0101] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0102] Computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0103] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present invention. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession 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 square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0104] The units involved in the embodiments of the present invention may be implemented by software or hardware, wherein the name of a unit does not limit the unit itself in some cases.
[0105] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0106] In addition, the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned memory page paging method is implemented.
[0107] According to one or more embodiments of the present invention, a memory page paging method is provided, wherein the method comprises the following steps:
[0108] Searching according to the base address of the current level-one page table directory table in the memory page table structure and the addressing address corresponding to the current level-one page table directory table in the linear address to obtain the current level-one page table directory entry, and obtaining type information for describing the type of the next level table from the current level-one page table directory entry, wherein the type includes a page table directory table and a page table;
[0109] Repeating the steps until the type information indicates that the next level table is a page table;
[0110] Searching according to the base address of the page table and the addressing address corresponding to the page table in the linear address to obtain a page table entry in the page table, and obtaining a page base address from the page table entry;
[0111] A page address is determined according to the page base address and the physical page offset.
[0112] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0113] The memory page table structure includes an n-level table, where n is a positive integer greater than 1.
[0114] The n-level table includes at least one level of page table directory table,
[0115] The page table is located at the mth level, where m<n and m is a positive integer greater than 1.
[0116] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0117] For the nth level page table directory, get the base address from the register;
[0118] For the page table directory table of level n-1 to level m+1, the base address is obtained from the page table directory entry of the previous level;
[0119] For the mth level page table, the base address is obtained from the m+1th level page table directory entry.
[0120] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0121] The page table directory entry uses an identification bit to describe type information of the type of the next level table.
[0122] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0123] The addressing width of each level of page table directory is a fixed value.
[0124] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0125] Physical page offset = storage address width - (nm) * addressing width of page table directory entry - addressing width of page table entry.
[0126] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0127] The addressing width of the page table in the memory page table structure is a non-fixed value.
[0128] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0129] An index register is set for each page table to identify the addressing width of the page table entries in the page table.
[0130] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0131] The storage address width is 48 bits. When paging 4MB pages,
[0132] Read the fourth-level page table directory table according to the base address of the fourth-level page table directory table obtained from the register, and search with the 9-bit addressing address corresponding to the fourth-level page table directory table in the linear address to obtain the fourth-level page table directory entry;
[0133] Obtain the base address of the third-level page table directory table and the identification bit information describing the type of the third-level table from the fourth-level page table directory entry, read the third-level page table directory table from the base address of the third-level page table directory table, and search with the 9-bit addressing address corresponding to the third-level page table directory table in the linear address to obtain the third-level page table directory entry;
[0134] Obtain the base address of the second-level page table and the identification bit information describing the type of the second-level table from the third-level page table directory entry, read the second-level page table from the base address of the second-level page table, and search with the 8-bit addressing address corresponding to the second-level page table in the linear address to obtain the second-level page table entry;
[0135] Get the page base address from the second-level page table entry;
[0136] Physical page offset = 48 bits - 2*9-8 = 22 bits of address;
[0137] 4MB page address = page base address + physical page offset.
[0138] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0139] The storage address width is 48 bits. When paging 2MB pages,
[0140] Read the fourth-level page table directory table according to the base address of the fourth-level page table directory table obtained from the register, and search with the 9-bit addressing address corresponding to the fourth-level page table directory table in the linear address to obtain the fourth-level page table directory entry;
[0141] Obtain the base address of the third-level page table directory table and the identification bit information describing the type of the third-level table from the fourth-level page table directory entry, read the third-level page table directory table from the base address of the third-level page table directory table, and search with the 9-bit addressing address corresponding to the third-level page table directory table in the linear address to obtain the third-level page table directory entry;
[0142] Obtain the base address of the second-level page table and the identification bit information describing the type of the second-level table from the third-level page table directory entry, read the second-level page table from the base address of the second-level page table, and search with the 9-bit addressing address corresponding to the second-level page table in the linear address to obtain the second-level page table entry;
[0143] Get the page base address from the second-level page table entry;
[0144] Physical page offset = 48 bits - 2*9-9 = 21 bits of address;
[0145] 2MB page address = page base address + physical page offset.
[0146] According to one or more embodiments of the present invention, a memory page paging method is provided, characterized in that:
[0147] The storage address width is 48 bits. When paging 8KB pages,
[0148] Read the fourth-level page table directory table according to the base address of the fourth-level page table directory table obtained from the register, and search with the 9-bit addressing address corresponding to the fourth-level page table directory table in the linear address to obtain the fourth-level page table directory entry;
[0149] Obtain the base address of the third-level page table directory table and the identification bit information describing the type of the third-level table from the fourth-level page table directory entry, read the third-level page table directory table from the base address of the third-level page table directory table, and search with the 9-bit addressing address corresponding to the third-level page table directory table in the linear address to obtain the third-level page table directory entry;
[0150] Obtain the base address of the second-level page table directory table and the identification bit information describing the type of the second-level table from the third-level page table directory entry, read the second-level page table directory table from the base address of the second-level page table directory table, and search with the 9-bit addressing address corresponding to the second-level page table directory table in the linear address to obtain the second-level page table directory entry;
[0151] Obtain the base address of the first-level page table and the identification bit information describing the type of the first-level table from the second-level page table directory entry, read the first-level page table from the base address of the first-level page table, and search with the 8-bit addressing address corresponding to the first-level page table in the linear address to obtain the first-level page table entry;
[0152] Get the page base address from the first-level page table entry;
[0153] Physical page offset = 48 bits - 3*9-8 = 13 bits of address;
[0154] 8KB page address = page base address + physical page offset.
[0155] According to one or more embodiments of the present invention, a paging device for a memory page is provided, wherein the device comprises:
[0156] A traversal module searches according to a base address of a current level page table directory table in a memory page table structure and an addressing address corresponding to the current level page table directory table in a linear address to obtain a current level page table directory entry, and obtains type information for describing a type of a next level table from the current level page table directory entry, wherein the type includes a page table directory table and a page table, and repeats the steps until the type information indicates that the next level table is a page table, searches according to a base address of the page table and an addressing address corresponding to the page table in a linear address to obtain a page table entry in the page table, and obtains a page base address from the page table entry; and
[0157] The address determination module determines the page address according to the page base address and the physical page offset.
[0158] According to one or more embodiments of the present invention, a paging device for a memory page is provided, characterized in that:
[0159] The memory page table structure includes an n-level table, where n is a positive integer greater than 1.
[0160] The n-level table includes at least one level of page table directory table,
[0161] The page table is located at the mth level, where m<n and m is a positive integer greater than 1.
[0162] According to one or more embodiments of the present invention, a paging device for a memory page is provided, characterized in that:
[0163] For the nth level page table directory, get the base address from the register;
[0164] For the page table directory table of level n-1 to level m+1, the base address is obtained from the page table directory entry of the previous level;
[0165] For the mth level page table, the base address is obtained from the m+1th level page table directory entry.
[0166] According to one or more embodiments of the present invention, a paging device for a memory page is provided, characterized in that:
[0167] The page table directory entry uses an identification bit to describe type information of the type of the next level table.
[0168] According to one or more embodiments of the present invention, a paging device for a memory page is provided, characterized in that:
[0169] The addressing width of each level of page table directory is a fixed value.
[0170] According to one or more embodiments of the present invention, a paging device for a memory page is provided, characterized in that:
[0171] The addressing width of the page table in the memory page table structure is a non-fixed value.
[0172] According to one or more embodiments of the present invention, a paging device for a memory page is provided, characterized in that:
[0173] An index register is set for each page table to identify the addressing width of the page table entries in the page table.
[0174] According to one or more embodiments of the present invention, there is provided a CPU chip, characterized in that it comprises a plurality of die DIEs, each of which comprises at least one processor core;
[0175] The processor core executes the above-mentioned memory page paging method.
[0176] According to one or more embodiments of the present invention, there is provided a computer, characterized in that it includes the above-mentioned CPU.
[0177] The above description is only a preferred embodiment of the present invention and an explanation of the technical principles used. Those skilled in the art should understand that the disclosure scope involved in the present invention is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in the present invention (but not limited to) by each other.
[0178] In addition, although each operation is described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the present invention. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0179] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A paging method for a memory page, characterized in that: The steps of the method include: The first step is to search according to the base address of the current level-one page table directory table in the memory page table structure and the addressing address corresponding to the current level-one page table directory table in the linear address to obtain the current level-one page table directory entry, and obtain type information for describing the type of the next level table from the current level-one page table directory entry, wherein the type includes a page table directory table and a page table; The second step is to repeat the first step until the type information indicates that the next level table is a page table; The third step is to search according to the base address of the page table and the addressing address corresponding to the page table in the linear address to obtain a page table entry in the page table, and obtain the page base address from the page table entry; and The fourth step is to determine the page address according to the page base address and the physical page offset. The page address=the page base address+the physical page offset.
2. The method according to claim 1, characterized in that: The memory page table structure includes an n-level table, where n is a positive integer greater than 1. The n-level table includes at least one level of page table directory table, The page table is located at the mth level, where m<n and m is a positive integer greater than 1.
3. The method according to claim 2, characterized in that For the nth level page table directory, get the base address from the register; For the page table directory table of level n-1 to level m+1, the base address is obtained from the page table directory entry of the previous level; For the mth level page table, the base address is obtained from the m+1th level page table directory entry.
4. The method according to claim 3, characterized in that The page table directory entry uses an identification bit to describe type information of the type of the next level table.
5. The method according to claim 4, characterized in that The addressing width of each level of page table directory is a fixed value.
6. The method according to claim 5, characterized in that Physical page offset = storage address width - (nm) * addressing width of page table directory entry - addressing width of page table entry.
7. The method according to claim 6, characterized in that The addressing width of the page table in the memory page table structure is a non-fixed value.
8. The method according to claim 7, characterized in that An index register is set for each page table to identify the addressing width of the page table entries in the page table.
9. The method according to claim 8, characterized in that The storage address width is 48 bits. When paging 4MB pages, Read the fourth-level page table directory table according to the base address of the fourth-level page table directory table obtained from the register, and search with the 9-bit addressing address corresponding to the fourth-level page table directory table in the linear address to obtain the fourth-level page table directory entry; Obtain the base address of the third-level page table directory table and the identification bit information describing the type of the third-level table from the fourth-level page table directory entry, read the third-level page table directory table from the base address of the third-level page table directory table, and search with the 9-bit addressing address corresponding to the third-level page table directory table in the linear address to obtain the third-level page table directory entry; Obtain the base address of the second-level page table and the identification bit information describing the type of the second-level table from the third-level page table directory entry, read the second-level page table from the base address of the second-level page table, and search with the 8-bit addressing address corresponding to the second-level page table in the linear address to obtain the second-level page table entry; Get the page base address from the second-level page table entry; Physical page offset = 48 bits - 2*9-8 = 22 bits of address; 4MB page address = page base address + physical page offset.
10. The method according to claim 8, characterized in that The storage address width is 48 bits. When paging 2MB pages, Read the fourth-level page table directory table according to the base address of the fourth-level page table directory table obtained from the register, and search with the 9-bit addressing address corresponding to the fourth-level page table directory table in the linear address to obtain the fourth-level page table directory entry; Obtain the base address of the third-level page table directory table and the identification bit information describing the type of the third-level table from the fourth-level page table directory entry, read the third-level page table directory table from the base address of the third-level page table directory table, and search with the 9-bit addressing address corresponding to the third-level page table directory table in the linear address to obtain the third-level page table directory entry; Obtain the base address of the second-level page table and the identification bit information describing the type of the second-level table from the third-level page table directory entry, read the second-level page table from the base address of the second-level page table, and search with the 9-bit addressing address corresponding to the second-level page table in the linear address to obtain the second-level page table entry; Get the page base address from the second-level page table entry; Physical page offset = 48 bits - 2*9-9 = 21 bits of address; 2MB page address = page base address + physical page offset.
11. The method according to claim 8, characterized in that The storage address width is 48 bits. When paging 8KB pages, Read the fourth-level page table directory table according to the base address of the fourth-level page table directory table obtained from the register, and search with the 9-bit addressing address corresponding to the fourth-level page table directory table in the linear address to obtain the fourth-level page table directory entry; Obtain the base address of the third-level page table directory table and the identification bit information describing the type of the third-level table from the fourth-level page table directory entry, read the third-level page table directory table from the base address of the third-level page table directory table, and search with the 9-bit addressing address corresponding to the third-level page table directory table in the linear address to obtain the third-level page table directory entry; Obtain the base address of the second-level page table directory table and the identification bit information describing the type of the second-level table from the third-level page table directory entry, read the second-level page table directory table from the base address of the second-level page table directory table, and search with the 9-bit addressing address corresponding to the second-level page table directory table in the linear address to obtain the second-level page table directory entry; Obtain the base address of the first-level page table and the identification bit information describing the type of the first-level table from the second-level page table directory entry, read the first-level page table from the base address of the first-level page table, and search with the 8-bit addressing address corresponding to the first-level page table in the linear address to obtain the first-level page table entry; Get the page base address from the first-level page table entry; Physical page offset = 48 bits - 3*9-8 = 13 bits of address; 8KB page address = page base address + physical page offset.
12. A paging device for a memory page, characterized in that: The device includes: The traversal module performs a first step, searches according to the base address of the current level page table directory table in the memory page table structure and the addressing address corresponding to the current level page table directory table in the linear address to obtain the current level page table directory entry, obtains type information for describing the type of the next level table from the current level page table directory entry, wherein the type includes a page table directory table and a page table, performs a second step, repeats the first step until the type information indicates that the next level table is a page table, performs a third step, searches according to the base address of the page table and the addressing address corresponding to the page table in the linear address to obtain a page table entry in the page table, and obtains a page base address from the page table entry; and The address determination module performs the fourth step of determining the page address according to the page base address and the physical page offset. The page address=the page base address+the physical page offset.
13. The device according to claim 12, characterized in that The memory page table structure includes an n-level table, where n is a positive integer greater than 1. The n-level table includes at least one level of page table directory table, The page table is located at the mth level, where m<n and m is a positive integer greater than 1.
14. The device according to claim 13, characterized in that For the nth level page table directory, get the base address from the register; For the page table directory table of level n-1 to level m+1, the base address is obtained from the page table directory entry of the previous level; For the mth level page table, the base address is obtained from the m+1th level page table directory entry.
15. The device according to claim 14, characterized in that The page table directory entry uses an identification bit to describe type information of the type of the next level table.
16. The device according to claim 15, characterized in that The addressing width of each level of page table directory is a fixed value.
17. The device according to claim 16, characterized in that The addressing width of the page table in the memory page table structure is a non-fixed value.
18. The device according to claim 17, characterized in that An index register is set for each page table to identify the addressing width of the page table entries in the page table.
19. A CPU chip, characterized in that: comprising a plurality of die DIEs, each die DIE comprising at least one processor core; The processor core executes the memory page paging method according to any one of claims 1 to 11.
20. A computer, characterized in that: Comprising the CPU as claimed in claim 19.
