Virtual machine data read-write method and related device
By setting a virtual machine identifier field and an input/output page table in the device control table, the security issue of data transmission between external pass-through devices and securely isolated virtual machines is resolved. This enables secure data transmission to secure memory that the virtual machine monitor cannot access, thereby improving the security of data transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HYGON INFORMATION TECH CO LTD
- Filing Date
- 2021-11-30
- Publication Date
- 2026-07-24
AI Technical Summary
In existing technologies, there is a risk that the virtual machine monitor may steal and tamper with data during the data read and write process between external pass-through devices and securely isolated virtual machines, which cannot guarantee the security of confidential data.
By setting a virtual machine identifier field in the device control table, and combining it with the input/output page table and memory owner table, address data read/write requests are constructed to ensure that the virtual machine monitor cannot access secure memory during data transmission, thus achieving secure data transmission between pass-through devices and securely isolated virtual machines.
It improves the security of data transmission between external pass-through devices and securely isolated virtual machines, prevents virtual machine monitors from stealing or tampering with data, and ensures the security of confidential data.
Smart Images

Figure CN114237817B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, specifically to a virtual machine data reading and writing method and related apparatus. Background Technology
[0002] With the development of cloud technology, most service programs run in virtual machines in the cloud. As the carrier of user data, the data security of the virtual machine itself is receiving increasing attention.
[0003] In existing technologies, with the help of a Virtual Machine Monitor (VMM), virtual machines can pass through external pass-through devices to input and output data. To protect the security of virtual machine memory data, a memory owner table (SPOT table) can be set by the memory controller to isolate memory read and write operations between different virtual machines and between the virtual machine monitor and virtual machines. However, in the case of passing through data between existing external pass-through devices and securely isolated virtual machines, the securely isolated virtual machine for data processing cannot be determined based on the external pass-through device that sends the data read / write request. When address translation is performed using the input / output page table (IO page table), the obtained address cannot directly correspond to the secure memory of a specific securely isolated virtual machine; it can only be shared memory that can be shared with the virtual machine monitor or even other virtual machines.
[0004] During the data read / write process between the external pass-through device and the secure isolated virtual machine, the data must pass through the aforementioned shared memory. During this process, the virtual machine monitor has the right to read the shared memory. Thus, the data read / written between the external pass-through device and the secure isolated virtual machine is at risk of being stolen and tampered with by the virtual machine monitor, making it impossible for the external pass-through device and the secure isolated virtual machine to read and write confidential data. However, in confidential computing scenarios, it is essential to ensure the security of the data read / written between the external pass-through device and the secure isolated virtual machine.
[0005] Therefore, how to ensure that data reading and writing between external pass-through devices and securely isolated virtual machines are not affected by the virtual machine monitor, and improve the security of data transmission, has become a technical problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0006] In view of this, the virtual machine data read / write method provided in this application embodiment can ensure that data read / write between external devices and securely isolated virtual machines is not affected by the virtual machine monitor, thereby improving the security of data transmission.
[0007] To achieve the above objectives, the embodiments of this application provide the following technical solutions.
[0008] In a first aspect, embodiments of this application provide a virtual machine data read / write method, applicable to an input / output storage management unit, including:
[0009] Obtain a data read / write request sent by a passthrough device, wherein the data read / write request includes the physical address of the virtual machine to which the data is to be read / written, and the passthrough device is an external device of the corresponding virtual machine;
[0010] Obtain the configured device control table corresponding to the pass-through device, obtain the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and obtain the configured input / output page table based on the input / output page table base address;
[0011] According to the input / output page table, obtain the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address, wherein the encryption information represents the encryption status of the memory space corresponding to the host physical address;
[0012] Based on the encrypted information, the virtual machine identifier, and the host physical address, an address data read / write request is constructed and sent to the memory.
[0013] Secondly, embodiments of this application provide a virtual machine data read / write method, applicable to a memory controller, including:
[0014] Receive address data read / write request, the address data read / write request including a request obtained according to the virtual machine data read / write method described above;
[0015] Based on the host physical address in the address data read / write request, obtain the corresponding memory virtual machine identifier from the pre-stored memory owner table;
[0016] When the memory virtual machine identifier matches the virtual machine identifier, data is read or written in the host physical address according to the address data read / write request.
[0017] Thirdly, embodiments of this application provide a device control table applicable to an input / output storage management unit, including a virtual machine identifier field.
[0018] Fourthly, embodiments of this application provide a virtual machine data read / write device, applicable to an input / output storage management unit, comprising:
[0019] The data read / write request acquisition module is adapted to acquire data read / write requests sent by a pass-through device. The data read / write request includes the physical address of the virtual machine to which the data is to be read / written, wherein the pass-through device is an external device of the corresponding virtual machine.
[0020] The input / output page table acquisition module is adapted to acquire the configured device control table corresponding to the pass-through device, acquire the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and acquire the configured input / output page table according to the input / output page table base address;
[0021] The host physical address and encryption information acquisition module is adapted to acquire the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address according to the input / output page table, wherein the encryption information represents the encryption status of the memory space corresponding to the host physical address;
[0022] The address data read / write request construction module is adapted to construct an address data read / write request based on the encrypted information, the virtual machine identifier, and the host physical address, and send the address data read / write request to the memory.
[0023] Fifthly, embodiments of this application provide a virtual machine data read / write device, applicable to a memory controller, comprising:
[0024] The address data read / write request acquisition module is adapted to receive address data read / write requests, wherein the address data read / write requests include requests obtained according to the virtual machine data read / write method described above;
[0025] The memory virtual machine identifier acquisition module is adapted to obtain the memory virtual machine identifier corresponding to the pre-stored memory owner table based on the host physical address in the address data read / write request;
[0026] The read / write data module is adapted to read and write data in the host physical address according to the address data read / write request when the memory virtual machine identifier is consistent with the virtual machine identifier.
[0027] Sixthly, embodiments of this application provide an electronic device, including:
[0028] Virtual machine;
[0029] A pass-through device, suitable for data reading and writing with the virtual machine;
[0030] The input / output storage management unit is adapted to construct an address data read / write request based on the data read / write request sent by the pass-through device, and send the address data read / write request to the memory to execute the virtual machine data read / write method as described above.
[0031] In a seventh aspect, embodiments of this application provide an electronic device, including:
[0032] The input / output storage management unit is adapted to construct an address data read / write request based on the data read / write request sent by the pass-through device, and send the address data read / write request to the memory to execute the virtual machine data read / write method as described above.
[0033] A memory controller is adapted to receive address data read / write requests, wherein the address data read / write requests include obtaining a request according to the virtual machine data read / write method described above, obtaining the corresponding memory virtual machine identifier in a pre-stored memory owner table according to the host physical address in the address data read / write request, and when the memory virtual machine identifier is consistent with the virtual machine identifier, reading and writing data in the host physical address according to the address data read / write request.
[0034] The virtual machine data read / write method provided in this application embodiment is applicable to an input / output storage management unit. When performing virtual machine data read / write, it first obtains a data read / write request sent by a passthrough device, the data read / write request including the virtual machine physical address of the data to be read / written; then, it obtains the corresponding configured device control table according to the passthrough device, obtains the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and obtains the configured input / output page table according to the input / output page table base address; next, it obtains the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address according to the input / output page table; finally, it constructs an address data read / write request according to the encryption information, the virtual machine identifier and the host physical address, and sends the address data read / write request to memory. Thus, the virtual machine data read / write method provided in this application embodiment, by setting a virtual machine identifier in the device control table, can ensure that the device control table based on the specific pass-through device can obtain the virtual machine identifier. Therefore, when an address data read / write request is formed, the formed address data read / write request not only includes the host physical address and encryption information, but also includes the virtual machine identifier. This enables direct access to the memory of the virtual machine corresponding to the virtual machine identifier based on the host physical address and the virtual machine identifier. The virtual machine monitor has no right to access the secure memory corresponding to the virtual machine, thereby preventing the virtual machine monitor from stealing or tampering with data, and thus ensuring the security of confidential data transmission between the pass-through device and the virtual machine. Attached Figure Description
[0035] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0036] Figure 1 A diagram showing the direct connection architecture between the virtual machine and the pass-through device;
[0037] Figure 2 A diagram illustrating secure virtual machine memory isolation;
[0038] Figure 3 A flowchart illustrating a virtual machine data read / write method provided in an embodiment of this application;
[0039] Figure 4 Another flowchart illustrating the virtual machine data read / write method provided in this application embodiment;
[0040] Figure 5 A schematic diagram of the structure of a virtual machine data read / write device provided in an embodiment of this application;
[0041] Figure 6 This is an architectural diagram of an electronic device provided in an embodiment of this application. Detailed Implementation
[0042] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0043] The following uses the passthrough process between a virtual machine and a passthrough device as an example to explain the passthrough situation of the passthrough device.
[0044] It's easy to understand that external devices refer to devices other than the host machine. Specifically, external devices that virtual machines can use include non-passthrough devices and passthrough devices. Passthrough devices include ordinary passthrough devices and secure passthrough devices. Virtual machines and passthrough devices can input or output data in a passthrough manner, as follows:
[0045] Please refer to Figure 1 , Figure 1 This is a diagram of a passthrough architecture between a virtual machine and a passthrough device.
[0046] As shown in the figure, virtual machine 10 and passthrough device 12 transmit data through virtual machine monitor 11 and input / output storage management unit 15, using nested page table 13 and input / output page table (IO page table) 14. Nested page table 13 contains the correspondence between virtual machine physical address and passthrough device storage space address from the CPU perspective, and input / output page table (IO page table) 14 stores the correspondence between virtual machine physical address data stored in passthrough device storage space address and host physical address.
[0047] When the virtual machine 10 starts, the virtual machine monitor (VMM) 11 assigns external devices to the virtual machine 10 and forms a device control table corresponding to each device, which is stored in the input / output storage management unit 15.
[0048] After virtual machine 10 starts, when virtual machine monitor (VMM) 11 enumerates external devices, it informs virtual machine 10 that there is pass-through device 12 on the bus, and helps virtual machine 10 and pass-through device 12 establish a pass-through input or output data process as follows:
[0049] In one specific embodiment, the pass-through device described below can be a PCI / PCIe device, where PCI / PCIe is a general-purpose bus interface that can connect to external devices, and the PCI / PCIe device is an external device connected through the PCI / PCIe general-purpose bus interface.
[0050] First, the Virtual Machine Monitor (VMM) 11 helps the virtual machine 10 complete the mapping of nested page tables 13 to the pass-through device storage space (BAR space), which contains the correspondence between the virtual machine's physical address and the pass-through device storage space address.
[0051] When DMA data transfer is required, the virtual machine issues a request to write data from address GPA1 to address GPA2. Then, based on the "virtual machine physical address GPA2" and the established nested page table 13 (which contains the correspondence between the virtual machine physical address GPA2 and the passthrough device storage space address BAR1), it accesses the "passthrough device storage space address BAR1" and writes the virtual machine physical address GPA1 containing the data to be transferred into the DMA register of the passthrough device storage space address BAR1.
[0052] Furthermore, the Virtual Machine Monitor (VMM) 11 assists the passthrough device 12 in completing the mapping of the input / output page table (IO page table) 14 in the Input / Output Memory Management Unit (IOMMU) 15 located on the bus, writing the virtual machine physical address GPA1 into the input / output page table (IO page table) 14, and forming a correspondence between the virtual machine physical address GPA1 and the host physical address HPA1, thus establishing a passthrough path.
[0053] In this way, with the help of VMM11, virtual machine 10 and pass-through device 12 can input or output data in a pass-through manner. After the nested page table 13 and input / output page table (IO page table) 14 are mapped, the pass-through path is established, and virtual machine 10 can directly access the storage space of pass-through device 12 without the help of virtual machine monitor (VMM) 11.
[0054] On the other hand, in order to protect data security, virtual machines can also be secure isolated virtual machines. The memory of a secure isolated virtual machine can be divided into ordinary memory and secure memory. In order to achieve secure control of secure memory, the memory controller uses the memory owner table (SPOT table) set on the bus for accessing memory to isolate memory read and write between different virtual machines, as well as between the virtual machine monitor and the virtual machine.
[0055] Please refer to Table 1, which shows an example of the parameters of the SPOT table in the embodiments of this application.
[0056] Table 1: Example of parameters for the SPOT table:
[0057] Host Physical Address (HPA) Virtual machine identifier Memory 1 (e.g., HPA1--HPA16) VMID1 Memory 2 (e.g., HPA17--HPA32) VMID2 Memory 3 (e.g., HPA33--HPA48) VMID3
[0058] Please refer to the following: Figure 2 , Figure 2 For secure isolation of virtual machine memory, when virtual machine 1 (20) issues a data read request, it determines and verifies the virtual machine identifier corresponding to the host physical address in the SPOT table based on the host physical address in the data request and the SPOT table stored on the bus. Then it compares whether the virtual machine identifier in the data read request is consistent with the virtual machine identifier in the SPOT table. If they are consistent, access to the corresponding memory is allowed; otherwise, access to the corresponding memory is not allowed.
[0059] As shown in the figure, if the virtual machine identifier is determined to be VMID1 (21) based on the host physical address and SPOT table, and the virtual machine identifier in the data read request is also VMID1, then access to memory 1 (22) corresponding to virtual machine 1 (20) and identified by the host physical address is allowed; otherwise, access is not allowed, and of course, access to memory 2 (23) is also not allowed.
[0060] In other words, before accessing secure memory, it is necessary to first determine whether the virtual machine identifier matches based on the SPOT table. Only if it matches can secure memory be accessed. This can securely isolate the secure memory of the virtual machine, so that neither the virtual machine monitor (VMM) nor the mismatched virtual machine can read the data in the secure memory, thus protecting the security of the data in the memory corresponding to the securely isolated virtual machine.
[0061] As discussed above, although the process of inputting or outputting data in a passthrough manner between a virtual machine and a passthrough device no longer requires the assistance of the Virtual Machine Monitor (VMM), and the SPOT table established using secure isolation virtual machine technology can isolate secure memory and prevent the VMM from reading data in secure memory, in the case of data passing between an external passthrough device and a secure isolation virtual machine, the secure isolation virtual machine performing data processing cannot be determined based on the external passthrough device sending the data read / write request. When address translation is performed using the input / output page table (IO page table), the obtained address cannot directly correspond to the secure memory of a specific secure isolation virtual machine. Therefore, external passthrough devices and secure isolation virtual machines cannot directly access secure memory; they can only directly access shared memory shared with the Virtual Machine Monitor (VMM) or even other virtual machines.
[0062] Because external passthrough devices and secure isolated virtual machines can only access shared memory through passthrough, when data is read or written between them, the data read from or written to the secure isolated virtual machine's memory can only be data from the aforementioned shared memory. During this process, the Virtual Machine Monitor (VMM) has the right to read the shared memory. Thus, there is a risk that the data read and written between the external passthrough device and the secure isolated virtual machine can be stolen and tampered with by the VMM, making it impossible for the external passthrough device and the secure isolated virtual machine to read and write confidential data. However, in confidential computing scenarios, there is a need for the external passthrough device and the secure isolated virtual machine to read and write confidential data, which necessitates ensuring the security of the data read and written between the external passthrough device and the secure isolated virtual machine.
[0063] To overcome the shortcomings of the prior art, the virtual machine data read / write method provided in this application embodiment can ensure that data read / write between external pass-through devices and securely isolated virtual machines is not affected by the virtual machine monitor, thereby improving the security of data transmission.
[0064] To facilitate understanding of the virtual machine data read / write method provided in this application embodiment, and in conjunction with the foregoing description, it is easy to understand that before the virtual machine data read / write method provided in this application embodiment, the virtual machine has already been started in advance, and a passthrough path between the virtual machine and the passthrough device has already been established in advance. That is, the virtual machine physical address corresponding to the data read / write request has already been written into the storage space of the passthrough device. Therefore, the specific process of starting the virtual machine and establishing the passthrough path will be explained first. Please refer to the following description in conjunction with the foregoing examples for details:
[0065] When a virtual machine starts up, in order to ensure that subsequent address data read and write requests can specify the specific virtual machine, the Virtual Machine Monitor (VMM) first assigns a Virtual Machine ID (VMID) to the virtual machine and allocates the necessary external devices to the virtual machine. Thus, after the virtual machine starts up, when the VMM enumerates external devices, it informs the virtual machine that there are pass-through devices on the bus. It's easy to understand that one pass-through device corresponds to only one virtual machine, while one virtual machine can correspond to multiple pass-through devices.
[0066] When a virtual machine starts up, after the Virtual Machine Monitor (VMM) assigns a passthrough device to the virtual machine, it also needs to create a device control table for each passthrough device and save it in the Input / Output Memory Management Unit (IOMMU). This allows the IOMMU to determine the passthrough device that sent the request based on the received data read / write request and understand the control status of each device.
[0067] Of course, in order to ensure that the address data read and write requests constructed subsequently contain the information of the corresponding virtual machine, each field in the configured device control table needs to include a virtual machine identifier field. Please refer to Table 2, which shows a parameter example of the device control table with an added virtual machine identifier field in the embodiment of this application.
[0068] Table 2: Example of parameters for the device control table with added virtual machine identifier field:
[0069]
[0070] In one specific implementation, each field in the device control table can be configured through the virtual machine monitor, and can be configured at the same time as the device control table is created.
[0071] When the virtual machine is a secure isolated virtual machine, in order to improve data security and prevent the risk of configuration information being tampered with when configuring the fields of the device control table, in another specific implementation, the virtual machine identifier field in the device control table of the pass-through device of the secure isolated virtual machine can be configured through a security processor.
[0072] Specifically, in one implementation, to ensure comprehensive security, the virtual machine identifier field of the device control table of all pass-through devices can be configured through the security processor, regardless of whether the virtual machine corresponding to the pass-through device is a security-isolated virtual machine.
[0073] Thus, when the virtual machine corresponding to the passthrough device is a securely isolated virtual machine, the configured virtual machine identifier field is the specific virtual machine identifier, i.e., virtual machine number identifier (e.g., VMID1, VMID2, VMID3, ..., VMIDn); when the virtual machine corresponding to the passthrough device is a non-securely isolated virtual machine, the configured virtual machine identifier field is the identifier of the virtual machine monitor (e.g., VMID is 0), i.e., the virtual machine monitor identifier. In other words, the virtual machine identifier can include both the virtual machine monitor identifier and the virtual machine number identifier. Therefore, with a single configuration of the security processor, the configuration of the virtual machine identifier field in the device control table can be achieved.
[0074] However, in order to reduce the workload of the security processor, in another implementation, the security processor can first determine whether the virtual machine is a secure isolated virtual machine. If it is determined to be a secure isolated virtual machine, then the security processor can configure the virtual machine identifier field of the device control table of the pass-through device; otherwise, the virtual machine identifier field of the device control table of the pass-through device can also be configured through the virtual machine monitor, or the virtual machine identifier field of the device control table can be left unconfigured.
[0075] To address this, two fields can be set in the device control table to jointly identify the virtual machine. The virtual machine identification field includes a security isolation identifier field and a virtual machine number identifier field. The security isolation identifier field is used to identify whether the virtual machine corresponding to the pass-through device is a security isolated virtual machine, and the virtual machine number identifier field is used to identify the specific virtual machine number.
[0076] For example, a 0 can be used to indicate that the virtual machine corresponding to the passthrough device is not a secure isolated virtual machine. When the security processor determines that the virtual machine corresponding to the passthrough device is not a secure isolated virtual machine, the security processor configures the security isolation identifier field in the device control table to 0. In this way, the virtual machine monitor does not need to configure the virtual machine number identifier field again. Of course, it can be configured, but the specific virtual machine number configured will no longer be useful in subsequent use. Conversely, a 1 can be used to indicate that the virtual machine corresponding to the passthrough device is a secure isolated virtual machine. When the security processor determines that the virtual machine corresponding to the passthrough device is a secure isolated virtual machine, the security processor configures the security isolation identifier field in the device control table to 1. In this way, the security processor continues to configure the virtual machine number identifier field in the device control table using the virtual machine number identifier VMIDn.
[0077] It can be seen that regardless of the method used to configure the virtual machine identifier through the security processor, security risks caused by the virtual machine monitor can be avoided.
[0078] Of course, in order to realize the translation between the virtual machine physical address and the host physical address, when the virtual machine starts up and the virtual machine monitor (VMM) allocates a passthrough device for the virtual machine, the virtual machine monitor (VMM) also needs to create an input / output page table between the virtual machine and the passthrough device. As mentioned above, the input / output page table stores the correspondence between the virtual machine physical address and the host physical address, where the virtual machine physical address is the address in the data read / write request sent by the passthrough device.
[0079] Specifically, the Virtual Machine Monitor (VMM) first creates all page table entries in the input / output page table for the passthrough device except for the last-level page table entry, and stores the created input / output page table in the shared memory shared by the Virtual Machine Monitor (VMM) and the virtual machine, thus initially obtaining the base address of the input / output page table of the passthrough device.
[0080] When establishing a passthrough path between a virtual machine and a passthrough device, a mapping between the virtual machine's physical addresses GPA1 and HPA1 is established in advance. When the passthrough device reads data from the virtual machine, the mapping between the host physical address HPA1 and the virtual machine's physical address GPA1 of the data to be read has already been established. At this time, it is only necessary to add it to the input / output page table. When writing data from the passthrough device to a specific virtual machine physical address GPA1 of the virtual machine, a mapping between that virtual machine physical address GPA1 and a specific host physical address HPA1 must be established in advance, and then added to the input / output page table.
[0081] Building upon the preceding discussion, let's take reading data from the virtual machine's physical address GPA1 via a passthrough device as an example for further explanation:
[0082] Specifically, the virtual machine will issue a request to write data from address GPA1 to address GPA2. Based on the "virtual machine physical address GPA2" and the established nested page table (which contains the correspondence between the virtual machine physical address GPA2 and the passthrough device storage space address BAR1), it will access the "passthrough device storage space address BAR1" and write the virtual machine physical address GPA1 where the data to be transferred is located into the DMA register of the passthrough device storage space address BAR1.
[0083] At this time, the virtual machine simultaneously configures the virtual machine physical address GPA1 in the last level page table entry of the input / output page table through the virtual machine monitor (VMM), establishes the correspondence between the virtual machine physical addresses GPA1 and HPA1 in the input / output page table, and saves it to the aforementioned shared memory. At the same time, it configures the input / output page table base address field in the device control table for subsequent lookup.
[0084] However, to further prevent the virtual machine monitor from maliciously modifying the GPA1 data in the passthrough device's storage space address BAR1 and the GPA1 in the input / output page table, in one specific implementation, when the virtual machine is a securely isolated virtual machine, when the virtual machine sends a message to the passthrough device to write the data "virtual machine physical address GPA1" from the virtual machine's physical address GPA2 to GPA2, the virtual machine can also send "virtual machine physical address GPA1" to the security processor through a secure call. The security processor then completes the configuration of the last-level page table entry in the input / output page table, thereby further ensuring the security of the virtual machine physical address GPA1 in the input / output page table.
[0085] When the virtual machine is a securely isolated virtual machine, the virtual machine physical address GPA1 can be configured to the last-level page table entry in the input / output page table through the security processor. This can prevent the virtual machine monitor from changing the virtual machine physical address in the input / output page table and can promptly detect any tampering of the virtual machine physical address configured in the passthrough device by the virtual machine monitor, thereby improving data security.
[0086] Specifically, in one embodiment, to improve the security of data transmission, the virtual machine physical address GPA1 can be sent by the virtual machine to the security processor via a secure call, so that the security processor can complete the configuration of the last-level page table entry of the input / output page table.
[0087] By using secure calls, the virtual machine's physical address is encrypted and checked, thereby improving the security of data transmission.
[0088] Of course, to further enhance the protection of the input / output page table, in one embodiment, when the virtual machine is a secure isolated virtual machine, the input / output page table with the last-level page table entry configured can be saved to secure memory by the secure processor, and the base address of the input / output page table can be obtained. The secure memory is the secure memory allocated to the secure isolated virtual machine.
[0089] It is easy to understand that when the input / output page table, after the last-level page table entries have been configured, is saved to secure memory by the secure processor, the base address of the input / output page table is no longer the original shared memory address, thus resulting in a new base address for the input / output page table. Of course, to ensure security, the secure memory is the secure memory allocated to the secure isolated virtual machine.
[0090] When a new input / output page table base address is obtained, it is configured into the device control table by the security processor so that the corresponding input / output page table can be obtained based on the device control table.
[0091] Through the above steps, the virtual machine is started, the device configuration table is established and configured, and the pass-through path between the pass-through device and the virtual machine is constructed (including the construction and configuration of the input / output page table), thereby enabling the execution of the virtual machine data read / write method provided in the embodiments of this application.
[0092] Please refer to Figure 3 , Figure 3 This is a flowchart illustrating a virtual machine data read / write method provided in an embodiment of this application.
[0093] like Figure 3 As shown in the embodiments of this application, the virtual machine data read / write method is applicable to input / output management devices and may include the following steps:
[0094] Step S30: Obtain the data read / write request sent by the passthrough device. The data read / write request includes the physical address of the virtual machine to which the data is to be read / written. The passthrough device is the external device of the corresponding virtual machine.
[0095] After configuration, the pass-through device will issue a data read / write request. Of course, the data read / write request includes the virtual machine physical address of the data to be read / written. Continuing with the previous example, this is the virtual machine physical address GPA1.
[0096] For the Input / Output Storage Management Unit (IOMMU), it receives data read / write requests sent by the passthrough device, obtains the virtual machine physical address corresponding to the read / write, so that the subsequently generated address data read request includes the host physical address corresponding to the virtual machine physical address.
[0097] Of course, as can be seen from the foregoing description, in a specific embodiment, when the virtual machine is a securely isolated virtual machine, the virtual machine data read / write method provided in this application obtains the virtual machine physical address by which the virtual machine is pre-configured to the passthrough device by the virtual machine, and is pre-sent to the security processor by the virtual machine through a secure call, so that the security processor can complete the configuration of the last-level page table entry of the input / output page table.
[0098] When a virtual machine is a secure isolated virtual machine and it starts up, the Virtual Machine Monitor (VMM) assigns a specific secure isolated virtual machine number, VMID1, to it and informs the security processor of the relevant information. When the secure isolated virtual machine establishes a passthrough path with the passthrough device, it directly configures the address of the data to be read and written, "Virtual Machine Physical Address GPA1", to the passthrough device. At this time, this GPA1 belongs to the secure isolated virtual machine with the number VMID1. At the same time, the secure isolated virtual machine also sends the virtual machine physical address GPA1 to the security processor in advance through a secure call. When the security processor receives the virtual machine physical address GPA1, it completes the configuration of the last-level page table entry of the input / output page table.
[0099] As can be seen, when the virtual machine is a secure isolated virtual machine, when the virtual machine initializes the passthrough device, the virtual machine will send the virtual machine physical address GPA1 to the security processor, in order to prepare for the security processor to configure the last level of the input / output page table entries.
[0100] Furthermore, when the virtual machine is a securely isolated virtual machine, the last-level page table entry in the input / output page table is configured by the security processor, wherein the last-level page table entry includes the correspondence between the virtual machine's physical address and the host's physical address.
[0101] As mentioned above, when a virtual machine starts up, the Virtual Machine Monitor (VMM) creates all page table entries in the input / output page table except for the last-level page table entry for the secure pass-through device. The last-level page table entry is created by the security processor after a specific read / write request is issued. The last-level page table entry completes the mapping between the virtual machine physical address (GPA) and the host physical address (HPA). That is, after the virtual machine sends the virtual machine physical address GPA1 to the security processor, the security processor will configure the last-level page table entry corresponding to GPA1 and HPA1 in the input / output page table.
[0102] As can be seen, in the virtual machine data read / write method provided in this application embodiment, when the pass-through device is a secure pass-through device, the virtual machine monitor (VMM) does not have the authority to construct all input / output page table entries for the secure pass-through device. The last-level input / output page table entries are constructed by the security processor, and the last-level page table entries include the correspondence between the virtual machine physical address and the host physical address. This can prevent the virtual machine monitor (VMM) from knowing the correspondence between the virtual machine physical address and the host physical address, or from tampering with the virtual machine physical address and the host physical address, thereby ensuring the security of the correspondence between the virtual machine physical address and the host physical address and improving the security of data transmission.
[0103] Furthermore, the input / output page table with the last-level page table entries configured is saved to secure memory by the secure processor to obtain the base address of the input / output page table. The secure memory is the secure memory allocated to the secure isolated virtual machine.
[0104] After the security processor configures the last-level page table entry of the I / O page table for the secure pass-through device, it saves the configured I / O page table to secure memory, thus obtaining the base address of the I / O page table for the secure pass-through device. At this time, the secure memory is the secure memory allocated to the secure isolated virtual machine, which ensures that the configured I / O page table cannot be tampered with by the virtual machine monitor (VMM), thereby improving the security of I / O page table storage. Of course, the obtained base address of the I / O page table provides the basis for the subsequent configuration of the device control table of the pass-through device.
[0105] Please continue to refer to this. Figure 3 Step S31: Obtain the configured device control table corresponding to the pass-through device, obtain the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and obtain the configured input / output page table according to the input / output page table base address.
[0106] Upon receiving a data read / write request, the Input / Output Storage Management Unit (IOMMU) can determine the corresponding stored device control table based on the pass-through device that sent the data read / write request. It can then obtain the virtual machine identifier and input / output page table base address of the virtual machine in the device control table, and obtain the configured input / output page table based on the input / output page table base address.
[0107] Of course, in a specific embodiment, when the virtual machine is a secure isolated virtual machine, in order to ensure that the pass-through device to the secure virtual machine works in a secure environment and that the pass-through device corresponding to the secure isolated virtual machine can directly access the secure memory of the secure isolated virtual machine, a virtual machine identifier field can be set in the device control table.
[0108] To ensure that the passthrough device for secure virtual machines operates in a secure environment, this embodiment of the application adds a virtual machine identifier field to the device control table of the passthrough device. The virtual machine identifier field records the virtual machine identifier.
[0109] In one specific embodiment, the virtual machine identifier field may include a security isolation identifier field (secure identifier field) and a virtual machine number identifier field (VMID identifier field). Accordingly, the virtual machine identifier recorded in the virtual machine identifier field includes the security isolation identifier (secure) and the virtual machine number identifier (VMID).
[0110] The security isolation identifier includes an isolation identifier and a non-isolation identifier. The isolation identifier can be represented by 1, and the non-isolation identifier can be represented by 0. When the security isolation identifier of a pass-through device is a non-isolation identifier of 0, it indicates that the pass-through device is a normal pass-through device. When the security isolation identifier of a pass-through device is an isolation identifier of 1, it indicates that the pass-through device is a secure pass-through device. In this case, the virtual machine number identifier field and the input / output page table base address field in the device control table can only be configured by the security processor, and the virtual machine monitor (VMM) has no right to configure them.
[0111] Only after the security processor changes the security isolation flag in the device control table of a passthrough device from isolation flag 1 to non-isolation flag 0, can the virtual machine monitor (VMM) configure the virtual machine number identifier field and the input / output page table base address field of that passthrough device.
[0112] It is evident that by adding a virtual machine identifier field to the device control table, direct data access between pass-through devices and securely isolated virtual machines can be achieved.
[0113] Furthermore, by setting the virtual machine identifier field to be controlled only by the security processor, the virtual machine monitor (VMM) can be prevented from controlling the device control table, thereby enhancing the security of the device control table and improving the security of data transmission between external passthrough devices and securely isolated virtual machines. Simultaneously, the secure identifier field and virtual machine ID field included in the virtual machine identifier field provide the security processor with more diverse control fields, enabling the security processor to better manage passthrough devices.
[0114] When a virtual machine starts, a passthrough device is assigned to a securely isolated virtual machine. The security processor learns which passthrough devices are regular passthrough devices and which are secure passthrough devices. After obtaining this information, the security processor configures the corresponding secure isolation identifier in the device control table for each passthrough device. Regular passthrough devices are configured with a non-isolation identifier (0), while secure passthrough devices are configured with an isolation identifier (1). Furthermore, the Virtual Machine Monitor (VMM) also assigns a virtual machine ID to the securely isolated virtual machine and informs the security processor of this information. Upon receiving this information, the security processor will... The security processor configures the Virtual Machine ID (VMID) in the device control table for the passthrough device. When the passthrough device is a normal passthrough device, the security processor configures the Virtual Machine ID (VMID) to 0. When VMID is 0, it means that the passthrough device is using the shared memory shared by the secure isolated virtual machine monitor (VMM) or even other virtual machines, as described above. When the passthrough device is a secure passthrough device, the security processor configures the Virtual Machine ID (VMID) to the specific secure isolated virtual machine ID VMID1. When VMID is the specific VMID1, it means that the passthrough device can use the secure memory corresponding to the secure isolated virtual machine VMID1 in the SPOT table.
[0115] As can be seen, the virtual machine identifier recorded in the virtual machine identifier field of the device control table is specifically configured by the security processor, which can prevent it from being tampered with by the virtual machine monitor (VMM), further improving the security of the device control table, and also providing a foundation for improving the security of data transmission between external pass-through devices and securely isolated virtual machines.
[0116] Meanwhile, the virtual machine identifier includes a secure identifier and a virtual machine ID (VMID). The secure identifier can easily indicate whether the passthrough device is a normal passthrough device or a secure passthrough device, while the virtual machine ID (VMID) can indicate whether the passthrough device uses shared memory or secure memory, enabling the security processor to configure the device control table more simply and clearly.
[0117] Of course, in another specific embodiment, the virtual machine identifier recorded in the virtual machine identifier field added to the device control table may include the virtual machine monitor identifier and the virtual machine number identifier.
[0118] When a virtual machine starts up, the Virtual Machine Monitor (VMM) allocates passthrough devices for secure isolated virtual machines. After the security processor learns which passthrough devices are ordinary passthrough devices and which are secure passthrough devices, it configures the virtual machine monitor identifier in the device control table for the corresponding passthrough device. When the passthrough device is an ordinary passthrough device, the security processor sets the virtual machine monitor identifier to 0, indicating that the ordinary passthrough device uses the shared memory shared by the secure isolated virtual machine monitor (VMM) or even other virtual machines. Only when the security processor sets the virtual machine monitor identifier to 0 can the virtual machine monitor (VMM) have the right to configure the input / output page table base address field in the device control table of the passthrough device. Otherwise, the input / output page table base address field in the device control table can only be configured by the security processor.
[0119] When the passthrough device is a secure passthrough device, the security processor will configure the virtual machine ID in the device control table to the specific secure isolated virtual machine ID VMID1 according to the virtual machine ID assigned to the secure isolated virtual machine by the virtual machine monitor (VMM). When VMID is the specific VMID1, it means that the passthrough device can access the secure memory corresponding to the secure isolated virtual machine VMID1 in the SPOT table.
[0120] As can be seen, the virtual machine identifier recorded in the virtual machine identifier field of the device control table can include the virtual machine monitor identifier and the virtual machine number identifier. The virtual machine number identifier is still configured by the security processor. While preventing the virtual machine number identifier from being tampered with by the virtual machine monitor (VMM) and further improving the security of the device control table, it also makes the configuration method of the virtual machine identifier more flexible and diverse.
[0121] In one specific embodiment, when the virtual machine is a secure isolated virtual machine, the virtual machine identifier and the input / output page table base address are both pre-configured to the device control table by the security processor.
[0122] When the virtual machine is a secure isolated virtual machine, as described above, when the virtual machine starts, the Virtual Machine Monitor (VMM) creates all page table entries in the input / output page table for the secure pass-through device except for the last-level page table entry. The last-level page table entry is created by the security processor. The input / output page table with the last-level page table entry configured is saved to secure memory by the security processor, obtaining the base address of the input / output page table of the secure pass-through device. At the same time, when the virtual machine starts, the Virtual Machine Monitor (VMM) also assigns a Virtual Machine ID (VMID) to the secure isolated virtual machine, assigns a pass-through device to the secure isolated virtual machine, and informs the security processor which pass-through devices are ordinary pass-through devices and which pass-through devices are secure pass-through devices. Therefore, the security processor can obtain the relevant virtual machine identification information. Furthermore, the Virtual Machine Monitor (VMM) requests the security processor to configure the device control table for the pass-through device. In this way, the security processor can configure the virtual machine ID and the base address of the input / output page table into the device control table.
[0123] By pre-configuring the virtual machine identifier and I / O page table base address into the device control table through the security processor, the smooth reading and writing of confidential data between the pass-through device and the securely isolated virtual machine can be guaranteed.
[0124] Therefore, the input / output storage management unit can obtain the virtual machine identifier and the base address of the input / output page table of the virtual machine through the device control table, so as to ensure the acquisition of the virtual machine identifier and the input / output page table.
[0125] Please continue to refer to this. Figure 3 After obtaining the configured input / output page table, step S32: Based on the input / output page table, obtain the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address, wherein the encryption information represents the encryption status of the memory space corresponding to the host physical address.
[0126] As described above, when a virtual machine starts up, after the Virtual Machine Monitor (VMM) allocates a passthrough device for the virtual machine, the input / output page table is created by the VMM. When the passthrough device is a normal passthrough device, the VMM can create an input / output page table for the normal passthrough device, configure all page table entries, and store the configured input / output page table in the shared memory shared by the VMM and the virtual machine, thus obtaining the base address of the input / output page table for the normal passthrough device.
[0127] When the passthrough device is a secure passthrough device, the Virtual Machine Monitor (VMM) creates all page table entries in the input / output page table except for the last-level page table entry. After the security processor configures the last-level page table entry for the secure passthrough device, it saves the configured input / output page table to secure memory, thus obtaining the base address of the secure passthrough device's input / output page table. The input / output page table can be obtained through the base address. The last-level page table entry includes the mapping between the virtual machine physical address (GPA) and the host physical address (HPA). The host physical address contains encrypted information related to the host physical address, which indicates the encryption status of the memory space corresponding to the host physical address. The host physical address (HPA) includes the secure memory address pre-allocated to the virtual machine, that is, the host physical address includes the part of the host physical address that has been configured in the SPOT table. This ensures the security of the passthrough device when accessing secure memory.
[0128] Of course, the encrypted information is contained in the host's physical address. Specifically, it can be identified by the c-bit. When c-bit = 1, it is encrypted memory, and when c-bit = 0, it is unencrypted memory.
[0129] Step S33: Based on the encrypted information, the virtual machine identifier, and the host physical address, construct an address data read / write request and send the address data read / write request to the memory.
[0130] After obtaining the encryption information, the virtual machine identifier, and the host physical address, the input / output storage management unit in this embodiment of the application has enhanced hardware functions. It can construct address data read / write requests using the input / output storage management unit and send the constructed address data read / write requests to the memory controller.
[0131] Of course, during the actual data reading process, the obtained virtual machine identifier may be a virtual machine code identifier that indicates a specific secure isolated virtual machine. In this case, the obtained address data read / write request is an address data read / write request that includes the specific virtual machine code identifier to access the secure memory of the secure isolated virtual machine. Alternatively, it may be a non-isolated identifier or a virtual machine monitor identifier that is not a secure isolated virtual machine. In this case, the obtained address data read / write request is an address data read / write request to access shared memory.
[0132] Furthermore, to clearly illustrate address data read / write requests, let's take the example of a virtual machine identifier field that includes a security isolation identifier field (secure identifier field) and a virtual machine number identifier field (VMID identifier field). Accordingly, the virtual machine identifier recorded in the virtual machine identifier field includes a security isolation identifier (secure) and a virtual machine number identifier (VMID). Example 1:
[0133] When the virtual machine is a secure isolated virtual machine, in order to ensure that the pass-through device to the secure virtual machine works in a secure environment, this application embodiment adds a virtual machine identifier field to the device control table of the pass-through device. The virtual machine identifier field records the virtual machine identifier, which includes a secure identifier and a virtual machine number identifier (VMID).
[0134] When a virtual machine starts up, the Virtual Machine Monitor (VMM) assigns passthrough devices to securely isolated virtual machines and informs the security processor which passthrough devices are regular passthrough devices and which are secure passthrough devices. After receiving the relevant information, the security processor configures the security isolation identifier (secure) in the device control table accordingly for the passthrough devices. It configures the security isolation identifier (secure) of regular passthrough devices to non-isolation identifier 0 and the security isolation identifier (secure) of secure passthrough devices to isolation identifier 1.
[0135] Furthermore, when a virtual machine starts up, the Virtual Machine Monitor (VMM) assigns a Virtual Machine ID to the secure isolated virtual machine and informs the security processor of the relevant information. After receiving the relevant information, the security processor will configure the Virtual Machine ID (VMID) in the device control table for the passthrough device accordingly. When the passthrough device is a normal passthrough device, the security processor will configure the Virtual Machine ID (VMID) to 0. When VMID is 0, it means that the passthrough device is using the shared memory shared by the secure isolated virtual machine monitor (VMM) or even other virtual machines, as mentioned above. When the passthrough device is a secure passthrough device, the security processor will configure the Virtual Machine ID (VMID) to the specific secure isolated virtual machine ID VMID1. When VMID is the specific VMID1, it means that the passthrough device is using the secure memory corresponding to the secure isolated virtual machine VMID1 in the SPOT table.
[0136] Therefore, when a virtual machine starts, if the passthrough device is a regular passthrough device, the security processor configures the security isolation flag (secure) in the device control table of the regular passthrough device to 0 and the virtual machine ID (VMID) to 0. When secure is 0, the virtual machine monitor (VMM) creates page table entries for all input / output page tables for the regular passthrough device and stores the created input / output page tables in the shared memory shared by the virtual machine monitor (VMM) and the virtual machine, obtaining the base address of the input / output page table of the regular passthrough device. The virtual machine monitor (VMM) writes the obtained base address of the input / output page table into the device control table corresponding to the regular passthrough device. The last-level page table entry of the input / output page table includes the correspondence between the virtual machine physical address (GPA) and the host physical address (HPA). When secure is 0 and VMID is configured to 0, the host physical address (HPA) points to the shared memory shared by the virtual machine monitor (VMM) and the virtual machine, and the host physical address contains encrypted information related to the host physical address. This encrypted information can indicate the encryption status of the memory space corresponding to the host physical address.
[0137] When a virtual machine starts, if the passthrough device is a secure passthrough device, the security processor configures the secure isolation identifier (secure) in the device control table of the secure passthrough device to 1, and configures the virtual machine number identifier (VMID) to the specific secure isolation virtual machine number VMID1; when secure is 1, the virtual machine monitor (VMM) creates the remaining page table entries in the input / output page table for the secure passthrough device, except for the last level page table entry.
[0138] After the Virtual Machine Monitor (VMM) facilitates the establishment of a passthrough process between the secure virtual machine and the passthrough device for data input or output, when the virtual machine and the passthrough device construct a passthrough path, the virtual machine's physical address GPA1 is directly configured to the passthrough device (when the virtual machine sends data, GPA1 is the source virtual machine's physical address; when the virtual machine receives data, GPA1 is the destination virtual machine's physical address). Simultaneously, the virtual machine also pre-sends its physical address GPA1 to the security processor via a secure call. The last-level page table entry of the I / O page table is created by the security processor. The input / output page table, after its first-level page table entry configuration is completed, is saved to secure memory by the security processor, obtaining the base address of the input / output page table for the secure pass-through device. The security processor then writes this base address into the device control table corresponding to the secure pass-through device. The last-level page table entry includes the mapping between the virtual machine physical address (GPA) and the host physical address (HPA). Specifically, after the virtual machine sends its physical address GPA1 to the security processor, the security processor configures the last-level page table entry corresponding to GPA1 and HPA1 in the input / output page table. When secure is 1 and VMID is configured as the specific secure isolation virtual machine number VMID1, the host physical address (HPA) points to the secure memory already configured in the SPOT table. Similarly, the host physical address also contains encrypted information related to the host physical address, which indicates the encryption status of the memory space corresponding to the host physical address.
[0139] When a passthrough device needs to read or write data with a securely isolated virtual machine, the passthrough device sends a data request for GPA1 address data to the Input / Output Storage Management Unit (IOMMU). Upon receiving the data request, the IOMMU determines the corresponding device control table based on the passthrough device that sent the data request. It then obtains the secure, VMID, and I / O page table base address information from the device control table. Based on the I / O page table base address information, it can locate the I / O page table (IO page table), thereby obtaining the correspondence between the virtual machine physical address (GPA) and the host physical address (HPA) in the I / O page table (IO page table), as well as the encryption information contained in the host physical address (HPA). Based on the HPA indication, the IOMMU constructs an address data read / write request using the aforementioned encryption information, the virtual machine identifier (secure, VMID), and the host physical address, and sends the address data read / write request to the memory controller.
[0140] In summary, when HPA points to shared encrypted memory, the IOMMU constructs an address data read / write request in the format of {C-bit=1, VMID=0, physical address} and sends this address data read / write request to the memory controller to complete subsequent data read / write. In this scenario, the host and virtual machine use the same key for shared memory, so the host and virtual machine can share memory content.
[0141] C-bit represents the encrypted information bit; C-bit = 1 indicates encryption, and C-bit = 0 indicates no encryption. The physical address is the host physical address (HPA).
[0142] When HPA points to encrypted secure memory, the IOMMU constructs an address data read / write request with the format: {C-bit=1, VMID=VMID1, physical address}, and sends this address data read / write request to the memory controller to complete the subsequent data read / write.
[0143] VMID1 is the specific security-isolated virtual machine number.
[0144] In another specific embodiment, to clearly illustrate the address data read / write request, the virtual machine identifier recorded in the virtual machine identifier field includes the virtual machine monitor identifier and the virtual machine number identifier, as exemplified in Example 2. For the sake of simplicity, please refer to the description of Example 1 for the same parts, and only the different parts are described as follows:
[0145] When the virtual machine is a securely isolated virtual machine, the virtual machine identifier field added to the device control table of the pass-through device includes the virtual machine monitor identifier and the virtual machine number identifier.
[0146] When a virtual machine starts up, the Virtual Machine Monitor (VMM) assigns a passthrough device to the secure isolated virtual machine. When the passthrough device is a normal passthrough device, the security processor configures the virtual machine monitor identifier to 0. For subsequent I / O page table and other related configurations, please refer to the description in Example 1, which will not be repeated here. When the passthrough device is a secure passthrough device, the security processor configures the virtual machine number identifier in the device control table to the specific secure isolated virtual machine number VMID1 according to the virtual machine number assigned to the secure isolated virtual machine by the virtual machine monitor (VMM). For subsequent I / O page table and other related configurations, please refer to the description in Example 1, which will not be repeated here.
[0147] In summary, the virtual machine data read / write method provided in this application embodiment is applicable to an input / output storage management unit. When performing virtual machine data read / write, it first obtains a data read / write request sent by a passthrough device, the data read / write request including the virtual machine physical address of the data to be read / written; then, it obtains the corresponding configured device control table according to the passthrough device, obtains the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and obtains the configured input / output page table according to the input / output page table base address; next, it obtains the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address according to the input / output page table; finally, it constructs an address data read / write request according to the encryption information, the virtual machine identifier, and the host physical address, and sends the address data read / write request to memory.
[0148] Thus, the virtual machine data read / write method provided in this application embodiment, by setting a virtual machine identifier in the device control table, can ensure that the device control table based on the specific pass-through device can obtain the virtual machine identifier. Therefore, when an address data read / write request is formed, the formed address data read / write request not only includes the host physical address and encryption information, but also includes the virtual machine identifier. This enables direct access to the memory of the virtual machine corresponding to the virtual machine identifier based on the host physical address and the virtual machine identifier. The virtual machine monitor has no right to access the secure memory corresponding to the virtual machine, thereby preventing the virtual machine monitor from stealing or tampering with data, and thus ensuring the security of confidential data transmission between the pass-through device and the virtual machine.
[0149] To address the aforementioned problems, this application also provides a virtual machine data read / write method, applicable to memory controllers. Upon receiving the aforementioned data read / write request, the memory controller performs data read / write operations. For details, please refer to [reference needed]. Figure 4 , Figure 4 This is another flowchart illustrating the virtual machine data read / write method provided in an embodiment of this application.
[0150] Step S40: Receive an address data read / write request, wherein the address data read / write request includes a request obtained according to the virtual machine data read / write method described in any of the foregoing embodiments.
[0151] Once the IOMMU has completed constructing the address data read / write request, it will send the address data read / write request to the memory controller. After receiving the address data read / write request, the memory controller will continue to complete the subsequent data read / write.
[0152] Step S41: Obtain the corresponding memory virtual machine identifier from the pre-stored memory owner table based on the host physical address in the address data read / write request.
[0153] Based on the host physical address in the address data read / write request, it can be determined whether the address data read / write request is trying to access shared memory shared by the virtual machine monitor (VMM) and the virtual machine, or secure memory. When the address data read / write request is trying to access secure memory, the memory controller will obtain the memory virtual machine identifier corresponding to the host physical address from the memory owner table (i.e., the SPOT table) that is pre-stored.
[0154] Step S42: When the memory virtual machine identifier matches the virtual machine identifier, read and write data in the host physical address according to the address data read and write request.
[0155] When the address data read / write request is for accessing shared memory, the memory controller will read or write data in the host physical address according to the address data read / write request.
[0156] When the address data read / write request is for accessing secure memory, the memory controller will obtain the memory virtual machine identifier corresponding to the host physical address in the SPOT table based on the host physical address in the address data read / write request. After obtaining the memory virtual machine identifier, it will compare it with VMID1 in the address data read / write request. If they are the same, access to the secure memory corresponding to the host physical address is allowed, and data will be read and written in the host physical address according to the address data read / write request.
[0157] As can be seen, after receiving an address data read / write request, the memory controller will continue to complete the data read / write according to the address data read / write request. When the address data read / write request is to access safe memory, it will further check whether SPOT matches. Only if it matches will access to safe memory be allowed, thus further ensuring the safety of data read / write.
[0158] Specifically, based on the different encrypted information, the steps of reading and writing data in the host physical address according to the address data read / write request include:
[0159] When the encryption information identifier of the address data read / write request is encrypted, the encryption / decryption key is obtained according to the virtual machine identifier;
[0160] When the address data read / write request is a read request, the data in the host physical address is decrypted using the encryption / decryption key and returned to the pass-through device;
[0161] When the address data read / write request is a write request, the encryption / decryption key is used to encrypt the data to be written and write it to the memory space corresponding to the host physical address.
[0162] As can be seen, the technical solution provided in this application embodiment can perform data read and write operations according to address data read and write requests, and can also encrypt and decrypt the data before continuing to complete the data read and write operations, ensuring the completion of data read and write under encryption and decryption conditions.
[0163] Continuing with Example 1 above, the steps for reading and writing data will be explained as follows:
[0164] When the HPA points to shared encrypted memory, the memory controller receives an address data read / write request in the format: {C-bit=1, VMID=0, physical address}, where C-bit is the encryption information bit, C-bit=1 indicates encryption, and the physical address is the host physical address (HPA). The host physical address (HPA) contains encryption information related to the host physical address, which indicates the encryption status of the memory space corresponding to the host physical address. The memory controller receives the encryption information, obtains the encryption / decryption key based on the virtual machine identifier, and when the address data read / write request is a read request, it uses the encryption / decryption key to decrypt the data in the host physical address and returns it to the passthrough device; when the address data read / write request is a write request, it uses the encryption / decryption key to encrypt the data to be written and writes it to the memory space corresponding to the host physical address.
[0165] When HPA points to encrypted secure memory, the memory controller receives an address data read / write request with the address format: {C-bit=1, VMID=VMID1, physical address}. The memory controller retrieves the memory virtual machine identifier corresponding to the host physical address from the SPOT table based on the host physical address in the address data read / write request. After obtaining the memory virtual machine identifier, it compares it with VMID1 in the address data read / write request. If they are the same, access to the secure memory corresponding to the host physical address is allowed. C-bit represents the encryption information bit; C-bit=1 indicates encryption, and physical address... The address is the Host Physical Address (HPA). The HPA contains encrypted information related to the host physical address. This encrypted information indicates the encryption status of the memory space corresponding to the host physical address. The memory controller obtains the encrypted information and, based on the virtual machine identifier, obtains the encryption / decryption key. When the address data read / write request is a read request, the encryption / decryption key is used to decrypt the data in the host physical address and return it to the passthrough device. When the address data read / write request is a write request, the encryption / decryption key is used to encrypt the data to be written and write it to the memory space corresponding to the host physical address.
[0166] In Example 2 above, after the memory controller obtains the address data read / write request, the steps for reading and writing data are the same as in Example 1, and will not be repeated here.
[0167] The foregoing describes multiple embodiment schemes provided by the embodiments of this application. The optional methods described in each embodiment scheme can be combined and cross-referenced with each other without conflict, thereby extending to a variety of possible embodiment schemes. These can all be considered as the embodiment schemes disclosed and published by the embodiments of this application.
[0168] This application also provides a virtual machine data reading and writing device, which can be considered as a functional module required to implement the virtual machine data reading and writing method provided in this application.
[0169] Please refer to Figure 5 , Figure 5 This is a schematic diagram of the structure of a virtual machine data read / write device provided in an embodiment of this application.
[0170] like Figure 5 As shown, the virtual machine data read / write device provided in this application embodiment is suitable for an input / output storage management unit and may include:
[0171] The data read / write request acquisition module 50 is adapted to acquire data read / write requests sent by a pass-through device. The data read / write request includes the virtual machine physical address of the data to be read / written, wherein the pass-through device is an external device of the corresponding virtual machine.
[0172] The input / output page table acquisition module 51 is adapted to acquire the configured device control table corresponding to the pass-through device, acquire the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and acquire the configured input / output page table according to the input / output page table base address;
[0173] The host physical address and encryption information acquisition module 52 is adapted to acquire the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address according to the input / output page table, wherein the encryption information represents the encryption status of the memory space corresponding to the host physical address;
[0174] Address data read / write request construction module 53 is adapted to construct an address data read / write request based on the encrypted information, the virtual machine identifier and the host physical address, and send the address data read / write request to memory.
[0175] In some embodiments, when the virtual machine is a secure isolated virtual machine, the virtual machine identifier and the input / output page table base address are both pre-configured to the device control table by the security processor.
[0176] In some embodiments, the device control table is created via a virtual machine monitor.
[0177] In some embodiments, when the virtual machine is a secure isolated virtual machine, the input / output page table with the last-level page table entry configured is saved to secure memory by the secure processor to obtain the base address of the input / output page table, and the secure memory is the secure memory allocated to the secure isolated virtual machine.
[0178] In some embodiments, when the virtual machine is a secure isolated virtual machine, the last-level page table entry in the input / output page table is configured by the security processor, wherein the last-level page table entry includes the correspondence between the virtual machine's physical address and the host's physical address.
[0179] In some embodiments, when the virtual machine is a secure isolated virtual machine, the virtual machine's physical address is pre-configured to the passthrough device by the virtual machine and pre-sent to the security processor by the virtual machine through a secure call, so that the security processor can complete the configuration of the last-level page table entry of the input / output page table.
[0180] In some embodiments, the input / output page table is created via the virtual machine monitor.
[0181] In some embodiments, the host physical address includes a secure memory address pre-allocated to the virtual machine.
[0182] In some embodiments, the virtual machine identifier includes a security isolation identifier and a virtual machine number identifier.
[0183] In some embodiments, the security isolation identifier includes an isolation identifier and a non-isolation identifier.
[0184] In some embodiments, the virtual machine identifier includes a virtual machine monitor identifier and a virtual machine number identifier.
[0185] This application also provides a virtual machine data read / write device, suitable for a memory controller, which may include:
[0186] The address data read / write request acquisition module is adapted to receive address data read / write requests, wherein the address data read / write requests include requests obtained according to the virtual machine data read / write method described in any of the foregoing embodiments.
[0187] The memory virtual machine identifier acquisition module is adapted to obtain the memory virtual machine identifier corresponding to the pre-stored memory owner table based on the host physical address in the address data read / write request;
[0188] The read / write data module is adapted to read and write data in the host physical address according to the address data read / write request when the memory virtual machine identifier is consistent with the virtual machine identifier.
[0189] In some embodiments, the read / write data module is adapted to read / write data in the host physical address according to the address data read / write request, including:
[0190] The encryption / decryption key acquisition unit is adapted to acquire the encryption / decryption key based on the virtual machine identifier when the encryption information identifier of the address data read / write request is encrypted;
[0191] The data read unit is adapted to decrypt the data in the host physical address using the encryption / decryption key when the address data read / write request is a read request, and return the data to the pass-through device.
[0192] The write data unit is adapted to encrypt the data to be written using the encryption / decryption key when the address data read / write request is a write request, and write it to the memory space corresponding to the host physical address.
[0193] As can be seen, the virtual machine data read / write device provided in this application embodiment can provide hardware protection for the virtual machine data read / write method provided in this application embodiment. By setting a virtual machine identifier in the device control table, it can be ensured that the device control table based on the specific pass-through device can obtain the virtual machine identifier. Thus, when an address data read / write request is formed, the formed address data read / write request not only includes the host physical address and encryption information, but also includes the virtual machine identifier. This enables direct access to the memory of the virtual machine corresponding to the virtual machine identifier based on the host physical address and the virtual machine identifier. The virtual machine monitor has no right to access the secure memory corresponding to the virtual machine, thereby preventing the virtual machine monitor from stealing or tampering with data, and thus ensuring the security of confidential data transmission between the pass-through device and the virtual machine.
[0194] Please refer to Figure 6 , Figure 6 This is an architectural diagram of an electronic device provided in an embodiment of this application.
[0195] This application also provides an electronic device, including:
[0196] Virtual machine 60;
[0197] The pass-through device 61 is adapted to perform data reading and writing with the virtual machine;
[0198] The input / output storage management unit 62 is adapted to construct an address data read / write request based on the data read / write request sent by the pass-through device 61, and send the address data read / write request to the memory to execute the virtual machine data read / write method as described in any of the foregoing embodiments.
[0199] Of course, an electronic device provided in this application embodiment may also include a virtual machine monitor 63: adapted to manage data reading and writing between the virtual machine 60 and the pass-through device 61;
[0200] Security processor 64: suitable for configuring data security for virtual machine 60 and pass-through device 61;
[0201] Memory controller 65: adapted to control data reading and writing between virtual machine 60 and pass-through device 61;
[0202] Memory 66: Includes shared memory and secure memory, suitable for storing data.
[0203] This application also provides another electronic device, including:
[0204] The input / output storage management unit is adapted to construct an address data read / write request based on the data read / write request sent by the pass-through device, and send the address data read / write request to the memory to execute the virtual machine data read / write method as described in any of the foregoing embodiments.
[0205] A memory controller is adapted to receive address data read / write requests, wherein the address data read / write requests include obtaining a request according to the virtual machine data read / write method described in any of the foregoing embodiments, obtaining the corresponding memory virtual machine identifier in a pre-stored memory owner table according to the host physical address in the address data read / write request, and when the memory virtual machine identifier is consistent with the virtual machine identifier, reading and writing data in the host physical address according to the address data read / write request.
[0206] While the embodiments disclosed above are described in this application, this application is not limited thereto. Any person skilled in the art can make various modifications and alterations without departing from the spirit and scope of this application; therefore, the scope of protection of this application should be determined by the scope defined in the claims.
Claims
1. A virtual machine data read / write method, characterized in that, Applicable to input / output storage management units, including: Obtain a data read / write request sent by a passthrough device, wherein the data read / write request includes the physical address of the virtual machine to which the data is to be read / written, and the passthrough device is an external device of the corresponding virtual machine; Obtain the configured device control table corresponding to the pass-through device, obtain the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and obtain the configured input / output page table based on the input / output page table base address; According to the input / output page table, obtain the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address, wherein the encryption information indicates whether the memory space corresponding to the host physical address is encrypted; Based on the encrypted information, the virtual machine identifier, and the host physical address, an address data read / write request is constructed and sent to the memory; the memory is the virtual machine's secure memory; the secure memory cannot be accessed by the virtual machine monitor.
2. The virtual machine data read / write method as described in claim 1, characterized in that, When the virtual machine is a secure isolated virtual machine, the virtual machine identifier and the input / output page table base address are both pre-configured to the device control table by the security processor.
3. The virtual machine data read / write method as described in claim 2, characterized in that, The device control table is created using a virtual machine monitor.
4. The virtual machine data read / write method as described in claim 1, characterized in that, When the virtual machine is a secure isolated virtual machine, the input / output page table with the last-level page table entry configured is saved to secure memory by the secure processor to obtain the base address of the input / output page table. The secure memory is the secure memory allocated to the secure isolated virtual machine.
5. The virtual machine data read / write method as described in claim 4, characterized in that, When the virtual machine is a secure isolated virtual machine, the last-level page table entry in the input / output page table is configured by the security processor, wherein the last-level page table entry includes the correspondence between the virtual machine's physical address and the host's physical address.
6. The virtual machine data read / write method as described in claim 4, characterized in that, When the virtual machine is a secure isolated virtual machine, the physical address of the virtual machine is pre-configured to the passthrough device by the virtual machine and pre-sent to the security processor by the virtual machine through a secure call, so that the security processor can complete the configuration of the last-level page table entry of the input / output page table.
7. The virtual machine data read / write method as described in claim 4, characterized in that, The input / output page table is created through the virtual machine monitor.
8. The virtual machine data read / write method according to any one of claims 1-7, characterized in that, The host physical address includes the secure memory address pre-allocated to the virtual machine.
9. The virtual machine data read / write method according to any one of claims 1-7, characterized in that, The virtual machine identifier includes a security isolation identifier and a virtual machine number identifier.
10. The virtual machine data read / write method as described in claim 9, characterized in that, The security isolation signage includes isolation signs and non-isolation signs.
11. The virtual machine data read / write method according to any one of claims 1-7, characterized in that, The virtual machine identifier includes the virtual machine monitor identifier and the virtual machine number identifier.
12. A virtual machine data read / write method, characterized in that, Applicable to memory controllers, including: Receive an address data read / write request, wherein the address data read / write request includes obtaining a request according to the virtual machine data read / write method as described in any one of claims 1-11; Based on the host physical address in the address data read / write request, obtain the corresponding memory virtual machine identifier from the pre-stored memory owner table; When the memory virtual machine identifier matches the virtual machine identifier, data is read or written in the host physical address according to the address data read / write request.
13. The virtual machine data read / write method as described in claim 12, characterized in that, The step of reading and writing data in the host physical address according to the address data read / write request includes: When the encryption information identifier of the address data read / write request is encrypted, the encryption / decryption key is obtained according to the virtual machine identifier; When the address data read / write request is a read request, the data in the host physical address is decrypted using the encryption / decryption key and returned to the pass-through device; When the address data read / write request is a write request, the encryption / decryption key is used to encrypt the data to be written and write it to the memory space corresponding to the host physical address.
14. An input / output storage management unit, wherein the input / output storage management unit is applicable to the virtual machine data read / write method according to any one of claims 1-11, characterized in that, A device control table is stored, which includes a virtual machine identifier field.
15. The input / output storage management unit as described in claim 14, characterized in that, The virtual machine identification field includes a security isolation identification field and a virtual machine number identification field.
16. A virtual machine data read / write device, characterized in that, Applicable to input / output storage management units, including: The data read / write request acquisition module is adapted to acquire data read / write requests sent by a pass-through device. The data read / write request includes the physical address of the virtual machine to which the data is to be read / written, wherein the pass-through device is an external device of the corresponding virtual machine. The input / output page table acquisition module is adapted to acquire the configured device control table corresponding to the pass-through device, acquire the virtual machine identifier and input / output page table base address of the virtual machine through the device control table, and acquire the configured input / output page table according to the input / output page table base address; The host physical address and encryption information acquisition module is adapted to acquire the host physical address corresponding to the virtual machine physical address and the encryption information of the host physical address according to the input / output page table, wherein the encryption information indicates whether the memory space corresponding to the host physical address is encrypted; The address data read / write request construction module is adapted to construct an address data read / write request based on the encrypted information, the virtual machine identifier, and the host physical address, and send the address data read / write request to the memory; the memory is the virtual machine's secure memory; the secure memory cannot be accessed by the virtual machine monitor.
17. The virtual machine data read / write device as described in claim 16, characterized in that, When the virtual machine is a secure isolated virtual machine, the virtual machine identifier and the input / output page table base address are both pre-configured to the device control table by the security processor.
18. The virtual machine data read / write device as described in claim 17, characterized in that, The device control table is created using a virtual machine monitor.
19. The virtual machine data read / write device as described in claim 16, characterized in that, When the virtual machine is a secure isolated virtual machine, the input / output page table with the last-level page table entry configured is saved to secure memory by the secure processor to obtain the base address of the input / output page table. The secure memory is the secure memory allocated to the secure isolated virtual machine.
20. The virtual machine data read / write device as described in claim 19, characterized in that, When the virtual machine is a secure isolated virtual machine, the last-level page table entry in the input / output page table is configured by the security processor, wherein the last-level page table entry includes the correspondence between the virtual machine's physical address and the host's physical address.
21. The virtual machine data read / write device as described in claim 19, characterized in that, When the virtual machine is a secure isolated virtual machine, the physical address of the virtual machine is pre-configured to the passthrough device by the virtual machine and pre-sent to the security processor by the virtual machine through a secure call, so that the security processor can complete the configuration of the last-level page table entry of the input / output page table.
22. The virtual machine data read / write device as described in claim 19, characterized in that, The input / output page table is created through the virtual machine monitor.
23. The virtual machine data read / write apparatus according to any one of claims 16-22, characterized in that, The host physical address includes the secure memory address pre-allocated to the virtual machine.
24. The virtual machine data read / write apparatus according to any one of claims 16-22, characterized in that, The virtual machine identifier includes a security isolation identifier and a virtual machine number identifier.
25. The virtual machine data read / write device as described in claim 24, characterized in that, The security isolation signage includes isolation signs and non-isolation signs.
26. The virtual machine data read / write apparatus according to any one of claims 16-22, characterized in that, The virtual machine identifier includes the virtual machine monitor identifier and the virtual machine number identifier.
27. A virtual machine data read / write device, characterized in that, Applicable to memory controllers, including: The address data read / write request acquisition module is adapted to receive address data read / write requests, wherein the address data read / write requests include requests obtained according to the virtual machine data read / write method as described in any one of claims 1-11; The memory virtual machine identifier acquisition module is adapted to obtain the memory virtual machine identifier corresponding to the pre-stored memory owner table based on the host physical address in the address data read / write request; The read / write data module is adapted to read and write data in the host physical address according to the address data read / write request when the memory virtual machine identifier is consistent with the virtual machine identifier.
28. The virtual machine data read / write device as described in claim 27, characterized in that, The read / write data module is adapted to read and write data in the host physical address according to the address data read / write request, including: The encryption / decryption key acquisition unit is adapted to acquire the encryption / decryption key based on the virtual machine identifier when the encryption information identifier of the address data read / write request is encrypted; The data read unit is adapted to decrypt the data in the host physical address using the encryption / decryption key when the address data read / write request is a read request, and return the data to the pass-through device. The write data unit is adapted to encrypt the data to be written using the encryption / decryption key when the address data read / write request is a write request, and write it to the memory space corresponding to the host physical address.
29. An electronic device, characterized in that, include: Virtual machine; A pass-through device, suitable for data reading and writing with the virtual machine; The input / output storage management unit is adapted to construct an address data read / write request based on the data read / write request sent by the pass-through device, and send the address data read / write request to the memory to execute the virtual machine data read / write method as described in any one of claims 1 to 13.
30. An electronic device, characterized in that, include: The input / output storage management unit is adapted to construct an address data read / write request based on the data read / write request sent by the pass-through device, and send the address data read / write request to the memory to execute the virtual machine data read / write method as described in any one of claims 1 to 13; A memory controller is adapted to receive address data read / write requests, wherein the address data read / write request includes obtaining a request according to the virtual machine data read / write method according to any one of claims 1-11, obtaining a corresponding memory virtual machine identifier in a pre-stored memory owner table according to the host physical address in the address data read / write request, and when the memory virtual machine identifier is consistent with the virtual machine identifier, reading and writing data in the host physical address according to the address data read / write request.