A method for forwarding interrupts of a jailhouse isolated PCIe network card

CN117762840BActive Publication Date: 2026-08-21KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311421342.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-30
Publication Date
2026-08-21
Estimated Expiration
2043-10-30

AI Technical Summary

Technical Problem

[0005]为了克服上述缺陷,提出了本发明,以提供当jailhouse在AArch64架构上进行PCIe网卡设备的隔离时,无法完成MSIx中断转发注入的技术问题

Benefits of technology

[0042]在实施本发明的技术方案中,使用jailhouse添加MSICapturer模块、应用程序vfio_demo.c和用户态程序文件inject后隔离PCIe网卡设备,并在虚拟机操作系统nonrootlinux中加载标准的Intel I210PCIe网卡驱动程序,使PCIe网卡设备可以成功被虚拟机操作系统发现,并被其中的igb.ko初始化,经过MSICapturer模块对客户机中PCIe网卡的MSIx中断信息进行捕获,通过应用程序vfio_demo调用用户态程序文件inject将PCIe网卡的MSIx中断注入到虚拟机操作系统nonroot linux中,如此实现PCIe网卡设备的MSIx中断转发功能。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117762840B_ABST
    Figure CN117762840B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of computer, and specifically provides a method for forwarding the interrupt of jailhouse isolated PCIe network card, aiming at solving the technical problem that MSIx interrupt forwarding injection cannot be completed when jailhouse isolates PCIe network card device on AArch64 architecture. For this purpose, the present application comprises the following steps: obtaining jailhouse source code; adding MSICapturer module in the jailhouse source code, wherein the MSICapturer module is used for obtaining and saving the DeviceID, EventID, ICID and pINTID of the PCIe network card; adding application program vfio_demo.c in the jailhouse source code directory, wherein the application program vfio_demo.c is used for obtaining the EventID and DeviceID of the PCIe network card enabling MSIx interrupt and forwarding to the user state program file inject.c; adding the user state program file inject.c in the source code directory of jailhouse, wherein the user state program file inject.c is used for injecting the DeviceID and EventID of the PCIe network card to the MSICapturer module; saving and compiling the modified jailhouse source code, installing jailhouse; adding virtual machine operating system; copying the file igb.ko containing the PCIe network card driver into the root file system of the virtual machine operating system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, specifically providing a method for jailhouse-based interrupt forwarding of PCIe network cards. Background Technology

[0002] A PCIe network card is a network adapter with a PCIe interface, used as an expansion card interface in motherboard-level connections. The latest PCIe cards have been improved and have become the inevitable trend when choosing a network card. Most current PCIe network card devices use MSIx (Message Signaled Interrupt eXtended) to send interrupt signals to the CPU.

[0003] Jailhouse is virtualization software for implementing device isolation. It's a Linux static partition management program based on Hypervisor virtualization technology. Jailhouse uses Cell nodes to configure the virtualization functions of the CPU and device hardware platform, and the resources allocated to each node do not interfere with each other. As a type 1 virtual machine monitor, Jailhouse has high performance and can virtualize INTx interrupts, but it does not directly support message-based MSIx interrupts.

[0004] Jailhouse can physically isolate PCIe devices, meaning they can be allocated as resources to various virtual machines. However, when isolating some PCIe network interface cards (NICs) on an AArch64 architecture, jailhouse encounters a problem where the non-root Linux system cannot respond to MSIx interrupts. This prevents the acquisition of MSIx interrupt information for the PCIe NICs in the non-root Linux system, thus hindering the MSIx interrupt forwarding and injection process. Summary of the Invention

[0005] To overcome the above-mentioned defects, this invention is proposed to address the technical problem of MSIx interrupt forwarding injection when jailhouse isolates PCIe network card devices on the AArch64 architecture.

[0006] This invention provides a method for jailhouse isolation of interrupt forwarding of PCIe network cards, comprising the following steps:

[0007] Obtain jailhouse source code;

[0008] Add the MICapturer module to the jailhouse source code. The MICapturer module is used to obtain and save the DeviceID, EventID, ICID and pINTID of the PCIe network card.

[0009] Add the application vfio_demo.c to the jailhouse source code directory. The application vfio_demo.c is used to obtain the EventID and DeviceID of the PCIe network card that enables MSIx interrupts and forward them to the user-space program file inject.c.

[0010] Add a user-mode program file inject.c to the jailhouse source code directory. The user-mode program file inject.c is used to inject the PCIe network card's DeviceID and EventID into the MSICapturer module.

[0011] Save and compile the modified jailhouse source code, then install jailhouse.

[0012] Add a virtual machine operating system;

[0013] Copy the file igb.ko, which contains the PCIe network card driver, to the root file system of the virtual machine operating system.

[0014] In a further embodiment of the above method, adding the application vfio_demo.c to the jailhouse source code directory includes:

[0015] The bdf and msix vectors of the PCIe network card are obtained through the lspci command. The bdf is saved as the deviceid variable. The same number of eventfds are created according to the msix vector and saved to the eventid array variable in sequence.

[0016] Enable the MSIx interrupt of the PCIe network card based on the eventid array variable;

[0017] Create an epoll instance and initialize it, then read EPOLL_CTL_ADD type events with the eventid array variable as a parameter;

[0018] The epoll_wait function is called to block the epoll instance until the MSIx interrupt of the enabled PCIe network card is generated, at which point the blocking is released.

[0019] The PCIe network card's EventID is obtained from the epoll instance, and the PCIe network card's DeviceID is obtained from the deviceid variable.

[0020] In a further embodiment of the above method, adding the MSICapturer module to the jailhouse source code includes:

[0021] According to the platform chip manual, obtain the offset address its_base and space size its_space of the interrupt translation service hardware;

[0022] Based on the offset address its_base and the space size its_space, register the callback function for the virtual machine operating system to access the interrupt translation service hardware;

[0023] Add the file msi-capturer.c to the jailhouse source code directory, and add the function to implement the callback function in the msi-capturer.c file.

[0024] In a further embodiment of the above method, registering a callback function for virtual machine hardware access to the interrupt translation service based on the offset address its_base and the space size its_space includes:

[0025] Add the following external declaration function for the callback function in the jailhouse source file control.c: extern enum mmio_result msi_capturer_handler(void*arg,struct mmio_access*mmio);

[0026] Modify the cell_create function in the source code file control.c, and add the following code at the point where the function returns successfully: mmio_region_register(cell,its_base,its_space,msi_capturer_handler,(void*)cell).

[0027] In a further embodiment of the above method, a user-mode program file, inject.c, is added to the source code directory of the jailhouse, including:

[0028] Add a macro definition for the system call code SYS_CALL_PROC to the jailhouse.h source file;

[0029] Add a function to handle system call codes in the jailhouse_ioctl function in the jailhouse source file main.c;

[0030] Add the macro definition for the super system call word HYPER_SYS_CALL_WORD to the jailhouse source file hypercall.h;

[0031] Add a function to handle the super system call word in the hypercall function of the jaihouse source file contol.c;

[0032] The obtained PCIe network card's DeviceID and EventID are used as the calling parameters for the system call code SYS_CALL_PROC.

[0033] In a further embodiment of the above method, copying the file igb.ko, which contains the PCIe network card driver, to the root file system of the virtual machine operating system includes:

[0034] Generate an image file containing the PCIe network card driver within the virtual machine operating system kernel;

[0035] Compile the image file Image to obtain the compiled file igb.ko;

[0036] Copy the compiled file igb.ko to the root file system of the virtual machine operating system.

[0037] In a further embodiment of the above method, in response to initializing jailhouse, the MSI Capturer module is registered, a storage structure for the PCIe network card's device ID, event ID, CPU mapping table ID, and interrupt ID is created, and the application vfio_demo.c and the user-mode program file inject.c are started.

[0038] In a further embodiment of the above method, the initialization of jailhouse includes:

[0039] The jailhouse is initialized by enabling root-pcie-nic.cell &&inject.

[0040] In a further embodiment of the above method, in response to the virtual machine operating system starting up and running into the root file system, the PCIe network card driver is loaded.

[0041] The working principle and beneficial effects of this invention are as follows:

[0042] In implementing the technical solution of this invention, the PCIe network card device is isolated after adding the MSICapturer module, the application vfio_demo.c, and the user-mode program file inject using jailhouse. A standard Intel I210 PCIe network card driver is loaded into the virtual machine operating system (nonrootlinux), enabling the PCIe network card device to be successfully discovered by the virtual machine operating system and initialized by igb.ko. The MSICapturer module captures the MSIx interrupt information of the PCIe network card in the guest machine, and the application vfio_demo calls the user-mode program file inject to inject the MSIx interrupt of the PCIe network card into the virtual machine operating system (nonrootlinux), thus realizing the MSIx interrupt forwarding function of the PCIe network card device. Attached Figure Description

[0043] The disclosure of this invention will become more readily understood with reference to the accompanying drawings. It will be readily understood by those skilled in the art that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of this invention. Furthermore, similar numbers in the drawings are used to denote similar components, wherein:

[0044] Figure 1 This is a flowchart illustrating the main steps of a jailhouse method for isolating interrupt forwarding of a PCIe network card according to the present invention.

[0045] Figure 2 This is a schematic diagram of a network structure according to a jailhouse method for isolating interrupt forwarding of PCIe network cards based on the present invention. Detailed Implementation

[0046] Some embodiments of the present invention will now be described with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are merely illustrative of the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.

[0047] This embodiment is based on the Aarch64 platform. It uses jailhouse to add the MSICharter module, the application vfio_demo.c, and the user-space program file inject to isolate the PCIe network card device. A standard Intel I210 PCIe network card driver is loaded into the virtual machine operating system (nonrootlinux), allowing the PCIe network card device to be successfully discovered by the virtual machine operating system and initialized by igb.ko. The MSICharter module captures the MSIx interrupt information of the PCIe network card in the guest machine, and the application vfio_demo calls the user-space program file inject to inject the PCIe network card's MSIx interrupts into the virtual machine operating system (nonrootlinux), thus realizing the MSIx interrupt forwarding function of the PCIe network card device.

[0048] Figure 1 This is a flowchart illustrating the main steps of a jailhouse method for isolating interrupt forwarding of a PCIe network card according to the present invention. Figure 2 This is a schematic diagram of a network structure according to a jailhouse method for isolating interrupt forwarding of PCIe network cards, based on the present invention. Figure 1-2 As shown, a method for interrupt forwarding of a jailhouse-isolated PCIe network card in an embodiment of the present invention mainly includes the following steps S1-S7.

[0049] Step S1: Obtain the jailhouse source code.

[0050] Jailhouse is a Linux-based partitioned virtual machine manager that uses cells to configure the virtualization features of hardware such as the CPU. Cells are divided into root cells and non-root cells. There is only one root cell, which manages system hardware resources; multiple non-root cells can exist and obtain system resources from the root cell. In this embodiment, a Linux system is installed on a non-root cell configured in jailhouse, and the Linux system is used to drive the PCIe network card, thus achieving virtualization isolation of the PCIe network card by jailhouse.

[0051] Step S2: Add the MICapturer module to the jailhouse source code. The MICapturer module is used to obtain and save the DeviceID, EventID, ICID and pINTID of the PCIe network card.

[0052] In this embodiment, the MSI Capturer module is responsible for monitoring the virtual machine operating system guest (non-root Linux) access to the ITS (Interrupt Translation Service) hardware, analyzing the data, saving the obtained results, and outputting them.

[0053] In a further embodiment of the above method, step S2 includes:

[0054] Step S21: According to the aarch64 platform chip manual, obtain the offset address its_base and space size its_space of the interrupt translation service its hardware.

[0055] Step S22: Based on the offset address its_base and the space size its_space, register the callback function for the virtual machine operating system guest (non-root linux) to access the interrupt translation service its hardware.

[0056] Add the following external declaration function for the callback function in the jailhouse source file control.c: extern enum mmio_result msi_capturer_handler(void*arg,struct mmio_access*mmio);

[0057] Using the offset address its_base and space size its_space obtained above, modify the cell_create function in the source code file control.c, and add the following code at the point where the function returns successfully (return0): mmio_region_register(cell,its_base,its_space,msi_capturer_handler,(void*)cell).

[0058] Step S23: Add the msi-capturer.c file to the jailhouse source code directory, and add the function to implement the callback function in the msi-capturer.c file;

[0059]

[0060]

[0061]

[0062] Step S3: Add the application vfio_demo.c to the jailhouse source code directory. The application vfio_demo.c is used to obtain the EventID and DeviceID of the PCIe network card that enables MSIx interrupts and forward them to the user-space program file inject.c.

[0063] In a further embodiment of the above method, step S3 includes:

[0064] Step S31: Save the PCIe network card's deviceid and initialize the eventid.

[0065] Use the lspci command to obtain the number of bdf and MSIx vectors of the INTEL I210 network card, save the bdf to the deviceid variable, create the same number of eventfds according to the number of MSIx vectors, and save them to the eventid array variable in sequence.

[0066] Step S32: Enable the MSIx interrupt of the PCIe network card.

[0067] The system call interface VFIO_DEVICE_SET_IRQS in vfio_pci.ko takes the data in the eventid array and the flag VFIO_IRQ_SET_DATA_EVENTFD|VFIO_IRQ_SET_ACTION_TRIGGER as parameters and makes a system call to enable the network card's MSIx interrupt vector.

[0068] Step S33: epoll creation and initialization.

[0069] After the above steps are completed, an epoll instance is created through the epoll_create1 interface function, and the epoll_ctl function is called to set the instance. The type is set to EPOLL_CTL_ADD, the type of event is read, and the parameter is the eventid array data.

[0070] Step S34: Wait for the PCIe network card's MSIx interrupt.

[0071] After completing the above steps, you can call the `epoll_wait` function to block and wait for the epoll instance. The blocking of the epoll instance will be released once the MSIx interrupt enabled by the PCIe network card is generated.

[0072] Step S35: Inject MSIx interrupt into non-root Linux

[0073] After the above steps are unblocked, the eventid array data set in step S33 will be obtained. By obtaining the array index through this data, the EventID vector is obtained. Combined with DeviceID (deviceid variable in step S31), the current interrupt is injected into the non-root linux (guest) based on step S4.

[0074] Step S36: Repeat step S34 to complete the interrupt forwarding of the PCIe network card.

[0075] Because PCIe network card interrupts are constantly generated along with the transmission of data packets, each interrupt must enter S34 for forwarding. In the entire interrupt forwarding method, step S3 should be the last step.

[0076] Step S4: Add a user-mode program file inject.c to the jailhouse source code directory. The user-mode program file inject.c is used to inject the PCIe network card's DeviceID and EventID into the MSICapturer module.

[0077] In a further embodiment of the above method, step S4 includes:

[0078] Step S41: Define system call code SYS_CALL_PROC

[0079] Add macro definitions to the jailhouse.h source code file.

[0080] #define SYS_CALL_PROC(_IOW(0,7,struct jailhouse_cell_id)

[0081] Step S42: Define the super system call word HYPER_SYS_CALL_WORD

[0082] Add macro definitions to the jailhouse source file hypercall.h

[0083] #define HYPER_SYS_CALL_WORD(9)

[0084] Step S43: Process system call codes in the driver.

[0085] In the jailhouse source file main.c, add a function jailhouse_call_arg2 to the jailhouse_ioctl function to handle the SYS_CALL_PROC system call code. This function is built into jailhouse and can be directly passed in HYPER_SYS_CALL_WORD and user-level parameters, thus realizing the transition from system call to super system call.

[0086] Step S44: Processing the super system call word in virtualization

[0087] In the jaihouse source code file contol.c, add a part to handle the HYPER_SYS_CALL_WORD call word in the hypercall function, and directly call the msi_capturer_trigger function of the MSICAPturer module.

[0088] Step S45: Add application inject runtime interruption injection

[0089] Add a user-space program file, inject.c, to the jailhouse directory. This program, after opening the jailhouse.ko driver, uses the obtained PCIe network card's DeviceID and EventID as the call parameters for the system call code SYS_CALL_PROC, and then performs the SYS_CALL_PROC system call.

[0090] Step S5: Save and compile the modified jailhouse source code, and install jailhouse.

[0091] After Jailhouse is compiled, the generated files are divided into three parts: The first part is the Jailhouse driver and hypervisor firmware, which provides the user-space interface and initializes the hypervisor; the second part is the cell and guest image. The cell describes the system resources required for the image to run; the guest image runs on top of the cell and includes bare metal, RTOS, and Linux kernel images; the third part is the user-space tools, which are used to load the cell, run the image, and view the Jailhouse status.

[0092] Prepare an aarch64 environment, install CentOS 8.4, and reserve memory space for the jailhouse firmware and the nonroot Linux virtual machine operating system in the kernel boot parameters. Install the Jailhosue code and prepare the resource files required to boot the virtual machine operating system (Linux) when testing jailhouse: initrd memory root file system rootfs.cpio, nonroot.dts device tree file, and kernel image file Image. Jailhosue is built in a static partition environment. After adding the MSIPicturer module, the application vfio_demo.c, and the user-space program file inject, compile and install. The required machine configuration is as follows:

[0093] ①Requires hardware support for virtualization extensions and two or more CPU cores;

[0094] ② Linux kernel version 4.7+, with PSCI support for CPU operations, etc.

[0095] Step S6: Add a virtual machine operating system to the installed jailhouse program;

[0096] Step S7: Copy the file igb.ko, which contains the PCIe network card driver, to the root file system of the virtual machine operating system.

[0097] In a further embodiment of the above method, step S7 includes:

[0098] Step S71: Generate an image file containing the PCIe network card driver in the virtual machine operating system kernel;

[0099] Step S72: Compile the image file Image to obtain the compiled file igb.ko;

[0100] Step S73: Copy the compiled file igb.ko to the root file system rootfs.cpio of the virtual machine operating system.

[0101] Through steps S1-S7 above, the jailhouse tool is used to perform hardware isolation of the arm64 core, memory, and PCIe device, and a Linux operating system runs in the partition. This Linux system drives the isolated Intel I210 PCIe network card. After jailhouse cell Linux runs, it loads the driver igb.ko for the isolated PCIe network card. During jailhouse enable initialization, the application vfio_demo.c and the user-space program file inject are started. The vfio_demo program obtains the BDF and vectors parameters of the PCIe device (I210 network card) according to the lspci command, and saves them as DeviceID, EventID, and the corresponding eventFD parameter. Then, a thread is started and enters an infinite loop. The thread enables the PCIe network card with the msix interrupt through the interface provided by vfio and completes the initialization of epoll creation and control. After that, the thread enters an infinite loop. Each iteration waits for a read event from the eventfd in epoll, which identifies the corresponding EventID and Devi. The `ceID` parameter, along with the `inject` function, calls the user-space program file `inject`. This calls the `sys_call` system call to enter the `jailhouse.ko` driver, which then uses a super system call to enter the hypervisor. The jailhouse hypervisor uses the passed `DeviceID` and `EventID` to call the `MSICapturer` module. The `MSICapturer` module uses these two parameters to determine the PCIe network card's BDF and vector ID, mapping `pINTID` and `ICID` from the captured MSIx interrupt information. This achieves precise injection of PCIe network card MSIx interrupts, thus completing the PCIe network card MSIx interrupt forwarding function.

[0102] It should be noted that although the steps in the above embodiments are described in a specific order, those skilled in the art will understand that in order to achieve the effects of the present invention, different steps do not necessarily have to be executed in such an order. They can be executed simultaneously (in parallel) or in other orders, and these variations are all within the scope of protection of the present invention.

[0103] After adding jailhouse with the MSICamper module and the user-space program file inject, and installing a Linux system capable of driving PCIe network cards on the modified jailhouse program, the following verification was performed to further demonstrate the interrupt acquisition results of this embodiment:

[0104] Prepare an x86 environment, install CentOS 8.4 as the analysis environment, configure it with a gigabit Ethernet interface, and have the iperf3 software package installed.

[0105] ① Deployment environment initialization

[0106] This step initializes jailhouse and starts the vfio_demo program by enabling jailhouse root-pcie-nic.cell&&vfio_demo.

[0107] ② Deployment environment startup guest

[0108] The jailhouse cell is a Linux guest-pcie-nic.cell file. The image is dnonroot.dtb, and the file is irootfs.cpio. The file contains the following characters: "earlycon=PL011,0x28000000console=ttyAMA0,115200root= / dev / ram0 ramdisk_size=0x1000000". This step starts the guest (non-root Linux) instance; then, the Intel I210 network card driver is loaded in the guest instance using `insmod igb.ko`.

[0109] ③ Analyze the environment and start the iperf server.

[0110] Connect the Gigabit Ethernet port to the PCIe I210 network card in the deployment environment using a network cable, and set the local Ethernet IP address to 192.168.1.10. Then, execute `iperf3-si 1` in the console to start the server listening connection of the analysis environment.

[0111] ④ Analyze the environment: guest starts the iperf client.

[0112] In the analysis environment's guest (non-root Linux) instance, first set the IP address of the I210 network card to "192.168.1.100". Then, in the non-root Linux instance, execute the command `iperf3 -c 192.168.1.10 -t 10 -i 5` to start the iperf client.

[0113] ⑤ Perform network packet analysis in the analysis environment

[0114] After executing the above steps, observe the iperf server data in the console on the analysis environment (192.168.1.10). After analysis, it is found that all iperf client data packets were transmitted in the nonroot Linux deployment environment, and the network bandwidth utilization rate was 941 Mbits / sec. This proves that the MSIx interrupt forwarding of the PCIe network card is very successful.

[0115] In this embodiment, the PCIe network card device can be isolated by adding the vfio_demo function in jailhouse. The device can be successfully scanned and discovered by the Linux system in the guest machine and initialized by igb.ko. The initialization MSIx interrupt information is captured by MSICapturer. vfio_demo can enable the MSIx interrupt of the I210 network card and forward the MSIx interrupt of the PCIe network card to the PCIe network card driver in the nonroot Linux.

[0116] Figure 2 In Jailhouse Hypervisor, UART0 is hardware serial port 0, UART1 is hardware serial port 1, MMIO is memory-mapped I / O, which is a standard interface in jailhouse, and ttyAMA0 is a device node under the / dev directory in the Linux system. The console mentioned is the bound ttyAMA0.

[0117] Interrupt forwarding involves obtaining the PCIe network card's DeviceID and EventID parameters through the vfio_demo program and forwarding them to the inject program. The inject program directly calls the jailhouse.ko driver to retrieve the PCIe network card's DeviceID and EventID parameters via a system call. Within the driver, a super system call is used to access the jailhouse.bin hypervisor firmware (located in the compiled and installed path / lib / firmware / ). Then, the MSICapture module is invoked using the passed DeviceID and EventID. The MSICapture module uses these two parameters to determine the network card's BDF and vector ID, mapping the pINTID and ICID from the captured msi_capture information, and injecting them into the virtual machine operating system GuestLinux. This completes the precise injection of the msix interrupt. Since the data is bidirectional, after the driver injects the interrupt into the MSICapture module, MSICapture will also provide feedback to the driver.

[0118] Figure 2The two consoles correspond to the X86 analysis machine console and the client console on the Aarch64 test machine, respectively. In the X86 console, we set the LAN IP address (192.168.1.10) and then run the iper3 server (iperf3 –s –i1) to enable TCP listening. Then, in the Aarch64 client console, we set the LAN IP address (192.168.1.100) and then run the iperf3 client (iperf3 –c 192.168.1.10 –t 10 –i 5). We then see the network transmission performance data in the output of the analysis machine console.

[0119] The technical solution of the present invention has been described above with reference to the preferred embodiments shown in the accompanying drawings. However, it will be readily understood by those skilled in the art that the scope of protection of the present invention is obviously not limited to these specific embodiments. Without departing from the principles of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will all fall within the scope of protection of the present invention.

Claims

1. A method for jailhouse isolation of interrupt forwarding of PCIe network cards, characterized in that, Including the following steps: Obtain jailhouse source code; Add the MICapturer module to the jailhouse source code. The MICapturer module is used to obtain and save the DeviceID, EventID, ICID and pINTID of the PCIe network card. Add the application vfio_demo.c to the jailhouse source code directory. The application vfio_demo.c is used to obtain the EventID and DeviceID of the PCIe network card that enables MSIx interrupts and forward them to the user-space program file inject.c. Add a user-mode program file inject.c to the jailhouse source code directory. The user-mode program file inject.c is used to inject the PCIe network card's DeviceID and EventID into the MSICapturer module. Save and compile the modified jailhouse source code, then install jailhouse. Add a virtual machine operating system; Copy the file igb.ko, which contains the PCIe network card driver, to the root file system of the virtual machine operating system.

2. The method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 1, characterized in that, Adding the application vfio_demo.c to the jailhouse source code directory includes: The bdf and msix vectors of the PCIe network card are obtained through the lspci command. The bdf is saved as the deviceid variable. The same number of eventids are created according to the msix vector and saved to the eventid array variable in sequence. Enable the MSIx interrupt of the PCIe network card based on the eventid array variable; Create an epoll instance and initialize it, then read EPOLL_CTL_ADD type events with the eventid array variable as a parameter; The epoll_wait function is called to block the epoll instance until the MSIx interrupt of the enabled PCIe network card is generated, at which point the blocking is released. The PCIe network card's EventID is obtained from the epoll instance, and the PCIe network card's DeviceID is obtained from the deviceid variable.

3. The method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 1, characterized in that, Adding the MSI Capturer module to the jailhouse source code includes: According to the platform chip manual, obtain the offset address its_base and space size its_space of the interrupt translation service hardware; Based on the offset address its_base and the space size its_space, register the callback function for the virtual machine operating system to access the interrupt translation service hardware; Add the file msi-capturer.c to the jailhouse source code directory, and add the function to implement the callback function in the msi-capturer.c file.

4. The method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 3, characterized in that, The step of registering a callback function for virtual machine hardware access to the interrupt translation service based on the offset address its_base and the space size its_space includes: Add the following external declaration function for the callback function in the jailhouse source file control.c: externenum mmio_result msi_capturer_handler(void*arg,struct mmio_access*mmio); Modify the cell_create function in the source code file control.c, and add the following code at the point where the function returns successfully: mmio_region_register(cell,its_base,its_space,msi_capturer_handler,(void*)cell).

5. The method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 1, characterized in that, The step of adding the user-mode program file inject.c to the jailhouse source code directory includes: Add a macro definition for the system call code SYS_CALL_PROC to the jailhouse.h source file; Add a function to handle system call codes in the jailhouse_ioctl function in the jailhouse source file main.c; Add the macro definition for the super system call word HYPER_SYS_CALL_WORD to the jailhouse source file hypercall.h; Add a function to handle the super system call word in the hypercall function of the jailhouse source file contol.c; The obtained PCIe network card's DeviceID and EventID are used as the calling parameters for the system call code SYS_CALL_PROC.

6. The method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 1, characterized in that, The step of copying the file igb.ko, which contains the PCIe network card driver, to the root file system of the virtual machine operating system includes: Generate an image file containing the PCIe network card driver within the virtual machine operating system kernel; Compile the image file Image to obtain the compiled file igb.ko; Copy the compiled file igb.ko to the root file system of the virtual machine operating system.

7. The method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 1, characterized in that, In response to initializing jailhouse, the MSI Capturer module is registered, a storage structure for the PCIe network card's device ID, event ID, CPU mapping table ID, and interrupt ID is created, and the application vfio_demo.c and the user-mode program file inject.c are started.

8. A method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 7, characterized in that, The initialization of jailhouse includes: The jailhouse is initialized by enabling root-pcie-nic.cell &&inject.

9. A method for interrupt forwarding of a jailhouse-isolated PCIe network card according to claim 1, characterized in that, In response to the virtual machine operating system starting up and running into the root file system, the PCIe network card driver is loaded.

Citation Information

Patent Citations

  • Realization method of high-efficiency network communication of a virtual machine monitor

    CN101557420A

  • Method, system and device for enabling network card to support virtualization function and storage medium

    CN113691381A