Access control method, device, computer readable storage medium and electronic device
By configuring the physical address after the virtualization manager determines the access permissions on the chip, the increased cost caused by the need to equip an SMMU in the prior art is solved, and a secure and efficient direct memory access control is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HORIZON JOURNEY (HANGZHOU) ARTIFICIAL INTELLIGENCE TECHNOLOGY CO LTD
- Filing Date
- 2022-07-22
- Publication Date
- 2026-06-02
Smart Images

Figure CN115185643B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to chip technology, and more particularly to an access control 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 the security of memory access by the Direct Memory Access (DMA) controller. 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 an access control method, apparatus, computer-readable storage medium, and electronic device.
[0004] According to one aspect of the embodiments of this disclosure, an access control 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 virtualization manager determines the access permissions of the target virtual machine to the physical address;
[0008] 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.
[0009] According to another aspect of the present disclosure, an access control device 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] The determination module is used to determine, through the virtualization manager, the access permissions of the target virtual machine to the physical address converted by the conversion module;
[0013] A configuration module is configured to, in response to the access permission information determined by the determining module indicating that the target virtual machine has access permission to the physical address, configure the physical address in the direct memory access controller through the target virtual machine.
[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 access control method described above.
[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 access control method described above.
[0019] Based on the access control 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 is converted into a physical address by the memory management unit. When the access permission information determined by the virtualization manager 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. Since in the embodiments of this disclosure, the physical address, not the intermediate physical address, is configured in the direct memory access controller, the direct memory access controller can directly perform data copying based on the physical address. Furthermore, before configuring the physical address in the direct memory access controller, access permission related determination (i.e., determining whether the target virtual machine has access permission to the physical address) has been performed. This restricts the area accessible to the target virtual machine through the direct memory access controller. Thus, in the embodiments of this disclosure, the direct memory access controller does not need to obtain the physical address through the system memory management unit, nor does it need to perform access permission related determination through the system memory management unit. Therefore, the chip does not need to be equipped with a system memory management unit (see details...). Figure 7 (The chip structure in the chip) can reduce the manufacturing cost of the chip.
[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 flowchart illustrating an exemplary embodiment of the access control method provided in 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 schematic diagram of the chip structure in an embodiment of this disclosure.
[0029] Figure 8-1 This is a flowchart illustrating an access control method provided in another exemplary embodiment of this disclosure.
[0030] Figure 8-2 This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0031] Figure 9-1 This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0032] Figure 9-2 This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0033] Figure 10-1 This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0034] Figure 10-2 This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0035] Figure 11This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0036] Figure 12 This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0037] Figure 13 This is a flowchart illustrating an access control method provided in yet another exemplary embodiment of this disclosure.
[0038] Figure 14 This is a schematic diagram of the structure of an access control device provided in an exemplary embodiment of the present disclosure.
[0039] Figure 15-1 This is a schematic diagram of the structure of an access control device provided in another exemplary embodiment of this disclosure.
[0040] Figure 15-2 This is a schematic diagram of the structure of an access control device provided in another exemplary embodiment of the present disclosure.
[0041] Figure 16 This is a schematic diagram of the structure of an access control device provided in yet another exemplary embodiment of this disclosure.
[0042] Figure 17 This is a schematic diagram of the structure of an access control device provided in yet another exemplary embodiment of this disclosure.
[0043] Figure 18 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 3 As 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 this can be achieved by using... Figure 1 , Figure 2 , Figure 3 The virtualization manager shown enables multiple virtual machines (Guest OS) to run simultaneously on a single chip; 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 data can be configured in the DMI in IPA format. For example, ... Figure 2As 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, controlling relevant modules (such as memory modules or peripheral 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] Considering the security of virtual machines accessing memory through the Direct Memory Access Controller (DMI), after the DMI provides the source and destination addresses in IPA format to the System Memory Management Unit (SMU), the SMU can check whether the DMI has access rights to the source and destination addresses in PA format. If the check result is negative, the SMU will not return the source and destination addresses in IPA format to the DMI, and the SMU will report an error.
[0066] It's important to note that without a system memory management unit (SMU) in the chip, it's impossible to restrict the direct memory access controller's (DMC) memory access permissions while running multiple virtual machines and virtualization managers, thus compromising the security of DMC memory access. To ensure the security of DMC memory access, the chip must be equipped with a SMU, which increases manufacturing costs.
[0067] Exemplary methods
[0068] Figure 4 This is a flowchart illustrating an exemplary embodiment of the access control method provided in this disclosure. Figure 4 The method shown may include steps 410, 420, 430 and 440, which are explained below.
[0069] Step 410: Generate an address translation request through the target virtual machine. The address translation request includes an intermediate physical address.
[0070] It should be noted that the target virtual machine can be any one of multiple virtual machines running on the chip, for example, Figure 2 , Figure 3 , Figure 5 , Figure 6 In Guest OS A, the term "target" in the target virtual machine does not constitute any limitation on the target virtual machine.
[0071] 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.
[0072] Step 420: The intermediate physical address is translated into a physical address through the memory management unit.
[0073] Optionally, the target virtual machine can forward the address translation request to the memory management unit, which can respond to the address translation request by converting the intermediate physical address included in the address translation request into a physical address and sending the physical address to the virtualization manager.
[0074] Optionally, the target virtual machine can forward the address translation request to the virtualization manager, which can respond to the address translation request by calling the memory management unit to translate the intermediate physical address included in the address translation request into a physical address.
[0075] Step 430: Determine the target virtual machine's access permissions to physical addresses through the virtualization manager.
[0076] 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.
[0077] Step 440: 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.
[0078] If the access permission information is "1", it means that the target virtual machine has access permission to the physical address. The virtualization manager can send the physical address to the target virtual machine, and the target virtual machine can configure the physical address in the direct memory access controller. In this way, the direct memory access controller can perform data copying based on the physical address.
[0079] If the access permission information is "0", it means 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.
[0080] 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 is converted to a physical address by the memory management unit. If the access permission information determined by the virtualization manager 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. Since the physical address, not the intermediate physical address, is configured in the direct memory access controller in the embodiments of this disclosure, the direct memory access controller can directly perform data copying based on the physical address. Furthermore, before configuring the physical address in the direct memory access controller, access permission related determination (i.e., determining whether the target virtual machine has access permission to the physical address) has been performed. This restricts the area accessible to the target virtual machine through the direct memory access controller. Therefore, in the embodiments of this disclosure, the direct memory access controller does not need to obtain the physical address through the system memory management unit, nor does it need to perform access permission related determinations through the system memory management unit. Thus, the chip does not need to be equipped with a system memory management unit (see details...). Figure 7 (The chip structure in the chip) can reduce the manufacturing cost of the chip.
[0081] In one optional example, the physical address has a corresponding access whitelist, which includes multiple virtual machine identifiers. Figure 4 Based on the illustrated embodiment, step 430 includes Figure 8-1 The steps shown in step 4301 or Figure 8-2 Step 4303 is shown.
[0082] Step 4301: In response to the fact that the identification information of the target virtual machine is in the access whitelist, the access permission information is determined by the virtualization manager to indicate that the target virtual machine has access permission to the physical address.
[0083] Step 4303: 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.
[0084] 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.
[0085] 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.
[0086] In the embodiments of this disclosure, due to the setting of the access whitelist, by determining whether the identification information of the target virtual machine is in the access whitelist corresponding to the physical address, it is possible to efficiently and reliably determine whether the target virtual machine has access rights to the physical address.
[0087] 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.
[0088] exist Figure 8-1 or Figure 8-2 The basis of the illustrated embodiment, such as Figure 9-1 or Figure 9-2 As shown, step 420 includes step 4201.
[0089] Step 4201: 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.
[0090] Following step 430, the method further includes step 450.
[0091] Step 450: 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.
[0092] Alternatively, the recorded addresses can be represented in the form of an address table.
[0093] 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.
[0094] If IPA0 exists in the recorded address, the virtualization manager can directly reject the address translation request from Guest OS A.
[0095] 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.
[0096] 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 with the intermediate physical address IPA0 again 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 perform the access permission information determination step and the physical address configuration step based on the physical address. This helps to save computing resources.
[0097] 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.
[0098] exist Figure 8-1 or Figure 8-2 The basis of the illustrated embodiment, such as Figure 10-1 or Figure 10-2 As shown, the method further includes steps 460 and 470.
[0099] Step 460: 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.
[0100] 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.
[0101] 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 say, "Please confirm whether Guest OS A has access to PA0," or display a pop-up window on the screen saying, "Please confirm whether Guest OS A has access to PA0," to prompt manual confirmation of whether Guest OS A has access to PA0.
[0102] Step 470: 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.
[0103] Optionally, regarding the permission confirmation prompt message output in step 460, in one possible approach, "Yes" or "No" can be output via voice. If a "Yes" command is received via voice output, 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, in another possible approach, two selection buttons, "Yes" and "No," can be displayed below the pop-up window on the screen. Regarding the permission confirmation prompt message output in step 460, either the "Yes" or "No" selection button can be selected. If the "Yes" selection button is selected, 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.
[0104] 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 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, 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.
[0105] 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;
[0106] exist Figure 4 Based on the illustrated embodiments, as Figure 11 As shown, step 440 includes step 4401.
[0107] Step 4401: In response to the access permission information indicating that the target virtual machine has access permissions to both the physical source address and the physical destination address in the physical address, the physical address is configured in the direct memory access controller through the target virtual machine.
[0108] 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.
[0109] Optionally, PA1 and PA2 can each have corresponding access whitelists. If the target virtual machine's identification information is present in both the access whitelist corresponding to PA1 and the access whitelist corresponding to PA2, it can be assumed that the target virtual machine has access to both PA1 and PA2. In this case, the target virtual machine can configure the physical addresses including PA1 and PA2 in the direct memory access controller, which can then copy data from the address space corresponding to PA1 to the address space corresponding to PA2. If the target virtual machine's identification information is not present in the access whitelist corresponding to PA1, and / or, the target virtual machine's identification information is not present in the access whitelist corresponding to PA2, it can be assumed that the target virtual machine does not have access to both PA1 and PA2. In this case, the target virtual machine will not configure the physical addresses including PA1 and PA2.
[0110] In the embodiments of this disclosure, access permission related judgments can be performed on the physical source address and physical destination address in the physical address respectively, and the judgment results can be combined to determine whether to configure the physical address in the direct memory access controller, so as to effectively ensure the security of the direct memory access controller accessing memory.
[0111] exist Figure 4 Based on the illustrated embodiments, as Figure 12 As shown, before step 440, the method further includes steps 432 and 434.
[0112] Step 432: Obtain the target virtual machine's occupancy mode for the direct memory access controller.
[0113] 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 .
[0114] Step 434: Obtain control information for the direct memory access controller.
[0115] Optionally, the control information obtained in step 434 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.
[0116] Step 440 includes steps 4403 and 4405.
[0117] Step 4403: Determine the configuration method that matches the occupancy mode.
[0118] 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.
[0119] Step 4405: Configure the physical address and control information in the direct memory access controller according to the configuration method through the target virtual machine.
[0120] 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.
[0121] In the embodiments of this disclosure, by referring to the target virtual machine's occupation mode of the direct memory access controller, a suitable configuration method can be adopted to 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 by referring to the physical address and control information.
[0122] Optionally, such as Figure 13 As shown, the access control method provided in the embodiments of this disclosure may include the following steps:
[0123] Step 1201: 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.
[0124] Step 1203: 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.
[0125] Step 1205: The virtualization manager determines whether Guest OS A has access permissions to both physical source address PA1 and physical destination address PA2. If yes, proceed to step 1207; otherwise, end.
[0126] Step 1207: The virtualization manager returns the physical source address PA1 and the physical destination address PA2 to the Guest OSA;
[0127] Step 1209: 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).
[0128] Optionally, the physical source address PA1 can be either an address in memory or an address of a peripheral device on the bus; the physical destination address PA2 can also be either an address in memory or an address of a peripheral device on the bus. Thus, the data copying process at the DMA controller can have the following four scenarios: address in memory → address in memory; address in memory → address of a peripheral device; address of a peripheral device → address of a peripheral device; address of a peripheral device → address in memory.
[0129] In summary, the embodiments of this disclosure can virtualize the DMA controller on a chip without an SMMU, so that the permissions of multiple virtual machines running on the chip when using the DMA controller can be controlled, which helps to reduce chip costs. Furthermore, the virtual machines can access the DMA controller more quickly.
[0130] Any of the access control methods 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 of the access control methods provided in this disclosure can be executed by a processor, such as by a processor executing any of the access control methods mentioned in this disclosure by calling corresponding instructions stored in memory. Further details will not be elaborated below.
[0131] Exemplary device
[0132] Figure 14 This is a schematic diagram of the structure of an access control device provided in an exemplary embodiment of the present disclosure. The device shown in FIG10 includes a generation module 1410, a conversion module 1420, a determination module 1430, and a configuration module 1440.
[0133] The generation module 1410 is used to generate an address translation request through the target virtual machine. The address translation request includes an intermediate physical address.
[0134] The conversion module 1420 is used to convert the intermediate physical address included in the address conversion request generated by the generation module 1410 into a physical address through the memory management unit;
[0135] The determination module 1430 is used to determine the access rights information of the target virtual machine to the physical address converted by the conversion module 1420 through the virtualization manager;
[0136] The configuration module 1440 is used to configure the physical address in the direct memory access controller in response to the access permission information determined by the determination module 1430, which indicates that the target virtual machine has access permission to the physical address.
[0137] In one optional example, the physical address has a corresponding access whitelist, which includes multiple virtual machine identification information. The determining module 1430 includes... Figure 15-1 The first determining submodule 14301 shown or Figure 15-2 The second determining submodule 14303 is shown;
[0138] The first determining submodule 14301 is used to determine access permission information through the virtualization manager in response to the target virtual machine's identification information being in the access whitelist, indicating that the target virtual machine has access permissions to the physical address; or,
[0139] The second determining submodule 14303 is used to determine access permission information through the virtualization manager in response to the target virtual machine's identification information not being in the access whitelist, indicating that the target virtual machine does not have access permission to the physical address.
[0140] In an optional example, such as Figure 15-1 , Figure 15-2 As shown, the conversion module 1420 includes:
[0141] The conversion submodule 14201 is used to convert the intermediate physical address included in the address conversion request generated by the generation module 1410 into a physical address through the memory management unit in response to the absence of an intermediate physical address included in the address conversion request generated by the generation module 1410 in the recorded address.
[0142] The device also includes:
[0143] The first adding module 1450 is used to add the intermediate physical address included in the address translation request generated by the generating module 1410 to the already recorded address after the determining module 1430 determines the access permission information of the target virtual machine to the physical address translated by the translation module 1420 through the virtualization manager. This is in response to the access permission information determined by the determining module 1430 indicating that the target virtual machine does not have access permission to the physical address translated by the translation submodule 14201.
[0144] In an optional example, such as Figure 15-1 , Figure 15-2 As shown, the device also includes:
[0145] Output module 1460 is used to respond to the target virtual machine generating more than a preset number of address translation requests within a preset time period, and to determine that the access permission information corresponding to each address translation request determined by module 1430 indicates that the target virtual machine does not have access permission to the physical address translated by translation module 1420, and output permission confirmation prompt information; wherein, the permission confirmation prompt information includes the identification information and physical address of the target virtual machine;
[0146] The second adding module 1470 is used to add the identification information of the target virtual machine to the access whitelist in response to the trigger operation of the permission confirmation prompt message output by the output module 1460.
[0147] 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;
[0148] like Figure 16 As shown, configuration module 1440 includes:
[0149] The third determining submodule 14401 is used to determine whether the access permission information determined by the determining module 1430 indicates that the target virtual machine has access permissions to both the physical source address and the physical destination address in the physical address;
[0150] The first configuration submodule 14403 is used to respond to the access permission information determined by the third determination submodule 14401, which indicates that the target virtual machine has access permissions to both the physical source address and the physical target address in the physical address, and configures the physical address in the direct memory access controller through the target virtual machine.
[0151] In an optional example, such as Figure 17 As shown, the device also includes:
[0152] The first acquisition module 1432 is used to acquire the target virtual machine's occupancy mode of the direct memory access controller before configuring the physical address in the direct memory access controller through the virtual machine;
[0153] The second acquisition module 1434 is used to acquire control information for the direct memory access controller;
[0154] Configuration module 1440 includes:
[0155] The fourth determining submodule 14405 is used to determine the configuration method that matches the occupancy mode obtained by the first obtaining module 1432;
[0156] The second configuration submodule 14407 is used to configure the physical address and the control information obtained by the second acquisition module 1434 in the direct memory access controller according to the configuration method determined by the fourth determination submodule 14405 through the target virtual machine.
[0157] Exemplary electronic devices
[0158] Below, for reference Figure 18 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.
[0159] Figure 18 A block diagram of an electronic device according to an embodiment of the present disclosure is shown.
[0160] like Figure 18 As shown, the electronic device 1800 includes one or more processors 1810 and memory 1820.
[0161] The processor 1810 may be a central processing unit (CPU) or other form of processing unit with data processing capabilities and / or instruction execution capabilities, and may control other components in the electronic device 1800 to perform desired functions.
[0162] The memory 1820 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 1810 may execute the program instructions to implement the access control 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.
[0163] In one example, the electronic device 1800 may also include an input device 1830 and an output device 1840, which are interconnected via a bus system and / or other forms of connection mechanism (not shown).
[0164] For example, when the electronic device is a first device or a second device, the input device 1830 may be a microphone or a microphone array. When the electronic device is a standalone device, the input device 1830 may be a communication network connector for receiving acquired input signals from the first device and the second device.
[0165] In addition, the input device 1830 may also include, for example, a keyboard, a mouse, etc.
[0166] The output device 1840 can output various information to the outside, including determined distance information, direction information, etc. The output device 1840 may include, for example, a display, a speaker, a printer, and a communication network and its connected remote output devices, etc.
[0167] Of course, for the sake of simplicity, Figure 18 Only some of the components of the electronic device 1800 relevant to this disclosure are shown, omitting components such as buses, input / output interfaces, etc. In addition, the electronic device 1800 may include any other suitable components depending on the specific application.
[0168] Exemplary computer program products and computer-readable storage media
[0169] 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 access control methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section of this specification.
[0170] 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.
[0171] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions thereon, which, when executed by a processor, cause the processor to perform the steps in the access control methods according to various embodiments of this disclosure as described in the "Exemplary Methods" section above.
[0172] 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.
[0173] 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.
[0174] 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.
[0175] 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.
[0176] 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.
[0177] 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.
[0178] 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.
[0179] 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 therein.
Claims
1. An access control method applied to a chip, the method comprising: An address translation request is generated by the target virtual machine. The address translation request includes an intermediate physical address and is used to request the intermediate physical address to be translated into a physical address. The intermediate physical address is converted into a physical address through the memory management unit; The virtualization manager determines the access permission information of the target virtual machine to the physical address, and the access permission information is used to characterize whether the target virtual machine has access permission to the physical address; 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; Wherein, when the intermediate physical address includes an intermediate physical source address and an intermediate physical destination address, the physical address includes a physical source address derived from the intermediate physical source address and a physical destination address derived from the intermediate physical destination address. The step of configuring the physical address in the direct memory access controller via the target virtual machine, in response to the access permission information indicating that the target virtual machine has access permission to the physical address, includes: In response to the access permission information indicating that the target virtual machine has access permissions to both the physical source address and the physical target address in the physical address, the physical address is configured in the direct memory access controller through the target virtual machine. The direct memory access controller is used to copy data from the address space corresponding to the physical source address to the address space corresponding to the physical target address.
2. The method according to claim 1, wherein, The physical address has a corresponding access whitelist, which includes multiple virtual machine identifiers. Determining the access permission information of the target virtual machine for the physical address through the virtualization manager includes: 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 permission to the physical address; or, In response to the fact that the identification information of the target virtual machine is not in the access whitelist, the virtualization manager determines that the access permission information indicates that the target virtual machine does not have access permission to the physical address.
3. The method according to claim 2, wherein, The step of converting the intermediate physical address to a physical address through the memory management unit includes: In response to the absence of the intermediate physical address in the recorded addresses, the intermediate physical address is converted into a physical address by the memory management unit; After determining the access permission information of the target virtual machine to the physical address through the virtualization manager, the method further includes: In response to the access permission information indicating that the target virtual machine does not have access permission to the physical address, the intermediate physical address is added to the recorded address.
4. The method according to claim 2, further comprising: 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, an access confirmation prompt is output; wherein, the access confirmation prompt includes the identification information of the target virtual machine and the physical address; In response to the triggered operation of the permission confirmation prompt message, the identification information of the target virtual machine is added to the access whitelist.
5. The method according to claim 1, wherein, Before configuring the physical address in the direct memory access controller via the 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. An access control device applied to a chip, 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 and is used to request the intermediate physical address to be translated into a physical 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 a memory management unit; The determination module is used to determine, through the virtualization manager, the access permission information of the target virtual machine to the physical address converted by the conversion module, wherein the access permission information is used to characterize whether the target virtual machine has access permission to the physical address; A configuration module is configured to, in response to the access permission information determined by the determining module indicating that the target virtual machine has access permission to the physical address, configure the physical address in the direct memory access controller through the target virtual machine; Wherein, when the intermediate physical address includes an intermediate physical source address and an intermediate physical destination address, the physical address includes a physical source address converted from the intermediate physical source address and a physical destination address converted from the intermediate physical destination address. The configuration module includes a first configuration submodule, used for: In response to the access permission information indicating that the target virtual machine has access permissions to both the physical source address and the physical target address in the physical address, the physical address is configured in the direct memory access controller through the target virtual machine. The direct memory access controller is used to copy data from the address space corresponding to the physical source address to the address space corresponding to the physical target address.
7. The apparatus according to claim 6, wherein, The physical address has a corresponding access whitelist, the access whitelist includes multiple virtual machine identification information, and the determining module includes; The first determining submodule is used to determine, in response to the fact that the identification information of the target virtual machine is in the access whitelist, the access permission information through the virtualization manager to indicate that the target virtual machine has access permission to the physical address; or, The second determining submodule is used to determine, in response to the fact that the identification information of the target virtual machine is not in the access whitelist, the access permission information through the virtualization manager to indicate that the target virtual machine does not have access permission to the physical address.
8. A computer-readable storage medium storing a computer program for performing the access control method according to any one of claims 1-5.
9. 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 access control method according to any one of claims 1-5.