A method for jailhouse to realize SR-IOV virtual device discovery
By implementing the method of SR-IOV virtual device discovery in jailhouse, generating VF device resource tables and controlling PCIe configuration space access, the problem that jailhouse does not support SR-IOV virtual device isolation is solved, and the function of discovering VF devices through physical PCIe devices on a none root client is realized, which improves the efficiency of hardware resource utilization.
Patent Information
- Application Number
- CN202510169653.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-02-17
AI Technical Summary
The existing partition virtualization tool jailhouse does not support SR-IOV virtual device isolation, which limits the application of partition virtualization and cannot effectively utilize hardware resources.
By implementing SR-IOV virtual device discovery method in jailhouse, a VF device resource table associated with the PF device of the PCIe network card is generated, and the PCIe configuration space access of the none root client is controlled in the Hypervisor, so that VF devices are discovered through physical PCIe device discovery on the none root client.
Under the armv8 architecture, VF devices are discovered through physical PCIe device discovery method under the armv8 architecture, and then combined with msi-x interrupt transmission method, the SR-IOV virtual device transmission is realized, which improves the utilization efficiency of hardware resources.
Smart Images

Figure CN119621251B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to PCIe device virtualization, and in particular to a method for realizing SR-IOV virtual device discovery in a jailhouse, belonging to the technical field of virtual device discovery. Background Art
[0002] With the development of integrated circuit manufacturing technology, more and more computing units are integrated into a single chip. How to use the resources on a single chip more effectively to obtain good system scalability has become an important issue facing system software designers. Currently, deploying a virtual machine monitor (Hypervisor) on a multi-core system is an effective solution to this problem. The virtualization and isolation functions of the Hypervisor can enable multiple client operating systems to run on the same hardware platform. According to different client application requirements, different hardware resources can be configured for different clients to make more effective use of hardware resources.
[0003] Among them, PCIe devices are the most commonly used hardware devices on the hardware platform, such as network cards, graphics cards, etc., which are all connected to the hardware platform through the PCIe bus. SR-IOV (Single-Root I / O virtualization) is a standard launched by PCI-SIG, which defines a standard mechanism for PCIe device virtualization technology, which is used to virtualize a PCIe device into multiple PCIe devices. SR-IOV introduces two new function types: PF (Physical Function) and VF (Virtual Function). PF is a complete PCIe function, including the SR-IOV extension function, which is used to configure and manage the SR-IOV function; VF is a "lightweight" PCIe function that contains the resources required for data movement, but has a minimized set of configuration resources.
[0004] Currently, the partition virtualization tool jailhouse does not support SR-IOV virtual device isolation, which limits the application of partition virtualization and makes it impossible to use hardware resources more effectively. Summary of the invention
[0005] In view of the above problems, the present invention provides a method for realizing SR-IOV virtual device discovery in jailhouse, so as to use the partition virtualization tool jailhouse to realize VF device discovery of PCIe device supporting SR-IOV function through physical PCIe device discovery on none root client.
[0006] To achieve the above object, the technical solution of the present invention is:
[0007] A method for realizing SR-IOV virtual device discovery in a jailhouse, realizing partition virtualization through a jailhouse, isolating a host into two partitions, namely, a root client and a none root client, including the following steps:
[0008] Step S1: providing a new PCI device configuration data structure on the root client, and improving the device configuration of the PCIe device based on the new PCI device configuration data structure, and generating a VF device associated with the PF device of the PCIe network card;
[0009] Step S2: Map the host PCIe ECAM address space to the Hypervisor, so that the Hypervisor has the ability to access the PCIe ECAM address space;
[0010] Step S3: Add the sriov module in the Hypervisor to manage the VF devices generated in step S1;
[0011] Step S4: Provide the sriov module with a device resource table retrieval function and device configuration space access control. By retrieving the VF device resource table and device configuration space access control, the VF device can be discovered on the none root client through the physical PCIe device discovery method.
[0012] Furthermore, step S1 specifically includes the following steps:
[0013] Step S11: Add a device configuration for marking the PCIe device type in the PCI device configuration data structure of the root client, namely JAILHOUSE_PCI_TYPE_SRIOV, to identify a PCIe device that supports the SR-IOV function;
[0014] Step S12: Continue to add two variables vf_num and vf_id in the PCI device configuration data structure of the root client; vf_num is used to identify how many VF devices associated with the PF device of the PCIe network card are generated, and vf_id is used to identify the device serial number of the VF device associated with the PF device of the PCIe network card. The device serial number range of the VF device is 0-(vf_num - 1);
[0015] Step S13: based on the PCI device configuration data structure provided in steps S11 and S12, improve the device configuration of the PCIe device;
[0016] Step S14: In the jailhouse driver, the corresponding PCIe device is searched through the domain and bdf configured in the device, and the SR-IOV function of the PCIe device is enabled through the pci_enable_sriov() interface to generate vf_num VF devices.
[0017] Furthermore, step S3 specifically includes the following steps:
[0018] Step S31: the sriov module is initialized, and according to the device configuration in step S1, a VF device resource table associated with the PF device of the PCIe network card is created;
[0019] Step S32: judging whether the SR-IOV function is enabled according to the SR-IOV Control field; if not, returning a message indicating that the creation of the VF device resource table has failed.
[0020] Furthermore, the VF device resource table is a secondary table:
[0021] The first-level table displays the bdf number of the PF device associated with the VF device, and can be indexed by the bdf number of the PF device;
[0022] The secondary table displays the resource information of the VF device. The VF device resource table is created sequentially and can be indexed by the VF device serial number;
[0023] The resource information of the VF device displayed in the secondary table includes: Vendor ID, Device ID, and VF device bdf number.
[0024] Furthermore, the creation of the VF device resource table includes the following steps:
[0025] Step S31a: The Hypervisor accesses the PCIe device configuration space, that is, the configuration space of the PF device associated with the VF device, to obtain the configuration information shared by the VF device and the PF device and the SR-IOV extended configuration information;
[0026] The configuration information shared by the VF device and the PF device includes: Vendor ID, which is used to identify the device manufacturer;
[0027] The SR-IOV extended configuration information is defined in the SR-IOV Extended Capability of the PF device of the PCIe network card, including:
[0028] SR-IOV Control: This is the SR-IOV function control field, used to control the SR-IOV function enable;
[0029] NumVFs: This is the VF device number field, which is used to control the number of VF devices associated with the PF device.
[0030] VF Stride: VF device stride, used to define the routing ID offset of all VF devices associated with the PF device from one VF device to the next VF device;
[0031] First VF Offset: The offset of the first VF device, which is used to define the routing ID offset of the first VF device associated with the PF device;
[0032] VF Device: VF device identifier, used to identify this PCIe device as a VF device;
[0033] Step S31b: Create a VF device resource table according to the configuration information shared by the VF device and the PF device and the SR-IOV extended configuration information, wherein in the VF device resource table,
[0034] Vendor ID: the vendor ID of the PF device associated with the VF device;
[0035] Device ID: VF Device in the SR-IOV extended information of the PF device associated with the VF device. This ID is used for device driver matching.
[0036] The bdf number of the VF device is calculated using the following formula:
[0037] VF bdf = (PF bdf + First VF Offset + (VF serial number - 1) VF Stride)% 2^16.
[0038] Furthermore, step S4 specifically includes the following steps:
[0039] Step S41: Add a device configuration item for marking the PCIe device type, JAILHOUSE_PCI_TYPE_SRIOV, to the PCI device configuration data structure of the none root client. In the PCI device configuration data structure of the none root client, bdf represents the bdf number of the VF device associated with the PF device, and vf_id represents the device serial number of the VF device.
[0040] Step S42: when the Linux system of the none root client starts, the device configuration of the PCIe device is scanned on BUS 0, and the PCI device configuration space access is intercepted by simulating the MMIO mode in the Hypervisor; the bdf number of the device configuration of the PCIe device scanned on BUS 0 is associated with the device configuration in the none root client configuration;
[0041] Step S43: The PF device is retrieved in the primary table of the VF device resource table through the bdf number of the VF device associated with the PF device in the device configuration of the PCIe device of the none root client, and the corresponding secondary table is found through the primary table, and then the VF device sequence number of the PCI device configured by the none root client is retrieved, and the VF device resource information is obtained from the secondary table;
[0042] Step S44: Control access to the PCI device configuration space of the none root client Linux system according to the retrieved VF device resource information:
[0043] If the none root client wants to access the Vendor ID and Device ID fields in the PCI device configuration space, the sriov module directly returns the Vendor ID and Device ID fields of the retrieved VF device resources;
[0044] If the none root client accesses other fields in the PCI device configuration space, the bdf field in the accessed PCI device configuration space address is replaced with the bdf number of the VF device of the retrieved VF device resource, and then the configuration space of the VF device is accessed.
[0045] Furthermore, if multiple PCIe devices are configured, step S1 and step S3 are repeatedly executed.
[0046] The beneficial effects of the method for realizing SR-IOV virtual device discovery in a jailhouse of the present invention are as follows:
[0047] The present invention can realize the discovery of VF devices on a none root client through a physical PCIe device discovery method under an armv8 architecture by using a partition virtual machine tool jailhouse, and further, combined with an msi-x interrupt transparent transmission method, can realize SR-IOV virtual device transparent transmission.
[0048] The present invention creates a VF device resource table associated with a PCIe PF device in a Hypervisor to generate VF device information. By simulating an MMIO mode, the access to the PCIe configuration space of a none root client is controlled in the Hypervisor, and the none root client Linux scans the VF device configured to the client on BUS 0 through a PCIe device discovery mode, and indexes the VF device sequence number associated with the PF device in the VF device resource table to obtain the VF device resources, which are then converted into access to the VF device configuration space, thereby realizing the discovery of the VF device on the none root client through a physical PCIe device discovery mode. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0050] Figure 1 It is an overall structural framework diagram of the method for realizing SR-IOV virtual device discovery in jailhouse of the present invention;
[0051] Figure 2 It is the structural framework diagram of the sriov module of the present invention;
[0052] Figure 3 It is a PCI device configuration data structure diagram of the present invention;
[0053] Figure 4 It is a PCI device configuration diagram of the present invention. DETAILED DESCRIPTION
[0054] The technical scheme in the embodiment of the present invention is described clearly and completely below in conjunction with the accompanying drawings in the embodiment of the present invention. In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.
[0055] A method for realizing SR-IOV virtual device discovery in a jailhouse of the present invention, firstly, enables the SR-IOV function of a PCIe device on a host in a jailhouse driver, and generates n VF devices. In a hypervisor, a VF device resource table associated with a PF device of a PCIe network card is created, and VF device information is generated. By simulating an MMIO mode, the access to the PCI configuration space of a none root client is controlled in the hypervisor, and the none root client Linux is enabled to scan the VF device configured to the client on BUS 0 (bus) through a PCIe device discovery mode, and the VF device sequence number associated with the PF device is indexed in the VF device resource table to obtain the VF device resources, which are then converted into access to the VF device configuration space, thereby realizing the discovery of the VF device on the none root client through a physical PCIe device discovery mode. Example 1
[0056] A method for realizing SR-IOV virtual device discovery in jailhouse, the specific implementation of the present invention is based on armv8 hardware platform, external Intel i350 PCIe network card, Linux kernel version is 4.19. Through jailhouse, partition virtualization is realized, and the host is isolated into two partitions: root client and none root client. Both clients run Linux system, and finally the VF device of PCIe network card is discovered on none root client through physical PCIe device discovery method. Figure 1 and Figure 2 , the specific implementation is as follows, the PCIe device mentioned in the following steps refers to the PCIe network card:
[0057] Step S1: providing a new PCI device configuration data structure on the root client, and improving the device configuration of the PCIe device based on the new PCI device configuration data structure, and generating a VF device associated with the PF device of the PCIe network card; specifically comprising the following steps:
[0058] Step S11: Add a device configuration for marking the PCIe device type in the PCI device configuration data structure of the root client, namely JAILHOUSE_PCI_TYPE_SRIOV, to identify a PCIe device that supports the SR-IOV function;
[0059] Figure 1 In the example, the PF driver is the original PCIe network card driver, which is loaded when the host is started. After the hypervisor is started, the host becomes the root cell, and the PF in the root cell is the PF device of the PCIe network card. Figure 3 and Figure 4 The new PCI device configuration data structure provided by the present invention and the device configuration of a certain PCI device are respectively: the PCI device configuration is described by a data structure, in which a variable is used to identify the PCIe device type (such as Figure 3 "__u8type" in , and Figure 4 "type = JAILHOUSE_PCI_TYPE_SRIOV"), a new PCI device type is added here, and the following program performs special processing on the PCIe device corresponding to this PCI device type;
[0060] Step S12: Continue to add two variables vf_num and vf_id in the PCI device configuration data structure of the root client; vf_num is used to identify how many VF devices associated with the PF device of the PCIe network card are generated, and vf_id is used to identify the device serial number of the VF device associated with the PF device of the PCIe network card. The device serial number range of the VF device is 0-(vf_num - 1);
[0061] Step S13: based on the PCI device configuration data structure provided in steps S11 and S12, improve the device configuration of the PCIe device;
[0062] Step S14: In the jailhouse driver, the corresponding PCIe device is searched through the domain and bdf configured in the device, and the SR-IOV function of the PCIe device is enabled through the pci_enable_sriov() interface to generate vf_num VF devices; wherein, domain and bdf are both PCI-related concepts, which are the contents in the original data structure, and the PCI device (PCIe device is a type of PCI device, and is processed as a PCI device in Linux) searches for a complete interface provided by the Linux PCI driver;
[0063] Step S2: Map the host PCIe ECAM address space to the Hypervisor, so that the Hypervisor has the ability to access the PCIe ECAM address space;
[0064] Step S3: Add a sriov module in the Hypervisor to manage the VF devices generated in step S1; specifically, the following steps are included:
[0065] Step S31: the sriov module is initialized, and according to the device configuration in step S1, a VF device resource table associated with the PF device of the PCIe network card is created;
[0066] The VF device resource table is a secondary table:
[0067] The first-level table displays the bdf number of the PF device associated with the VF device and can be indexed by the bdf number of the PF device;
[0068] The secondary table displays the resource information of the VF device. The VF device resource table is created sequentially and can be indexed by the VF device serial number;
[0069] The table is as Figure 1 The VF device resource table shown in the figure; the resource information of the VF device displayed in the secondary table includes: VendorID, Device ID, VF device bdf number;
[0070] The creation of the VF device resource table includes the following steps:
[0071] Step S31a: The Hypervisor accesses the PCIe device configuration space, that is, the configuration space of the PF device associated with the VF device, to obtain the configuration information shared by the VF device and the PF device and the SR-IOV extended configuration information;
[0072] The configuration information shared by the VF device and the PF device includes: Vendor ID, which is used to identify the device manufacturer;
[0073] The SR-IOV extended configuration information is defined in the SR-IOV Extended Capability of the PF device of the PCIe network card, including:
[0074] SR-IOV Control: This is the SR-IOV function control field, used to control the SR-IOV function enable;
[0075] NumVFs: This is the VF device number field, which is used to control the number of VF devices associated with the PF device.
[0076] VF Stride: VF device stride, used to define the routing ID offset of all VF devices associated with the PF device from one VF device to the next VF device;
[0077] First VF Offset: The offset of the first VF device, which is used to define the routing ID offset of the first VF device associated with the PF device;
[0078] VF Device: VF device identifier, used to identify this PCIe device as a VF device;
[0079] Step S31b: Create a VF device resource table according to the configuration information shared by the VF device and the PF device and the SR-IOV extended configuration information, wherein in the VF device resource table,
[0080] Vendor ID: the vendor ID of the PF device associated with the VF device;
[0081] Device ID: VF Device in the SR-IOV extended information of the PF device associated with the VF device. This ID is used for device driver matching.
[0082] The bdf number of the VF device is calculated using the following formula:
[0083] VF bdf = (PF bdf + First VF Offset + (VF serial number - 1) VF Stride)% 2^16.
[0084] Step S32: judging whether the SR-IOV function is enabled according to the SR-IOV Control field; if not, returning a message indicating that the creation of the VF device resource table has failed.
[0085] This is a program robustness design. The driver module and the Hypervisor program are two parts. For example, if the driver fails to be enabled or the loaded driver is incorrect, the SR-IOV function will not be enabled. Adding a judgment here can prevent the Hypervisor program from abnormal.
[0086] Step S4: Provide the sriov module with a device resource table retrieval function and device configuration space access control. By retrieving the VF device resource table and device configuration space access control, the VF device is discovered on the none root client through the physical PCIe device discovery method, including the following steps:
[0087] Step S41: Add a device configuration item for marking the PCIe device type, JAILHOUSE_PCI_TYPE_SRIOV, to the PCI device configuration data structure of the none root client. In the PCI device configuration data structure of the none root client, bdf represents the bdf number of the VF device associated with the PF device, and vf_id represents the device serial number of the VF device.
[0088] Step S42: before the retrieval function is implemented, the following steps are also included: when the Linux system of the none root client is started, the device configuration of the PCIe device is scanned on BUS 0, and the PCI device configuration space access is intercepted by simulating MMIO in the Hypervisor; the bdf number of the device configuration of the PCIe device scanned on BUS 0 is associated with the device configuration in the none root client configuration;
[0089] Step S43: retrieve the PF device in the primary table of the VF device resource table through the bdf number of the VF device associated with the PF device in the device configuration of the PCIe device of the none root client, find the corresponding secondary table through the primary table, and then retrieve according to the VF device serial number of the PCI device configured by the none root client, and obtain the VF device resource information from the secondary table;
[0090] That is, the present invention retrieves the VF device resource through the VF device sequence number of the device configuration of the none root client PCIe device.
[0091] Step S44: Control access to the PCI device configuration space of the none root client Linux system according to the retrieved VF device resource information:
[0092] If the none root client wants to access the Vendor ID and Device ID fields in the PCI device configuration space, the sriov module directly returns the Vendor ID and Device ID fields of the retrieved VF device resources;
[0093] If the none root client accesses other fields in the PCI device configuration space, the bdf field in the accessed PCI device configuration space address is replaced with the bdf number of the VF device of the retrieved VF device resource, and then the configuration space of the VF device is accessed.
[0094] This enables the discovery of VF devices on the none root client through physical PCIe device discovery. Example 2
[0095] On the basis of Example 1, if multiple PCIe devices are configured, repeat step S1 and step S3; multiple PCIe devices refer to multiple PCIe network cards, each network card supports the generation of multiple vf devices, and steps S11 to S14 and step S3 are executed for each PCIe device. The other steps are the same as in Example 1.
[0096] In summary, the present invention creates a VF device resource table associated with a PCIe PF device in a Hypervisor and generates VF device information. By simulating the MMIO method, the access to the PCIe configuration space of the none root client is controlled in the Hypervisor, and the none root client Linux scans the VF device configured to the client on BUS 0 through the PCIe device discovery method, and indexes the VF device sequence number associated with the PF device in the VF device resource table to obtain the VF device resources, which are then converted into access to the VF device configuration space, thereby realizing the discovery of the VF device on the none root client through the physical PCIe device discovery method.
[0097] The present invention can realize the discovery of VF devices on a none root client through a physical PCIe device discovery method under an armv8 architecture by using a partition virtual machine tool jailhouse, and further, combined with an msi-x interrupt transparent transmission method, can realize SR-IOV virtual device transparent transmission.
[0098] Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
Claims
1. A method for realizing SR-IOV virtual device discovery in a jailhouse, realizing partition virtualization through a jailhouse, isolating a host into two partitions, namely, a root client and a none root client, characterized in that: The steps include: Step S1: providing a PCI device configuration data structure on the root client, and improving the device configuration of the PCIe device based on the PCI device configuration data structure, and generating a VF device associated with the PF device of the PCIe network card; Step S2: Map the host PCIe ECAM address space to the Hypervisor, so that the Hypervisor has the ability to access the PCIe ECAM address space; Step S3: Add the sriov module in the Hypervisor to manage the VF devices generated in step S1; Step S4: Provide the sriov module with a device resource table retrieval function and device configuration space access control, and realize the discovery of VF devices through the physical PCIe device discovery method on the none root client by retrieving the VF device resource table and the device configuration space access control; Step S1 includes the following steps: adding a device configuration for marking the PCIe device type in the PCI device configuration data structure of the root client; continuing to add two variables in the PCI device configuration data structure of the root client, respectively used to identify how many VF devices associated with the PF device of the PCIe network card are generated and the device serial number of the VF device; Step S4 includes the following steps: adding a device configuration item for marking the PCIe device type in the PCI device configuration data structure of the none root client.
2. The method for realizing SR-IOV virtual device discovery in a jailhouse according to claim 1, characterized in that: Step S1 specifically includes the following steps: Step S11: adding a device configuration for marking the PCIe device type in the PCI device configuration data structure of the root client, specifically JAILHOUSE_PCI_TYPE_SRIOV, for identifying a PCIe device that supports the SR-IOV function; the data structure includes a type field, an iommu field, a domain field, and a bdf field; Step S12: Continue to add two variables vf_num and vf_id in the PCI device configuration data structure of the root client; vf_num is used to identify how many VF devices associated with the PF device of the PCIe network card are generated, and vf_id is used to identify the device serial number of the VF device associated with the PF device of the PCIe network card. The device serial number range of the VF device is 0-(vf_num - 1); Step S13: based on the PCI device configuration data structure provided in steps S11 and S12, improve the device configuration of the PCIe device; Step S14: In the jailhouse driver, the corresponding PCIe device is searched through the domain and bdf configured in the device, and the SR-IOV function of the PCIe device is enabled through the pci_enable_sriov() interface to generate vf_num VF devices.
3. The method for realizing SR-IOV virtual device discovery in a jailhouse according to claim 2, characterized in that: Step S3 specifically includes the following steps: Step S31: the sriov module is initialized, and according to the device configuration in step S1, a VF device resource table associated with the PF device of the PCIe network card is created; Step S32: judging whether the SR-IOV function is enabled according to the SR-IOV Control field; if not, returning a message indicating that the creation of the VF device resource table has failed.
4. The method for realizing SR-IOV virtual device discovery in a jailhouse according to claim 3, characterized in that: The VF device resource table is a secondary table: The first-level table displays the bdf number of the PF device associated with the VF device, and can be indexed by the bdf number of the PF device; The secondary table displays the resource information of the VF device. The VF device resource table is created sequentially and can be indexed by the VF device serial number; The resource information of the VF device displayed in the secondary table includes: Vendor ID, Device ID, and VF device bdf number.
5. The method for realizing SR-IOV virtual device discovery in a jailhouse according to claim 4, characterized in that: The creation of the VF device resource table includes the following steps: Step S31a: The Hypervisor accesses the PCIe device configuration space, that is, the configuration space of the PF device associated with the VF device, to obtain the configuration information shared by the VF device and the PF device and the SR-IOV extended configuration information; The configuration information shared by the VF device and the PF device includes: Vendor ID, which is used to identify the device manufacturer; The SR-IOV extended configuration information is defined in the SR-IOV Extended Capability of the PF device of the PCIe network card, including: SR-IOV Control: This is the SR-IOV function control field, used to control the SR-IOV function enable; NumVFs: This is the VF device number field, which is used to control the number of VF devices associated with the PF device. VF Stride: VF device stride, used to define the routing ID offset of all VF devices associated with the PF device from one VF device to the next VF device; First VF Offset: The offset of the first VF device, which is used to define the routing ID offset of the first VF device associated with the PF device; VF Device: VF device identifier, used to identify this PCIe device as a VF device; Step S31b: Create a VF device resource table according to the configuration information shared by the VF device and the PF device and the SR-IOV extended configuration information, wherein in the VF device resource table, Vendor ID: the vendor ID of the PF device associated with the VF device; Device ID: VF Device in the SR-IOV extended information of the PF device associated with the VF device. This ID is used for device driver matching. The bdf number of the VF device is calculated using the following formula: VF bdf = (PF bdf + First VF Offset + (VF sequence number - 1) VF Stride) % 2^16.
6. The method for realizing SR-IOV virtual device discovery in a jailhouse according to claim 5, characterized in that: Step S4 specifically includes the following steps: Step S41: Add an item for marking the PCIe device type in the PCI device configuration data structure of the none root client, specifically JAILHOUSE_PCI_TYPE_SRIOV. In the PCI device configuration data structure of the none root client, bdf represents the bdf number of the VF device associated with the PF device, and vf_id represents the device serial number of the VF device. Step S42: when the Linux system of the none root client starts, the device configuration of the PCIe device is scanned on BUS 0, and the PCI device configuration space access is intercepted by simulating the MMIO mode in the Hypervisor; the bdf number of the device configuration of the PCIe device scanned on BUS 0 is associated with the device configuration in the none root client configuration; Step S43: The PF device is retrieved in the primary table of the VF device resource table through the bdf number of the VF device associated with the PF device in the device configuration of the PCIe device of the none root client, and the corresponding secondary table is found through the primary table, and then the VF device sequence number of the PCI device configured by the none root client is retrieved, and the VF device resource information is obtained from the secondary table; Step S44: Control access to the PCI device configuration space of the none root client Linux system according to the retrieved VF device resource information: If the none root client wants to access the Vendor ID and Device ID fields in the PCI device configuration space, the sriov module directly returns the Vendor ID and Device ID fields of the retrieved VF device resources; If the none root client accesses other fields in the PCI device configuration space, the bdf field in the accessed PCI device configuration space address is replaced with the bdf number of the VF device of the retrieved VF device resource, and then the configuration space of the VF device is accessed.
7. The method for realizing SR-IOV virtual device discovery in a jailhouse according to claim 1, characterized in that: If multiple PCIe devices are configured, step S1 and step S3 are repeated.
Citation Information
Patent Citations
GPU virtualization implementation method based on SR-IOV technology
CN115904617A
Method for virtual machine to simultaneously support PCIe virtual device and physical device
CN116737322A