A method and system for implementing peripheral debugging based on Hypervisor
The register operation of Guest OS is intercepted through Hypervisor, which solves the peripheral conflict problem caused by abnormal restart of Guest OS, realizes intuitive debugging of Guest OS peripherals, simplifies the debugging process, and ensures the normal operation of the peripherals.
Patent Information
- Application Number
- CN202111219880.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-20
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2041-10-20
AI Technical Summary
In a Hypervisor-based multi-system environment, Guest OS abnormal restart causes peripheral driver conflicts and cannot work properly. The existing technology lacks effective method for debugging peripheral implementation to solve this problem.
The register operation of Guest OS is intercepted through Hypervisor, recording and printing peripheral debugging information is recorded and printed, and the debugging of Guest OS peripherals is realized, independent of the normal startup status of Guest OS.
It realizes intuitive debugging of Guest OS peripherals, avoids peripheral conflicts caused by restart, simplifies peripheral read and write operations, and improves the intuitiveness and convenience of debugging.
Smart Images

Figure CN113961308B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and system for implementing peripheral debugging based on a Hypervisor. Background Art
[0002] Hypervisor is called Virtual Machine Monitor, which is an operating system that runs other operating systems. Hypervisor runs as an intermediate layer operating system between physical hardware and operating system, allowing multiple operating systems and applications to share a set of basic physical hardware. The operating system running on the Hypervisor is called the guest operating system (Guest OS).
[0003] Hypervisor has been used in the server field before, but with the development of embedded systems, it is considered to be the next frontier of embedded systems to solve the decision-making difficulties of the limited resources of embedded systems in the increasingly complex application scenarios. Hypervisor provides the flexibility to carry heterogeneous operating systems on the same multi-core processor, and it also implements good reliability and fault control mechanisms to ensure the safe separation between mission-critical, hard real-time applications and general-purpose, untrusted user applications. For example, the current smart cockpit of a car uses Hypervisor technology to realize the full LCD instrument display and the central control entertainment system display on a single board at the same time, where the full LCD instrument runs on the Guest OS of Linux or QNX, and the central control entertainment system runs on the Guest OS of Android.
[0004] At present, common Guest OS will provide peripheral debugging methods in the operating system itself, such as printing debugging information through printk, realizing communication between Linux kernel space and user space through proc file system, exporting kernel data structures and their attributes to users through sysfs, etc. Engineers can debug Guest OS peripherals through these debugging information.
[0005] In a multi-system environment based on Hypervisor, you can debug peripherals by entering the Guest OS. However, in the actual debugging process, problems such as peripheral driver writing logic may occur, causing the system to crash abnormally, and you cannot enter the Guest OS to view the peripheral status and debugging information.
[0006] Currently, most device drivers for Guest OS do not take virtualization scenarios into consideration. In non-virtualization scenarios, an abnormal restart will cause the system to power on again. In a multi-system environment based on Hypervisor, when Guest OS restarts abnormally, Hypervisor will not power on the entire system again. Because Guest OS peripherals are not powered on again, conflicts will occur between operations on peripherals before and after the restart, causing the peripherals to not work properly. During a normal restart, the Guest OS peripheral driver will perform a shutdown operation on the peripheral, and after the system restarts, the peripheral can work normally. Therefore, when Guest OS restarts abnormally, Hypervisor needs to execute the shutdown operation of the Guest OS peripheral driver. Because the shutdown operations of different peripherals are completely different and the code is complicated, it is very difficult to simplify it to the peripheral read and write registers.
[0007] Therefore, at this stage, there is an urgent need to provide a Hypervisor-based peripheral debugging implementation solution to solve the above problems. Summary of the invention
[0008] The purpose of the present invention is to provide a method for debugging peripherals based on a Hypervisor. When running on a Hypervisor, the method records the operation of the Guest OS peripheral registers by intercepting the registers of the Guest OS transparently transmitted peripherals, thereby facilitating the debugging of the Guest OS peripherals.
[0009] In order to achieve the above object, the technical solution adopted by the present invention to solve the technical problem is as follows:
[0010] A method for debugging peripherals based on a Hypervisor comprises the following steps:
[0011] S1: Hypervisor creates several Guest OSs based on user configuration;
[0012] S2: Hypervisor parses the Guest OS resource file;
[0013] S3: The Hypervisor starts the Guest OS, enters the Guest OS and runs the corresponding services. In addition, the Guest OS generates register read and write operations for the debugging peripherals.
[0014] S4: The Hypervisor determines the switch status of the debugging peripheral device; if the switch status is off, the process ends; otherwise, the process continues to step S5;
[0015] S5: Determine whether the currently operated peripheral register is within the range specified in the Guest OS resource file; if not, end the process; otherwise, the Hypervisor intercepts the operation of the Guest OS on the peripheral register and continues to execute step S6;
[0016] S6: The Hypervisor prints the operation of the Guest OS on the peripheral register; wherein, it parses the operation of the Guest OS on the register, obtains the debugging information of the debugged peripheral, and outputs the debugging information to the log information or prints it to the serial port.
[0017] According to a specific embodiment, in step S6 of the method for upgrading an embedded multi-system based on Hypervisor of the present invention, the step of the Hypervisor printing the operation of the Guest OS on the peripheral register includes:
[0018] S601: The Hypervisor obtains the Guest OS ID for the operation on the peripheral;
[0019] S602: The Hypervisor obtains the Guest OS peripheral name;
[0020] S603: The Hypervisor prints the operation of the Guest OS on the peripheral register, and the printing format includes: <Guest OSID><Guest OS peripheral name>: Write Reg:0x0,Val:0x0;
[0021] Based on the same inventive concept, the present invention also provides a system for implementing a debugged peripheral based on Hypervisor, which includes:
[0022] Guest OS resource file parsing module, which is used to parse the debugged peripherals and intercepted register operations specified in the Guest OS resource file;
[0023] Peripheral register interception module, which is used to intercept the corresponding operation of the Guest OS on the register by parsing the Guest OS resource file;
[0024] Debugging information printing module, which is used to parse the operation of the Guest OS on the register, obtain the debugging information of the debugged peripheral, and output the debugging information to the log information or print it to the serial port.
[0025] In summary, compared with the prior art, the beneficial effects of the present invention are:
[0026] The present invention is an embedded multi-system upgrade method based on Hypervisor. The method firstly creates a plurality of Guest OSes according to user configuration; then, the Hypervisor parses the Guest OS resource file; then, the Hypervisor starts the Guest OS, enters the Guest OS to run and executes corresponding services; the Guest OS generates register read and write operations for the debugging peripherals; then, the Hypervisor determines the switch state of the debugging peripherals; then, the Hypervisor intercepts the Guest OS peripheral registers configured by the resource file; finally, the Hypervisor prints the operation of the Guest OS on the peripheral registers; therefore, the present invention does not rely on the normal startup of the Guest OS in the process of debugging the peripherals, and can more intuitively and conveniently see the operation process of the Guest OS on the peripheral registers. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is shown as a schematic diagram of the process of the present invention.
[0028] Figure 2 Shown is a data flow diagram of the present invention.
[0029] Figure 3 Shown is a schematic structural diagram of the present invention. DETAILED DESCRIPTION
[0030] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. However, this should not be understood as the scope of the above subject matter of the present invention being limited to the following embodiments, and all technologies realized based on the content of the present invention belong to the scope of the present invention.
[0031] like Figure 1 and Figure 2 As shown, the present invention is based on the Hypervisor to debug the peripheral implementation method, which includes the following steps:
[0032] S1: Hypervisor creates several Guest OSs based on user configuration;
[0033] S2: Hypervisor parses the Guest OS resource file;
[0034] S3: The Hypervisor starts the Guest OS, enters the Guest OS and runs the corresponding services. In addition, the Guest OS generates register read and write operations for the debugging peripherals.
[0035] S4: Hypervisor determines the switch status of the debugging peripheral;
[0036] S5: The Hypervisor intercepts the operation records of the Guest OS on the peripheral registers configured in the Guest OS resource file;
[0037] S6: The Hypervisor prints the operations of the Guest OS on the peripheral registers. Among them, the Hypervisor obtains the debugging information of the debugged peripherals by parsing the operations of the Guest OS on the peripheral registers, and outputs the debugging information to the log information or prints it to the serial port.
[0038] Moreover, in step S6 of the method for upgrading an embedded multi-system based on the Hypervisor according to the present invention, the step of the Hypervisor printing the operations of the Guest OS on the peripheral registers includes:
[0039] S601: The Hypervisor obtains the Guest OS ID of the operation on the peripheral;
[0040] S602: The Hypervisor obtains the Guest OS peripheral name;
[0041] S603: The Hypervisor prints the operations of the Guest OS on the peripheral registers, and the printing format includes: <Guest OSID><Guest OS peripheral name>: Write Reg: 0x0, Val: 0x0.
[0042] Based on the same inventive concept, the present invention also provides a system for implementing debugged peripherals based on the Hypervisor, as Figure 3 shown, the system includes:
[0043] Guest OS resource file parsing module, which is used to parse the debugged peripherals and intercepted register operations specified in the Guest OS resource file;
[0044] Peripheral register interception module, which is used to intercept the corresponding operations of the Guest OS on the registers by parsing the Guest OS resource file;
[0045] Debugging information printing module, which is used to parse the operations of the Guest OS on the registers, obtain the debugging information of the debugged peripherals, and output the debugging information to the log information or print it to the serial port.
[0046] The above are only the preferred embodiments of the present invention, and are not intended to limit the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for implementing a peripheral debugging based on a Hypervisor, characterized in that: Including the following steps: S1: The Hypervisor creates several Guest OSs according to user configuration; S2: The Hypervisor parses the Guest OS resource file; S3: The Hypervisor starts the Guest OS, enters the Guest OS to run and execute corresponding services to generate register read and write operations on the debug peripheral; S4: The Hypervisor judges the switch state of the debug peripheral; wherein, if the switch state is off, it ends, otherwise it continues to execute step S5; S5: Judge whether the peripheral register being operated is within the range specified in the Guest OS resource file; if it is not within the specified range, it ends, otherwise the Hypervisor intercepts the operation of the Guest OS on the peripheral register and continues to execute step S6; S6: The Hypervisor prints the operation of the Guest OS on the peripheral register; wherein, it analyzes the operation of the Guest OS on the register, obtains the debug information of the debug peripheral, and outputs the debug information to the log information or prints it to the serial port.
2. The method for implementing a peripheral debugging based on a Hypervisor according to claim 1, characterized in that: In step S6, the steps for the Hypervisor to print the operation of the Guest OS on the peripheral register include: S601: The Hypervisor obtains the Guest OS ID for the peripheral operation; S602: The Hypervisor obtains the Guest OS peripheral name; S603: The Hypervisor prints the operation of the Guest OS on the peripheral register, and the printing format includes: <Guest OS ID><Guest OS peripheral name>: Write Reg:0x0, Val:0x0.
3. A debug peripheral implementation system based on Hypervisor, used to implement the debug peripheral implementation method based on Hypervisor as described in any one of claims 1-2, including: A Guest OS resource file parsing module, used to parse the debug peripheral and the intercepted register operation specified in the Guest OS resource file through the Hypervisor; A peripheral register interception module, used to parse the Guest OS resource file through the Hypervisor to intercept the corresponding Guest OS operation on the register; A debug information printing module, used to parse the operation of the Guest OS on the register through the Hypervisor, obtain the debug information of the debug peripheral, and output the debug information to the log information or print it to the serial port.
