Abnormality processing method and device and storage medium

By obtaining the address in the log file and fixing, it solves the problem of restarting problems caused by the specific cause of electronic equipment when jumping problems, and realizes the improvement of system stability and user experience.

CN119376986AActive Publication Date: 2025-01-28HONOR DEVICE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202310927894.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-26
Publication Date
2025-01-28
Estimated Expiration
2043-07-26

AI Technical Summary

Technical Problem

When existing electronic devices have jump problems, they cannot locate specific reasons, resulting in the restart of the entire machine and affecting the system stability and user experience.

Method used

Provide an abnormal processing method. By obtaining the address in the log file, repair the address of the unbridled alignment, and repair the bitflip problem on the preset comparison specialty to avoid the equipment restart.

Benefits of technology

The analysis and repair of the jumping problem of electronic equipment is realized, the equipment is restarted, and the stability of the whole machine is guaranteed and the user experience is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119376986A_ABST
    Figure CN119376986A_ABST
Patent Text Reader

Abstract

The invention provides an exception handling method and device and a storage medium. According to the method, in the process of accessing data corresponding to a first address according to a first access request of a first application, when it is determined that a kernel crashes due to exceptions of a preset type at present, the currently accessed first address is obtained from a log file, and when it is determined that an initial address of the first address is not subjected to four-byte alignment, the first address is accessed to the log file; by repairing the initial address of the first address into the four-byte aligned initial address, normal data access can be performed without restarting the electronic equipment, so that the stability of the whole machine / system is guaranteed, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to an exception handling method, device and storage medium. Background Art

[0002] During the operation of electronic devices, a jump problem may occur due to device abnormality, that is, one or more bits of the address / data to be accessed are flipped. Therefore, when a jump problem occurs, the original business logic or the address / data to be accessed is usually changed.

[0003] For commercial electronic devices, there is no fulldump file in such electronic devices. Therefore, when a jump problem occurs, the electronic device cannot locate the specific cause of the jump and can only report a panic error (a kernel error), which causes the entire device to restart. Summary of the invention

[0004] The present application provides an exception handling method, device and storage medium, which aim to analyze and handle the jump problem of commercial electronic devices without increasing hardware costs, and then repair the abnormal problem on the spot according to the determined analysis results, so that the electronic device will not restart, thereby ensuring the stability of the whole machine / system and improving the user experience.

[0005] In a first aspect, the present application provides an exception handling method, which is applied to an electronic device. The method includes: obtaining a first access request of a first application; accessing data of a first address based on the first access request, and in the process of accessing the data of the first address, a kernel crash occurs based on an exception of a preset type; obtaining the first address from a log file, and repairing the first address; wherein the starting address of the first address is not four-byte aligned; based on the repaired first address, accessing the data of the first address; wherein the starting address of the repaired first address is four-byte aligned.

[0006] The preset type of exception is, for example, the DAbt exception or instruction exception mentioned in the following embodiments.

[0007] The first address is the address corresponding to the data accessed by the electronic device when the kernel crash occurs. Since the address may be abnormal, it can also be understood as an abnormal address, such as the abnormal address mentioned in the following embodiment. Subsequently, the second address to the tenth address can all be understood as an abnormal address.

[0008] Regarding the judgment logic and corresponding scenarios of the address read from the log file being the first address, reference may be made to steps 301 to 305 and step 320 in the following embodiments, which will not be described in detail here.

[0009] The repair of the first address is specifically to align the starting address of the first address with four bytes. For details about the repair of the first address, please refer to Fig. 6A and Figure 6B ,as well as Fig. 6A and Figure 6B The description of the corresponding embodiments will not be repeated here.

[0010] Among them, the first access request, and the access requests involved in subsequent implementation aspects, such as the second access request to the tenth access request, can be generated when the user clicks on the function control of the first application or triggers the interface to jump during the operation of the first application.

[0011] The first application may be any application program installed on the electronic device.

[0012] In this way, in the process of accessing the data corresponding to the first address according to the first access request of the first application, when it is determined that the kernel crashes due to an exception of a preset type, by obtaining the first address currently being accessed from the log file, and when it is determined that the starting address of the first address is not four-byte aligned, by repairing the starting address of the first address to a four-byte aligned starting address, normal data access can be performed without restarting the electronic device, thereby ensuring the stability of the entire machine / system and improving the user experience.

[0013] According to the first aspect, the method also includes: obtaining a second access request of the first application; accessing data of the second address based on the second access request, and in the process of accessing the data of the second address, a kernel crash occurs based on an exception of a preset type; obtaining the second address from a log file, and repairing the second address; wherein the starting address of the second address is four-byte aligned, and the preset bit position of the second address contains N 0s, where N is an integer greater than 0 and less than 3; based on the repaired second address, accessing the data of the second address; wherein the starting address of the repaired second address is four-byte aligned, and the preset bit position does not contain 0.

[0014] Among them, in some possible implementations, the abnormal address read from the log file, such as the second address, is specifically a binary address, that is, an address that only includes 0 and 1, and the binary address can be an address occupying 64 bits. When the second address occupies an address occupying 64 bits, the preset bits are, for example, the high bits mentioned in the following embodiment, that is, the first 24 bits.

[0015] For the contents of the high bits of a normal binary address, enter Fig. 7A As shown, all are 1. Therefore, by judging whether there is 0 in the high bit and the number of 0s, it can be determined whether a bitflip occurs in the high bit of the second address.

[0016] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the second address, please refer to steps 301 to 304, steps 306 to 308, and steps 319 and 320 in the following embodiments, which will not be repeated here.

[0017] In this way, in the process of accessing the data corresponding to the second address according to the second access request of the first application, when it is determined that the kernel crashes due to an exception of a preset type, the second address currently being accessed is obtained from the log file, and when it is determined that the starting address of the second address is aligned with four bytes and the preset bit contains 1 or 2 0s, the 0 that appears on the preset bit in the second address is repaired to 1, and the value of the bit that is about to jump is flipped, and normal data access can be performed without restarting the electronic device, thereby ensuring the stability of the entire machine / system and improving the user experience.

[0018] According to the first aspect, or any implementation of the first aspect above, the method further includes: when the data at the second address cannot be accessed based on the repaired second address, the electronic device is restarted.

[0019] For example, if after the 0 on the preset bit position in the second address is repaired to 1, the data still cannot be accessed based on the repaired second address, or the data cannot be accessed normally, then the preset type of exception currently occurs, and the kernel crash is not caused by the Bitflip. Therefore, in order to restore the first application's access to the data as soon as possible, the electronic device needs to be restarted, specifically, a hot start of the entire machine.

[0020] For specific implementation details of this scenario, please refer to steps 301 to 304 and steps 306 to 309 in the following embodiments, which will not be repeated here.

[0021] According to the first aspect, or any implementation of the first aspect above, the method also includes: obtaining a third access request of the first application; accessing data of the third address based on the third access request, and in the process of accessing the data of the third address, a kernel crash occurs based on an exception of a preset type; obtaining the third address from the log file, and repairing the third address; wherein the starting address of the third address is four-byte aligned, and the preset bit position of the third address contains M 0s, and M is an integer greater than or equal to 3; the address of the second register is the same as the address of any register except the first register, the first register is the register corresponding to the third address, and the second register is the upper-level register of the first register; the third address is the address of the data segment, and the instruction corresponding to the third address is a load instruction or a transfer instruction; based on the repaired third address, accessing the data of the third address; wherein the starting address of the repaired third address is four-byte aligned, and the preset bit position does not contain 0.

[0022] Among them, the data segment (also referred to as the data area, static data area, static area) is the data in the program. For the data segment, it can also be understood as a global variable in the program. For the description of the address of the data segment and the non-data segment, please refer to the description part of step 313 in the following embodiment, which will not be repeated here.

[0023] Among them, the first register, the second register, and the third register to the fourth register that appear subsequently are only used to illustrate the register corresponding to the address currently obtained from the log file, and the register associated with the register, and do not identify a certain register.

[0024] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the third address, please refer to steps 301 to 304, step 306, steps 310 to 314, and steps 319 and 320 in the following embodiments, which will not be repeated here.

[0025] In this way, in the process of accessing the data corresponding to the third address according to the third access request of the first application, when it is determined that the kernel crash occurs due to an exception of a preset type, the third address currently being accessed is obtained from the log file, and it is determined whether the third address satisfies the conditions of steps 301 to 304, step 306, steps 310 to 314, and step 319 in the following embodiment. When the conditions are met, it is determined that the problem causing the kernel crash of the electronic device is due to a Bitflip occurring at the third address. In this way, the 0 that appears on the preset bit position where the Bitflip occurs in the third address is repaired to 1, and the value of the bit position that is about to jump is flipped, and normal data access can be performed without restarting the electronic device, thereby ensuring the stability of the entire machine / system and improving the user experience.

[0026] According to the first aspect, or any implementation of the first aspect above, the method also includes: obtaining a fourth access request of the first application; accessing data of the fourth address based on the fourth access request, and in the process of accessing the data of the fourth address, a kernel crash occurs based on an exception of a preset type; obtaining the fourth address from a log file; when the starting address of the fourth address is four-byte aligned, the preset bit of the fourth address contains M 0s, and the address of the fourth register is different from the address of any register except the third register, the electronic device is restarted; wherein M is an integer greater than or equal to 3, the third register is the register corresponding to the fourth address, and the fourth register is the upper-level register of the third register.

[0027] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the fourth address, please refer to steps 301 to 304, step 306, steps 310 to 312, and step 309 in the following embodiments, which will not be repeated here.

[0028] In this way, when it cannot be determined that the cause of the kernel freeze is due to the Bitflip at the fourth address, the electronic device can restore the first application's access to data as soon as possible by re-performing a hot restart of the entire device.

[0029] According to the first aspect, or any implementation of the first aspect above, the method also includes: obtaining a fifth access request of the first application; accessing data of the fifth address based on the fifth access request, and in the process of accessing the data of the fifth address, a kernel crash occurs based on an exception of a preset type; obtaining the fifth address from a log file; when the starting address of the fifth address is four-byte aligned, the preset bits of the fifth address contain M 0s, the address of the sixth register is the same as the address of any register except the fifth register, and the fifth address is not the address of the data segment, the electronic device restarts; wherein M is an integer greater than or equal to 3, the fifth register is the register corresponding to the fifth address, and the sixth register is the upper-level register of the fifth register.

[0030] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the fifth address, please refer to steps 301 to 304, step 306, steps 310 to 313, and step 309 in the following embodiments, which will not be repeated here.

[0031] In this way, when it cannot be determined that the cause of the kernel freeze is due to the Bitflip at the fifth address, the electronic device can restore the first application's access to data as soon as possible by re-performing a hot restart of the entire device.

[0032] According to the first aspect, or any implementation of the first aspect above, the method also includes: obtaining a sixth access request of the first application; accessing data at the sixth address based on the sixth access request, and in the process of accessing the data at the sixth address, a kernel crash occurs based on an exception of a preset type; obtaining the sixth address from a log file; aligning the starting address of the sixth address with four bytes, the preset bits of the fifth address contain M 0s, the address of the eighth register is the same as the address of any register except the seventh register, the sixth address is the address of the data segment, and when the instruction corresponding to the sixth address is not a load instruction or a transfer instruction, the electronic device restarts; wherein M is an integer greater than or equal to 3, the seventh register is the register corresponding to the sixth address, and the eighth register is the upper-level register of the seventh register.

[0033] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the sixth address, please refer to steps 301 to 304, step 306, steps 310 to 314, and step 309 in the following embodiments, which will not be repeated here.

[0034] In this way, when it cannot be determined that the cause of the kernel freeze is due to the Bitflip at the sixth address, the electronic device can restore the first application's access to data as soon as possible by re-performing a hot restart of the entire device.

[0035] According to the first aspect, or any implementation of the first aspect above, the load instruction includes an LDR instruction and an LDUR instruction, and the transfer instruction includes a STR instruction.

[0036] According to the first aspect, or any implementation of the first aspect above, the method also includes: obtaining a seventh access request from the first application; accessing data at the seventh address based on the seventh access request, and in the process of accessing the data at the seventh address, a kernel crash occurs based on an exception of a preset type; obtaining the seventh address from a log file; wherein the starting address of the seventh address is four-byte aligned, the preset bit of the seventh address does not contain 0, the seventh address is the same as the address corresponding to any register except the ninth register, and there is no bit flip problem in the eighth address accessed through the ninth register, and the ninth register is the register corresponding to the seventh address; flipping the value of the bit where the bit flip occurs in the eighth address to obtain a repaired eighth address; based on the repaired eighth address, accessing the data of the eighth address; based on the seventh address, accessing the data of the seventh address.

[0037] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the seventh address, please refer to steps 301 to 304, step 306, step 315, and steps 317 to 319, step 320 in the following embodiments, which will not be repeated here.

[0038] In this way, in the process of accessing the data corresponding to the seventh address according to the seventh access request of the first application, when it is determined that the kernel crash occurs due to an exception of a preset type, the seventh address currently being accessed is obtained from the log file, and it is determined whether the seventh address satisfies the conditions of 301 to step 304, step 306, step 315, and step 317 to step 319, and step 320 in the following embodiment. When the conditions are met, it is determined that the problem causing the kernel crash of the electronic device is because a bitflip occurs at the eighth address of the register corresponding to the seventh address that has been accessed. In this way, the 0 that appears on the preset bit where the bitflip occurs in the eighth address is repaired to 1, and the value of the bit that is about to jump is flipped, and normal data access can be performed without restarting the electronic device, thereby ensuring the stability of the entire machine / system and improving the user experience.

[0039] According to the first aspect, or any implementation of the first aspect above, the method also includes: determining the currently executed assembly instruction based on the stack information in the log file; among the currently executed assembly instructions, searching upward from the last executed assembly instruction, and determining the address corresponding to the found assembly instruction that has accessed the ninth register or the address of the operation corresponding to the assembly instruction as the eighth address.

[0040] Regarding the method for determining the eighth address, reference may be made to step 317 in the following embodiment, which will not be described in detail here.

[0041] According to the first aspect, or any implementation of the first aspect above, the method also includes: obtaining a ninth access request of the first application; accessing data at a ninth address based on the ninth access request, and in the process of accessing data at the ninth address, a kernel crash occurs based on an exception of a preset type; obtaining the ninth address from a log file; when the starting address of the ninth address is four-byte aligned, the preset bit of the ninth address does not contain 0, and the ninth address is not the same as the address corresponding to any register except the tenth register, the electronic device restarts; wherein the tenth register is the register corresponding to the ninth address.

[0042] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the ninth address, please refer to steps 301 to 304, step 306, step 315, and step 316 in the following embodiments, which will not be repeated here.

[0043] In this way, when it cannot be determined that the cause of the kernel freeze is due to the Bitflip at the ninth address, the electronic device can restore the first application's access to data as soon as possible by re-performing a hot restart of the entire device.

[0044] According to the first aspect, or any implementation of the first aspect above, the method also includes: obtaining the tenth access request of the first application; accessing the data of the tenth address based on the tenth access request, and in the process of accessing the data of the tenth address, a kernel crash occurs based on an exception of a preset type; obtaining the tenth address from the log file; aligning the starting address of the tenth address with four bytes, the preset bit of the tenth address does not contain 0, the tenth address is the same as the address corresponding to any register except the eleventh register, and when the address of the accessed eleventh register has a bit flip problem, the electronic device restarts; wherein the eleventh register is the register corresponding to the tenth address.

[0045] Regarding the judgment logic and corresponding scenarios that the address read from the log file is the tenth address, please refer to steps 301 to 304, step 306, step 315, step 317, step 318 and step 316 in the following embodiments, which will not be repeated here.

[0046] In this way, when it cannot be determined that the cause of the kernel freeze is due to the Bitflip at the tenth address, the electronic device can restore the first application's access to data as quickly as possible by re-hot-starting the entire device.

[0047] According to the first aspect, or any implementation of the first aspect above, the log file is obtained from the call stack based on an exception handling function corresponding to an exception of a preset type.

[0048] Exemplarily, in the case of a preset type of exception, such as the DAbt exception or instructional exception described in the following embodiments, the log file obtained when a kernel crash occurs due to the preset type of exception is, for example, obtained from the call stack based on the exception handling function do_mem_abort.

[0049] Regarding the implementation details of determining the preset type of exception that caused the kernel crash, and obtaining exception data from the call stack according to the exception handling function corresponding to the exception, and then obtaining the log file, please refer to steps 301 to 303 in the following embodiment, which will not be repeated here.

[0050] According to the first aspect, or any implementation of the first aspect above, the address obtained from the log file is a binary address, occupying 64 bits, and the preset bits are the first 24 bits.

[0051] According to the first aspect, or any implementation of the first aspect above, restarting the electronic device includes: hot-starting the electronic device, starting a computer program of the electronic device, and loading the first application.

[0052] In a second aspect, the present application provides an electronic device. The electronic device includes: a memory and a processor, the memory and the processor are coupled; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes instructions of the method in the first aspect or any possible implementation of the first aspect.

[0053] The second aspect and any implementation of the second aspect correspond to the first aspect and any implementation of the first aspect respectively. The technical effects corresponding to the second aspect and any implementation of the second aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.

[0054] In a third aspect, the present application provides a computer-readable medium for storing a computer program, wherein the computer program includes instructions for executing the method in the first aspect or any possible implementation of the first aspect.

[0055] The third aspect and any implementation of the third aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the third aspect and any implementation of the third aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here.

[0056] In a fourth aspect, the present application provides a computer program, comprising instructions for executing the method in the first aspect or any possible implementation of the first aspect.

[0057] The fourth aspect and any implementation of the fourth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fourth aspect and any implementation of the fourth aspect can refer to the technical effects corresponding to the above-mentioned first aspect and any implementation of the first aspect, which will not be repeated here.

[0058] In a fifth aspect, the present application provides a chip, the chip comprising a processing circuit and a transceiver pin, wherein the transceiver pin and the processing circuit communicate with each other through an internal connection path, and the processing circuit executes the method in the first aspect or any possible implementation of the first aspect to control the receiving pin to receive a signal and control the sending pin to send a signal.

[0059] The fifth aspect and any implementation of the fifth aspect correspond to the first aspect and any implementation of the first aspect, respectively. The technical effects corresponding to the fifth aspect and any implementation of the fifth aspect can refer to the technical effects corresponding to the first aspect and any implementation of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0060] Figure 1 is a schematic diagram of the hardware structure of an electronic device shown as an example;

[0061] Figure 2 A schematic diagram of the software structure of an electronic device is shown as an example;

[0062] Figure 3 The following is a schematic diagram showing the interaction of functional modules involved in implementing the exception handling method provided by the present application;

[0063] Figure 4 A flowchart of an exception handling method provided by an embodiment of the present application is shown as an example;

[0064] Figure 5 Another flowchart of the exception handling method provided by the embodiment of the present application is exemplarily shown;

[0065] Fig. 6A is a schematic diagram showing an abnormal address that is not four-byte aligned;

[0066] Figure 6B For example, the Fig. 6A Schematic diagram of the address after the abnormal address in is repaired;

[0067] Fig. 7A The diagram is a schematic diagram showing an example of a 64-bit exception address in which the high-order address does not include 0;

[0068] Figure 7B A schematic diagram showing an exemplary 64-bit exception address in which a high-order address includes a 0;

[0069] Figure 7C The schematic diagram is a 64-bit exception address in which the high-order address includes 4 zeros;

[0070] Figure 8 The present invention is a schematic diagram of the structure of an apparatus for implementing the exception handling method provided by the present application. DETAILED DESCRIPTION

[0071] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0072] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0073] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.

[0074] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.

[0075] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "multiple" refers to two or more than two. For example, multiple processing units refer to two or more processing units; multiple systems refer to two or more systems.

[0076] In order to facilitate the understanding of the embodiments of the present application, some terms involved in the embodiments of the present application are explained below to facilitate understanding by those skilled in the art.

[0077] (1) EWP (Early Warning Process)

[0078] Specifically, EWP refers to a method of analyzing the first batch of faulty machines after new products and new models (i.e. different types of electronic equipment) are launched in key areas, identifying the causes of the problems, and implementing improvement measures in subsequent products, so as to reduce the failure rate of the product throughout its life cycle.

[0079] (2)fulldump file

[0080] Before explaining the fulldump file, let's first explain the dump file. The so-called dump file refers to a memory dump file, which can also be called a memory snapshot file (memory image). The dump file contains data such as the module information, thread information, stack call information, and exception information of the program running, which can facilitate system technicians to troubleshoot errors, and then quickly and accurately locate the problem and solve the problem in time.

[0081] The fulldump file is a dump file that contains the complete address space data of a process and a lot of user debugging information.

[0082] Since the dump file / fulldump file is for system technicians to troubleshoot errors. Therefore, only electronic devices that are not on the market (not commercially available, i.e., in the research stage) have open interfaces for outputting dump files / fulldump files. For commercial machines, that is, electronic devices used by a large user group, dump files / fulldump files are generally not generated. Only the last log is saved when an exception occurs. According to the log file, it can usually only be seen that an exception has occurred and the stack corresponding to the exception. However, it is impossible to know the specific data of each traversal in the stack, the source of the data, etc., so it is impossible to know at which link the exception occurred, nor is it possible to know the specific cause of the exception.

[0083] (3) Bitflip Issue

[0084] Specifically, the Bitflip problem in the embodiments of the present application is the bit flip problem, which means that when the program is running, one or more bits of the data / address to be accessed have flipped, for example, the original 0 is flipped to 1, and the original 1 is flipped to 0.

[0085] For example, in some possible implementations, the bits that are bit-flipped may be bits in universal flash storage (UFS / flash).

[0086] For example, in some other possible implementations, the bits that are bit-flipped may also be bits in a double data rate synchronous dynamic random access memory (Double Data Rate, DDR).

[0087] Exemplarily, in some other possible implementations, the bits that are bit-flipped may also be bits of a cache or register in a CPU.

[0088] That is to say, the Bitflip problem may occur in the various memory devices mentioned above. At present, self-repair of the Bitflip problem (that is, when the Bitflip problem occurs, it is automatically repaired without restarting the electronic device) usually requires the electronic device itself to have high-end chips, such as chips that support error correction code (ECC) capabilities, and there are also requirements for the type of CPU. However, even high-end chips with ECC capabilities can currently only handle Bitflip problems that occur in the cache. When Bitflip problems occur in other memory devices, the problem is still solved by restarting the electronic device.

[0089] In addition, it should be noted that Bitflip problems can usually be divided into two types of exceptions: instruction exceptions and data exceptions.

[0090] Regarding instructional exceptions, it specifically refers to a jump in the machine code (instruction) to be executed, resulting in access to undefined instructions.

[0091] For example, the instruction to be run (hexadecimal) is "F85C012A", and its corresponding binary number is "1111 1000 0101 1100 0000 0001 0010 1010". If the first two bits are flipped, the binary number corresponding to the instruction to be run becomes "0011 1000 0101 1100 0000 0001 0010 1010", and the corresponding hexadecimal instruction becomes "385C 012A". If the "385C 012A" instruction is an undefined instruction, it will not be accessed normally, and the process performing the access operation will throw an interrupt. Since the fulldump file cannot be output, the problem cannot be located, and the kernel will print the last part of the log when the exception occurs, which will trigger the restart of the entire machine.

[0092] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0093] In addition, it should be noted that if the machine code (instruction) to be executed changes, but the machine code (instruction) after the change is still a defined instruction. In this case, in actual applications, the instruction after the change can still be accessed, but because the instruction actually accessed is different from the instruction expected to be accessed, the following data anomalies or other anomalies may occur if the program continues to run. In other words, the change of the machine code (instruction) will still cause an anomaly.

[0094] That is to say, as long as the machine code (instruction) to be executed changes, no matter the machine code (instruction) after the change is an undefined instruction or a defined instruction, it will cause an exception.

[0095] The data exception refers to the data abort exception (DAbt). Part of the reason for the data exception may be that the address to be accessed has a jump, resulting in access to an illegal address.

[0096] For example, if the binary number corresponding to the address to be accessed is “1111 1111 1111 11111 11111111100 0000 0011 1001 0111 0111 1001 1001 0010 0000”, if the second and fourth bits are flipped, the binary number corresponding to the address to be accessed becomes “1010 1111 1111 1111 1111 1111 11000000 00111001 0111 0111 1001 1001 0010 0000”, and the address obtained after the jump is “1010 111111111 1111111 1111 1100 0000 0011 "1001 0111 0111 1001 1001 0010 0000" is an illegal address, that is, an address that cannot be accessed. The kernel of the existing electronic device that cannot output the fulldump file will read the exception address and stack information from the call stack and print them after this problem, that is, the DAbt problem, occurs, and trigger the restart of the entire machine.

[0097] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0098] In addition, it should be noted that, specifically in the present application, the Bitflip problem targeted is mainly the Bitflip problem caused by device abnormality (device failure).

[0099] In addition, it should be noted that, specifically in this application, after the Bitflip problem occurs, the whole machine restart is a hot start, not a cold start. That is, the triggered whole machine restart is actually a whole machine software restart, and the hardware is not powered off.

[0100] Specifically, a cold start refers to the start of an electronic device before it is powered on. During a cold start, the electronic device needs to be powered on first, i.e. powered on. A hot start refers to the start of an electronic device after it is powered on, specifically the start of a computer program without powering off, and is usually used when the machine stops abnormally during operation.

[0101] In addition, it should be noted that if the address to be accessed changes, but the address after the change is an accessible legal address, in this case, continuing to run will operate on the data used by other task processes, and then the task process actually corresponding to the data will have an error when accessing it during normal operation, which will cause the entire machine to restart.

[0102] In other words, as long as the address to be accessed changes, no matter whether the address after the change is an illegal address or a legal address, it will cause an exception.

[0103] From the above description, it can be seen that the Bitflip problem may occur in various memory devices, but current electronic devices, especially electronic devices with high-end chips with ECC capabilities, can only handle the Bitflip problem that occurs in the cache. That is, it is impossible to handle the Bitflip problem that occurs in other memory devices.

[0104] In addition, since current commercial electronic devices do not support the output of fulldump files, in commercial scenarios, even if electronic devices that are judged to be faulty are sent to sales outlets or after-sales centers by users, the problem cannot be quickly and accurately located. In other words, it is not easy to delimit and locate EWP problems.

[0105] In view of this, the present application provides an exception handling method, which aims to handle Bitflip problems occurring in various memory devices of electronic devices that do not output fulldump files without increasing hardware costs or limiting CPU types, and after locating the problem, the exception problem can be repaired on the spot so that the electronic device will not restart, thereby ensuring the stability of the entire machine / system and improving the user experience.

[0106] In addition, since the exception handling method provided by the present application can analyze and locate abnormal problems for electronic devices that do not support the output of fulldump files, by applying the exception handling method provided by the present application to commercial electronic devices, the demarcation and positioning of EWP problems can be better achieved, thereby facilitating manufacturers of faulty machines to locate and solve problems faster and more accurately.

[0107] The exception handling method provided in the embodiment of the present application is mainly applied to electronic devices. In some possible implementations, the electronic device may be a commercially available electronic device, that is, an electronic device that does not support outputting a fulldump file. In other possible implementations, the electronic device may also be an electronic device used in the research stage, that is, an electronic device that can output a fulldump file.

[0108] In addition, the electronic devices in this embodiment, whether commercial or in the research stage, can be mobile terminals or non-mobile terminals. Among them, the mobile terminal can be a mobile phone, a laptop computer, a tablet computer, a PDA, a vehicle terminal, a wearable device, an ultra-mobile personal computer (ultra-mobile personal compute, UMPC), a netbook or a personal digital assistant (personal digital assistant, PDA), etc., and the non-mobile terminal can be a personal computer (personal computer, PC), a television, a teller machine, a self-service machine, etc., which are not listed here one by one, and this application does not limit this.

[0109] In order to better understand the technical solution provided by the embodiment of the present application, before describing the technical solution of the embodiment of the present application, the hardware structure of the electronic device to which the embodiment of the present application is applicable is first described in conjunction with the accompanying drawings. Figure 1 Let's take a mobile phone as an example.

[0110] See also Figure 1 The mobile phone 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc.

[0111] Among them, the processor 110 may include one or more processing units, for example: the processor 110 may include an application processor (application processor, AP), a modem processor (Modem), a graphics processor (graphics processing unit, GPU), an image signal processor (image signal processor, ISP), a controller, a video codec, a digital signal processor (digital signal processor, DSP), a baseband processor, and / or a neural-network processing unit (neural-network processing unit, NPU), etc., which are not listed one by one here and the present application does not limit this.

[0112] In addition, the processor 110 may further include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc., which are not listed here one by one, and the present application does not limit this.

[0113] In addition, the processor 110 may also be provided with a memory for storing instructions and data. In some implementations, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0114] Continue to see Figure 1 The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the mobile phone 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function.

[0115] Continue to see Figure 1, the internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the mobile phone 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function, etc. The data storage area can store data created during the use of the mobile phone 100, etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0116] Continue to see Figure 1 The charging management module 140 is used to receive charging input from the charger.

[0117] Continue to see Figure 1 , the power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc.

[0118] Continue to see Figure 1 The wireless communication function of the mobile phone 100 can be realized through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0119] It should be noted that antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in mobile phone 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other implementations, the antenna can be used in combination with a tuning switch.

[0120] Continue to see Figure 1, the mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied on the mobile phone 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some implementations, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some implementations, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0121] Continue to see Figure 1 The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the mobile phone 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering processing, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of the signal, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0122] Continue to see Figure 1 The audio module 170 may include a speaker 170A, a receiver 170B, a microphone 170C, an earphone jack 170D, and the like.

[0123] Continue to see Figure 1 The sensor module 180 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, etc., which are not listed here one by one and are not limited in this application.

[0124] Continue to see Figure 1 The buttons 190 include a power button, a volume button, etc. The motor 191 can generate a vibration prompt. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power changes, messages, missed calls, notifications, etc.

[0125] Continue to see Figure 1 The camera 193 is used to capture static images or videos. The display screen 194 is used to display images, videos, etc.

[0126] The hardware structure of the mobile phone 100 is introduced here. It should be understood that: Figure 1 The illustrated mobile phone 100 is merely an example, and in a specific implementation, the mobile phone 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have a different component configuration. Figure 1 The various components shown in the drawings may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.

[0127] In addition, it should be understood that an operating system, such as a Windows system, an Android system, or an iOS system, etc., needs to be run on the hardware components of the electronic device. Moreover, application programs can also be installed and run on the operating system.

[0128] In addition, it should be understood that no matter which operating system is used, a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture can be used. For ease of explanation, the present application embodiment takes the Android system with a layered architecture as an example to illustrate an electronic device such as Figure 1 The software structure of the mobile phone 100 is shown.

[0129] See also Figure 2 , which is a software structure block diagram of the mobile phone 100 according to an embodiment of the present application.

[0130] like Figure 2 As shown, the layered architecture of the mobile phone 100 divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some implementations, the Android system is divided into five layers, from top to bottom, the application layer / application layer (Applications) belonging to the application part, the framework layer / application framework layer (Application Framework, FWK) belonging to the core part, the runtime (Runtime) and the system library belonging to the bottom layer, the hardware abstract layer (HAL) and the Linux kernel (Linux Kernel) layer.

[0131] The application layer can include a series of application packages. Figure 2 As shown, the application package may include camera, game, video, live broadcast and other applications, which are not listed here one by one and are not limited in this application.

[0132] The framework layer can provide application programming interfaces (APIs) and programming frameworks for applications in the application layer. In some implementations, these programming interfaces and programming frameworks can be described as functions. Figure 2 As shown, the framework layer may include functions such as content provider, window manager, resource manager, view system, etc., which are not listed here one by one and are not limited in this application.

[0133] The content provider is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone book, etc., which are not listed here and are not limited by this application.

[0134] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.

[0135] Among them, the resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc., which are not listed here one by one and this application does not impose any restrictions on this.

[0136] The view system includes visual controls, such as controls for displaying text and controls for displaying pictures. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text notification icon can include a view for displaying text and a view for displaying pictures.

[0137] In addition, it should be understood that in other possible implementations, the functional modules in the framework layer can also be represented as services or frameworks, such as the window manager can be represented as a window management service, the view system can be represented as a control framework, etc. This embodiment does not limit this.

[0138] Continue to see Figure 2 , exemplarily, the runtime, specifically the Android runtime (Android Runtime) may include a core library and a virtual machine, which is mainly responsible for the scheduling and management of the Android system.

[0139] The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.

[0140] Continue to see Figure 2 Exemplarily, the system library may include multiple functional modules, such as a surface manager, a media library, a three-dimensional (3D) graphics processing library (such as OpenGL ES), a two-dimensional (2D) graphics engine (such as SGL), etc.

[0141] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports multiple commonly used audio and video format playback and recording, as well as static image files. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PnG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing.

[0142] In addition, it can be understood that the 2D graphics engine mentioned above is a drawing engine for 2D drawing.

[0143] Continue to see Figure 2 For example, the HAL layer is an interface layer between the operating system kernel (kernel layer) and the hardware circuit. Its purpose is to isolate the FWK from the kernel so that Android does not rely too much on the kernel, so that the development of FWK can be carried out without considering the driver.

[0144] Continue to see Figure 2 For example, the HAL layer may include various interfaces, such as audio and video interface, GPS interface, call interface, WiFi interface, etc., which are not listed here one by one and are not limited in this application.

[0145] Continue to see Figure 2 , exemplary, the kernel layer in the Android system is a layer between hardware and software. The kernel layer may include various processes / threads, interrupt handling modules, exception handling modules, etc.

[0146] Among them, the various processes / threads included in the kernel layer can be task processes / threads corresponding to various application programs, etc.

[0147] Among them, the interrupt handling module and the exception handling module can also be understood as two functional functions, or two processes for implementing this case.

[0148] Specifically, in the exception handling method provided in the embodiment of the present application, no matter whether a problem occurs in the application layer or a Bitflip problem occurs in the bottom layer, the process where the exception occurs will first throw an interrupt, and then the interrupt handling module in the kernel will receive the interrupt information, and then call the exception handling module through the interrupt vector table (or notify the exception handling module through the interrupt vector table), so that the exception handling module can call the corresponding exception handling function, determine the virtual address (exception address) where the exception occurs and the corresponding stack information, and then read the exception address and stack information from the call stack, and print the read data (output to the specified location in the form of a log file).

[0149] In addition, it should be noted that, specifically in the exception handling method provided in the embodiment of the present application, after the exception handling module obtains the corresponding log file in the above manner, it will analyze and process the log file according to the specific execution strategy, and then determine the specific exception type, specific link, specific jump position and other analysis results of the exception problem.

[0150] In addition, after obtaining the analysis result of the current abnormal problem, the abnormality handling module will also repair the current abnormality according to the analysis result, so that the electronic device does not need to be restarted.

[0151] In addition, it should be noted that if the set execution strategy cannot determine the specific type of the current abnormal problem, the specific link where the abnormality occurred, the specific jump position, etc., that is, no analysis results are obtained and repairs cannot be performed, the exception handling module will directly trigger the electronic device to restart the entire machine.

[0152] For details about the execution strategy based on the exception handling module and the specific implementation details of the exception handling method provided in the embodiments of the present application, please refer to the description of the following embodiments, which will not be repeated here.

[0153] In addition, it should be noted that in some possible implementations, the interrupt handling module and the exception handling module implemented in the kernel can also be encapsulated in the framework layer. For this implementation, the interrupt handling module and the exception handling module integrated in the framework layer can interact with the kernel by providing a corresponding interface in the HAL layer, and then interact with the hardware part through the interface provided by the kernel.

[0154] This concludes the introduction to the software structure of the mobile phone 100. It can be understood that: Figure 2The layers in the software structure shown and the components included in each layer do not constitute a specific limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 may include more or fewer layers than shown, and each layer may include more or fewer components, which is not limited in the present application.

[0155] In addition, it should be noted that although the embodiments of the present application are described using the Android system as an example, the basic principles are also applicable to electronic devices with other operating systems, such as iOS or Windows operating systems.

[0156] In addition, it should be noted that the execution subject of the exception handling method provided in each embodiment of the present application can be the electronic device mentioned above, or it can be a functional module and / or functional entity (such as an interrupt handling module and an exception handling module in the kernel) in the electronic device that can implement the exception handling method. The specific implementation can be determined according to actual use requirements, and the present application does not limit this. Figure 3 , from the perspective of the functional modules and / or functional entities that can implement the exception handling method in the electronic device, the interaction of the functional modules and / or functional entities involved in the process of implementing the exception handling method provided in the embodiment of the present application is exemplarily described.

[0157] For example, in this embodiment, the Bitflip problem is thrown by the application layer as an example. Figure 3 When the user clicks on the icon of APP1 displayed on the desktop of the electronic device, the electronic device responds to the operation and executes step 101 to start APP1.

[0158] Continue to see Figure 3 For example, since the application programs installed in the electronic device, such as APP1, and other stored data contents are usually stored in the form of binary files in a UFS type memory device, when the electronic device starts APP1, it will first read the relevant data of APP1 from the UFS to the DDR memory device, that is, execute step 102.

[0159] In step 102, the data related to APP1 in the DDR is read from the UFS, for example, the data required during the operation of APP1. In some possible implementations, the data may include user data and program data.

[0160] Exemplarily, user data is data created when the user uses APP1 or the address corresponding to these data. Taking APP1 as a telephone application that can make voice calls, for example, the user data corresponding to APP1 can be call record data of the user using APP1 to make calls, recording data during the call, etc.

[0161] Exemplarily, the program data is the program to be executed by APP1, or the instruction that triggers the execution of the program, or the address corresponding to the instruction. In the process of APP1 startup, the first program data loaded is, for example, the configuration list file of APP1. The configuration list file is used to record the configuration information of APP1, such as the package name information, version number information, component information, permission information, etc. of APP1.

[0162] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0163] Continue to see Figure 3 It should be noted that cache is a high-speed cache between DDR (DRAM) and CPU. Inside the processor, the read and write speed of cache is higher than that of DDR, but lower than that of CPU. Since the speed of CPU is much higher than that of DDR, if there is no cache and CPU directly accesses DDR, then CPU needs to wait for the data of DDR to arrive before doing other things, which will result in low CPU utilization efficiency. Therefore, in order to speed up the operation and improve the utilization efficiency of CPU, step 103 can be executed first to read the relevant data of APP1 in DDR, such as the instructions or addresses mentioned above, into the cache memory device, so that CPU can read directly from cache, thereby shortening the data reading time.

[0164] Regarding the access relationship between UFS, DDR, cache and CPU, and the data reading and writing speed, please refer to the existing literature and will not go into details here.

[0165] Continue to see Figure 3 For example, the CPU reads the relevant program (instruction / address) of APP1 from the cache and executes it, that is, executes step 104. The operation performed by the CPU after reading the relevant program of APP1 from the cache is, for example, running the read instruction or accessing the read address.

[0166] Continue to see Figure 3 For example, if the read instruction / address does not have a Bitflip problem, APP1 will be started and run normally. On the contrary, if the read instruction / address has a Bitflip problem, APP1 (specifically, the task process corresponding to APP1) will throw an exception, that is, execute step 105.

[0167] It should be understood that there are many exceptions that may occur during program operation, such as data loss, functional abnormalities, etc. Some of these exceptions will not affect the normal use of the application, while some may cause the kernel to crash. When a kernel crash occurs, in order to restore the kernel to normal operation as soon as possible, in one possible implementation, the entire machine will be restarted, which is the aforementioned hot start.

[0168] Therefore, in order to be able to repair the exception that causes the kernel crash on the spot when the kernel crashes, thereby avoiding the electronic device from having to restart the entire device. Specifically in this embodiment, the exception thrown by the task process corresponding to APP1 is specifically the exception that causes the kernel crash.

[0169] Regarding the exceptions that can cause kernel crashes, specifically Linux exceptions, which usually include program error exceptions (bugs), stuck exceptions (hung), kernel crash exceptions (panic), and the above-mentioned Bitflip, etc., which are not listed here one by one, and this application does not limit them.

[0170] It should be noted that the so-called bug, which can also be called a defect or a bug, refers to a phenomenon such as malfunction, crash, data loss, abnormal interruption, etc. caused by a misalignment of the program itself during the operation of the application. Specifically in this embodiment, the bug exception that occurs is specifically a phenomenon that causes a crash.

[0171] In addition, it should be noted that when a task process is running, a hung exception occurs, which generally means that the program is stuck and cannot run normally. If it is stuck for a long time, it will be stuck, and the only way to solve this type of exception is to restart the whole machine. Therefore, in order to improve the user experience and avoid long-term stuck phenomena, an exception will be thrown in time when a stuck phenomenon occurs.

[0172] In addition, it should be noted that when a panic occurs during the task process, the kernel will crash directly and cannot run normally. In order to restore to normal, the only way is to restart the whole machine.

[0173] That is to say, during the operation of the task process, when the above exception occurs, the task process will throw an exception so that the interrupt processing module in the kernel layer can capture the exception in time.

[0174] Specifically in this embodiment, in order to enable the task process corresponding to APP1 to throw an exception when an exception occurs during the startup / operation process of APP1, when starting the task process corresponding to APP1, the kernel will register the corresponding interrupt processing function for the task process. In this way, the interrupt processing function can be called throughout the life cycle of the task process. Therefore, during the operation of the task process, when the above-mentioned exception that causes the kernel to crash occurs, the task process of APP1 will call the panic() function through the interrupt processing function to realize the throwing of the exception. In other words, when the task process of APP1 calls the panic() function through the corresponding interrupt processing function, it can be regarded as APP1 throwing an exception.

[0175] In addition, it should be noted that the interrupt handling function registered for each task process is managed by the interrupt handling module in the kernel layer. Therefore, when the task process of APP1 calls the panic() function through the interrupt handling function, the interrupt handling module will capture the exception thrown by the task process of APP1.

[0176] Continue to see Figure 3 Exemplarily, when the interrupt processing module captures the exception thrown by the task process of APP1, it will notify the exception processing module that the electronic device currently has a kernel crash exception, that is, execute step 106.

[0177] It should be noted that before the kernel crash occurs and the electronic device is hot-started, or before the exception is repaired, the data corresponding to the exception that caused the kernel crash (hereinafter referred to as exception data) is still recorded in the call stack in the DDR. Therefore, when the exception handling module learns that the kernel crash has occurred, it will call the corresponding exception handling function, that is, the exception handling function of the exception that actually caused the kernel crash of the electronic device, such as the exception handling function corresponding to the bug exception, the exception handling function corresponding to the hung exception, the exception handling function corresponding to the panic exception, and the exception handling function corresponding to the DAbt exception, and then obtain the exception data corresponding to the kernel crash from the call stack in the DDR.

[0178] In addition, it should be noted that in this embodiment, the repair of the exception that causes the kernel crash refers to the repair of the bitflip problem in the DAbt exception. Other exceptions that cause the kernel crash cannot be repaired by the exception handling method provided in this embodiment, that is, they still need to be resolved by restarting the entire machine.

[0179] Therefore, when it is determined that the exception causing the current kernel freeze of the electronic device is a DAbt exception, the acquired exception data will be analyzed and processed based on the exception handling method provided in the embodiment of the present application, and then it will be determined whether to perform exception repair or restart the entire machine based on the analysis results.

[0180] Specifically in this embodiment, there are two types of analysis results, one is to determine that the cause of the DAbt abnormality is Bitflip, and the other is to determine that the cause of the DAbt abnormality is not Bitflip. Among them, for the DAbt abnormality caused by Bitflip, the electronic device can be repaired. For the DAbt abnormality not caused by Bitflip, the electronic device cannot be repaired.

[0181] It should be noted that, in a possible implementation, in the scenario where the cause of the DAbt exception is Bitflip, the analysis result may include information such as the exception type, the specific link that caused the exception, the specific jump position, etc. In this way, for the scenario where the analysis result is the cause of Bitflip, the exception handling module can directly perform on-site repairs on the current exception based on the output analysis result without triggering a restart of the entire machine, that is, reloading the software of the entire machine.

[0182] It should be noted that, based on the exception handling method provided in this embodiment, the repair of different types of exception problems does not actually involve hardware modification, but only modifications from the software perspective, such as modifying the address that has jumped back to the original address, and modifying the instruction that has jumped back to the original instruction.

[0183] In addition, it should be noted that the address mentioned in this embodiment is specifically a kernel virtual address.

[0184] Continue to see Figure 3 For example, for a scenario where the analysis result is not due to a Bitflip, the exception handling module can directly trigger a restart of the entire machine according to the existing processing logic.

[0185] It should be noted that when the abnormal problem cannot be repaired, no modification of the hardware is involved.

[0186] pass Figure 3 As can be seen from the description of the illustrated embodiment, the exception handling method provided by the present application has no specific requirements for the chip and CPU, that is, the chip and CPU of the current electronic device will not be changed. Therefore, without increasing the hardware cost and limiting the CPU type, the Bitflip problem occurring in various memory devices of electronic devices that do not output fulldump files is handled, and after locating the problem, the abnormal problem can be repaired on the spot, so that the electronic device will not be restarted, thereby ensuring the stability of the entire machine / system and improving the user experience.

[0187] The exception handling method provided in this application is described in detail below in conjunction with specific embodiments.

[0188] See also Figure 4The exception handling method provided in this embodiment specifically includes steps 201 to 208. Step 201 is implemented by an interrupt handling module, and steps 202 to 208 are implemented by an exception handling module.

[0189] 201, the interrupt processing module captures the exception thrown by the task process, and notifies the exception processing module that the electronic device has a kernel crash exception.

[0190] It can be seen from the description of the above embodiment that only when the current exception will cause the kernel to crash, the task process will call the panic() function in the corresponding interrupt processing function to throw an exception. The interrupt processing functions corresponding to different task processes are uniformly managed by the interrupt processing module, so the interrupt processing module can capture the exception thrown by the task process in time.

[0191] In addition, since the exception handling operation is completed by the exception handling module, after the interruption handling module captures the exception that causes the core crash, it will notify the exception handling module that the electronic device currently has a core crash exception.

[0192] For specific implementation details about the task process throwing an exception, the interrupt handling module capturing the exception, and the interrupt handling module notifying the exception handling module of the kernel crash exception after capturing the exception, please refer to the description of steps 105 and 106 in the above embodiment, which will not be repeated here.

[0193] 202, the exception handling module determines whether the exception causing the kernel crash is a DAbt exception.

[0194] It can be seen from the description of step 105 in the above embodiment that, specifically in each embodiment of the present application, the premise for the task process to call the panic() function through the corresponding interrupt handling function is that an exception that causes the kernel to crash occurs. The exception that causes the kernel to crash, for example, may include the Bug exception, hung exception, panic exception mentioned in the above embodiment, as well as the instruction exception and DAbt exception caused by Bitflip, etc., which are not listed here one by one, and the present application does not limit this. Among them, only the instruction exception and DAbt exception caused by Bitflip can be repaired.

[0195] In addition, it should be noted that since any of the above-mentioned exceptions that can cause kernel panic are thrown through the panic() function, and different exceptions correspond to different exception types, when the kernel panic exception is thrown through the panic() function, it will carry a specific exception type, such as the exception types corresponding to the Bug exception, hung exception, panic exception, DAbt exception, and instruction exception mentioned above.

[0196] Accordingly, when the interrupt processing module notifies the exception handling module that a kernel crash exception has occurred in the electronic device, the exception handling module will send the exception type to the exception handling module. In this way, the exception handling module only needs to determine whether the exception causing the kernel crash is a DAbt exception (or an instruction exception) based on the received exception type.

[0197] Through the above explanations of instructional exceptions and DAbt exceptions, it can be known that one of the causes of instructional exceptions and DAbt exceptions is that the corresponding instructions / addresses have a jump (Bitflip). The analysis and processing logic for these two types of exceptions (determining whether a Bitflip has occurred) can be the same. In order to facilitate the description of this embodiment, taking the determination of whether the cause of the DAbt exception is a Bitflip as an example, the analysis and processing performed by the exception handling module is specifically described.

[0198] Specifically, when the exception handling module determines that the exception that caused the kernel crash is a DAbt exception, step 203 is executed. Otherwise, the exception handling method provided in the embodiment of the present application is directly exited, and according to the existing processing logic, the electronic device is triggered to restart the entire device, that is, steps 203 to 206 are skipped, and step 207 is directly executed.

[0199] 203. The exception handling module determines the exception address and stack information (exceptional data) where the exception occurs from the call stack according to the exception handling function corresponding to the DAbt exception.

[0200] It is understandable that since different exception types correspond to different exception handling functions, and different exceptions correspond to different exception addresses, stack information, etc., in order to ensure the rationality of the analysis results, this embodiment will first determine the exception handling function that matches the determined exception type, and then determine the exception address and stack information (hereinafter referred to as exception data for the sake of convenience) where the DAbt exception occurs from the DDR call stack through the exception handling function.

[0201] The call stack (also called function call stack) mentioned in this embodiment is specifically an internal data structure called "execution context" generated during the function execution process. That is, the call stack is an internal data structure in DDR, which can be used to store the function's execution environment, variables, function parameters, accessed addresses, stack and other information.

[0202] Since the present embodiment takes the DAbt exception as an example, the exception handling function called by the exception handling module can be a do_mem_abort function specifically used to handle the DAbt exception. Through the do_mem_abort function, the exception address (specifically the virtual address) and stack information of the exception can be obtained. In this way, it is possible to obtain the exception data from the call stack and then obtain the operation of the log file, that is, the operation of step 204.

[0203] 204. The exception handling module obtains determined exception data from the call stack and generates a log file.

[0204] Specifically in this embodiment, after obtaining the log file corresponding to this exception, the exception handling module will analyze and process the exception data recorded in the log file, and then determine whether the cause of the current DAbt exception in the electronic device is Bitflip. That is, based on the exception handling method provided in this embodiment, after obtaining the log file corresponding to this exception, it will not directly trigger the electronic device to restart the entire machine, nor will it directly repair the exception, but it is necessary to first determine whether the cause of the current DAbt exception in the electronic device is Bitflip. Because only when the DAbt exception is caused by Bitflip, can the exception be repaired by flipping the bit that has jumped, without having to solve the exception problem by restarting the entire machine.

[0205] Therefore, after generating the log file, the exception handling module will execute step 205.

[0206] In addition, it should be noted that before the electronic device is powered off (i.e. before cold start), all log files are stored in the DDR. Therefore, in this embodiment, the log files generated by the exception handling module will also be first stored in the DDR.

[0207] 205, the exception processing module analyzes and processes the abnormal data in the log file to determine whether the cause of the DAbt exception is Bitflip.

[0208] Specifically, if the exception handling module determines through analysis and processing that the cause of the DAbt exception is Bitflip, step 206 will be executed. Otherwise, step 207 will be executed.

[0209] For details on how the exception handling module analyzes and processes the abnormal data in the log file and determines whether the cause of the DAbt exception is Bitflip, see Figure 5 Steps 304 to 320 in the illustrated embodiment are not described in detail here.

[0210] 206 , the exception handling module repairs the DAbt exception (the electronic device does not need to be restarted).

[0211] Exemplarily, in a possible implementation, the exception handling module performs Figure 5 The processing logic of step 304 to step 320 in the illustrated embodiment analyzes and processes the abnormal data in the log file, and when it is determined that the cause of the DAbt abnormality is Bitflip, the DAbt abnormality will be repaired according to the analysis result.

[0212] It can be seen from the above description that in this embodiment, by analyzing and processing the abnormal data corresponding to the DAbt abnormality, when it is determined that the cause of the DAbt abnormality is Bitflip, the analysis result will also include information such as the abnormality type, the specific link that caused the abnormality, and the specific jump position. Therefore, according to the specific environment where the abnormality occurs given in the analysis result, as well as the specific jump position and other information, the bit that needs to be flipped can be accurately located, and then the content of the bit is flipped, such as from 0 to 1. In this way, the normal access address and instruction can be restored, that is, the abnormality can be repaired, so that the electronic device can operate normally without restarting the whole machine.

[0213] In addition, it should be noted that in some other implementations, in order to facilitate the acquisition of anomalies that have occurred in the electronic device and have been repaired, the exception handling module can also record the type of anomaly currently being repaired and the repair time, etc. under the path specified by the electronic device after completing the above step 206.

[0214] For example, the first kernel crash exception that occurs in an electronic device is a DAbt exception, and the cause of the DAbt exception is Bitflip. When the repair time of the exception is T1, the exception handling module will record the DAbt exception caused by Bitflip that was repaired at time T1 under the path specified by the electronic device (for the sake of convenience, the file recording the exception is called an exception repair record file).

[0215] For example, the second kernel crash exception of the electronic device is an instructional exception, and the cause of the instructional exception is Bitflip. When the repair time of the exception is T2, the exception handling module will then record the information of the instructional exception caused by Bitflip that was repaired at time T2 in the above-mentioned exception repair record file.

[0216] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0217] 207, the exception handling module triggers the electronic device to restart.

[0218] Specifically, based on the exception handling method provided in this embodiment, when the exception that causes the kernel to crash is not the DAbt exception and instructional exception caused by the Bitflip mentioned above, that is, when the exception that causes the kernel to crash is the Bug exception, or the hung exception, or the panic exception mentioned above, the exception handling module will trigger the electronic device to restart the entire device. That is, through the hot start method, the computer program of the electronic device is restarted, so that the kernel can be restored to a normal operating state.

[0219] 208. The exception handling module writes the log file to the disk.

[0220] Specifically, in order to facilitate the acquisition of the cause of the hot start of the electronic device, after the electronic device completes the hot start, in order to avoid the loss of the log file stored in the DDR, the exception handling module will write the log file generated in step 204 to the specified path in the disk.

[0221] Exemplarily, in some possible implementations, the path corresponding to the log file written to the disk and the abnormal repair record file written to the disk may be the same, so that it is convenient for technicians to obtain them at one time.

[0222] Exemplarily, in some other possible implementations, the paths corresponding to the log file written to the disk and the abnormal repair record file written to the disk may be different paths, so as to facilitate the maintenance and management of different files.

[0223] In addition, it should be noted that in order to prevent the log files and the abnormality repair record files from being tampered with and deleted, the log files and the abnormality repair record files can be set to be invisible to the user.

[0224] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0225] Therefore, when an exception occurs and causes the kernel to crash, by determining whether the currently occurring kernel crash exception is an exception that may be caused by Bitflip (DAbt exception, instructional exception), and then when it is determined that the exception that causes the kernel crash is a DAbt exception or an instructional exception, the exception data corresponding to the exception is obtained according to the exception handling function corresponding to the exception, and by analyzing and processing the exception data corresponding to the exception, it is determined whether the exception is caused by Bitflip. Therefore, when the exception that causes the kernel crash is an exception caused by Bitflip, the content on the bit where Bitflip occurs can be flipped and modified, and then restored to the normal access address and instruction, that is, the exception can be repaired, so that the electronic device can operate normally. That is, there is no need to solve the abnormal problem by restarting the entire machine software, which effectively guarantees the stability of the system and the entire machine and improves the user experience.

[0226] In order to better understand the exception handling method provided in this application, different exception handling functions and execution strategies are used for different exception types for analysis and processing. Figure 5 , taking the specific exception type DAbt as an example, the exception handling method provided by this application is described in detail.

[0227] See also Figure 5 For example, when the current exception is a DAbt exception, the exception handling module can determine that the exception handling function to be called is the do_mem_abort function, and the corresponding execution strategy can be Figure 5 The analysis and processing logic of steps 304 to 320 shown in FIG. 1 is to execute step 301 .

[0228] Continue to see Figure 5 Exemplarily, after completing the operation of step 301, the exception handling module can determine the exception address and stack information of the exception from the call stack according to the determined exception handling function (do_mem_abort function), that is, execute step 302.

[0229] Continue to see Figure 5 Exemplarily, after the exception handling module determines the exception address and stack information where the exception occurs from the call stack through the do_mem_abort function, it can read the determined exception address and stack information from the call stack and print them, that is, execute step 303.

[0230] Regarding the printing of the exception address and stack information in this embodiment, for example, the exception address and stack information are saved as a log file (log) as mentioned above, and then saved to a path / directory specified by the electronic device.

[0231] Continue to see Figure 5 For example, after completing the operations from step 301 to step 303, the exception handling module can call the required components according to the determined execution strategy, analyze and process the log information in the log file, and determine the analysis results of the abnormal problem.

[0232] Regarding the processing logic of this part, it can be as step 304 to step 320. Figure 5 , steps 304 to 320 are described in detail.

[0233] First, step 304 is executed to obtain the exception address from the printed log file, and the exception address is judged to determine whether the exception address is a four-byte aligned address, that is, to determine whether the exception address is not four-byte aligned.

[0234] Specifically, this embodiment takes the processor used by the electronic device as an ARM (Advanced RISC Machines) processor as an example. According to the documentation of the ARM processor, its access rules can be divided into one access to 4-byte content (the starting address of the content must be at a 4-byte aligned position) and one access to 2-byte content (the starting address of the content must be at a 2-byte aligned position). This embodiment takes one access to 4-byte content as an example, so the exception handling module can first determine whether the abnormal address of the current abnormality is not aligned with four bytes, that is, determine whether the current abnormality is due to the start address of the content accessed once not being at a 4-byte aligned position.

[0235] It should be noted that byte alignment means that various types of data are arranged in space according to certain rules, rather than being arranged one by one in sequence. Based on this, the so-called N-byte alignment, such as the four-byte alignment in this embodiment, means that the storage start address of the data is %4==0.

[0236] For example, if the starting address of the abnormal address obtained from the log file is "FFFFFFD6938C718", based on the above four-byte alignment standard, by performing a modulo operation on the starting address, it can be seen that the final remainder is 0. Therefore, it can be determined that the abnormal address "FFFFFF D6938 C718" is a four-byte aligned address.

[0237] Correspondingly, if the starting address of the abnormal address obtained from the log file is "FFFFFF D6938C717", based on the above four-byte alignment standard, by performing a modulo operation on the starting address, it can be known that the final remainder is 3. Therefore, it can be determined that the abnormal address "FFFFFF D6938 C717" is an address that is not four-byte aligned.

[0238] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0239] Based on the above description of the four-byte alignment standard, it can be known that in this embodiment, whether there is a situation where the abnormal address is not four-byte aligned is determined by judging whether the remainder of the start address of the abnormal address divided by 4 is 0. Accordingly, if the remainder is 0, it is determined that the start address of the current abnormal address is four-byte aligned, and if the remainder is not 0, it is determined that the start address of the current abnormal address is not four-byte aligned.

[0240] Continue to see Figure 5 For example, when it is determined that the exception address is not a four-byte aligned address, that is, the exception address is not four-byte aligned, the exception handling module can directly output the analysis result that the exception cause is that the address is not four-byte aligned, that is, execute step 305.

[0241] Continue to see Figure 5 Exemplarily, after the exception handling module obtains the exact analysis result, it can repair the current abnormal problem according to the analysis result, that is, execute step 320. In this way, the electronic device does not need to restart the software of the whole machine, ensuring the stability of the system and the user experience.

[0242] It should be noted that, when the analysis result shows that the cause of the exception is that the address is not four-byte aligned, the exception handling module performs the exception repair by specifically aligning the address to four bytes.

[0243] For example, if the memory corresponding to the abnormal address retrieved from the log file stores 8 bytes of data content, and the data stored in the abnormal address is of int type (an int type occupies 4 bytes). Based on this premise, Fig. 6A As shown in the figure, when the starting address of the exception address is "18", by dividing 18 by 4, it can be seen that the remainder is 2, that is, the exception address is not four-byte aligned. In this case, the exception handling module needs to add 2 bytes to the starting address of the exception address when repairing, such as Figure 6B That is, the int type data in the above abnormal address needs to be placed starting from address "20".

[0244] pass Fig. 6A and Figure 6B As shown, when the exception address has a starting address of "18" and an ending address of "26", the exception address is repaired to a starting address of "20" and an ending address of "28" by adding 2 bytes to the starting address of the exception address, so that the exception address can be repaired to a four-byte aligned address, so that the electronic device can normally read the content in the repaired address.

[0245] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0246] Continue to see Figure 5 Exemplarily, when the exception handling module determines that there is no non-four-byte alignment in the exception address, that is, the exception address is four-byte aligned, step 306 can be executed.

[0247] Continue to see Figure 5 , exemplarily, for the case where the exception address is not not four-byte aligned, the exception handling module can further determine whether the exception address is a kernel virtual address mapped by the phenomenon.

[0248] Regarding the method for determining whether the exception address is a kernel virtual address of the phenomenon mapping, specifically, the number of 0s in the high bits of the exception address may be checked.

[0249] It should be noted that the high bits mentioned above are related to the ARM processor. For example, for a 64-bit ARM processor, the first 24 bits can be set as the high bits according to business needs. For ease of explanation. In this embodiment, the ARM processor is a 64-bit processor. Accordingly, the high bits that need to be checked are the first 24 bits.

[0250] See also Fig. 7A , exemplarily shows a 64-bit exception address (binary) "1111 1111 11111111111111 1100 0000 0011 1001 0111 0111 1001 1001 0010 0000". For this exception address, the high bit to be checked is Fig. 7A 24 bits between the 0th bit and the 23rd bit are shown in FIG.

[0251] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0252] In addition, it should be noted that, usually, the high-order bits are all 1, such as Fig. 7A Therefore, if 0 appears in the high position, it indicates that a jump has occurred, and jumps caused by different links and reasons will cause different numbers of 0s to appear in the high position.

[0253] Continue to see Figure 5, Exemplarily, if 1 or 2 bits among the first 24 bits of the abnormal address are 0, that is, the number (num) of 0s satisfies the following relationship: 0 < num < 3. In this case, it is usually caused by 1-bit or 2-bit jumps. For such problems, the exception handling module can attempt to repair the high-order address to the kernel linear virtual address range and attempt to access it, that is, execute step 307.

[0254] For example, the exception handling module checks the first 24 bits of the abnormal address. If the 10th bit appears as 0, as Figure 7B shown, the operation of step 307 will be executed.

[0255] It should be understood that the above description is only an example listed for better understanding of the technical solution of this embodiment and does not serve as the sole limitation of this embodiment.

[0256] Regarding the abnormal address range from the high-order address to the kernel linear virtual address that the abnormal handling module attempts to repair in step 307, for example, the value on the bit where 0 appears in the high-order address is modified to 1. In this way, the repaired address can be obtained, and the exception handling module can attempt to access the repaired address.

[0257] Continue to refer to Figure 5 , Exemplarily, if the address can be accessed after attempting to repair the high-order address to the kernel thread virtual address range, the analysis result indicating that the original cause of the exception is Bitflip can be output, that is, execute step 319. In this way, the exception handling module can perform on-site repair of the exception problem based on the output analysis result, so that it is not necessary to restart the software in the electronic device, that is, execute step 320.

[0258] It should be noted that since 1-bit or 2-bit jumps are usually caused by device problems (device defects), the output analysis result can not only include the description information indicating that the current original cause of the exception is a Bitflip problem, but also include the reason indicating that this Bitflip problem is caused by device defects, as well as the abnormal address that needs to be repaired, the specific bit where the jump occurs, etc.

[0259] It should be understood that the above description is only an example listed for better understanding of the technical solution of this embodiment and does not serve as the sole limitation of this embodiment.

[0260] Continue to refer to Figure 5, for example, if the address after the high address to the kernel thread virtual address range is not accessible after the attempt to repair it, it indicates that the reason for the address in this range to jump to the above-mentioned abnormal address is not a defective device, and the specific reason cannot be determined. Therefore, in order to solve the current abnormal problem and restore the electronic device to normal operation, the abnormality handling module can only trigger the electronic device to restart the whole machine (software restart), that is, execute step 309.

[0261] Continue to see Figure 5 For example, if the first 24 bits of the exception address have 3 or more 0s, that is, 3 or more bits are 0. In this case, it is not just a device problem (a simple device problem generally does not jump more than 2 bits), and there may be an exception in the processing link. Specifically, in the exception handling method provided in this application, when it is determined that num≥3, the exception handling can be performed according to the processing flow of steps 310 to 314.

[0262] For example, the exception handling module checks the first 24 bits of the exception address. If the 10th, 12th, 18th, and 21st bits are 0, such as Figure 7C As shown, the exception handling can be performed according to the processing flow from step 310 to step 314.

[0263] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0264] Continue to see Figure 5 , illustratively, for the case where num≥3, the accessed register content can be retrieved first, that is, step 310 is executed.

[0265] For example, if the instruction corresponding to the exception address is the LDUR instruction, the address of the register corresponding to the LDUR instruction is "F85C012A", and the content corresponding to the LDUR instruction is "x10, [x9, #-0x40]; x10, [x9, #-64]", then the register to be accessed is x10, and the content taken out from register x10 is "[x9, #-0x40]; x10, [x9, #-64]". This content indicates that the starting address corresponding to "x10" is the address offset #-0x40 of register "x9", and the ending address is the address offset #-64 of register "x9".

[0266] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0267] Continue to see Figure 5For example, after taking out the contents of the currently accessed register, the address of the upper level register (hereinafter referred to as address 1 for ease of description) can be determined based on the taken out register contents, that is, step 311 is executed.

[0268] It can be seen from the example listed in step 310 that the address of the register currently to be accessed is determined after performing a corresponding offset based on the addresses of other registers. Therefore, in this embodiment, the register is referred to as the upper-level register of the register currently to be accessed.

[0269] Still using the example listed in step 310 for explanation, when the starting address corresponding to "x10" is the address offset #-0x40 of register "x9", and the ending address is the address offset #-64 of register "x9", and the address of register x10 is "F85C012A", the address of register x9 needs to be supplemented with the offset #-0x40 and #-64 on the address of register x10, so as to obtain the starting address and ending address corresponding to register x9.

[0270] It should be understood that the above description is merely an example listed for a better understanding of the technical solution of this embodiment, and is not intended to be the sole limitation to this embodiment.

[0271] Continue to see Figure 5 For example, after obtaining address 1, the exception handling module can traverse the addresses corresponding to other registers except the currently accessed register, such as x10, and match the addresses of the traversed registers with address 1, that is, execute step 312.

[0272] For example, taking a 64-bit ARM processor as an example, the number of corresponding processors may be 32. In this case, the maximum number of registers to be traversed by the exception handling module is 31.

[0273] Continue to see Figure 5 , exemplarily, if address 1 is the same as the address of any one of the 31 registers, it can be determined that the data stored in the register does not have the possibility of a high-bit jump. Therefore, the current exception is not caused by the data stored in the register. For this case, the exception address can be classified to determine whether the exception address is the address of the data segment or the address of the non-data segment (such as the address of the code segment), that is, step 313 is executed.

[0274] It should be noted that the code segment mentioned above refers to the executable part of the program, which is composed of function stacks. The data segment (also known as the data area, static data area, static area) is the data in the program. The data segment can also be understood as a global variable in the program. The specific differences between the data segment and the code segment will not be elaborated here.

[0275] Continue to see Figure 5 For example, if the abnormal address is not the address of the data segment, in this case, the abnormality handling module cannot temporarily determine whether the current abnormality is caused by this jump. Therefore, there is no way to output the analysis result. In order to solve the abnormality problem and restore the electronic device to normal operation, the abnormality handling module can only trigger the electronic device to restart the whole machine (software restart), that is, execute step 309.

[0276] Continue to see Figure 5 For example, if the exception address is the address of the data segment, it can be further determined whether the instruction corresponding to the exception address is a load / transfer instruction, that is, step 314 is executed.

[0277] It should be noted that, in this embodiment, the load instruction mentioned above may be, for example, an LDR instruction or an LDUR instruction. The transfer instruction mentioned above may be, for example, an STR instruction (used to transfer a 32-bit word data from a source register to a memory). For the use of the LDR instruction, the LDUR instruction, and the STR instruction, please refer to the relevant documents, which will not be described here.

[0278] Continue to see Figure 5 For example, when the instruction corresponding to the abnormal address is neither a load instruction nor a transfer instruction, the abnormality handling module cannot determine whether the reason for the address to be accessed to become the abnormal address is caused by a jump, and therefore has no way to output the analysis result. In order to solve the abnormality problem and restore the electronic device to normal operation, the abnormality handling module can only trigger the electronic device to restart the whole device (software restart), that is, execute step 309.

[0279] Continue to see Figure 5 , for example, when the instruction corresponding to the abnormal address is a read / instruction, it can be determined that the abnormal problem currently occurring is due to the instruction content jumping, resulting in accessing the wrong register, that is, a jump occurs in this link. Based on this, the analysis results of the specific link and the jump position where the jump occurs can be output, that is, step 319. In this way, the abnormality handling module can perform on-site repair of the abnormal problem based on the output analysis results, so that there is no need to restart the software in the electronic device, that is, execute step 320.

[0280] Continue to see Figure 5 For example, if address 1 is different from the address of any of the 31 registers, in this case, the exception handling module cannot temporarily determine whether the current exception is caused by this jump. Therefore, there is no way to output the analysis result. In order to solve the exception problem and restore the electronic device to normal operation, the exception handling module can only trigger the electronic device to restart the whole machine (software restart), that is, execute step 309.

[0281] Continue to see Figure 5 For example, if the first 24 bits of the abnormal address are all 1 (no 0 appears), it indicates that the high-order address is not abnormal. In this case, it is necessary to first find the source of the abnormal address. That is, execute step 315 to first determine whether the address of the currently accessed register recorded in the log file exists in the remaining 31 registers (other registers except the currently accessed register), that is, whether the address comes from these 31 registers.

[0282] Continue to see Figure 5 , illustratively, if the address does not exist in the other 31 registers. The exception handling module is temporarily unable to determine whether the current exception is caused by this jump. Therefore, there is no way to output the analysis result. In order to solve the exception problem and restore the normal operation of the electronic device, the exception handling module can only trigger the electronic device to restart the whole machine (software restart), that is, execute step 316. Among them, step 316 is the same as step 309, both of which trigger the electronic device to restart the whole machine (software restart).

[0283] Continue to see Figure 5 For example, if the address comes from these 31 registers, the exception handling module can search upward for the executed instructions (specifically, the instructions for accessing the registers corresponding to the address) in the currently running instructions, and then search for possible jump conditions in the instructions and the operations corresponding to the instructions, that is, execute steps 317 and 318.

[0284] Continue to see Figure 5 For example, if it is determined through the judgment of step 318 that a bitflip exists in the instruction and / or the operation corresponding to the instruction, it is determined that the current exception is caused by a bitflip occurring in the instruction and / or the operation corresponding to the instruction. Therefore, the analysis results of the specific location and link where the jump occurs can be output, i.e., step 319. In this way, the exception handling module can perform on-site repair of the exception problem based on the output analysis results, thereby eliminating the need to restart the software in the electronic device, i.e., executing step 320.

[0285] Continue to see Figure 5 , for example, if after the judgment of step 318, it is determined that there is no Bitflip in the instruction and / or the operation corresponding to the instruction. For this case, the exception handling module is temporarily unable to determine whether the current exception is caused by this jump. Therefore, there is no way to output the analysis result. In order to solve the exception problem and restore the normal operation of the electronic device, the exception handling module can only trigger the electronic device to restart the whole machine (software restart), that is, execute step 316. Among them, step 316 is the same as step 309, both of which trigger the electronic device to restart the whole machine (software restart).

[0286] Therefore, for DAtb exceptions, according to the above three different judgment logics, that is, after obtaining the currently accessed address, first take the high bit of the address, and judge whether the number of bits that jump in the high bit is 0, or greater than 0 and less than 3, or greater than or equal to 3, and then analyze and process according to the corresponding judgment logic, so that the location and description of the exceptions of different memory devices can be achieved without increasing hardware costs and without fulldump files. Therefore, according to the determined analysis results, the current exception can be repaired on the spot, and the electronic device does not need to be restarted.

[0287] In addition, it should be noted that in some possible implementations, after the abnormal address is repaired according to the analysis results, it is also possible to try whether it can be accessed. If it can be accessed, the electronic device can operate normally. If it is not available, try restarting.

[0288] In addition, it is understandable that, in order to implement the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.

[0289] In one example, Figure 8 A schematic block diagram of a device 400 according to an embodiment of the present application is shown. The device 400 may include: a processor 401 and a transceiver / transceiver pin 402 , and optionally, a memory 403 .

[0290] The components of the device 400 are coupled together via a bus 404, wherein the bus 404 includes a power bus, a control bus, and a status signal bus in addition to a data bus. However, for the sake of clarity, all buses are referred to as bus 404 in the figure.

[0291] Optionally, the memory 403 may be used for the instructions in the aforementioned method embodiment. The processor 401 may be used to execute the instructions in the memory 403, and control the receiving pin to receive a signal, and control the sending pin to send a signal.

[0292] The apparatus 400 may be the electronic device or a chip of the electronic device in the above method embodiment.

[0293] Among them, all relevant contents of each step involved in the above method embodiment can be referred to the functional description of the corresponding functional module, and will not be repeated here.

[0294] This embodiment further provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the method in the above-mentioned embodiment.

[0295] This embodiment also provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement the method in the above-mentioned embodiment.

[0296] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory so that the chip executes the methods in the above-mentioned method embodiments.

[0297] Among them, the electronic device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above and will not be repeated here.

[0298] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.

Claims

1. An exception handling method, characterized in that: Applied to electronic equipment, the method comprises: Obtaining a first access request of a first application; accessing data at a first address based on the first access request, and during the access to the data at the first address, a kernel crash occurs based on an exception of a preset type; Obtaining the first address from the log file, and repairing the first address; wherein the starting address of the first address is not four-byte aligned; Based on the repaired first address, data of the first address is accessed; wherein the starting address of the repaired first address is four-byte aligned.

2. The method according to claim 1, characterized in that The method further comprises: Obtaining a second access request of the first application; accessing data at a second address based on the second access request, and during the access to the data at the second address, a kernel crash occurs based on an exception of a preset type; Obtain the second address from the log file, and repair the second address; wherein the starting address of the second address is four-byte aligned, and the preset bit position of the second address contains N 0s, where N is an integer greater than 0 and less than 3; Based on the repaired second address, access the data of the second address; wherein the starting address of the repaired second address is four-byte aligned, and the preset bit position does not contain 0.

3. The method according to claim 2, characterized in that The method further comprises: When the data at the second address cannot be accessed based on the repaired second address, the electronic device restarts.

4. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: Obtaining a third access request of the first application; accessing data at a third address based on the third access request, and in the process of accessing the data at the third address, a kernel crash occurs based on an exception of a preset type; The third address is obtained from the log file, and the third address is repaired; wherein the starting address of the third address is four-byte aligned, and the preset bit of the third address contains M zeros, where M is an integer greater than or equal to 3; the address of the second register is the same as the address of any register except the first register, the first register is the register corresponding to the third address, and the second register is the upper-level register of the first register; the third address is the address of the data segment, and the instruction corresponding to the third address is a load instruction or a transfer instruction; Based on the repaired third address, access the data of the third address; wherein the starting address of the repaired third address is four-byte aligned, and the preset bit position does not contain 0.

5. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: Obtaining a fourth access request of the first application; accessing data at a fourth address based on the fourth access request, and in the process of accessing the data at the fourth address, a kernel crash occurs based on an exception of a preset type; Obtain the fourth address from the log file; When the starting address of the fourth address is aligned with four bytes, the preset bits of the fourth address contain M 0s, and the address of the fourth register is different from the address of any register except the third register, the electronic device restarts; wherein M is an integer greater than or equal to 3, the third register is the register corresponding to the fourth address, and the fourth register is the upper-level register of the third register.

6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Obtaining a fifth access request of the first application; accessing data at a fifth address based on the fifth access request, and during accessing the data at the fifth address, a kernel crash occurs based on an exception of a preset type; Obtain the fifth address from the log file; When the starting address of the fifth address is aligned with four bytes, the preset bits of the fifth address contain M zeros, the address of the sixth register is the same as the address of any register except the fifth register, and the fifth address is not the address of the data segment, the electronic device restarts; wherein M is an integer greater than or equal to 3, the fifth register is the register corresponding to the fifth address, and the sixth register is the upper-level register of the fifth register.

7. The method according to any one of claims 1 to 6, characterized in that: The method further comprises: Obtaining a sixth access request of the first application; accessing data at a sixth address based on the sixth access request, and during the access to the data at the sixth address, a kernel crash occurs based on an exception of a preset type; Obtain the sixth address from the log file; The starting address of the sixth address is aligned with four bytes, the preset bits of the fifth address contain M zeros, the address of the eighth register is the same as the address of any register except the seventh register, the sixth address is the address of the data segment, and when the instruction corresponding to the sixth address is not a load instruction or a transfer instruction, the electronic device restarts; wherein M is an integer greater than or equal to 3, the seventh register is the register corresponding to the sixth address, and the eighth register is the upper-level register of the seventh register.

8. The method according to any one of claims 4 to 7, characterized in that: The load instructions include LDR instructions and LDUR instructions, and the transfer instructions include STR instructions.

9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: Obtaining a seventh access request of the first application; accessing data at a seventh address based on the seventh access request, and during the access to the data at the seventh address, a kernel crash occurs based on an exception of a preset type; The seventh address is obtained from the log file; wherein the starting address of the seventh address is four-byte aligned, the preset bit of the seventh address does not contain 0, the seventh address is the same as the address corresponding to any register except the ninth register, and there is no bit flip problem in the eighth address that has accessed the ninth register, and the ninth register is the register corresponding to the seventh address; Flip the value of the bit where the bit flip occurs in the eighth address to obtain the repaired eighth address; Accessing data at the eighth address based on the repaired eighth address; Based on the seventh address, data of the seventh address is accessed.

10. The method according to claim 9, characterized in that The method further comprises: Determine the currently executed assembly instruction according to the stack information in the log file; Among the currently executed assembly instructions, searching upward from the last executed assembly instruction, the address corresponding to the found assembly instruction that has accessed the ninth register or the address of the operation corresponding to the assembly instruction is determined as the eighth address.

11. The method according to any one of claims 1 to 10, characterized in that: The method further comprises: Obtaining a ninth access request of the first application; accessing data at a ninth address based on the ninth access request, and in the process of accessing the data at the ninth address, a kernel crash occurs based on an exception of a preset type; Obtain the ninth address from the log file; When the starting address of the ninth address is aligned with four bytes, the preset bit of the ninth address does not contain 0, and the ninth address is different from the address corresponding to any register except the tenth register, the electronic device restarts; wherein the tenth register is the register corresponding to the ninth address.

12. The method according to any one of claims 1 to 11, characterized in that: The method further comprises: Obtaining a tenth access request of the first application; accessing data at a tenth address based on the tenth access request, and during accessing the data at the tenth address, a kernel crash occurs based on an exception of a preset type; Obtain the tenth address from the log file; The starting address of the tenth address is aligned with four bytes, the preset bit of the tenth address does not contain 0, the tenth address is the same as the address corresponding to any register except the eleventh register, and when the address of the eleventh register accessed has a bit flip problem, the electronic device restarts; wherein the eleventh register is the register corresponding to the tenth address.

13. The method according to any one of claims 1 to 12, characterized in that: The log file is obtained from the call stack based on the exception handling function corresponding to the exception of the preset type.

14. The method according to claim 2, or 4, or 5, or 6, or 7, or 9, or 11, or 12, characterized in that: The address obtained from the log file is a binary address, occupying 64 bits, and the preset bits are the first 24 bits.

15. An electronic device, characterized in that: The electronic device comprises: a memory and a processor, wherein the memory and the processor are coupled; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the exception handling method according to any one of claims 1 to 14.

16. A computer-readable storage medium, characterized in that: It comprises a computer program, and when the computer program is run on an electronic device, the electronic device executes the exception handling method as claimed in any one of claims 1 to 14.

Citation Information

Patent Citations

  • Test method and system based on SPARC (Scalable Processor ARChitecture) processor single event upset fault injection

    CN108710551A

  • Application program running method, computing equipment and storage medium

    CN114003289A

  • Method and device for repairing abnormal application exit and electronic equipment

    CN114153638A

  • Data processing system having self-aligning stack pointer and method therefor

    CN1168505A

  • Derived generation system for parity bits with bi-directional, crossed-fields utilizing stored flip-bit feature

    US5768299A