Abnormality processing method, device, and storage medium
By handling abnormal addresses in the log files of commercial electronic devices, the Bitflip problem was quickly located and fixed, the kernel crash issue was resolved, and system stability and user experience were improved.
Patent Information
- Application Number
- CN202310927894.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-26
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2043-07-26
AI Technical Summary
When Bitflip issues occur in commercial electronic devices, the specific cause cannot be identified, leading to kernel crashes and restarts, which affects system stability and user experience.
By obtaining the abnormal address from the log file and performing four-byte alignment or bit repair of the starting address, the electronic device can be restarted, ensuring the stability of data access.
Without increasing hardware costs, it enables rapid location and repair of Bitflip issues in commercial electronic devices, improving system stability and user experience.
Smart Images

Figure CN119376986B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer, in particular to an exception processing method, device and storage medium. BACKGROUND
[0002] During the running of the electronic device, a jump problem may occur due to device exception, that is, one or more bits of the accessed address / data are flipped. Therefore, when the jump problem occurs, the original business logic is usually changed or the accessed address / data is changed.
[0003] For the commercially available electronic device, since there is no fulldump file in such electronic device. Therefore, when the jump problem occurs, the electronic device cannot locate the specific reason causing the jump, and can only report a panic error (a kind of kernel error), thereby causing the whole machine to restart. SUMMARY
[0004] The present application provides an exception processing method, device and storage medium, which aims to analyze and process the jump problem occurred in the commercially available electronic device without increasing the hardware cost, and then repair the abnormal problem on the spot according to the determined analysis result, 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 processing method applied to an electronic device. The method comprises: obtaining a first access request of a first application; accessing data of a first address based on the first access request, wherein a kernel dies in a process of accessing the data of the first address based on a preset type of exception; obtaining the first address from a log file and repairing the first address, wherein a start address of the first address is not four-byte aligned; accessing the data of the first address based on the repaired first address, wherein the start address of the repaired first address is four-byte aligned.
[0006] The preset type of exception is, for example, the DAbt exception or the instruction exception as described in the following embodiments.
[0007] The first address is the address corresponding to the data accessed by the electronic device when the kernel dies, and since the address may be abnormal, it can also be understood as an abnormal address, such as the abnormal address described in the following embodiments. Subsequently, the second address to the tenth address can also be understood as an abnormal address.
[0008] The judgment logic and the corresponding scenario that the address read from the log file is the first address can be referred to steps 301 to 305 and step 320 in the following embodiments, which will not be described here.
[0009] The repairing of the first address specifically includes four-byte alignment of a start address of the first address. For the repairing of the first address, refer to Figure 6A and Figure 6B and Figure 6A and Figure 6B The description of the corresponding embodiments will not be repeated here.
[0010] 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 a user clicks a function control of the first application or triggers an interface jump during a first application operation.
[0011] The first application can be any application program installed on the electronic device.
[0012] In this way, during the process of accessing data corresponding to the first address according to the first access request of the first application, when it is determined that the kernel is dead due to a preset type of exception, the first address currently accessed is obtained from the log file, and when it is determined that the start address of the first address is not four-byte aligned, the start address of the first address is repaired to a four-byte aligned start address, without restarting the electronic device, normal data access can be performed, thereby ensuring the stability of the whole machine / system and improving the user experience.
[0013] According to the first aspect, the method further includes: obtaining a second access request of the first application; accessing data of a second address based on the second access request, wherein the kernel is dead due to a preset type of exception during the process of accessing the data of the second address; obtaining the second address from the log file and repairing the second address; wherein the start address of the second address is four-byte aligned, and the preset bit of the second address contains N zeros, N being an integer greater than 0 and less than 3; accessing the data of the second address based on the repaired second address; wherein the start address of the repaired second address is four-byte aligned, and the preset bit does not contain zero.
[0014] In some possible implementation manners, the exception address read from the log file, such as the second address, is specifically a binary address, that is, an address including only 0 and 1, and the binary address can be an address occupying 64 bits. When the second address occupies an address of 64 bits, the preset bit is, for example, the high bit in the following embodiments, that is, the first 24 bits.
[0015] The content of the high bit of the normal binary address can be Figure 7A , that is, all 1s. Therefore, by judging whether the high bit contains 0 and the number of 0s, it can be determined whether the high bit of the second address has Bitflip.
[0016] The judgment logic and corresponding scenario for the second address read from the log file can be found in steps 301-304, 306-308, and 319, 320 of 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 is dead due to the occurrence of the preset type of exception, the second address currently accessed is obtained from the log file, and when it is determined that the start address of the second address is four-byte aligned and contains one or two 0s in the preset bit, the 0s in the preset bit of the second address are repaired to 1s, that is, the values of the bits that have jumped are flipped, without restarting the electronic device, normal data access can be performed, thereby ensuring the stability of the whole machine / system and improving the user experience.
[0018] According to the first aspect or any one of the implementations of the first aspect, the method further includes: restarting the electronic device when the data at the second address cannot be accessed based on the repaired second address.
[0019] For example, if the 0s in the preset bit of the second address are repaired to 1s, but the data still cannot be accessed or normally accessed based on the repaired second address, it is not caused by Bitflip that the current preset type of exception occurs and the kernel is dead, and therefore, in order to quickly restore the access of the first application to the data, the electronic device needs to be restarted, specifically, the whole machine needs to be hot-started.
[0020] For specific implementation details of this scenario, please refer to steps 301-304, 306-309 of the following embodiments, which will not be repeated here.
[0021] According to the first aspect or any one of the implementations of the first aspect, the method further includes: 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, the kernel is dead based on the preset type of exception; obtaining the third address from the log file and repairing the third address; wherein the start address of the third address is four-byte aligned, and the preset bit of the third address contains M 0s, M being 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 being the register corresponding to the third address, and the second register being the upper-level register of the first register; the third address is an address of a data segment, and the instruction corresponding to the third address is a load instruction or a transfer instruction; accessing the data at the third address based on the repaired third address; wherein the start address of the repaired third address is four-byte aligned, and the preset bit does not contain 0.
[0022] The data segment (also referred to as a data area, a static data area, or a static area) is data in the program. For the data segment, it can also be understood as a global variable in the program. For the addresses of the data segment and the non-data segment, refer to the description of step 313 in the following embodiments, which will not be repeated here.
[0023] The first register, the second register, and the third register to the fourth register appearing later 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 characterize a certain register.
[0024] For the judgment logic and the corresponding scenario that the address read from the log file is the third address, 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 crashes due to the occurrence of the preset type of exception, the third address currently accessed is obtained from the log file, 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 embodiments, and then it is determined that the problem causing the kernel crash of the electronic device is because the Bitflip occurs in the third address when the conditions are satisfied. In this way, by repairing 0 in the preset bit position of the third address where the Bitflip occurs to 1, that is, by flipping the value of the bit position where the jump occurs, normal data access can be performed without restarting the electronic device, thereby ensuring the stability of the whole machine / system and improving the user experience.
[0026] According to the first aspect, or any one of the implementations of the first aspect, the method further includes: obtaining a fourth access request of the first application; accessing data of a fourth address based on the fourth access request, wherein the kernel crashes based on the occurrence of the preset type of exception in the process of accessing the data of the fourth address; obtaining the fourth address from the log file; when the start address of the fourth address is four-byte aligned, the preset bit position 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 restarts; wherein M is an integer greater than or equal to 3, the third register is a register corresponding to the fourth address, and the fourth register is a register one level above the third register.
[0027] The judgment logic and corresponding scenarios for the address read from the log file being the fourth address can be found in steps 301-304, 306, 310-312, and 309 of the following embodiments, and will not be repeated here.
[0028] In this way, in the case where it is not determined that the reason for the kernel crash is that Bitflip occurs at the fourth address, the electronic device re-performs hot start of the whole machine, so that access of the first application to the data can be restored as soon as possible.
[0029] According to the first aspect, or any one of the implementations of the first aspect, the method further includes: obtaining a fifth access request of the first application; accessing data at a fifth address based on the fifth access request, wherein the kernel crashes in the process of accessing the data at the fifth address based on a preset type of exception; obtaining the fifth address from the log file; and restarting the electronic device when a start address of the fifth address is four-byte aligned, M zeros are contained on a preset bit of the fifth address, an address of a sixth register is the same as an address of any register except the fifth register, and the fifth address is not an address of a data segment, where M is an integer greater than or equal to 3, the fifth register is a register corresponding to the fifth address, and the sixth register is a higher-level register of the fifth register.
[0030] The judgment logic and corresponding scenarios for the address read from the log file being the fifth address can be found in steps 301-304, 306, 310-313, and 309 of the following embodiments, and will not be repeated here.
[0031] In this way, in the case where it is not determined that the reason for the kernel crash is that Bitflip occurs at the fifth address, the electronic device re-performs hot start of the whole machine, so that access of the first application to the data can be restored as soon as possible.
[0032] According to the first aspect, or any one of the implementations of the first aspect, the method further includes: obtaining a sixth access request of the first application; accessing data at a sixth address based on the sixth access request, wherein the kernel crashes in the process of accessing the data at the sixth address based on a preset type of exception; obtaining the sixth address from the log file; and restarting the electronic device when a start address of the sixth address is four-byte aligned, M zeros are contained on a preset bit of the fifth address, an address of an eighth register is the same as an address of any register except a seventh register, the sixth address is an address of a data segment, and an instruction corresponding to the sixth address is not a load instruction or a transfer instruction, where M is an integer greater than or equal to 3, the seventh register is a register corresponding to the sixth address, and the eighth register is a higher-level register of the seventh register.
[0033] The judgment logic and corresponding scenarios of the address read from the log file being the sixth address can be found in steps 301-304, 306, 310-314, and 309 of the following embodiments, and will not be repeated here.
[0034] In this way, in the case where it is unable to determine that the reason for the kernel crash is the Bitflip of the sixth address, the electronic device can quickly restore the access of the first application to the data by re-performing the hot start of the whole machine.
[0035] According to the first aspect, or any one of the implementations of the above first aspect, the load instruction includes an LDR instruction and an LDUR instruction, and the transfer instruction includes an STR instruction.
[0036] According to the first aspect, or any one of the implementations of the above first aspect, the method further includes: obtaining a seventh access request of the first application; accessing data of a seventh address based on the seventh access request, wherein the kernel crashes in the process of accessing the data of the seventh address based on a preset type of exception; obtaining the seventh address from the log file; wherein the start address of the seventh address is four bytes 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 the eighth address of the ninth register accessed does not have a bit flip problem, and the ninth register is the register corresponding to the seventh address; flipping the value of the bit of the eighth address where the bit flip occurs to obtain a repaired eighth address; accessing the data of the eighth address based on the repaired eighth address; and accessing the data of the seventh address based on the seventh address.
[0037] The judgment logic and corresponding scenarios of the address read from the log file being the seventh address can be found in steps 301-304, 306, 315, and 317-319, and 320 of the following embodiments, and will not be repeated here.
[0038] Thus, in the process of accessing data corresponding to the seventh address according to the seventh access request of the first application, when it is determined that the kernel is currently dead due to the occurrence of the preset type of exception, the seventh address currently accessed is obtained from the log file, whether the seventh address meets the conditions of steps 301-304, step 306, step 315, and steps 317-319, and step 320 in the embodiments are judged, and when the conditions are met, it is determined that the problem causing the kernel of the electronic device to die is that the eighth address accessing the register corresponding to the seventh address has Bitflip. Thus, by repairing 0 in the preset bit of the eighth address where Bitflip occurs to 1, i.e., flipping the value of the bit where the jump occurs, the electronic device can perform normal data access without restarting, thereby ensuring the stability of the whole machine / system and improving the user experience.
[0039] According to the first aspect, or any one of the implementations of the above first aspect, the method further includes: determining the currently run assembly instruction according to the stack information in the log file; and in the currently run assembly instruction, finding upwards from the last run assembly instruction to determine the address corresponding to the assembly instruction or the address of the operation corresponding to the assembly instruction of the found assembly instruction accessing the ninth register as the eighth address.
[0040] For the determination manner of the eighth address, refer to step 317 in the embodiments below, which will not be repeated here.
[0041] According to the first aspect, or any one of the implementations of the above first aspect, the method further includes: obtaining a ninth access request of the first application; accessing data of a ninth address based on the ninth access request, and in the process of accessing data of the ninth address, the kernel is dead based on the occurrence of the preset type of exception; obtaining the ninth address from the log file; when the start 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 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.
[0042] For the judgment logic and corresponding scenarios of the address read from the log file being the ninth address, refer to steps 301-304, step 306, step 315, and step 316 in the embodiments below, which will not be repeated here.
[0043] Thus, in the case where it cannot be determined that the reason causing the kernel to die is that the ninth address has Bitflip, the electronic device restarts the whole machine to recover the access of the first application to data as soon as possible.
[0044] According to a first aspect, or any one of the implementations of the first aspect, the method further includes: obtaining a tenth access request of the first application; accessing data at a tenth address based on the tenth access request, wherein, in the process of accessing the data at the tenth address, a kernel crash occurs based on a preset type of exception; obtaining the tenth address from the log file; when a start address of the tenth address is four bytes aligned, the preset bit of the tenth address does not contain 0, the tenth address is the same as an address corresponding to any register except an eleventh register, and there is a bit flip problem in accessing the address of the eleventh register, the electronic device restarts; and the eleventh register is a register corresponding to the tenth address.
[0045] For the judgment logic and the corresponding scenario that the address read from the log file is the tenth address, 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 reason for the kernel crash is because the tenth address has Bitflip, the electronic device can quickly recover the access of the first application to the data by restarting the hot start of the whole machine.
[0047] According to the first aspect, or any one of the implementations of the first aspect, the log file is obtained from the call stack based on an exception handling function corresponding to the preset type of exception.
[0048] For example, when the preset type of exception is, for example, the DAbt exception or the instruction exception described in the following embodiments, the log file obtained from the call stack when the kernel crash occurs due to the preset type of exception is, for example, based on the do_mem_abort exception handling function.
[0049] For details of determining the preset type of exception that causes the kernel crash, obtaining exception data from the call stack based on the exception handling function corresponding to the exception, and obtaining the log file, refer to steps 301 to 303 in the following embodiments, which will not be repeated here.
[0050] According to the first aspect, or any one of the implementations of the first aspect, the address obtained from the log file is a binary address, occupying 64 bits, and the preset bit is the first 24 bits.
[0051] According to the first aspect, or any one of the implementations of the first aspect, the electronic device restarts, including: the electronic device performs a hot start, starts a computer program of the electronic device, and loads the first application.
[0052] In a second aspect, the present application provides an electronic device. The electronic device comprises a memory and a processor, the memory and the processor are coupled; the memory stores program instructions, the program instructions are executed by the processor to enable the electronic device to perform the method of the first aspect or any possible implementation manner of the first aspect.
[0053] The second aspect and any possible implementation manner of the second aspect correspond to the first aspect and any possible implementation manner of the first aspect respectively. The technical effects of the second aspect and any possible implementation manner of the second aspect correspond to the technical effects of the first aspect and any possible implementation manner of the first aspect, which will not be described here.
[0054] In a third aspect, the present application provides a computer readable medium for storing a computer program, the computer program comprising instructions for performing the method of the first aspect or any possible implementation manner of the first aspect.
[0055] The third aspect and any possible implementation manner of the third aspect correspond to the first aspect and any possible implementation manner of the first aspect respectively. The technical effects of the third aspect and any possible implementation manner of the third aspect correspond to the technical effects of the first aspect and any possible implementation manner of the first aspect, which will not be described here.
[0056] In a fourth aspect, the present application provides a computer program comprising instructions for performing the method of the first aspect or any possible implementation manner of the first aspect.
[0057] The fourth aspect and any possible implementation manner of the fourth aspect correspond to the first aspect and any possible implementation manner of the first aspect respectively. The technical effects of the fourth aspect and any possible implementation manner of the fourth aspect correspond to the technical effects of the first aspect and any possible implementation manner of the first aspect, which will not be described here.
[0058] In a fifth aspect, the present application provides a chip, the chip comprising a processing circuit, a receiving pin and a transmitting pin. The receiving pin, the transmitting pin and the processing circuit communicate with each other through an internal connection path. The processing circuit executes the method of the first aspect or any possible implementation manner of the first aspect to control the receiving pin to receive a signal and control the transmitting pin to transmit a signal.
[0059] The fifth aspect and any possible implementation manner of the fifth aspect correspond to the first aspect and any possible implementation manner of the first aspect respectively. The technical effects of the fifth aspect and any possible implementation manner of the fifth aspect correspond to the technical effects of the first aspect and any possible implementation manner of the first aspect, which will not be described here. BRIEF DESCRIPTION OF DRAWINGS
[0060] Figure 1 A hardware structure schematic diagram of an electronic device is exemplarily shown;
[0061] Figure 2 A software structure schematic diagram of an electronic device is exemplarily shown;
[0062] Figure 3 An interaction schematic diagram of functional modules involved in an exception handling method provided by the present application is exemplarily shown;
[0063] Figure 4 A flow schematic diagram of an exception handling method provided by an embodiment of the present application is exemplarily shown;
[0064] Figure 5 Another flow schematic diagram of an exception handling method provided by an embodiment of the present application is exemplarily shown;
[0065] Figure 6A A schematic diagram of an exception address not aligned with four bytes is exemplarily shown;
[0066] Figure 6B A schematic diagram of an address after repairing an exception address in Figure 6A is exemplarily shown;
[0067] Figure 7A A schematic diagram of a 64-bit exception address in which high-bit addresses do not include 0 is exemplarily shown;
[0068] Figure 7B A schematic diagram of a 64-bit exception address in which high-bit addresses include one 0 is exemplarily shown;
[0069] Figure 7C A schematic diagram of a 64-bit exception address in which high-bit addresses include four 0s is exemplarily shown;
[0070] Figure 8 A structure schematic diagram of an apparatus for implementing an exception handling method provided by the present application is exemplarily shown. DETAILED DESCRIPTION
[0071] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the scope of protection of the present application.
[0072] The term "and / or", as used herein, merely describes association between associated objects, and can exist in three forms: for example, A and / or B can mean: A alone, both A and B, or B alone.
[0073] The terms "first" and "second" and the like in the specification and claims of the present application are used to distinguish different objects, and are not used to describe a specific order of the objects. For example, the first target object and the second target object are used to distinguish different target objects, and are not used to describe a specific order of the target objects.
[0074] In the embodiments of the present application, the words "exemplary" or "for example" are used to mean serving as an example, instance, or illustration, and not necessarily to imply any preference or advantage as compared to other embodiments or designs. The use of the words "exemplary" or "for example" is intended to present concepts in a concrete manner, in a particular way.
[0075] In the description of the embodiments of the present application, unless otherwise specified, the meaning of "a plurality of" is two or more. For example, a plurality of processing units means two or more processing units; a plurality of systems means two or more systems.
[0076] In order to facilitate understanding of the embodiments of the present application, the following explains some of the terms involved in the embodiments of the present application, so as 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 a new product or new model (i.e. electronic equipment of different models) is launched in a key area, finding out 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, first explain the dump file. The so-called dump file is a memory dump file, which can also be called a memory snapshot file (memory image). The dump file contains module information, thread information, stack call information, exception information and other data of the program running, which can facilitate system technicians to troubleshoot errors, and thus quickly and accurately locate problems and solve problems in a timely manner.
[0081] The fulldump file is a dump file containing complete address space data of a certain process and much user debugging information.
[0082] Since the dump file / fulldump file is for system technicians to troubleshoot errors, only the electronic device that has not been put on the market (not commercially available, i.e., in the research stage) opens the interface for outputting the dump file / fulldump file. For commercially available electronic devices, i.e., electronic devices for a large user group, generally no dump file / fulldump file is generated, and only the last point of log is saved when an exception occurs. According to the log file, it is usually only possible to see that an exception has occurred and the stack corresponding to the exception. However, it is not possible to know the specific data of each traversal in the stack and the source of the data, so it is not possible to know at which link the exception specifically occurs and the specific reason for the exception.
[0083] (3) Bitflip problem
[0084] Specifically, the Bitflip problem in the embodiments of the present application refers to a jump problem. Specifically, it refers to that the data / address to be accessed during program running has one or more bit flips, for example, a bit originally being 0 is flipped to 1, and a bit originally being 1 is flipped to 0.
[0085] Exemplarily, in some possible implementation manners, the bits that have the flip may be bits in a universal flash storage (UFS / flash).
[0086] Exemplarily, in another possible implementation manner, the bits that have the flip may also be bits in a double data rate (DDR).
[0087] Exemplarily, in another possible implementation manner, the bits that have the flip may also be bits in a cache or a register of a CPU.
[0088] That is, the Bitflip problem can occur in various memory devices mentioned above. At present, the self-repair (that is, automatically repairing when the Bitflip problem occurs, without restarting the electronic device) for the Bitflip problem usually requires that the electronic device itself has a high-end chip, such as a chip supporting the Error Correcting Code (ECC) capability, and has requirements for the type of CPU. However, even if the high-end chip with the ECC capability, at present, can only implement the processing of the Bitflip problem occurring in the cache. When the Bitflip problem occurs in other memory devices, the electronic device is still restarted to solve the problem.
[0089] In addition, it should be noted that the Bitflip problem can be divided into two types of exceptions: instruction exception and data exception.
[0090] Regarding the instruction exception, it specifically refers to the machine code (instruction) to be run has a jump, resulting in accessing an undefined instruction.
[0091] For example, the instruction (hexadecimal) to be run is “F85C012A”, which corresponds to the binary number “1111 1000 0101 1100 0000 0001 0010 1010”. If the first 2 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 cannot be normally accessed, 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, thereby triggering a whole machine restart.
[0092] It should be understood that the above description is only an example for better understanding the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0093] In addition, it should be noted that if the machine code (instruction) to be run has a jump, but the machine code (instruction) after the jump is still a defined instruction. For this case, in actual application, the instruction after the jump can still be accessed, but since the actual accessed instruction is not the same as the expected accessed instruction, continuing to run can cause the data exception or other exceptions mentioned below. That is, the jump of the machine code (instruction) will still cause an exception.
[0094] That is, as long as the machine code (instruction) to be run jumps, whether the machine code (instruction) after the jump is an undefined instruction or a defined instruction, it will cause an exception.
[0095] Regarding the data exception, specifically, it refers to a data termination exception (DAbt). Part of the reason for causing a data exception can be that the address to be accessed jumps, causing access to an illegal address.
[0096] For example, if the binary number corresponding to the address to be accessed is "1111 1111 1111 1111 1111 1111 1100 0000 0011 1001 0111 0111 1001 1001 0010 0000", and the 2nd and 4th bits are flipped, i.e. the binary number corresponding to the address to be accessed becomes "1010 1111 1111 1111 1111 1111 1100 0000 0011 1001 0111 0111 1001 1001 0010 0000", and the address obtained after the jump "1010 1111 1111 1111 1111 1111 1100 0000 0011 1001 0111 0111 1001 1001 0010 0000" is an illegal address, i.e. 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 when this problem, i.e. the DAbt problem, occurs, and trigger a whole machine restart.
[0097] It should be understood that the above description is only an example for better understanding of the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0098] In addition, it should be noted that in the present application, the Bitflip problem is mainly caused by device anomalies (device defects).
[0099] In addition, it should be noted that in the present application, the whole machine restart after the Bitflip problem 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 does not power off.
[0100] Specifically, the so-called cold start refers to the start of the electronic device in the case of not being powered on. In the cold start process, the electronic device needs to be powered on first, i.e. power-on start. The hot start refers to the start of the electronic device in the case of being powered on, specifically the start of the computer program in the continuous power state, which is usually used when the machine runs abnormally.
[0101] In addition, it also needs to be explained that if the address to be accessed jumps, but the address after the jump is a legal address that can be accessed. For this case, if the running continues to operate the data used by other task processes, the actual corresponding task process of the data will have an error when normally accessed, and the whole machine will be restarted.
[0102] That is, as long as the address to be accessed jumps, whether the address after the jump 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 can occur in various memory devices, and the current electronic device, and the electronic device with ECC capability of high-end chips, can only process the Bitflip problem occurring in the cache. That is, it cannot process the Bitflip problem occurring in other memory devices.
[0104] In addition, since the current commercial electronic device does not support outputting a fulldump file. Therefore, in the commercial scene, the electronic device determined to be a faulty machine cannot be quickly and accurately positioned even if it is sent to a sales outlet or an after-sales center. That is, it is not convenient to define and position the EWP problem.
[0105] Therefore, the present application provides an exception processing method, which aims to process the Bitflip problem occurring in various memory devices of an electronic device that does not output a fulldump file without increasing hardware costs and without limiting the type of CPU, and after positioning the problem, the exception problem can be repaired on the spot, so that the electronic device will not be restarted, thereby ensuring the stability of the whole machine / system and improving the user experience.
[0106] In addition, since the exception processing method provided by the present application can analyze and position the exception problem of an electronic device that does not support outputting a fulldump file, by applying the exception processing method provided by the present application to a commercial electronic device, the definition and positioning of the EWP problem can be better achieved, so that the manufacturer of the faulty machine can quickly and accurately position the problem and solve it.
[0107] The exception processing method provided by the present application is mainly applied to an electronic device. In some possible implementation manners, the electronic device can be a commercial electronic device, i.e., an electronic device that does not support outputting a fulldump file. In other possible implementation manners, the electronic device can also be an electronic device used in the research stage, i.e., an electronic device that can output a fulldump file.
[0108] In addition, regarding the electronic device in the embodiment, whether it is commercial or in the research stage, it can be a mobile terminal or a non-mobile terminal. The mobile terminal can be a mobile phone, a notebook computer, a tablet computer, a palm computer, a vehicle-mounted terminal, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc., and the non-mobile terminal can be a personal computer (PC), a television, a cashier machine, a self-service machine, etc., which are not listed one by one here, and the present application does not make any limitation thereto.
[0109] In order to better understand the technical solutions provided by the embodiments of the present application, before the technical solutions of the embodiments of the present application are described, the hardware structure of the electronic device to which the embodiments of the present application are applicable is first described in conjunction with the accompanying drawings. In order to facilitate the description, Figure 1 A mobile phone is taken as an example for description.
[0110] Referring to Figure 1 The mobile phone 100 can include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charge 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 key 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] The processor 110 can include one or more processing units, for example: the processor 110 can include an application processor (AP), a modem, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc., which are not listed one by one here, and the present application does not make any limitation thereto.
[0112] In addition, the processor 110 can further include one or more interfaces. Among them, the interface can 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, and the like, which will not be listed one by one here, and the present application does not make any limitation thereto.
[0113] In addition, the processor 110 can 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 can save instructions or data that the processor 110 has just used or repeatedly uses. If the processor 110 needs to use the instructions or data again, it can be directly called from the memory. Avoiding repeated access, reducing the waiting time of the processor 110, thus improving the efficiency of the system.
[0114] Continuing to refer to Figure 1 The external memory interface 120 can be used to connect an external storage card, such as a Micro SD card, to expand the storage capacity of the mobile phone 100. The external storage card communicates with the processor 110 through the external memory interface 120 to realize the data storage function.
[0115] Continuing to refer to Figure 1The internal memory 121 can be used to store computer executable program codes including instructions. The processor 110 performs 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 can include a program storage area and a data storage area. The program storage area can store an operating system, at least one application program required by a function, and the like. The data storage area can store data created during use of the mobile phone 100, and the like. In addition, the internal memory 121 can include a high-speed random access memory, and can further include a non-volatile memory such as at least one magnetic disk storage device, a flash memory device, a universal flash storage (UFS), and the like.
[0116] With continued reference to Figure 1 The charging management module 140 is configured to receive charging input from a charger.
[0117] With continued reference to Figure 1 The power management module 141 is configured to connect the battery 142 and the charging management module 140 to the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, and the wireless communication module 160, and the like. The power management module 141 can also be configured to monitor parameters such as battery capacity, battery cycle count, battery health status (leakage, impedance), and the like.
[0118] With continued reference to Figure 1 The wireless communication function of the mobile phone 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, a modem processor, and a baseband processor, and the like.
[0119] It should be noted that the antenna 1 and the antenna 2 are configured to transmit and receive electromagnetic wave signals. Each antenna in the mobile phone 100 can be configured to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example, the antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other implementations, the antennas can be used in combination with a tuning switch.
[0120] With continued reference to Figure 1The mobile communication module 150 can provide a solution for wireless communication including 2G / 3G / 4G / 5G, etc. applied to the phone 100. The mobile communication module 150 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, and perform filtering, amplification, etc. on the received electromagnetic waves, and transmit the processed signals to the modem processor for demodulation. The mobile communication module 150 can also amplify the signals modulated by the modem processor, and radiate the signals as electromagnetic waves through the antenna 1. In some implementations, at least part of the functions of the mobile communication module 150 can be provided in the processor 110. In some implementations, at least part of the functions of the mobile communication module 150 can be provided in the same device as at least part of the functions of the processor 110.
[0121] Referring back to FIG. 1, Figure 1 The wireless communication module 160 can provide a solution for wireless communication including wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) network), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR) technology, etc. applied to the phone 100. The wireless communication module 160 can be one or more devices that integrate at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering on the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 can also receive signals to be transmitted from the processor 110, perform frequency modulation and amplification on the signals, and radiate the signals as electromagnetic waves through the antenna 2.
[0122] Referring back to FIG. 1, Figure 1 The audio module 170 can include a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, etc.
[0123] Referring back to FIG. 1, Figure 1 The sensor module 180 can include a pressure sensor, a gyro sensor, a barometric 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 one by one here, and the present application does not limit the same.
[0124] With reference to both Figure 1 , the keys 190 include a power key, a volume key, etc.; the motor 191 can generate a vibration prompt; the indicator 192 can be an indicator light, which can be used to indicate a charging state, a power change, and can also be used to indicate a message, a missed call, a notification, etc.
[0125] With reference to both Figure 1 , the camera 193 is used to capture still images or videos. The display screen 194 is used to display images, videos, etc.
[0126] The hardware structure of the mobile phone 100 will be described here, and it should be understood that Figure 1 The mobile phone 100 shown is only an example, and in specific implementations, the mobile phone 100 can have more or fewer components than those shown in the figure, can combine two or more components, or can have a different component configuration. Figure 1 The various components shown in the mobile phone 100 can 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 on top of the hardware components of the electronic device, an operating system such as a Windows system, or an Android system, or an iOS system, etc. also needs to be run. And on top of the operating system, an application program can also be installed and run.
[0128] In addition, it should be understood that regardless of which operating system, a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture can be used. For ease of illustration, the Android system with a layered architecture is taken as an example to illustrate the software structure of the electronic device, such as the Figure 1 mobile phone 100.
[0129] Referring to Figure 2 , a software structure block diagram of the mobile phone 100 of the embodiments of the present application.
[0130] As shown in Figure 2 , the layered architecture of the mobile phone 100 divides the software into several layers, each layer has a clear role 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 / applications (Applications) belongs to the application part, the framework layer / application framework layer (Application Framework, FWK) belongs to the core part, the runtime (Runtime) and system library, the hardware abstraction layer (Hardware Abstract Layer, HAL) belongs to the bottom part, and the Linux kernel (Linux Kernel) layer.
[0131] The application layer can include a series of application packages. As shown in Figure 2 , the application packages can include camera, game, video, live broadcast, etc. application programs, which are not listed one by one here, and the present application does not limit this.
[0132] The framework layer can provide application programming interfaces (APIs) and programming frameworks for the application programs of the application layer. In some implementations, these programming interfaces and programming frameworks can be described as functions. As shown in Figure 2 , the framework layer can include content providers, window managers, resource managers, view systems, etc. functions, which are not listed one by one here, and the present application does not limit this.
[0133] The content provider is used to store and obtain data, and make the data accessible to the application program. The data can include video, image, audio, dialed and answered phone, browsing history and bookmark, phone book, etc. which are not listed one by one here, and the present application does not limit this.
[0134] The window manager is used to manage the window program. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, and intercept the screen, etc.
[0135] The resource manager provides various resources for the application program, such as localized strings, icons, pictures, layout files, video files, etc. which are not listed one by one here, and the present application does not limit this.
[0136] The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build an application program. The display interface can be composed of one or more views. For example, a display interface including a short message 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, 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. The present embodiment does not limit this.
[0138] Continuing to refer to Figure 2 , for example, the runtime, specifically the Android runtime (Android Runtime), can include a core library and a virtual machine, mainly responsible for scheduling and management of the Android system.
[0139] The core library includes two parts: one part is a function function that needs to be called by the java language, and the other part is the core library of Android. The application layer and the framework layer run in the virtual machine. The virtual machine executes the java file of the application layer and the framework layer into a binary file. The virtual machine is used to execute the management of the object life cycle, the stack management, the thread management, the security and the exception management, and the garbage collection and the like.
[0140] With reference to Figure 2 , for example, the system library can include a plurality of function modules. For example, a surface manager, media libraries, a three-dimensional (3D) graphics processing library (for example, OpenGL ES), a two-dimensional (2D) graphics engine (for example, SGL), and the like.
[0141] The surface manager is used to manage the display subsystem, and provides a fusion of 2D and 3D layers for a plurality of application programs. The media library supports a plurality of commonly used audio, video format playing and recording, and static image files and the like. The media library can support a plurality of audio and video coding formats, for example, MPEG4, H.264, MP3, AAC, AMR, JPG, PnG and the like. The three-dimensional graphics processing library is used to realize three-dimensional graphics drawing, image rendering, synthesis, and layer processing and the like.
[0142] In addition, it can be understood that the 2D graphics engine mentioned above is a drawing engine for 2D drawing.
[0143] With reference to Figure 2 , for example, the HAL layer is an interface layer between the operating system kernel (kernel layer) and the hardware circuit, and the purpose is to isolate the FWK from the kernel, so that Android does not depend too much on the kernel, so that the development of the FWK can be carried out without considering the driver.
[0144] With reference to Figure 2 , for example, the HAL layer can include various interfaces, such as audio and video interfaces, GPS interfaces, call interfaces, WiFi interfaces, and the like, which are not listed one by one, and the present application does not limit this.
[0145] With reference to Figure 2 , for example, the kernel layer in the Android system is a layer between hardware and software. The kernel layer can include various processes / threads, interrupt processing modules, exception processing modules and the like.
[0146] The various processes / threads included in the kernel layer can be task processes / threads corresponding to various application programs and the like.
[0147] The interrupt processing module and the exception processing module can also be understood as two function functions, or two processes for implementing the present application.
[0148] In the exception processing method provided by the embodiment of the present application, no matter whether an application layer has a problem or a bottom layer has a Bitflip problem, an exception process will first throw an interrupt, and then an interrupt processing module in the kernel will receive the interrupt information, and further call an exception processing module through an interrupt vector table (or inform the exception processing module through the interrupt vector table), so that the exception processing module can call a corresponding exception processing function, determine a virtual address (an exception address) of the exception and corresponding stack information, further read the exception address and the stack information from a call stack, and print the read data (output to a specified location in a log file).
[0149] In addition, it should be noted that in the exception processing method provided by the embodiment of the present application, when the exception processing module obtains the corresponding log file in the above manner, the log file will be analyzed and processed according to a specific execution strategy, and then analysis results of a specific exception type, a specific link, a specific jump position, and the like of the exception problem are determined.
[0150] In addition, after obtaining the analysis results of the current occurring exception problem, the exception processing module will also repair the current occurring exception according to the analysis results, so that the electronic device does not need to be restarted.
[0151] In addition, it should be noted that if the specific type of the current occurring exception problem, the specific link of the occurrence of the exception, the specific jump position, and the like cannot be determined through the set execution strategy, that is, no analysis results are obtained, and the repair cannot be performed, the exception processing module will directly trigger the electronic device to restart.
[0152] The execution strategy on which the exception processing module is based and the specific implementation details of the exception processing method provided by the embodiment of the present application will be described in detail in the following embodiments, and will not be described here.
[0153] In addition, it should be noted that in some possible implementation manners, the interrupt processing module and the exception processing module implemented in the kernel can also be encapsulated into the framework layer. For this implementation manner, a corresponding interface can be provided in the HAL layer, so that the interrupt processing module and the exception processing module integrated in the framework layer can interact with the kernel, and further interact with the hardware part through the interface provided by the kernel.
[0154] The software structure of the mobile phone 100 is introduced here, and it can be understood that, Figure 2The layers and components included in each layer in the illustrated software structure do not constitute a specific limitation on the mobile phone 100. In other embodiments of the present application, the mobile phone 100 can include more or fewer layers than illustrated, and each layer can include more or fewer components, without limitation.
[0155] In addition, it should be noted that although the embodiments of the present application are described by taking the Android system as an example, the basic principles are also applicable to electronic devices of 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 by the embodiments of the present application can be the electronic device as described above, or a functional module and / or functional entity (such as an interrupt processing module and an exception handling module in the kernel) capable of implementing the exception handling method in the electronic device. The specific implementation can be determined according to actual use requirements, and the present application does not make any limitation. The following will be described in combination with Figure 3 From the perspective of the functional module and / or functional entity capable of implementing the exception handling method in the electronic device, the interaction of the functional module and / or functional entity involved in the process of implementing the exception handling method provided by the embodiments of the present application will be described exemplarily.
[0157] Exemplarily, the Bitflip problem in the present embodiment is thrown by the application layer. Referring to Figure 3 When the user clicks the icon of APP1 displayed in the desktop of the electronic device, the electronic device will start APP1 in response to the operation behavior.
[0158] Continuing to refer to Figure 3 Exemplarily, since the application programs installed in the electronic device, such as APP1, and other data contents stored therein are usually saved in the form of binary files in the UFS type memory device. Therefore, the electronic device will first read the related data of APP1 from the UFS to the DDR memory device in the process of starting APP1, i.e., step 102 is performed.
[0159] Regarding the related data of APP1 read from the UFS to the DDR in step 102, for example, the data required in the running process of APP1. In some possible implementation manners, these data can include user data and program data.
[0160] Exemplarily, the user data is the data created by the user when using APP1 or the address corresponding to the data. Taking the phone application APP1 that can make voice calls as an example, the user data corresponding to APP1 can be the call record data of the user using APP1 to make a call, the recording data in the call process, etc.
[0161] For example, the program data is a program to be executed by APP1, or an instruction triggering the execution of the program, or an address corresponding to the instruction. In the startup of APP1, the first program data loaded is, for example, a configuration manifest file of APP1. The configuration manifest file is used to record the configuration information of APP1, such as including the package name information, version number information, component information, permission information, and the like of APP1.
[0162] It should be understood that the above description is only an example for better understanding the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0163] Continuing to refer to Figure 3 It should be noted that the cache is a high-speed cache between the DDR (DRAM) and the CPU. In the processor, the read / write speed of the cache is higher than that of the DDR but lower than that of the CPU. Since the speed of the CPU is much higher than that of the DDR, if there is no cache and the CPU directly accesses the DDR, the CPU needs to wait for the data of the DDR to arrive before doing other things, which will cause the CPU to have a low use efficiency. Therefore, in order to speed up the operation and improve the use efficiency of the CPU, the related data of APP1 in the DDR, such as the instructions or addresses mentioned above, can be read into the cache memory device in step 103, so that the CPU can directly read from the cache, thereby shortening the data reading time.
[0164] For the access relationship between the UFS, the DDR, the cache, and the CPU, the data read / write speed, reference can be made to the existing documents, which will not be repeated here.
[0165] Continuing to refer to Figure 3 For example, the CPU reads the related program (instruction / address) of APP1 from the cache and executes it, that is, step 104 is performed. For example, the operation of the CPU after reading the related program of APP1 from the cache is to run the read instruction or access the read address.
[0166] Continuing to refer to Figure 3 For example, if the read instruction / address does not have a Bitflip problem, APP1 will be normally started and run. Otherwise, if the read instruction / address has a Bitflip problem, APP1 (specifically, a task process corresponding to APP1) will throw an exception, that is, step 105 is performed.
[0167] It should be understood that there are many exceptions during the program running process, such as data loss, function exception, etc. Some of these exceptions will not affect the normal use of the application program, and some will cause the kernel to crash. When the kernel crashes, in order to make the kernel resume normal operation as soon as possible, in one possible implementation, the whole machine will be restarted, that is, the hot start mentioned above.
[0168] Therefore, in order to be able to implement on-site repair of the exception causing the kernel to crash when the kernel crashes, and further avoid the whole machine restart of the electronic device. Specifically in the embodiment, the exception thrown by the task process corresponding to APP1 is the exception causing the kernel to crash.
[0169] Regarding the exception that will cause the kernel to crash, it is specifically Linux exception. For Linux exception, it usually includes bug, hung, panic, and the above-mentioned Bitflip, etc. which will not be listed one by one here, and the present application does not limit this.
[0170] It should be noted that the so-called bug, also known as defect, bug, is a phenomenon that the function is not normal, dead machine, data loss, non-normal interruption, etc. caused by the misplacement of the program itself during the running of the application program. Specifically in the embodiment, the bug exception occurs, specifically the phenomenon that causes the kernel to crash.
[0171] In addition, it also needs to be explained that when the task process is working, the 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 appear to be dead, and finally only the whole machine restart can solve this kind of exception. Therefore, in order to improve the user experience and avoid the phenomenon of long-time sticking, when the sticking phenomenon occurs, the exception will also be thrown in time.
[0172] In addition, it also needs to be explained that when the task process is working, the panic exception occurs, and the kernel will directly crash and cannot run normally. In order to recover normally, only the whole machine restart can be performed.
[0173] That is, during the task process working process, when the above-mentioned exception occurs, the task process will throw an exception so that the interrupt handling module in the kernel layer can capture the exception in time.
[0174] Specific to the embodiment, in order to enable the APP1 corresponding task process to throw an exception when an exception occurs in the startup / running process of APP1, the kernel will register the corresponding interrupt handling function for the task process when starting the task process corresponding to APP1. In this way, the interrupt handling function can be called throughout the life cycle of the task process. Therefore, when the above-mentioned exception causing the kernel to crash occurs during the task process operation, the task process of APP1 will throw an exception by calling the panic() function through the interrupt handling function. That is, when the task process of APP1 calls the panic() function through the corresponding interrupt handling function, it can be regarded as that APP1 has thrown 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] Continuing to refer to Figure 3 For example, when the interrupt handling module captures the exception thrown by the task process of APP1, it will notify the exception handling module that the current kernel crash exception has occurred in the electronic device, that is, step 106 is performed.
[0177] It should be noted that before the kernel crash occurs, the electronic device is hot started, or the exception causing the kernel crash is repaired, the data corresponding to the exception causing 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 causes 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 the embodiment, the repair of the exception causing the kernel crash refers to the repair of the Bitflip problem in the DAbt exception. For other exceptions causing the kernel crash, the repair cannot be achieved through the exception handling method provided in the embodiment, that is, the whole machine still needs to be restarted.
[0179] Therefore, when it is determined that the exception causing the kernel crash of the electronic device is the DAbt exception, the obtained exception data is analyzed and processed based on the exception handling method provided in the embodiment, and then it is determined whether to perform exception repair or whole machine restart operation according to the analysis result.
[0180] Specifically, in the embodiment, the analysis result has two types, one is to determine that the cause of the DAbt exception is Bitflip, and the other is to determine that the cause of the DAbt exception is not Bitflip. Among them, for the DAbt exception caused by Bitflip, the electronic device can be repaired. For the DAbt exception caused by Bitflip, the electronic device cannot be repaired.
[0181] It should be noted that in a possible implementation, in the case where the cause of the DAbt exception is Bitflip, the analysis result can include information such as exception type, specific link causing the exception, and specific jump position. In this way, for the scenario where the analysis result is Bitflip, the exception handling module can directly repair the current exception on site according to the output analysis result, without triggering a whole machine restart, that is, reloading the software of the whole machine.
[0182] It should be noted that based on the exception handling method provided in the embodiment, the repair of different types of abnormal problems actually does not involve hardware modification, but only modification from the software perspective, such as modifying the address where the jump occurs back to the original address and modifying the instruction where the jump occurs back to the original instruction.
[0183] In addition, it should be noted that the address mentioned in the embodiment is specifically a kernel virtual address.
[0184] Continuing to refer to Figure 3 , for example, for the scenario where the analysis result is not Bitflip, the exception handling module can directly trigger a whole machine restart according to the existing processing logic.
[0185] It should be noted that when the abnormal problem cannot be repaired, the hardware is not modified.
[0186] It can be known from the description of the embodiment shown in Figure 3 The exception handling method provided by the present application does not have specific requirements for chips and CPUs, that is, it does not change the current chips and CPUs of the electronic device. Therefore, without increasing hardware costs and without limiting the type of CPU, the Bitflip problem occurring in various memory devices of the electronic device that does not output a fulldump file is handled, and after locating the problem, the abnormal problem can be repaired on site, so that the electronic device does not restart, thereby ensuring the stability of the whole machine / system and improving the user experience.
[0187] The exception handling method provided by the present application will be specifically described below in conjunction with specific embodiments.
[0188] Referring to Figure 4The abnormality processing method provided in the embodiment specifically includes steps 201 to 208. The step 201 is implemented by the interrupt processing module, and the steps 202 to 208 are implemented by the abnormality processing module.
[0189] 201. The interrupt processing module captures the exception thrown by the task process and notifies the abnormality processing module that the kernel crash exception occurs in the electronic device.
[0190] As can be known from the description of the above embodiment, the panic() function is called by the task process in the corresponding interrupt processing function only when the current occurring exception causes the kernel to crash. The interrupt processing functions corresponding to different task processes are uniformly managed by the interrupt processing module, and therefore the interrupt processing module can capture the exception thrown by the task process in time.
[0191] In addition, since the abnormality processing operation is completed by the abnormality processing module, after the interrupt processing module captures the exception causing the kernel to crash, the interrupt processing module notifies the abnormality processing module that the kernel crash exception occurs in the electronic device.
[0192] For the specific implementation details of the task process throwing the exception, the interrupt processing module capturing the exception, and the interrupt processing module notifying the abnormality processing module that the kernel crash exception occurs in the electronic device after capturing the exception, reference can be made to the description of steps 105 and 106 in the above embodiment, which will not be repeated here.
[0193] 202. The abnormality processing module determines whether the exception causing the kernel to crash is a DAbt exception.
[0194] As can be known from the description of step 105 in the above embodiment, in the embodiments of the present application, the task process calls the panic() function through the corresponding interrupt processing function on the premise that the exception causing the kernel to crash occurs. The exception causing the kernel to crash may, for example, include the Bug exception, the hung exception, the panic exception, and the instruction exception and the DAbt exception caused by Bitflip, which will not be listed one by one here, and the present application does not limit this. Among them, only the instruction exception and the DAbt exception caused by Bitflip can be repaired.
[0195] In addition, it should be noted that any of the above-mentioned exceptions that can cause the kernel to crash are thrown through the panic() function. Different exceptions correspond to different exception types, and therefore when the panic() function is used to throw the exception causing the kernel to crash, the specific exception type is carried, such as the exception type corresponding to the Bug exception, the hung exception, the panic exception, the DAbt exception, and the instruction exception.
[0196] Correspondingly, the interrupt processing module will send the exception type to the exception processing module when it informs the exception processing module that the kernel crash exception has occurred in the electronic device. In this way, the exception processing module only needs to determine whether the exception causing the kernel crash is a DAbt exception (or an instructional exception) according to the received exception type.
[0197] As can be known from the above explanation and description of the instructional exception and the DAbt exception, one of the reasons causing the instructional exception and the DAbt exception is that the corresponding instruction / address has a bit flip. The analysis and processing (determination of whether a bit flip occurs) logic of the two types of exceptions can be the same. In order to facilitate the description, the embodiment takes the determination of whether the reason causing the DAbt exception is a bit flip as an example to specifically describe the analysis and processing of the exception processing module.
[0198] Specifically, the exception processing module executes step 203 when it determines that the exception causing the kernel crash is a DAbt exception. Otherwise, it directly exits the exception processing method provided by the present application, triggers the electronic device to perform a whole machine restart according to the existing processing logic, that is, skips steps 203 to 206, and directly executes step 207.
[0199] 203. The exception processing module determines the exception address and stack information (exception data) causing the exception from the call stack according to the exception handling function corresponding to the DAbt exception.
[0200] Understandably, since different exception types will correspond to different exception handling functions, and the exception addresses, stack information, etc. corresponding to different exceptions will be different, in order to ensure the rationality of the analysis result, the embodiment will first determine the exception handling function matched with the determined exception type, and then determine the exception address and stack information (for the sake of convenience, referred to as exception data hereinafter) causing the DAbt exception from the call stack of the DDR through the exception handling function.
[0201] Regarding the call stack (also referred to as function call stack) mentioned in the embodiment, it is specifically an internal data structure called "execution context" generated in the function execution process. That is, the call stack is an internal data structure in the DDR, which can be used to store the execution environment, variables, function parameters, accessed addresses, stack, and other information of the function.
[0202] Since the present embodiment takes DAbt exception as an example, the exception handling function called by the exception handling module can be a do_mem_abort function specially used for handling DAbt exception. Through the do_mem_abort function, the exception address (specifically, the virtual address) and stack information where the exception occurs can be obtained. In this way, the operation of obtaining the exception data from the call stack and then obtaining the log file, that is, the operation of step 204, can be realized.
[0203] 204. The exception handling module obtains the determined exception data from the call stack to generate a log file.
[0204] Specifically, after obtaining the log file corresponding to the present exception, the exception handling module analyzes and processes the exception data recorded in the log file to determine whether the reason for the current DAbt exception of the electronic device is Bitflip. That is, based on the exception handling method provided in the present embodiment, after obtaining the log file corresponding to the present exception, the electronic device will not be directly triggered to restart the whole machine, nor will it be directly repaired. Instead, it is necessary to first determine whether the reason for the current DAbt exception of the electronic device is Bitflip. Because only in the case where the DAbt exception is caused by Bitflip, the repair of the exception can be realized by flipping the bit that jumps, without the need to solve the exception problem by restarting the whole 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 saved in the DDR. Therefore, in the present embodiment, the log file generated by the exception handling module will also be saved in the DDR first.
[0207] 205. The exception handling module analyzes and processes the exception data in the log file to determine whether the reason for the DAbt exception is Bitflip.
[0208] Specifically, if the exception handling module determines through analysis and processing that the reason for the DAbt exception is Bitflip, it will execute step 206. Otherwise, it will execute step 207.
[0209] For the specific implementation of the exception handling module analyzing and processing the exception data in the log file to determine whether the reason for the DAbt exception is Bitflip, reference can be made to steps 304 to 320 in the embodiment shown in Figure 5 here.
[0210] 206, the abnormality processing module repairs the DAbt abnormality (the electronic device does not need to be restarted).
[0211] For example, in a possible implementation, the abnormality processing module analyzes the abnormality data in the log file according to the processing logic of steps 304 to 320 in the embodiment shown in the figure, and when it is determined that the cause of the DAbt abnormality is Bitflip, the DAbt abnormality is repaired according to the analysis result. Figure 5 For example, in a possible implementation, the abnormality processing module analyzes the abnormality data in the log file according to the processing logic of steps 304 to 320 in the embodiment shown in the figure, and when it is determined that the cause of the DAbt abnormality is Bitflip, the DAbt abnormality is repaired according to the analysis result.
[0212] As can be seen from the above description, in the embodiment, when it is determined that the cause of the DAbt abnormality is Bitflip, the analysis result also includes information such as the abnormality type, the specific link that causes the abnormality to occur, and the specific jump position. Therefore, according to the specific environment in which the abnormality occurs and the position of the specific jump given in the analysis result, 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 is repaired, so that the electronic device can operate normally without the need for a whole-machine restart.
[0213] In addition, it should be noted that in other implementations, in order to facilitate learning of the repaired abnormality that has occurred in the electronic device, the abnormality processing module can also record the repaired abnormality type and the repair time in the path specified by the electronic device after completing step 206.
[0214] For example, the first kernel crash abnormality that occurs in the electronic device is a DAbt abnormality, and the cause of the DAbt abnormality is Bitflip. When the repair time of the abnormality is T1, the abnormality processing module records the DAbt abnormality repaired at T1 due to Bitflip in the path specified by the electronic device (for the sake of convenience, the file recording the abnormality is referred to as an abnormality repair record file).
[0215] For example, the second kernel crash abnormality that occurs in the electronic device is an instruction abnormality, and the cause of the instruction abnormality is Bitflip. When the repair time of the abnormality is T2, the abnormality processing module records the information of the instruction abnormality repaired at T2 due to Bitflip in the above abnormality repair record file.
[0216] It should be understood that the above description is only an example for better understanding of the technical solution of the embodiment and is not the only limitation of the embodiment.
[0217] 207, the abnormality processing module triggers the electronic device to restart.
[0218] Specifically, based on the abnormality processing method provided in the embodiment, when the abnormality causing the kernel to die is not the DAbt abnormality and the instruction abnormality caused by the Bitflip, i.e., when the abnormality causing the kernel to die is the Bug abnormality, the hung abnormality, or the panic abnormality, the abnormality processing module will trigger the electronic device to perform a whole-machine restart. That is, the computer program of the electronic device is restarted in a hot start manner, and thus the kernel can be restored to a normal running state.
[0219] 208, the abnormality processing module writes the log file into the disk.
[0220] Specifically, in order to facilitate the understanding of the reason causing the electronic device to perform the hot start, after the electronic device completes the hot start, in order to avoid the loss of the log file saved in the DDR, the abnormality processing module will write the log file generated in step 204 into the specified path in the disk.
[0221] Exemplarily, in some possible implementation manners, the path corresponding to the log file written into the disk and the abnormality repair record file written into the disk can be the same. In this way, it is convenient for the technician to obtain once.
[0222] Exemplarily, in another possible implementation manner, the path corresponding to the log file written into the disk and the abnormality repair record file written into the disk can be different. In this way, it is convenient for the maintenance and management of different files.
[0223] In addition, it also needs to be explained that, in order to avoid the log file and the abnormality repair record file being tampered with and deleted, the log file and the abnormality repair record file can be set to be invisible to the user.
[0224] It should be understood that the above description is only an example for better understanding the technical solution of the embodiment, and is not the only limitation of the embodiment.
[0225] Thus, when an exception occurs, causing the kernel to crash, by determining whether the currently occurring kernel crash exception is an exception (DAbt exception, instruction exception) that can be caused by Bitflip, and further determining that the exception causing the kernel to crash is a DAbt exception or an instruction exception, the exception data corresponding to the exception is obtained according to the exception processing function corresponding to the exception, and the exception data corresponding to the exception is analyzed and processed to determine whether the exception is caused by Bitflip. Thus, when the exception causing the kernel to crash is an exception caused by Bitflip, the content on the bit where Bitflip occurs is modified by flipping, and then the normal access address and instruction are restored, i.e. the exception is repaired, so that the electronic device can work normally. That is, the problem of exception does not need to be solved by restarting the whole machine software, which effectively guarantees the stability of the system and the whole machine, and improves the user experience.
[0226] In order to better understand the different exception processing functions and execution strategies used in the exception processing method provided in the present application for different types of exceptions, the following will be described in detail in combination with Figure 5 , taking the DAbt exception as an example.
[0227] Referring to Figure 5 , for example, when the current exception is a DAbt exception, the exception processing module can determine that the exception processing function to be called is the do_mem_abort function, and the corresponding execution strategy can be the analysis and processing logic of steps 304 to 320 in Figure 5 , i.e. step 301.
[0228] Continuing to refer to Figure 5 , for example, after the exception processing module completes the operation of step 301, it can determine the exception address and stack information where the exception occurs from the call stack according to the determined exception processing function (do_mem_abort function), i.e. step 302.
[0229] Continuing to refer to Figure 5 , for example, after the exception processing module determines the exception address and stack information where the exception occurs from the call stack by the do_mem_abort function, it can read the determined exception address and stack information from the call stack and print them, i.e. step 303.
[0230] As for 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) and then saved to a specified path / directory of the electronic device.
[0231] Continuing to refer toFigure 5 For example, after the operations in steps 301 to 303 are completed, the abnormality processing module can call the required components to analyze the log information in the log file according to the determined execution strategy, and determine the analysis result of the abnormality problem.
[0232] As to the partial processing logic here, steps 304 to 320 can be performed. The following will be specifically explained in combination with Figure 5 Steps 304 to 320.
[0233] First, step 304 is performed to obtain the abnormality address from the printed log file, and determine whether the abnormality address is a four-byte aligned address, i.e., whether the abnormality address is not four-byte aligned.
[0234] Specifically, the processor adopted by the electronic device in the embodiment is taken as an example, which is an ARM (Advanced RISC Machines) processor. According to the document of the ARM processor, its access rule can be divided into accessing 4-byte content (the start address of the content must be at a 4-byte aligned position) and accessing 2-byte content (the start address of the content must be at a 2-byte aligned position). The embodiment takes accessing 4-byte content as an example, so the abnormality processing module can first determine whether the abnormality address of the current abnormality exists in a non-four-byte aligned condition, i.e., whether the current abnormality is caused by the start address of the accessed content not being at a 4-byte aligned position.
[0235] It should be noted that the so-called byte alignment is that various types of data are arranged in space according to certain rules, rather than sequentially arranged one by one. Based on this, the commonly said N-byte alignment, such as the four-byte alignment in the embodiment, means that the storage start address of the data %4 == 0.
[0236] For example, if the start address of the abnormality address obtained from the log file is “FFFFFFD6938C718”, based on the above four-byte alignment standard, it can be known through the remainder operation on the start address that the final remainder is 0. Therefore, it can be determined that the abnormality address “FFFFFFD6938C718” is a four-byte aligned address.
[0237] Correspondingly, if the start address of the abnormality address obtained from the log file is “FFFFFFD6938C717”, based on the above four-byte alignment standard, it can be known through the remainder operation on the start address that the final remainder is 3. Therefore, it can be determined that the abnormality address “FFFFFFD6938C717” is a non-four-byte aligned address.
[0238] It should be understood that the above description is only an example for better understanding the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0239] Based on the above description of the four-byte alignment standard, it is determined in the embodiments whether there is a case of non-four-byte alignment in the exception address, specifically whether the remainder of the start address of the exception address divided by 4 is 0. Correspondingly, if the remainder is 0, it is determined that the start address of the current exception address is four-byte aligned, and if the remainder is not 0, it is determined that the start address of the current exception address is not four-byte aligned.
[0240] Continuing to refer to Figure 5 , for example, when it is determined that the exception address is not a four-byte aligned address, i.e., there is a case of non-four-byte alignment in the exception address, the exception processing module can directly output the analysis result that the exception cause is address non-four-byte alignment, i.e., step 305 is performed.
[0241] Continuing to refer to Figure 5 , for example, after obtaining the exact analysis result, the exception processing module can repair the current exception problem according to the analysis result, i.e., step 320 is performed. In this way, the electronic device does not need to perform software restart of the whole machine, thereby ensuring the stability of the system and the user experience.
[0242] It should be noted that for the analysis result that the exception cause is address non-four-byte alignment, the exception repair performed by the exception processing module is specifically to perform four-byte alignment on the address.
[0243] For example, if the exception address taken out from the log file corresponds to 8 bytes of data content stored in the memory, and the data stored in the exception address is of the int type (one int type occupies 4 bytes). Based on this precondition, as shown in Figure 5 , when the start address of the exception address is "18", it is known by dividing 18 by 4 that the remainder is 2, i.e., the exception address is a case of non-four-byte alignment. For this case, the exception processing module needs to add 2 bytes to the start address of the exception address when performing repair, as shown in Figure 6A . That is, the int type data in the exception address needs to be placed starting from address "20".
[0244] As shown in Figure 6B and Figure 6A , when the exception address is the start address "18" and the end address "26", by adding 2 bytes to the start address of the exception address, the exception address is repaired to the start address "20" and the end address "28", so that the exception address can be repaired to a four-byte aligned address, and thus the electronic device can normally read the content in the repaired address.
[0245] It should be understood that the above description is only an example for better understanding the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0246] With reference to Figure 6B , for example, when the exception handling module determines that there is no un-quadruple-byte alignment in the exception address, i.e., the exception address is quadruple-byte alignment, step 306 can be performed.
[0247] With reference to Figure 5 , for example, for the case that there is no un-quadruple-byte alignment in the exception address, the exception handling module can further determine whether the exception address is a phenomenon mapping kernel virtual address.
[0248] As to the method of determining whether the exception address is a phenomenon mapping kernel virtual address, it can be specifically checking the number of 0 in the high bits of the exception address.
[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 high bits according to business needs. For the convenience of description, the ARM processor in the embodiments is a 64-bit processor. Accordingly, the high bits to be checked are the first 24 bits.
[0250] With reference to Figure 5 , a 64-bit exception address (binary) "1111 1111 1111 111111111111 1100 0000 0011 1001 0111 0111 1001 1001 0010 0000" is exemplarily shown. For the exception address, the high bits to be checked are the 24 bits between the 0th bit and the 23rd bit shown in Figure 7A .
[0251] It should be understood that the above description is only an example for better understanding the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0252] In addition, it should be further noted that, in general, all bits in the high bits are 1, as shown in Figure 7A . Therefore, if 0 appears in the high bits, it indicates that a jump occurs, and the jump caused by different links or reasons will cause different numbers of 0 in the high bits.
[0253] With reference to Figure 7AFor example, if the first 24 bits of the exception address have 1 bit or 2 bits being 0, i.e., the number of 0s (num) satisfies the following relationship: 0 < num < 3, the exception processing module can attempt to fix the high bits of the address to the kernel linear virtual address range and attempt to access, i.e., perform step 307.
[0254] For example, the exception processing module checks the first 24 bits of the exception address. If the 10th bit is 0, as shown in Figure 5 , the exception processing module performs step 307.
[0255] It should be understood that the above description is only an example for better understanding the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0256] For example, the exception processing module attempts to fix the high bits of the address to the kernel linear virtual address range, e.g., changes the value of the bit on which 0 appears in the high bits of the address to 1. In this way, the fixed address is obtained, and the exception processing module can attempt to access the fixed address.
[0257] Referring back to Figure 7B , for example, if the address obtained after the exception processing module attempts to fix the high bits of the address to the kernel linear virtual address range can be accessed, the analysis result indicating that the exception cause is Bitflip can be output, i.e., step 319 is performed. In this way, the exception processing module can perform on-site repair according to the output analysis result, so that the software in the electronic device does not need to be restarted, i.e., step 320 is performed.
[0258] It should be noted that since 1 bit or 2 bit flip is usually caused by device problems (device defects), the output analysis result can not only include description information indicating that the current exception cause is a Bitflip problem, but also include information indicating that the Bitflip problem is caused by device defects, the exception address that needs to be repaired, the specific bit that has flip, etc.
[0259] It should be understood that the above description is only an example for better understanding the technical solutions of the embodiments and is not the only limitation of the embodiments.
[0260] Referring back to Figure 5For example, if the address after the high-bit address to the kernel thread virtual address range cannot be accessed after the repair attempt, it indicates that the cause of the address jump to the above-mentioned abnormal address is not a device defect, and the specific cause cannot be determined. Therefore, in order to solve the current abnormal problem and make the electronic device return to normal operation, the abnormal processing module can only trigger the electronic device to perform a whole machine restart (software restart), that is, step 309 is executed.
[0261] Continuing to refer to Figure 5 For example, if the first 24 bits of the abnormal address have 3 or more than 3 0s, that is, 3 or more bits are 0. For this case, it is not only a device problem (a pure device problem generally does not jump more than 2 bits), but also an abnormal processing link. Specifically, in the abnormal processing method provided in the present application, when num≥3 is determined, the abnormal processing can be performed according to the processing procedure of steps 310 to 314.
[0262] For example, the abnormal processing module checks the first 24 bits of the abnormal address. If the 10th bit, the 12th bit, the 18th bit, and the 21st bit appear 0, as shown in Figure 5 , the abnormal processing can be performed according to the processing procedure of steps 310 to 314.
[0263] It should be understood that the above description is only an example for better understanding the technical solution of the present embodiment, and is not the only limitation of the present embodiment.
[0264] Continuing to refer to Figure 7C For example, for the case of num≥3, the content of the accessed register can be taken out first, that is, step 310 is executed.
[0265] Taking the LDUR instruction corresponding to the abnormal address as an example, 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]”. The content to be accessed by the register x10 is “[x9, # -0x40]; x10, [x9, # -64]”. The content indicates that the start address corresponding to “x10” is the address offset # -0x40 of the register “x9”, and the end address is the address offset # -64 of the register “x9”.
[0266] It should be understood that the above description is only an example for better understanding the technical solution of the present embodiment, and is not the only limitation of the present embodiment.
[0267] Continuing to refer to Figure 5For example, after the content in the currently accessed register is taken out, the address of the previous register (referred to as address 1 for convenience of description) can be determined according to the taken-out register content, that is, step 311 is performed.
[0268] As can be seen from the example listed in step 310, the address of the register to be currently accessed is determined by corresponding offsetting from the address of another register, and therefore, in this embodiment, the register is referred to as the previous register of the register to be currently accessed.
[0269] Still taking the example listed in step 310, in the case where the start address corresponding to "x10" is the address of register "x9" offset by # -0x40, and the end address is the address of register "x9" offset by # -64, and the address of register x10 is "F85C012A", the address of register x9 needs to be offset by # -0x40 and # -64 from the address of register x10, and then the start address and the end address corresponding to register x9 are obtained.
[0270] It should be understood that the above description is only an example for better understanding the technical solution of this embodiment, and is not the only limitation of this embodiment.
[0271] Continuing to refer to Figure 5 For example, after the address 1 is obtained, the exception processing module can traverse the addresses corresponding to the registers other than the currently accessed register such as x10, and match the addresses of the traversed registers with the address 1, that is, step 312 is performed.
[0272] For example, taking the ARM processor as 64 bits, the corresponding number of processors can be 32. For this case, the maximum number of registers to be traversed by the exception processing module is 31.
[0273] Continuing to refer to Figure 5 For example, if the address 1 is the same as the address of any one of the 31 registers, it can be determined that there is no possibility of high-bit transition of the data saved in the register. Therefore, the current exception is not caused by the data saved in the register. For this case, the exception address can be classified to determine whether the exception address is the address of a data segment or the address of a non-data segment (such as the address of a code segment), that is, step 313 is performed.
[0274] It should be noted that the code segment mentioned above refers to the executable part in the program, which is composed of function stacks. The data segment (also referred to as the data area, the static data area, or the static area) is the data in the program. For the data segment, it can also be understood as the global variable in the program. The specific difference between the data segment and the code segment will not be described here.
[0275] With reference to Figure 5 For example, if the exception address is not the address of the data segment, the exception handling module cannot determine whether the current exception is caused by the jump at this stage. Therefore, there is no way to output the analysis result. In order to solve the exception problem and make the electronic device run normally, the exception handling module can only trigger the electronic device to perform a whole machine restart (software restart), that is, step 309 is performed.
[0276] With reference to 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 / transmission instruction, that is, step 314 is performed.
[0277] It should be noted that in the embodiment, the load instruction mentioned above can be, for example, an LDR instruction or an LDUR instruction. As for the transmission instruction mentioned above, it can be, for example, an STR instruction (used to transmit a 32-bit word data from a source register to a memory). For the use of LDR instructions, LDUR instructions, and STR instructions, please refer to the relevant documents, which will not be described here.
[0278] With reference to Figure 5 For example, if the instruction corresponding to the exception address is neither a load instruction nor a transmission instruction, the exception handling module cannot determine whether the reason for the address to be accessed to become the exception address is caused by the jump. Therefore, there is no way to output the analysis result. In order to solve the exception problem and make the electronic device run normally, the exception handling module can only trigger the electronic device to perform a whole machine restart (software restart), that is, step 309 is performed.
[0279] With reference to Figure 5 For example, if the instruction corresponding to the exception address is a read instruction, it can be determined that the current exception problem is caused by the jump of the instruction content, that is, the jump occurs at this link. Based on this, the analysis result of the specific link where the jump occurs and the jump position can be output, that is, step 319 is performed. In this way, the exception handling module can perform on-site repair on the exception problem according to the output analysis result, so as to avoid restarting the software in the electronic device, that is, step 320 is performed.
[0280] With reference to Figure 5 For example, if the address 1 is not the same as the address of any one of the 31 registers, the exception handling module cannot determine whether the current exception is caused by the jump at this stage. Therefore, there is no way to output the analysis result. In order to solve the exception problem and make the electronic device run normally, the exception handling module can only trigger the electronic device to perform a whole machine restart (software restart), that is, step 309 is performed.
[0281] Continuing to refer to Figure 5 , exemplary, if the first 24 bits of the abnormal address are all 1 (no 0 appears), it indicates that the high bit address is not abnormal. For this case, it is necessary to find the source of the abnormal address first. That is, step 315 is executed, and it is first judged whether the address of the currently accessed register recorded in the log file exists in the remaining 31 registers (other than the currently accessed register), that is, whether the address is from the 31 registers.
[0282] Continuing to refer to Figure 5 , exemplary, if the address does not exist in the remaining 31 registers. The abnormal processing module cannot temporarily determine whether the current abnormality is caused by the jump. Therefore, there is no way to output the analysis result. In order to solve the abnormal problem and make the electronic device run normally, the abnormal processing module can only trigger the electronic device to perform a whole machine restart (software restart), that is, step 316 is executed. Wherein, step 316 is the same as step 309, both are triggering the electronic device to perform a whole machine restart (software restart).
[0283] Continuing to refer to Figure 5 , exemplary, if the address is from the 31 registers, the abnormal processing module can find the executed instruction (specifically, the instruction accessing the register corresponding to the address) in the currently running instruction, and then find the possible jump in the instruction and the operation corresponding to the instruction, that is, steps 317 and 318 are executed.
[0284] Continuing to refer to Figure 5 , exemplary, if it is determined through step 318 that there is Bitflip in the instruction and / or the operation corresponding to the instruction, it is determined that the current abnormality is caused by Bitflip in the instruction and / or the operation corresponding to the instruction. Therefore, the analysis result of the specific position and link where the jump occurs can be output, that is, step 319 is executed. In this way, the abnormal processing module can perform on-site repair according to the output analysis result, so as to avoid restarting the software in the electronic device, that is, step 320 is executed.
[0285] Continuing to refer to Figure 5 , exemplary, if it is determined through step 318 that there is no Bitflip in the instruction and / or the operation corresponding to the instruction. For this case, the abnormal processing module cannot temporarily determine whether the current abnormality is caused by the jump. Therefore, there is no way to output the analysis result. In order to solve the abnormal problem and make the electronic device run normally, the abnormal processing module can only trigger the electronic device to perform a whole machine restart (software restart), that is, step 316 is executed. Wherein, step 316 is the same as step 309, both are triggering the electronic device to perform a whole machine restart (software restart).
[0286] Thus, for DAtb exception, by according to the above three different judgment logics, that is, after getting the address of the current access, first taking the high bits of the address, and judging whether the number of the bits of the jump in the high bits is 0, or greater than 0 and less than 3, or greater than or equal to 3, then analyzing and processing according to the corresponding judgment logic, in the case of not increasing the hardware cost and without fulldump file, the positioning and description of different memory device exceptions can be realized. Thus, according to the determined analysis result, the current occurring exception can be repaired on site, so that the electronic device does not need to be restarted.
[0287] In addition, it also needs to be explained that in some possible implementation manners, after repairing the exception address according to the analysis result, it can be tried whether it can be accessed, if it can be accessed, the electronic device can run normally, if it cannot be accessed, it is tried to restart again.
[0288] In addition, it can be understood that the electronic device contains the corresponding hardware and / or software modules for executing each function in order to realize the above functions. The algorithm steps of each example described in combination with the embodiments disclosed in the present application can be realized in the form of hardware or a combination of hardware and computer software. Whether a certain 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 beyond the scope of the present application.
[0289] In one example, Figure 5 Figure 8 A schematic block diagram of an apparatus 400 according to an embodiment of the present application is shown. The apparatus 400 can include a processor 401 and a transceiver / transceiver pin 402, and optionally further include a memory 403.
[0290] The various components of the apparatus 400 are coupled together by a bus 404, wherein the bus 404 includes not only a data bus, but also a power supply bus, a control bus, and a state signal bus. However, for the purpose of clear illustration, all kinds of buses are referred to as bus 404 in the figure.
[0291] Optionally, the memory 403 can be used for instructions in the foregoing method embodiments. The processor 401 can be used to execute the instructions in the memory 403, and control the receiving pin to receive signals and control the sending pin to send signals.
[0292] The apparatus 400 can be an electronic device or a chip of an electronic device in the above method embodiments.
[0293] All the related content of each step involved in the method embodiments can be referred to the function description of the corresponding function module, and will not be repeated here.
[0294] The embodiment further provides a computer storage medium, which stores computer instructions, and when the computer instructions run on an electronic device, the electronic device executes the related method steps to realize the method in the above embodiment.
[0295] The embodiment further provides a computer program product, which, when running on a computer, enables the computer to execute the related steps to realize the method in the above embodiment.
[0296] In addition, the embodiment of the present application further provides an apparatus, which can be a chip, a component or a module, and the apparatus can include a processor and a memory connected to each other; wherein the memory is used to store computer execution instructions, and when the apparatus runs, the processor can execute the computer execution instructions stored in the memory to enable the chip to execute the method in each method embodiment.
[0297] The electronic device, the computer storage medium, the computer program product or the chip provided by the embodiment are used to execute the corresponding method provided above, and thus the beneficial effects achieved by the electronic device, the computer storage medium, the computer program product or the chip can refer to the beneficial effects of the corresponding method provided above, which will not be repeated here.
[0298] The above-described embodiments are only used to illustrate the technical solutions of the present application, rather than limit them; although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalent ones; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments.
Claims
1. An exception handling method, characterized in that, Applied to electronic devices, the method includes: Obtain the first access request from the first application; Based on the first access request, data at the first address is accessed. During the process of accessing the data at the first address, a kernel crash occurs based on a preset type of exception. Obtain the first address from the log file and determine the analysis result of the first address; Based on the analysis results, the first address is repaired; wherein, the starting address of the first address is not four-byte aligned; Based on the repaired first address, access the data at the first address; wherein, the starting address of the repaired first address is four bytes aligned; The analysis results for determining the first address include: If the starting address of the first address is not four-byte aligned, the analysis result is determined to be not four-byte aligned. When the starting address of the first address is four bytes aligned, the number of 0s in the high-order bits of the first address is determined, and the corresponding judgment logic is selected based on the number of 0s in the high-order bits of the first address to determine the analysis result corresponding to the first address; wherein, different numbers of 0s in the high-order bits of the first address result in different judgment logics and different analysis results.
2. The method according to claim 1, characterized in that, The method further includes: Obtain the second access request from the first application; Based on the second access request, data at the second address is accessed. During the process of accessing the data at the second address, a kernel crash occurs based on a preset type of exception. 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 zeros, where N is an integer greater than 0 and less than 3; Based on the repaired second address, access the data at the second address; wherein the starting address of the repaired second address is four-byte aligned, and the preset bit does not contain 0.
3. The method according to claim 2, characterized in that, The method further includes: 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 includes: Obtain the third access request from the first application; Based on the third access request, data is accessed at a third address. During the process of accessing the data at the third address, a kernel crash occurs based on a preset type of exception. The third address is obtained from the log file and repaired. The third address is four-byte aligned to its starting address, and its preset bit position 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 other than the first register. The first register is the register corresponding to the third address, and the second register is the register preceding 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 at the third address; wherein the starting address of the repaired third address is four-byte aligned, and the preset bit does not contain 0.
5. The method according to claim 4, characterized in that, The loading instructions include LDR and LDUR instructions, and the transfer instructions include STR instructions.
6. The method according to any one of claims 1 to 3 and 5, characterized in that, The method further includes: Obtain the fourth access request from the first application; Based on the fourth access request, data at the fourth address is accessed. During the process of accessing the data at the fourth address, a kernel crash occurs based on a preset type of exception. Obtain the fourth address from the log file; The electronic device restarts when the starting address of the fourth address is four bytes aligned, the preset bit position of the fourth address contains M zeros, and the address of the fourth register is different from the address of any register other than the third register; 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 register above the third register.
7. The method according to any one of claims 1 to 3 and 5, characterized in that, The method further includes: Obtain the fifth access request from the first application; Based on the fifth access request, data at the fifth address is accessed. During the process of accessing the data at the fifth address, a kernel crash occurs based on a preset type of exception. Obtain the fifth address from the log file; The electronic device restarts when the starting address of the fifth address is four bytes aligned, the preset bit position of the fifth address contains M zeros, the address of the sixth register is the same as the address of any register other than the fifth register, and the fifth address is not the address of a data segment; 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 register above the fifth register.
8. The method according to any one of claims 1 to 3, characterized in that, The method further includes: Obtain the sixth access request from the first application; Based on the sixth access request, data at the sixth address is accessed. During the process of accessing the data at the sixth address, a kernel crash occurs based on a preset type of exception. Obtain the sixth address from the log file; The electronic device restarts when the starting address of the sixth address is four-byte aligned, the preset bit position of the sixth address contains 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 the instruction corresponding to the sixth address is not a load instruction or a transfer instruction; 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 register above the seventh register.
9. The method according to claim 8, characterized in that, The loading instructions include LDR and LDUR instructions, and the transfer instructions include STR instructions.
10. The method according to any one of claims 1 to 3, 5, and 9, characterized in that, The method further includes: Obtain the seventh access request from the first application; Based on the seventh access request, data at the seventh address is accessed. During the process of accessing the data at the seventh address, a kernel crash occurs based on a preset type of exception. 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 flipping problem in the eighth address that has accessed the ninth register, and the ninth register is the register corresponding to the seventh address; The values of the bits that have been flipped in the eighth address are flipped to obtain the repaired eighth address. Access the data at the eighth address based on the repaired eighth address; Access the data at the seventh address based on the seventh address.
11. The method according to claim 10, characterized in that, The method further includes: Based on the stack information in the log file, determine the assembly instructions that have been executed; Among the currently executed assembly instructions, starting from the last executed assembly instruction, search upwards and determine the address corresponding to the assembly instruction that accessed the ninth register or the address of the operation corresponding to the assembly instruction as the eighth address.
12. The method according to any one of claims 1 to 3, 5, 9, and 11, characterized in that, The method further includes: Obtain the ninth access request from the first application; Based on the ninth access request, data at the ninth address is accessed. During the process of accessing the data at the ninth address, a kernel crash occurs based on a preset type of exception. Obtain the ninth address from the log file; The electronic device restarts when the starting address of the ninth address is four bytes aligned, the preset bits of the ninth address do not contain 0, and the ninth address is different from the address corresponding to any register except the tenth register; wherein the tenth register is the register corresponding to the ninth address.
13. The method according to any one of claims 1 to 3, 5, 9, and 11, characterized in that, The method further includes: Obtain the tenth access request from the first application; Based on the tenth access request, data at the tenth address is accessed. During the process of accessing the data at the tenth address, a kernel crash occurs based on a preset type of exception. Obtain the tenth address from the log file; The electronic device restarts when the starting address of the tenth address is four bytes aligned, the preset bits of the tenth address do not contain 0, the tenth address is the same as the address corresponding to any register other than the eleventh register, and there is a bit flipping problem when the address of the eleventh register has been accessed; wherein, the eleventh register is the register corresponding to the tenth address.
14. The method according to any one of claims 1 to 3, 5, 9, and 11, characterized in that, The log file is obtained from the call stack based on the exception handling function corresponding to the preset type of exception.
15. The method according to any one of claims 2, 3, 5, 9, and 11, characterized in that, The address obtained from the log file is a binary address, occupying 64 bits, and the preset bit position is the first 24 bits.
16. An electronic device, characterized in that, The electronic device includes: a memory and a processor, the memory and the processor being coupled; the memory stores program instructions, which, when executed by the processor, cause the electronic device to perform the exception handling method as described in any one of claims 1 to 15.
17. A computer-readable storage medium, characterized in that, The computer program, when running on an electronic device, causes the electronic device to perform the exception handling method as described in any one of claims 1 to 15.
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