[go: up one dir, main page]

CN115858422A - Page table processing method, electronic device and storage medium - Google Patents

Page table processing method, electronic device and storage medium Download PDF

Info

Publication number
CN115858422A
CN115858422A CN202211677714.7A CN202211677714A CN115858422A CN 115858422 A CN115858422 A CN 115858422A CN 202211677714 A CN202211677714 A CN 202211677714A CN 115858422 A CN115858422 A CN 115858422A
Authority
CN
China
Prior art keywords
target
page
virtual
physical
peripheral
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
CN202211677714.7A
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.)
Alibaba China Co Ltd
Alibaba Cloud Computing Ltd
Original Assignee
Alibaba China Co Ltd
Alibaba Cloud Computing 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 Alibaba China Co Ltd, Alibaba Cloud Computing Ltd filed Critical Alibaba China Co Ltd
Priority to CN202211677714.7A priority Critical patent/CN115858422A/en
Publication of CN115858422A publication Critical patent/CN115858422A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Memory System Of A Hierarchy Structure (AREA)

Abstract

The application provides a page table processing method, an electronic device and a storage medium, wherein the method comprises the following steps: the operating system determines to allocate a target virtual peripheral virtualized on the physical peripheral to a target virtual machine, and obtains a plurality of existing state flag values currently contained in a page table corresponding to the target virtual machine, where the plurality of existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not; and sending the plurality of existing state flag values and the identifier of the target virtual machine to a physical peripheral device so that the physical peripheral device stores the plurality of existing state flag values in a target storage space corresponding to the target identifier. The operating system sends the flag value indicating whether the physical memory page frame exists in the page table corresponding to the target virtual machine to the corresponding peripheral equipment, so that the peripheral equipment can sense the page missing state of the virtual memory page, and the access to the page missing memory can be avoided.

Description

Page table processing method, electronic device and storage medium
Technical Field
The present invention relates to the field of internet technologies, and in particular, to a page table processing method, an electronic device, and a storage medium.
Background
In an electronic device including an IO Memory Management Unit (i.e., IOMMU), when an IO peripheral (generally referred to as a peripheral, i.e., an external device) connected to the IOMMU performs read/write operations on a Memory, in order to improve a data transmission rate and reduce a load of a CPU core, a Direct Memory Access (DMA) technique may be used to transfer data transmission between the peripheral and the Memory to a DMA controller, so that the peripheral directly accesses the Memory in a DMA manner independent of an operating system, which is generally referred to as an IO device pass-through technique. Briefly, the IO device pass-through technology is a way to present a physical Peripheral to a virtual machine, and generally, a device supporting Peripheral Component Interconnect (PCI) standard is passed through to the virtual machine, allowing the virtual machine to directly access the physical device.
The IOMMU simply translates a virtual memory address accessed by the peripheral device into a physical memory address, that is, maps a virtual memory page (page) accessed by the peripheral device to a corresponding physical page frame (page frame). Specifically, the IOMMU obtains an Address translation relationship from a Virtual Address (VA) to a Physical Address (PA) accessed by the peripheral device by traversing a page table based on a DMA mapping (DMA remapping) function. In a virtualization scenario, the virtual memory Address is also generally denoted as (GPA), and the Physical memory Address is generally denoted as (hard Physical Address/Host Physical Address, HPA).
In an IO-pass working scenario, because the IOMMU cannot interact with the memory management subsystem in the operating system in a state of a page missing in the memory, all virtual memory pages (i.e., virtual memory addresses) that may be accessed by the peripheral device cannot be in a page missing state, for example, after a virtual memory address accessed by the peripheral device at a certain time is queried by the IOMMU for a corresponding page table, it is found that a physical memory address corresponding to the virtual memory address is not allocated, and at this time, a serious result that is not easily overcome will be generated. To avoid such a page fault, currently, the operating system pre-allocates all virtual memory addresses that the peripheral device may access to with corresponding physical memory addresses and sets the virtual memory addresses as non-swappable, i.e. page locked (paged), but this reduces the resource utilization of the memory (memory).
Disclosure of Invention
Embodiments of the present invention provide a page table processing method, an electronic device, and a storage medium, so that an external device connected to a processing chip can sense in advance whether a virtual memory address to be accessed is in a page missing state, and avoid accessing a virtual memory address to which a corresponding physical memory address has not been allocated by an operating system.
In a first aspect, an embodiment of the present invention provides a page table processing method, which is applied to an operating system, and the method includes:
allocating the virtualized target virtual peripheral on the physical peripheral to a target virtual machine; the physical peripheral is connected with a memory management unit in the processor chip;
obtaining a plurality of existing state flag values currently included in a page table corresponding to the target virtual machine, where the plurality of existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not;
sending the plurality of existing state flag values and the target identifier to the physical peripheral equipment so that the physical peripheral equipment stores the plurality of existing state flag values into a target storage space corresponding to the target identifier; wherein the target identification comprises an identification of the target virtual machine and/or an identification of the target virtual peripheral.
In a second aspect, an embodiment of the present invention provides a page table processing apparatus, located in an operating system, including:
the determining module is used for allocating the virtualized target virtual peripheral on the physical peripheral to the target virtual machine; the physical peripheral is connected with a memory management unit in the processor chip;
an obtaining module, configured to obtain multiple existing status flag values currently included in a page table corresponding to the target virtual machine, where the multiple existing status flag values are used to indicate whether physical memory page frames corresponding to multiple virtual memory pages used by the target virtual machine exist or not;
a sending module, configured to send the presence status flag values and the target identifier to the physical peripheral device, so that the physical peripheral device stores the presence status flag values in a target storage space corresponding to the target identifier; wherein the target identification comprises an identification of the target virtual machine and/or an identification of the target virtual peripheral.
In a third aspect, an embodiment of the present invention provides a page table processing method, which is applied to a physical peripheral connected to a memory management unit in a processor chip, where a virtualized target virtual peripheral exists on the physical peripheral, and the method includes:
receiving a plurality of presence status flag values and a target identifier sent by an operating system after obtaining the plurality of presence status flag values currently included in a page table corresponding to a target virtual machine, where the target virtual peripheral is currently allocated to the target virtual machine by the operating system, the target identifier includes an identifier of the target virtual machine and/or an identifier of the target virtual peripheral, and the plurality of presence status flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist; wherein, a plurality of virtual memory addresses contained in each virtual memory page share a corresponding existing state flag value of the corresponding virtual memory page;
allocating a target storage space corresponding to the target identifier to store the plurality of presence status flag values in the target storage space.
In a fourth aspect, an embodiment of the present invention provides a page table processing apparatus, located in a physical peripheral connected to a memory management unit in a processor chip, where a virtualized target virtual peripheral exists on the physical peripheral, including:
a receiving module, configured to receive a plurality of presence status flag values and a target identifier that are sent by an operating system after obtaining the plurality of presence status flag values currently included in a page table corresponding to a target virtual machine, where the target virtual peripheral is currently allocated to the target virtual machine by the operating system, the target identifier includes an identifier of the target virtual machine and/or an identifier of the target virtual peripheral, and the plurality of presence status flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not; wherein, a plurality of virtual memory addresses contained in each virtual memory page share a corresponding existing state flag value of the corresponding virtual memory page;
and the storage module is used for allocating a target storage space corresponding to the target identification so as to store the plurality of existing state flag values into the target storage space.
In a fifth aspect, an embodiment of the present invention provides an electronic device, including:
the operating system comprises a memory management unit, a processing chip of a processor, a physical peripheral connected with the memory management unit and a memory; a virtualized target virtual peripheral exists on the physical peripheral, and a target virtual machine runs on the processor;
the operating system is configured to allocate the target virtual peripheral to a target virtual machine, and obtain a plurality of existing state flag values currently included in a page table corresponding to the target virtual machine, where the plurality of existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not; sending the presence status flag values and a target identifier to the physical peripheral, where the target identifier includes an identifier of the target virtual machine and/or an identifier of the target virtual peripheral, a page table corresponding to the target virtual machine is stored in the memory, and a plurality of virtual memory addresses included in each virtual memory page share a presence status flag value corresponding to a corresponding virtual memory page;
and the physical peripheral is used for distributing a target storage space corresponding to the target identification so as to store the plurality of existing state flag values into the target storage space.
In a sixth aspect, the present invention provides a non-transitory machine-readable storage medium, on which an executable code is stored, and when the executable code is executed by an operating system in an electronic device according to the fifth aspect, the operating system is caused to execute the processing method of the page table according to the first aspect; alternatively, when the executable code is executed by a physical peripheral in the electronic device according to the fifth aspect, the physical peripheral is caused to perform the processing method of the page table according to the third aspect.
In the solution provided in the embodiment of the present invention, taking a virtualization scenario as an example, when multiple virtual peripherals are obtained on a physical peripheral (an IO peripheral) through a virtualization technology, an operating system may allocate a target virtual peripheral to a target virtual machine for use, and independently maintain a page table corresponding to the target virtual machine for the target virtual machine, where the page table includes virtual memory pages that can be accessed by the target virtual machine, and each virtual memory page includes multiple virtual memory addresses. At the initial stage of starting up the target virtual machine, the operating system may load only a portion of data required for the target virtual machine to run into the memory from the disk, so that only a portion of virtual memory pages are allocated with corresponding physical memory page frames, and the remaining virtual memory pages are not allocated with corresponding physical memory page frames. At this time, the operating system obtains the existing state flag value of the physical memory page frame corresponding to each virtual memory page in the page table corresponding to the current target virtual machine. A page table entry in the page table includes a physical memory address field and an attribute field, where the attribute field includes a presence status (present) flag field, and for example, if the presence status flag field takes a value of 1, it indicates that a corresponding physical memory page frame exists, and if the presence status flag field takes a value of 0, it indicates that the corresponding physical memory page frame does not exist (i.e., is not yet allocated).
The operating system sends a plurality of existing state flag values and target identifiers obtained at this time to the physical peripheral, where the existing state flag values indicate whether physical memory page frames corresponding to virtual memory pages that can be accessed by the target virtual machine exist, and the target identifiers include identifiers of the target virtual machine and/or identifiers of the target virtual peripheral. And the physical peripheral allocates a target storage space corresponding to the target identification so as to store the plurality of existing state flag values into the target storage space. Therefore, by extending the present attribute corresponding to the physical memory page frame in the page table to the IO peripheral device, the IO peripheral device can sense the page missing state of the virtual memory page, so that DMA access to the virtual memory address in the page missing state can be avoided. And because the value of the one existing state flag is only 1bit, the hardware overhead is low. Moreover, the realization of the functions has no dependence on the IOMMU, does not need to modify and upgrade the IOMMU, and can be widely applied to the existing equipment.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
Fig. 1 is a schematic composition diagram of an electronic device according to an embodiment of the present invention;
FIG. 2 is a flowchart of a method for processing a page table according to an embodiment of the present invention;
FIG. 3 is a flowchart of a method for processing a page table according to an embodiment of the present invention;
fig. 4 is a schematic application diagram of a process for allocating physical memory addresses according to an embodiment of the present invention;
fig. 5 is a schematic application diagram of a release process of a physical memory address according to an embodiment of the present invention;
FIG. 6 is a schematic diagram illustrating an application of a page table processing method according to an embodiment of the present invention;
FIG. 7 is a flowchart of a method for processing a page table according to an embodiment of the present invention;
FIG. 8 is a flowchart of a method for processing a page table according to an embodiment of the present invention;
FIG. 9 is a flowchart of a method for processing a page table according to an embodiment of the present invention;
FIG. 10 is a flowchart of a method for processing a page table according to an embodiment of the present invention;
FIG. 11 is a block diagram of a page table processing apparatus according to an embodiment of the present invention;
fig. 12 is a schematic diagram of a processing apparatus of a page table according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In addition, the sequence of steps in each method embodiment described below is only an example and is not strictly limited.
A brief description will be given of some technical terms involved in the embodiments of the present invention.
The IOMMU: an Input/Output Memory Management Unit is used for realizing address conversion from a virtual Memory address accessed by a peripheral to a physical Memory address.
MMU: a Memory Management Unit, a general Memory Management Unit, is a Memory Management Unit used by a CPU core when performing Memory access, and is used to complete the conversion from a virtual Memory address to a physical Memory address accessed by the CPU core.
Peripheral equipment: the external device is connected to the IOMMU for short, so as to access the memory through the IOMMU. The embodiment of the invention relates to a physical peripheral and a virtual peripheral, wherein the physical peripheral is a hardware entity such as a physical network card, and the virtual peripheral is a plurality of virtual peripherals virtualized from the physical peripheral by a certain virtualization technology. Generally, a Physical peripheral may be referred to as a Physical Function (PF), a Virtual peripheral may be referred to as a Virtual Function (VF), and a Virtualization technology may be, for example, SR-IOV (Single Root I/O Virtualization) technology. A plurality of virtual peripherals virtualized from a physical peripheral can be respectively allocated to different virtual machines for use.
Root port: a Root Port, an interface provided by a processing chip (such as a CPU chip) to connect a peripheral, is located in a Root node (Root Complex). Some bus protocol is generally supported, such as PCI (Peripheral Component Interconnect) protocol, and IO peripherals connected through a PCI bus may also be referred to as PCI peripherals.
Page table: a page table is maintained by an operating system for each process/Virtual Machine (VM) and is used for storing a mapping relationship between a Virtual memory address and a physical memory address. Physical memory addresses that different processes/virtual machines can access are isolated from each other, but different processes/virtual machines can access the same virtual memory address. Since the page tables of different processes/virtual machines are different, the physical memory addresses to which they translate are different even though different processes/virtual machines access the same virtual memory address.
Virtual memory page, physical memory page frame: visible to the process/virtual machine is a virtual address space of the memory, which may be divided into a plurality of fixed-size pages, called virtual memory pages. Accordingly, the physical address space of the memory is divided into page frames of the same size, called physical memory page frames. For example, a virtual memory page with a size of 4K includes 4096 virtual memory addresses, and similarly, a physical memory page frame with the same size also includes 4096 physical memory addresses.
A page fault in the memory: if a virtual memory page accessed by a CPU core or a peripheral device is addressed in a page table by an MMU or an IOMMU, and a corresponding physical memory page frame is not allocated, an exception of a memory page fault may be generated.
A DMA engine: the DMA read-write request is positioned in the physical peripheral equipment, can be shared by a plurality of virtual peripheral equipment virtualized from the physical peripheral equipment and is used for sending the DMA read-write request to the IOMMU.
At present, if a CPU core generates a Page fault exception when accessing a memory, the CPU core may switch to a kernel state and solve the Page fault exception through a related exception handling function provided in an operating system kernel, however, when the peripheral encounters a Page fault exception, the currently provided solution needs the peripheral to provide functions such as Address Translation Service (ATS) and Page query Interface (ATS), and needs an mmu to also provide a suitable function, which is high in hardware cost and has a strong dependence on the IOMMU.
The embodiment of the invention provides a solution with low cost and no dependence on an IOMMU (input/output unit), so that the peripheral can sense whether the virtual memory page is in a page fault state, and DMA (direct memory access) of the virtual memory page in the page fault state is avoided.
Fig. 1 is a schematic composition diagram of an electronic device according to an embodiment of the present invention, and as shown in fig. 1, the electronic device includes: operating system, processing chip, internal memory and physical peripheral equipment.
The processing chip is, for example, a CPU chip, and may include at least one processor, such as at least one CPU core, and a memory management unit, such as an MMU and an IOMMU illustrated in the figure. When the CPU core accesses the memory, the MMU may be used to convert the virtual memory address into the physical memory address, and when the physical peripheral accesses the memory, the IOMMU may be used to convert the virtual memory address into the physical memory address. Therefore, the physical peripheral may be connected to the IOMMU through a root port (not shown).
In practical applications, the electronic device may be a user terminal such as a PC, a notebook computer, or the like, or may be a server.
In practical applications, the physical peripheral devices may be, for example, a physical network card, a video card, some acceleration computing chips, and so on.
In this embodiment, a virtual scene is taken as an example for description. In a virtualization scenario, a plurality of virtual peripherals may be virtualized on the same physical peripheral, each virtual peripheral is used by a corresponding virtual machine, and since the use processes of the virtual peripherals allocated to the virtual machines are similar, in the embodiment of the present invention, only one target virtual machine is allocated to a target virtual peripheral as an example for explanation.
It can be understood that, after a plurality of virtual peripherals are virtualized based on the physical peripherals and a plurality of virtual machines are built, the operating system may allocate the virtual peripherals to the virtual machines for use, that is, the operating system may establish a correspondence between the virtual peripheral identifiers and the virtual machine identifiers. Additionally, it will be appreciated that virtual machines may be run by an assigned CPU core.
Moreover, for a target virtual machine, the operating system maintains a corresponding page table for the target virtual machine, and the page tables for different virtual machines are different, that is, each virtual machine is limited to a different physical address space (domain). Thus, the virtual machine identification may be equivalent to the domain identification.
In addition, in practical applications, there may be two page tables corresponding to the target virtual machine, one is a page table for use by the MMU and the other is a page table for use by the IOMMU, and the two page tables may be organized differently, but both store therein the mapping relationship between each virtual memory address and the physical memory address that can be used by the target virtual machine. And the page table corresponding to the target virtual machine is stored in the memory.
In fact, currently, memory is managed by using paging (paging) technology, and the memory can be divided into a virtual address space visible to a virtual machine or a process and a physical address space of hardware. The memory paging technique divides a virtual address space and a physical address space into pages (pages) and page frames (page frames) according to a fixed size (such as 4k, 2m), and ensures that the sizes of the pages and the page frames are the same. Thus, a virtual memory address in this context is an address contained in a virtual memory page, and a physical memory address is an address contained in a physical page frame.
For example, the virtual memory address range corresponding to a virtual memory page is: 0x123485000-0x123485FFF, where 0x123485123 is a virtual memory address included in the virtual memory page. Given the known page specification, a virtual memory page may be represented by a first virtual memory address in the virtual memory page.
Additionally, as shown in FIG. 1, a DMA engine may be run in a physical peripheral, which is shared by multiple virtual peripherals virtualized based on the physical peripheral.
Based on the electronic device composition architecture shown in fig. 1, how to implement the external device to sense whether the virtual memory address in the page table is in the page fault state is described below with reference to the following embodiments.
Fig. 2 is a flowchart of a method for processing a page table according to an embodiment of the present invention, where the method may be executed by an operating system, and as shown in fig. 2, the method includes the following steps:
201. and allocating the target virtual peripheral virtualized on the physical peripheral to the target virtual machine.
202. Obtaining a plurality of existing state flag values currently contained in a page table corresponding to a target virtual machine, where the plurality of existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not.
203. And sending the plurality of existence state flag values and the target identification to a physical peripheral so that the physical peripheral stores the plurality of existence state flag values into a target storage space corresponding to the target identification, wherein the target identification comprises an identification of the target virtual machine and/or an identification of the target virtual peripheral.
As described above, when the operating system allocates the target virtual peripheral virtualized from the physical peripheral to the target virtual machine, and starts the target virtual machine, the part of the relevant program that the target virtual machine needs to run is loaded to the memory from the disk, and the corresponding physical memory page frame is allocated, and the mapping relationship between the corresponding virtual memory page and the physical memory page frame is established in the page table corresponding to the target virtual machine.
At this time, the operating system may obtain a plurality of presence status flag values included in the current page table, where the presence status flag values respectively correspond to each virtual memory page used by the target virtual machine, so as to indicate whether a physical memory page frame corresponding to each virtual memory page exists at this time.
In fact, the page table is generally organized in a multi-level page table manner, and the information of the physical memory page frame corresponding to the virtual memory page is stored in the last-level page table. The page table comprises a plurality of page table entries, and each page table entry comprises two parts: a physical memory address field corresponding to the physical memory page frame and a plurality of attribute fields, wherein the plurality of attribute fields include a presence status (present) flag field indicating whether the corresponding physical memory page frame exists, when present =1, the corresponding physical memory page frame is present, and when present =0, the corresponding physical memory page frame is absent, that is, not yet allocated.
In the embodiment of the present invention, the value (0, 1) of the presence status flag field indicates whether a physical memory page frame corresponding to one virtual memory page exists. Since one virtual memory page includes a plurality of virtual memory addresses, and correspondingly, one physical memory page frame includes a plurality of physical memory addresses, the plurality of virtual memory addresses included in one virtual memory page share the existence status flag value corresponding to the corresponding virtual memory page, so that, if a corresponding physical memory page frame exists in one virtual memory page, it indicates that each virtual memory address in the virtual memory page has been allocated with a corresponding physical memory address.
Assuming that the virtual address space of the target virtual machine includes N virtual memory pages, the presence states of N physical memory page frames corresponding to the N virtual memory pages may be determined from the page table, i.e., N presence state flag values may be obtained. The N presence status flag values are sent to the physical peripheral. In practical application, the physical peripheral device is provided with an interface for interacting with the operating system, and the operating system sends the presence status flag value and the target identifier to the physical peripheral device through the interface.
In the embodiment of the present invention, the existing state flag value is represented by 1bit, that is, 1bit may be used to store the state flag information indicating whether the physical memory page frame corresponding to one virtual memory page exists, and the storage overhead is low.
Because the number of the virtual peripherals virtualized on the physical peripheral is often multiple, and different virtual peripherals are allocated to different virtual machines for use, in order to distinguish the use situations of different virtual machines on the corresponding virtual peripherals, for a target virtual machine, when an operating system sends a plurality of existing state flag values obtained from a page table to the physical peripheral, the operating system also needs to send corresponding target identifiers to the physical peripheral. The target identification may include a target virtual machine identification and/or a target virtual peripheral identification.
In an alternative embodiment, since the representation of the target virtual machine identifier and the target virtual peripheral identifier used in the operating system may not be suitable for the physical peripheral, a set conversion algorithm may be used to convert the target identifier into the representation of the identifier suitable for the physical peripheral. For example, a hash algorithm is used to convert a target identifier maintained in an operating system, and the converted target identifier is sent to the physical peripheral.
And the physical peripheral equipment allocates a target storage space corresponding to the target identification so as to store the received multiple existence state flag values into the target storage space.
In practical applications, a Static Random-Access Memory (SRAM) or other memories may be disposed in the physical peripheral, and a target storage space with a corresponding bit capacity, for example, a storage space with a size of N bits, is allocated in the memories according to the number of the received multiple presence status flag values to store the N presence status flag values. And in order to distinguish the target virtual machine/target virtual peripheral corresponding to the target storage space, establishing a corresponding relation between the target storage space and the target identifier.
Then, as the operating system loads the program that the target virtual machine needs to execute from the disk into the memory, a new physical memory page frame is allocated. On one hand, based on the allocation of a new physical memory page frame, the mapping relationship between the corresponding virtual memory page and the physical memory page frame is stored in the page table, and on the other hand, the operating system may synchronize the update condition of the existing state flag value indicating whether the physical memory page frame corresponding to the virtual memory page exists to the physical peripheral.
In an optional embodiment, the operating system may send all the presence status flag values included in the page table to the physical peripheral device synchronously when an update condition occurs in the page table, for example, when a presence status flag value corresponding to a certain physical memory page frame changes, so that the physical peripheral device replaces the presence status flag value stored in the target storage space before. Of course, the operating system may also send only the virtual memory address with the changed presence status flag value corresponding to the corresponding physical memory page frame and the target identifier to the physical peripheral device, so that the operating system updates only the corresponding presence status flag value in the target storage space. The following examples will be described in detail.
In the page table processing method provided in the above embodiment of the present invention, the operating system may extend the presence status flag value indicating whether the physical memory page frame corresponding to the virtual memory page exists in the page table into the physical peripheral device, so that the physical peripheral device can sense whether each virtual memory page in the current page table is in the page missing state (i.e., whether the corresponding physical memory page frame exists), and thus, for the virtual memory address in the page missing state, the DMA access is not triggered. The implementation of the scheme does not depend on hardware units such as an IOMMU (input/output memory unit), and the scheme can be widely applied to various existing devices, only needs to occupy a small amount of storage space in a physical peripheral, and is low in storage overhead.
Fig. 3 is a flowchart of a method for processing a page table according to an embodiment of the present invention, where the method may be executed by an operating system, as shown in fig. 3, where the method includes the following steps:
301. and allocating the target virtual peripheral virtualized on the physical peripheral to the target virtual machine.
302. Obtaining a plurality of existing state flag values currently contained in a page table corresponding to a target virtual machine, where the plurality of existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not.
303. And sending the plurality of existing state flag values, the page specification corresponding to the page table and the target identifier to a physical peripheral, so that the physical peripheral stores the plurality of existing state flag values into a target storage space corresponding to the target identifier and establishes a mapping relation between the page specification and the target storage space.
The target identification comprises identification of a target virtual machine and/or identification of a target virtual peripheral.
304. If it is determined that the first virtual memory page is allocated with the corresponding first physical memory page frame, a mapping relationship between the first virtual memory page and the first physical memory page frame is established in a page table, and a first notification message is sent to the physical peripheral, where the first notification message includes a first virtual memory address and a target identifier corresponding to the first virtual memory page, so that the physical peripheral determines a target storage space according to the target identifier, determines a first location index in the target storage space according to the first virtual memory address and the page specification, and updates a presence status flag value corresponding to the first location index to a first value, where the first value indicates that the first virtual memory page has the corresponding first physical memory page frame.
305. If the second physical memory page frame corresponding to the second virtual memory page is determined to be released, a second notification message is sent to the physical peripheral, the second notification message includes a second virtual memory address corresponding to the second virtual memory page and a target identifier, so that the physical peripheral determines a target storage space according to the target identifier and a second position index in the target storage space according to the second virtual memory address and the page specification, the existence state flag value corresponding to the second position index is updated to a second numerical value, and the page table is cleared of the mapping relationship between the second virtual memory page and the second physical memory page frame, and the second numerical value indicates that the second physical memory page frame corresponding to the second virtual memory page does not exist.
In this embodiment, optionally, the operating system may send the plurality of presence status flag values and the target identifier to the physical peripheral device, and may also send the page specification in the page table corresponding to the target virtual machine to the physical peripheral device. The page size is the page size, such as 4K,2M, and 1G.
In an actual application scenario, if the page specifications adopted by the page tables corresponding to all the virtual machines in the electronic device are configured to be uniform by default, and the physical peripheral device also knows the default configuration situation, the page specifications may not be sent to the physical peripheral device.
However, in some practical scenarios, there may be a situation of mixed page tables, i.e. the target virtual machine may use two different sizes of pages: such as 4K,2M, in this case, the page table corresponding to the target virtual machine may include a first page table corresponding to page specification 4K and a second page table corresponding to page specification 2M. Accordingly, the plurality of presence status flag values above includes a first set of presence status flag values obtained from the first page table and a second set of presence status flag values obtained from the second page table.
The two groups of presence status flag values may be stored in an array, that is, two independent sub-storage spaces are set in the target storage space, where the first sub-storage space is used to store an array corresponding to the first group of presence status flag values, and the second sub-storage space is used to store an array corresponding to the second group of presence status flag values.
In view of the existence of the mixed page table situation, when sending a plurality of presence status flag values obtained from a certain page table to a physical peripheral, the operating system simultaneously sends a page specification corresponding to the page table to the physical peripheral, so that the physical peripheral associates the page specification with a storage space storing the corresponding plurality of presence status flag values.
The reason why the physical peripheral device needs to distinguish the page specifications corresponding to different page tables is that the position index of the corresponding existing state flag value of a certain virtual memory address accessed by the target virtual machine in the target storage space needs to be determined based on the page specifications.
Specifically, assume that the page specification of the page table of the target virtual machine is only one, such as 2M. After an operating system initially sends all of a plurality of presence status flag values (for convenience of description, it is assumed that there are N presence status flag values, each of which is represented by 1bit, and the N presence status flag values are in one-to-one correspondence with N virtual memory addresses available to a target virtual machine), the page specification, and a target identifier to a physical peripheral, the physical peripheral allocates a corresponding target storage space, and creates an array with a size of N in the target storage space for storing the N presence status flag values, where a position index of the N presence status flag values in the target storage space may be a subscript index in the array: 1. 2, \ 8230;, N. And establishing the corresponding relation between the target storage space and the target mark and page specification.
Assuming N =10, the 10 presence status flag values stored in the array are assumed as follows: 01 11 00000 0.
Then, assuming that the operating system allocates a corresponding first physical memory page frame to a first virtual memory page of the N virtual memory pages (it is assumed that the first physical memory page frame is not allocated before), at this time, on one hand, the operating system updates a mapping relationship between the first virtual memory page and the first physical memory page frame to a page table corresponding to the target virtual machine (i.e., updates a mapping relationship between a plurality of virtual memory addresses included in the first virtual memory page and a plurality of physical memory addresses included in the first physical memory page frame to the page table), at this time, a value of a presence status flag bit corresponding to the first physical memory page frame in the page table changes from 0 to 1, and on the other hand, the change is synchronously notified to a physical peripheral device, that is, a first notification message indicating that the first virtual memory page frame corresponding to the first virtual memory page exists is sent to the physical peripheral device, and the first notification message includes the first virtual memory address corresponding to the first virtual memory page and the target identifier. As described above, the first virtual memory address corresponding to the first virtual memory page may be a first virtual memory address of a plurality of virtual memory addresses included in the first virtual memory page.
And the physical peripheral determines a corresponding target storage space according to the target identification. Then, according to the first virtual memory address and the page specification corresponding to the target storage space, a first location index corresponding to the presence status flag value corresponding to the first virtual memory page in the target storage space is determined, and the presence status flag value corresponding to the first location index is updated to a first value based on the first notification message, that is, the presence status flag value corresponding to the first location index is updated from 0 to 1.
The first location index is obtained by dividing the first virtual memory address by the page specification. For example, in a page table using a 2M page specification, the first virtual memory address is 0x200000, and the first location index calculation process is as follows: 0x200000/0x200000 (hexadecimal 2M representation), the first position index calculated is 1. The first presence state flag value is located among the 10 presence state flag values, and the original 0 is updated to 1. Thus, the current update result of the 10 presence status flag values is: 11 11 00000 0.
Similarly, assuming that the operating system determines to release a second physical memory page frame corresponding to a second virtual memory page of the N virtual memory pages, a second notification message indicating that the second physical memory page frame corresponding to the second virtual memory page is in an absent state is sent to the physical peripheral device, where the second notification message includes a second virtual memory address corresponding to the second virtual memory page and the target identifier. And after the physical peripheral determines the target storage space according to the target identifier, determining a second position index in the target storage space according to the second virtual memory address and the page specification corresponding to the target storage space, and updating the existing state flag value corresponding to the second position index from the original 1 to a second value 0.
The following is a simple example of the case where the page table corresponding to the target virtual machine adopts two different page specifications. Assuming that the first page table corresponding to the target virtual machine adopts a 4K page specification and the second page table adopts a 2M page specification, in the initial stage, the operating system stores K1 presence status flag values obtained from the first page table into the first array in the target storage space corresponding to the target virtual machine, and stores K2 presence status flag values obtained from the second page table into the second array in the target storage space corresponding to the target virtual machine. And stores two page specifications of 4K and 2M for the target memory space association. It is assumed here that the first page table includes K1 virtual memory addresses, and the second page table includes K2 virtual memory addresses.
Then, assuming that the operating system allocates a corresponding first physical memory page frame to the first virtual memory page, the first notification message may include the first virtual memory address and the target identifier. And the physical peripheral determines a corresponding target storage space according to the target identification and determines that the target storage space is associated with two page specifications of 4K and 2M. Then, the physical peripheral device may determine the location index a by using the first virtual memory address and the page specification 4K, and then determine the location index B by using the first virtual memory address and the page specification 2M. Assuming that the first virtual memory address corresponds to the first page table using the 4K page specification, the location index a is located in the first array, and the location index a is absent in the second array, so the value of the presence status flag at the location index a in the first array can be updated from 0 to 1. Similarly, the position index B is not located in the first array and the second array. Similarly, assuming that the first virtual memory address corresponds to the second page table using the 2M page specification, the location index B is not located in the first array, and the location index B is present in the second array, so the presence status flag value at the location index B in the second array can be updated from 0 to 1. Similarly, the position index a is not located in the first array and the second array.
Of course, in an optional embodiment, when the operating system sends the first notification message, the operating system may also carry a page specification corresponding to the first virtual memory address, so that the physical peripheral device may directly determine, based on the page specification, whether to search in the first array or the second array.
The process of allocating and releasing corresponding physical memory page frames for virtual memory pages by the operating system is outlined above. A specific embodiment of the physical memory page frame allocation and release process is illustrated below with reference to fig. 4 and 5, respectively.
Fig. 4 illustrates a process in which an operating system allocates a corresponding physical memory page frame to a virtual memory page in a virtual address space of a target virtual machine.
As shown in fig. 4, first, the operating system allocates one physical memory page frame Y. For example, after some data corresponding to the target virtual machine is loaded to the memory from the disk, a physical memory page frame for storing the data is determined, where the physical memory page frame includes a plurality of physical memory addresses. And then, the operating system acquires the page table lock so as to lock the page table corresponding to the target virtual machine. Then, a mapping relation between the virtual memory page X and the physical memory page frame Y is established in a page table a used by the CPU core through the MMU, and a mapping relation between the virtual memory page X and the physical memory page frame Y is established in a page table b used by the peripheral IOMMU.
Then, the operating system synchronously informs the physical peripheral equipment through an interface between the operating system and the physical peripheral equipment: the physical memory page frame Y corresponding to the virtual memory page X of the target virtual machine is in a present state. The physical peripheral sets the presence status flag value corresponding to the virtual memory page X to 1 in the target storage space corresponding to the target virtual machine. And then, the physical peripheral feeds back an operation success message to the operating system. The operating system releases the page table lock.
Fig. 5 illustrates a process of releasing (may also be referred to as destroying) a corresponding physical memory page frame of a virtual memory page in a virtual address space of a target virtual machine, where an operating system is the target virtual machine.
First, the operating system synchronously notifies the physical peripheral: and the physical memory page frame Y corresponding to the virtual memory page X of the target virtual machine is in an absent state. The physical peripheral determines whether a DMA request using a virtual memory address in the virtual memory page X exists currently, if so, the physical peripheral waits for the completion of the DMA request, and if not, the physical peripheral sets a flag value of an existence state corresponding to the virtual memory page X to 0 in a target storage space corresponding to a target virtual machine. And then, the physical peripheral feeds back an operation success message to the operating system. Then, the operating system acquires a page table lock, clears the mapping relationship between the virtual memory page X and the physical memory page frame Y in the page table a, and clears the mapping relationship between the virtual memory page X and the physical memory page frame Y in the page table b, and then releases the page table lock.
In order to more clearly and intuitively understand the interaction process between the operating system and the physical peripheral device in the embodiment of the present invention, an example is described in conjunction with fig. 6.
In fig. 6, it is assumed that a virtual machine a is running on a CPU core in the processing chip, and the virtual machine a is assigned with a virtual peripheral (not shown in the figure) virtualized from a physical peripheral. The virtual address space of the virtual machine a includes a plurality of virtual memory pages, such as memory page 1 — memory page N illustrated in the figure. In fig. 6, it is assumed that a physical memory page frame corresponding to a memory page 5 does not exist, so the corresponding presence status flag value =0, and a physical memory page frame corresponding to another memory page exists, so the corresponding presence status flag value =1.
In fig. 6, assuming that the identifier of the virtual machine a is denoted as id _ a, optionally, the operating system may perform hash (hash) calculation on the identifier to obtain a converted virtual machine identifier: dev-ASID. The operating system then sends this identification Dev-ASID, and the N presence flag values obtained from the page table corresponding to virtual machine a, to the physical peripheral.
The physical peripheral is allocated a target memory space and associated with it an identification Dev-ASID, in which target memory space N presence status flag values are stored.
Fig. 7 is a flowchart of a method for processing a page table according to an embodiment of the present invention, where the method is performed by a physical peripheral device as described above, and as shown in fig. 7, the method includes the following steps:
701. receiving a plurality of existing state flag values and a target identifier sent by an operating system after obtaining a plurality of existing state flag values currently contained in a page table corresponding to a target virtual machine, wherein the target virtual peripheral is currently allocated to the target virtual machine by the operating system, the target identifier includes an identifier of the target virtual machine and/or an identifier of the target virtual peripheral, and the plurality of existing state flag values are used for indicating whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not.
702. Allocating a target storage space corresponding to the target identifier to store the plurality of presence status flag values in the target storage space.
For the specific execution process of the physical peripheral in this embodiment, reference may be made to the relevant description in the foregoing embodiment, which is not described herein again.
Fig. 8 is a flowchart of a method for processing a page table according to an embodiment of the present invention, where the method is executed by a physical peripheral device as described above, and as shown in fig. 8, the method includes the following steps:
801. receiving a plurality of existing state flag values, a target identifier and a page specification corresponding to a page table, which are sent by an operating system after obtaining the plurality of existing state flag values currently contained in the page table corresponding to a target virtual machine, wherein the target virtual peripheral is currently allocated to the target virtual machine by the operating system, the target identifier includes an identifier of the target virtual machine, and the plurality of existing state flag values are used for indicating whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not.
802. Allocating a target storage space corresponding to the target identification, establishing a mapping relation between the page specification and the target storage space, and storing the plurality of existing state flag values into the target storage space.
803. Receiving a first notification message sent by an operating system, where the first notification message includes a first virtual memory address and a target identifier corresponding to a first virtual memory page, and the operating system sends the first notification message when determining that a corresponding first physical memory page frame is allocated to the first virtual memory page.
804. Determining a target storage space according to the target identifier, determining a first position index in the target storage space according to the first virtual memory address and the page specification, and updating a presence status flag value corresponding to the first position index to a first numerical value indicating that the first virtual memory page has a corresponding first physical memory page frame.
805. And receiving a second notification message sent by the operating system, wherein the second notification message includes a second virtual memory address corresponding to a second virtual memory page and a target identifier, and the operating system sends the second notification message when determining to release a second physical memory page frame corresponding to the second virtual memory page.
806. And determining a target storage space according to the target identifier, determining a second position index in the target storage space according to the second virtual memory address and the page specification, and updating a presence state flag value corresponding to the second position index to a second numerical value, wherein the second numerical value indicates that a second physical memory page frame corresponding to the second virtual memory page does not exist.
For the specific execution process of the physical peripheral in this embodiment, reference may be made to the relevant description in the foregoing embodiment, which is not described herein again.
Fig. 9 is a flowchart of a method for processing a page table according to an embodiment of the present invention, where the method is performed by a physical peripheral device as described above, and as shown in fig. 9, the method includes the following steps:
901. and receiving a memory read-write request triggered by the target virtual peripheral through a memory access engine, wherein the memory read-write request comprises the target identifier and a third virtual memory address.
902. And determining a target storage space according to the target identifier, and determining a third position index in the target storage space according to the third virtual memory address and the page specification.
903. If the existence status flag value corresponding to the third location index indicates that the third virtual memory page to which the third virtual memory address belongs has the first numerical value of the corresponding third physical memory page frame, the memory read-write request is sent to the memory management unit, so that the memory management unit performs data read-write operation on the physical memory address corresponding to the third virtual memory address.
904. And if the existence state flag value corresponding to the third position index indicates that the third virtual memory page to which the third virtual memory address belongs does not have the second numerical value of the corresponding third physical memory page frame, sending an error prompt to the target virtual machine.
In this embodiment, a process of performing, by a physical peripheral device, DMA access to a memory based on a plurality of locally stored presence status flag values corresponding to a target virtual machine is described.
The memory access engine is a DMA engine illustrated in fig. 1, and the memory management unit is an IOMMU.
At a certain time, the target virtual machine sends a memory read-write instruction to the target virtual peripheral, wherein the memory read-write instruction comprises a target identifier (such as a target virtual machine identifier) and a third virtual memory address, and the target virtual peripheral triggers a DMA read-write request to the DMA engine, wherein the DMA read-write request comprises the target identifier and the third virtual memory address.
And the DMA engine determines a corresponding target storage space according to the target identifier, and determines a third position index in the target storage space according to the page specification associated with the target storage space and a third virtual memory address. Such as rounding the quotient of the third virtual memory address divided by the page specification to determine a third location index. Checking whether the value of the presence status flag corresponding to the third location index is a first value (for example, 1) indicating that a third physical memory page frame corresponding to a third virtual memory page to which the third virtual memory address belongs exists, or a second value (for example, 0) indicating that the third physical memory page frame does not exist. If the value is the first value, the DMA read-write request is sent to the IOMMU, otherwise, error prompt information is fed back. And after receiving the DMA read-write request, the IOMMU inquires and determines a physical memory address corresponding to the third virtual memory address, and performs corresponding data read-write operation on the physical memory address.
Therefore, the DMA engine is improved in the physical peripheral, so that whether the physical memory address corresponding to the corresponding virtual memory address exists or not is judged before the DMA read-write request is sent, and the page fault memory can be prevented from being accessed.
The embodiments described above are page table processing methods implemented in a virtualization scenario. In fact, the page table processing method is not limited to be used in a virtualization scenario, but may also be used in a non-virtualization scenario, such as the embodiment shown in fig. 10.
Fig. 10 is a flowchart of a method for processing a page table according to an embodiment of the present invention, as shown in fig. 10, the method includes the following steps:
1001. the operating system obtains a plurality of existing state flag values currently contained in a page table corresponding to a target process, where the existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target process exist or not.
1002. And the operating system sends the plurality of existence state flag values and the process identification to the physical peripheral equipment so that the physical peripheral equipment stores the plurality of existence state flag values into a target storage space corresponding to the process identification, and the target process is used for controlling the physical peripheral equipment or the virtualized virtual peripheral equipment on the physical peripheral equipment.
1003. The physical peripheral receives a memory read-write request triggered by a target process through a memory access engine, wherein the memory read-write request comprises a process identifier and a target virtual memory address.
1004. And the physical peripheral determines a target storage space according to the process identifier and determines a target position index in the target storage space according to the target virtual memory address.
1005. If the existence state flag value corresponding to the target position index indicates that the virtual memory page to which the target virtual memory address belongs has a corresponding physical memory page frame, the physical peripheral sends the memory read-write request to the memory management unit so that the memory management unit performs data read-write operation on the target physical memory address corresponding to the target virtual memory address; and if the existing state flag value corresponding to the target position index indicates that the physical memory page frame does not exist, sending an error prompt.
In this embodiment, the target process may be a user process operating the physical peripheral or a virtual peripheral virtualized on the physical peripheral, and the operating system maintains a corresponding page table for each process. The process of accessing the memory by the target process is similar to that of the target virtual machine in the foregoing embodiment, and details are not described here.
The processing apparatus of the page table of one or more embodiments of the present invention will be described in detail below. Those skilled in the art will appreciate that these means can each be constructed using commercially available hardware components and configured through the steps taught in this scheme.
Fig. 11 is a schematic structural diagram of a page table processing apparatus according to an embodiment of the present invention, the apparatus being located in an operating system. As shown in fig. 11, the apparatus includes: the device comprises a determining module 11, an obtaining module 12 and a sending module 13.
A determining module 11, configured to allocate a target virtual peripheral virtualized on a physical peripheral to a target virtual machine; the physical peripheral is connected with a memory management unit in the processor chip.
An obtaining module 12, configured to obtain multiple existing state flag values currently included in a page table corresponding to the target virtual machine, where the multiple existing state flag values are used to indicate whether physical memory page frames corresponding to multiple virtual memory pages used by the target virtual machine exist or not.
A sending module 13, configured to send the presence status flag values and the target identifier to the physical peripheral device, so that the physical peripheral device stores the presence status flag values in a target storage space corresponding to the target identifier; wherein the target identification comprises an identification of the target virtual machine and/or an identification of the target virtual peripheral.
Optionally, the sending module 13 is further configured to: and sending the page specification corresponding to the page table to the physical peripheral equipment so that the physical peripheral equipment establishes the mapping relation between the page specification and the target storage space.
Optionally, the sending module 13 is further configured to: if it is determined that a corresponding first physical memory page frame is allocated to a first virtual memory page in the virtual memory pages, sending a first notification message to the physical peripheral, where the first notification message includes a first virtual memory address corresponding to the first virtual memory page and the target identifier, so that the physical peripheral determines the target storage space according to the target identifier and determines a first location index in the target storage space according to the first virtual memory address and the page specification, and updates a presence status flag value corresponding to the first location index to a first value, where the first value indicates that the first virtual memory page has the corresponding first physical memory page frame. The device further comprises: an update module, configured to establish a mapping relationship between the first virtual memory page and the first physical memory page frame in the page table.
Optionally, the sending module 13 is further configured to: if it is determined that a second physical memory page frame corresponding to a second virtual memory page in the plurality of virtual memory pages is released, a second notification message is sent to the physical peripheral, where the second notification message includes a second virtual memory address corresponding to the second virtual memory page and the target identifier, so that the physical peripheral determines the target storage space according to the target identifier and determines a second location index in the target storage space according to the second virtual memory address and the page specification, and updates an existence status flag value corresponding to the second location index to a second numerical value, where the second numerical value indicates that the second physical memory page frame corresponding to the second virtual memory page does not exist. The update module is further to: clearing the mapping relation between the second virtual memory page and the second physical memory page frame in the page table.
The apparatus shown in fig. 11 may perform the steps performed by the operating system in the foregoing embodiment, and the detailed performing process and technical effect refer to the description in the foregoing embodiment, which are not described herein again.
Fig. 12 is a schematic structural diagram of a page table processing apparatus according to an embodiment of the present invention, the apparatus is located in a physical peripheral connected to a memory management unit in a processor chip, and a virtualized target virtual peripheral exists on the physical peripheral, as shown in fig. 12, the apparatus includes: a receiving module 21 and a storage module 22.
A receiving module 21, configured to receive a plurality of presence status flag values and a target identifier that are sent by an operating system after obtaining a plurality of presence status flag values currently included in a page table corresponding to a target virtual machine, where the target virtual peripheral is currently allocated to the target virtual machine by the operating system, the target identifier includes an identifier of the target virtual machine and/or an identifier of the target virtual peripheral, and the plurality of presence status flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not; the virtual memory addresses included in each virtual memory page share the presence status flag value corresponding to the corresponding virtual memory page.
A storage module 22, configured to allocate a target storage space corresponding to the target identifier, so as to store the presence status flag values in the target storage space.
Optionally, the receiving module 21 is further configured to: and receiving a page specification corresponding to the page table sent by the operating system. The storage module 22 is further configured to: and establishing a mapping relation between the page specification and the target storage space.
Optionally, the receiving module 21 is further configured to: receiving a first notification message sent by the operating system, where the first notification message includes a first virtual memory address corresponding to a first virtual memory page and the target identifier; the operating system sends the first notification message when determining that the corresponding first physical memory page frame is allocated to the first virtual memory page. The storage module 22 is further configured to: determining the target storage space according to the target identifier, determining a first location index in the target storage space according to the first virtual memory address and the page specification, and updating a presence status flag value corresponding to the first location index to a first value, where the first value indicates that a first physical memory page frame corresponding to the first virtual memory page exists.
Optionally, the receiving module 21 is further configured to: receiving a second notification message sent by the operating system, where the second notification message includes a second virtual memory address corresponding to a second virtual memory page and the target identifier; and sending the second notification message when the operating system determines to release a second physical memory page frame corresponding to the second virtual memory page. The storage module 22 is further configured to: determining the target storage space according to the target identifier, determining a second location index in the target storage space according to the second virtual memory address and the page specification, and updating a presence status flag value corresponding to the second location index to a second numerical value, where the second numerical value indicates that the second virtual memory page does not have a corresponding second physical memory page frame.
Optionally, the apparatus further comprises: the access processing module is used for receiving a memory read-write request triggered by the target virtual peripheral through a memory access engine, wherein the memory read-write request comprises the target identifier and a third virtual memory address; determining the target storage space according to the target identification; determining a third position index in the target storage space according to the third virtual memory address and the page specification; if the existence status flag value corresponding to the third location index indicates that a third virtual memory page to which the third virtual memory address belongs has a first numerical value of a corresponding third physical memory page frame, sending the memory read-write request to the memory management unit, so that the memory management unit performs data read-write operation on a physical memory address corresponding to the third virtual memory address; and if the existence status flag value corresponding to the third location index indicates that the third virtual memory page to which the third virtual memory address belongs does not have the second numerical value of the corresponding third physical memory page frame, sending an error prompt.
The apparatus shown in fig. 12 may perform the steps performed by the physical peripheral in the foregoing embodiment, and the detailed performing process and technical effect refer to the description in the foregoing embodiment, which are not described herein again.
Embodiments of the present invention provide a non-transitory machine-readable storage medium having stored thereon executable code, which when executed by an operating system or a physical peripheral in an electronic device, causes the operating system or the physical peripheral to perform the steps in the corresponding page table processing method as provided in the foregoing embodiments.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (11)

1. A method for processing a page table, applied to an operating system, the method comprising:
allocating the virtualized target virtual peripheral on the physical peripheral to a target virtual machine; the physical peripheral is connected with a memory management unit in the processor chip;
obtaining a plurality of existing state flag values currently included in a page table corresponding to the target virtual machine, where the plurality of existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not;
sending the plurality of existing state flag values and the target identification to the physical peripheral device, so that the physical peripheral device stores the plurality of existing state flag values into a target storage space corresponding to the target identification; wherein the target identification comprises an identification of the target virtual machine and/or an identification of the target virtual peripheral.
2. The method of claim 1, further comprising:
and sending the page specification corresponding to the page table to the physical peripheral equipment so that the physical peripheral equipment establishes a mapping relation between the page specification and the target storage space.
3. The method of claim 2, further comprising:
if it is determined that a corresponding first physical memory page frame is allocated to a first virtual memory page of the plurality of virtual memory pages, sending a first notification message to the physical peripheral, where the first notification message includes a first virtual memory address corresponding to the first virtual memory page and the target identifier, so that the physical peripheral determines the target storage space according to the target identifier and determines a first location index in the target storage space according to the first virtual memory address and the page specification, and updates an existence status flag value corresponding to the first location index to a first value, where the first value indicates that the first virtual memory page has the corresponding first physical memory page frame;
establishing a mapping relationship between the first virtual memory page and the first physical memory page frame in the page table.
4. The method of claim 2, further comprising:
if it is determined that a second physical memory page frame corresponding to a second virtual memory page in the plurality of virtual memory pages is released, sending a second notification message to the physical peripheral, where the second notification message includes a second virtual memory address corresponding to the second virtual memory page and the target identifier, so that the physical peripheral determines the target storage space according to the target identifier and determines a second location index in the target storage space according to the second virtual memory address and the page specification, and updates a presence status flag value corresponding to the second location index to a second numerical value, where the second numerical value indicates that the second physical memory page frame corresponding to the second virtual memory page does not exist;
clearing the mapping relation between the second virtual memory page and the second physical memory page frame in the page table.
5. A method for processing a page table, applied to a physical peripheral device connected to a memory management unit in a processor chip, where a virtualized target virtual peripheral device exists on the physical peripheral device, the method comprising:
receiving a plurality of presence status flag values and a target identifier sent by an operating system after obtaining the plurality of presence status flag values currently included in a page table corresponding to a target virtual machine, where the target virtual peripheral is currently allocated to the target virtual machine by the operating system, the target identifier includes an identifier of the target virtual machine and/or an identifier of the target virtual peripheral, and the plurality of presence status flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist; wherein, a plurality of virtual memory addresses contained in each virtual memory page share a corresponding existence status flag value of the corresponding virtual memory page;
allocating a target storage space corresponding to the target identifier to store the plurality of presence status flag values in the target storage space.
6. The method of claim 5, further comprising:
receiving a page specification corresponding to the page table sent by the operating system;
and establishing a mapping relation between the page specification and the target storage space.
7. The method of claim 6, further comprising:
receiving a first notification message sent by the operating system, where the first notification message includes a first virtual memory address corresponding to a first virtual memory page and the target identifier; sending, by the operating system, the first notification message when determining that a corresponding first physical memory page frame is allocated to the first virtual memory page;
determining the target storage space according to the target identification;
determining a first position index in the target storage space according to the first virtual memory address and the page specification;
updating the existing state flag value corresponding to the first location index to a first value, where the first value indicates that the first virtual memory page has a corresponding first physical memory page frame.
8. The method of claim 6, further comprising:
receiving a second notification message sent by the operating system, where the second notification message includes a second virtual memory address corresponding to a second virtual memory page and the target identifier; the operating system sends the second notification message when determining to release a second physical memory page frame corresponding to the second virtual memory page;
determining the target storage space according to the target identification;
determining a second position index in the target storage space according to the second virtual memory address and the page specification;
and updating the existence status flag value corresponding to the second location index to a second numerical value, where the second numerical value indicates that the second virtual memory page does not have a corresponding second physical memory page frame.
9. The method of claim 6, further comprising:
receiving a memory read-write request triggered by the target virtual peripheral through a memory access engine, wherein the memory read-write request comprises the target identifier and a third virtual memory address;
determining the target storage space according to the target identification;
determining a third position index in the target storage space according to the third virtual memory address and the page specification;
if the existence status flag value corresponding to the third location index indicates that the third virtual memory page to which the third virtual memory address belongs has the first numerical value of the corresponding third physical memory page frame, sending the memory read-write request to the memory management unit, so that the memory management unit performs data read-write operation on the physical memory address corresponding to the third virtual memory address;
and if the existence status flag value corresponding to the third location index indicates that the third virtual memory page to which the third virtual memory address belongs does not have the second numerical value of the corresponding third physical memory page frame, sending an error prompt.
10. An electronic device, comprising:
the operating system comprises a memory management unit, a processing chip of a processor, a physical peripheral connected with the memory management unit and a memory;
a virtualized target virtual peripheral exists on the physical peripheral, and a target virtual machine runs on the processor;
the operating system is configured to allocate the target virtual peripheral to a target virtual machine, and obtain a plurality of existing state flag values currently included in a page table corresponding to the target virtual machine, where the plurality of existing state flag values are used to indicate whether physical memory page frames corresponding to a plurality of virtual memory pages used by the target virtual machine exist or not; sending the presence status flag values and a target identifier to the physical peripheral, where the target identifier includes an identifier of the target virtual machine and/or an identifier of the target virtual peripheral, a page table corresponding to the target virtual machine is stored in the memory, and a plurality of virtual memory addresses included in each virtual memory page share a presence status flag value corresponding to a corresponding virtual memory page;
and the physical peripheral is used for distributing a target storage space corresponding to the target identification so as to store the plurality of existing state flag values into the target storage space.
11. A non-transitory machine-readable storage medium having stored thereon executable code that, when executed by an operating system in an electronic device as claimed in claim 10, causes the operating system to perform a method of processing a page table as claimed in any one of claims 1 to 4, or that, when executed by a physical peripheral in an electronic device as claimed in claim 10, causes the physical peripheral to perform a method of processing a page table as claimed in any one of claims 5 to 9.
CN202211677714.7A 2022-12-26 2022-12-26 Page table processing method, electronic device and storage medium Pending CN115858422A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211677714.7A CN115858422A (en) 2022-12-26 2022-12-26 Page table processing method, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211677714.7A CN115858422A (en) 2022-12-26 2022-12-26 Page table processing method, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN115858422A true CN115858422A (en) 2023-03-28

Family

ID=85654896

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211677714.7A Pending CN115858422A (en) 2022-12-26 2022-12-26 Page table processing method, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN115858422A (en)

Similar Documents

Publication Publication Date Title
US11656779B2 (en) Computing system and method for sharing device memories of different computing devices
US10564997B2 (en) Computing system for securely executing a secure application in a rich execution environment
US7620766B1 (en) Transparent sharing of memory pages using content comparison
EP4407470A1 (en) Request processing method, apparatus and system
CN108351829B (en) System and method for input/output computing resource control
CN106445628A (en) Virtualization method, apparatus and system
US9584628B2 (en) Zero-copy data transmission system
CN105518631B (en) EMS memory management process, device and system and network-on-chip
US9146879B1 (en) Virtual memory management for real-time embedded devices
CN111966468A (en) Method, system, secure processor and storage medium for pass-through device
EP3163451B1 (en) Memory management method and device, and memory controller
US8862834B2 (en) Shared memory translation facility
CN116302491A (en) Memory management method, device, computer equipment and storage medium
CN116069689B (en) Page table access method, system, electronic component and page table configuration method
WO2023155694A1 (en) Memory paging method and system, and storage medium
CN102722452B (en) Memory redundancy eliminating method
US20240356886A1 (en) Network Node Configuration Method and Apparatus, and Access Request Processing Method and Apparatus
CA2816443A1 (en) Secure partitioning with shared input/output
CN115858422A (en) Page table processing method, electronic device and storage medium
CN115586943A (en) Hardware marking implementation method for dirty pages of virtual machine of intelligent network card
CN117851289B (en) Page table acquisition method, system, electronic component and electronic device
CN117851290B (en) Page table management method, system, electronic component and electronic device
CN113326213B (en) Method for realizing address mapping in driver under Feiteng server platform
WO2024082702A1 (en) Data processing method and apparatus, and chip and computer-readable storage medium
US9424227B2 (en) Providing byte enables for peer-to-peer data transfer within a computing environment

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