A memory management method and apparatus

By replacing the memory mapping request with a placeholder VMA or creating a new VMA to manage the overlapping region, the problem of gap exposure during memory mapping is solved, improving the security and stability of the operating system.

CN121364950BActive Publication Date: 2026-04-17NEW H3C TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
NEW H3C TECH CO LTD
Filing Date
2025-12-22
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Existing technologies may expose gaps due to overlapping virtual address ranges during memory mapping, leading to operating system security vulnerabilities and crashes.

Method used

When a forced memory mapping request is received, the first VMA managing the overlapping region is replaced with a placeholder VMA or a VMA created according to the mapping parameters. Then, the mapping relationship is removed from the page table and the new mapping relationship is recorded to ensure that the overlapping region is always managed by a VMA.

Benefits of technology

This avoids the exposure of gaps in the memory management process, improving the security and robustness of the operating system, especially in high-security and high-concurrency scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121364950B_ABST
    Figure CN121364950B_ABST
Patent Text Reader

Abstract

This invention provides a memory management method and apparatus, relating to the field of computer technology. The method includes: receiving a forced memory mapping request for a target virtual address range; locking the target virtual address range; determining a first Virtual Address Management (VMA) for managing overlapping ranges; replacing the determined first VMA with a second VMA; removing a first mapping relationship between the overlapping range and the mapped physical memory region from the page table; if the second VMA is the VMA corresponding to the overlapping range, recording a second mapping relationship between the VMA corresponding to the overlapping range and the new physical memory region indicated by the forced memory mapping request in the page table; if the second VMA is a placeholder VMA, replacing the placeholder VMA with the VMA corresponding to the overlapping range and recording the second mapping relationship in the page table; and unlocking the target virtual address range. Applying the memory management scheme provided in this application can improve the security of the operating system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and in particular to a memory management method and apparatus. Background Technology

[0002] Operating systems employing virtual memory management allocate independent virtual address ranges to each process. Through memory mapping operations, these allocated virtual address ranges are mapped to physical memory regions. This allows the processes to access the mapped physical memory regions by accessing the allocated virtual address ranges. To facilitate the management of the virtual address ranges allocated to each process, the operating system records the mapping relationship between the virtual address ranges allocated to processes and the physical memory regions in a page table and creates a Virtual Memory Area (VMA) for each process, managing the virtual address ranges allocated to the process through the VMA.

[0003] When performing a memory mapping operation on a virtual address range, this range may overlap with the virtual address range currently managed by the valid Virtual Address Management (VMA). In this case, during the memory mapping process using related technologies, there may be brief periods where the virtual address range is not managed by the VMA, resulting in gap exposure. This can lead to security vulnerabilities in the operating system, and in severe cases, may cause application malfunctions or operating system crashes. Summary of the Invention

[0004] The purpose of this invention is to provide a memory management method and apparatus to improve the security of the operating system. The specific technical solution is as follows:

[0005] In a first aspect, embodiments of this application provide a memory management method, the method comprising:

[0006] Receive a forced memory mapping request for a target virtual address range and lock the target virtual address range;

[0007] Determine the first VMA that manages the overlapping interval, wherein the overlapping interval is: the interval that overlaps between the virtual address interval managed by the currently effective VMA and the target virtual address interval;

[0008] The determined first VMA is replaced with the second VMA, wherein the second VMA is: a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is: a VMA created according to the mapping parameters carried by the forced memory mapping request for managing the overlapping interval;

[0009] Remove the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table;

[0010] If the second VMA is the VMA corresponding to the overlapping interval, then the second mapping relationship between the overlapping interval and the new physical memory region indicated by the forced memory mapping request is recorded in the page table;

[0011] If the second VMA is the placeholder VMA, then the placeholder VMA is replaced with the VMA corresponding to the overlapping interval, and the second mapping relationship is recorded in the page table;

[0012] Unlock the target virtual address range.

[0013] In one embodiment of this application, determining the first VMA for managing the overlapping interval includes:

[0014] Among the currently valid VMAs, identify candidate VMAs whose managed virtual address range overlaps with the target virtual address range;

[0015] If a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then a third VMA is segmented from the candidate VMA and used as the first VMA, wherein the third VMA manages the portion of the virtual address range.

[0016] If the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then the candidate VMA is determined to be the first VMA.

[0017] In one embodiment of this application, after segmenting the third VMA from the candidate VMA, the method further includes:

[0018] In the page table, the mapping relationship between the partial range and the mapped physical memory region is segmented from the mapping relationship between the virtual address range managed by the candidate VMA and the mapped physical memory region.

[0019] In one embodiment of this application, the step of removing the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table includes:

[0020] The first mapping relationship between the overlapping interval and the mapped physical memory region is moved from the page table to the list to be cleaned up.

[0021] Page table entry cleanup is performed on the first mapping relationship recorded in the list to be cleaned, on a unit basis.

[0022] In one embodiment of this application, after replacing the determined first VMA with the second VMA, the method further includes:

[0023] If the mapping type recorded in the first VMA is a file mapping type, remove the association between the file mapped by the first VMA and the first VMA.

[0024] Secondly, embodiments of this application provide a memory management device, the device comprising:

[0025] The request receiving module is used to receive a forced memory mapping request for a target virtual address range and lock the target virtual address range.

[0026] The VMA determination module is used to determine the first VMA that manages the overlapping interval, wherein the overlapping interval is the interval between the virtual address interval managed by the currently effective VMA and the target virtual address interval;

[0027] The VMA replacement module is used to replace the determined first VMA with a second VMA, wherein the second VMA is: a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is: a VMA created according to the mapping parameters carried by the forced memory mapping request for managing the overlapping interval;

[0028] The relationship removal module is used to remove the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table;

[0029] The first recording module is used to record a second mapping relationship between the overlapping interval and the new physical memory region indicated by the forced memory mapping request in the page table when the second VMA is the VMA corresponding to the overlapping interval.

[0030] The second recording module is used to replace the placeholder VMA with the VMA corresponding to the overlapping interval when the second VMA is the placeholder VMA, and record the second mapping relationship in the page table;

[0031] The range unlocking module is used to unlock the target virtual address range.

[0032] In one embodiment of this application, the VMA determination module is specifically used for:

[0033] Among the currently valid VMAs, identify candidate VMAs whose managed virtual address range overlaps with the target virtual address range;

[0034] If a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then a third VMA is segmented from the candidate VMA and used as the first VMA, wherein the third VMA manages the portion of the virtual address range.

[0035] If the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then the candidate VMA is determined to be the first VMA.

[0036] In one embodiment of this application, the apparatus further includes:

[0037] The relationship segmentation module is used to, after the third VMA is segmented from the candidate VMA, segment the mapping relationship between the partial range and the mapped physical memory region from the mapping relationship between the virtual address range managed by the candidate VMA and the mapped physical memory region in the page table.

[0038] In one embodiment of this application, the relationship termination module is specifically used for:

[0039] The first mapping relationship between the overlapping interval and the mapped physical memory region is moved from the page table to the list to be cleaned up.

[0040] Page table entry cleanup is performed on the first mapping relationship recorded in the list to be cleaned, on a unit basis.

[0041] In one embodiment of this application, the apparatus further includes:

[0042] The relationship removal module is used to remove the association between the file mapped by the first VMA and the first VMA after the determined first VMA is replaced with the second VMA, provided that the mapping type recorded in the first VMA is a file mapping type.

[0043] Thirdly, embodiments of this application provide an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0044] Memory, used to store computer programs;

[0045] When a processor executes a program stored in memory, it implements any of the steps described in the first aspect above.

[0046] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the steps described in the first aspect above.

[0047] Beneficial effects of the embodiments of the present invention:

[0048] As can be seen from the above, when managing memory using the solution provided in the embodiments of this application, after receiving a forced memory mapping request, a first VMA for managing the overlapping region is determined. The region managed by the first VMA belongs to the target virtual address region targeted by the forced memory mapping request, and the overlapping region has actually established a mapping relationship. When re-establishing the mapping relationship of the overlapping region in the target virtual address region based on the forced memory mapping request, the first VMA is first replaced with a placeholder VMA or a VMA created according to the mapping parameters in the request for managing the overlapping region. Then, the first mapping relationship of the overlapping region is removed from the page table, and the second mapping relationship is re-recorded in the page table.

[0049] Compared to first deleting the first VMA and unmapping the first mapping relationship, then creating a new VMA and recording the second mapping relationship, this method results in gaps being exposed because the overlapping interval is unmanaged during the time between deleting the first VMA and creating the new VMA. In contrast, this solution replaces the first VMA with the second VMA before unmapping the mapping relationship. If the second VMA is a placeholder VMA, it will be replaced again with the VMA corresponding to the overlapping interval. Throughout this process, it ensures that a VMA is always present to manage the overlapping interval, and the same applies if the second VMA is the VMA corresponding to the overlapping interval. Therefore, applying the memory management scheme provided in this application's embodiments prevents gap exposure during the entire request processing process, thereby avoiding security vulnerabilities in the operating system and improving operating system security. Attached Figure Description

[0050] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other embodiments can be obtained based on these drawings.

[0051] Figure 1 A schematic diagram illustrating the relationship between VMA, virtual address range, page table, and physical memory region provided in the embodiments of this application;

[0052] Figure 2 A flowchart illustrating the first memory management method provided in this application embodiment;

[0053] Figure 3 A schematic diagram illustrating the distribution of virtual address ranges provided in this application embodiment;

[0054] Figure 4 This is a schematic diagram of a maple tree data structure provided in an embodiment of this application;

[0055] Figure 5a This is a schematic diagram of the first mapping relationship provided in the embodiments of this application;

[0056] Figure 5b This is a schematic diagram of a second mapping relationship provided in an embodiment of this application;

[0057] Figure 6 A flowchart illustrating the second memory management method provided in this application embodiment;

[0058] Figure 7 This is a schematic diagram of the structure of a memory management device provided in an embodiment of this application;

[0059] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0060] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art based on this application are within the scope of protection of the present invention.

[0061] First, some concepts mentioned in the embodiments of this application will be explained.

[0062] 1. VMA

[0063] Virtual Address Maps (VMAs) are the basic units used by the operating system kernel (such as Linux) to manage the virtual address ranges of processes. Each VMA represents a contiguous range within a process's virtual address range. The operating system kernel uses VMAs to record information such as the starting address, length, permissions, and mapping type of this range. Efficient VMA management is crucial for implementing functions such as process isolation, memory allocation and reclamation, and memory access permission control.

[0064] See Figure 1 It illustrates the relationship between VMA, virtual address ranges, page tables, and physical memory regions, from... Figure 1 As can be seen, VMA is used to manage virtual address ranges. The page table records the mapping relationship between virtual address ranges and physical memory regions. When a process receives a memory access request, after the VMA verifies the request for permissions, identity, etc., it can read the mapping relationship recorded in the page table, determine the physical memory region mapped by the process's virtual address range based on the mapping relationship, and thus obtain the data stored in the determined physical memory region.

[0065] 2. Mapping type

[0066] Mapping type is one of the information recorded in VMA, including file mapping and anonymous mapping.

[0067] Applications can use the `mmap()` system call to request the allocation or mapping of a specified virtual memory region from the operating system, thereby achieving flexible management of memory resources. The relevant code for creating a new memory mapping within the calling process's virtual address space using the `mmap()` method is as follows:

[0068] viod mmap(size_t length);

[0069] void addr[length], size_t length, int prot, int flags,

[0070] (int fd, dff_t offset);

[0071] In the code above, if the fd parameter specifies an open file or device, mmap() will map a section of the file's content to the process's virtual address range, so that access to this virtual memory directly affects the file content through the page cache. This mapping is called file mapping.

[0072] If the fd parameter is -1 and MAP_ANINYMOUS is specified, a memory region not associated with any file is created. This type of mapping is called anonymous mapping and is often used to allocate private memory.

[0073] Additionally, in the code above, the addr parameter is the desired starting address for the mapping (if this parameter is set to NULL, the kernel will automatically select an appropriate address).

[0074] The length parameter is the length of the mapped bytes. This parameter must be greater than 0 and is usually aligned to the page size.

[0075] Other parameters (such as prot and flags) are used to determine mapping permissions and shared / private attributes.

[0076] The memory management method provided in this application will be described below through specific embodiments.

[0077] See Figure 2 , Figure 2 This is a flowchart illustrating a first memory management method provided in an embodiment of this application. In this embodiment, the method includes the following steps S201-S207.

[0078] Step S201: Receive a forced memory mapping request for the target virtual address range and lock the target virtual address range.

[0079] The aforementioned forced memory mapping request is used to forcibly establish a mapping relationship between the target virtual address range and physical memory. If the target virtual address range has already established a memory mapping relationship with a segment of physical memory, it is necessary to remove the memory mapping relationship between the target virtual address range and that physical memory, and re-establish the memory mapping relationship between the target virtual range and other physical memory according to the forced memory mapping request.

[0080] For example, in the mmap() system call, the MAP_FIXED flag is widely used to request the operating system to forcibly map a specified physical memory region to a user-provided virtual address range. This requirement is particularly common in embedded development, runtime memory layout optimization, hardware interface programming, and high-performance computing scenarios. When an application calls mmap() and sets the MAP_FIXED flag, the operating system attempts to forcibly map the specified memory region to the virtual address range specified in mmap(). If this virtual address range is already occupied by another memory mapping, the operating system will unmap the existing mapping and replace it with a new one.

[0081] After receiving a forced memory mapping request, the operating system can parse the request, obtain the target virtual address range, and lock the target virtual address range to prevent other threads or processes from accessing or concurrently modifying the target virtual address range during the management process, thus ensuring mutual exclusion of operations.

[0082] In one embodiment of this application, the operating system can perform write-mode memory mapping locking (mmap_lock) on the target virtual address range.

[0083] Alternatively, the operating system can lock the memory mapping in two modes: reading and writing, for the target virtual address range.

[0084] Step S202: Determine the first VMA for managing the overlapping interval.

[0085] The overlapping interval is the interval that overlaps between the currently valid virtual address interval managed by VMA and the target virtual address interval.

[0086] Each currently active Virtual Address Management (VMA) manages its own virtual address range. The operating system can determine the overlapping range with the target virtual address range within the virtual address range managed by the currently active VMA. The determined range is the overlapping range, and the VMA managing the overlapping range is then identified as the first VMA.

[0087] See Figure 3 , Figure 3 This shows the range distribution of virtual address ranges currently under effective VMAs. Figure 3 In the given information, the virtual address range managed by effective VMA1 is 0x0000-0x1000, that of effective VMA2 is 0x1000-0x2000, that of effective VMA3 is 0x2000-0x3000, and that of effective VMA4 is 0x7000-0x8000. If the target virtual address range is 0x0000-0x5000, then the overlapping range between the target virtual address range and the range managed by each effective VMA is 0x0000-0x3000. Therefore, effective VMA1, effective VMA2, and effective VMA3 can be identified as the first VMA.

[0088] In one embodiment of this application, the operating system uses a maple tree data structure to manage the virtual address range of each process. The terminal child node of each branch in the maple tree corresponds to the valid VMA. When determining the first VMA, the system can search for the node corresponding to the overlapping range in the maple tree according to the target virtual address range, and determine the VMA corresponding to the searched node as the first VMA.

[0089] See Figure 4 , Figure 4 This is a schematic diagram of a maple tree data structure. Figure 4 In the diagram, the root node records three virtual addresses: 24, 44, and 99. Below the root node are three other nodes: the first records 17 and 24, corresponding to the virtual address range 17-24; the second records 34 and 44, corresponding to the virtual address range 34-44; and the third records 54, 64, and 74. Below the third node are two child nodes: the first records 45 and 50, corresponding to the virtual address range 45-50; and the second records 55 and 60, corresponding to the virtual address range 55-60. Figure 4 When searching for the target address range 17-50 in the map tree shown, the nodes corresponding to the three virtual address ranges 17-24, 34-44, and 45-50 can be found, thus determining that the VMA corresponding to these three nodes is the first VMA.

[0090] When using a maple tree data structure to manage the virtual address ranges of each process, after obtaining the aforementioned forced memory mapping request, the maple tree data structure can be locked. After parsing the target virtual address range from the forced memory mapping request, the target virtual address range can be locked again. After the request is processed, the target virtual address range and the maple tree data structure can be unlocked.

[0091] Step S203: Replace the determined first VMA with the second VMA.

[0092] The second VMA is: a preset placeholder VMA or the VMA corresponding to the overlapping interval.

[0093] The two cases of the second VMA will be explained below.

[0094] 1. The second VMA is a placeholder VMA.

[0095] The aforementioned placeholder VMAs are pre-generated VMAs used to prevent virtual address ranges from being unmanaged by VMAs.

[0096] Specifically, the first VMA is a valid VMA, and the overlapping region managed by the first VMA already has a memory mapping relationship. When a forced memory mapping request is made to re-establish the mapping relationship for the overlapping region, the VMA managing the overlapping region also needs to be re-established. If the first VMA is directly removed after its identification, and a new VMA is subsequently created, the overlapping region will be without VMA management during the period between removing the first VMA and creating the new VMA. In this case, malicious processes or attackers can directly access the overlapping region without hindrance, reading and modifying the data on the physical memory mapped by the overlapping region, thus causing security risks such as data leakage, privilege escalation, and system crashes. Therefore, when removing the first VMA, a pre-generated placeholder VMA can be used to replace it first, and then the placeholder VMA can be replaced with the new VMA later. This ensures that VMA management always exists in the overlapping region.

[0097] If multiple first VMAs are identified, each first VMA can be replaced with a placeholder VMA.

[0098] 2. The second VMA is the VMA corresponding to the overlapping interval.

[0099] The VMA corresponding to the overlapping interval is: a VMA created based on the mapping parameters carried by the forced memory mapping request to manage the overlapping interval.

[0100] The mapping parameters mentioned above can include the mapping address, byte length, mapping permissions, shared / private attributes, etc.

[0101] Specifically, after receiving the aforementioned forced memory mapping request, the forced memory mapping request is parsed to obtain the mapping parameters carried in the request. When the first VMA is determined in step S202, the overlapping interval is also determined. Thus, based on the obtained mapping parameters and the overlapping interval, a VMA for managing the overlapping interval can be created, that is, a VMA corresponding to the overlapping interval is created, thereby replacing the first VMA with the VMA corresponding to the overlapping interval.

[0102] If multiple first VMAs are identified, for each first VMA, a VMA corresponding to the overlapping interval managed by that first VMA can be created, and then the first VMA can be replaced with the VMA corresponding to the overlapping interval created. Multiple first VMAs are then replaced with VMAs corresponding to multiple overlapping intervals.

[0103] Step S204: Remove the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table.

[0104] The page table mentioned above is used to record the mapping relationship between virtual address ranges and physical memory regions.

[0105] After replacing the first VMA with the second VMA, the mapping relationship corresponding to the overlapping interval managed by the first VMA can be retrieved in the page table. After the mapping relationship corresponding to the overlapping interval is retrieved, the mapping relationship is removed from the page table.

[0106] There may be one or more first VMAs. Each first VMA manages a virtual address range. The page table also records the first mapping relationship of the virtual address range managed by each VMA. Therefore, the first mapping relationship can be terminated in either of the following two ways.

[0107] In the first approach, the first mapping relationship between the overlapping interval and the mapped physical memory region can be migrated from the page table to the cleanup list; page table entries are cleaned up on a per-cleanup list basis, recording the first mapping relationship in the cleanup list.

[0108] This approach first migrates all first mapping relationships to the cleanup list. Then, by performing page table cleanup operations on the cleanup list, all first mapping relationships can be removed at once, achieving atomic operations on all first mapping relationships. This ensures that the removal process is not interrupted or interfered with by other operations, ensuring that the entire removal process is completed as an indivisible whole. This also guarantees that no gaps will be exposed during the operation, ensuring the consistency and security of memory space and eliminating the risks of race conditions and data inconsistency.

[0109] In the second method, the first mapping relationship of each virtual address range managed by the first VMA can be released one by one.

[0110] After the first mapping relationship is released, the physical memory area recorded in the first mapping relationship is no longer restricted by the mapping relationship. Therefore, releasing the first mapping relationship also releases the physical memory area recorded in the first mapping relationship.

[0111] In one embodiment of this application, when the mapping type recorded in the first VMA is a file mapping type, in addition to removing the first mapping relationship from the page table, it is also necessary to remove the association between the file mapped by the first VMA and the first VMA.

[0112] For example, the operating system can call a file unmapping callback function to remove the association between the file mapped by the first VMA and the first VMA.

[0113] The solution provided in this application can remove the mapping and association relationships of VMAs under file mapping types and execute subsequent steps to complete the processing of forced memory mapping requests. Therefore, the memory management solution provided in this application can manage virtual address ranges under multiple mapping types, including file mapping types, and has a wide range of applicability.

[0114] After completing all operations such as unmapping mappings and releasing physical memory related to the first VMAs, the operating system kernel can release the virtual address ranges of all first VMAs back to the operating system kernel's memory allocation subsystem and update relevant memory statistics to facilitate subsequent management and allocation of free memory.

[0115] Step S205: If the second VMA is the VMA corresponding to the overlapping interval, then record the second mapping relationship between the overlapping interval and the new physical memory region indicated by the forced memory mapping request in the page table.

[0116] Specifically, by parsing the forced memory mapping request, the new physical memory region indicated by the forced memory mapping request can be obtained. After the first mapping relationship corresponding to the overlapping interval is removed in the page table, the second mapping relationship between the overlapping interval and the new physical memory region can be recorded again in the page table.

[0117] Step S206: If the second VMA is a placeholder VMA, then replace the placeholder VMA with the VMA corresponding to the overlapping interval, and record the second mapping relationship in the page table.

[0118] In the case of a placeholder VMA in the second VMA bit, after the mapping relationship is removed from the page table, the VMA that manages the overlapping interval is still a placeholder VMA. Therefore, the VMA corresponding to the overlapping interval can be created, the placeholder VMA can be replaced with the VMA corresponding to the overlapping interval, and the second mapping relationship can be recorded in the page table.

[0119] Step S207: Unlock the target virtual address range.

[0120] As can be seen from the above, when managing memory using the solution provided in the embodiments of this application, after receiving a forced memory mapping request, a first VMA for managing the overlapping region is determined. The region managed by the first VMA belongs to the target virtual address region targeted by the forced memory mapping request, and the overlapping region has actually established a mapping relationship. When re-establishing the mapping relationship of the overlapping region in the target virtual address region based on the forced memory mapping request, the first VMA is first replaced with a placeholder VMA or a VMA created according to the mapping parameters in the request for managing the overlapping region. Then, the first mapping relationship of the overlapping region is removed from the page table, and the second mapping relationship is re-recorded in the page table.

[0121] Compared to first deleting the first VMA and unmapping the first mapping relationship, then creating a new VMA and recording the second mapping relationship, this method results in gap exposure due to the lack of VMA management in the overlapping area during the time between deleting the first VMA and creating the new VMA. However, this solution replaces the first VMA with the second VMA before unmapping the mapping relationship. If the second VMA is a placeholder VMA, it will be replaced again with the VMA corresponding to the overlapping area. Throughout the entire process, it ensures that a VMA always exists to manage the overlapping area, and the same applies if the second VMA is the VMA corresponding to the overlapping area. Therefore, the memory management solution provided in this application avoids gap exposure during the entire request processing process, does not affect the compatibility and performance of the mmap() interface, and thus prevents operating system security vulnerabilities. It improves the security, reliability, and robustness of operating system memory management, particularly effectively enhancing the security and robustness of the operating system kernel in high-security and high-concurrency scenarios, and promoting the widespread adoption of cloud computing, big data, and high-security systems.

[0122] Furthermore, since this solution directly replaces the first VMA with the second VMA after the first VMA is determined, during the entire memory management process, external processes or external visitors can either traverse the application to find out that the overlapping region is managed by the first VMA or by the second VMA. There will never be a situation where the overlapping region is traversed but there is no VMA managing it. It can be seen from the perspective of external processes or external visitors that adopting this solution can avoid the situation where gaps are exposed in the operating system.

[0123] The first VMA mentioned above can be determined in the manner described in the following embodiments.

[0124] In one embodiment of this application, when determining the first VMA, candidate VMAs whose managed virtual address ranges overlap with the target virtual address range can be identified among the currently valid VMAs. If a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, a third VMA is segmented from the candidate VMA and used as the first VMA. If the entire virtual address range managed by the candidate VMA overlaps with the target virtual address range, the candidate VMA is determined as the first VMA.

[0125] The third VMA manages the aforementioned intervals.

[0126] Specifically, within the virtual address range managed by the currently valid VMA, an overlapping range that overlaps with the target virtual address range can be identified. Among the currently valid VMAs, those VMAs whose managed virtual address ranges contain the overlapping range can be identified as candidate VMAs.

[0127] by Figure 3 Taking the effective VMAs shown as examples, if the target virtual address range is 0x1000-0x7500, then among the virtual address ranges managed by effective VMA1, effective VMA2, effective VMA3, and effective VMA4, the overlapping ranges that overlap with the target virtual address range are 0x1000-0x2000, 0x2000-0x3000, and 0x7000-0x7500. Among them, 0x1000-0x2000 is the virtual address range managed by effective VMA2, 0x2000-0x3000 is the virtual address range managed by effective VMA3, and 0x7000-0x7500 is a part of the virtual address range 0x7000-0x8000 managed by effective VMA4. Therefore, effective VMA2, effective VMA3, and effective VMA4 can be identified as candidate VMAs.

[0128] After the candidate VMA is determined, if a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then the third VMA is segmented from the candidate VMA and used as the first VMA.

[0129] When segmenting a VMA, a third VMA that manages the aforementioned partial interval and a fourth VMA that manages the aforementioned non-overlapping interval can be generated based on the aforementioned partial interval and the non-overlapping interval in the virtual address interval managed by the candidate VMA, and only the third VMA is used as the first VMA.

[0130] If the virtual address range managed by the candidate VMA overlaps with the overall target virtual address range, then the candidate VMA is directly adopted as the first VMA.

[0131] In the example above, the virtual address range managed by the effective VMA4 partially overlaps with the target virtual address range. The overlapping range is 0x7000-0x7500. The non-overlapping range of the virtual address range managed by the effective VMA4, excluding this overlapping range, is 0x7500-0x8000. Therefore, a third VMA managing 0x7000-0x7500 and a fourth VMA managing 0x7500-0x8000 can be generated, and the third VMA managing 0x7000-0x7500 can be used as the first VMA.

[0132] The virtual address ranges managed by effective VMA2 and effective VMA3 overlap with the target virtual address range. Therefore, effective VMA2 and effective VMA3 can be directly identified as the first VMA.

[0133] As can be seen from the above, when managing memory using the scheme provided in the embodiments of this application, for VMAs that partially overlap with the target virtual address range, the operating system can segment out the VMAs that manage the overlapping portion of the VMA, and then determine the segmented VMA as the first VMA. For VMAs that completely overlap with the target virtual address range, the VMA is directly determined as the first VMA. This can accurately determine the first VMA, and memory management can be performed based on the first VMA, thereby improving the accuracy of memory management.

[0134] In cases where a portion of the virtual address range managed by a candidate VMA overlaps with the target virtual address range, the method described in the following embodiments can be performed after the third VMA is segmented from the candidate VMA.

[0135] In one embodiment of this application, after the third VMA is segmented from the candidate VMA, the mapping relationship between the aforementioned portion of the range and the mapped physical memory region can be segmented from the mapping relationship between the virtual address range managed by the candidate VMA and the mapped physical memory region in the page table.

[0136] Specifically, the candidate VMA can be divided into a third VMA and a fourth VMA. The third VMA manages the portion of the candidate VMA's managed range that overlaps with the target virtual address range. The fourth VMA manages the non-overlapping portions of the candidate VMA's managed range, excluding the third VMA's managed range. After dividing the candidate VMA into the third VMA, the physical memory regions mapped to the aforementioned portion of the managed range (referred to as the first physical memory region) and the physical memory regions mapped to the aforementioned non-overlapping portions (referred to as the second physical memory region) can be determined based on the mapping relationships of the portions managed by the candidate VMA recorded in the page table. This splits the original set of mapping relationships into two sets: one set between the aforementioned portion of the managed range and the first physical memory region, and the other set between the aforementioned non-overlapping portions and the second physical memory region. The mapping relationship between the portion of the managed range and the first physical memory region is the mapping relationship between the divided portion of the managed range and the mapped physical memory region, and this mapping relationship is the first mapping relationship to be de-de-escalated.

[0137] See Figure 5a , Figure 5a It shows Figure 3 The mapping relationship between the virtual address range managed by VMA4 and the mapped physical memory region is valid in [the context of the VMA4 implementation]. Figure 5a In the database, there is a mapping relationship between the virtual address range 0x7000-0x8000 and the physical memory region 0x4000-0x5000. The operating system can split this mapping relationship into two sets of mapping relationships, such as... Figure 5b As shown, the first set of mapping relationships is the mapping between the overlapping interval 0x7000-0x7500 and the physical memory region 0x4000-0x4500. The second set of mapping relationships is the mapping between the non-overlapping interval 0x7500-0x8000 and the physical memory region 0x4500-0x5000. The first set of mapping relationships specifically represents the mapping between the segmented intervals and the mapped physical memory regions.

[0138] As can be seen from the above, when managing memory using the scheme provided in the embodiments of this application, after the third VMA is segmented from the candidate VMA, in the page table, the mapping relationship between a portion of the virtual address range managed by the candidate VMA and the mapped physical memory region is segmented. This allows the first mapping relationship between the overlapping range and the mapped physical memory region to be accurately determined in the page table, thereby releasing the first mapping relationship and performing subsequent processing. This enables accurate memory management and improves the security of the operating system.

[0139] During memory management, the virtual address range managed by all valid VMAs may not completely cover the target virtual address range. In the above... Figure 3 For example, if the target virtual address range is 0x1000-0x7500, then the range covered by all valid virtual address ranges managed by VMAs is 0x1000-0x3000 and 0x7000-0x7500. Other ranges in the target virtual address range, 0x3000-0x7000, have not yet been assigned to VMAs for management, and there is no mapping relationship for the range 0x3000-0x7000 in the page table.

[0140] Therefore, for the overlapping regions covered by the target virtual address range, the aforementioned steps S202-S204 can be used for processing. For the remaining regions in the target virtual address range excluding the overlapping regions, a VMA managing these remaining regions can be directly created based on the mapping parameters carried in the forced memory mapping request. Furthermore, since the page table does not record the mapping relationship of these remaining regions, and the overlapping region's mapping relationship is released by executing step S204, the page table does not record the mapping relationship of the entire target virtual address range after step S204 is executed. Therefore, when executing step S205 or step S206 to record the second mapping relationship, the mapping relationship between the entire target virtual address range and the new physical memory region can be directly recorded in the page table.

[0141] In the above Figure 3 In the example, the overlapping intervals are 0x1000-0x2000, 0x2000-0x3000, and 0x7000-0x7500. The page table originally recorded the mapping relationship of these three intervals, but did not record the mapping relationship of 0x3000-0x7000. After executing the above step S204 to remove the mapping relationship of the above three intervals, the page table no longer records the mapping relationship of the entire target virtual address space of 0x1000-0x7500. Therefore, when recording the second mapping relationship later, the mapping relationship of 0x1000-0x7500 can be directly recorded in the page table.

[0142] Furthermore, when using a maple tree data structure to manage the virtual address ranges of each process, after the aforementioned VMA replacement and creation, the entire target virtual address range is actually managed by VMAs, with multiple VMAs each managing a portion of the target virtual address range. Thus, after the VMA replacement and creation, the maple tree data structure can, based on the virtual address ranges managed by each valid VMA, integrate the nodes corresponding to the VMAs managing different portions of the target virtual address range into a single node corresponding to the target virtual address range. Simultaneously, the mapping relationship corresponding to this single target virtual address range is recorded in the page table.

[0143] In one embodiment of this application, see Figure 6 , Figure 6 This is a flowchart illustrating a second memory management method provided in an embodiment of this application. In this embodiment, the method includes the following steps S601-S611.

[0144] Step S601: Receive a forced memory mapping request for the target virtual address range;

[0145] Step S602: Parse the forced memory mapping request to obtain the target virtual address range;

[0146] Step S603: Lock the target virtual address range;

[0147] Step S604: Determine the first VMA for managing the overlapping interval;

[0148] Step S605: Replace the determined first VMA with the second VMA;

[0149] Step S606: Check if the replacement was successful. If the replacement was successful, proceed to step S608. If the replacement failed, proceed to step S607.

[0150] Step S607: Return error message, end;

[0151] For example, it can return error messages indicating that the request response failed, the VMA replacement failed, etc.

[0152] Step S608: Remove the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table;

[0153] Step S609: If the second VMA is the VMA corresponding to the overlapping interval, then record the second mapping relationship between the overlapping interval and the new physical memory region indicated by the forced memory mapping request in the page table; if the second VMA is a placeholder VMA, then replace the placeholder VMA with the VMA corresponding to the overlapping interval, and record the second mapping relationship in the page table.

[0154] Step S610: Unlock the target virtual address range;

[0155] Step S611: Return the mapping result and end.

[0156] Corresponding to the memory management method described above, this application also provides a memory management device.

[0157] In one embodiment of this application, see Figure 7 A memory management device is provided, the device comprising:

[0158] The request receiving module 701 is used to receive a forced memory mapping request for a target virtual address range and lock the target virtual address range;

[0159] VMA determination module 702 is used to determine a first VMA that manages an overlapping interval, wherein the overlapping interval is: the interval that overlaps between the virtual address interval managed by the currently effective VMA and the target virtual address interval;

[0160] VMA replacement module 703 is used to replace the determined first VMA with a second VMA, wherein the second VMA is: a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is: a VMA created according to the mapping parameters carried by the forced memory mapping request for managing the overlapping interval;

[0161] The relationship removal module 704 is used to remove the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table;

[0162] The first recording module 705 is used to record a second mapping relationship between the overlapping interval and the new physical memory region indicated by the forced memory mapping request in the page table when the second VMA is the VMA corresponding to the overlapping interval.

[0163] The second recording module 706 is used to replace the placeholder VMA with the VMA corresponding to the overlapping interval when the second VMA is the placeholder VMA, and record the second mapping relationship in the page table;

[0164] The range unlocking module 707 is used to unlock the target virtual address range.

[0165] As can be seen from the above, when managing memory using the solution provided in the embodiments of this application, after receiving a forced memory mapping request, a first VMA for managing the overlapping region is determined. The region managed by the first VMA belongs to the target virtual address region targeted by the forced memory mapping request, and the overlapping region has actually established a mapping relationship. When re-establishing the mapping relationship of the overlapping region in the target virtual address region based on the forced memory mapping request, the first VMA is first replaced with a placeholder VMA or a VMA created according to the mapping parameters in the request for managing the overlapping region. Then, the first mapping relationship of the overlapping region is removed from the page table, and the second mapping relationship is re-recorded in the page table.

[0166] Compared to first deleting the first VMA and unmapping the first mapping relationship, then creating a new VMA and recording the second mapping relationship, this method results in gap exposure due to the lack of VMA management in the overlapping area during the time between deleting the first VMA and creating the new VMA. However, this solution replaces the first VMA with the second VMA before unmapping the mapping relationship. If the second VMA is a placeholder VMA, it will be replaced again with the VMA corresponding to the overlapping area. Throughout the entire process, it ensures that a VMA always exists to manage the overlapping area, and the same applies if the second VMA is the VMA corresponding to the overlapping area. Therefore, the memory management solution provided in this application avoids gap exposure during the entire request processing process, does not affect the compatibility and performance of the mmap() interface, and thus prevents operating system security vulnerabilities. It improves the security, reliability, and robustness of operating system memory management, particularly effectively enhancing the security and robustness of the operating system kernel in high-security and high-concurrency scenarios, and promoting the widespread adoption of cloud computing, big data, and high-security systems.

[0167] Furthermore, since this solution directly replaces the first VMA with the second VMA after the first VMA is determined, during the entire memory management process, external processes or external visitors can either traverse the application to find out that the overlapping region is managed by the first VMA or by the second VMA. There will never be a situation where the overlapping region is traversed but there is no VMA managing it. It can be seen from the perspective of external processes or external visitors that adopting this solution can avoid the situation where gaps are exposed in the operating system.

[0168] In one embodiment of this application, the VMA determination module 702 is specifically used for:

[0169] Among the currently valid VMAs, identify candidate VMAs whose managed virtual address range overlaps with the target virtual address range;

[0170] If a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then a third VMA is segmented from the candidate VMA and used as the first VMA, wherein the third VMA manages the portion of the virtual address range.

[0171] If the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then the candidate VMA is determined to be the first VMA.

[0172] As can be seen from the above, when managing memory using the scheme provided in the embodiments of this application, for VMAs that partially overlap with the target virtual address range, the operating system can segment out the VMAs that manage the overlapping portion of the VMA, and then determine the segmented VMA as the first VMA. For VMAs that completely overlap with the target virtual address range, the VMA is directly determined as the first VMA. This can accurately determine the first VMA, and memory management can be performed based on the first VMA, thereby improving the accuracy of memory management.

[0173] In one embodiment of this application, the apparatus further includes:

[0174] The relationship segmentation module is used to, after the third VMA is segmented from the candidate VMA, segment the mapping relationship between the partial range and the mapped physical memory region from the mapping relationship between the virtual address range managed by the candidate VMA and the mapped physical memory region in the page table.

[0175] As can be seen from the above, when managing memory using the scheme provided in the embodiments of this application, after the third VMA is segmented from the candidate VMA, in the page table, the mapping relationship between a portion of the virtual address range managed by the candidate VMA and the mapped physical memory region is segmented. This allows the first mapping relationship between the overlapping range and the mapped physical memory region to be accurately determined in the page table, thereby releasing the first mapping relationship and performing subsequent processing. This enables accurate memory management and improves the security of the operating system.

[0176] In one embodiment of this application, the relationship termination module 704 is specifically used for:

[0177] The first mapping relationship between the overlapping interval and the mapped physical memory region is moved from the page table to the list to be cleaned up.

[0178] Page table entry cleanup is performed on the first mapping relationship recorded in the list to be cleaned, on a unit basis.

[0179] In this solution, all first mapping relationships are first migrated to the cleanup list. Then, page table entry cleanup operations are performed on the cleanup list to remove all first mapping relationships at once, achieving atomic operations on all first mapping relationships. This ensures that the removal process is not interrupted or interfered with by other operations, and that the entire removal process is completed as an indivisible whole. This also ensures that no gaps are exposed during the operation, guaranteeing the consistency and security of memory space and eliminating the risks of race conditions and data inconsistency.

[0180] In one embodiment of this application, the apparatus further includes:

[0181] The relationship removal module is used to remove the association between the file mapped by the first VMA and the first VMA after the determined first VMA is replaced with the second VMA, provided that the mapping type recorded in the first VMA is a file mapping type.

[0182] The solution provided in this application can remove the mapping and association relationships of VMAs under file mapping types and execute subsequent steps to complete the processing of forced memory mapping requests. Therefore, the memory management solution provided in this application can manage virtual address ranges under multiple mapping types, including file mapping types, and has a wide range of applicability.

[0183] This invention also provides an electronic device, such as... Figure 8 As shown, it includes a processor 801, a communication interface 802, a memory 803, and a communication bus 804, wherein the processor 801, the communication interface 802, and the memory 803 communicate with each other through the communication bus 804.

[0184] Memory 803 is used to store computer programs;

[0185] When the processor 801 executes a program stored in the memory 803, it implements the steps of any of the above memory management methods.

[0186] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0187] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0188] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0189] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0190] In another embodiment of the present invention, a computer-readable storage medium is also provided, wherein a computer program is stored therein, and when the computer program is executed by a processor, it implements the steps of any of the above memory management methods.

[0191] In another embodiment of the present invention, a computer program product containing instructions is also provided, which, when run on a computer, causes the computer to execute any of the memory management methods described above.

[0192] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0193] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0194] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the embodiments of apparatus, electronic devices, computer-readable storage media, and computer program products are basically similar to the method embodiments, and therefore the descriptions are relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0195] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A memory management method, characterized in that, The method includes: Receive a forced memory mapping request for a target virtual address range and lock the target virtual address range; Determine the first VMA that manages the overlapping interval, wherein the overlapping interval is: the interval that overlaps between the virtual address interval managed by the currently effective VMA and the target virtual address interval; The determined first VMA is replaced with the second VMA, wherein the second VMA is: a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is: a VMA created according to the mapping parameters carried by the forced memory mapping request for managing the overlapping interval; Remove the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table; If the second VMA is the VMA corresponding to the overlapping interval, then the second mapping relationship between the overlapping interval and the new physical memory region indicated by the forced memory mapping request is recorded in the page table; If the second VMA is the placeholder VMA, then the placeholder VMA is replaced with the VMA corresponding to the overlapping interval, and the second mapping relationship is recorded in the page table; Unlock the target virtual address range.

2. The method according to claim 1, characterized in that, The determination of the first VMA for the management overlap interval includes: Among the currently valid VMAs, identify candidate VMAs whose managed virtual address range overlaps with the target virtual address range; If a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then a third VMA is segmented from the candidate VMA and used as the first VMA, wherein the third VMA manages the portion of the virtual address range. If the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then the candidate VMA is determined to be the first VMA.

3. The method according to claim 2, characterized in that, After segmenting the third VMA from the candidate VMA, the process further includes: In the page table, the mapping relationship between the partial range and the mapped physical memory region is segmented from the mapping relationship between the virtual address range managed by the candidate VMA and the mapped physical memory region.

4. The method according to any one of claims 1-3, characterized in that, The step of removing the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table includes: The first mapping relationship between the overlapping interval and the mapped physical memory region is moved from the page table to the list to be cleaned up. Page table entry cleanup is performed on the first mapping relationship recorded in the list to be cleaned, on a unit basis.

5. The method according to any one of claims 1-3, characterized in that, After replacing the determined first VMA with the second VMA, the method further includes: If the mapping type recorded in the first VMA is a file mapping type, remove the association between the file mapped by the first VMA and the first VMA.

6. A memory management device, characterized in that, The device includes: The request receiving module is used to receive a forced memory mapping request for a target virtual address range and lock the target virtual address range. The VMA determination module is used to determine the first VMA that manages the overlapping interval, wherein the overlapping interval is the interval between the virtual address interval managed by the currently effective VMA and the target virtual address interval; The VMA replacement module is used to replace the determined first VMA with a second VMA, wherein the second VMA is: a preset placeholder VMA or a VMA corresponding to the overlapping interval, and the VMA corresponding to the overlapping interval is: a VMA created according to the mapping parameters carried by the forced memory mapping request for managing the overlapping interval; The relationship removal module is used to remove the first mapping relationship between the overlapping interval and the mapped physical memory region from the page table; The first recording module is used to record a second mapping relationship between the overlapping interval and the new physical memory region indicated by the forced memory mapping request in the page table when the second VMA is the VMA corresponding to the overlapping interval. The second recording module is used to replace the placeholder VMA with the VMA corresponding to the overlapping interval when the second VMA is the placeholder VMA, and record the second mapping relationship in the page table; The range unlocking module is used to unlock the target virtual address range.

7. The apparatus according to claim 6, characterized in that, The VMA determination module is specifically used for: Among the currently valid VMAs, identify candidate VMAs whose managed virtual address range overlaps with the target virtual address range; If a portion of the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then a third VMA is segmented from the candidate VMA and used as the first VMA, wherein the third VMA manages the portion of the virtual address range. If the virtual address range managed by the candidate VMA overlaps with the target virtual address range, then the candidate VMA is determined to be the first VMA.

8. The apparatus according to claim 7, characterized in that, The device further includes: The relationship segmentation module is used to, after the third VMA is segmented from the candidate VMA, segment the mapping relationship between the partial range and the mapped physical memory region from the mapping relationship between the virtual address range managed by the candidate VMA and the mapped physical memory region in the page table.

9. The apparatus according to any one of claims 6-8, characterized in that, The relationship termination module is specifically used for: The first mapping relationship between the overlapping interval and the mapped physical memory region is moved from the page table to the list to be cleaned up. Page table entry cleanup is performed on the first mapping relationship recorded in the list to be cleaned, on a unit basis.

10. The apparatus according to any one of claims 6-8, characterized in that, The device further includes: The relationship removal module is used to remove the association between the file mapped by the first VMA and the first VMA after the determined first VMA is replaced with the second VMA, provided that the mapping type recorded in the first VMA is a file mapping type.

11. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, when executing a program stored in memory, implements the steps of the method described in any one of claims 1-5.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-5.

Citation Information

Patent Citations

  • Security isolation method for edge computing nodes of Internet of Things

    CN120378184A

  • Memory Deduplication Support for Remote Direct Memory Access (RDMA)

    US20160350261A1