CN117896346A - Address translation method, address translation device, physical machine and storage medium - Google Patents

Address translation method, address translation device, physical machine and storage medium Download PDF

Info

Publication number
CN117896346A
CN117896346A CN202311707210.XA CN202311707210A CN117896346A CN 117896346 A CN117896346 A CN 117896346A CN 202311707210 A CN202311707210 A CN 202311707210A CN 117896346 A CN117896346 A CN 117896346A
Authority
CN
China
Prior art keywords
virtual machine
address
machine
physical
virtual
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311707210.XA
Other languages
Chinese (zh)
Inventor
叶敬茂
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Tiantian Smart Core Semiconductor Co ltd
Original Assignee
Shanghai Tiantian Smart Core Semiconductor Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Tiantian Smart Core Semiconductor Co ltd filed Critical Shanghai Tiantian Smart Core Semiconductor Co ltd
Priority to CN202311707210.XA priority Critical patent/CN117896346A/en
Publication of CN117896346A publication Critical patent/CN117896346A/en
Pending legal-status Critical Current

Links

Landscapes

  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The invention provides an address conversion method, an address conversion device, a physical machine and a storage medium, and relates to the technical field of data processing. Comprising the following steps: acquiring a first mapping relation between a virtual address of a first virtual machine and a physical address of a client by adopting the first virtual machine; adopting a first virtual machine to send a first mapping relation of the first virtual machine to the external device of the physical machine; and adding a first mapping relation of the first virtual machine to a first address conversion table by adopting a peripheral of the physical machine, wherein the first mapping relation of at least one virtual machine is arranged in the first address conversion table, and the first mapping relation of each virtual machine is used for enabling the peripheral of the physical machine to perform address conversion in combination with a second mapping relation of a client physical address and a host physical address of each virtual machine in a second address conversion table. And issuing the first mapping relation of the first virtual machine to the peripheral equipment of the physical machine, wherein a second address conversion table is preset in the peripheral equipment of the physical machine, the virtual machine does not need to be withdrawn, and the normal operation of the virtual machine is ensured.

Description

Address translation method, address translation device, physical machine and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to an address conversion method, an address conversion device, a physical machine, and a storage medium.
Background
The virtualization technology virtualizes a plurality of devices in a software mode for a plurality of virtual machines to use, so that the purpose that the plurality of virtual machines share one physical device can be realized, and the physical machines have corresponding relations between virtual addresses and host physical addresses, thereby being convenient for converting the virtual addresses of the virtual machines.
In the related art, a virtual machine issues a corresponding relationship between a virtual address and a physical address of a client to an external device of a physical machine, a driver installed on the physical machine intercepts the corresponding relationship, at the moment, the virtual machine stops running, and exits to run on the physical machine, a father driver determines a host physical address corresponding to the physical address of the client, issues the corresponding relationship between the virtual address and the physical address of the host to a peripheral device of the physical machine, and then the virtual machine continues to run.
However, in the related art, when the correspondence between the virtual address and the host physical address is added to the physical machine, the virtual machine is required to be suspended from running.
Disclosure of Invention
The present invention is directed to address translation method, device, physical machine and storage medium, which solve the above-mentioned problems of the related art.
In order to achieve the above purpose, the technical scheme adopted by the embodiment of the invention is as follows:
in a first aspect, an embodiment of the present invention provides an address translation method applied to a physical machine, where at least one virtual device is created in advance on the physical machine, and each virtual device has a corresponding virtual machine, where the method includes:
a first virtual machine is adopted, and a first mapping relation between a virtual address of the first virtual machine and a physical address of a client is obtained;
issuing a first mapping relation of the first virtual machine to the peripheral equipment of the physical machine by adopting the first virtual machine;
and adding the first mapping relation of the first virtual machine to a first address conversion table by adopting the peripheral of the physical machine, so that the first mapping relation of at least one virtual machine is arranged in the first address conversion table, wherein the first mapping relation of each virtual machine is used for carrying out address conversion by combining the peripheral of the physical machine with the second mapping relation of the client physical address and the host physical address of each virtual machine in a second address conversion table.
Optionally, the obtaining the first mapping relationship between the virtual address of the first virtual machine and the physical address of the client machine includes:
According to the virtual address of the first virtual machine, acquiring a client machine physical address corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine;
and obtaining a first mapping relation of the first virtual machine according to the virtual address of the first virtual machine and the client physical address corresponding to the virtual address of the first virtual machine.
Optionally, the obtaining, according to the virtual address of the first virtual machine, a physical address of a client corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine includes:
according to the virtual address of the first virtual machine, a device driver on the first virtual machine is adopted to acquire a client machine physical address corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine;
the issuing, by the first virtual machine, the first mapping relationship of the first virtual machine to the peripheral device of the physical machine includes:
and adopting the device driver on the first virtual machine to issue a first mapping relation of the first virtual machine to the peripheral equipment of the physical machine.
Optionally, the method further comprises:
and when each virtual machine is started, creating a second mapping relation of each virtual machine on the peripheral of the physical machine, and obtaining the second address conversion table.
Optionally, the creating, at the time of starting each virtual machine, a second mapping relationship of each virtual machine on a peripheral of the physical machine includes:
and when each virtual machine is started, a preset management program on the physical machine is adopted to create a second mapping relation of each virtual machine on the peripheral of the physical machine through a father driver.
Optionally, the method further comprises:
acquiring a virtual address of a second virtual machine by adopting the peripheral equipment of the physical machine;
determining a client physical address of the second virtual machine according to the virtual address of the second virtual machine and a first mapping relation of the second virtual machine in the first address conversion table by adopting the peripheral of the physical machine;
and determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation of the second virtual machine in the second address conversion table by adopting the peripheral of the physical machine, so as to perform service processing on the peripheral of the physical machine based on the host physical address of the second virtual machine.
Optionally, the determining the host physical address of the second virtual machine according to the guest physical address of the second virtual machine and the second mapping relationship of the second virtual machine in the second address translation table includes:
If the conversion function of the client physical address of the second virtual machine is started, determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation;
the method further comprises the steps of:
and if the conversion function is not started by the client physical address of the second virtual machine, adopting the peripheral equipment of the physical machine to perform service processing according to the client physical address of the second virtual machine.
In a second aspect, an embodiment of the present invention further provides an address translation apparatus applied to a physical machine, where at least one virtual device is created in advance on the physical machine, and each virtual device has a corresponding virtual machine, where the apparatus includes:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a first mapping relation between a virtual address of a first virtual machine and a physical address of a client machine by adopting the first virtual machine;
the issuing module is used for issuing a first mapping relation of the first virtual machine to the peripheral equipment of the physical machine by adopting the first virtual machine;
the adding module is used for adding the first mapping relation of the first virtual machine to a first address conversion table by adopting the peripheral equipment of the physical machine, so that the first address conversion table has the first mapping relation of at least one virtual machine, wherein the first mapping relation of each virtual machine is used for carrying out address conversion by combining the peripheral equipment of the physical machine with the second mapping relation of the client physical address and the host physical address of each virtual machine in a second address conversion table.
Optionally, the acquiring module is specifically configured to acquire, from a system kernel of the physical machine, a physical address of a client corresponding to the virtual address of the first virtual machine according to the virtual address of the first virtual machine; and obtaining a first mapping relation of the first virtual machine according to the virtual address of the first virtual machine and the client physical address corresponding to the virtual address of the first virtual machine.
Optionally, the acquiring module is specifically configured to acquire, according to the virtual address of the first virtual machine, a physical address of a client corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine by using a device driver on the first virtual machine;
the issuing module is configured to issue a first mapping relationship of the first virtual machine to a peripheral of the physical machine by using a device driver on the first virtual machine.
Optionally, the apparatus further includes:
and the creation module is used for creating a second mapping relation of each virtual machine on the peripheral of the physical machine when each virtual machine is started, so as to obtain the second address conversion table.
Optionally, the creating module is specifically configured to, when each virtual machine is started, create, by using a preset hypervisor on the physical machine, a second mapping relationship of each virtual machine on a peripheral of the physical machine through a parent driver.
Optionally, the apparatus further includes:
the first acquisition module is used for acquiring a virtual address of the second virtual machine by adopting the peripheral equipment of the physical machine;
the determining module is used for determining the physical address of the client of the second virtual machine according to the virtual address of the second virtual machine and the first mapping relation of the second virtual machine in the first address conversion table by adopting the peripheral of the physical machine; and determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation of the second virtual machine in the second address conversion table by adopting the peripheral of the physical machine, so as to perform service processing on the peripheral of the physical machine based on the host physical address of the second virtual machine.
Optionally, the determining module is specifically configured to determine, if the conversion function is started by the guest physical address of the second virtual machine, a host physical address of the second virtual machine according to the guest physical address of the second virtual machine and the second mapping relationship;
the apparatus further comprises:
and the processing module is used for carrying out service processing according to the physical address of the client of the second virtual machine by adopting the peripheral of the physical machine if the physical address of the client of the second virtual machine does not start the conversion function.
In a third aspect, an embodiment of the present invention further provides a physical machine, including: a memory storing a computer program executable by the processor, and a processor implementing the address translation method of any one of the first aspects above when the processor executes the computer program.
In a fourth aspect, an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, where the computer program is read and executed to implement the address translation method according to any one of the first aspects.
The beneficial effects of the invention are as follows: the embodiment of the invention provides an address conversion method, which comprises the following steps: acquiring a first mapping relation between a virtual address of a first virtual machine and a physical address of a client by adopting the first virtual machine; adopting a first virtual machine to send a first mapping relation of the first virtual machine to the external device of the physical machine; and adding the first mapping relation of the first virtual machine to the first address conversion table by adopting the peripheral of the physical machine, so that the first mapping relation of at least one virtual machine is arranged in the first address conversion table, wherein the first mapping relation of each virtual machine is used for enabling the peripheral of the physical machine to perform address conversion in combination with the second mapping relation of the client physical address and the host physical address of each virtual machine in the second address conversion table. The method comprises the steps that a first mapping relation of a first virtual machine is issued to a peripheral of a physical machine by the aid of the first virtual machine, the first mapping relation of the first virtual machine is added to a first address conversion table by the peripheral of the physical machine, address conversion can be carried out by the peripheral of the physical machine based on the first address conversion table and a preset second address conversion table, operation of the virtual machine is not required to be suspended in the whole process, and therefore normal operation of the virtual machine can be guaranteed.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings that are needed in the embodiments will be briefly described below, it being understood that the following drawings only illustrate some embodiments of the present invention and therefore should not be considered as limiting the scope, and other related drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a system architecture on which an address translation method according to an embodiment of the present application is based;
fig. 2 is a flow chart of an address translation method according to an embodiment of the present invention;
FIG. 3 is a flowchart illustrating another address translation method according to an embodiment of the present invention;
FIG. 4 is a flowchart illustrating another address translation method according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of an address translation device according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of a physical machine according to an embodiment of the present invention.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention.
Thus, the following detailed description of the embodiments of the present application, as provided in the accompanying drawings, is not intended to limit the scope of the application, as claimed, but is merely representative of selected embodiments of the application. All other embodiments, which can be made by one of ordinary skill in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In the description of the present application, it should be noted that, if the terms "upper", "lower", and the like indicate an azimuth or a positional relationship based on the azimuth or the positional relationship shown in the drawings, or an azimuth or the positional relationship that is commonly put when the product of the application is used, it is merely for convenience of description and simplification of the description, and does not indicate or imply that the apparatus or element to be referred to must have a specific azimuth, be configured and operated in a specific azimuth, and therefore should not be construed as limiting the present application.
Furthermore, the terms first, second and the like in the description and in the claims and in the above-described figures, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that the embodiments of the invention described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be noted that, without conflict, features in embodiments of the present application may be combined with each other.
The embodiment of the application provides an address conversion method, which is applied to a physical machine, wherein at least one virtual device is pre-established on the physical machine, each virtual device is provided with a corresponding virtual machine, the number of the virtual machines corresponding to each virtual device can be one, and the virtual devices can support the operation of the virtual machines.
Fig. 1 is a schematic diagram of a system architecture based on which an address translation method according to an embodiment of the present application is provided, as shown in fig. 1, where the system architecture includes: the system comprises a peripheral of a physical machine, a preset management program and a virtual machine, wherein the preset management program and the virtual machine run on the physical machine, and the peripheral of the physical machine is connected with the physical machine.
Wherein, the peripheral hardware of physical machine includes: the processing module and the MMU (Memory Management Unit, memory management module) can be a block-a module for processing issued tasks; the processing module and the MMU are hardware modules, and the peripheral of the physical machine is a hardware unit.
In addition, the preset hypervisor may be a hypervisor (an intermediate software layer running between a physical server and an operating system, which may allow multiple operating systems and applications to share a set of underlying physical hardware); the preset management program is deployed with a parent driver and an MDEV (media device, which is a kernel module and provides a basic framework of software virtualization)/VFIO (Virtual Function I/O, which is a user-state driving framework through which a user can expose the resources of the device to the user space and then pass the device to the virtual machine or realize the user-state driving technology by himself).
In the embodiment of the application, the MDEV/VFIO technology is adopted, so that at least one virtual device can be created, and as shown in fig. 1, the virtual device can comprise: VDEV-0 and VDEV-1, wherein the virtual device may also be referred to as a VDEV (virtual device). By way of example, as shown in FIG. 1, a virtual machine may include: VM1 and VM2, wherein the Virtual machines may also be referred to as VMs (Virtual machines). Each virtual interior is deployed with a DEV driver (device driver).
It should be noted that, only the virtual address of the memory can be seen in the virtual machine, so as to determine the physical address of the client corresponding to the virtual address, and the physical address of the host of the memory cannot be obtained by adopting the physical address of the client.
An address translation method provided in the embodiments of the present application is explained below.
Fig. 2 is a flow chart of an address translation method according to an embodiment of the present invention, as shown in fig. 2, the method may include:
s101, acquiring a first mapping relation between a virtual address of a first virtual machine and a physical address of a client by adopting the first virtual machine.
In some embodiments, the application layer determines a virtual address of the first virtual machine in response to a business operation input by a user; and acquiring a virtual address of the first virtual machine by adopting the first virtual machine, determining a client physical address corresponding to the virtual address of the first virtual machine according to the virtual address of the first virtual machine, and obtaining a first mapping relation between the virtual address of the first virtual machine and the client physical address.
It should be noted that, at least one virtual machine may be deployed on the physical machine, and the first virtual machine may be any virtual machine in the at least one virtual machine, which is not specifically limited in the embodiment of the present application.
S102, issuing a first mapping relation of the first virtual machine to the external device of the physical machine by adopting the first virtual machine.
The method comprises the steps that a first mapping relation of a first virtual machine is issued to an external device of a physical machine by the aid of the first virtual machine, and the external device of the physical machine can acquire the first mapping relation of the first virtual machine. The first mapping relation is stored in a memory of a peripheral of the physical machine.
In addition, the first mapping relationship of the first virtual machine refers to a mapping relationship between a virtual address in the first virtual machine and a guest physical address.
In this embodiment of the present application, the peripheral device of the physical machine may be a graphics card, or may be a network card, or may be other external devices of the physical machine, which is not specifically limited in this embodiment of the present application.
S103, adding the first mapping relation of the first virtual machine to the first address conversion table by adopting the peripheral equipment of the physical machine, so that the first address conversion table has the first mapping relation of at least one virtual machine.
The first mapping relation of each virtual machine is used for enabling the peripheral equipment of the physical machine to perform address conversion in combination with the second mapping relation of the client physical address and the host physical address of each virtual machine in the second address conversion table. The second mapping relation is stored in the internal memory of the peripheral of the physical machine.
In this embodiment of the present application, a first address conversion table is preset in a peripheral of a physical machine, and a first mapping relationship of a first virtual machine is added to the first address conversion table by using the peripheral of the physical machine, where the first address conversion table may further include: a first mapping relationship of other virtual machines; the peripheral equipment of the physical machine is preset with a second address conversion table, and the second address conversion table comprises a second mapping relation between the client machine physical address and the host machine physical address of each virtual machine.
In practical application, the peripheral of the physical machine may convert the virtual address from any one of the at least one virtual machine based on the first mapping relationship of each virtual machine and the second mapping relationship of each virtual machine, to obtain a corresponding host physical address.
In addition, the first address conversion table may include: the number of the first mapping relationships of the first virtual machine in S101 to S104 in the embodiment of the present application is not specifically limited. As shown in fig. 1, a memory range in a virtual machine VM0 may be 0G to 2G, and there may be a plurality of guest physical addresses in the range of 0G to 2G, where each guest physical address has a corresponding virtual address, so as to form a plurality of first mappings of VM 0.
In summary, an embodiment of the present invention provides an address translation method, including: acquiring a first mapping relation between a virtual address of a first virtual machine and a physical address of a client by adopting the first virtual machine; adopting a first virtual machine to send a first mapping relation of the first virtual machine to the external device of the physical machine; and adding the first mapping relation of the first virtual machine to the first address conversion table by adopting the peripheral of the physical machine, so that the first mapping relation of at least one virtual machine is arranged in the first address conversion table, wherein the first mapping relation of each virtual machine is used for enabling the peripheral of the physical machine to perform address conversion in combination with the second mapping relation of the client physical address and the host physical address of each virtual machine in the second address conversion table. The method comprises the steps that a first mapping relation of a first virtual machine is issued to a peripheral of a physical machine by the aid of the first virtual machine, the first mapping relation of the first virtual machine is added to a first address conversion table by the peripheral of the physical machine, address conversion can be carried out by the peripheral of the physical machine based on the first address conversion table and a preset second address conversion table, the virtual machine does not need to be withdrawn in the whole process, and normal operation of the virtual machine can be ensured.
In addition, in the related art, as soon as a new correspondence between the virtual address and the physical address of the client exists, the father driver in the hypervisor is required to intercept and sink into the hypervisor to determine the host physical address corresponding to the physical address of the client, so that the frequent sink into the hypervisor can influence the overall performance of the virtual machine, the father driver is not required to intercept in the application, the realization process is simpler and more convenient, the realization is realized on the peripheral equipment of the virtual machine and the physical machine, the frequent sink into the hypervisor is not required, and the overall performance of the virtual machine is improved.
Optionally, fig. 3 is a flowchart of another address translation method according to an embodiment of the present invention, as shown in fig. 3, a process for obtaining a first mapping relationship between a virtual address of a first virtual machine and a physical address of a client in the above S101 may include:
s201, according to the virtual address of the first virtual machine, a client physical address corresponding to the virtual address of the first virtual machine is obtained from a system kernel of the physical machine.
S202, obtaining a first mapping relation of the first virtual machine according to the virtual address of the first virtual machine and the client physical address corresponding to the virtual address of the first virtual machine.
In some embodiments, the application layer determines a virtual address of the first virtual machine in response to a business operation input by a user; and acquiring the virtual address by using the first virtual machine, determining a client physical address corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine according to the virtual address of the first virtual machine, and then recording the virtual address of the first virtual machine and the client physical address corresponding to the virtual address of the first virtual machine to obtain a first mapping relation of the first virtual machine.
Optionally, the process of obtaining, in S201, the physical address of the client corresponding to the virtual address of the first virtual machine from the system kernel of the physical machine according to the virtual address of the first virtual machine may include:
according to the virtual address of the first virtual machine, a device driver on the first virtual machine is adopted, and a client machine physical address corresponding to the virtual address of the first virtual machine is obtained from a system kernel of the physical machine;
the device driver, namely the DEV-driver, is independently deployed on each virtual machine in the at least one virtual machine. The first virtual machine acts as one of the at least one virtual machine, and a device driver is also deployed on the first virtual machine.
It is worth to describe that, the device driver on the first virtual machine can accurately and efficiently obtain the client machine physical address corresponding to the virtual address of the first virtual machine from the system kernel of the physical machine.
The step of issuing the first mapping relationship of the first virtual machine to the external device of the physical machine by using the first virtual machine in S102 may include:
and adopting the device driver on the first virtual machine to send the first mapping relation of the first virtual machine to the external device of the physical machine.
The device driver on the first virtual machine is adopted, so that the first mapping relation of the first virtual machine can be efficiently and reliably issued to the peripheral of the physical machine.
Optionally, the method further comprises:
and when each virtual machine is started, creating a second mapping relation of each virtual machine on the peripheral of the physical machine, and obtaining a second address conversion table.
In this embodiment of the present application, at least one virtual machine may be started at the same time, or may be started at different times, if a virtual machine is started, a second mapping relationship of the virtual machine is created on a peripheral of a physical machine, the second mapping relationship of the virtual machine is added to a second address translation table, and after each virtual machine and each virtual machine are started, the second address translation table may include the second mapping relationship of each virtual machine.
It should be noted that after the second mapping relationship of a virtual machine is configured in the peripheral device of the physical machine, the conversion function of the physical address of the client of the virtual machine may be started.
Optionally, when each virtual machine is started, creating a second mapping relationship of each virtual machine on a peripheral of the physical machine, including:
when each virtual machine is started, a preset management program on the physical machine is adopted to create a second mapping relation of each virtual machine on the peripheral of the physical machine through a father driver.
As shown in fig. 1, a preset management program is deployed on a physical machine, the preset management program includes a parent driver, a second mapping relation of each virtual machine is created on a peripheral of the physical machine by adopting the parent driver, and the second mapping relation of each virtual machine is added to a second address conversion table.
It should be noted that, only when each virtual machine is started, the father driver is adopted to create the second mapping relation of each virtual machine on the peripheral of the physical machine, the father driver on the preset management software is not required to be called in the follow-up process, and even if the follow-up first virtual machine needs to issue the first mapping relation of the newly added different virtual addresses and the client physical addresses for many times, the father driver on the preset management software is not required to participate, that is, the father driver is not required to be called frequently, so that the overall performance of the virtual machine is improved.
Optionally, fig. 4 is a schematic flow chart of another address translation method according to an embodiment of the present invention, as shown in fig. 4, where the method may further include:
s301, obtaining a virtual address of a second virtual machine by adopting the peripheral equipment of the physical machine.
The second virtual machine may be any one of at least one virtual machine, which is not specifically limited in the embodiments of the present application.
In practical applications, the first address translation table and the second address translation table may be deployed in an MMU module in a peripheral of the physical machine.
In some embodiments, the method includes that the second virtual machine sends a virtual address of the second virtual machine to an external device of the physical machine, the peripheral device of the physical machine obtains the virtual address of the second virtual machine through the processing module, the processing module sends the virtual address of the second virtual machine to an MMU module in the peripheral device of the physical machine, the MMU module obtains the virtual address of the second virtual machine, and the MMU module may include: a first address translation table and a second address translation table.
S302, adopting the peripheral equipment of the physical machine, and determining the physical address of the client of the second virtual machine according to the virtual address of the second virtual machine and the first mapping relation of the second virtual machine in the first address conversion table.
In some embodiments, a physical address of a client corresponding to a virtual address of the second virtual machine is determined from the first mapping relationship of the second virtual machine according to the virtual address of the second virtual machine and the first mapping relationship of the second virtual machine.
In the embodiment of the present application, the guest physical address may be referred to as GPA (Guest Physical Address ), the host physical address may be referred to as HPA (Host Physical Address, guest physical address), and the Virtual address may be referred to as VA (Virtual address).
For example, the virtual address of the second virtual machine may be VA1, and the first mapping relationship of the second virtual machine may include: VA1: gpa=1g, va2: gpa=2g, according to VA1 and the plurality of first mapping relationships of the second virtual machine, a first mapping relationship corresponding to the virtual address VA1 of the second virtual machine may be determined, and according to the first mapping relationship corresponding to the virtual address VA1 of the second virtual machine, that is, VA1: gpa=1g, and then determines that the physical address of the client corresponding to VA1 is gpa=1g.
S303, adopting the peripheral equipment of the physical machine, and determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation of the second virtual machine in the second address conversion table so as to perform service processing on the peripheral equipment of the physical machine based on the host physical address of the second virtual machine.
Wherein, the host physical address of the second virtual machine can be determined from the second mapping relation of the second virtual machine according to the client physical address of the second virtual machine.
For example, the virtual address of the second virtual machine may be gpa=1g, and the second mapping of the second virtual machine may include: gpa=1g: hpa=9g, gpa=2g: hpa=10g, then according to gpa=1g and the second mapping relationship of the second virtual machine, it may be determined that the host physical address corresponding to the guest physical address gpa=1g of the second virtual machine may be hpa=10g.
As shown in fig. 1, the memory range in the virtual machine VM0 may be 0G to 2G, and there are multiple guest physical addresses in the range of 0G to 2G; the memory range in the VM0 may be 0G to 2G, where there are multiple guest physical addresses in the range of 0G to 2G, where the guest physical addresses of 0G to 2G in the VM0 correspond to host physical addresses of 4G to 6G, the guest physical addresses of 0G to 2G in the VM0 correspond to host physical addresses of 8G to 10G, and the guest physical address in the VM1 is 1G, i.e., gpa=1g, and the determined hpa=9g according to the first address conversion table and the second address conversion table.
In this embodiment of the present application, each virtual machine in at least one virtual machine has a plurality of processes, and for a plurality of processes of the same virtual machine, a first mapping relationship of the virtual machine and a second mapping relationship of the virtual machine may be bound.
In some embodiments, a peripheral of a physical machine is adopted to obtain a virtual address and a process identifier of a second virtual machine, a first mapping relation of the second virtual machine is determined from a first address conversion table according to the process identifier, and then a physical address of a client of the second virtual machine is determined based on the virtual address of the second virtual machine and the first mapping relation of the second virtual machine in the first address conversion table; and determining a second mapping relation of the second virtual machine from the second address conversion table according to the process identification, and then determining a host physical address of the second virtual machine based on the client physical address of the second virtual machine and the second mapping relation of the second virtual machine in the second address conversion table.
Optionally, the determining the host physical address of the second virtual machine in S303 according to the client physical address of the second virtual machine and the second mapping relationship of the second virtual machine in the second address translation table may include:
if the client physical address of the second virtual machine has started the conversion function, determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation;
Wherein, whether to start the conversion function of the client physical address can be flexibly configured for each virtual machine.
Optionally, the method further comprises:
and if the client physical address of the second virtual machine does not start the conversion function, adopting the peripheral equipment of the physical machine to perform service processing according to the client physical address of the second virtual machine.
In some embodiments, an MMU module in a peripheral of the physical machine is used to determine whether the translation function is turned on by the guest physical address of the second virtual machine, and if the translation function is turned on by the guest physical address of the second virtual machine, the MMU module translates the GPA of the second virtual machine into an HPA according to the second mapping relationship, and can access the system memory through the HPA of the second virtual machine.
If the MMU module determines that the translation function is not started for the client physical address of the second virtual machine, adopting the MMU module to carry out no subsequent processing for the client physical address of the second virtual machine, and carrying out service processing according to the client physical address of the second virtual machine.
In summary, the embodiment of the present application provides an address translation method, in which a first mapping relationship of a first virtual machine is issued to a peripheral of a physical machine by using the first virtual machine, the peripheral of the physical machine adds the first mapping relationship of the first virtual machine to a first address translation table, and the peripheral of the physical machine can implement VA to GPA conversion based on the first address translation table, and can implement GPA to HPA conversion based on a preset second address translation table, so that the whole process does not need to exit the virtual machine, and normal operation of the virtual machine can be ensured; the second address translation table is introduced into the peripheral of the physical machine, so that an MMU module in the peripheral of the physical machine automatically completes the translation process from GPA to HPA, the number of times of virtual machine exit is effectively reduced, the overall performance of the system is improved, a father driver does not need to carry out complex page table tracking and replacing processes, and the software complexity is reduced; because the peripheral of the physical machine is provided with the mapping from GPA to HPA, the dependence on the IOMMU (Input/Output Memory Management Unit ) is reduced, and the interaction between the equipment and the virtual machine can be easily realized in a system without the IOMMU.
The following describes an address conversion device, a physical machine, a storage medium, etc. for executing the address conversion method provided in the present application, and specific implementation processes and technical effects thereof refer to relevant contents of the address conversion method, which are not described in detail below.
Fig. 5 is a schematic structural diagram of an address translation device according to an embodiment of the present invention, where, as shown in fig. 5, the device is applied to a physical machine, where at least one virtual device is created in advance on the physical machine, and each virtual device has a corresponding virtual machine, and the device includes:
an obtaining module 101, configured to obtain a first mapping relationship between a virtual address of a first virtual machine and a physical address of a client by using the first virtual machine;
a transmitting module 102, configured to transmit, by using the first virtual machine, a first mapping relationship of the first virtual machine to a peripheral of the physical machine;
and the adding module 103 is configured to add the first mapping relation of the first virtual machine to a first address translation table by using the peripheral of the physical machine, so that the first address translation table has the first mapping relation of at least one virtual machine, where the first mapping relation of each virtual machine is used to enable the peripheral of the physical machine to perform address translation in combination with the second mapping relation of the client physical address and the host physical address of each virtual machine in a second address translation table.
Optionally, the obtaining module 101 is specifically configured to obtain, from a system kernel of the physical machine, a physical address of a client corresponding to the virtual address of the first virtual machine according to the virtual address of the first virtual machine; and obtaining a first mapping relation of the first virtual machine according to the virtual address of the first virtual machine and the client physical address corresponding to the virtual address of the first virtual machine.
Optionally, the obtaining module 101 is specifically configured to obtain, according to the virtual address of the first virtual machine, a physical address of a client corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine by using a device driver on the first virtual machine;
the issuing module 102 is configured to issue a first mapping relationship of the first virtual machine to a peripheral of the physical machine by using a device driver on the first virtual machine.
Optionally, the apparatus further includes:
and the creation module is used for creating a second mapping relation of each virtual machine on the peripheral of the physical machine when each virtual machine is started, so as to obtain the second address conversion table.
Optionally, the creating module is specifically configured to, when each virtual machine is started, create, by using a preset hypervisor on the physical machine, a second mapping relationship of each virtual machine on a peripheral of the physical machine through a parent driver.
Optionally, the apparatus further includes:
the first acquisition module is used for acquiring a virtual address of the second virtual machine by adopting the peripheral equipment of the physical machine;
the determining module is used for determining the physical address of the client of the second virtual machine according to the virtual address of the second virtual machine and the first mapping relation of the second virtual machine in the first address conversion table by adopting the peripheral of the physical machine; and determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation of the second virtual machine in the second address conversion table by adopting the peripheral of the physical machine, so as to perform service processing on the peripheral of the physical machine based on the host physical address of the second virtual machine.
Optionally, the determining module is specifically configured to determine, if the conversion function is started by the guest physical address of the second virtual machine, a host physical address of the second virtual machine according to the guest physical address of the second virtual machine and the second mapping relationship;
the apparatus further comprises:
and the processing module is used for carrying out service processing according to the physical address of the client of the second virtual machine by adopting the peripheral of the physical machine if the physical address of the client of the second virtual machine does not start the conversion function.
The foregoing apparatus is used for executing the method provided in the foregoing embodiment, and its implementation principle and technical effects are similar, and are not described herein again.
The above modules may be one or more integrated circuits configured to implement the above methods, for example: one or more application specific integrated circuits (Application Specific Integrated Circuit, abbreviated as ASIC), or one or more microprocessors (digital singnal processor, abbreviated as DSP), or one or more field programmable gate arrays (Field Programmable Gate Array, abbreviated as FPGA), or the like. For another example, when a module above is implemented in the form of a processing element scheduler code, the processing element may be a general-purpose processor, such as a central processing unit (Central Processing Unit, CPU) or other processor that may invoke the program code. For another example, the modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
Fig. 6 is a schematic structural diagram of a physical machine according to an embodiment of the present invention, as shown in fig. 6, where the physical machine includes: processor 201, memory 202.
The memory 202 is used for storing a program, and the processor 201 calls the program stored in the memory 202 to execute the above-described method embodiment. The specific implementation manner and the technical effect are similar, and are not repeated here.
Optionally, the present invention also provides a program product, such as a computer readable storage medium, comprising a program for performing the above-described method embodiments when being executed by a processor.
In the several embodiments provided by the present invention, it should be understood that the disclosed apparatus and method may be implemented in other manners. For example, the apparatus embodiments described above are merely illustrative, e.g., the division of the units is merely a logical function division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in hardware plus software functional units.
The integrated units implemented in the form of software functional units described above may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium, and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) or a processor (english: processor) to perform some of the steps of the methods according to the embodiments of the invention. And the aforementioned storage medium includes: u disk, mobile hard disk, read-Only Memory (ROM), random access Memory (Random Access Memory, RAM), magnetic disk or optical disk, etc.
The above is only a preferred embodiment of the present invention, and is not intended to limit the present invention, but various modifications and variations can be made to the present invention by those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1. An address translation method, applied to a physical machine, where at least one virtual device is created in advance on the physical machine, and each virtual device has a corresponding virtual machine, the method comprising:
a first virtual machine is adopted, and a first mapping relation between a virtual address of the first virtual machine and a physical address of a client is obtained;
issuing a first mapping relation of the first virtual machine to the peripheral equipment of the physical machine by adopting the first virtual machine;
and adding the first mapping relation of the first virtual machine to a first address conversion table by adopting the peripheral of the physical machine, so that the first mapping relation of at least one virtual machine is arranged in the first address conversion table, wherein the first mapping relation of each virtual machine is used for carrying out address conversion by combining the peripheral of the physical machine with the second mapping relation of the client physical address and the host physical address of each virtual machine in a second address conversion table.
2. The method of claim 1, wherein the obtaining a first mapping relationship between the virtual address of the first virtual machine and the physical address of the client comprises:
according to the virtual address of the first virtual machine, acquiring a client machine physical address corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine;
And obtaining a first mapping relation of the first virtual machine according to the virtual address of the first virtual machine and the client physical address corresponding to the virtual address of the first virtual machine.
3. The method according to claim 2, wherein the obtaining, from the system kernel of the physical machine, the guest physical address corresponding to the virtual address of the first virtual machine according to the virtual address of the first virtual machine includes:
according to the virtual address of the first virtual machine, a device driver on the first virtual machine is adopted to acquire a client machine physical address corresponding to the virtual address of the first virtual machine from a system kernel of the physical machine;
the issuing, by the first virtual machine, the first mapping relationship of the first virtual machine to the peripheral device of the physical machine includes:
and adopting the device driver on the first virtual machine to issue a first mapping relation of the first virtual machine to the peripheral equipment of the physical machine.
4. The method according to claim 1, wherein the method further comprises:
and when each virtual machine is started, creating a second mapping relation of each virtual machine on the peripheral of the physical machine, and obtaining the second address conversion table.
5. The method of claim 4, wherein creating a second mapping relationship for each virtual machine on the peripheral device of the physical machine at the time of the start-up of each virtual machine comprises:
and when each virtual machine is started, a preset management program on the physical machine is adopted to create a second mapping relation of each virtual machine on the peripheral of the physical machine through a father driver.
6. The method according to claim 1, wherein the method further comprises:
acquiring a virtual address of a second virtual machine by adopting the peripheral equipment of the physical machine;
determining a client physical address of the second virtual machine according to the virtual address of the second virtual machine and a first mapping relation of the second virtual machine in the first address conversion table by adopting the peripheral of the physical machine;
and determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation of the second virtual machine in the second address conversion table by adopting the peripheral of the physical machine, so as to perform service processing on the peripheral of the physical machine based on the host physical address of the second virtual machine.
7. The method of claim 6, wherein determining the host physical address of the second virtual machine based on the guest physical address of the second virtual machine and a second mapping of the second virtual machine in the second address translation table comprises:
if the conversion function of the client physical address of the second virtual machine is started, determining the host physical address of the second virtual machine according to the client physical address of the second virtual machine and the second mapping relation;
the method further comprises the steps of:
and if the conversion function is not started by the client physical address of the second virtual machine, adopting the peripheral equipment of the physical machine to perform service processing according to the client physical address of the second virtual machine.
8. An address translation apparatus for application to a physical machine on which at least one virtual device is pre-created, each virtual device having a corresponding virtual machine, the apparatus comprising:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a first mapping relation between a virtual address of a first virtual machine and a physical address of a client machine by adopting the first virtual machine;
the issuing module is used for issuing a first mapping relation of the first virtual machine to the peripheral equipment of the physical machine by adopting the first virtual machine;
The adding module is used for adding the first mapping relation of the first virtual machine to a first address conversion table by adopting the peripheral equipment of the physical machine, so that the first address conversion table has the first mapping relation of at least one virtual machine, wherein the first mapping relation of each virtual machine is used for carrying out address conversion by combining the peripheral equipment of the physical machine with the second mapping relation of the client physical address and the host physical address of each virtual machine in a second address conversion table.
9. A physical machine, comprising: a memory storing a computer program executable by the processor, and a processor implementing the address translation method of any of the preceding claims 1-7 when the computer program is executed by the processor.
10. A computer readable storage medium, characterized in that the storage medium has stored thereon a computer program which, when read and executed, implements the address translation method of any of the preceding claims 1-7.
CN202311707210.XA 2023-12-12 2023-12-12 Address translation method, address translation device, physical machine and storage medium Pending CN117896346A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311707210.XA CN117896346A (en) 2023-12-12 2023-12-12 Address translation method, address translation device, physical machine and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311707210.XA CN117896346A (en) 2023-12-12 2023-12-12 Address translation method, address translation device, physical machine and storage medium

Publications (1)

Publication Number Publication Date
CN117896346A true CN117896346A (en) 2024-04-16

Family

ID=90646526

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311707210.XA Pending CN117896346A (en) 2023-12-12 2023-12-12 Address translation method, address translation device, physical machine and storage medium

Country Status (1)

Country Link
CN (1) CN117896346A (en)

Similar Documents

Publication Publication Date Title
US7421533B2 (en) Method to manage memory in a platform with virtual machines
US10025615B2 (en) Dynamic guest virtual machine identifier allocation
US8966477B2 (en) Combined virtual graphics device
US20110167422A1 (en) Virtualization apparatus
US20120054740A1 (en) Techniques For Selectively Enabling Or Disabling Virtual Devices In Virtual Environments
EP1628215A2 (en) Systems and methods for running a legacy 32-bit X86 virtual machine on a 64-bit X86 processor
JP2013515983A (en) Method and apparatus for performing I / O processing in a virtual environment
US10318460B2 (en) UMA-aware root bus selection
US10620963B2 (en) Providing fallback drivers for IO devices in a computing system
US9354896B1 (en) Hypervisor utilization to reduce bootstrap time for data storage system
US20120311572A1 (en) Method and apparatus for implementing virtual proxy to support heterogenous systems management
US9164788B2 (en) Apparatus and method for automatic para-virtualization of OS kernel
US20170277632A1 (en) Virtual computer system control method and virtual computer system
WO2017112126A1 (en) Starting application processors of a virtual machine
US10146569B2 (en) Template based software scans
KR101077908B1 (en) Apparatus for server virtualization
CN110383255B (en) Method and computing device for managing client partition access to physical devices
US11074114B1 (en) System and method for executing applications in a non-native environment
CN117896346A (en) Address translation method, address translation device, physical machine and storage medium
US10140218B2 (en) Non-uniform memory access support in a virtual environment
CN112989326A (en) Instruction sending method and device
CN102622245A (en) Virtual machine automatic-starting control method under sun4v architecture
CN114461290A (en) Data processing method, example and system
CN116361033B (en) Communication method, electronic device, and storage medium
KR20100122431A (en) Sharing input/output(i/o) resources across multiple computing systems and/or environments

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination