Memory address mapping method, memory management unit, electronic equipment and storage medium

By searching the address segment table and the address segment attribute table in parallel, the problem of low query efficiency of the radix tree structure page table is solved, and the mapping efficiency of the memory management unit is improved.

CN120705082APending Publication Date: 2025-09-26T-HEAD (SHANGHAI) SEMICON CO LTD +1
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410347911.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-25
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

In virtualization application scenarios, as memory capacity increases, the page table level of the radix tree structure increases, and the memory management unit spends a long time when querying the page table, resulting in low efficiency in mapping virtual addresses to physical addresses.

Method used

A parallel search method of the address segment table and the address segment attribute table is adopted to determine the physical address of the virtual address by searching the base address information in the address segment table and the offset information in the address segment attribute table.

Benefits of technology

The lookup depth of the address segment table and the address segment attribute table is reduced, and the efficiency of mapping virtual addresses to physical addresses is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120705082A_ABST
    Figure CN120705082A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a memory address mapping method, a memory management unit, electronic equipment and a storage medium. The memory address mapping method comprises the following steps: receiving a virtual address from a current process; determining an address field table and an address field attribute table according to the identification information of the current process; base address information is searched from an address field table according to a first virtual address field included in the virtual address, the base address information is used for indicating a base address of a target physical address space segment, and the target physical address space segment is a physical address space segment where a physical address mapped with the virtual address is located; searching offset information from an address field attribute table according to a second virtual address field included in the virtual address, wherein the offset information is used for indicating the offset of a physical address mapped with the virtual address in a target physical address space field; and determining a physical address mapped with the virtual address according to the base address information and the offset information. According to the scheme, the efficiency of mapping the virtual address into the physical address can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of computer technology, and in particular to a memory address mapping method, a memory management unit, an electronic device, and a storage medium. Background Art

[0002] In application scenarios such as virtualization, the Memory Management Unit (MMU) needs to map virtual addresses to physical addresses so that processes can access memory space through virtual addresses and ensure that processes cannot access unallocated memory space.

[0003] Currently, the mapping relationship between virtual addresses and physical addresses is stored in a page table with a radix tree structure. The memory management unit determines the physical address mapped to the virtual address by querying the page table.

[0004] However, as the memory capacity increases, the number of levels of the page table in the radix tree structure increases, and the memory management unit needs to query the page table level by level. The increase in the number of page table levels causes the memory management unit to take a longer time to determine the physical address mapped to the virtual address, which in turn leads to lower efficiency in mapping the virtual address to the physical address. Summary of the Invention

[0005] In view of this, embodiments of the present application provide a memory address mapping method, a memory management unit, an electronic device, and a storage medium to at least partially solve the above problems.

[0006] According to a first aspect of an embodiment of the present application, a memory address mapping method is provided, comprising: receiving a virtual address from a current process; determining an address segment table and an address segment attribute table corresponding to the current process based on identification information of the current process; searching for base address information from the address segment table based on a first virtual address segment included in the virtual address, the base address information being used to indicate a base address of a target physical address space segment, the target physical address space segment being a physical address space segment where a physical address mapped to the virtual address is located; searching for offset information from the address segment attribute table based on a second virtual address segment included in the virtual address, the offset information being used to indicate an offset of a physical address mapped to the virtual address within the target physical address space segment; and determining a physical address mapped to the virtual address based on the base address information and the offset information.

[0007] According to a second aspect of an embodiment of the present application, a memory management unit is provided, comprising: a receiving module for receiving a virtual address from a current process; a table acquisition module for determining an address segment table and an address segment attribute table corresponding to the current process based on identification information of the current process; a first table lookup module for searching for base address information from the address segment table based on a first virtual address segment included in the virtual address, the base address information being used to indicate a base address of a target physical address space segment, the target physical address space segment being a physical address space segment where a physical address mapped to the virtual address is located; a second table lookup module for searching for offset information from the address segment attribute table based on a second virtual address segment included in the virtual address, the offset information being used to indicate an offset of the physical address mapped to the virtual address within the target physical address space segment; and an integration module for determining a physical address mapped to the virtual address based on the base address information and the offset information.

[0008] According to the third aspect of the embodiment of the present application, an electronic device is provided, including: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform the operation corresponding to the method described in the first aspect above.

[0009] According to a fourth aspect of the embodiments of the present application, a computer storage medium is provided, on which a computer program is stored. When the program is executed by a processor, the method described in the first aspect is implemented.

[0010] According to a fifth aspect of an embodiment of the present application, a computer program product is provided, comprising computer instructions, wherein the computer instructions instruct a computing device to execute the method described in the first aspect above.

[0011] It can be seen from the above technical solution that the base address information is searched from the address segment table according to the first virtual address segment included in the virtual address. The base address information can indicate the base address of the target physical address space segment where the physical address mapped to the virtual address is located. The offset information is searched from the address segment attribute table according to the second virtual address segment included in the virtual address. The offset information can indicate the offset of the physical address mapped to the virtual address within the target physical address space segment. Then, the physical address mapped to the virtual address can be determined based on the base address information and the offset information. Since the table lookup process of the address segment table and the address segment attribute table can be performed in parallel, and the address segment table and the address segment attribute table are searched respectively according to the first virtual address segment and the second virtual address segment, the table lookup depth of the address segment table and the address segment attribute table can be reduced, and the time for searching the address segment table and the address segment attribute table can be shortened, thereby improving the efficiency of mapping the virtual address to the physical address. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.

[0013] Figure 1 is a schematic diagram of an exemplary system used in one embodiment of the present application;

[0014] Figure 2 This is a flowchart of a memory address mapping method according to an embodiment of the present application;

[0015] Figure 3 is a schematic diagram of a physical memory space according to an embodiment of the present application;

[0016] Figure 4 is a schematic diagram of an address segment table according to an embodiment of the present application;

[0017] Figure 5 This is a schematic diagram of an address segment table lookup process according to an embodiment of the present application;

[0018] Figure 6 1 is a schematic diagram of an address segment table lookup process according to another embodiment of the present application;

[0019] Figure 7 is a schematic diagram of an address segment attribute table according to an embodiment of the present application;

[0020] Figure 8 This is a schematic diagram of an address segment attribute table lookup process according to an embodiment of the present application;

[0021] Figure 9 This is a schematic diagram of another address segment attribute table lookup process described in this application;

[0022] Figure 10 This is a schematic diagram of a process accessing a memory table lookup process according to an embodiment of the present application;

[0023] Figure 11 This is a schematic diagram of a process accessing a memory table lookup process according to another embodiment of the present application;

[0024] Figure 12 is a schematic diagram of a memory management unit according to an embodiment of the present application;

[0025] Figure 13 It is a schematic diagram of an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0026] The present application is described below based on examples, but the present application is not limited to these examples. In the detailed description of the present application below, certain specific details are described in detail. Those skilled in the art can fully understand the present application without describing these details. To avoid obscuring the essence of the present application, well-known methods, processes, and procedures are not described in detail. In addition, the drawings are not necessarily drawn to scale.

[0027] First, some nouns or terms that appear in the process of describing the embodiments of the present application are subject to the following explanations.

[0028] Memory Management Unit: A memory management unit (MMU) is a hardware device located between the processor and memory in a computer system. It is used to process access requests issued by programs and convert virtual addresses into physical addresses to manage and protect memory.

[0029] Virtual Machine: A virtual machine (VM) is a complete computer system that is simulated by software and has complete hardware system functions and runs in a completely isolated environment.

[0030] Radix Trees: Radix Trees are a more space-efficient prefix tree (Trie). For a parent node of a radix tree, if the number of child nodes of the parent node is 1, the child nodes of the parent node will be merged into the parent node.

[0031] Linear list: A linear list is a type of data structure. A linear list is a finite sequence of n data elements with the same characteristics. A data element is an abstract symbol whose specific meaning generally varies in different situations.

[0032] Exemplary Systems

[0033] Figure 1 An exemplary system for the memory address mapping method applicable to the embodiment of the present application is shown. Figure 1 As shown, the system may include a cloud service terminal 102, a communication network 104 and at least one user device 106. Figure 1 The example is a plurality of user devices 106. It should be noted that the solution of the embodiment of the present application can be applied to both the cloud service end 102 and the user device 106.

[0034] The cloud server 102 can be any suitable device for storing information, data, programs, and / or any other suitable type of content, including but not limited to a distributed storage system, a server cluster, a computing cloud server cluster, and the like. In some embodiments, the cloud server 102 can perform any suitable function. For example, in some embodiments, the cloud server 102 can be used to build a virtualized environment. Based on a virtual machine, a network card driver, or other process created in the virtualized environment, a memory management unit included in the cloud server 102 converts the virtual address included in the memory access request into a physical address, and then reads and writes the memory space to be accessed by the process using the physical address. As an alternative example, in some embodiments, the memory management unit included in the cloud server 102 can divide the virtual address included in the memory access request into two virtual address segments, and then use these two address segments to search for two corresponding physical address segments in two tables in parallel. Then, based on the two found physical address segments, the physical address mapped to the virtual address is determined. This reduces the depth of the lookup table while increasing the parallelism of the table lookup, thereby improving the efficiency of mapping the virtual address to the physical address.

[0035] The communication network 104 can be any suitable combination of one or more wired and / or wireless networks. For example, the communication network 104 can include any one or more of the following: the Internet, an intranet, a wide area network (WAN), a local area network (LAN), a wireless network, a digital subscriber line (DSL) network, a frame relay network, an asynchronous transfer mode (ATM) network, a virtual private network (VPN), and / or any other suitable communication network. The user device 106 can be connected to the communication network 104 via one or more communication links (e.g., communication link 112), and the communication network 104 can be linked to the cloud service end 102 via one or more communication links (e.g., communication link 114). The communication link can be any communication link suitable for transmitting data between the cloud service end 102 and the user device 106, such as a network link, a dial-up link, a wireless link, a hard-wired link, any other suitable communication link, or any suitable combination of such links.

[0036] The user device 106 may include any one or more user devices suitable for interaction. In some embodiments, after receiving a request from the user device 106, the cloud service end 102 may construct a virtual machine for use and operation by the user device 106 in a virtualized environment. The virtual machine may send a memory access request to the memory management unit included in the cloud service end 102 based on the user's operating instructions. After receiving the memory access request, the memory management unit included in the cloud service end 102 maps the virtual address included in the memory access request into a physical address, and then reads and writes the memory space to be accessed by the virtual machine through the physical address. The user device 106 may include any suitable type of device. For example, the user device 106 may include a mobile device, a tablet computer, a laptop computer, a desktop computer, a wearable computer, a vehicle system and / or any other suitable type of user device.

[0037] The embodiments of the present application mainly focus on the process of the memory management unit mapping the virtual address to the corresponding physical address. The mapping process of the memory virtual address to the physical address will be described in detail later.

[0038] Memory address mapping method

[0039] Based on the above system, an embodiment of the present application provides a memory address mapping method, and the memory address mapping method is described in detail below through multiple embodiments.

[0040] Figure 2 This is a flow chart of a memory address mapping method according to an embodiment of the present application. Figure 2 As shown, the memory address mapping method includes the following steps:

[0041] Step 201: Receive a virtual address from the current process.

[0042] Multiple processes can send memory access requests to the memory management unit. The processes can be various processes running on the CPU (Central Processing Unit) or graphics processing unit (GPU) that can access memory, such as a virtual machine, a network card driver, etc. The memory management unit can process memory access requests from different processes in parallel, and the memory management unit uses the same strategy to process memory access requests from different processes. The embodiments of the present application focus on the process of the memory management unit processing memory access requests. In order to distinguish different processes, the embodiments of the present application use the current process among multiple processes as an example for explanation. The current process can be any process among multiple processes that can access memory.

[0043] When the current process accesses memory, it sends a memory access request to the memory management unit. The memory access request includes the virtual address that the current process wants to access. By parsing the memory access request, the virtual address that the current process wants to access can be obtained. The embodiments of the present application do not limit the length of the virtual address. For example, the length of the virtual address can be 32 bits, 64 bits, or 128 bits.

[0044] Step 202: Determine the address segment table and address segment attribute table corresponding to the current process according to the identification information of the current process.

[0045] Different processes have different identification information, and this information can be used to distinguish different processes. A process can send a memory access request to the memory management unit in the form of a data stream. The data stream carries a stream ID. Since the data streams sent by different processes carry different stream IDs, the process identification information can be the stream ID carried by the data stream sent by the process.

[0046] For a process that can access memory through the memory management unit, an address segment table and an address segment attribute table corresponding to the process are pre-created. Different processes may correspond to the same address segment table, and different processes may correspond to different address segment attribute tables.

[0047] The address segment table is used to record the correspondence between virtual address segments and physical address space segments. A physical address space segment indicates a continuous memory space, and different physical address space segments indicate different memory spaces. The address segment table can record the correspondence between multiple virtual address segments and physical address space segments. In the address segment table, a physical address space segment can be represented by the physical base address of the physical address space segment, or by the high-order bits of the physical base address of the physical address space segment.

[0048] The address segment attribute table is used to record the correspondence between virtual address segments and offsets within physical address space segments. The offset within the physical address space segment is used to indicate the offset address value within the corresponding physical address space segment, or to indicate the high-order bit of the offset address value within the corresponding physical address space segment. The address segment attribute table can record the correspondence between multiple virtual address segments and offsets within the physical address space segment.

[0049] It should be noted that the virtual address segments recorded in the address segment table and the address segment attribute table are different address segments within the virtual address. The virtual address segments recorded in the address segment table and the address segment attribute table are continuous and non-overlapping within the virtual address. In one example, when the effective virtual address is 52 bits, the virtual address segment recorded in the address segment table is bits 32 to 51 of the virtual address, while the virtual address segment recorded in the address segment attribute table is bits 12 to 31 of the virtual address.

[0050] After the virtual address of the current process is obtained, the address segment table and address segment attribute table corresponding to the current process can be determined from at least one pre-created address segment table and multiple address segment attribute tables according to the identification information of the current process.

[0051] Step 203: Search the address segment table for base address information according to the first virtual address segment included in the virtual address.

[0052] After obtaining the address segment table corresponding to the current process, the first virtual address segment can be extracted from the virtual address to be accessed by the current process, and then the base address information corresponding to the first virtual address segment can be found from the address segment table corresponding to the current process. The length of the first virtual address segment is equal to the length of the virtual address segment recorded in the address segment table, and the position of the first virtual address segment in the virtual address is the same as the position of the virtual address segment recorded in the address segment table in the corresponding virtual address. For example, if the virtual address segment recorded in the address segment table is 32 to 51 bits of the corresponding virtual address, then 32 to 51 bits are extracted from the virtual address to be accessed by the current process as the first virtual address segment.

[0053] It should be noted that, unless otherwise specified, the virtual address in the subsequent embodiments refers to the virtual address from the current process, that is, the virtual address to be accessed by the current process.

[0054] The physical address space segment where the physical address mapped to the virtual address resides is defined as the target physical address space segment. The base address information found in the address segment table can indicate the base address of the target physical address space segment. The target physical address space segment indicates a continuous memory space, and the memory location indicated by the physical address mapped to the virtual address is located within this memory space.

[0055] If two virtual addresses that include the same first virtual address segment come from the same process, or the two virtual addresses come from two different processes corresponding to the same address segment table, the base address information determined based on the two virtual addresses is the same, that is, the memory locations indicated by the two physical addresses mapped to the two virtual addresses are located in the same continuous memory space.

[0056] Step 204: Search the address segment attribute table for offset information according to the second virtual address segment included in the virtual address.

[0057] After obtaining the address segment attribute table corresponding to the current process, the second virtual address segment can be extracted from the virtual address, and then the offset information corresponding to the second virtual address segment can be found from the address segment attribute table corresponding to the current process. The length of the second virtual address segment is equal to the length of the virtual address segment recorded in the address segment attribute table, and the position of the second virtual address segment in the virtual address is the same as the position of the virtual address segment recorded in the address segment attribute table in the corresponding virtual address. For example, if the virtual address segment recorded in the address segment attribute table is 12 to 31 bits of the corresponding virtual address, then 12 to 31 bits are extracted from the virtual address to be accessed by the current process as the second virtual address segment.

[0058] In the virtual address, the first virtual address segment is adjacent to the second virtual address segment, and the first virtual address segment and the second virtual address segment do not overlap.

[0059] The offset information retrieved from the address segment attribute table can indicate the offset of the physical address mapped to the virtual address within the target physical address space segment. In one example, the offset information can indicate the offset of the physical address mapped to the virtual address within the target physical address space segment. In this case, the second virtual address segment includes the lower bits of the virtual address that precede the first virtual address segment. For example, if the first virtual address segment is bits 32 to 51 of the virtual address, the second virtual address segment includes bits 0 to 31 of the virtual address. The physical address mapped to the virtual address can then be directly determined based on the base address information and the offset information. In another example, the offset information may indicate the offset of the physical address space subsegment within the target physical address space segment, the physical address space subsegment being the physical address segment where the physical address mapped to the virtual address is located, and the physical address space subsegment being a subset of the target physical address space segment, the target physical address space segment may include multiple physical address space subsegments, and at this time, there is at least one low bit in the virtual address before the second virtual address segment, for example, the first virtual address segment is 32 to 51 bits in the virtual address, and the second virtual address segment includes 12 to 31 bits in the virtual address, and then the physical address mapped to the virtual address may be determined based on the base address information, the offset information and the low bits in the virtual address before the second virtual address segment.

[0060] It should be noted that step 203 and step 204 can be executed in parallel.

[0061] Step 205: Determine the physical address mapped to the virtual address according to the base address information and the offset information.

[0062] Since the base address information can indicate the base address of the target physical address space segment, and the offset information can indicate the offset of the physical address mapped to the virtual address within the target physical address space segment, the physical address mapped to the virtual address can be determined based on the base address information and the offset information.

[0063] If the second virtual address segment includes the lower bits of the virtual address that precede the first virtual address segment, the physical address mapped to the virtual address can be directly determined based on the base address information and the offset information. If there is at least one lower bit in the virtual address that precedes the second virtual address segment, the physical address mapped to the virtual address can be determined based on the base address information, the offset information, and the lower bits of the virtual address that precede the second virtual address segment.

[0064] After determining the physical address mapped to the virtual address, the memory management unit can read and write the memory according to the determined physical address.

[0065] In an embodiment of the present application, base address information is searched from an address segment table based on the first virtual address segment included in the virtual address. The base address information can indicate the base address of the target physical address space segment where the physical address mapped to the virtual address is located. Offset information is searched from an address segment attribute table based on the second virtual address segment included in the virtual address. The offset information can indicate the offset of the physical address mapped to the virtual address within the target physical address space segment. Then, the physical address mapped to the virtual address can be determined based on the base address information and the offset information. Since the lookup process of the address segment table and the address segment attribute table can be performed in parallel, and the address segment table and the address segment attribute table are searched respectively based on the first virtual address segment and the second virtual address segment, the lookup depth of the address segment table and the address segment attribute table can be reduced, and the time for searching the address segment table and the address segment attribute table can be shortened, thereby improving the efficiency of mapping the virtual address to the physical address.

[0066] In a possible implementation, the address segment table corresponds to multiple processes including the current process, and different processes correspond to different address segment attribute tables.

[0067] The address segment table is used to record the correspondence between virtual address segments and physical address space segments. Different physical address space segments indicate different memory spaces. Different memory spaces can be allocated to different processes. Moreover, different sub-memory spaces included in the same memory space can also be allocated to different processes. Therefore, multiple processes can share the same address segment table. For example, the first virtual address segment in the virtual address to be accessed by process 1 and process 2 is the same, indicating that the two memory locations indicated by the two physical addresses mapped to the virtual addresses to be accessed by process 1 and process 2 are both located in the memory space indicated by the physical address space segment corresponding to the first virtual address segment.

[0068] It should be noted that when the number of processes is large, multiple address segment tables can be created, each address segment table corresponds to one or more processes, and different address segment tables correspond to different processes.

[0069] The address segment attribute table is used to record the correspondence between virtual address segments and offsets within physical address space segments. The second virtual address segments in the virtual addresses to be accessed by different processes may be the same, but the offsets within the physical address space segments indicated by the second virtual address segments in the virtual addresses to be accessed by different processes may be different. Therefore, different address segment attribute tables are established for different processes. For example, the first virtual address segments in the virtual addresses to be accessed by process 1 and process 2 are different, and the second virtual address segments are the same. The physical address mapped to the virtual address to be accessed by process 1 is located in physical address space segment 1, and the physical address mapped to the virtual address to be accessed by process 2 is located in physical address space segment 2. The offset of the physical address mapped to the virtual address to be accessed by process 1 in physical address space segment 1 is the first offset, and the offset of the physical address mapped to the virtual address to be accessed by process 2 in physical address space segment 2 is the second offset. The first offset is different from the second offset. If process 1 and process 2 share the same address segment attribute table, the corresponding offset information cannot be found from the address segment attribute table according to the second virtual address segment, that is, the same second virtual address segment will correspond to different offsets in the physical address space segment.

[0070] In an embodiment of the present application, the address segment table can be shared by multiple processes, reducing the storage space occupied by the address segment table. Different address segment attribute tables are established for different processes to ensure that the physical address mapped to the virtual address to be accessed by the process can be accurately determined through the address segment table and the address segment attribute table. The physical address mapped to the virtual address is determined by searching the address segment table and the address segment attribute table. Since the address segment table and the address segment attribute table can be searched in parallel, the efficiency of the table lookup can be improved, and the table lookup depth of the address segment table and the address segment attribute table is small, thereby improving the efficiency of mapping the virtual address to the physical address.

[0071] In one possible implementation, the target physical address space segment includes multiple physical address space sub-segments, and the multiple physical address space sub-segments are adjacent to each other and do not overlap. The physical address mapped to the virtual address is located in the target physical address space sub-segment among these multiple physical address space sub-segments. The offset information can indicate the offset of the base address of the target physical address space sub-segment relative to the base address of the target physical space segment.

[0072] Figure 3 FIG. 1 shows a schematic diagram of the physical memory space of an embodiment of the present application. Figure 3As shown, the target physical address space segment includes multiple adjacent and non-overlapping physical address space sub-segments. The target physical address space segment can indicate a continuous memory space, and the physical address space sub-segment can indicate a continuous sub-memory space within the memory space. Different physical address space sub-segments indicate different sub-memory spaces. The base address information is used to indicate the base address of the target physical address space segment, and the offset information is used to indicate the offset of the base address of the target physical address space sub-segment relative to the base address of the target physical address space segment.

[0073] Based on the base address information, it can be determined that the physical address mapped to the virtual address is located within the target physical address space segment, that is, based on the base address information, the high bit of the physical address mapped to the virtual address can be determined. Based on the offset information, it can be determined that the physical address mapped to the virtual address is located within the target physical address space sub-segment, that is, based on the offset information, the high bit of the offset address value of the physical address mapped to the virtual address within the target physical address space segment can be determined. Based on the low bits in the virtual address before the second virtual address segment, the offset address value of the physical address mapped to the virtual address within the target physical address space sub-segment can be determined, that is, the low bit of the offset address value of the physical address mapped to the virtual address within the target physical address space segment. Thus, based on the base address information, the offset information, and the low bits in the virtual address before the second virtual address segment, the physical address mapped to the virtual address can be completely determined.

[0074] In one example, the lower bits of the virtual address preceding the second virtual address segment are defined as the third virtual address segment. Thus, the first virtual address segment, the second virtual address segment, and the third virtual address segment are sequentially adjacent in the virtual address, and the third virtual address segment is located in the lower bits of the virtual address. When determining the physical address mapped to the virtual address, the base address information and the offset information are added to obtain the base address of the target physical address space subsegment. The base address of the target physical address space subsegment is then added to the third virtual address segment to obtain the physical address mapped to the virtual address.

[0075] In an embodiment of the present application, the target physical address space segment where the physical address mapped to the virtual address is located can be determined according to the base address information, the offset value of the target physical address space sub-segment where the physical address mapped to the virtual address is located within the target physical address space segment can be determined according to the offset information, and the offset value of the physical address mapped to the virtual address within the target physical address space sub-segment can be determined according to the third virtual address segment. By adding the base address information, the offset information and the third virtual address segment, the physical address mapped to the virtual address can be completely determined, so that the physical address determination process is simple to calculate and the correctness of the determined physical address can be guaranteed.

[0076] In a possible implementation, the address segment table may be a linear table structure or a radix tree structure, and the address segment attribute table may be a linear table structure or a radix tree structure.

[0077] The data structure of the address segment table can adopt a linear table structure or a radix tree structure according to the size of the address segment table. The size of the address segment table is related to the size of the physical address space (effective physical address bit width) and the size of the segment granularity (SG). The segment granularity is used to characterize the size of the memory space indicated by the physical address space segment. The segment granularity can be 32MB, 64MB, 128MB, 256MB, 1GB, 4GB, 8GB, etc., where MB is megabytes and GB is gigabytes. When the physical address space is large and the segment granularity is small, the physical address space will be divided into a larger number of physical address space segments. At this time, the size of the address segment table is large, and the address segment table can adopt a radix tree structure. When the physical address space is small and the segment granularity is large, the physical address space will be divided into a smaller number of physical address space segments. At this time, the size of the address segment table is small, and the address segment table can adopt a linear table structure.

[0078] The data structure of the address segment attribute table can adopt a linear table structure or a radix tree structure according to the size of the address segment attribute table. The size of the address segment attribute table is related to the size of the physical address space segment and the size of the segment attribute granularity (SAG). The segment attribute granularity is used to characterize the size of the sub-memory space indicated by the physical address space sub-segment. The segment attribute granularity can be 4KB, 8KB, 16KB, 32KB, 64KB, 2MB, etc., where KB is kilobytes. When the physical address space segment is large and the segment attribute granularity is small, the physical address space segment includes a large number of physical address space sub-segments. In this case, the size of the address segment attribute table is large, and the address segment attribute table can adopt a radix tree structure. When the physical address space segment is small and the segment attribute granularity is large, the physical address space segment includes a small number of physical address space sub-segments. In this case, the size of the address segment attribute table is small, and the address segment attribute table can adopt a linear table structure.

[0079] When the segment granularity is small (for example, the segment granularity is 512MB), the data structure of the address segment attribute table can be a linear table, and the number of bits of the entries included in the address segment attribute table can be reduced to a few bits. This can speed up the lookup of the address segment attribute table and reduce the resource overhead of the address segment attribute table.

[0080] Segment granularity and segment attribute granularity can be configured through system software (such as the operating system or virtual machine management software). Segment granularity is much larger than segment attribute granularity. For example, when the segment granularity is 4GB, the segment attribute granularity can be 4KB or 16KB. When the segment granularity is 1GB, the segment attribute granularity can be 4KB or 16KB.

[0081] It should be noted that the data structures of the address segment table and the address segment attribute table may be the same or different. The embodiment of the present application does not limit whether the data structures of the address segment table and the address segment attribute table are the same.

[0082] In an embodiment of the present application, the data structure of the address segment table can adopt a linear table structure or a radix tree structure according to the scale of the address segment table, and the data structure of the address segment attribute table can adopt a linear table structure or a radix tree structure according to the scale of the address segment attribute table. For example, the address segment table and the address segment attribute table adopt the data structure that can make the table lookup efficient, thereby shortening the time spent on looking up the address segment table and the address segment attribute table and improving the efficiency of mapping physical addresses to physical addresses.

[0083] In one possible implementation, when the data structure of the address segment table is a radix tree structure, the address segment table includes at least two segment table levels, the first-level segment table level in at least two segment table levels includes an address segment sub-table, and the non-first-level segment table level in at least two segment table levels includes multiple address segment sub-tables, and the address segment sub-table includes multiple entries.

[0084] Figure 4 FIG. 1 is a schematic diagram of an address segment table according to an embodiment of the present application. Figure 4 As shown, the address segment table includes segment table level 0, segment table level 1, and segment table level 2. Segment table level 0 is the first segment table level, and segment table level 2 is the last segment table level. Segment table level 0 includes one address segment subtable, and segment table level 1 and segment table level 2 each include multiple address segment subtables. The address segment subtable at segment table level 0 has four entries.

[0085] It should be noted that Figure 4 The address segment table shown is an example of an address segment table in an embodiment of the present application. In other embodiments, the number of address segment table levels included in the address segment table, the number of address segment sub-tables included in the address segment table levels, and the number of entries included in the address segment sub-tables can be any suitable values.

[0086] In the at least two segment table levels included in the address segment table, different entries in the final segment table level correspond to different physical address space segments, and the entries in the final segment table level are used to store at least the base address of the physical address space segment corresponding to the entry. Because different entries in the final segment table level are used to store the base addresses of different physical address space segments, the number of entries in the final segment table level is equal to the number of physical address space segments that the address segment table can indicate. It should be understood that the entries in the final segment table level refer to the entries included in the address segment sub-table in the final segment table level.

[0087] like Figure 4 As shown, segment table level 2 is the last segment table level. Entries at segment table level 2 are used to store at least the base address of the physical address space segment corresponding to the entry. Different entries at segment table level 2 store the base addresses of different physical address space segments. For example, entry 21, entry 22, and entry 2n are all located at segment table level 2. Entry 21 is used to store the base address of physical address space segment 1, entry 22 is used to store the base address of physical address space segment 2, and entry 2n is used to store the base address of physical address space segment n.

[0088] It should be noted that, in addition to storing the base address of the physical address space segment, the entry at the last segment table level may also store attribute information of the physical address space segment.

[0089] In the at least two segment table levels included in the address segment table, entries in a non-final segment table level are used to store the base address of the address segment sub-table corresponding to the entry in the next segment table level, and different entries in the same non-final segment table level correspond to different address segment sub-tables in the next segment table level. Because different entries in the same non-final segment table level correspond to different address segment sub-tables in the next segment table level, the number of entries included in a non-final segment table level is equal to the number of address segment sub-tables included in the next segment table level.

[0090] like Figure 4 As shown, segment table level 1 is a non-final segment table level, and segment table level 2 is the next segment table level below segment table level 1. Entry 11, entry 12, and entry 1m are all located in segment table level 1, and address segment subtable 1, address segment subtable 2, and address segment subtable m are all located in segment table level 2. Entry 11 is used to store the base address of address segment subtable 1, entry 12 is used to store the base address of address segment subtable 2, and entry 1m is used to store the base address of address segment subtable m.

[0091] In an embodiment of the present application, entries located at the last-level segment table level are used to store the base address of the corresponding physical address space segment, and entries located at the non-last-level segment table level are used to store the base address of the corresponding address segment subtable in the next segment table level. According to the first virtual address segment, corresponding entries can be searched from each segment table level in the order from the first-level segment table level to the last-level segment table level. After finding the corresponding entry from the last-level segment table level, the base address information is read from the entry to ensure that the base address information can be found accurately and quickly according to the first virtual address segment, thereby ensuring the accuracy and efficiency of mapping the virtual address to the physical address.

[0092] In one possible implementation, when the data structure of the address segment table is a radix tree, the virtual address sub-segment corresponding to the i-th level segment table level in the first virtual address segment can be shifted left by n bits and then added to the base address of the i-th address segment sub-table to obtain the i-th segment table entry address, and then the base address of the i+1-th address segment sub-table where the i-th segment table entry address is stored in the entry pointed to by the i-th address segment sub-table can be obtained, wherein i is a positive integer less than N, N is equal to the number of segment table levels, the base address of the first address segment sub-table is the physical base address of the address segment table, and the data length of the entry in the address segment table at the non-last level segment table level is 2 n byte.

[0093] Since the data length of the entry in the address segment table at the non-last segment table level is 2 n Bytes, so the value obtained by shifting the virtual address sub-segment corresponding to the i-th segment table level in the first virtual address segment left by n bits can indicate the offset of the entry corresponding to the virtual address sub-segment in the i-th address segment sub-table, and then adding this value to the base address of the i-th address segment sub-table can obtain the physical address of the entry corresponding to the virtual address sub-segment in the i-th address segment sub-table, that is, the i-th segment table entry address.

[0094] After obtaining the base address of the Nth address segment subtable, the virtual address subsegment corresponding to the Nth level segment table level in the first virtual address segment is shifted left by n bits, and then added to the base address of the Nth address segment subtable to obtain the Nth segment table entry address, and then the base address of the entry stored in the Nth address segment subtable pointed to by the Nth segment table entry address can be obtained, and the base address is determined as the base address information.

[0095] The value obtained by shifting the virtual address subsegment corresponding to the Nth level segment table level in the first virtual address segment left by n bits can indicate the offset of the entry corresponding to the virtual address subsegment in the Nth address segment subtable. This value is then added to the base address of the Nth address segment subtable to obtain the physical address of the entry corresponding to the virtual address subsegment in the Nth address segment subtable, i.e., the Nth segment table entry address. The entry at the Nth level segment table level stores the base address of the physical address space segment. The base address of the target physical address space segment can then be read from the entry pointed to by the Nth segment table entry address, and the read base address is used as the base address information.

[0096] The data length of entries in the address segment table at the non-last segment table level can be determined according to the number of effective physical address bits in the system. For example, when the number of effective physical address bits in the system is 48 bits or 52 bits, the data length of entries in the address segment table can be 64 bits. The data length of entries in the address segment table at the last segment table level can be equal to the data length of entries at the non-last segment table level. For example, the data lengths of entries in the address segment table at different segment table levels are all 64 bits. When the segment granularity of the address segment table is large, such as the segment granularity is 4G, or the number of effective physical address bits in the system is small, the data length of entries at the last segment table level can be smaller than the data length of entries at the non-last segment table level. For example, the data length of entries at the non-last segment table level is 64 bits, and the data length of entries at the last segment table level is 32 bits. This can reduce the storage space occupied by the address segment table.

[0097] The position of the first virtual address segment in the virtual address is related to the number of effective physical address bits in the system and the segment granularity. For example, when the effective physical address bit number of the system is 52 bits and the segment granularity is 4GB, the first virtual address segment is 32 to 52 bits in the virtual address. When the effective physical address bit number of the system is 52 bits and the segment granularity is 1GB, the first virtual address segment is 30 to 52 bits in the virtual address.

[0098] The spatial size of the address segment subtable is related to the number of entries included in the address segment subtable and the data length of the entries. The number of bits of the virtual address subsegments corresponding to each level of the segment table in the first virtual address segment is related to the number of entries included in the address segment subtable.

[0099] Figure 5 FIG. 1 is a schematic diagram showing an address segment table lookup process according to an embodiment of the present application. Figure 5As shown, when the number of effective physical address bits of the system is 52 bits, the segment granularity is 4GB, the space size of the address segment subtable is 4KB, and the data length of the entries in the address segment table is 64 bits, the address segment subtable located at the non-first-level address segment level includes 512 entries. The virtual address subsegment corresponding to the 1st-level segment table level is 50 to 51 bits in the first virtual address segment, the virtual address subsegment corresponding to the 2nd-level segment table level is 41 to 49 bits in the first virtual address segment, and the virtual address subsegment corresponding to the 3rd-level segment table level is 32 to 40 bits in the first virtual address segment. The 3rd-level segment table level is the last-level segment table level. The 1st-level segment table level includes 1 address segment subtable, which includes 4 entries. The 2nd-level segment table level includes 4 address segment subtables, each of which includes 512 entries. The 3rd-level segment table level includes 2 11 There are address segment sub-tables, each of which contains 512 entries.

[0100] Figure 6 FIG. 1 is a schematic diagram showing an address segment table lookup process according to another embodiment of the present application. Figure 6 As shown, when the number of effective physical address bits of the system is 52 bits, the segment granularity is 1GB, the space size of the address segment subtable is 4KB, and the data length of the entry is 64 bits, the address segment subtable located at the non-first-level address segment level includes 512 entries. The virtual address subsegment corresponding to the 1st-level segment table level is 48 to 51 bits in the first virtual address segment, the virtual address subsegment corresponding to the 2nd-level segment table level is 39 to 47 bits in the first virtual address segment, and the virtual address subsegment corresponding to the 3rd-level segment table level is 30 to 38 bits in the first virtual address segment. The 3rd-level segment table level is the last-level segment table level. The 1st-level segment table level includes 1 address segment subtable, which includes 16 entries. The 2nd-level segment table level includes 16 address segment subtables, each of which includes 512 entries. The 3rd-level segment table level includes 2 13 There are address segment sub-tables, each of which contains 512 entries.

[0101] like Figure 5As shown, since the segment granularity is 4GB, the lower 32 bits of the virtual address do not participate in the address segment table lookup. After shifting bits 50 to 51 of the virtual address left by 3 bits, the bits are added to the base address of the address segment table to obtain the address of the first segment table entry. Then, the base address of the second address segment subtable can be read from the entry pointed to by the first address segment subtable. The first address segment subtable is located at the first level of the segment table, and the second address segment subtable is located at the second level of the segment table. After shifting bits 41 to 49 of the virtual address left by 3 bits, the bits are added to the base address of the second address segment subtable to obtain the address of the second segment table entry. Then, the base address of the third address segment subtable can be read from the entry pointed to by the second address segment subtable. The third address segment subtable is located at the third level of the segment table. After shifting bits 32 to 40 in the virtual address left by 3 bits, the address is added to the base address of the 3rd address segment subtable to obtain the address of the 3rd segment table entry. Then, the base address of the physical address space segment can be read from the entry pointed to by the 3rd address segment subtable from the 3rd segment table entry address, and the read base address is used as the base address information.

[0102] like Figure 6 As shown, since the segment granularity is 1GB, the lower 30 bits of the virtual address do not participate in the address segment table lookup. After shifting bits 48 to 51 of the virtual address left by 3 bits, the bits are added to the base address of the address segment table to obtain the address of the first segment table entry. Then, the base address of the second address segment subtable can be read from the entry pointed to by the first address segment subtable. The first address segment subtable is located at the first level of the segment table, and the second address segment subtable is located at the second level of the segment table. After shifting bits 39 to 47 of the virtual address left by 3 bits, the bits are added to the base address of the second address segment subtable to obtain the address of the second segment table entry. Then, the base address of the third address segment subtable can be read from the entry pointed to by the second address segment subtable. The third address segment subtable is located at the third level of the segment table. After shifting bits 30 to 38 of the virtual address left by 3 bits, the bits are added to the base address of the 3rd address segment subtable to obtain the address of the 3rd segment table entry. Then, the base address of the physical address space segment can be read from the entry pointed to by the 3rd address segment subtable from the 3rd segment table entry address, and the read base address is used as the base address information.

[0103] It should be noted that the base address of the physical address space segment stored in the entry at the last address segment level can be the high bit of the physical base address of the corresponding physical address space segment. Figure 5 and Figure 6 As shown in the figure, bits 0 to 31 of the entry in the third address segment subtable store bits 32 to 64 of the physical base address of the corresponding physical address space segment. In addition to storing the base address of the physical address space segment, the entry at the last address segment level can also store the attribute information of the corresponding physical address space segment. In addition, the entry at the last address segment level can also include a reserved field. Figure 5 and Figure 6 As shown, bits 32 to 63 of the entry in the third address segment subtable store the attribute information and reserved field of the physical address space segment.

[0104] It should be noted that in the aforementioned embodiments and subsequent embodiments, bit refers to the unit of measurement of the position or information amount in a binary number, the corresponding Chinese name is bit, and the corresponding English name is Binary digit.

[0105] In addition to storing the base address of the address segment subtable corresponding to the entry in the next segment table level, the entry located at the non-last segment table level also stores segment table level information, etc. The segment table level information is used to indicate whether the entry is located at the last segment table level.

[0106] In an embodiment of the present application, the first virtual address segment includes virtual address sub-segments corresponding to different segment table levels. By shifting the virtual address sub-segment left and adding it to the base address of the corresponding address segment sub-table, a certain entry in the address segment sub-table can be located, and the entries located at the non-last segment table level store the base address of the entry located at the next segment table level, and then the entries located at the next segment table level can be further located until the entry located at the last segment table level is located, and the base address stored in the entry is read as the base address information, so that the lookup depth of the address segment table is reduced, thereby ensuring that the base address information can be quickly found according to the first virtual address segment.

[0107] In one possible implementation, when the address segment attribute table is a radix tree structure, the address segment attribute table includes at least two attribute table levels, the first attribute table level in the at least two attribute table levels includes an attribute sub-table, and the non-first attribute table level in the at least two attribute table levels includes multiple attribute sub-tables, and the attribute sub-table includes multiple entries.

[0108] Figure 7 FIG. 1 is a schematic diagram of an address segment attribute table according to an embodiment of the present application. Figure 7 As shown, the address segment attribute table includes attribute table level 0, attribute table level 1, and attribute table level 2. Attribute table level 0 is the first attribute table level, and attribute table level 2 is the last attribute table level. Attribute table level 0 includes one attribute subtable, and attribute table level 1 and attribute table level 2 each include multiple attribute subtables. The attribute subtable at attribute table level 0 contains four entries.

[0109] It should be noted that Figure 7 The address segment attribute table shown is an example of an address segment attribute table in an embodiment of the present application. In other embodiments, the number of attribute table levels included in the address segment attribute table, the number of attribute sub-tables included in the attribute table level, and the number of entries included in the attribute sub-table can be any appropriate value.

[0110] In the at least two attribute table levels included in the address segment attribute table, different entries in the final attribute table level correspond to different physical address space sub-segments. The entry in the final attribute table level is used to store at least the base address of the physical address space sub-segment corresponding to the entry and the offset relative to the base address of the physical address space segment in which the physical address space sub-segment is located. Because different entries in the final attribute table level are used to store the offsets of different physical address space sub-segments, the number of entries in the final attribute table level is equal to the number of physical address space sub-segments that the address segment attribute table can indicate. It should be understood that the entries in the final attribute table level refer to the entries included in the attribute sub-table in the final attribute table level.

[0111] like Figure 7 As shown, attribute table level 2 is the last attribute table level. Entries at attribute table level 2 are used to store at least the offset of the physical address space subsegment corresponding to the entry. Different entries at attribute table level 2 store the offsets of different physical address space subsegments. For example, entry 21, entry 22, and entry 2n are all located at attribute table level 2. Entry 21 is used to store the offset of the base address of physical address space subsegment 1 relative to the base address of the physical address space segment where physical address space subsegment 1 is located. Entry 22 is used to store the offset of the base address of physical address space subsegment 2 relative to the base address of the physical address space segment where physical address space subsegment 2 is located. Entry 2n is used to store the offset of the base address of physical address space subsegment n relative to the base address of the physical address space segment where physical address space subsegment n is located.

[0112] It should be noted that, in addition to storing the offset of the physical address space sub-segment, entries at the final attribute table level can also store attribute information for the physical address space sub-segment. This attribute information includes information such as read and write permissions, security attributes, and whether the physical address space sub-segment has been written to. Entries at the final attribute table level can also include reserved fields.

[0113] In the at least two attribute table hierarchies included in the address segment attribute table, entries in a non-final attribute table hierarchy are used to store the base address of the attribute sub-table corresponding to the entry in the next attribute table hierarchy, and different entries in the same non-final attribute table hierarchy correspond to different attribute sub-tables in the next attribute table hierarchy. Because different entries in the same non-final attribute table hierarchy correspond to different attribute sub-tables in the next attribute table hierarchy, the number of entries in a non-final attribute table hierarchy is equal to the number of attribute sub-tables in the next attribute table hierarchy.

[0114] like Figure 7As shown, attribute table level 1 is a non-last attribute table level, and attribute table level 2 is the next attribute table level below attribute table level 1. Entries 11, 12, and 1m are all located in attribute table level 1, and attribute sub-tables 1, 2, and m are all located in attribute table level 2. Entry 11 is used to store the base address of attribute sub-table 1, entry 12 is used to store the base address of attribute sub-table 2, and entry 1m is used to store the base address of attribute sub-table m.

[0115] In an embodiment of the present application, entries located at the last-level attribute table level are used to store the offset of the corresponding physical address space sub-segment, and entries located at the non-last-level attribute table level are used to store the base address of the corresponding attribute sub-table in the next attribute table level. According to the second virtual address segment, the corresponding entries can be searched from each attribute table level in the order from the first-level attribute table level to the last-level attribute table level. After the corresponding entry is found from the last-level attribute table level, the offset information is read from the entry to ensure that the offset information can be found accurately and quickly according to the second virtual address segment, thereby ensuring the accuracy and efficiency of mapping the virtual address to the physical address.

[0116] In a possible implementation, when the data structure of the address segment attribute table is a radix tree, the virtual address sub-segment corresponding to the j-th attribute table level in the second virtual address segment can be shifted left by m bits and then added to the base address of the j-th attribute sub-table to obtain the j-th attribute table entry address, and then the base address of the j+1-th attribute sub-table where the entry pointed to by the j-th attribute table entry address in the j-th attribute sub-table is stored can be obtained, wherein j is less than M, M is equal to the number of attribute table levels, the base address of the first attribute sub-table is the physical base address of the address segment attribute table, and the data length of the entry in the address segment attribute table at the non-last attribute table level is 2 m byte.

[0117] Since the data length of the entry in the address segment attribute table at the non-last attribute table level is 2 m Bytes, so the value obtained by shifting the virtual address sub-segment corresponding to the j-th attribute table level in the second virtual address segment left by m bits can indicate the offset of the entry corresponding to the virtual address sub-segment in the j-th attribute sub-table, and then adding the value to the base address of the j-th attribute sub-table can obtain the physical address of the entry corresponding to the virtual address sub-segment in the j-th attribute sub-table, that is, the address of the j-th attribute table entry.

[0118] After obtaining the base address of the Mth attribute subtable, the virtual address subsegment corresponding to the Mth attribute table level in the second virtual address segment is shifted left by m bits, and then added to the base address of the Mth attribute subtable to obtain the Mth attribute table entry address, and then the offset of the entry stored in the Mth attribute subtable pointed to by the Mth attribute table entry address can be obtained, and the offset is determined as the offset information.

[0119] The value obtained by shifting the virtual address subsegment corresponding to the M-th attribute table level in the second virtual address segment left by m bits can indicate the offset of the entry corresponding to the virtual address subsegment in the M-th attribute subtable. This value is then added to the base address of the M-th attribute subtable to obtain the physical address of the entry corresponding to the virtual address subsegment in the M-th attribute subtable, i.e., the M-th attribute table entry address. The entry at the M-th attribute table level stores the offset of the physical address space subsegment. The offset of the target physical address space subsegment can then be read from the entry pointed to by the M-th attribute table entry address, and the read offset is used as the offset information.

[0120] The data length of entries in the address segment attribute table located at the non-last-level attribute table level can be determined according to the number of effective physical address bits in the system. For example, when the number of effective physical address bits in the system is 48 bits or 52 bits, the data length of entries in the address segment attribute table can be 64 bits. The data length of entries in the address segment attribute table located at the last-level attribute table level can be equal to the data length of entries located at the non-last-level attribute table level. For example, the data lengths of entries in the address segment attribute table located at different attribute table levels are all 64 bits. When the segment attribute granularity of the address segment attribute table is large, or the number of effective physical address bits in the system is small, the data length of entries at the last-level attribute table level can be smaller than the data length of entries at the non-last-level attribute table level. For example, the data length of entries at the non-last-level attribute level is 64 bits, and the data length of entries at the last-level attribute table level is 32 bits. This can reduce the storage space occupied by the address segment attribute table.

[0121] The position of the second virtual address segment in the virtual address is related to the segment attribute granularity. For example, when the number of effective physical address bits in the system is 52 bits and the segment attribute granularity is 4KB, the second virtual address segment is 21 to 31 bits in the virtual address. When the number of effective physical address bits in the system is 52 bits and the segment attribute granularity is 16KB, the second virtual address segment is 14 to 29 bits in the virtual address.

[0122] The spatial size of the attribute subtable is related to the number of entries included in the attribute subtable and the data length of the entries. The number of bits of the virtual address subsegments corresponding to each level of the attribute table in the second virtual address segment is related to the number of entries included in the attribute subtable.

[0123] Figure 8 FIG. 1 is a schematic diagram showing the address segment attribute table lookup process of an embodiment of the present application. Figure 8As shown, the number of effective physical address bits of the system is 52 bits, the segment granularity is 4GB, the segment attribute granularity is 4KB, the space size of the attribute subtable is 4KB, and the data length of the entries in the address segment attribute table is 64 bits. The attribute subtable located at the non-first-level attribute table level includes 512 entries. The virtual address subsegment corresponding to the first-level attribute table level is 30 to 31 bits in the second virtual address segment, the virtual address subsegment corresponding to the second-level attribute table level is 21 to 29 bits in the second virtual address segment, and the virtual address subsegment corresponding to the third-level attribute table level is 12 to 20 bits in the second virtual address segment. The first-level attribute table level includes 1 attribute subtable, which includes 4 entries. The second-level attribute table level includes 4 attribute subtables, each of which includes 512 entries. The third-level attribute table level includes 2 11 There are address segment sub-tables, each of which contains 512 entries.

[0124] Figure 9 FIG. 1 is a schematic diagram showing the address segment attribute table lookup process of another embodiment of the present application. Figure 9 As shown, the number of effective physical address bits of the system is 52 bits, the segment granularity is 1GB, the segment attribute granularity is 16KB, the space size of the attribute subtable is 4KB, and the data length of the entries in the address segment attribute table is 64 bits. The attribute subtable located at the non-first-level attribute table level includes 512 entries. The virtual address subsegment corresponding to the first-level attribute table level is bits 23 to 29 in the second virtual address segment, and the virtual address subsegment corresponding to the second-level attribute table level is bits 14 to 22 in the second virtual address segment. The first-level attribute table level includes 1 attribute subtable, which includes 128 entries. The second-level attribute table level includes 128 attribute subtables, each of which includes 512 entries.

[0125] like Figure 8As shown, since the segment attribute granularity is 4KB, the lower 12 bits of the virtual address do not participate in the address segment attribute table lookup. After shifting bits 30 to 31 in the virtual address left by 3 bits, the bits are added to the base address of the address segment attribute table to obtain the address of the first attribute table entry. Then, the base address of the second attribute subtable can be read from the entry pointed to by the first attribute subtable from the address of the first attribute table entry. The first attribute subtable is located at the first level attribute table level, and the second attribute subtable is located at the second level attribute table level. After shifting bits 21 to 29 in the virtual address left by 3 bits, the bits are added to the base address of the second attribute subtable to obtain the address of the second attribute table entry. Then, the base address of the third attribute subtable can be read from the entry pointed to by the second attribute subtable from the address of the second attribute table entry. The third attribute subtable is located at the third level attribute table level. After shifting bits 12 to 20 in the virtual address left by 3 bits and adding them to the base address of the third attribute subtable, the address of the third attribute table entry can be obtained. Then, the offset of the physical address space subsegment can be read from the entry pointed to by the third attribute subtable from the address of the third attribute table entry, and the read offset can be used as the offset information.

[0126] like Figure 9 As shown, since the segment attribute granularity is 16KB, the lower 14 bits of the virtual address do not participate in the address segment attribute table lookup. After shifting bits 23 to 29 in the virtual address left by 3 bits, the bits are added to the base address of the address segment attribute table to obtain the address of the first attribute table entry. Then, the base address of the second attribute subtable can be read from the entry pointed to by the first attribute subtable from the address of the first attribute table entry. The first attribute subtable is located at the first level attribute table level, and the second attribute subtable is located at the second level attribute table level. After shifting bits 14 to 22 in the virtual address left by 3 bits, the bits are added to the base address of the second attribute subtable to obtain the address of the second attribute table entry. Then, the offset of the physical address space subsegment can be read from the entry pointed to by the second attribute subtable from the address of the second attribute table entry, and the read offset is used as the offset information.

[0127] It should be noted that the offset of the physical address space sub-segment stored in the entry at the last attribute table level can be the high bit of the offset address of the corresponding physical address space sub-segment. Figure 8 As shown, bits 0 to 31 of the entry in the third attribute subtable store bits 12 to 31 of the offset address of the corresponding physical address space subsegment, such as Figure 9 As shown, bits 14 to 31 of the entry in the second attribute subtable store bits 14 to 31 of the offset address of the corresponding physical address space subsegment. In addition to storing the offset address of the physical address space subsegment, the entry at the last attribute table level can also store the attribute information of the corresponding physical address space subsegment. In addition, the entry at the last attribute table level can also include a reserved field. Figure 8As shown in FIG, bits 32 to 63 of the entry in the third attribute subtable store the attribute information of the physical address space subsegment and the reserved field. Figure 9 As shown, bits 0 to 11 of the entry in the second attribute subtable store the attribute information of the physical address space subsegment, and bits 12 to 13 are reserved.

[0128] In addition to storing the base address of the attribute subtable corresponding to the entry in the next attribute table level, the entry at the non-last attribute table level also stores attribute table level information, etc. The attribute table level information is used to indicate whether the entry is at the last attribute table level.

[0129] In an embodiment of the present application, the second virtual address segment includes virtual address sub-segments corresponding to different attribute table levels. By shifting the virtual address sub-segment left and adding it to the base address of the corresponding attribute sub-table, a certain entry in the attribute sub-table can be located, and the entries at the non-last attribute table level store the base address of the entry at the next attribute table level, and then the entries at the next attribute table level can be further located until the entry at the last attribute table level is located, and the offset stored in the entry is read as offset information, so that the lookup depth of the address segment attribute table is reduced, thereby ensuring that the offset information can be quickly found according to the second virtual address segment.

[0130] In one possible implementation, permission information may be retrieved from an address segment attribute table based on the second virtual address segment. The permission information may indicate access rights for a physical address mapped to the virtual address. The permission information and corresponding offset information are stored in the same entry in the address segment attribute table.

[0131] After finding the permission information based on the second virtual address segment, it can be determined based on the permission information whether the current process has the permission to access the physical address mapped to the virtual address. If the current process has the permission to access the physical address mapped to the virtual address, the current process is allowed to access the physical address mapped to the virtual address, and then read and write the physical address mapped to the virtual address. If the current process does not have the permission to access the physical address mapped to the virtual address, the current process is denied access to the physical address mapped to the virtual address, and then the current process's current memory access request is not responded to, or an indication information indicating a memory access failure is returned to the current process.

[0132] Since the offset information stored in the address segment attribute table is used to indicate the offset of the physical address space sub-segment, and the physical address space sub-segment includes a continuous range of physical addresses, the address segment attribute information indicates the access rights of the physical address space sub-segment. If the permission information indicates that the current process has access rights to the target physical address space sub-segment, then the current process has the right to access the physical address mapped to the virtual address. If the permission information indicates that the current process does not have access rights to the target physical address space sub-segment, then the current process does not have the right to access the physical address mapped to the virtual address.

[0133] When the data structure of the address segment attribute table is a radix tree structure, the permission information is stored in the entry located at the last-level attribute table level, that is, the offset of the physical address space sub-segment and the permission information of the physical address space sub-segment are stored in the same entry. When the offset of the target physical address space sub-segment is searched from the address segment attribute table according to the second virtual address segment, the permission information of the target physical address space sub-segment can be obtained at the same time, and then it can be determined whether the current process has the permission to access the physical address mapped to the virtual address based on the obtained permission information.

[0134] In one example, Figure 8 As shown in the figure, the permission information is located in bits 32 to 63 of the entry in the third attribute subtable. Figure 9 As shown, the permission information is located in bits 0 to 11 of the entry in the second attribute subtable.

[0135] In an embodiment of the present application, the address segment attribute table stores permission information of the physical address space sub-segment. When searching for offset information from the address segment attribute table, the permission information of the target physical address space sub-segment can be found simultaneously. Then, based on the found permission information, it can be determined whether the current process has access rights to the target physical address space sub-segment. If the current process has access rights to the target physical space sub-segment, the current process has permission to access the physical address mapped to the virtual address. If the current process does not have access rights to the target physical address space sub-segment, the current process does not have permission to access the physical address mapped to the virtual address. The offset address of the physical address space sub-segment relative to the physical address space segment and the permission rights of the physical address space sub-segment are stored in the address segment attribute table. When searching for the offset address of the physical address space sub-segment, the permission information of the physical address space sub-segment can be obtained simultaneously, so that different processes can have access rights to different physical address space sub-segments included in the same physical address space segment, which facilitates the management of the process's memory access rights and can more flexibly divide the continuous memory space for different processes to use.

[0136] In a possible implementation, the address segment table and the address segment attribute table corresponding to the current process may be determined according to identification information of the current process.

[0137] When determining the address segment table corresponding to the current process, the address segment identity information corresponding to the current process can be searched from the segment set table based on the identification information of the current process, and then the base address of the address segment table corresponding to the current process can be searched from the segment configuration table based on the address segment identity information corresponding to the current process, and then the address segment table whose corresponding base address is the base address of the address segment table corresponding to the current process is determined as the address segment table corresponding to the current process.

[0138] The segment set table stores the correspondence between the identification information of multiple processes and the address segment identity information, and the same address segment identity information in the segment set table corresponds to the identification information of at least one process, that is, the identification information of different processes can correspond to the same address segment identity information, and the identification information of different processes is different.

[0139] The segment configuration table stores the correspondence between multiple address segment identity information and the base addresses of the address segment table. Different address segment identity information corresponds to different address segment table base addresses. Different address segment tables have different base addresses. That is, the number of correspondences between the address segment identity information and the base addresses of the address segment table stored in the segment configuration table is equal to the number of address segment tables.

[0140] In an example, the identification information of process 1 is identification information 1, the identification information of process 2 is identification information 2, and the identification information of process 3 is identification information 3. Identification information 1, identification information 2, and identification information 3 are all different. In the segment set table, identification information 1 and identification information 2 both correspond to address segment identity information 1, and identification information 3 corresponds to address segment identity information 2. Address segment identity information 1 and address segment identity information 2 are different. Therefore, process 1 and process 2 correspond to the same address segment table, and process 3 and process 1 (process 2) correspond to different address segment tables.

[0141] The segment set table and segment configuration table can be programmed and configured through system management software (such as the operating system). In addition to storing the address segment table base address corresponding to the address segment identity information, the segment configuration table can also store information such as the segment granularity of the address segment table indicated by the address segment table base address and the global configuration attributes of the address segment table.

[0142] In an embodiment of the present application, since the same address segment table can be shared by multiple processes, the address segment identity information corresponding to the process's identification information can be searched through the segment set table. The identification information of different processes can correspond to the same address segment identity information. The address segment table base address corresponding to the address segment identity information can be searched through the segment configuration table, and the address segment table corresponding to the process can be determined based on the address segment table base address. Since different processes can correspond to the same address segment table, the address segment table corresponding to the process can be conveniently determined based on the process's identification information through the segment set table and the segment configuration table, while reducing the amount of data in the segment configuration table.

[0143] In another embodiment, compared to the above embodiment, a segment set table may not be provided, and the corresponding address segment table base address may be directly searched from the segment configuration table using the process identification information. The corresponding segment configuration table stores a plurality of correspondences between identification information and address segment table base addresses, with different identification information corresponding to different address segment table base addresses, and different processes corresponding to different identification information. After obtaining the identification information of the current process, the corresponding entry in the segment configuration table may be directly indexed based on the identification information of the current process, and then the address segment table base address corresponding to the current process may be obtained from the entry. The address segment table whose corresponding base address is the address segment table base address corresponding to the current process is then determined as the address segment table corresponding to the current process.

[0144] In another embodiment, the segment set table may be replaced by a mapping algorithm. The mapping algorithm may map the identification information of a process to corresponding address segment identity information. The mapping algorithm may map the identification information of different processes to the same address segment identity information.

[0145] When determining the address segment attribute table corresponding to the current process, the attribute table base address corresponding to the current process can be found from the attribute configuration table based on the identification information of the current process. The address segment attribute table whose base address is the attribute table base address corresponding to the current process is then determined as the address segment attribute table corresponding to the current process. The attribute configuration table stores the correspondence between the identification information of multiple processes and the attribute table base addresses, with different identification information corresponding to different attribute table base addresses.

[0146] The attribute configuration table stores a plurality of correspondences between identification information and attribute table base addresses. Different identification information corresponds to different attribute table base addresses. Different address segment attribute tables have different base addresses. That is, the number of correspondences between identification information and attribute table base addresses stored in the attribute configuration table is equal to the number of address segment attribute tables.

[0147] The attribute configuration table can be programmed and configured through system management software (such as an operating system). In addition to storing the attribute table base address corresponding to the identification information, the attribute configuration table can also store information such as the segment attribute granularity of the address segment attribute table and the global configuration attributes of the address segment attribute table.

[0148] In an embodiment of the present application, since different processes correspond to different address segment attribute tables, the correspondence between the process's identification information and the attribute table's base address is recorded through the attribute configuration table. The process's identification information is used as the basis for searching the attribute configuration table, and the attribute table's base address corresponding to the process's identification information can be obtained. The address segment attribute table having the same base address as the obtained attribute table's base address is then determined as the address segment attribute table corresponding to the process, and the address segment attribute table corresponding to the process can be found quickly and accurately.

[0149] Figure 10FIG. 1 is a schematic diagram showing a process of accessing a memory table lookup process according to an embodiment of the present application. Figure 10 As shown, a process's memory access request enters the memory management unit. The memory access request includes the process's identification information and the virtual address to be accessed. Based on the process's identification information, the memory management unit searches the segment set table and the attribute configuration table in parallel. After finding the address segment identity information corresponding to the identification information in the segment set table, it searches the segment configuration table for the address segment table base address corresponding to the address segment identity information, and searches the attribute configuration table for the attribute table base address corresponding to the identification information. The segment set table, segment configuration table, and attribute configuration table can be stored locally.

[0150] After finding the base address of the address segment table, the address segment table corresponding to the process can be determined according to the base address of the address segment table, and then the address segment table is searched according to the first virtual address segment included in the virtual address to obtain the base address information. Figure 10 In the example shown, process m and process n correspond to the same address segment table.

[0151] After finding the attribute table base address, the address segment attribute table corresponding to the process can be determined according to the attribute table base address, and then the address segment attribute table is searched according to the second virtual address segment included in the virtual address to obtain the offset information. Figure 10 As shown, process m and process n correspond to different address segment attribute tables. When the address segment attribute table is searched according to the second virtual address segment, the permission information of the target physical address space sub-segment can also be obtained.

[0152] After completing the search of the address segment table and the address segment attribute table and obtaining the base address information, offset information, and permission information, the base address information, offset information, and the low bit of the virtual address are added together to obtain the physical address mapped to the virtual address, and based on the permission information, it is determined whether the process has permission to access the physical address mapped to the virtual address. If the process has permission to access the physical address mapped to the virtual address, the corresponding process is allowed to access the physical address mapped to the virtual address. If the process does not have permission to access the physical address mapped to the virtual address, the corresponding process is not allowed to access the physical address mapped to the virtual address.

[0153] It should be noted that the segment set table and the segment configuration table can be searched in parallel with the attribute configuration table, and the address segment table and the address segment attribute table can be searched in parallel.

[0154] In one possible implementation, when the data structure of the address segment table is a radix tree, if the physical addresses to be accessed by two processes are located in the same physical address space segment, then the two processes can share the last segment table level of the address segment table, that is, the last segment table levels of the two address segment tables corresponding to the two processes are the same, but the non-last segment table levels are different. If the physical addresses to be accessed by the two processes are located in different physical address space segments, then the two processes correspond to different address segment tables, that is, the two processes cannot share the last segment table level. Different processes correspond to different address segment attribute tables.

[0155] Figure 11 FIG. 1 is a schematic diagram showing a process of accessing a memory table lookup process according to another embodiment of the present application. Figure 11 As shown, the physical addresses to be accessed by process 0 and process 1 are both located in physical address space segment A, and the physical addresses to be accessed by process 2 are located in physical address space B. Therefore, process 0 and process 1 can share the same final segment table hierarchy, but process 2 cannot share the final segment table hierarchy with process 0 and process 1. Process 2 needs to have a corresponding independent address segment table. It should be understood that Figure 11 It shows that process 2 cannot share the final segment table level with process 0 and process 1, but in actual application scenarios, process 2 can share the final segment table level with other processes besides process 0 and process 1. Of course, process 2 does not have to share the final segment table level with other processes.

[0156] In one example, the address segment table includes three segment table levels. The third level segment table level of the two address segment tables corresponding to process 0 and process 1 is the same, while the first level segment table level and the second level segment table level of the two address segment tables are different.

[0157] In an example, when the segment granularity is 4GB, the sizes of physical address space segment A and physical address space segment B are both 4GB. Physical address space segment A and physical address space segment B can be adjacent physical address space segments in the physical address space, or they can be non-adjacent physical address space segments in the physical address space.

[0158] Process 0 can access the physical address space sub-segments within physical address space segment A to which it has access rights, but cannot access the physical address space sub-segments within physical address space segment A to which it does not have access rights. Process 1 can access the physical address space sub-segments within physical address space segment A to which it has access rights, but cannot access the physical address space sub-segments within physical address space segment A to which it does not have access rights. Process 2 can access the physical address space sub-segments within physical address space segment B to which it has access rights, but cannot access the physical address space sub-segments within physical address space segment B to which it does not have access rights.

[0159] like Figure 11As shown in the figure, the address segment table corresponding to process 0 is address segment table 0, the address segment table corresponding to process 1 is address segment table 1, and the address segment table corresponding to process 2 is address segment table 2. Address segment table 0 and address segment table 1 share the same last-level segment table hierarchy. The address segment attribute table corresponding to process 0 is address segment attribute table 0, the address segment attribute table corresponding to process 1 is address segment attribute table 1, and the address segment attribute table corresponding to process 2 is address segment attribute table 2.

[0160] After receiving virtual address 0 from process 0, based on the first virtual address segment included in virtual address 0, the base address of the last-level address segment subtable is searched from the non-last-level segment table level of address segment table 0. Based on the base address of the last-level address segment subtable and the first virtual address segment included in virtual address 0, the entry storing the base address of physical address space segment A is searched from the shared last-level segment table level, and the base address of physical address space segment A is read from this entry. Based on the second virtual address segment included in virtual address 0, offset information 0 is searched from address segment attribute table 0. Based on the base address of physical address space segment A, offset information 0, and the low bits of virtual address 0, the physical address 0 mapped to virtual address 0 is determined.

[0161] After receiving virtual address 1 from process 1, the base address of the last-level address segment subtable is searched from the non-last-level segment table level of address segment table 1 based on the first virtual address segment included in virtual address 1. Based on the base address of the last-level address segment subtable and the first virtual address segment included in virtual address 1, the entry storing the base address of physical address space segment A is searched from the shared last-level segment table level, and the base address of physical address space segment A is read from this entry. Based on the second virtual address segment included in virtual address 1, offset information 1 is searched from address segment attribute table 1. Based on the base address of physical address space segment A, offset information 1, and the low bits of virtual address 1, the physical address 1 mapped to virtual address 1 is determined.

[0162] After receiving virtual address 2 from process 2, the base address of physical address space segment B is searched from address segment table 2 based on the first virtual address segment included in virtual address 2. Offset information 2 is searched from address segment attribute table 2 based on the second virtual address segment included in virtual address 2. Based on the base address of physical address space segment B, offset information 2, and the low bits of virtual address 2, the physical address 2 mapped to virtual address 2 is determined.

[0163] It should be noted that the table structure of the address segment table and the address segment attribute table, and the table lookup method of the address segment table and the address segment attribute table in the embodiment of the present application are consistent with the above embodiment and will not be repeated here.

[0164] In an embodiment of the present application, different processes whose accessed physical addresses are located in the same physical address space segment can share the last-level segment table hierarchy of the address segment table, that is, they can share the address segment sub-table included in the last-level segment table hierarchy. For different address segment tables that share the last-level segment table hierarchy, only one address segment sub-table included in the last-level segment table hierarchy needs to be stored, thereby reducing the storage resources occupied by the address segment table.

[0165] In one possible implementation, to improve the efficiency of searching the address segment table and the address segment attribute table, a segment table search buffer is provided for the address segment table, and an attribute table search buffer is provided for the address segment attribute table. After determining the base address information corresponding to the first virtual address segment by searching the address segment table, the correspondence between the first virtual address segment and the base address information can be stored in the segment table search buffer. After determining the offset information corresponding to the second virtual address segment by searching the address segment attribute table, the correspondence between the second virtual address segment and the offset information can be stored in the attribute table search buffer.

[0166] After receiving the virtual address from the current process, first search in the segment table lookup buffer to see whether there is base address information corresponding to the first virtual address segment in the virtual address. If so, there is no need to search the address segment table again. If not, search the segment configuration table to determine the address segment table corresponding to the current process, and then search the corresponding base address information from the address segment table.

[0167] After receiving the virtual address from the current process, first search the attribute table buffer to see whether the offset information corresponding to the second virtual address segment in the virtual address exists. If it exists, there is no need to search the address segment attribute table again. If it does not exist, search the attribute configuration table to determine the address segment attribute table corresponding to the current process, and then search the corresponding offset information from the address segment attribute table.

[0168] It should be noted that the correspondence between the first virtual address segment and the base address information stored in the segment table search buffer will identify which process it belongs to, and the correspondence between the second virtual address segment and the offset information stored in the corresponding attribute table search buffer will also identify which process it belongs to.

[0169] Since the address segment table and the address segment attribute table are relatively shallow, the segment table lookup buffer and the attribute table lookup buffer have a larger memory reach, resulting in a higher hit rate in the segment table lookup buffer and the attribute table lookup buffer, thereby improving the table lookup performance.

[0170] It should be noted that the segment table lookup buffer and the attribute table lookup buffer can be searched in parallel.

[0171] In an embodiment of the present application, the correspondence between the first virtual address segment and the base address information found by the buffer cache is searched through the segment table, and the correspondence between the second virtual address segment and the offset information found by the buffer cache is searched through the attribute table. When the same process accesses the physical address located in the same physical address space segment multiple times, multiple searches of the address segment table can be avoided. When the same process accesses the physical address located in the same physical address space sub-segment multiple times, multiple searches of the address segment attribute table can be avoided, thereby saving time for searching the address segment table and / or the address segment attribute table and improving the efficiency of mapping the virtual mapping to the physical address.

[0172] In one possible implementation, when a process's memory access space changes, since different processes correspond to different address segment attribute tables, the system software can adjust the address segment attribute table corresponding to that process without having to adjust the address segment table corresponding to that process, thereby preventing any impact on other processes. The system software can flexibly manage the address space based on the address segment table and the address segment attribute table.

[0173] In one possible application scenario, system software can establish an address segment table for multiple processes. The physical address space corresponding to this address segment table is a large, contiguous block of address space A, with a high granularity. Separate address segment attribute tables are established for different processes, with a finer granularity, allowing for precise control of fine-grained access permissions within address space A. This not only improves the parallelism of table lookups and reduces the overall table lookup depth, but also allows for fine-grained control of access permissions within address space A, enabling efficient utilization of address space A without causing memory fragmentation.

[0174] It should be noted that the base addresses in the above embodiments all refer to physical base addresses.

[0175] Memory Management Unit

[0176] Figure 12 This is a block diagram of the internal structure of a memory management unit according to an embodiment of the present application. Figure 12 As shown, the memory management unit 110 includes: a receiving module 111 , a table acquisition module 112 , a first table lookup module 113 , a second table lookup module 114 and an integration module 115 .

[0177] The receiving module 111 can receive a virtual address from the current process. The table acquisition module 112 can determine the address segment table and address segment attribute table corresponding to the current process based on the identification information of the current process. The first table lookup module 113 can search for base address information from the address segment table based on the first virtual address segment included in the virtual address. The base address information is used to indicate the base address of the target physical address space segment. The target physical address space segment is the physical address space segment where the physical address mapped to the virtual address is located. The second table lookup module 114 can search for offset information from the address segment attribute table based on the second virtual address segment included in the virtual address. The offset information is used to indicate the offset of the physical address mapped to the virtual address within the target physical address space segment. The integration module 115 can determine the physical address mapped to the virtual address based on the base address information and the offset information.

[0178] In an embodiment of the present application, the receiving module 111 can receive a virtual address from a process, the table acquisition module 112 can obtain an address segment table and an address segment attribute table corresponding to the process, the first table lookup module 113 can look up base address information from the address segment table based on the first virtual address segment included in the virtual address, the base address information can indicate the base address of the target physical address space segment where the physical address mapped to the virtual address is located, the second table lookup module 114 can look up offset information from the address segment attribute table based on the second virtual address segment included in the virtual address, the offset information can indicate the offset of the physical address mapped to the virtual address within the target physical address space segment, and then the integration module 115 can determine the physical address mapped to the virtual address based on the base address information and the offset information. Since the lookup process of the address segment table and the address segment attribute table can be performed in parallel, and the address segment table and the address segment attribute table are looked up respectively based on the first virtual address segment and the second virtual address segment, the lookup depth of the address segment table and the address segment attribute table can be reduced, and the time for looking up the address segment table and the address segment attribute table can be shortened, thereby improving the efficiency of mapping the virtual address to the physical address.

[0179] The memory management unit may be a system memory management unit (SMMU), an input / output memory management unit (IOMMU), or the like.

[0180] It should be noted that the memory management unit 110 of this embodiment is used to implement the memory address mapping method in the aforementioned method embodiment. The interaction between the various modules and units in the memory management unit 110 can be found in the description in the aforementioned image processing method embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.

[0181] electronic devices

[0182] Figure 13 This is a schematic block diagram of an electronic device provided in an embodiment of the present application. The specific embodiments of the present application do not limit the specific implementation of the electronic device. Figure 13 As shown, the electronic device may include: a processor 1202, a communications interface 1204, a memory 1206, and a communication bus 1208.

[0183] The processor 1202 , the communication interface 1204 , and the memory 1206 communicate with each other via a communication bus 1208 .

[0184] The communication interface 1204 is used to communicate with other electronic devices or servers.

[0185] The processor 1202 is used to execute the program 1210, and specifically can execute the relevant steps in any of the aforementioned memory address mapping method embodiments.

[0186] Specifically, the program 1210 may include program codes, which include computer operation instructions.

[0187] The processor 1202 may be a CPU, an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present application. The one or more processors included in the smart device may be processors of the same type, such as one or more CPUs, or may be processors of different types, such as one or more CPUs and one or more ASICs.

[0188] RISC-V is an open-source instruction set architecture based on the principles of the Reduced Instruction Set (RISC). It can be applied to various fields, including microcontrollers and FPGA chips. Specifically, it has applications in areas such as IoT security, industrial control, mobile phones, and personal computers. Designed with small size, high speed, and low power consumption in mind, it is particularly suitable for modern computing devices such as warehouse-scale cloud computers, high-end mobile phones, and tiny embedded systems. With the rise of the artificial intelligence (AI) Internet of Things (AIoT), the RISC-V instruction set architecture has also received increasing attention and support, and is expected to become the next generation of widely used CPU architecture.

[0189] The computer operation instructions in the embodiments of the present application may be computer operation instructions based on the RISC-V instruction set architecture. Correspondingly, the processor 1202 may be designed based on the RISC-V instruction set. Specifically, the processor chip in the electronic device provided in the embodiments of the present application may be a chip designed using the RISC-V instruction set. The chip may execute executable code based on the configured instructions, thereby implementing the memory address mapping method in the above embodiments.

[0190] The memory 1206 is used to store the program 1210. The memory 1206 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.

[0191] The program 1210 can be specifically used to enable the processor 1202 to execute the memory address mapping method in any of the aforementioned embodiments.

[0192] The specific implementation of each step in program 1210 can refer to the corresponding description of the corresponding steps and units in any of the aforementioned memory address mapping method embodiments, and will not be repeated here. Those skilled in the art will clearly understand that for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding process descriptions in the aforementioned method embodiments, and will not be repeated here.

[0193] Through the electronic device of the embodiment of the present application, based on the first virtual address segment included in the virtual address, the base address information is searched from the address segment table, and the base address information can indicate the base address of the target physical address space segment where the physical address mapped to the virtual address is located. Based on the second virtual address segment included in the virtual address, the offset information is searched from the address segment attribute table, and the offset information can indicate the offset of the physical address mapped to the virtual address within the target physical address space segment. Then, the physical address mapped to the virtual address can be determined based on the base address information and the offset information. Since the table lookup process of the address segment table and the address segment attribute table can be performed in parallel, and the address segment table and the address segment attribute table are searched respectively based on the first virtual address segment and the second virtual address segment, the table lookup depth of the address segment table and the address segment attribute table can be reduced, and the time for searching the address segment table and the address segment attribute table can be shortened, thereby improving the efficiency of mapping the virtual address to the physical address.

[0194] Computer storage media

[0195] The present application also provides a computer-readable storage medium storing instructions for causing a machine to execute the memory address mapping method described herein. Specifically, a system or device equipped with a storage medium can be provided, on which software program code implementing the functions of any of the above-described embodiments is stored, and a computer (or CPU or MPU) of the system or device can read and execute the program code stored in the storage medium.

[0196] In this case, the program code read from the storage medium itself can realize the function of any one of the above embodiments, so the program code and the storage medium storing the program code constitute part of this application.

[0197] Examples of storage media for providing program code include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code can be downloaded from a server computer via a communication network.

[0198] Computer program product

[0199] An embodiment of the present application also provides a computer program product, including computer instructions, which instruct a computing device to perform any corresponding operation in the above-mentioned multiple method embodiments.

[0200] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present application can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present application.

[0201] The above-mentioned method according to the embodiment of the present application can be implemented in hardware, firmware, or can be implemented as software or computer code that can be stored in a recording medium (such as CD ROM, RAM, floppy disk, hard disk or magneto-optical disk), or can be implemented as computer code that is originally stored in a remote recording medium or a non-temporary machine-readable medium downloaded via a network and will be stored in a local recording medium, so that the method described herein can be stored in such software processing on a recording medium using a general-purpose computer, a special-purpose processor or programmable or special-purpose hardware (such as ASIC or FPGA). It can be understood that a computer, a processor, a microprocessor controller or programmable hardware includes a storage component (e.g., RAM, ROM, flash memory, etc.) that can store or receive software or computer code, and when the software or computer code is accessed and executed by a computer, a processor or hardware, the method described herein is implemented. In addition, when a general-purpose computer accesses the code for implementing the method shown here, the execution of the code converts the general-purpose computer into a special-purpose computer for executing the method shown here.

[0202] It should be noted that the user-related information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to sample data used to train the model, data used for analysis, stored data, displayed data, etc.) involved in the embodiments of the present disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0203] It should be understood that the various embodiments in this specification are described in a progressive manner. References to the same or similar parts of each embodiment can be made to the other embodiments. The embodiments focus on the differences from other embodiments. In particular, the method embodiments are generally similar to the methods described in the device and system embodiments, so their description is relatively simple. For relevant details, references to the descriptions of other embodiments can be made.

[0204] It should be understood that the foregoing description of this specification is based on specific embodiments. Other embodiments are within the scope of the claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the embodiments and still achieve the desired results. Furthermore, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0205] It should be understood that an element described herein in the singular or shown in the drawings as only one does not limit the number of the element to one. In addition, modules or elements described or shown herein as separate may be combined into a single module or element, and modules or elements described or shown herein as single may be split into multiple modules or elements.

[0206] It should also be understood that the terms and expressions used herein are for descriptive purposes only, and the one or more embodiments of this specification should not be limited to these terms and expressions. The use of these terms and expressions does not mean to exclude any equivalent features of the illustrations and descriptions (or portions thereof), and it should be recognized that various modifications that may exist should also be included in the scope of the claims. Other modifications, variations, and substitutions may also exist. Accordingly, the claims should be deemed to cover all such equivalents.

Claims

1. A memory address mapping method, comprising: Receive the virtual address from the current process; Determining, based on the identification information of the current process, an address segment table and an address segment attribute table corresponding to the current process; searching, from the address segment table, for base address information according to a first virtual address segment included in the virtual address, the base address information being used to indicate a base address of a target physical address space segment, the target physical address space segment being a physical address space segment where a physical address mapped to the virtual address is located; searching, from the address segment attribute table, for offset information according to a second virtual address segment included in the virtual address, the offset information being used to indicate an offset of a physical address mapped to the virtual address within the target physical address space segment; A physical address mapped to the virtual address is determined according to the base address information and the offset information.

2. The method according to claim 1, wherein The address segment table corresponds to multiple processes including the current process, and different processes correspond to different address segment attribute tables.

3. The method according to claim 1, wherein The offset information is used to indicate an offset of a base address of a target physical address space subsegment relative to a base address of the target physical address space segment, the physical address mapped to the virtual address is located within the target physical address space subsegment, and the target physical address space segment includes the target physical address space subsegment; The determining, according to the base address information and the offset information, a physical address mapped to the virtual address includes: Adding the base address information to the offset information to obtain a base address of the target physical address space subsegment; Add the base address of the target physical address space sub-segment to the third virtual address segment included in the virtual address to obtain a physical address mapped to the virtual address, wherein the first virtual address segment, the second virtual address segment and the third virtual address segment are adjacent in sequence in the virtual address, and the third virtual address segment is located at the low bit of the virtual address.

4. The method according to claim 3, wherein: The address segment table is a linear table structure or a radix tree structure, and / or the address segment attribute table is a linear table structure or a radix tree structure.

5. The method according to claim 4, wherein If the address segment table has a radix tree structure, the address segment table includes at least two segment table levels, a first segment table level of the at least two segment table levels includes an address segment sub-table, and a non-first segment table level of the at least two segment table levels includes a plurality of address segment sub-tables, and the address segment sub-table includes a plurality of entries; Different entries in a last segment table level of the at least two segment table levels correspond to different physical address space segments, and the entry in the last segment table level is used to store at least a base address of the physical address space segment corresponding to the entry; The entry located in the non-last segment table level among the at least two segment table levels is used to store the base address of the address segment sub-table corresponding to the entry in the next segment table level, and different entries located in the same non-last segment table level correspond to different address segment sub-tables in the next segment table level.

6. The method according to claim 5, wherein: The searching base address information from the address segment table according to the first virtual address segment included in the virtual address includes: After shifting the virtual address subsegment corresponding to the i-th level segment table level in the first virtual address segment left by n bits, the virtual address subsegment is added to the base address of the i-th address segment subtable to obtain the i-th segment table entry address, and the base address of the i+1-th address segment subtable where the i-th segment table entry address is stored in the entry pointed to by the i-th address segment subtable is obtained, where i is a positive integer less than N, where N is equal to the number of segment table levels, the base address of the first address segment subtable is the physical base address of the address segment table, and the data length of the entry in the address segment table at the non-last level segment table level is 2 n byte; After shifting the virtual address sub-segment corresponding to the Nth level segment table level in the first virtual address segment left by n bits, the result is added to the base address of the Nth address segment sub-table to obtain the Nth segment table entry address, and the base address stored in the entry pointed to by the Nth address segment sub-table by the Nth segment table entry address is determined as the base address information.

7. The method according to claim 4, wherein: If the address segment attribute table is a radix tree structure, the address segment attribute table includes at least two attribute table levels, a first attribute table level in the at least two attribute table levels includes an attribute sub-table, and a non-first attribute table level in the at least two attribute table levels includes a plurality of attribute sub-tables, and the attribute sub-tables include a plurality of entries; Different entries at a last attribute table level of the at least two attribute table levels correspond to different physical address space subsegments, and the entry at the last attribute table level is used to store at least an offset of a base address of the physical address space subsegment corresponding to the entry relative to a base address of the physical address space segment in which the physical address space subsegment is located; The entry located in the non-last attribute table level among the at least two attribute table levels is used to store the base address of the attribute sub-table corresponding to the entry in the next attribute table level, and different entries located in the same non-last attribute table level correspond to different attribute sub-tables in the next attribute table level.

8. The method according to claim 7, wherein: The searching offset information from the address segment attribute table according to the second virtual address segment included in the virtual address includes: After the virtual address sub-segment corresponding to the j-th attribute table level in the second virtual address segment is shifted left by m bits, it is added to the base address of the j-th attribute sub-table to obtain the j-th attribute table entry address, and the base address of the j+1-th attribute sub-table where the entry pointed to by the j-th attribute sub-table is stored, j is a positive integer less than M, M is equal to the number of attribute table levels, the base address of the first attribute sub-table is the physical base address of the address segment attribute table, and the data length of the entry in the address segment attribute table at the non-last attribute table level is 2 m byte; After shifting the virtual address sub-segment corresponding to the M-th attribute table level in the second virtual address segment left by m bits, the sub-segment is added to the base address of the M-1th attribute sub-table to obtain the M-th attribute table entry address, and the offset of the M-th attribute table entry address stored in the entry pointed to by the M-th attribute sub-table is determined as the offset information.

9. The method according to any one of claims 1 to 8, further comprising: searching, from the address segment attribute table, for permission information according to the second virtual address segment, the permission information being used to indicate access rights of a physical address mapped to the virtual address, the permission information and the offset information being stored in the same entry included in the address segment attribute table; If it is determined according to the permission information that the current process has permission to access the physical address mapped to the virtual address, then the current process is allowed to access the physical address mapped to the virtual address; If it is determined according to the permission information that the current process does not have the permission to access the physical address mapped to the virtual address, the current process is denied access to the physical address mapped to the virtual address.

10. The method according to claim 2, wherein: The determining, based on the identification information of the current process, an address segment table and an address segment attribute table corresponding to the current process includes: According to the identification information of the current process, searching for the address segment identity information corresponding to the current process from a segment set table, wherein the segment set table stores a correspondence between the identification information of multiple processes and the address segment identity information, and the same address segment identity information in the segment set table corresponds to the identification information of at least one process; According to the address segment identity information corresponding to the current process, searching the address segment table base address corresponding to the current process from the segment configuration table, wherein the segment configuration table stores a correspondence between multiple address segment identity information and address segment table base addresses, and different address segment identity information corresponds to different address segment table base addresses; Determine the address segment table corresponding to the current process as the address segment table corresponding to the current process; According to the identification information of the current process, searching the attribute table base address corresponding to the current process from the attribute configuration table, wherein the attribute configuration table stores the correspondence between the identification information of multiple processes and the attribute table base addresses, and different identification information corresponds to different attribute table base addresses; The address segment attribute table whose corresponding base address is the base address of the attribute table corresponding to the current process is determined as the address segment attribute table corresponding to the current process.

11. The method according to claim 10, characterized in that The method further comprises: Searching for the base address information from a segment table lookup buffer according to the address segment identity information corresponding to the current process; The offset information is searched for in the attribute table buffer according to the identification information of the current process.

12. A memory management unit, comprising: A receiving module for receiving a virtual address from the current process; A table acquisition module, configured to determine an address segment table and an address segment attribute table corresponding to the current process according to identification information of the current process; a first table lookup module, configured to search, from the address segment table, for base address information according to a first virtual address segment included in the virtual address, the base address information being used to indicate a base address of a target physical address space segment, the target physical address space segment being a physical address space segment where a physical address mapped to the virtual address is located; a second table lookup module, configured to search the address segment attribute table for offset information according to a second virtual address segment included in the virtual address, the offset information being used to indicate an offset of a physical address mapped to the virtual address within the target physical address space segment; An integration module is used to determine a physical address mapped to the virtual address according to the base address information and the offset information.

13. An electronic device comprising: Processor, memory, communication interface and communication bus, the processor, memory and communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to any one of the methods according to claims 1-11.

14. A computer storage medium having a computer program stored thereon, wherein when the program is executed by a processor, the method according to any one of claims 1 to 11 is implemented.

15. A computer program product comprising computer instructions, the computer instructions instructing a computing device to perform the method according to any one of claims 1 to 11.

Citation Information

Cited By

  • Optimization method for high-speed read-write of memory

    CN122131986A