Search

CN-115292077-B - Kernel exception handling method and system

CN115292077BCN 115292077 BCN115292077 BCN 115292077BCN-115292077-B

Abstract

The embodiment of the application relates to the field of kernel exception handling and discloses a kernel exception handling method and a kernel exception handling system. The kernel exception handling system comprises electronic equipment, a network console and a remote host, wherein the electronic equipment is in communication connection with the network console and the remote host, and the network console is in communication connection with the remote host. In the application, when the kernel crashes in the operating system of the electronic equipment, the electronic equipment sends the context information of the kernel crashes to the remote host and starts the network console, and the remote host interacts with the network console after receiving the context information, thereby obtaining a corresponding crash log, accurately analyzing the reason of the kernel crashes, avoiding the need of storing Vmcore files in large capacity and saving the requirement of storing Vmcore files.

Inventors

  • LI GUOHUI

Assignees

  • 深圳市道通智能汽车有限公司

Dates

Publication Date
20260505
Application Date
20220713

Claims (9)

  1. 1. The kernel exception handling method is characterized by being applied to a kernel exception handling system, wherein the system comprises electronic equipment, a network console and a remote host, the electronic equipment is in communication connection with the network console and the remote host, and the network console is in communication connection with the remote host, and the method comprises the following steps: When the operating system of the electronic equipment is in kernel collapse, the electronic equipment utilizes a polling mechanism to send the context information of the kernel collapse to the remote host, and the electronic equipment starts the network console; The remote host generates a debugging command after receiving the context information by using a polling mechanism, and sends the debugging command to the network console by using the polling mechanism, wherein the debugging command comprises a command for reading memory data or a command for reading a register; The network console receives a debugging command sent by the remote host by using a polling mechanism, and sends a crash log corresponding to the kernel crash to the remote host according to the debugging command; and after receiving the crash log, the remote host analyzes the kernel crash reason.
  2. 2. The method according to claim 1, wherein the method further comprises: The electronic equipment judges whether the current instruction abnormality is a user state instruction abnormality or not; If the current instruction exception is not the user state instruction exception, the electronic equipment determines that the current instruction exception is a kernel state instruction exception; The electronic device invokes an interrupt function to shut down the interrupt that occurred the kernel mode exception.
  3. 3. The method of claim 1, wherein after the remote host sends the debug command to the network console, the method further comprises: The electronic equipment acquires a crash log in a kernel log buffer area; The electronic device sends the crash log to the network console using a polling mechanism.
  4. 4. The method of claim 1, wherein the remote host, upon receiving the crash log, analyzes a kernel crash cause comprising: And after receiving the crash log, the remote host uses an exception analyzer to call a crash tool to analyze the crash log so as to obtain a kernel crash reason.
  5. 5. The method of claim 4, wherein after the remote host receives the crash log, the remote host uses an exception analyzer to invoke a crash tool to analyze the crash log to obtain a kernel crash cause, comprising: The remote host acquires the first instruction content and the corresponding address of the abnormal instruction according to the crash log; The remote host uses an exception analysis program to call a crash tool to judge whether the instruction with exception is a memory access instruction or not; if the remote host judges that the abnormal instruction is a memory access instruction, the remote host judges whether the memory access address corresponding to the abnormal instruction is abnormal; if the memory access corresponding to the abnormal instruction is abnormal, the remote host determines the data access abnormality and tracks the reason of the data access abnormality.
  6. 6. The method of claim 5, wherein the method further comprises: If the remote host judges that the abnormal instruction is not a memory access instruction, the remote host acquires second instruction content from the abnormal analysis program according to an address corresponding to the abnormal instruction; the remote host judges whether the second instruction content is consistent with the first instruction content; if the first instruction content and the second instruction content are different, the remote host determines that the memory of the instruction with the exception is modified; the remote host analyzes the reasons for the modified memory of the instruction with exception.
  7. 7. The method of claim 6, wherein after the address exception corresponding to the instruction if the exception occurred or after the remote host determines that the memory of the instruction if the exception occurred was modified, the method further comprises: And the remote host acquires memory data from the network console, wherein the memory data corresponds to the memory access abnormality reason or the memory modified reason.
  8. 8. The kernel exception handling system is characterized by comprising electronic equipment, a network console and a remote host, wherein the electronic equipment is in communication connection with the network console and the remote host, and the network console is in communication connection with the remote host, and the kernel exception handling system comprises the electronic equipment, the network console and the remote host, wherein: The electronic equipment is used for sending context information of kernel collapse to the remote host by utilizing a polling mechanism when the operating system of the electronic equipment is in kernel collapse, and the electronic equipment starts the network console; The remote host is used for generating a debugging command after receiving the context information by using a polling mechanism, and sending the debugging command to the network console by using the polling mechanism, wherein the debugging command comprises a command for reading memory data or a command for reading a register; The network console is used for receiving a debugging command sent by the remote host by utilizing a polling mechanism, and sending a crash log corresponding to the kernel crash to the remote host according to the debugging command; the remote host is further configured to analyze a kernel crash cause after receiving the crash log.
  9. 9. The system of claim 8, wherein the electronic device is further configured to: Judging whether the current instruction abnormality is user state instruction abnormality or not; If the current instruction exception is not the user state instruction exception, determining that the current instruction exception is a kernel state instruction exception; an interrupt function is called to shut down interrupts that are abnormal in kernel mode.

Description

Kernel exception handling method and system Technical Field The embodiment of the application relates to the technical field of kernel processing, in particular to a kernel exception processing method and system. Background Currently, in an electronic device, for example, a computer is installed with a Linux operating system, which may be other types of operating systems, for example, a Linux operating system is taken as an example, and an operating system with a kernel crash refers to a kernel crash of the Linux operating system, and of course, may be other types of operating systems and kernels. Kernel crashes, also known as kernel exceptions, refer to the fact that the kernel has bumped unrecoverable errors, such as instruction memory errors, instruction content errors, etc. When a kernel exception occurs, the system typically requires a reboot to recover. At present, the existing analysis of the cause of the kernel crash generally analyzes a memory dump file Vmcore generated by a memory dump mechanism Kdump of the kernel, but the mode has higher requirement on the memory. Disclosure of Invention The embodiment of the application aims to provide a kernel exception handling method and a system, which are used for switching to a network console in a kernel mode when kernel exception occurs, wherein the network console interacts with a remote host, analyzing the reason of kernel crash, and saving the requirement of storing Vmcore files without storing Vmcore files in a large capacity. In order to solve the technical problems, the embodiment of the application adopts the following technical scheme: In a first aspect, an embodiment of the present application provides a method for processing kernel exception, which is applied to a kernel exception processing system, where the system includes an electronic device, a network console and a remote host, where the electronic device is communicatively connected to the network console and the remote host, and the network console is communicatively connected to the remote host, and the method includes: when the operating system of the electronic equipment has kernel collapse, the electronic equipment sends context information of the kernel collapse to the remote host, and the electronic equipment starts the network console; after receiving the context information, the remote host generates a debugging command and sends the debugging command to the network console; the network console receives a debugging command sent by the remote host, and sends a crash log corresponding to the kernel crash to the remote host according to the debugging command; and after receiving the crash log, the remote host analyzes the kernel crash reason. In some embodiments, the method further comprises: The electronic equipment judges whether the current instruction abnormality is a user state instruction abnormality or not; If the current instruction exception is not the user state instruction exception, the electronic equipment determines that the current instruction exception is a kernel state instruction exception; The electronic device invokes an interrupt function to shut down the interrupt that occurred the kernel mode exception. In some embodiments, the electronic device utilizes a polling mechanism to send context information of the kernel crash to the remote host, the remote host utilizes the polling mechanism to receive the context information, and the network console utilizes the polling mechanism to receive a debug command sent by the remote host. In some embodiments, after the remote host sends the debug command to the network console, the method further comprises: The electronic equipment acquires a crash log in a kernel log buffer area; The electronic device sends the crash log to the network console using a polling mechanism. In some embodiments, after the remote host receives the crash log, analyzing a kernel crash cause includes: And after receiving the crash log, the remote host uses an exception analyzer to call a crash tool to analyze the crash log so as to obtain a kernel crash reason. In some embodiments, after receiving the crash log, the remote host uses an exception analyzer to call a crash tool to analyze the crash log to obtain a kernel crash cause, including: The remote host acquires the first instruction content and the corresponding address of the abnormal instruction according to the crash log; The remote host uses an exception analysis program to call a crash tool to judge whether the instruction with exception is a memory access instruction or not; if the remote host judges that the abnormal instruction is a memory access instruction, the remote host judges whether the memory access address corresponding to the abnormal instruction is abnormal; if the memory access corresponding to the abnormal instruction is abnormal, the remote host determines the data access abnormality and tracks the reason of the data access abnormality. In some embodiments, the method