Data copying methods, apparatus, computer-readable storage media and electronic devices

By directly translating intermediate physical addresses into physical addresses on the chip using a virtual machine and configuring them in the direct memory access controller, the increased cost caused by the need for a system memory management unit in the prior art is solved, and a data copy function without SMMU is realized, thus reducing chip cost.

CN115145843BActive Publication Date: 2025-11-14HORIZON JOURNEY (HANGZHOU) ARTIFICIAL INTELLIGENCE TECHNOLOGY CO LTD

Patent Information

Application Number
CN202210868561.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-22
Publication Date
2025-11-14
Estimated Expiration
2042-07-22

AI Technical Summary

Technical Problem

When multiple virtual machines run on a single chip, existing technologies require a system memory management unit within the chip to ensure that the direct memory access controller can correctly obtain addresses for data copying, which increases manufacturing costs.

Method used

The target virtual machine generates an address translation request, which translates the intermediate physical address into a physical address and configures it directly in the direct memory access controller, thus avoiding dependence on the system memory management unit.

Benefits of technology

This reduces chip manufacturing costs and enables data copying functionality in the absence of a system memory management unit.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115145843B_ABST
    Figure CN115145843B_ABST
Patent Text Reader

Abstract

A data copying method, apparatus, computer-readable storage medium, and electronic device are disclosed. The method includes: generating an address translation request via a target virtual machine, the address translation request including an intermediate physical address; converting the intermediate physical address into a physical address via a memory management unit; configuring the physical address in a direct memory access controller via the target virtual machine; and controlling a target module to copy data according to the physical address via the direct memory access controller, the target module including a memory module and / or a peripheral module. Embodiments of this disclosure can reduce chip manufacturing costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to chip technology, and more particularly to a data copying method, apparatus, computer-readable storage medium, and electronic device. Background Technology

[0002] When using a virtualization manager to enable multiple virtual machines to run simultaneously on a single chip, a System Memory Management Unit (SMMU) must be included in the chip to ensure that the Direct Memory Access (DMA) controller in the chip can correctly obtain addresses for data copying. This increases the chip's manufacturing cost. Summary of the Invention

[0003] To address the aforementioned technical problems, this disclosure is proposed. Embodiments of this disclosure provide a data copying method, apparatus, computer-readable storage medium, and electronic device.

[0004] According to one aspect of the embodiments of this disclosure, a data copying method is provided, comprising:

[0005] An address translation request is generated by the target virtual machine, and the address translation request includes an intermediate physical address;

[0006] The intermediate physical address is converted into a physical address through the memory management unit;

[0007] The physical address is configured in the direct memory access controller via the target virtual machine;

[0008] The target module is controlled by the direct memory access controller to copy data according to the physical address. The target module includes a memory module and / or a peripheral module.

[0009] According to another aspect of the present disclosure, a data copying apparatus is provided, comprising:

[0010] A generation module is used to generate an address translation request through a target virtual machine, wherein the address translation request includes an intermediate physical address;

[0011] A conversion module is used to convert the intermediate physical address included in the address conversion request generated by the generation module into a physical address through a memory management unit;

[0012] A configuration module is used to configure the physical address converted by the conversion module into the direct memory access controller through the target virtual machine;

[0013] A control module is used to control the target module to copy data according to the physical address converted by the conversion module through the direct memory access controller. The target module includes a memory module and / or a peripheral module.

[0014] According to another aspect of the present disclosure, a computer-readable storage medium is provided, the storage medium storing a computer program for performing the above-described data copying method.

[0015] According to another aspect of the present disclosure, an electronic device is provided, comprising:

[0016] processor;

[0017] Memory used to store the processor's executable instructions;

[0018] The processor is configured to read the executable instructions from the memory and execute the instructions to implement the data copying method described above.

[0019] Based on the data copying method, apparatus, computer-readable storage medium, and electronic device provided in the above embodiments of this disclosure, an address translation request can be generated by the target virtual machine, the intermediate physical address in the address translation request can be converted into a physical address by the memory management unit, and the physical address can be configured in the direct memory access controller by the target virtual machine. Since the physical address is configured in the direct memory access controller instead of the intermediate physical address in the embodiments of this disclosure, the direct memory access controller can directly control the target module to perform data copying based on the physical address without using the system memory management unit for address translation. Therefore, the chip does not need to be equipped with a system memory management unit, thereby reducing the chip manufacturing cost.

[0020] The technical solutions of this disclosure will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0021] The above and other objects, features, and advantages of this disclosure will become more apparent from the more detailed description of the embodiments thereof in conjunction with the accompanying drawings. The drawings are provided to further illustrate the embodiments of this disclosure and form part of the specification. They are used together with the embodiments of this disclosure to explain the disclosure and do not constitute a limitation thereof. In the drawings, the same reference numerals generally represent the same components or steps.

[0022] Figure 1 This is a schematic diagram of the chip structure in related technologies.

[0023] Figure 2 This is a schematic diagram illustrating the working principle of a chip in related technologies.

[0024] Figure 3 This is a schematic diagram illustrating another working principle of a chip in related technologies.

[0025] Figure 4 This is a schematic diagram of the chip structure in an embodiment of this disclosure.

[0026] Figure 5 This is a schematic diagram illustrating the working principle of the chip in an embodiment of this disclosure.

[0027] Figure 6 This is another schematic diagram of the chip's operation in an embodiment of this disclosure.

[0028] Figure 7 This is a flowchart illustrating a data copying method provided in an exemplary embodiment of this disclosure.

[0029] Figure 8 This is a flowchart illustrating a data copying method provided in another exemplary embodiment of this disclosure.

[0030] Figure 9 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0031] Figure 10 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0032] Figure 11 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0033] Figure 12 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0034] Figure 13-1 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0035] Figure 13-2 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0036] Figure 14-1 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0037] Figure 14-2 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0038] Figure 15-1 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0039] Figure 15-2This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0040] Figure 16 This is a flowchart illustrating a data copying method provided in yet another exemplary embodiment of this disclosure.

[0041] Figure 17 This is a schematic diagram of the structure of a data copying device provided in an exemplary embodiment of the present disclosure.

[0042] Figure 18 This is a schematic diagram of the structure of a data copying device provided in another exemplary embodiment of this disclosure.

[0043] Figure 19 This is a structural diagram of an electronic device provided in an exemplary embodiment of this disclosure. Detailed Implementation

[0044] Hereinafter, exemplary embodiments according to the present disclosure will be described in detail with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of the present disclosure, and not all embodiments of the present disclosure, and it should be understood that the present disclosure is not limited to the exemplary embodiments described herein.

[0045] It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps set forth in these embodiments do not limit the scope of this disclosure.

[0046] Those skilled in the art will understand that the terms "first," "second," etc., in the embodiments of this disclosure are only used to distinguish different steps, devices, or modules, and do not represent any specific technical meaning, nor do they indicate a necessary logical order between them.

[0047] It should also be understood that in the embodiments disclosed herein, "a plurality of" may refer to two or more, and "at least one" may refer to one, two or more.

[0048] It should also be understood that any component, data or structure mentioned in the embodiments of this disclosure can generally be understood as one or more unless expressly defined or given to the contrary in the context.

[0049] Furthermore, the term "and / or" in this disclosure is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this disclosure generally indicates that the preceding and following related objects have an "or" relationship.

[0050] It should also be understood that the description of the various embodiments in this disclosure emphasizes the differences between the various embodiments, and the similarities or similarities can be referred to each other. For the sake of brevity, they will not be described in detail.

[0051] At the same time, it should be understood that, for ease of description, the dimensions of the various parts shown in the accompanying drawings are not drawn according to actual scale.

[0052] The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit this disclosure or its application or use.

[0053] Techniques, methods, and equipment known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and equipment should be considered part of the specification.

[0054] It should be noted that similar labels and letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be discussed further in subsequent figures.

[0055] The embodiments disclosed herein can be applied to electronic devices such as terminal devices, computer systems, and servers, and can operate together with a wide range of other general-purpose or special-purpose computing system environments or configurations. Examples of well-known terminal devices, computing systems, environments, and / or configurations suitable for use with electronic devices such as terminal devices, computer systems, and servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick clients, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputer systems, mainframe computer systems, and distributed cloud computing environments including any of the above systems, etc.

[0056] Electronic devices such as terminal devices, computer systems, and servers can be described in the general context of computer system executable instructions (such as program modules) executed by a computer system. Typically, program modules can include routines, programs, object programs, components, logic, data structures, etc., which perform specific tasks or implement specific abstract data types. Computer systems / servers can be implemented in distributed cloud computing environments, where tasks are executed by remote processing devices linked through communication networks. In distributed cloud computing environments, program modules can reside on local or remote computing system storage media, including storage devices.

[0057] Application Overview

[0058] The chip can be a system-on-a-chip (SOC), such as... Figure 1 , Figure 2 , Figure 3As shown, the chip may include: a Memory Management Unit (MMU), a memory module, a peripheral module, a direct memory access controller, a system memory management unit, and a chip bus module.

[0059] A fundamental function of the memory management unit is virtual memory management, including but not limited to translating virtual addresses to physical addresses (PA), translating virtual addresses to intermediate physical addresses (IPA), and translating intermediate physical addresses to physical addresses.

[0060] Direct memory access controllers are used for data copying, that is, to copy data from one address space to another.

[0061] The system memory management unit is responsible for managing chip peripherals.

[0062] It should be noted that multiple virtual machines (Guest OS) can run simultaneously on a single chip by using a virtualization manager (or virtualization manager module); both the virtualization manager and the multiple virtual machines can be software modules running on the chip.

[0063] In practice, virtual machines can indirectly manipulate hardware through a virtualization manager. When a virtual machine uses a direct memory access controller (DMI), the source and destination addresses of the data can typically be configured in the DMI as IPAs. For example, ... Figure 2 As shown, when Guest OS A, a virtual machine, exclusively uses the direct memory access controller, Guest OS A can directly configure the source and destination addresses in IPA format into the direct memory access controller. For example, ... Figure 3 As shown, when the Guest OS A virtual machine does not exclusively use the direct memory access controller, but shares the direct memory access controller with other virtual machines (in this case, the virtualization manager is responsible for implementing mutual exclusion when each virtual machine accesses the direct memory access controller), the Guest OS A can configure the source address and destination address in IPA form into the direct memory access controller through the virtualization manager.

[0064] The Direct Memory Access Controller (DMI) can provide source and destination addresses in IPA (Input Per Attachment) format to the system memory management unit (SMU), which then translates these addresses into PA (Packet Address Attachment) format. The DMI can also perform data copying based on the PA format source and destination addresses, i.e., controlling relevant modules to copy data from the address space corresponding to the PA format source address to the address space corresponding to the PA format destination address.

[0065] Since the aforementioned data copying scheme requires the use of a system memory management unit (SMU), if the chip lacks an SMU, the direct memory access controller (DMC) cannot correctly obtain addresses (i.e., source and destination addresses in PA form) for data copying during the operation of the virtualization manager and multiple virtual machines. Therefore, to ensure that the DMC module can correctly obtain addresses for data copying, the chip must be equipped with a SMU, which increases the chip's manufacturing cost.

[0066] Exemplary System

[0067] To address the technical problems mentioned in the overview section of the above application, in the embodiments of this disclosure, the approach of configuring IPA-format addresses into the Direct Memory Access Controller (DMI) via a virtual machine, and then having the DMI convert the IPA-format addresses to PA-format addresses using the system memory management unit, can be abandoned. Instead, the approach of having the virtual machine convert the IPA-format addresses to PA-format addresses using the memory management unit, and then having the virtual machine directly configure the PA-format addresses into the DMI, is as follows: Figures 4 to 6 As shown, there is no need to equip the chip with a dedicated system memory management unit, which can reduce the chip's manufacturing cost.

[0068] Exemplary methods

[0069] Figure 7 This is a flowchart illustrating a data copying method provided in an exemplary embodiment of this disclosure. Figure 7 The method shown may include steps 710, 720, 730 and 740, which are described below.

[0070] Step 710: Generate an address translation request through the target virtual machine. The address translation request includes an intermediate physical address.

[0071] It should be noted that the target virtual machine can be any one of multiple virtual machines running on the chip, for example, Figure 5 , Figure 6In Guest OS A, the term "target" in the target virtual machine does not constitute any limitation on the target virtual machine.

[0072] Before generating an address translation request, the target virtual machine can obtain a virtual address and call the memory management unit to translate the virtual address into an intermediate physical address. Next, the target virtual machine can generate an address translation request that includes the intermediate physical address; this request is used to request the translation of the intermediate physical address into a physical address.

[0073] Step 720: The intermediate physical address is converted into a physical address through the memory management unit.

[0074] Optionally, the target virtual machine may forward the address translation request to the memory management unit, which may respond to the address translation request by converting the intermediate physical address included in the address translation request into a physical address; or, the target virtual machine may forward the address translation request to the virtualization manager, which may respond to the address translation request by calling the memory management unit to convert the intermediate physical address included in the address translation request into a physical address.

[0075] Step 730: Configure the physical address in the direct memory access controller through the target virtual machine.

[0076] Optionally, the target virtual machine may configure the physical address in the direct memory access controller according to a pre-defined copy method; or, the target virtual machine may determine a copy method that is compatible with the physical address and configure the physical address in the direct memory access controller according to the determined copy method.

[0077] Step 740: Control the target module to copy data according to the physical address through the direct memory access controller. The target module includes a memory module and / or a peripheral module.

[0078] like Figure 5 , Figure 6 As shown, the memory module, peripheral module, and direct memory access controller can all interact with the chip bus module. In this way, the direct memory access controller can control the memory module and / or peripheral module by relaying the interactive information through the chip bus module. Under the control of the direct memory access controller, the memory module and / or peripheral module can copy data according to the physical address.

[0079] In the embodiments of this disclosure, an address translation request can be generated by the target virtual machine, the intermediate physical address in the address translation request can be converted into a physical address by the memory management unit, and the physical address can be configured in the direct memory access controller by the target virtual machine. Since the physical address is configured in the direct memory access controller instead of the intermediate physical address in the embodiments of this disclosure, the direct memory access controller can directly control the target module to perform data copying based on the physical address without using the system memory management unit for address translation. Therefore, the chip does not need to be equipped with a system memory management unit, thereby reducing the chip manufacturing cost.

[0080] exist Figure 7 Based on the illustrated embodiments, as Figure 8 As shown, before step 720, the method further includes step 715.

[0081] Step 715: The intermediate physical address is sent to the memory management unit via the virtualization manager.

[0082] After the target virtual machine generates an address translation request, it can forward the request to the virtualization manager. Upon receiving the address translation request from the target virtual machine, the virtualization manager can send the intermediate physical address included in the request to the memory management unit. Upon receiving the intermediate physical address from the virtualization manager, the memory management unit can translate the intermediate physical address into a physical address and return the physical address to the virtualization manager. Upon receiving the physical address from the memory management unit, the virtualization manager can provide the physical address to the target virtual machine, enabling the target virtual machine to configure the physical address in the direct memory access controller.

[0083] In embodiments of this disclosure, the intermediate physical address included in the address translation request can be efficiently and reliably provided to the memory management unit by means of a virtualization manager, so that the memory management unit can perform the corresponding address translation processing.

[0084] In an optional example, the intermediate physical address includes an intermediate physical source address and an intermediate physical destination address, and the physical address includes the physical source address converted from the intermediate physical source address and the physical destination address converted from the intermediate physical destination address;

[0085] exist Figure 7 Based on the illustrated embodiments, as Figure 9 As shown, step 740 includes steps 7402, 7404 and 7406.

[0086] Step 7402: Determine the data characteristic information of the stored data corresponding to the physical source address.

[0087] Optionally, the stored data corresponding to the physical source address may refer to the data stored in the address space corresponding to the physical source address; data characteristic information includes, but is not limited to, data format, data size, data update cycle, etc.

[0088] Step 7404: Determine the copy method that matches the data characteristic information of the stored data corresponding to the physical source address.

[0089] It should be noted that the correspondence between data feature information and copying methods can be preset. Copying methods include, but are not limited to, single transmission, loop transmission, and double buffering mode. In step 7404, the copying method corresponding to the data feature information determined in step 7402 can be determined based on the preset correspondence. The determined copying method can then be used as the copying method that matches the data feature information.

[0090] Step 7406: The target module is controlled by the direct memory access controller to copy the stored data from the physical source address to the physical target address according to the determined copy method.

[0091] Assuming the intermediate physical source address included in the intermediate physical address is IPA1, the intermediate physical destination address included in the intermediate physical address is IPA2, the physical source address obtained by IPA1 is PA1, and the physical destination address obtained by IPA2 is PA2, then the physical address can include PA1 and PA2.

[0092] After obtaining the physical addresses of PA1 and PA2, the data characteristic information T1 of the stored data Data1 corresponding to PA1 can be determined. Based on the pre-set correspondence between the data characteristic information and the copying method, the copying method C1 corresponding to T1 is determined. The target module is then controlled by the direct memory access controller to copy Data1 from PA1 to PA2 (i.e., from the address space corresponding to PA1 to the address space corresponding to PA2) according to the copying method C1.

[0093] Optionally, PA1 can be either a memory address or an address of a peripheral device on the bus; PA2 can also be either a memory address or an address of a peripheral device on the bus. Thus, when copying Data1 from PA1 to PA2, the copy path of Data1 can have the following four possibilities: memory address → memory address; memory address → peripheral address; peripheral address → peripheral address; peripheral address → memory address.

[0094] In the embodiments of this disclosure, the physical address obtained by the intermediate physical address translation included in the address translation request can simultaneously include a physical source address and a physical destination address. Furthermore, the data characteristic information of the stored data corresponding to the physical source address can be referenced to perform the copying of the stored data in a manner that is compatible with it. For example, if the amount of stored data is very small, a single transmission method can be used to efficiently copy the stored data. Or, if the stored data is peripheral data that needs to be read periodically, a cyclic transmission method can be used to copy the stored data. This helps to ensure data copying efficiency and can meet the data requirements.

[0095] exist Figure 7 Based on the illustrated embodiments, as Figure 10 As shown, after step 740, the method further includes steps 750 and 760.

[0096] Step 750: In response to the detection of data copy failure, determine whether the number of data copy failures has reached a preset number; if yes, proceed to step 760; if no, return to step 730.

[0097] Step 760: Output an exception message for the direct memory access controller.

[0098] Optionally, the preset number of times can be 2, 3, 4, 5 or other numbers, which will not be listed here.

[0099] Optionally, the output format of the abnormal prompt information includes, but is not limited to, voice, text, and light.

[0100] After controlling the target module to copy data according to the physical address by executing step 740, it is possible to detect whether the data copy was successful or failed.

[0101] If a data copy failure is detected, the number of data copy failures can be determined and compared with a preset number.

[0102] If the number of data copy failures is less than the preset number, the process can return to step 730, which involves reconfiguring the physical address in the direct memory access controller via the target virtual machine. The subsequent steps after step 730 will also be executed again.

[0103] If the number of data copy failures is greater than or equal to a preset number, an error message for the Direct Memory Access Controller (DMA controller) can be output. This could be done via voice announcement of "DMA controller error" or by displaying a pop-up window on the screen, prompting manual troubleshooting of the DMA controller malfunction. Generally, DMA controller malfunctions can be caused by: clock errors, power supply errors, memory module errors, peripheral module errors, DMA controller errors, electromagnetic compatibility (EMC) interference, etc.

[0104] It should be noted that if the number of data copy failures is greater than or equal to the preset number, in addition to outputting an error message, the execution of steps 710 to 740 above can be prohibited until the cause of the direct memory access controller error is manually identified, thereby resolving the direct memory access controller error problem.

[0105] In one example, the preset number of attempts is 2. The physical address obtained from the intermediate physical address translation in the address translation request includes both the physical source address PA1 and the physical destination address PA2. If PA1 and PA2 are configured in the Direct Memory Access Controller (DMI) for the first time through the target virtual machine, and the target module is controlled to copy Data1 from PA1 to PA2 for the first time, a data copy failure is detected. Since the number of data copy failures at this point is 1, which is less than the preset number, PA1 and PA2 can be configured in the DMI a second time through the target virtual machine, and the target module is controlled to copy Data1 from PA1 to PA2 a second time. If the data copy fails again after the target module copies Data1 from PA1 to PA2 for the second time, since the number of data copy failures at this point is 2, which is equal to the preset number, an error message for the DMI can be output in voice or text format.

[0106] In the embodiments of this disclosure, after the control target module performs data copying according to the physical address, if the data copying fails and the number of data copying failures has not reached a preset number, the process can return to the step of configuring the physical address so that the data copying can be attempted again. However, if the data copying fails and the number of data copying failures reaches the preset number, the data copying will no longer be attempted. Instead, an error message will be output to prompt manual investigation of the cause of the memory access controller's abnormality, so as to eliminate the abnormality as soon as possible and enable normal data copying in the future.

[0107] exist Figure 7 Based on the illustrated embodiments, as Figure 11As shown, before step 730, the method further includes steps 722 and 724.

[0108] Step 722: Obtain the target virtual machine's occupancy mode for the direct memory access controller;

[0109] It should be noted that there are two possible usage modes: exclusive mode and non-exclusive mode. In exclusive mode, the target virtual machine can communicate directly with the direct memory access controller; in non-exclusive mode, the target virtual machine can communicate with the direct memory access controller through the virtualization manager. For details on exclusive mode, please refer to [link to relevant documentation]. Figure 5 For the non-exclusive mode, please refer to [link / reference]. Figure 6 .

[0110] Step 724: Obtain control information for the direct memory access controller.

[0111] Optionally, the control information obtained in step 724 can also be called DMA control information. The DMA control information may include at least one of the following: copy speed information, copy mode information, and data verification method.

[0112] Step 730 includes steps 7302 and 7304.

[0113] Step 7302: Determine the configuration method that matches the occupancy mode.

[0114] If the occupancy mode is exclusive, the configuration method that matches the occupancy mode can be: direct configuration; if the occupancy mode is non-exclusive, the configuration method that matches the occupancy mode can be: configuration through the virtualization manager.

[0115] Step 7304: Configure the physical address and control information in the direct memory access controller according to the configuration method through the target virtual machine.

[0116] If the occupancy mode is exclusive, the target virtual machine can directly configure the physical address and control information to the direct memory access controller; if the occupancy mode is non-exclusive, the target virtual machine can configure the physical address and control information to the direct memory access controller through the virtualization manager.

[0117] In the embodiments of this disclosure, a configuration method adapted to the target virtual machine's occupation mode of the direct memory access controller can be adopted to efficiently and reliably configure the physical address and control information in the direct memory access controller, so that the direct memory access controller can perform data copying processing with reference to the physical address and control information.

[0118] exist Figure 7 Based on the illustrated embodiments, as Figure 12 As shown, step 730 includes steps 7306 and 7308.

[0119] Step 7306: Determine the target virtual machine's access permissions to the physical address through the virtualization manager.

[0120] Optionally, the virtualization manager can determine the target virtual machine's access permission information to physical addresses according to a predetermined access permission control policy. The access permission information can be used to characterize whether the target virtual machine has access permission to physical addresses.

[0121] In one specific implementation, the physical address has a corresponding access whitelist, which includes multiple virtual machine identification information. Figure 12 Based on the illustrated embodiment, step 7306 includes Figure 13-1 Step 73062 or Figure 13-2 Step 73064 in the text.

[0122] Step 73062: In response to the target virtual machine's identification information being in the access whitelist, the virtualization manager determines the access permission information to indicate that the target virtual machine has access permissions to the physical address.

[0123] Step 73064: In response to the fact that the identification information of the target virtual machine is not in the access whitelist, the access permission information is determined by the virtualization manager to indicate that the target virtual machine does not have access permission to the physical address.

[0124] It should be noted that the mapping between physical addresses and access whitelists can be stored in advance. After the intermediate physical address included in the address translation request is converted into a physical address by the memory management unit, the virtualization manager can determine the access whitelist corresponding to the physical address based on the pre-stored mapping and traverse the access whitelist corresponding to the physical address to determine whether the identification information of the target virtual machine is in the access whitelist corresponding to the physical address.

[0125] If the target virtual machine's identification information is in the access whitelist corresponding to the physical address, the access permission information determined by the virtualization manager can be represented as "1", indicating that the target virtual machine has access permission to the physical address. If the target virtual machine's identification information is not in the access whitelist corresponding to the physical address, the access permission information determined by the virtualization manager can be represented as "0", indicating that the target virtual machine does not have access permission to the physical address.

[0126] By adopting this implementation method, due to the setting of the access whitelist, it is possible to efficiently and reliably determine whether the target virtual machine has access rights to the physical address by judging whether the identification information of the target virtual machine is in the access whitelist corresponding to the physical address.

[0127] It should be noted that, in specific implementations, a corresponding access blacklist can also be set for the physical address. If the target virtual machine's identification information is in the access blacklist, the access permission information can indicate that the target virtual machine does not have access to the physical address. Conversely, if the target virtual machine's identification information is not in the access blacklist, the access permission information can indicate that the target virtual machine has access to the physical address.

[0128] Step 7308: In response to the access permission information indicating that the target virtual machine has access permission to the physical address, the physical address is configured in the direct memory access controller through the target virtual machine.

[0129] If the access permission information indicates that the target virtual machine has access to the physical address, the virtualization manager can send the physical address to the target virtual machine. The target virtual machine can then configure the physical address in the direct memory access controller, so that the direct memory access controller can perform data copying based on the physical address.

[0130] If the access permission information indicates that the target virtual machine does not have access to the physical address, the virtualization manager may not send the physical address to the target virtual machine, and the target virtual machine will not configure the physical address.

[0131] In the embodiments of this disclosure, the virtualization manager can determine the target virtual machine's access permission information to the physical address, and only when the access permission information indicates that the target virtual machine has access permission to the physical address, the physical address is configured in the direct memory access controller by the target virtual machine. Thus, the embodiments of this disclosure use the virtualization manager to make access permission related judgments before configuring the physical address in the direct memory access controller, thereby restricting which areas the target virtual machine can access through the direct memory access controller, which helps to ensure the security of the target virtual machine's access to memory through the direct memory access controller.

[0132] exist Figure 13-1 or Figure 13-2 Based on the illustrated embodiments, as Figure 14-1 or Figure 14-2 As shown, step 720 includes step 7202.

[0133] Step 7202: In response to the absence of an intermediate physical address in the recorded addresses, the intermediate physical address is converted to a physical address through the memory management unit;

[0134] The method also includes step 770.

[0135] Step 770: In response to the access permission information indicating that the target virtual machine does not have access permission to the physical address, an intermediate physical address is added to the recorded address.

[0136] Alternatively, the recorded addresses can be represented in the form of an address table.

[0137] In a specific example, the target virtual machine is Guest OS A. Suppose that Guest OS A generates an address translation request that includes the intermediate physical address IPA0, and then sends the address translation request to the virtualization manager. The virtualization manager can traverse the recorded addresses to determine whether IPA0 exists among the recorded addresses.

[0138] If IPA0 exists in the recorded address, the virtualization manager can directly reject the address translation request from Guest OS A.

[0139] If IPA0 is not present in the recorded address set, the virtualization manager can call the memory management unit to translate IPA0 into a physical address, which can then be PA0. The virtualization manager can further determine the access permissions of Guest OS A to PA0. If the access permission information indicates that Guest OS A does not have access to PA0, the virtualization manager can add IPA0 to the recorded address set. If the access permission information indicates that Guest OS A has access to PA0, the virtualization manager will not add IPA0 to the recorded address set. The virtualization manager can also send PA0 to Guest OS A so that Guest OS A can configure PA0 in the direct memory access controller.

[0140] In the case where the access permission information indicates that Guest OS A does not have access to PA0, since the virtualization manager added IPA0 to the recorded address, when Guest OS A generates an address translation request that includes the intermediate physical address IPA0 and sends the address translation request to the virtualization manager, the virtualization manager can determine that IPA0 exists in the recorded address by traversing the recorded address. At this time, the virtualization manager can directly reject the address translation request of Guest OS A without calling the memory management unit to translate IPA0 into a physical address and performing the access permission information determination step and the physical address configuration step based on the physical address. This helps to save computing resources.

[0141] In the embodiments of this disclosure, by updating and utilizing the recorded addresses, it is not necessary to convert all intermediate physical addresses in all address translation requests through the memory management unit. Instead, only intermediate physical addresses that do not exist in the recorded addresses need to be converted, which helps to save computing resources.

[0142] exist Figure 13-1 or Figure 13-2 Based on the illustrated embodiments, as Figure 15-1 or Figure 15-2 As shown, the method further includes steps 780 and 790.

[0143] Step 780: In response to the target virtual machine generating more than a preset number of address translation requests within a preset time period, and the access permission information corresponding to each address translation request indicating that the target virtual machine does not have access permission to the physical address, output permission confirmation prompt information; wherein, the permission confirmation prompt information includes the identification information and physical address of the target virtual machine.

[0144] Optionally, the preset duration can be 30 seconds, 1 minute, 2 minutes, etc., and the preset quantity can be 30, 40, 50, 60, 100, etc., which will not be listed here.

[0145] Assuming the target virtual machine generates 105 address translation requests, including physical addresses, within one minute, and based on the access whitelist corresponding to the physical addresses, the virtualization manager determines that the access permission information corresponding to each address translation request indicates that the target virtual machine does not have access to the physical addresses. In this case, a permission confirmation prompt message, including the target virtual machine's identification information and the physical addresses, can be output via voice or text. For example, it could announce "Please confirm whether Guest OS A has access to PA0" via voice, or display a pop-up window on the screen saying "Please confirm whether Guest OS A has access to PA0," prompting manual confirmation of whether Guest OS A has access to PA0.

[0146] Step 790: In response to the triggered operation of the permission confirmation prompt message, add the identification information of the target virtual machine to the access whitelist.

[0147] Optionally, in response to the permission confirmation prompt message output in step 780, a person can verbally say "yes" or "no". If the person verbally says "yes", it can be considered that a trigger operation for the permission confirmation prompt message has been received, and then the name of Guest OS A can be added to the access whitelist. Alternatively, two selection buttons, "yes" and "no", can be displayed at the bottom of the pop-up window on the screen. In response to the permission confirmation prompt message output in step 780, a person can manually select the "yes" or "no" selection button. If the person manually selects the "yes" selection button, it can be considered that a trigger operation for the permission confirmation prompt message has been received, and then the name of Guest OS A can be added to the access whitelist.

[0148] In the embodiments of this disclosure, if the target virtual machine generates a large number of address translation requests that include the same intermediate physical address in a short period of time, and the access permission information corresponding to each address translation request indicates that the target virtual machine does not have access permission to the physical address, then the user can be prompted to manually confirm whether the target virtual machine has access permission to the physical address by outputting the permission confirmation prompt. If the user confirms that the target virtual machine has access permission to the physical address, then the identification information of the target virtual machine can be added to the access whitelist, thereby ensuring the accuracy of the information recorded in the access whitelist.

[0149] Optionally, such as Figure 16 As shown, the data copying method provided in the embodiments of this disclosure may include the following steps:

[0150] Step 1602: Guest OS A uses the MMU to translate the virtual source address VA1 and the virtual destination address VA2 into the intermediate physical source address IPA1 and the intermediate physical destination address IPA2.

[0151] Step 1604: Guest OS A requests the virtualization manager to use the MMU to translate the intermediate physical source address IPA1 and intermediate physical destination address IPA2 into physical source address PA1 and physical destination address PA2.

[0152] Step 1606: Guest OS A configures the physical source address PA1, physical destination address PA2, and control information into the DMA controller (suitable for the case where Guest OS A exclusively controls the DMA controller; or, Guest OS A configures the physical source address PA1, physical destination address PA2, and control information into the DMA controller through the virtualization manager (suitable for the case where Guest OS A shares the DMA controller with other virtual machines).

[0153] Step 1608: The DMA controller controls the memory module or peripheral module to copy data from the physical source address PA1 to the physical destination address PA2.

[0154] In summary, the embodiments of this disclosure can virtualize the DMA controller on a chip without an SMMU, enabling multiple virtual machines running on the chip to correctly and quickly use the DMA controller to copy data, which helps to reduce chip costs.

[0155] Any data copying method provided in this disclosure can be executed by any suitable device with data processing capabilities, including but not limited to: terminal devices and servers. Alternatively, any data copying method provided in this disclosure can be executed by a processor, such as by a processor executing any data copying method mentioned in this disclosure by calling corresponding instructions stored in memory. Further details will not be elaborated below.

[0156] Exemplary device

[0157] Figure 17 This is a schematic diagram of the structure of a data copying device provided in an exemplary embodiment of the present disclosure. Figure 17 The apparatus shown includes a generation module 1710, a conversion module 1720, a configuration module 1730, and a control module 1740.

[0158] The generation module 1710 is used to generate an address translation request through the target virtual machine. The address translation request includes an intermediate physical address.

[0159] The conversion module 1720 is used to convert the intermediate physical address included in the address translation request generated by the generation module 1710 into a physical address through the memory management unit;

[0160] Configuration module 1730 is used to configure the physical address converted by translation module 1720 in the direct memory access controller through the target virtual machine;

[0161] The control module 1740 is used to control the target module to copy data according to the physical address converted by the conversion module 1720 through the direct memory access controller. The target module includes a memory module and / or a peripheral module.

[0162] In an optional example, such as Figure 18 As shown, the device also includes:

[0163] The sending module 1715 is used to send the intermediate physical address to the memory management unit via the virtualization manager before the intermediate physical address included in the address translation request generated by the generation module 1710 is translated into a physical address via the memory management unit.

[0164] In an optional example, the intermediate physical address includes an intermediate physical source address and an intermediate physical destination address, and the physical address includes the physical source address converted from the intermediate physical source address and the physical destination address converted from the intermediate physical destination address;

[0165] like Figure 18 As shown, the control module 1740 includes:

[0166] The first determining submodule 17402 is used to determine the data characteristic information of the stored data corresponding to the physical source address;

[0167] The second determining submodule 17404 is used to determine the copying method that matches the data feature information determined by the first determining submodule 17402;

[0168] The control submodule 17406 is used to control the target module to copy the stored data from the physical source address to the physical target address according to the copy method determined by the second determining submodule 17404 through the direct memory access controller.

[0169] In an optional example, such as Figure 18 As shown, the method also includes:

[0170] The trigger module 1750 is used to trigger the configuration module 1730 in response to the detection of data copy failure and the fact that the number of data copy failures has not reached a preset number after the control module 1740 controls the target module to copy data according to the physical address through the direct memory access controller.

[0171] The output module 1760 is used to output an abnormal prompt message to the direct memory access controller after the control module 1740 controls the target module to copy data according to the physical address through the direct memory access controller, in response to the detection of data copy failure and the number of data copy failures reaching a preset number.

[0172] In an optional example, such as Figure 18 As shown, the device also includes:

[0173] The first acquisition module 1722 is used to acquire the occupancy mode of the target virtual machine to the direct memory access controller before configuring the physical address in the direct memory access controller through the target virtual machine.

[0174] The second acquisition module 1724 is used to acquire control information for the direct memory access controller;

[0175] Configuration module 1730 includes:

[0176] The third determining submodule 17302 is used to determine the configuration method that matches the occupancy mode obtained by the first obtaining module 1722;

[0177] The configuration submodule 17304 is used to configure the physical address and the control information obtained by the second acquisition module 1724 in the direct memory access controller according to the configuration method determined by the third determination submodule 17302 through the target virtual machine.

[0178] Exemplary electronic devices

[0179] Below, for reference Figure 19 This describes an electronic device according to embodiments of the present disclosure. The electronic device may be either or both of a first device and a second device, or a standalone device independent of them, which may communicate with the first device and the second device to receive acquired input signals from them.

[0180] Figure 19 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.

[0181] like Figure 19 As shown, the electronic device 1900 includes one or more processors 1910 and memory 1920.

[0182] The processor 1910 may be a central processing unit (CPU) or other form of processing unit with data processing and / or instruction execution capabilities, and may control other components in the electronic device 1900 to perform desired functions.

[0183] The memory 1920 may include one or more computer program products, which may include various forms of computer-readable storage media, such as volatile memory and / or non-volatile memory. The volatile memory may include, for example, random access memory (RAM) and / or cache memory. The non-volatile memory may include, for example, read-only memory (ROM), hard disk, flash memory, etc. One or more computer program instructions may be stored on the computer-readable storage medium, and the processor 1910 may execute the program instructions to implement the data copying methods of the various embodiments of this disclosure described above and / or other desired functions. Various contents such as input signals, signal components, and noise components may also be stored in the computer-readable storage medium.

[0184] In one example, the electronic device 1900 may also include an input device 1930 and an output device 1940, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).

[0185] For example, when the electronic device is a first device or a second device, the input device 1930 may be a microphone or a microphone array. When the electronic device is a standalone device, the input device 13 may be a communication network connector for receiving acquired input signals from the first device and the second device.

[0186] In addition, the input device 1930 may also include, for example, a keyboard, a mouse, etc.

[0187] The output device 1940 can output various information to the outside, including determined distance information, direction information, etc. The output device 1940 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.

[0188] Of course, for the sake of simplicity, Figure 19 Only some of the components of the electronic device 1900 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 1900 may include any other suitable components depending on the specific application.

[0189] Exemplary computer program products and computer-readable storage media

[0190] In addition to the methods and apparatus described above, embodiments of this disclosure may also be computer program products comprising computer program instructions that, when executed by a processor, cause the processor to perform the steps of the data copying methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.

[0191] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this disclosure. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0192] Furthermore, embodiments of this disclosure may also be computer-readable storage media having stored thereon computer program instructions that, when executed by a processor, cause the processor to perform the steps of the data copying methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.

[0193] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0194] The basic principles of this disclosure have been described above with reference to specific embodiments. However, it should be noted that the advantages, benefits, and effects mentioned in this disclosure are merely examples and not limitations, and should not be considered as essential features of each embodiment of this disclosure. Furthermore, the specific details disclosed above are for illustrative and facilitative purposes only, and are not limitations. These details do not limit the scope of this disclosure to the necessity of employing the aforementioned specific details for implementation.

[0195] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For system embodiments, since they largely correspond to method embodiments, the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0196] The block diagrams of devices, apparatuses, devices, and systems disclosed herein are merely illustrative examples and are not intended to require or imply that they must be connected, arranged, or configured in the manner shown in the block diagrams. As those skilled in the art will recognize, these devices, apparatuses, devices, and systems can be connected, arranged, and configured in any manner. Words such as “comprising,” “including,” “having,” etc., are open-ended terms meaning “including but not limited to,” and are used interchangeably with them. The terms “or” and “and” as used herein refer to the terms “and / or,” and are used interchangeably with them unless the context clearly indicates otherwise. The term “such as” as used herein refers to the phrase “such as but not limited to,” and is used interchangeably with it.

[0197] The methods and apparatus of this disclosure may be implemented in many ways. For example, they may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above-described order of steps for the methods is for illustrative purposes only, and the steps of the methods of this disclosure are not limited to the order specifically described above unless otherwise specifically stated. Furthermore, in some embodiments, this disclosure may also be implemented as a program recorded on a recording medium, the program including machine-readable instructions for implementing the methods according to this disclosure. Thus, this disclosure also covers recording media storing programs for performing the methods according to this disclosure.

[0198] It should also be noted that in the apparatus, devices, and methods of this disclosure, the components or steps can be disassembled and / or recombined. These disassemblies and / or recombinations should be considered as equivalent solutions to this disclosure.

[0199] The above description of the disclosed aspects is provided to enable any person skilled in the art to make or use this disclosure. Various modifications to these aspects will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other aspects without departing from the scope of this disclosure. Therefore, this disclosure is not intended to be limited to the aspects shown herein, but rather to be carried out within the widest scope consistent with the principles and novel features disclosed herein.

[0200] The above description has been given for purposes of illustration and description. Furthermore, this description is not intended to limit the embodiments of this disclosure to the forms disclosed herein. Although numerous exemplary aspects and embodiments have been discussed above, those skilled in the art will recognize certain variations, modifications, alterations, additions, and sub-combinations thereof.

Claims

1. A data copying method applied to a chip, the chip including a memory management unit, a direct memory access controller, and a target module, the target module including a memory module and / or a peripheral module; the method comprising: An address translation request is generated by the target virtual machine. The address translation request includes an intermediate physical address. The target virtual machine is any one of the multiple virtual machines running on the chip. The intermediate physical address is obtained by the target virtual machine calling the memory management unit to translate the virtual address. The virtual address includes a virtual source address and a virtual target address. The intermediate physical address includes an intermediate physical source address translated from the virtual source address and an intermediate physical target address translated from the virtual target address. The memory management unit converts the intermediate physical address into a physical address, which includes a physical source address converted from the intermediate physical source address and a physical target address converted from the intermediate physical target address. The physical address is configured in the direct memory access controller via the target virtual machine; The direct memory access controller controls the target module to copy data according to the physical address, so as to copy the stored data corresponding to the physical source address from the physical source address to the physical target address.

2. The method according to claim 1, wherein, Before the intermediate physical address is translated into a physical address by the memory management unit, the method further includes: The intermediate physical address is sent to the memory management unit via the virtualization manager.

3. The method according to claim 1, wherein, The step of controlling the target module to copy data according to the physical address via the direct memory access controller includes: Determine the data characteristic information of the stored data corresponding to the physical source address; Determine the copy method that matches the data feature information; The direct memory access controller controls the target module to copy the stored data from the physical source address to the physical target address according to the copy method.

4. The method according to claim 1, wherein, After controlling the target module to copy data according to the physical address via the direct memory access controller, the method further includes: In response to the detection of the data copy failure, and the number of data copy failures has not reached a preset number, the process returns to the step of configuring the physical address in the direct memory access controller through the target virtual machine; In response to the detection of a data copy failure, and the number of data copy failures reaching the preset number, an exception message is output for the direct memory access controller.

5. The method according to claim 1, wherein, Before configuring the physical address in the direct memory access controller via the target virtual machine, the method further includes: Obtain the target virtual machine's occupancy mode for the direct memory access controller; Obtain control information for the direct memory access controller; The step of configuring the physical address in the direct memory access controller through the target virtual machine includes: Determine the configuration method that matches the occupancy pattern; The physical address and control information are configured in the direct memory access controller according to the configuration method of the target virtual machine.

6. A data copying device applied to a chip, the chip including a memory management unit, a direct memory access controller, and a target module, the target module including a memory module and / or a peripheral module; the device comprising: A generation module is used to generate an address translation request through a target virtual machine. The address translation request includes an intermediate physical address. The target virtual machine is any one of a plurality of virtual machines running on the chip. The intermediate physical address is obtained by the target virtual machine calling the memory management unit to translate the virtual address. The virtual address includes a virtual source address and a virtual target address. The intermediate physical address includes an intermediate physical source address translated from the virtual source address and an intermediate physical target address translated from the virtual target address. A conversion module is used to convert the intermediate physical address included in the address conversion request generated by the generation module into a physical address through the memory management unit. The physical address includes a physical source address converted from the intermediate physical source address and a physical target address converted from the intermediate physical target address. A configuration module is used to configure the physical address converted by the conversion module into the direct memory access controller via the target virtual machine; The control module is used to control the target module to copy data according to the physical address converted by the conversion module through the direct memory access controller, so as to copy the stored data corresponding to the physical source address from the physical source address to the physical target address.

7. The apparatus according to claim 6, further comprising: The sending module is configured to send the intermediate physical address included in the address translation request generated by the generation module to the memory management unit via the virtualization manager before the intermediate physical address included in the address translation request generated by the generation module is converted into a physical address via the memory management unit.

8. The apparatus according to claim 6, wherein, The control module includes: The first determining submodule is used to determine the data characteristic information of the stored data corresponding to the physical source address; The second determining submodule is used to determine a copying method that matches the data feature information determined by the first determining submodule; The control submodule is used to control the target module to copy the stored data from the physical source address to the physical target address according to the copy method determined by the second determining submodule through the direct memory access controller.

9. A computer-readable storage medium storing a computer program for performing the data copying method according to any one of claims 1-5.

10. An electronic device, comprising: processor; Memory used to store the processor's executable instructions; The processor is configured to read the executable instructions from the memory and execute the instructions to implement the data copying method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Memory page changing method and system and storage medium

    CN114201269A

Cited By

  • Data copying method and apparatus, computer-readable storage medium, and electronic device

    WO2024017146A1