A method for serial port device direct access to client based on ARM64 architecture

Through the two-stage address translation and interrupt virtualization mechanism of the ARM64 architecture, the performance and compatibility issues of virtual devices are solved, efficient and secure direct access to serial port devices in a virtualized environment is achieved, direct access to non-PCI devices is supported, and the performance and security of serial port devices in a virtualized environment are improved.

CN120277021BActive Publication Date: 2025-09-19KYLIN CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510766530.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-19
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

In the existing technology, virtual devices have high performance overhead, increased device access latency, and hardware characteristics and functional limitations. Device pass-through relies on specific hardware support and has poor compatibility, which cannot effectively solve the problem of direct access to serial port devices.

Method used

The two-stage address translation mechanism and interrupt virtualization mechanism of the ARM64 architecture are adopted to establish a mapping from the client physical address of the serial port device to the host physical address, and direct access to the serial port device is achieved through the virtual interrupt mechanism, avoiding virtual machine monitor emulation and host forwarding.

Benefits of technology

It enables efficient, low-latency and secure direct access to serial devices in a virtualized environment, improves performance, reliability and security, and supports direct access to non-PCI devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120277021B_ABST
    Figure CN120277021B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of virtual machine technology, and specifically provides a method for directly connecting a serial port device to a client based on the ARM64 architecture, comprising: establishing a mapping of the client physical address GPA of the serial port device to the host physical address HPA according to the physical address space occupied by the serial port device; establishing a mapping relationship between the serial port device hardware interrupt and the client virtual interrupt; establishing a mapping of the client virtual address GVA of the serial port device to the client physical address GPA; after the serial port device generates a hardware interrupt, the serial port interrupt is sent to a designated processor through an interrupt controller, and the serial port interrupt is forwarded to the corresponding client according to the mapping relationship; when the serial port device is accessed using the GVA, the GVA is converted into the GPA according to the mapping relationship, and then converted into the HPA, thereby accessing the physical address space of the serial port device. Through the above scheme, the performance, reliability and security of specific serial port devices in a virtualized environment are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of virtual machines, and specifically provides a method for directly communicating a serial port device with a client based on an ARM64 architecture. Background Art

[0002] In a virtualized environment, there are two main ways to use devices: virtual devices and device passthrough.

[0003] 1. Virtual Device

[0004] Virtual devices are hardware devices simulated in software by a virtual machine monitor (VmWare, QEMU, CrosVM, etc.). Clients operate through these virtual devices without directly accessing the host machine's hardware. Common virtual devices include virtual disks, virtual network interfaces, and virtual graphics cards. The main shortcomings of existing virtual devices include the following three points:

[0005] The performance overhead is high, as virtual devices are simulated through software, involving multiple transitions between the host and the client;

[0006] Increased device access latency: Virtual device operations are forwarded through the VM monitor, which adds an extra processing step. As a result, the response time of virtual devices is longer than when operating directly on physical devices.

[0007] Hardware features and functional limitations. Virtual devices are designed for compatibility and flexibility, but they usually cannot fully simulate all the features of physical hardware. For example, a virtual graphics card cannot provide the graphics acceleration function of a hardware graphics card.

[0008] 2. Device direct access

[0009] Device passthrough leverages hardware IOMMU support and VFIO software technology to pass the host's physical hardware devices (such as GPUs, network cards, and storage devices) directly to the client. This allows the client to directly access the host's physical hardware devices without emulation through the virtual machine monitor, significantly improving the performance of client access to hardware devices. The main drawbacks of existing device passthrough technologies include the following:

[0010] Strong hardware dependency. Device passthrough usually relies on the support of certain specific hardware, such as IOMMU (used for virtual-to-real address translation when the device accesses memory). Without specific hardware support, device passthrough cannot be used.

[0011] Device compatibility is poor. Currently, device passthrough requires IOMMU hardware and VFIO software technology, and only supports PCI / PCIE devices. Device passthrough is not possible for other types of devices.

[0012] Accordingly, the art needs a new solution for serial port devices to directly connect to the client to solve the above problems. Summary of the Invention

[0013] In order to overcome the above-mentioned defects, the present invention proposes a method for directly communicating a serial port device with a client based on the ARM64 architecture, comprising the following steps:

[0014] S1: Establish a mapping from the client physical address GPA of the serial port device to the host physical address HPA according to the physical address space occupied by the serial port device;

[0015] S2: Set up the hypervisor interrupt vector table and establish a mapping relationship between the serial port device hardware interrupt and the client virtual interrupt. When the serial port device generates an interrupt, the host sends a virtual interrupt to the corresponding client according to the mapping relationship.

[0016] S3: Establish a mapping between the client virtual address GVA of the serial device and the client physical address GPA;

[0017] S4: After the serial port device generates a hardware interrupt, the serial port interrupt is sent to the designated processor through the interrupt controller. After the host machine's hypervisor layer and the host machine's operating system kernel layer receive the interrupt, the serial port interrupt is forwarded to the corresponding client according to the mapping relationship;

[0018] S5: When the client uses the client virtual address GVA to access the serial port device, the client virtual address GVA is converted into the client physical address GPA according to the established mapping relationship, and then converted into the host physical address HPA, thereby accessing the physical address space of the serial port device.

[0019] Furthermore, the step S1 includes:

[0020] The virtual machine monitor at the host application layer allocates the corresponding client physical address GPA to the serial port device;

[0021] Enter the kernel layer of the host operating system through system calls, and obtain the host physical address HPA and physical resource size of the serial port device through the device tree;

[0022] The client physical address GPA, host physical address HPA and physical resource size are used as entry parameters to enter the host's Hypervisor layer through HVC call;

[0023] The host's Hypervisor layer constructs page table entries at all levels of the ARM64 architecture's second-stage address translation to implement address mapping from the guest physical address GPA to the host physical address HPA.

[0024] Further, the step S2 includes:

[0025] Enter the Hypervisor through HVC call and configure the corresponding interrupt vector table;

[0026] Get the physical interrupt number of the serial port device through the device tree;

[0027] Assign a unique corresponding virtual interrupt number to the physical interrupt number;

[0028] Use the virtual interrupt number to register the host serial port interrupt handler.

[0029] Further, the step S3 includes:

[0030] Get the client serial port device physical address GPA assigned by the virtual machine monitor to the serial port device;

[0031] Determine whether it is user mode access or kernel mode access;

[0032] If it is a user-mode access, the client operating system kernel layer searches for free address space in the process's user address space and allocates a user-mode virtual address (GVA) of the specified size according to the request;

[0033] If it is kernel-mode access, the client operating system kernel layer searches for free address space in the process's kernel address space and allocates a kernel-mode virtual address (GVA) of the specified size based on the request.

[0034] According to the obtained serial port device client physical address GPA and the allocated client virtual address GVA, the page table entries of each level of the first stage address translation of the ARM64 architecture are constructed to realize the conversion of the client virtual address GVA to the client physical address GPA.

[0035] Furthermore, if the serial port address space is mapped to the user-mode GVA through the mmap system call, it is determined to be user-mode access; if the serial port address space is mapped to the kernel-mode GVA through the ioremap kernel interface, it is determined to be kernel-mode access.

[0036] Further, the step S4 includes:

[0037] When a serial port device generates a hardware interrupt, the hardware disables the interrupt and sends the hardware interrupt to the designated processor through the interrupt controller. The processor then enters the interrupt handler at the host hypervisor layer.

[0038] The interrupt handler of the host hypervisor layer does not handle the serial port interrupt, calls guest_exit to exit the guest execution, and returns to the host operating system kernel layer execution;

[0039] After returning to the host operating system kernel layer, set the interrupt vector table entry to the interrupt vector table entry of the host operating system;

[0040] The kernel layer of the host operating system re-enables interrupts, and the serial port interrupt is triggered again through the interrupt controller, which then sends the serial port interrupt to the designated processor.

[0041] The host operating system kernel layer jumps to the interrupt handler according to the set interrupt vector table, and in the interrupt handler, a virtual interrupt is injected into the specified client;

[0042] The injected virtual interrupt is written into the interrupt controller hardware register and the client resumes execution;

[0043] The guest will receive the virtual interrupt after resuming execution.

[0044] Further, the step S5 includes:

[0045] The client user state access maps the client physical address GPA of the serial port device to the client virtual address GVA. After the mapping is completed, the client virtual address GVA in the user state can be used directly in the user state to read and write the serial port device address space;

[0046] The client kernel state access maps the client physical address GPA of the serial port device to the kernel state virtual address GVA. After the mapping is completed, the kernel state client virtual address GVA can be used directly in the kernel state to read and write the serial port device address space;

[0047] According to the ARM64 architecture's first stage address translation, the client virtual address GVA is converted to the client physical address GPA.

[0048] According to the ARM64 architecture's second-stage address translation, the client physical address GPA is converted to the host physical address HPA.

[0049] Use the host physical address (HPA) of the serial device to access the serial device address space.

[0050] Working principle and beneficial effects of the present invention:

[0051] In implementing the technical solution of the present invention, a two-stage address translation mechanism provided by the ARM64 architecture is employed to enable direct access to serial devices within the client. Furthermore, a virtual interrupt mechanism provided by the ARM64 architecture is employed, allowing the client to directly access the serial device address space and process serial device interrupts after the host receives an interrupt generated by the serial device, thereby avoiding data forwarding and interrupt processing by the host and ensuring the security, efficiency, and reliability of serial device access. This approach avoids using a virtual machine monitor to simulate serial devices or forwarding client data to physical serial devices through the host, aiming to enable direct client access to the host's physical serial devices in an efficient, low-latency, and secure manner, thereby improving the performance, reliability, and security of specific serial devices in a virtualized environment. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] The disclosure of the present invention will be more easily understood with reference to the accompanying drawings. Those skilled in the art will readily appreciate that these drawings are for illustrative purposes only and are not intended to limit the scope of protection of the present invention. Furthermore, similar numbers in the drawings represent similar components, wherein:

[0053] Figure 1 This is a schematic diagram of the main steps of the method for directly connecting a serial port device to a client computer according to the present invention;

[0054] Figure 2 1 is a flow chart of step S1 in the method for directly connecting a serial port device to a client device according to the present invention;

[0055] Figure 3 1 is a flow chart of step S2 in the method for directly connecting a serial port device to a client computer according to the present invention;

[0056] Figure 4 1 is a flow chart of step S3 in the method for directly connecting a serial port device to a client computer according to the present invention;

[0057] Figure 5 4 is a flow chart of step S4 in the method for directly connecting a serial port device to a client device according to the present invention;

[0058] Figure 6 It is a flow chart of step S5 in the method of directly connecting a serial port device to a client of the present invention. DETAILED DESCRIPTION

[0059] Some embodiments of the present invention are described below with reference to the accompanying drawings. Those skilled in the art should understand that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the scope of protection of the present invention.

[0060] In an embodiment of the present invention, a method for directly connecting a serial port device to a client based on the ARM64 architecture is proposed. This method does not require a virtual machine monitor to emulate the serial port, nor does it require specific IOMMU hardware. It fully utilizes the virtualization support (two-stage address translation and interrupt virtualization) of the ARM64 architecture processor itself to realize direct connection of the host serial port device to the client. The client can directly access the physical serial port device of the host in an efficient, low-latency and secure manner, thereby improving the performance, reliability and security of the client's use of the serial port device in a virtualized environment.

[0061] The ARM64 architecture provides two virtualization mechanisms: two-stage address translation and interrupt virtualization, which are used to solve two problems existing in device direct access to the client in a virtualized environment: physical address space access and device interrupt processing.

[0062] 1. Physical address space access

[0063] The ARM64 architecture provides a two-stage address translation mechanism: the first stage address translation is used to convert the guest virtual address (GVA) to the guest physical address (GPA). In a virtualized environment, the client cannot directly access the physical address space using GPA; the second stage address translation is used to convert the guest physical address (GPA) generated in the first stage to the host physical address (HPA). Finally, the client uses HPA to access the real physical address space.

[0064] 2. Device interrupt processing

[0065] The ARM64 architecture provides an interrupt virtualization mechanism. When a device generates an interrupt, software running at a certain priority level (hypervisor and host operating system) can use processor support to send a virtual interrupt to a specified client, allowing the specified client to respond to and handle the interrupt generated by the hardware.

[0066] Figure 1 This is a schematic diagram of the main steps of the method of the present invention for serial device to directly connect to the client. Figure 1 As shown, a method for a serial port device to directly connect to a client based on an ARM64 architecture in this embodiment mainly includes the following steps S1 to S5.

[0067] S1: Initialization, establish a mapping from GPA to HPA according to the physical address space occupied by the serial port device, where GPA represents the client physical address of the serial port device and HPA represents the host physical address of the serial port device.

[0068] In one embodiment, Figure 2 This is a flow chart of step S1 in the method of directly connecting a serial device to a client computer according to the present invention. Figure 2 As shown, step S1 specifically includes the following steps S11-S14.

[0069] S11: The virtual machine monitor at the host application layer allocates a corresponding guest physical address (GPA) to the serial port device. The guest physical address (GPA) is used by the guest operating system as the physical address of the serial port device and cannot directly access the address space of the serial port device.

[0070] S12: Enter the kernel layer of the host operating system through a system call. The serial port device is initially managed by the host operating system. The physical resources of the serial port device are obtained through the device tree, including the host physical address (HPA) of the serial port device and the size of the physical resource.

[0071] S13: Use GPA, HPA, and physical resource size as entry parameters and enter the host machine's hypervisor layer through HVC call;

[0072] S14: The host machine's Hypervisor layer constructs page table entries at all levels of the ARM64 architecture's second-stage address translation based on the input GPA, HPA, and resource size parameters to implement address mapping from GPA to HPA.

[0073] In this embodiment, the ARM64 architecture uses a two-stage address translation for client access to memory and the device's physical address space. Since the serial port device is initially managed by the host, step S1 is responsible for establishing the second stage of the two-stage address translation for serial port device access, namely, establishing a mapping from the GPA to the HPA based on the serial port device's physical address space.

[0074] S2: Interrupt mapping, setting up the hypervisor interrupt vector table and establishing a mapping relationship between the serial port device hardware interrupt and the client virtual interrupt; when the serial port device generates an interrupt, the host only sends a virtual interrupt to the specified client based on the mapping relationship between the hardware interrupt and the virtual interrupt.

[0075] In one embodiment, Figure 3 This is a flow chart of step S2 in the method of connecting a serial device to a client computer according to the present invention. Figure 3 As shown, step S2 specifically includes the following steps S21-S24.

[0076] S21: The host operating system enters the hypervisor through the HVC call and configures the corresponding interrupt vector table. When the client is running, if a serial port interrupt occurs, it can enter the hypervisor for processing;

[0077] S22: The kernel layer of the host operating system obtains the physical interrupt number of the serial port device through the device tree;

[0078] S23: The host operating system kernel layer allocates a unique virtual interrupt number corresponding to the physical interrupt number. The virtual interrupt number will be used by the client as the physical interrupt number of the serial port device.

[0079] S24: The host operating system kernel layer uses the virtual interrupt number to register a host serial port interrupt handler. In the interrupt handler, the serial port hardware is not accessed, and the virtual interrupt is only forwarded to the designated client through the virtual interrupt controller.

[0080] In this embodiment, when a serial device directly communicates with a client, the host operating system kernel does not process the hardware interrupt generated by the serial device. Instead, it maps the hardware interrupt into a virtual interrupt and forwards it to the designated client. To the client, the virtual interrupt is the hardware interrupt generated by the serial device, and the client operating system receives and processes the virtual interrupt.

[0081] S3: Address mapping: This establishes the first phase of the two-phase address translation for serial device access, namely, the GVA to GPA address mapping. The GPA is the client physical address of the serial device. To access the serial device, the client can only access it through the GVA, so a GVA to GPA address mapping is required.

[0082] In one embodiment, Figure 4 This is a flow chart of step S3 in the method of directly connecting a serial device to a client computer according to the present invention. Figure 4 As shown, step S3 specifically includes the following steps S31-S35.

[0083] S31: Obtain the client serial port device physical address GPA allocated by the virtual machine monitor to the serial port device. The GPA is used by the client as the physical address of the serial port device for use by the serial port device driver;

[0084] S32: Determine whether it is user-mode access (mapping the serial port address space to the user-mode GVA via the mmap system call) or kernel-mode access (mapping the serial port address space to the kernel-mode GVA via the ioremap kernel interface).

[0085] S33: If it is a user-mode access, the client operating system kernel layer searches for free address space from the user address space of the process and allocates a user-mode virtual address GVA of a specified size according to the request;

[0086] S34: If it is kernel-mode access, the kernel layer of the client operating system searches for free address space in the kernel address space of the process and allocates a kernel-mode virtual address GVA of a specified size according to the request;

[0087] S35: Based on the obtained serial port device client physical address GPA and the allocated client virtual address GVA, a page table (three-level or four-level page table) for the first stage address translation of the ARM64 architecture is constructed to implement address translation from GVA to GPA.

[0088] In this embodiment, in the ARM64 virtualization environment, the client needs to go through a two-stage address translation of GVA→GPA→HPA to access the actual physical address of the serial port device. Step S1 establishes a mapping from the serial port device's GPA to the HPA by constructing a second-stage address translation page table. However, the client can only access the serial port using the GVA address. Step S3 then establishes a mapping from GVA to GPA by constructing a first-stage address translation page table, thereby enabling direct access to the serial port device within the client.

[0089] S4: Interrupt processing: The serial port device generates a hardware interrupt and sends it to the designated processor through the interrupt controller. After the host machine's hypervisor layer and the host machine's operating system kernel layer receive the interrupt, they forward it to the designated client according to the physical interrupt to virtual interrupt mapping established in step S2. The serial port device driver of the client further processes the serial port interrupt.

[0090] In one embodiment, Figure 5 This is a flow chart of step S4 in the method of directly connecting a serial device to a client computer according to the present invention. Figure 5 As shown, step S4 specifically includes the following steps S41-S46.

[0091] S41: When the serial port device generates a hardware interrupt, the hardware disables the interrupt and sends the hardware interrupt to the specified processor through the interrupt controller. The processor uses the Hypervisor interrupt vector table entry set in process 2 to enter the interrupt handler of the host hypervisor layer.

[0092] S42: The interrupt handler of the host hypervisor layer does not handle the serial port interrupt, calls guest_exit to exit the guest execution, and returns to the host operating system kernel layer for execution;

[0093] S43: After returning to the host operating system kernel layer, set the interrupt vector table entry to the interrupt vector table entry of the host operating system;

[0094] S44: The kernel layer of the host operating system re-enables interrupts. Since the serial port interrupt is not handled at this time, the serial port interrupt will be triggered again through the interrupt controller, and the interrupt controller will send the serial port interrupt to the designated processor;

[0095] S45: The host operating system kernel layer jumps to the interrupt handler registered in step S2 according to the set interrupt vector table, and injects a virtual interrupt into the specified client in the interrupt handler;

[0096] S46: The injected virtual interrupt is written into the interrupt controller hardware register, and the client resumes execution;

[0097] Since step S46 writes the interrupt information to the hardware register, the interrupt controller will ensure that a virtual interrupt is triggered, and the client will receive the virtual interrupt after resuming execution. From the client's perspective, the virtual interrupt is handled by the client operating system like a hardware interrupt.

[0098] In this embodiment, when the host serial port device is directly connected to the client, the client must handle the hardware interrupt generated by the serial port device. The host only forwards the hardware interrupt generated by the serial port device, and forwards the serial port device hardware interrupt to the corresponding client through a virtual interrupt. The serial port device interrupt is handled by the client operating system.

[0099] S5: Device access. The client uses GVA to access the serial port device. First, according to the first stage conversion established in step S3, the GVA is converted to GPA. Then, according to the second stage address conversion established in step S1, the GPA is converted to HPA, thereby accessing the physical address space of the serial port device.

[0100] In one embodiment, Figure 6 1 is a flow chart of step S5 in the method of directly connecting a serial device to a client computer according to the present invention. Figure 6 As shown, step S5 specifically includes the following steps S51-S55.

[0101] S51: The client user state access maps the client physical address GPA of the serial port device to the client virtual address GVA. After the mapping is completed, the client virtual address GVA in the user state can be used to read and write the serial port device address space directly in the user state.

[0102] S52: The client kernel state access maps the client physical address GPA of the serial port device to the kernel state virtual address GVA. After the mapping is completed, the kernel state client virtual address GVA can be used directly in the kernel state to read and write the serial port device address space.

[0103] S53: Establishing a GVA→GPA address translation page table according to step S3, and implementing GVA→GPA translation through the page table;

[0104] S54: Establish a GPA→HPA address translation page table according to step S1, and implement GPA→HPA translation through the page table;

[0105] S55: Use the host physical address HPA of the serial port device to access the serial port device address space.

[0106] In this embodiment, a two-stage address translation of the serial port device address space GVA→GPA→HPA is established through steps S1 and S3. The client can directly access the serial port device address space using the GVA address in kernel mode or user mode.

[0107] The method of directly communicating a serial device with a client based on the ARM64 architecture, implemented based on steps S1 to S5, has the following advantages:

[0108] Avoid using a virtual machine monitor to emulate serial devices or forwarding client data to physical serial devices through the host. Instead, support passing non-PCI serial devices directly to the client. The client can directly access the serial devices and handle serial device interrupts. This is designed to enable direct client access to serial devices in an efficient, low-latency, and secure manner, thereby improving the performance, reliability, and security of accessing specific serial devices in a virtualized environment.

[0109] The two-stage address translation mechanism provided by the ARM64 architecture is adopted. The first stage of address translation realizes the conversion of the client serial port virtual address to the client serial port physical address, and the second stage of address translation realizes the conversion of the client serial port physical address to the host serial port physical address, thereby realizing direct access to the serial port device in the client.

[0110] Using the virtual interrupt mechanism provided by the ARM64 architecture, after the host receives the interrupt generated by the serial port device, it forwards the physical interrupt generated by the serial port device to the specified client by sending a virtual interrupt to the specified client. The client handles the serial port device interrupt. The client can directly access the serial port device address space and handle the serial port device interrupt, avoiding data forwarding and interrupt processing through the host, ensuring the security, efficiency and reliability of serial port device access.

[0111] It should be pointed out that although the various 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 have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.

[0112] Thus far, the technical solutions of the present invention have been described in conjunction with 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 may make equivalent changes or substitutions to the relevant technical features, and the technical solutions after such changes or substitutions will fall within the scope of protection of the present invention.

Claims

1. A method for directly connecting a serial port device to a client based on the ARM64 architecture, characterized in that: The following steps are involved: S1: Establish a mapping from the client physical address GPA of the serial port device to the host physical address HPA according to the physical address space occupied by the serial port device; S2: Set up the hypervisor interrupt vector table and establish a mapping relationship between the serial port device hardware interrupt and the client virtual interrupt. When the serial port device generates an interrupt, the host sends a virtual interrupt to the corresponding client according to the mapping relationship. S3: Establish a mapping between the client virtual address GVA of the serial device and the client physical address GPA; S4: After the serial port device generates a hardware interrupt, the serial port interrupt is sent to the designated processor through the interrupt controller. After the host machine's hypervisor layer and the host machine's operating system kernel layer receive the interrupt, the serial port interrupt is forwarded to the corresponding client according to the mapping relationship; S5: When the client uses the client virtual address GVA to access the serial port device, the client virtual address GVA is converted into the client physical address GPA according to the established mapping relationship, and then converted into the host physical address HPA, thereby accessing the physical address space of the serial port device; The step S1 comprises: The virtual machine monitor at the host application layer allocates the corresponding client physical address GPA to the serial port device; Enter the kernel layer of the host operating system through system calls, and obtain the host physical address HPA and physical resource size of the serial port device through the device tree; The client physical address GPA, host physical address HPA and physical resource size are used as entry parameters to enter the host's Hypervisor layer through HVC call; The host's Hypervisor layer constructs page table entries at all levels of the ARM64 architecture's second-stage address translation to implement address mapping from the guest physical address GPA to the host physical address HPA.

2. A method for directly communicating a serial port device with a client based on an ARM64 architecture according to claim 1, characterized in that: The step S2 comprises: Enter the Hypervisor through HVC call and configure the corresponding interrupt vector table; Get the physical interrupt number of the serial port device through the device tree; Assign a unique corresponding virtual interrupt number to the physical interrupt number; Use the virtual interrupt number to register the host serial port interrupt handler.

3. The method of directly communicating a serial port device with a client based on the ARM64 architecture according to claim 1, characterized in that: The step S3 comprises: Get the client serial port device physical address GPA assigned by the virtual machine monitor to the serial port device; Determine whether it is user mode access or kernel mode access; If it is a user-mode access, the client operating system kernel layer searches for free address space in the process's user address space and allocates a user-mode virtual address (GVA) of the specified size according to the request; If it is kernel-mode access, the client operating system kernel layer searches for free address space in the process's kernel address space and allocates a kernel-mode virtual address (GVA) of the specified size based on the request. According to the obtained serial port device client physical address GPA and the allocated client virtual address GVA, the page table entries of each level of the first stage address translation of the ARM64 architecture are constructed to realize the conversion of the client virtual address GVA to the client physical address GPA.

4. The method of directly communicating a serial port device with a client based on the ARM64 architecture according to claim 3, characterized in that: If the serial port address space is mapped to the user-mode GVA through the mmap system call, it is definitely user-mode access. If the serial port address space is mapped to the kernel-mode GVA through the ioremap kernel interface, it is definitely kernel-mode access.

5. The method of directly communicating a serial port device with a client based on the ARM64 architecture according to claim 1, wherein: The step S4 comprises: When a serial port device generates a hardware interrupt, the hardware disables the interrupt and sends the hardware interrupt to the designated processor through the interrupt controller. The processor then enters the interrupt handler at the host hypervisor layer. The interrupt handler of the host hypervisor layer does not handle the serial port interrupt, calls guest_exit to exit the guest execution, and returns to the host operating system kernel layer execution; After returning to the host operating system kernel layer, set the interrupt vector table entry to the interrupt vector table entry of the host operating system; The kernel layer of the host operating system re-enables interrupts, and the serial port interrupt is triggered again through the interrupt controller, which then sends the serial port interrupt to the designated processor. The host operating system kernel layer jumps to the interrupt handler according to the set interrupt vector table, and in the interrupt handler, a virtual interrupt is injected into the specified client; The injected virtual interrupt is written into the interrupt controller hardware register and the client resumes execution; The guest will receive the virtual interrupt after resuming execution.

6. The method of directly communicating a serial device with a client based on the ARM64 architecture according to claim 1, wherein: The step S5 comprises: The client user state access maps the client physical address GPA of the serial port device to the client virtual address GVA. After the mapping is completed, the client virtual address GVA in the user state can be used directly in the user state to read and write the serial port device address space; The client kernel state access maps the client physical address GPA of the serial port device to the kernel state virtual address GVA. After the mapping is completed, the kernel state client virtual address GVA can be used directly in the kernel state to read and write the serial port device address space; According to the ARM64 architecture's first stage address translation, the client virtual address GVA is converted to the client physical address GPA. According to the ARM64 architecture's second-stage address translation, the client physical address GPA is converted to the host physical address HPA. Use the host physical address (HPA) of the serial device to access the serial device address space.

Citation Information

Patent Citations

  • System and interrupt processing method

    CN113934504A

  • DPU (Data Processing Unit)-based RDMA (Remote Direct Memory Access) virtualized memory address conversion and data transmission method and system

    CN119829480A