A memory access method, device and storage medium

By building a clone page in the device passthrough scenario and delaying the update of the passthrough device-aware index information, the waste caused by exclusive use of physical memory is solved, and elastic utilization of physical memory is achieved.

CN119718970BActive Publication Date: 2025-11-21HANGZHOU ALICLOUD FEITIAN INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311267294.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-27
Publication Date
2025-11-21
Estimated Expiration
2043-09-27

AI Technical Summary

Technical Problem

In device passthrough scenarios, the exclusive requirement of passthrough devices for virtual machine memory leads to a waste of physical memory, which cannot be effectively utilized.

Method used

By building clone pages in the available ring, the update of the target passthrough device's awareness index information is delayed. The clone pages are monitored and updated after the page fault recovery of the virtual machine memory address to be accessed is completed, so that they are consistent with the target physical memory page. The target passthrough device is then notified to access the clone pages to obtain the virtual machine memory address.

Benefits of technology

Without affecting DMA access to pass-through devices, it supports on-demand reuse of physical memory, thereby improving the utilization of physical memory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119718970B_ABST
    Figure CN119718970B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a memory access method, device and storage medium. In a device pass-through scenario, a shadow page is constructed for a target physical memory page where index information in an available ring is located. By maintaining the shadow page, the index information accessed by the pass-through device can be made to lag behind the index information maintained by the virtual machine, and work such as page fault recovery can be completed during the lag, thereby ensuring that the memory data is prepared before the pass-through device obtains a virtual machine memory address to be accessed, and ensuring that the pass-through device can normally implement DMA access without being aware of the page fault. In this way, memory page faults can also be supported in the device pass-through scenario, and on this basis, physical memory pages can be reused on demand without affecting memory access by the pass-through device, thereby effectively improving the utilization of physical memory.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of virtualization, and in particular to a memory access method, device and storage medium. BACKGROUND

[0002] Device Pass-Through is a technology that supports virtual machines to directly access external devices on a host computer. Such external devices can be referred to as pass-through devices. This technology sacrifices the sharing capability of pass-through devices and dedicates pass-through devices to a single virtual machine, so as to provide perfect device functions and better device performance to the virtual machine.

[0003] In the device pass-through scenario, the pass-through device will directly access the virtual machine memory in the form of DMA (Direct Memory Access), which requires that all the memory of the virtual machine needs to maintain exclusive access to the corresponding physical memory in the host computer, and this part of the physical memory is not allowed to be reused for other virtual machines, otherwise it may cause the pass-through device to access the memory data of other virtual machines, thereby causing data security problems.

[0004] However, since the memory access of the pass-through device to the virtual machine is usually not full-time and not full address space, therefore, such exclusive access to the physical memory in the device pass-through scenario will cause great waste of the physical memory. SUMMARY

[0005] Aspects of the present application provide a memory access method, device and storage medium, which are used to improve the utilization rate of the physical memory in the host computer in the device pass-through scenario.

[0006] The present application provides a memory access method, which is suitable for a virtual machine manager in a host computer, and the transfer of a virtual machine memory address to be accessed between a target virtual machine and a target pass-through device on the host computer based on an available ring, and the method comprises the following steps:

[0007] In response to monitoring that an update event of index information occurs on the available ring, determining a virtual machine memory address to be accessed pointed by the updated index information on the available ring;

[0008] If it is detected that the determined virtual machine memory address to be accessed is in a page fault state, then after completing the page fault recovery, updating a shadow page constructed for a target physical memory page where the index information is located, so as to make the shadow page consistent with the target physical memory page;

[0009] notify the target pass-through device of the update event, so as to trigger the target pass-through device to access the shadow page and other physical memory pages except the target physical memory page in the physical memory pages where the available ring is located, to obtain the to-be-accessed virtual machine memory address.

[0010] The embodiment of the present application further provides a virtual machine manager, comprising:

[0011] a monitoring module, configured to determine a to-be-accessed virtual machine memory address pointed to by updated index information on the available ring in response to monitoring an update event of the index information on the available ring;

[0012] a processing module, configured to update a shadow page constructed by a target physical memory page where the index information is located, so as to make the shadow page consistent with the target physical memory page, if it is detected that the to-be-accessed virtual machine memory address is in a page fault state, and after completion of page fault recovery;

[0013] a notification module, configured to notify the target pass-through device of the update event, so as to trigger the target pass-through device to access the shadow page and other physical memory pages except the target physical memory page in the physical memory pages where the available ring is located, to obtain the to-be-accessed virtual machine memory address;

[0014] wherein the target virtual machine on the host machine and the target pass-through device perform transmission of a to-be-accessed virtual machine memory address based on the available ring.

[0015] The embodiment of the present application further provides a physical machine, comprising a memory and a processor, wherein the processor runs a virtual machine manager;

[0016] the memory is used for storing one or more computer instructions;

[0017] the processor is coupled with the memory, and is used for executing the one or more computer instructions, so as to execute the aforementioned memory access method by using the virtual machine manager;

[0018] The embodiment of the present application further provides a computer readable storage medium storing computer instructions, which, when executed by one or more processors, causes the one or more processors to execute the aforementioned memory access method.

[0019] In the device pass-through scenario, a dummy page is constructed for the target physical memory page where the index information in the available ring is located. During the transmission of the virtual machine memory address to be accessed between the target virtual machine and the target pass-through device based on the available ring, the update event of the index information occurring on the available ring can be monitored by the virtual machine manager, and in the case that the virtual machine memory address to be accessed pointed by the updated index information has a page fault problem, the dummy page is updated after ensuring that the page fault recovery of the virtual machine memory address is completed, so as to make the dummy page consistent with the target physical memory page. After the update of the dummy page is completed, the virtual machine manager notifies the target pass-through device of the update event. The target pass-through device accesses the physical memory pages other than the target physical memory page in the available ring and the physical memory page where the dummy page is located, to obtain the virtual machine memory address to be accessed. Accordingly, in the embodiment, the index information accessed by the pass-through device can be made to lag behind the index information maintained by the virtual machine by maintaining the dummy page, and the lag period can be used to complete the page fault recovery and the like, so as to ensure that the memory data is prepared before the pass-through device obtains the virtual machine memory address to be accessed, and the pass-through device can normally implement the DMA access without sensing the page fault problem. In this way, the memory page fault can be supported in the device pass-through scenario, and on this basis, the physical memory page can be reused as needed without affecting the memory access of the pass-through device, thereby effectively improving the utilization rate of the physical memory. BRIEF DESCRIPTION OF DRAWINGS

[0020] The accompanying drawings, which are included to provide a further understanding of the application and are incorporated in and constitute a part of this application, illustrate embodiments of the application and serve to explain the principles of the application, and do not limit the application. In the drawings:

[0021] Figure 1 A flowchart of a memory scheme method provided for an exemplary embodiment of the application;

[0022] Figure 2 A logic diagram of a memory access method provided for an exemplary embodiment of the application;

[0023] Figure 3 A processing logic diagram of an available ring provided for an exemplary embodiment of the application;

[0024] Figure 4 A flowchart of another memory access method provided for an exemplary embodiment of the application;

[0025] Figure 5 A logic diagram of the memory access method shown in FIG. 8; Figure 4

[0026] Figure 6 ​A structural schematic diagram of a virtual machine manager provided for another exemplary embodiment of the present application;

[0027] Figure 7 A structural schematic diagram of a physical machine provided for still another exemplary embodiment of the present application. DETAILED DESCRIPTION

[0028] For the purpose, technical solutions and advantages of the present application to be clearer, the technical solutions of the present application will be described clearly and completely below with embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present application.

[0029] Figure 1 A flow schematic diagram of a memory scheme method provided for an exemplary embodiment of the present application. Figure 2 A logic schematic diagram of a memory access method provided for an exemplary embodiment of the present application.

[0030] Reference Figure 2 In the embodiment, a plurality of virtual machines (VM) can be deployed on a host computer, and a virtual machine manager (VMM) is also deployed.

[0031] The host computer in the embodiment can be a computer device with functions of computing, storage and communication, for example, can be a single server device, or can be a clouded server array, etc. The virtual machine manager in the embodiment can be used for scheduling tasks, load balancing, state monitoring and resource management of the virtual machines on the host computer, etc. The virtual machine manager can be a hypervisor, etc.

[0032] Reference Figure 2 The host computer is also equipped with an external device. The external device can be various I / O devices externally connected to the host computer. Based on the device pass-through technology, the virtual machine can directly access the I / O device externally connected to the host computer through the virtual machine manager, so that the I / O operation path of the virtual machine is almost the same as the I / O path in the non-virtualization environment. Such I / O device is the pass-through device mentioned in the background technology. The pass-through device in the embodiment can include but is not limited to a network card, a storage medium, etc. The storage medium can be a disk, a hard disk and other persistent storage media. The pass-through device can be in communication connection with the CPU of the host computer through a communication interface; according to the form of the communication interface, the pass-through device can be implemented as a PCI device, a PCIe device, etc.

[0033] In this embodiment, virtio technology can be used to support I / O operations of the virtual machine on the pass-through device.

[0034] Virtio is an I / O semi-virtualization technology, which is an abstraction of a set of generic front-end devices in a semi-virtualization VMM. It is a front-end and back-end architecture, including a device driver, a virtualization device, and a virtualization queue (virt Queue) for communication between the device driver and the virtualization device. The device driver is located in the virtual machine and is the corresponding driver of the virtualization device in the virtual machine. The virtualization device is obtained by the VMM based on the virtualization of the front-end device. The device driver and the virtualization device can read and write data from the virtualization queue. The device driver saves the I / O request information in the virtual queue, and then notifies the virtualization device. The virtualization device can obtain the I / O request information from the virtual queue for processing. The virtualization queue can include an available ring, a used ring, and a descriptor ring. The available ring and the used ring can store the index of the logical buffer block. The description information of the logical buffer block is stored in the descriptor ring. Each logical buffer block can point to a virtual machine memory address.

[0035] Based on the virtio technology, the virtual machine and its associated pass-through device can transmit the virtual machine memory address corresponding to the I / O operation through the virtualization queue.

[0036] The inventors found in the research process that at present, the pass-through device can directly access the virtual machine memory through the DMA mode, that is, after the pass-through device obtains the virtual machine memory address corresponding to the I / O operation through the virtualization queue, the pass-through device can initiate a DMA access operation according to the virtual machine memory address to access the corresponding physical memory. Therefore, the existing device pass-through technology requires that all the memory of the virtual machine needs to maintain exclusive access to the corresponding physical memory in the host computer, and does not allow the physical memory to be reused for other virtual machines, which leads to a great waste of physical memory.

[0037] Therefore, an improved memory access scheme is proposed in this embodiment to support flexible scheduling of physical memory in a device pass-through scenario to improve the utilization of physical memory. Referring to Figure 1 The memory access method provided by the embodiment can include:

[0038] Step 100, in response to monitoring that an update event of index information occurs on the available ring, determining a virtual machine memory address to be accessed pointed by the updated index information on the available ring;

[0039] Step 102, if it is detected that the determined virtual machine memory address to be accessed is in a page fault state, then after completing the page fault recovery, the shadow page constructed for the target physical memory page where the index information is located is updated to make the shadow page consistent with the target physical memory page;

[0040] Step 103, the update event is notified to the target pass-through device to trigger the target pass-through device to access the shadow page and other physical memory pages of the available ring except the target physical memory page to obtain the virtual machine memory address to be accessed.

[0041] For the convenience of description, in the embodiment, the target virtual machine on the host and the corresponding target pass-through device are taken as examples to describe the memory access method, and it should be understood that the target virtual machine can be any virtual machine on the host, and the target pass-through device can be any pass-through device associated with the target virtual machine on the host.

[0042] Reference Figure 2 The memory access method provided in the embodiment can be implemented by a virtual machine manager in the host. The memory access method provided in the embodiment is improved on the basis of the existing Virtio technology to improve the utilization rate of the physical memory of the host.

[0043] As mentioned above, after the pass-through device obtains the virtual machine memory address corresponding to the I / O operation through the virtualization queue, the DMA access operation is initiated according to the virtual machine memory address. For this purpose, the embodiment proposes a technical concept of supporting memory elasticity in the device pass-through scenario: before the pass-through device obtains the virtual machine memory address corresponding to the I / O operation through the virtualization queue, the memory data under the virtual machine memory address is prepared to ensure that the pass-through device can normally access the corresponding memory data after obtaining the virtual machine memory address. Under this concept, the physical memory occupied by the target virtual machine can be reused to other virtual machines, and the exchanged memory data is exchanged back before the target pass-through device initiates the DMA access to the virtual memory address, that is, the target pass-through device is unaware of the memory swapping process under the target virtual machine, so as not to affect the DMA process of the target pass-through device.

[0044] To realize this concept, the embodiment proposes to delay the time when the target pass-through device learns the virtual machine memory address corresponding to the I / O operation to after the preparation of the memory data. In this way, sufficient processing time can be provided for the preparation of the memory data.

[0045] The inventors found in the research process that the available ring in the virtualization queue usually includes the following parts:

[0046] index: points to the next available index position in the available ring;

[0047] ring[]: records the descriptor identifier, points to a descriptor in the descriptor queue descriptor ring or the head descriptor of a descriptor chain.

[0048] Of course, the available ring can also contain other parts, for example, flags, etc., which are not described here.

[0049] Among them, only the device driver in the virtual machine has the right to write to the available ring. When a new I / O operation can be performed, the device driver will update the index information in the available ring, and the pass-through device can perform step-by-step lookup based on the index information in the available ring to ultimately determine the virtual machine memory address to be accessed, and then perform real-time DMA access. It can be seen that the target virtual machine and the target pass-through device are essentially based on the available ring to transfer the virtual machine memory address to be accessed.

[0050] To this end, the embodiment proposes to delay the time when the target pass-through device perceives the index information in the available ring, so as to achieve the technical goal of delaying the time when the target pass-through device learns the virtual machine memory address corresponding to the I / O operation.

[0051] It should be understood that the available ring in the embodiment, as well as the used ring and other parts in the virtualization queue described above, are all stored in the physical memory of the host. The virtual machine manager in the embodiment can maintain a page table for the target virtual machine, which can be used to map the virtual machine memory address accessed by the target virtual machine to the physical memory address of the host. Alternatively, the page table can adopt an extended page table (EPT) or a shadow page table (Shadow page table), etc. The embodiment does not limit the type of page table technology used, as long as it can support mapping the virtual machine memory address accessed by the target virtual machine to the physical memory address of the host. In this way, when the device driver in the target virtual machine initiates a write operation on the index information in the available ring described above, the virtual machine memory address (GPA) in the write operation can be translated into the physical memory address (HPA) of the host based on the page table, thereby updating the index information in the available ring in the physical memory. In addition, in actual applications, the index information usually only occupies one physical memory page, that is, the specification of the index information is usually less than 4kb (the specification of a single memory page).

[0052] To realize the time that the target pass-through device senses the index information in the available ring, the embodiment proposes to construct a dummy page for the target physical memory page where the index information is located, and make the dummy page visible to the target pass-through device, while making the target physical memory page invisible to the target pass-through device. That is, the target pass-through device can access the dummy page, instead of the target physical memory page which can be directly written by the device driver. In practical application, the target physical memory page can contain other contents in the virtualization queue, in addition to the index information, such as the contents in the available ring or the descriptor queue. In the embodiment, the hypervisor can maintain the target physical memory page as a unit, without making a more detailed distinction on the specific contents in the target physical memory page.

[0053] Based on this, referring to Figure 1 In step 100, in response to monitoring that the updating event of the index information occurs on the available ring, the virtual machine memory address to be accessed, which is pointed to by the updated index information on the available ring, is determined.

[0054] In this step, the updating event of the index information occurring on the available ring is monitored by the hypervisor, instead of allowing the target pass-through device to perform the monitoring. This is different from the traditional Virtio technology. Through the setting in step 100, it can be ensured that the target pass-through device has no awareness of the updating event of the index information occurring on the available ring.

[0055] In this step, the updating event of the index information occurring on the available ring is monitored by the hypervisor, instead of allowing the target pass-through device to perform the monitoring. This is different from the traditional Virtio technology. Through the setting in step 100, it can be ensured that the target pass-through device has no awareness of the updating event of the index information occurring on the available ring.

[0056] In an alternative implementation, the virtual machine manager can intercept the specified write instruction in the case that the specified write instruction for the specified base register address of the target pass-through device is issued in the target virtual machine, to determine that the update event of the index information on the available ring is monitored. In the conventional Virtio technology, the device driver can write the specified content to the specified base register address through the specified write instruction, to trigger the target pass-through device to learn the update event of the index information on the available ring based on the specified content. In the alternative implementation, it is proposed to set an interception point on the notification link of the device driver to the target pass-through device, that is, the specified write instruction of the device driver to the specified base register address of the target pass-through device is intercepted. In this way, the write instruction will be exited without being executed, and the specified content will not be written to the specified base register address of the target pass-through device, accordingly, the target pass-through device will not perceive the update event of the index information, and further, the target pass-through device will not access the index information on the available ring temporarily.

[0057] Of course, since the virtual machine manager has the control right for many operations in the target virtual machine, other implementation manners can also be used in the embodiment to ensure that the target pass-through device does not perceive the update event of the index information on the available ring, and more examples are not given here.

[0058] In step 100, the virtual machine manager can also determine the virtual machine memory address to be accessed which is pointed to by the updated index information on the available ring.

[0059] Figure 3 The processing logic diagram of the available ring provided for an exemplary embodiment of the present application is shown. Referring to Figure 3 , the virtual machine manager can determine the index position on the available ring which is pointed to by the updated index information; obtain the descriptor identifier on the index position; find the descriptor corresponding to the descriptor identifier from the descriptor queue associated with the available ring, to obtain the virtual machine memory address pointed to by the found descriptor as the virtual machine memory address to be accessed; wherein a single descriptor in the descriptor queue points to a single virtual machine memory address.

[0060] It should be understood that, in step 100, the available ring accessed by the virtual machine manager is the available ring maintained by the device driver, and the aforementioned dummy page is not involved herein. As mentioned above, the page table is maintained in the virtual machine manager for the target virtual machine, and the virtual machine manager can obtain the virtual machine memory address GPA where the index information is located from the intercepted specified write instruction, and then perform address translation based on the page to determine the physical machine memory address HPA of the target physical machine memory page where the index information is located, and then access the target physical machine memory page. In the same manner of address translation, the virtual machine manager can also access the descriptor queue, and then obtain the virtual machine memory address pointed to by the updated index information to be accessed.

[0061] As mentioned above, based on the memory access method provided in the embodiment, memory elasticity can be supported, that is, the physical memory occupied by the target virtual machine can be swapped. The memory swap technology is a technology of copying the infrequently used memory page to the disk and releasing the physical memory to increase the available memory of the system. By using the memory swap technology, the memory usage rate of the physical machine can be obviously improved, and the technology plays an important role in the memory high-density data center and cloud computing; and the memory swap can cause the page fault problem. In this way, the page fault problem can occur on the virtual machine memory address in the target virtual machine.

[0062] Continuing to refer to Figure 1 In step 101, the virtual machine manager can also detect whether the virtual machine memory address to be accessed determined in step 100 is in the page fault state, that is, whether the page fault problem exists.

[0063] In an optional implementation manner, the virtual machine manager can query the page table item information corresponding to the virtual machine memory address to be accessed from the page table maintained for the target virtual machine; and if the page fault identifier is carried in the page table item information, it is determined that the virtual machine memory address to be accessed is in the page fault state. As mentioned above, the page table can be used to map the virtual machine memory address accessed by the target virtual machine to the physical machine memory address of the host, and therefore, in the process of performing memory interaction on the physical memory occupied by the target virtual machine, the virtual machine manager can add the page fault identifier to the exchanged physical machine memory address, so that the virtual machine memory address mapped to the physical machine memory address in the page table is in the page fault state. That is, in the optional implementation manner, the page fault identifier recorded in the page table maintained by the virtual machine manager for the target virtual machine can be used as the basis for the virtual machine manager to judge whether the virtual machine memory address to be accessed is in the page fault state.

[0064] Of course, other implementation manners can also be used to implement the detection of the page fault state in step 101 in this embodiment, for example, the virtual machine manager initiates a page fault state query request to the operating system of the host, and the operating system returns the query result. No more examples are given here, and the detection manners supported in this embodiment are not limited to this.

[0065] The subsequent processing logic after the detection is described below in two cases:

[0066] In one case When the virtual machine manager detects that the virtual machine memory address to be accessed determined in step 100 has a page fault problem, the virtual machine manager can update the shadow page corresponding to the target physical memory page where the index information is located after the page fault recovery of the virtual machine memory address is completed, so as to make the shadow page consistent with the target physical memory page.

[0067] In this case, the virtual machine manager updates the shadow page described above only after determining that the page fault recovery of the virtual machine memory address to be accessed is completed. This can ensure that when the target pass-through device accesses the shadow page, the page fault recovery of the virtual machine memory address to be accessed is completed, that is, the corresponding memory data is ready, and the DMA access of the target pass-through device can be normally implemented without sensing that the page fault problem has occurred on the virtual machine memory address.

[0068] Optionally, in step 101, the virtual machine manager can perform the page fault recovery processing on the virtual machine memory address to be accessed: in the case that the virtual machine memory address to be accessed is in the page fault state, a page fault request is sent to the operating system of the host to trigger the operating system to call the memory management unit MMU to perform the page fault recovery on the virtual machine memory address to be accessed; after receiving the page fault response fed back by the operating system, it is determined that the page fault recovery of the virtual machine memory address to be accessed is completed. More specifically, the virtual machine manager can write the page fault request for the virtual machine memory address to be accessed into the message queue maintained in the operating system of the host, and send an interrupt to the operating system; the operating system can read out the page fault request from the message queue after receiving the interrupt; the operating system can recover the memory data (that is, the memory data belonging to the target virtual machine) in the physical memory page mapped by the virtual machine memory address by calling the memory management unit MMU. After completing the page fault recovery, the operating system can return a page fault response to the virtual machine manager, and thus the virtual machine manager can determine that the page fault recovery of the virtual machine memory address to be accessed is completed.

[0069] Of course, other implementation manners can also be used in the embodiment to complete the page fault recovery of the virtual machine memory address to be accessed, for example, the target virtual machine can actively request the operating system of the host to perform the page fault recovery, and the like, and no more examples are given herein. The embodiment does not limit the execution subject and specific execution logic of the page fault recovery, and the page fault recovery technology available now or in the future can be referred to.

[0070] In another case When the virtual machine manager detects that the virtual machine memory address to be accessed determined in step 100 has no page fault problem, the virtual machine manager can directly perform the updating of the shadow page corresponding to the target physical memory page where the index information is located, so as to make the shadow page consistent with the target physical memory page.

[0071] In any of the above cases, the virtual machine manager updates the shadow page after a time delay after the index information in the available ring is updated. Since the target pass-through device can only access the shadow page and is not allowed to access the target physical memory page where the index information is located, the target pass-through device can view the index information only after a period of time after the index information in the available ring is updated. During the period of time, the page fault recovery in the first case can be completed, so that no matter which case, when the target pass-through device accesses the shadow page, the memory data corresponding to the virtual machine memory address to be accessed is ready, and the DMA access of the target pass-through device can be normally implemented.

[0072] In this way, based on step 101, in the embodiment, the physical memory page used by the pass-through device can be allowed to have a page fault problem, and through the page fault recovery in step 101, it can be ensured that the pass-through device will not have an access failure problem due to a memory page fault, but can timely perceive the memory access initiated by the pass-through device through the shadow page, and prepare the required memory data for the pass-through device in advance through the page fault recovery. Therefore, the physical memory page used by the pass-through device can be dynamically scheduled without the awareness of the pass-through device, which makes it unnecessary to provide an exclusive physical memory page for the pass-through device in the device pass-through scenario. The freed physical memory page can be dynamically scheduled to other users, so that the memory elasticity can be supported in the device pass-through scenario.

[0073] Continue to refer to Figure 1 In step 102, the target pass-through device can be notified of the updating event, so as to trigger the target pass-through device to access the shadow page and the other physical memory pages in the physical memory page where the available ring is located except the target physical memory page, so as to obtain the virtual machine memory address to be accessed.

[0074] Refer to Figure 2In this embodiment, the virtual machine manager notifies the target pass-through device of the update time. In an alternative notification method, the virtual machine manager writes specified content to a specified base register address of the target pass-through device to trigger the target pass-through device to learn of the update event of the index information occurring on the available ring based on the specified content. In the light of the alternative implementation of monitoring the update event of the index information occurring on the available ring provided in step 100, the virtual machine manager can execute the aforementioned write instruction instead of the device driver, i.e., write the specified content to the specified base register address of the target pass-through device. According to the conventional virtio technology, the target pass-through device can perceive the specified content written to the specified base register address and take the specified content as the notification of the update event, thereby triggering the access operation on the index information.

[0075] As mentioned above, the available ring is stored in the physical memory of the host computer and usually occupies multiple physical memory pages. The target pass-through device does not have the access right to the target physical memory page where the index information is located, but has the access right to other physical memory pages of the available ring except the target physical memory page. Therefore, the target pass-through device can access the aforementioned dummy page and other physical memory pages of the available ring except the target physical memory page after receiving the notification to obtain the virtual machine memory address to be accessed.

[0076] Here, the target pass-through device can refer to the logic of the virtual machine manager for determining the virtual machine memory address to be accessed pointed by the updated index information from the available ring to obtain the virtual machine memory address to be accessed by accessing the aforementioned dummy page and other physical memory pages of the available ring except the target physical memory page, which will not be repeated here.

[0077] In this embodiment, the target pass-through device can perform memory access in the manner of DMA after obtaining the virtual machine memory address to be accessed. Since the virtual machine memory address to be accessed does not have the problem of page fault, the target pass-through device can accurately access the corresponding memory data. The DMA process of the target pass-through device is not modified in this embodiment, and therefore the DMA process of the target pass-through device will not be described in detail.

[0078] In summary, in the device pass-through scenario, the embodiment proposes to construct a shadow page for the target physical memory page where the index information in the available ring is located. In this way, during the transmission of the virtual machine memory address to be accessed between the target virtual machine and the target pass-through device based on the available ring, the hypervisor can monitor the update event of the index information on the available ring, and in the case that the virtual machine memory address to be accessed pointed to by the updated index information has a page fault problem, after ensuring that the virtual machine memory address completes the page fault recovery, the shadow page is updated to be consistent with the target physical memory page. After the update of the shadow page is completed, the hypervisor notifies the target pass-through device of the update event. The target pass-through device accesses the physical memory pages other than the target physical memory page where the shadow page and the available ring are located to obtain the virtual machine memory address to be accessed. Accordingly, in the embodiment, by maintaining the shadow page, the index information accessed by the pass-through device can lag behind the index information maintained by the virtual machine, and the lag period can be used to complete the page fault recovery and the like, thereby ensuring that the memory data is prepared before the pass-through device obtains the virtual machine memory address to be accessed, and ensuring that the pass-through device normally implements DMA access without sensing the page fault problem. In this way, the memory page fault can also be supported in the device pass-through scenario, and on this basis, the physical memory page can be reused as needed without affecting the memory access of the pass-through device, thereby effectively improving the utilization rate of the physical memory.

[0079] Figure 4 Another flowchart of a memory access method provided by an example embodiment of the present application is shown. Figure 5 For Figure 4 a logic diagram of the memory access method is shown. Referring to Figure 4 , the method can include:

[0080] Step 400, in the case that a memory elasticity mode start instruction is received, the physical memory address of the target physical memory page originally recorded in the address mapping table of the IOMMU is replaced with the physical memory address of the shadow page, so that the target pass-through device accesses the shadow page instead of the target physical memory page;

[0081] Step 401, in response to monitoring that an update event of the index information occurs on the available ring, the virtual machine memory address to be accessed pointed to by the updated index information on the available ring is determined;

[0082] Step 402, if it is detected that the determined virtual machine memory address to be accessed is in a page fault state, after it completes the page fault recovery, the shadow page constructed for the target physical memory page where the index information is located is updated to be consistent with the target physical memory page;

[0083] Step 403, notify the target pass-through device of the update event, so as to trigger the target pass-through device to access the split page and other physical memory pages except the target physical memory page in the available ring, so as to obtain the virtual machine memory address to be accessed.

[0084] Steps 401-403 can refer to the related descriptions in the foregoing embodiments, and thus will not be repeated here.

[0085] In this embodiment, at least two modes can be supported: a memory elastic mode and a memory inelastic mode. In the memory elastic mode, the physical memory occupied by the target virtual machine can be reused; and in the memory inelastic mode, the physical memory occupied by the target virtual machine cannot be reused.

[0086] In this embodiment, switching between the two modes described above is supported.

[0087] In this embodiment, the pass-through device can access the host physical address (HPA) of the host machine through a direct memory access (DMA) mode. For the DMA mode, there is a data path between the pass-through device and the physical memory of the host machine, which is used to implement data transmission between the pass-through device and the physical memory. During the data transmission between the pass-through device and the physical memory, the CPU of the host machine does not need to participate. As mentioned above, the pass-through device can obtain the virtual machine memory address (GPA) corresponding to the I / O operation through the virtualization queue described above. However, the pass-through device does not know the mapping relationship between the GPA and the HPA. Moreover, without limitation, if the pass-through device knows the entire physical memory address space of the host machine, it can initiate DMA access to any physical memory of the host machine, which may lead to the risk of malicious access to the physical memory. Therefore, referring to Figure 5 In this embodiment, an input input memory management unit (IOMMU) is introduced.

[0088] The IOMMU can be communicatively connected between the pass-through device and the physical memory. Alternatively, the IOMMU can be communicatively connected to the pass-through device and the physical memory of the host machine through a communication interface bus. The serial interface bus can be a PCI interface bus, a PCIe interface bus, etc. The IOMMU can ensure that the pass-through device can access the physical memory occupied by the virtual machine associated with the pass-through device on the host machine when performing the DMA operation.

[0089] The IOMMU can maintain an address mapping table for mapping a virtual machine memory address GPA accessed by the pass-through device to a physical memory address HPA of the host. When the pass-through device accesses the physical memory of the host by means of DMA, the VMM can capture a DMA request sent by the pass-through device and transmit the DMA request to the IOMMU. The IOMMU can obtain the to-be-accessed GPA from the DMA request; and then match the to-be-accessed GPA in the address mapping table stored in the IOMMU to obtain the HPA corresponding to the to-be-accessed GPA. The pass-through device can access the physical memory page in the physical memory of the host through the HPA corresponding to the to-be-accessed GPA.

[0090] Based on this, in this embodiment, step 400 provides an implementation manner for ensuring that the target pass-through device accesses the dummy page instead of the target physical memory page. Referring to Figure 5 In this implementation manner, after receiving the memory elasticity mode start instruction, the address mapping table of the IOMMU can be modified, and the physical memory address of the dummy page is used to replace the physical memory address of the target physical memory page. In this way, when the target pass-through device initiates a DMA request for the memory page where the index information is located, the virtual machine memory address carried in the DMA request will be mapped by the IOMMU to the physical memory address of the dummy page, so that the target pass-through device accesses the dummy page instead of the target physical memory page.

[0091] In the memory elasticity mode, the steps 401-403 described above can be used to ensure that the preparation of the memory data is completed before the target pass-through device obtains the to-be-accessed virtual machine memory address, so as to ensure that the target pass-through device is not aware of the page fault problem, thereby supporting memory elasticity.

[0092] In the case of switching to the memory non-elasticity mode, the virtual machine manager can modify the physical memory address of the dummy page in the address mapping table of the IOMMU to the physical memory address of the target physical memory page after receiving the memory elasticity mode stop instruction, so that the target pass-through device accesses the target physical memory page.

[0093] In this way, by switching the physical memory address HPA of the memory page where the index information is located in the address mapping table of the IOMMU, the target pass-through device can be adjusted to access the dummy page or access the target physical memory page on demand, thereby supporting memory access in the corresponding mode.

[0094] It should be understood that the above implementation manner provided in the embodiment is only exemplary, and other implementation manners can also be used in the embodiment to ensure that the target pass-through device accesses the shadow page without being allowed to access the target physical memory page. For example, without modifying the address mapping table of the IOMMU, the target physical page can be accessed by the virtual machine manager in the memory elasticity mode, and when an access request for the target physical memory page is monitored, the access can be redirected to the shadow page; and after switching to the memory non-elasticity mode, the access control function can be closed. The embodiment is not limited thereto, and no more examples are given herein.

[0095] In addition to switching the access permission of the shadow page and the target physical page, in the embodiment, after receiving the memory elasticity mode start instruction, the virtual machine manager can start monitoring and intercepting a specified write instruction for a specified base register address of the target pass-through device in the target virtual machine. In the case of receiving the memory elasticity mode stop instruction, the virtual machine manager stops intercepting the specified write instruction issued in the target virtual machine, and the monitoring of the specified write instruction can be stopped or not stopped, which does not affect the normal operation of the memory non-elasticity mode. Accordingly, after the memory elasticity mode is stopped, the device driver writes specified content to the specified base register address based on the specified write instruction to trigger the target pass-through device to learn the update event of the index information on the available ring based on the specified content. That is, the device driver directly notifies the target pass-through device of the update event instead of being notified by the virtual machine manager.

[0096] In summary, in the embodiment, after switching to the memory elasticity mode, the target pass-through device accesses the shadow page instead of the target physical memory page by modifying the address mapping table in the IOMMU, and the virtual machine manager can also start monitoring and intercepting the index information update event on the available ring to make the target pass-through device no longer directly perceive the update event. After switching to the memory non-elasticity mode, the related settings can be modified to the related configuration state under the traditional device pass-through technology. Therefore, in the embodiment, the seamless switching of the memory elasticity mode and the memory non-elasticity mode can be supported. Moreover, since only the target physical memory page where the index information is located can have other versions of data, during an I / O operation, the data version inconsistency problem during the access of the target pass-through device to the virtualization queue can be effectively avoided, and the accuracy of the I / O operation is ensured during the mode switching.

[0097] In the above or the following embodiments, in order to further ensure that the mode switching does not affect the accuracy of the I / O operation, further improvement schemes are provided:

[0098] In the case of receiving the memory elasticity mode stop instruction, the target physical memory page is write-protected.

[0099] After all the memory access operations that are determined to be not completed when the memory elasticity mode closing instruction is received are completed, the write protection on the target physical memory page is released.

[0100] During the write protection, for the update operation on the index information, a temporary suspension can be performed, and after the related I / O operation is completed, the write operation is continued. For other types of write operations, a rejection can be performed, and a rewriting is waited.

[0101] In the improved scheme, the virtual machine manager can perform write protection on the target physical memory page before switching to the memory inelasticity mode, that is, write operations on the physical memory page are not allowed during the switching, which can ensure that the target physical memory page and the shadow page maintain data version consistency during the switching. Thus, the problem of inconsistent data versions during the access of the virtualization queue by the target pass-through device can be avoided.

[0102] It should be noted that in some of the processes described in the above embodiments and the accompanying drawings, a plurality of operations are included in a specific order, but it should be clearly understood that these operations can be executed or performed in parallel or in the order in which they appear in this text. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any execution order. In addition, these processes can include more or fewer operations, and the operations can be executed in sequence or in parallel.

[0103] Figure 6 A structural schematic diagram of a virtual machine manager is provided for another exemplary embodiment of the present application. As shown in the figure, the virtual machine manager can include: Figure 6

[0104] The monitoring module 60 is configured to determine a virtual machine memory address to be accessed, which is pointed to by the updated index information on the available ring, in response to monitoring that an update event of the index information occurs on the available ring.

[0105] The processing module 61 is configured to update a shadow page constructed for a target physical memory page where the index information is located, after detecting that the virtual machine memory address to be accessed is in a page fault state, so that the shadow page is consistent with the target physical memory page.

[0106] The notification module 62 is configured to notify the update event to a target pass-through device, so as to trigger the target pass-through device to access the shadow page and other physical memory pages except the target physical memory page on the physical memory page where the available ring is located, so as to obtain the virtual machine memory address to be accessed.

[0107] ​Specifically, the target virtual machine on the host machine and the target pass-through device exchange the memory address of the virtual machine to be accessed based on the availability ring.

[0108] In an alternative embodiment, the virtual machine manager may further include a configuration module 63, which may be configured to: prior to detecting an update event of index information on the available ring.

[0109] Upon receiving a memory elastic mode enable instruction, the physical memory address of the target physical memory page, which was originally recorded in the address mapping table of the IOMMU, is replaced with the physical memory address of the clone page, so that the target passthrough device accesses the clone page instead of the target physical memory page.

[0110] The target pass-through device accesses the host machine's physical memory through address mapping via the IOMMU; in the memory elastic mode, the physical memory occupied by the target virtual machine is allowed to be reused.

[0111] In an optional embodiment, the configuration module 63 may also be configured as follows:

[0112] Upon receiving a memory elastic mode shutdown instruction, the physical memory address of the cloned page in the address mapping table of the IOMMU is modified to the physical memory address of the target physical memory page, so that the target passthrough device can access the target physical memory page;

[0113] When the memory elastic mode is turned off, the physical memory occupied by the target virtual machine is no longer allowed to be reused.

[0114] In an optional embodiment, the monitoring module 60 may further be configured as follows:

[0115] If a specified write instruction is detected in the target virtual machine for a specified base address register address of the target pass-through device, the specified write instruction is intercepted to determine that an index information update event has occurred on the available ring;

[0116] The specified write instruction is used to write specified content to the specified base address register address to trigger the target pass-through device to learn about the index information update event that occurred on the available ring based on the specified content.

[0117] In an optional embodiment, the notification module 62 may be specifically configured as follows:

[0118] Write the specified content to the specified base address register address of the target pass-through device to trigger the target pass-through device to learn about the index information update event that occurred on the available ring based on the specified content.

[0119] In an optional embodiment, the monitoring module 60 can be further configured to:

[0120] stop intercepting the specified write instruction issued by the target virtual machine in response to receiving a memory resilience mode off instruction;

[0121] wherein, after the memory resilience mode is turned off, a write instruction based on the specified write instruction is issued by the target virtual machine to write specified content to the specified base register address, so as to trigger the target pass-through device to learn the update event of the index information occurred on the available ring based on the specified content.

[0122] In an optional embodiment, the monitoring module 60 can be specifically configured to:

[0123] determine an index position on the available ring pointed to by the updated index information;

[0124] obtain a descriptor identifier at the index position;

[0125] from a descriptor queue associated with the available ring, find a descriptor corresponding to the descriptor identifier, so as to obtain a virtual machine memory address pointed to by the found descriptor as the to-be-accessed virtual machine memory address;

[0126] wherein, a single descriptor in the descriptor queue points to a single virtual machine memory address.

[0127] In an optional embodiment, the processing module 61 can be specifically configured to:

[0128] query page table item information corresponding to the to-be-accessed virtual machine memory address from a page table maintained for the target virtual machine;

[0129] if a page fault identifier is carried in the page table item information, determine that the to-be-accessed virtual machine memory address is in a page fault state;

[0130] wherein, the page table is used to map a virtual machine memory address accessed by the target virtual machine to a physical memory address of the host machine.

[0131] In an optional embodiment, the configuration module 63 can be further configured to:

[0132] perform write protection on the target physical memory page in response to receiving a memory resilience mode off instruction;

[0133] remove the write protection after all memory access operations that have not been completed when the memory resilience mode off instruction is received are completed.

[0134] In an optional embodiment, the processing module 61 can be specifically configured to:

[0135] In a case that the to-be-accessed virtual machine memory address is in a page fault state, sending a page fault request to an operating system of the host machine to trigger the operating system to invoke a memory management unit to perform page fault recovery on the to-be-accessed virtual machine memory address;

[0136] After receiving the page fault response fed back by the operating system, determining that the to-be-accessed virtual machine memory address completes the page fault recovery.

[0137] It is worth mentioning that the technical details of the above-mentioned embodiments of the virtual machine manager can refer to the related descriptions in the foregoing method embodiments, and will not be described here again in order to save space, but this should not cause the loss of the protection scope of the present application.

[0138] Figure 7 A structural schematic diagram of a physical machine is provided for another exemplary embodiment of the present application. Referring to Figure 7 The physical machine can include a memory 70 and a processor 71, and the processor 71 can run a virtual machine manager 72.

[0139] The processor 71 is coupled with the memory 70, and is configured to execute a computer program in the memory 70 to perform the following logic by using the virtual machine manager 72:

[0140] In response to monitoring that an update event of index information occurs on the available ring, determining a to-be-accessed virtual machine memory address pointed to by the updated index information on the available ring;

[0141] If it is detected that the determined to-be-accessed virtual machine memory address is in a page fault state, then after it completes the page fault recovery, updating a shadow page constructed for a target physical memory page where the index information is located, so as to make the shadow page consistent with the target physical memory page;

[0142] Notifying the target pass-through device of the update event to trigger the target pass-through device to access the shadow page and other physical memory pages of the available ring except the target physical memory page, to obtain the to-be-accessed virtual machine memory address;

[0143] Wherein, the delivery of the to-be-accessed virtual machine memory address between the target virtual machine on the host machine and the target pass-through device is based on the available ring.

[0144] In an optional embodiment, the virtual machine manager 72, before responding to the monitoring that the update event of the index information occurs on the available ring, can also be configured to:

[0145] In a case where a memory elasticity mode start instruction is received, a physical memory address of the target physical memory page originally recorded in an address mapping table of the IOMMU is replaced with a physical memory address of the shadow page, so that the target pass-through device accesses the shadow page instead of the target physical memory page;

[0146] In the memory elasticity mode, the physical memory occupied by the target virtual machine is allowed to be reused.

[0147] In an optional embodiment, the virtual machine manager 72 can be further configured to:

[0148] In a case where a memory elasticity mode stop instruction is received, the physical memory address of the shadow page in the address mapping table of the IOMMU is modified to the physical memory address of the target physical memory page, so that the target pass-through device accesses the target physical memory page;

[0149] In the memory elasticity mode, the physical memory occupied by the target virtual machine is allowed to be reused.

[0150] In an optional embodiment, the virtual machine manager 72 can be further configured to:

[0151] In a case where a specified write instruction for a specified base register address of the target pass-through device is monitored in the target virtual machine, the specified write instruction is intercepted to determine that an update event of index information on the available ring is monitored;

[0152] The specified write instruction is used to write specified content to the specified base register address, so that the target pass-through device learns the update event of index information on the available ring based on the specified content.

[0153] In an optional embodiment, when the virtual machine manager 72 notifies the target pass-through device of the update event, the virtual machine manager 72 can be further configured to:

[0154] The specified content is written to the specified base register address of the target pass-through device to trigger the target pass-through device to learn the update event of index information on the available ring based on the specified content.

[0155] In an optional embodiment, the virtual machine manager 72 can be further configured to:

[0156] In a case where a memory elasticity mode stop instruction is received, the interception of the specified write instruction issued in the target virtual machine is stopped;

[0157] wherein, after the memory elasticity mode is closed, a write instruction is issued by the target virtual machine to write specified content to the specified base register address, so as to trigger the target pass-through device to learn the update event of the index information occurred on the available ring based on the specified content.

[0158] In an optional embodiment, the virtual machine manager 72 can be further configured to:

[0159] determine an index position on the available ring pointed to by the updated index information;

[0160] obtain a descriptor identifier at the index position;

[0161] find a descriptor corresponding to the descriptor identifier from a descriptor queue associated with the available ring, so as to obtain a virtual machine memory address pointed to by the found descriptor as the to-be-accessed virtual machine memory address;

[0162] wherein, a single descriptor in the descriptor queue points to a single virtual machine memory address.

[0163] In an optional embodiment, the virtual machine manager 72 can be further configured to:

[0164] query page table item information corresponding to the to-be-accessed virtual machine memory address from a page table maintained for the target virtual machine;

[0165] if a page fault identifier is carried in the page table item information, determine that the to-be-accessed virtual machine memory address is in a page fault state;

[0166] wherein, the page table is used to map the virtual machine memory address accessed by the target virtual machine to a physical memory address of the host computer.

[0167] In an optional embodiment, the virtual machine manager 72 can be further configured to:

[0168] write-protect the target physical memory page in a case where a memory elasticity mode closing instruction is received;

[0169] remove the write-protection after all memory access operations that have not been completed when it is determined that the memory elasticity mode closing instruction is received are completed.

[0170] In an optional embodiment, the virtual machine manager 72 can be further configured to:

[0171] In a case that the to-be-accessed virtual machine memory address is in a page fault state, a page fault request is sent to an operating system of the host machine to trigger the operating system to call a memory management unit to perform page fault recovery on the to-be-accessed virtual machine memory address;

[0172] After receiving the page fault response fed back by the operating system, it is determined that the to-be-accessed virtual machine memory address completes the page fault recovery.

[0173] Further, as shown in Figure 7 the physical machine further includes a communication component 73, a power supply component 74 and other components. Figure 7 Some components are only schematically shown in the foregoing embodiments, and it does not mean that the physical machine only includes the components shown in the embodiments. Figure 7 The physical machine can further include other components.

[0174] It is worth noting that the technical details in the above embodiments of the physical machine can refer to the related descriptions in the foregoing method embodiments, and will not be repeated here to save space, but this should not cause the loss of the protection scope of the present application.

[0175] Correspondingly, the embodiments of the present application also provide a computer readable storage medium storing a computer program, which can implement each step that can be executed by the virtual machine manager in the above method embodiments when the computer program is executed.

[0176] The memory in the above Figure 7 is used to store computer programs, and can be configured to store other various data to support operations on the computing platform. Examples of these data include instructions of any application or method for operating on the computing platform, contact data, phonebook data, messages, pictures, videos, etc. The memory can be realized by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0177] The above Figure 7The communication component in the electronic device 100 is configured to facilitate wired or wireless communication between the electronic device 100 and other devices. The electronic device 100 can access a wireless network based on a communication standard, such as WiFi, a 2G, 3G, 4G / LTE, 5G, or the like mobile communication network, or a combination thereof. In an example embodiment, the communication component receives broadcast signals or broadcast-related information from external broadcast management systems via a broadcast channel. In an example embodiment, the communication component can further include a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) techniques, infrared data association (IrDA) techniques, ultra-wideband (UWB) techniques, Bluetooth (BT) techniques, and other techniques.

[0178] The power component in the electronic device 100 provides power to various components of the electronic device 100. The power component can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 100. Figure 7

[0179] Those skilled in the art will understand that embodiments of the present application can be provided as a method, a system, or a computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROMs, optical storage devices, and the like) embodying computer readable program code.

[0180] The present application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing system or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 The flowchart illustrations and / or block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatuses, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more executable procedures or functions. In some embodiments, the flowchart illustrations and / or block diagrams can include Figure 1 The flowchart illustrations and / or block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatuses, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more executable procedures or functions. In some embodiments, the flowchart illustrations and / or block diagrams can include

[0181] These computer program instructions can also be stored in a computer- readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instructions which implement the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 The flowchart illustrations and / or block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of apparatuses, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart illustrations and / or block diagrams can represent a module, segment, or portion of instructions, which comprises one or more executable procedures or functions. In some embodiments, the flowchart illustrations and / or block diagrams can include Figure 1 ​the function specified in the one or more blocks.

[0182] These computer program instructions can also be loaded into computer or other programmable data processing devices, so that a series of operation steps are performed on the computer or other programmable data processing devices to generate computer-implemented processes, thus the instructions executed on the computer or other programmable data processing devices provide processes for implementing the flows Figure 1 one or more flows and / or blocks Figure 1 the steps of the function specified in the one or more blocks.

[0183] It should also be noted that the terms "comprising", "including", or any other variant thereof are intended to cover non-exclusive inclusion, so that processes, methods, articles or devices including a series of elements not only include those elements, but also include other elements not explicitly listed, or inherent to such processes, methods, articles or devices. Without more limitations, the element defined by the statement "comprising a" does not exclude the presence of additional identical elements in the process, method, article or device including the element.

[0184] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

[0185] The above only describes the embodiments of the present application and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modification, equivalent replacement, improvement, etc. within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A memory access method, characterized in that, A method applicable to virtual machine managers on a host machine, wherein the transfer of the memory address of a target virtual machine to be accessed between a target virtual machine and a target passthrough device on the host machine is based on an available ring, the method comprising: In response to detecting an index information update event on the available ring, determine the virtual machine memory address to be accessed pointed to by the updated index information on the available ring; If the determined virtual machine memory address to be accessed is detected to be in a page fault state, after the page fault recovery is completed, it is updated to the clone page constructed by the target physical memory page where the index information is located, so that the clone page is consistent with the target physical memory page; The update event is notified to the target pass-through device to trigger the target pass-through device to access the clone page and other physical memory pages in the physical memory pages where the available ring is located, excluding the target physical memory page, in order to obtain the virtual machine memory address to be accessed.

2. The method according to claim 1, characterized in that, Prior to detecting an index information update event on the available ring, the method further includes: Upon receiving a memory elastic mode enable instruction, the physical memory address of the target physical memory page, which was originally recorded in the address mapping table of the Input / Output Memory Management Unit (IOMMU), is replaced with the physical memory address of the clone page, so that the target passthrough device accesses the clone page instead of the target physical memory page. The target pass-through device accesses the host machine's physical memory through address mapping via the IOMMU; in the memory elastic mode, the physical memory occupied by the target virtual machine is allowed to be reused.

3. The method according to claim 2, characterized in that, Also includes: Upon receiving a memory elastic mode shutdown instruction, the physical memory address of the cloned page in the address mapping table of the IOMMU is modified to the physical memory address of the target physical memory page, so that the target passthrough device can access the target physical memory page; When the memory elastic mode is turned off, the physical memory occupied by the target virtual machine is no longer allowed to be reused.

4. The method according to claim 1, characterized in that, Also includes: If a specified write instruction is issued in the target virtual machine for a specified base address register address of the target pass-through device, the specified write instruction is intercepted to determine that an index information update event has occurred on the available ring; The specified write instruction is used to write specified content to the specified base address register address to trigger the target pass-through device to learn about the index information update event that occurred on the available ring based on the specified content.

5. The method according to claim 4, characterized in that, Notifying the target pass-through device of the update event includes: Write the specified content to the specified base address register address of the target pass-through device to trigger the target pass-through device to learn about the index information update event that occurred on the available ring based on the specified content.

6. The method according to claim 4, characterized in that, Also includes: Upon receiving a command to disable memory elastic mode, stop intercepting the specified write command issued from the target virtual machine; Specifically, after the memory elastic mode is turned off, the target virtual machine issues a specified write instruction to write specified content to the specified base address register address, thereby triggering the target pass-through device to learn about the index information update event that occurred on the available ring based on the specified content.

7. The method according to claim 1, characterized in that, Determining the virtual machine memory address to be accessed, pointed to by the updated index information on the available ring, includes: Determine the index position that the updated index information points to on the available ring; Obtain the descriptor identifier at the index position; From the descriptor queue associated with the available ring, search for the descriptor corresponding to the descriptor identifier to obtain the virtual machine memory address pointed to by the found descriptor, which is used as the virtual machine memory address to be accessed; In this context, each descriptor in the descriptor queue points to a single virtual machine memory address.

8. The method according to claim 1, characterized in that, Also includes: From the page table maintained for the target virtual machine, query the page table entry information corresponding to the virtual machine memory address to be accessed; If the page table entry information contains a page fault identifier, then the virtual machine memory address to be accessed is determined to be in a page fault state. The page table is used to map the virtual machine memory address accessed by the target virtual machine to the physical memory address of the host machine.

9. The method according to claim 8, characterized in that, Also includes: Upon receiving a memory elastic mode shutdown command, write protection is applied to the target physical memory page; Write protection is lifted once all memory access operations that were not completed when the memory elastic mode shutdown command was received are completed.

10. The method according to claim 1, characterized in that, Also includes: If the virtual machine memory address to be accessed is in a page fault state, a page fault request is sent to the host operating system to trigger the operating system to call the memory management unit to perform page fault recovery on the virtual machine memory address to be accessed; After receiving the page fault response from the operating system, the virtual machine memory address to be accessed is determined and page fault recovery is completed.

11. A virtual machine manager, characterized in that, include: The monitoring module is configured to, in response to the detection of an index information update event on the available ring, determine the virtual machine memory address to be accessed pointed to by the updated index information on the available ring; The processing module is configured to, if it detects that the virtual machine memory address to be accessed is in a page fault state, update it to a clone page constructed from the target physical memory page where the index information is located after the page fault recovery is completed, so that the clone page is consistent with the target physical memory page; The notification module is configured to notify the target pass-through device of the update event, thereby triggering the target pass-through device to access the clone page and other physical memory pages in the physical memory pages where the available ring is located, excluding the target physical memory page, in order to obtain the virtual machine memory address to be accessed; Specifically, the target virtual machine on the host machine and the target pass-through device exchange the memory address of the virtual machine to be accessed based on the availability ring.

12. The virtual machine manager according to claim 11, characterized in that, It also includes a configuration module, which can be used to: Prior to the monitoring module detecting an update event of index information on the available ring. Upon receiving a memory elastic mode enable instruction, the physical memory address of the target physical memory page, which was originally recorded in the address mapping table of the IOMMU, is replaced with the physical memory address of the clone page, so that the target passthrough device accesses the clone page instead of the target physical memory page. The target pass-through device accesses the host machine's physical memory through address mapping via the IOMMU; in the memory elastic mode, the physical memory occupied by the target virtual machine is allowed to be reused.

13. A physical machine, characterized in that, It includes a memory and a processor, in which a virtual machine manager runs; The memory is used to store one or more computer instructions; The processor is coupled to the memory and is used to execute one or more computer instructions to perform the memory access method according to any one of claims 1-10 using the virtual machine manager.

14. A computer-readable storage medium for storing computer instructions, characterized in that, When the computer instructions are executed by one or more processors, the one or more processors perform the memory access method according to any one of claims 1-10.

Citation Information

Patent Citations

  • Novel memory virtualization method and system based on shadow page table mechanism

    CN112363960A

  • Computing system, memory page fault processing method, and storage medium

    WO2023165400A1