Hardware fault detection method, readable medium, electronic device and program product
By comparing the data processing results of the processor chip functional module with the preset standard results, hardware fault detection is realized, which solves the problem of high hardware fault detection cost in the existing technology and reduces the demand for hardware resources.
Patent Information
- Application Number
- CN202410706190.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-08-30
AI Technical Summary
Existing hardware fault detection methods such as dual-core lock-step technology and built-in self-test circuits require additional hardware resources, resulting in higher costs.
By comparing the data processing results of the functional modules to be detected in the processor chip with the preset standard results, fault detection is achieved without adding additional functional circuits.
The cost of hardware fault detection is reduced and effective fault detection of processor chip functional modules is achieved.
Smart Images

Figure CN118567894A
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a hardware fault detection method, a readable medium, an electronic device and a program product. Background Art
[0002] With the development of electronic technology, chips with embedded processors as the core are widely used in automobiles and industries. Taking the control chip of an automobile as an example, if a hardware failure occurs in the control chip, it may affect life safety, cause property losses, etc. Therefore, it is necessary to perform fault detection on the control chip so that when a hardware failure is determined in the control chip, corresponding processing can be performed.
[0003] Currently, hardware fault detection is usually implemented by hardware detection methods, such as dual code lock step (DCLS) technology, built-in self-test (BIST) circuit, etc., and the hardware cost is relatively high. Summary of the invention
[0004] The purpose of the present application is to provide a hardware fault detection method, a readable medium, an electronic device and a program product.
[0005] The first aspect of the present application provides a hardware fault detection method, including: detecting a detection instruction for a first processing module in a first processing circuit; acquiring detection data corresponding to the first processing module; controlling the first processing module to process the detection data to obtain a data processing result; and determining whether the first processing circuit has a fault based on a comparison result between the data processing result and a preset standard result.
[0006] In the embodiment of the present application, the first processing circuit may be a processing circuit to be detected, the first processing module may be a functional module to be detected, and the functional module to be detected is a hardware module integrated in the processing circuit to be detected.
[0007] It can be understood that by comparing the data processing results of each functional module to be detected with the preset standard results, fault detection of the functional module to be detected is achieved, without adding additional functional circuits, thereby reducing costs.
[0008] In a possible implementation of the first aspect above, the preset standard result is determined by at least one of the following methods: determining a data processing result of the detection data by the second processing module of the second processing circuit when it is in a normal working state, as the preset standard result, wherein the second processing module is of the same type as the first processing module; processing the detection data based on a first software program instruction corresponding to the first processing module to obtain a preset standard result, wherein the processing logic of the first software program instruction is the same as the processing logic of the first processing module.
[0009] In an embodiment of the present application, the second processing circuit may be a normal processor that has been tested, and the second processing module may be a functional module of the same type as the functional module to be tested in the normal processor that has been tested. The preset standard result may be a standard processing result obtained by processing the detection data based on the processing logic by the normal processing module that has been tested under normal operating conditions. Alternatively, the preset standard result may also be a processing result obtained by the processor corresponding to the functional module to be tested executing instructions written by the developer based on the processing logic of the functional module to be tested. Alternatively, the preset standard result may also be a processing result of a standard that can be directly set by the developer based on experience.
[0010] In a possible implementation of the first aspect above, the first processing circuit includes at least one of the following: a processor chip, a dedicated integrated circuit, a system on a chip, a high-speed data processing system, a logic module on a processor chip, a microcontroller, and a microprocessor.
[0011] In a possible implementation of the first aspect above, the first processing module is a register read and write function module, and the first processing module is controlled to process the detection data to obtain a data processing result, including: calling the write instruction corresponding to the register read and write function module to write the read and write detection data into the corresponding register; and calling the read instruction corresponding to the register read and write function module to read the data processing result from the corresponding register.
[0012] In a possible implementation of the first aspect above, the first processing module is an algorithm function module, and controlling the first processing module to process the detection data to obtain a data processing result includes: calling instructions corresponding to the algorithm function module, calculating the algorithm detection data, and obtaining a data processing result corresponding to the algorithm detection data.
[0013] In a possible implementation of the first aspect above, the first processing module is a jump function module, and the first processing module is controlled to process the detection data to obtain a data processing result, including: calling a jump instruction corresponding to the jump function module; reading a processing result of a target function corresponding to the jump instruction as a data processing result.
[0014] In a possible implementation of the first aspect above, the first processing module is an interrupt control function module, and the first processing module is controlled to process the detection data to obtain a data processing result, including: calling the instruction corresponding to the control function module; reading the data in the interrupt status register as the data processing result, wherein, corresponding to the interrupt control function module being in an interrupt processing state, the data in the interrupt status register is an interrupt flag value.
[0015] It can be understood that in the embodiments of the present application, fault detection is performed on the functional module to be detected of the processor chip through a preset instruction sequence (such as read instructions, write instructions, calling instructions corresponding to the functional module to be detected, etc.), without adding additional functional circuits, and the cost is low.
[0016] In a possible implementation of the first aspect above, the first processing module is a pointer verification and jump target identification module, and the method also includes: controlling the first processing module to process the detection data to obtain a data processing result, including: obtaining the detection data of at least one sub-module corresponding to the pointer verification and jump target identification module, wherein the sub-modules of the pointer verification and jump target identification module include at least one of the following: a key register read and write function sub-module, a pointer encryption algorithm sub-module, a program jump target identification sub-module, and a control logic sub-module; controlling each sub-module to process the detection data to obtain the data processing results corresponding to each sub-module.
[0017] In a possible implementation of the first aspect above, based on the comparison result between the data processing result and the preset standard result, it is determined whether the first processing circuit has a fault, including: when the data processing result corresponding to any sub-module is different from the preset standard result, it is determined that the corresponding sub-module and the pointer verification and jump target identification module have a fault.
[0018] In a possible implementation of the first aspect above, the detection data corresponding to the key register read-write function submodule is read-write detection data, and the preset standard result corresponding to the key register read-write function submodule is obtained by taking the read-write detection data as the preset standard result.
[0019] In a possible implementation of the first aspect above, each sub-module is controlled to process the detection data to obtain the data processing results corresponding to each sub-module, including: calling the write instruction corresponding to the key register read and write function sub-module to write the read and write detection data into the corresponding key register; and calling the read instruction corresponding to the key register read and write function sub-module to read the data processing results from the corresponding key register.
[0020] In a possible implementation of the first aspect above, the detection data of the pointer encryption algorithm submodule is algorithm detection data, and the algorithm detection data includes at least one of the following: detection key value, detection modifier value, detection pointer value, and the method for obtaining the preset standard result corresponding to the pointer encryption algorithm submodule is: based on the pointer encryption algorithm corresponding to the pointer encryption algorithm submodule, the algorithm detection data is calculated to obtain the preset standard result.
[0021] In a possible implementation of the first aspect above, each sub-module is controlled to process the detection data to obtain the data processing results corresponding to each sub-module, including: calling the instructions corresponding to the pointer encryption algorithm sub-module, calculating the algorithm detection data, and obtaining the data processing results corresponding to the algorithm detection data.
[0022] In a possible implementation of the first aspect above, the detection data of the program jump target identification submodule is jump detection data, wherein the jump detection data includes at least one of the following: a function name of a target function, an address of a target function, the first instruction of the target function is a branch target identification instruction, and the target function is used to write a check flag value into a general register; and a method for obtaining a preset standard result corresponding to the program jump target identification submodule is: using the check flag value as the preset standard result.
[0023] In a possible implementation of the first aspect above, each sub-module is controlled to process the detection data to obtain the data processing results corresponding to each sub-module, including: calling the jump instruction corresponding to the program jump target identification sub-module; reading the data in the general register corresponding to the target function as the data processing result.
[0024] In a possible implementation of the first aspect above, the detection data of the control logic submodule is control logic detection data, wherein the control logic detection data is exception data used to trigger an interrupt, and the control logic detection data includes at least one of the following: an exception check pointer verification code, a target function that does not contain a branch target identification instruction; and, the method for obtaining the preset standard result corresponding to the control logic submodule is: taking the check exception value and the interrupt flag value as the preset standard result, wherein the check exception value is used to indicate that the data processing result corresponding to at least one submodule of the key register read and write function submodule, the pointer encryption algorithm submodule, and the program jump target identification submodule is different from the preset processing result, and the interrupt flag value is used to indicate that the control logic submodule is in an interrupt processing state.
[0025] In the embodiment of the present application, the interrupt flag value may be a status bit value of a status register indicating that the interrupt exception is in an activated state.
[0026] In a possible implementation of the first aspect above, each sub-module is controlled to process the detection data to obtain the data processing results corresponding to each sub-module, including: calling the instructions corresponding to the control logic sub-module; reading the data in the system register and the status register as the data processing results, wherein, corresponding to the control logic sub-module being in an interrupt processing state, the data in the system register is a check abnormality value, and the data in the status register is an interrupt flag value.
[0027] A second aspect of the present application provides a readable medium on which instructions are stored. When the instructions are executed on an electronic device, the electronic device executes any one of the methods in the first aspect.
[0028] The third aspect of the present application provides an electronic device, comprising a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the processors of the electronic device, for executing any one of the methods in the above-mentioned first aspect.
[0029] A fourth aspect of the present application provides a program product, which includes instructions. When the instructions are executed on an electronic device, the electronic device implements any one of the methods in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0031] Figure 1 According to an embodiment of the present application, a schematic diagram of an implementation flow of a hardware fault detection method is shown;
[0032] Figure 2a According to an embodiment of the present application, a schematic diagram of an implementation flow of another hardware fault detection method is shown;
[0033] Figure 2b According to an embodiment of the present application, a schematic diagram of the structure of a processor chip is shown;
[0034] Figure 3 According to an embodiment of the present application, a flowchart of a method for detecting hardware faults in which the function module to be detected is a pointer verification and jump target identification module is shown;
[0035] Figure 4 According to an embodiment of the present application, a schematic diagram of a detection process of a key register read and write function submodule is shown;
[0036] Figure 5 According to an embodiment of the present application, a detection flow diagram of a pointer encryption algorithm submodule is shown;
[0037] Figure 6 According to an embodiment of the present application, a detection flow diagram of a program jump target identification submodule is shown;
[0038] Figure 7According to an embodiment of the present application, a detection flow diagram of a control logic submodule is shown;
[0039] Figure 8 According to an embodiment of the present application, a structural schematic diagram of an electronic device is shown. DETAILED DESCRIPTION
[0040] The illustrative embodiments of the present application include, but are not limited to, a hardware failure detection method, a readable medium, an electronic device, and a program product.
[0041] The hardware fault detection method provided in the embodiment of the present application can be used to perform fault detection on a functional module to be detected (as an example of a first processing module). Among them, the functional module to be detected can be a hardware module integrated in a processing circuit to be detected (as an example of a first processing circuit). The processing circuit to be detected includes but is not limited to: a processor chip, a logic module on a processor chip, an application specific integrated circuit (ASIC), a system on chip (SoC), a high-speed data processing system, any system of processors such as a microcontroller or a microprocessor. Among them, the processor chip includes but is not limited to an application processor (application processor, AP), a modem processor, a graphics processor (graphics processing unit, GPU), an image signal processor (imagesignal processor, ISP), a controller, a video codec, a digital signal processor (digital signalprocessor, DSP), a baseband processor, and / or a neural network processor (neural-network processing unit, NPU), etc.
[0042] The following is an introduction to the technical solution of the present application by taking the processing circuit to be detected as a processor chip and the functional module to be detected as a hardware module in the processor chip as an example. The functional module to be detected includes but is not limited to: a register read and write functional module, an algorithm functional module, a jump functional module, an interrupt control functional module, etc.
[0043] As mentioned above, hardware fault detection is usually implemented by hardware detection methods, such as dual code lock step (DCLS) technology, built-in self-test (BIST) circuit, etc.
[0044] Dual-core lockstep technology usually consists of two processor cores to form a redundant system. The main processor core and the secondary processor core execute the same instructions at the same time (in the same clock cycle), and then compare the execution results of the main processor core and the secondary processor core. If the execution results of the main processor core and the secondary processor core are inconsistent, it is determined that the main processor core and / or the secondary processor core has a hardware fault, and then the corresponding fault detection and repair module performs detection and repair processing. The built-in self-test circuit is a detection circuit designed in the chip to perform fault detection.
[0045] It can be understood that both the dual-core lock-step technology and the built-in self-test circuit require corresponding hardware (processor core, self-test circuit, etc.) to be implemented, and the hardware cost is relatively high.
[0046] In view of this, the embodiment of the present application provides a hardware fault detection method, which compares the data processing results of the function modules to be detected in the processor chip (such as register read and write function modules, algorithm function modules, jump function modules, interrupt control function modules, etc.) with the preset standard results to realize fault detection of the function modules to be detected in the processor chip. No additional functional circuits need to be added, thereby reducing costs.
[0047] Specifically, the hardware fault detection method includes: first, detecting a detection instruction of a function module to be detected of a processing circuit to be detected (such as a processor chip), and determining detection data and a preset standard result of the corresponding detection data. Secondly, inputting the detection data into the function module to be detected for detection, and obtaining a data processing result of the corresponding detection data. Then, comparing the data processing result with the preset standard result, if the data processing result is inconsistent with the preset standard result, it is determined that the function module to be detected has a fault.
[0048] Among them, it can be understood that each functional module to be detected realizes the corresponding function by executing specific functions, algorithms, programs and other processing logics. Therefore, the preset standard result can be determined by the following method: first determine the processing logic corresponding to the functional module to be detected, such as the corresponding algorithm, function, program, etc., and then use the normal processing module (such as a processor) that has been tested to process the detection data based on the algorithm, function, program and other processing logic under normal operating conditions to obtain the standard processing result.
[0049] Among them, the detected normal processing module can be a detected normal processor (as an example of the second processing circuit), or it can be a functional module of the same type as the functional module to be detected in the detected normal processor (as an example of the second processing module).
[0050] It can be understood that a normal processor that has been tested, that is, a processor without hardware faults, calls the instructions corresponding to each functional module of the processor, or executes the instructions written by the developer based on the processing logic, and the processing results obtained are all correct results, that is, the expected results of the functional module to be tested in the state where there is no hardware fault. Therefore, the processing result determined by the normal processor that has been tested under normal operating conditions based on the processing logic corresponding to the functional module to be tested can be used as a preset standard result, and compared with the data processing result of the functional module to be tested to determine whether the functional module to be tested has a fault.
[0051] Alternatively, in some embodiments, the preset standard result may also be the processing result obtained by the processor corresponding to the functional module to be detected executing the instruction written by the developer based on the processing logic of the functional module to be detected (as an instance of the first software program instruction). It can be understood that the instruction written by the developer is executed by the physical core of the processor and will not be executed by the functional module to be detected, and the processing results obtained are all correct results. Since the processing logic of the instruction written by the developer is the same as the processing logic of the functional module to be detected, it can be used as the expected result of the functional module to be detected in the absence of a hardware failure.
[0052] Alternatively, in other embodiments, the preset standard result may also be a standard processing result directly set by the developer based on experience.
[0053] For example, for the register read and write function module, the processing logic of reading and writing test data is: after writing the data into the register, read the written data from the register. If the test data is the data to be written into the register, the preset standard result is the test data.
[0054] Or for example, for an algorithm function module, the processing logic of the algorithm function module is: calculate the input data based on the algorithm corresponding to the algorithm function module, and use the calculated data as output data. If the detection data is the input data, the preset standard result is the data after the detection data is calculated based on the algorithm corresponding to the algorithm function module.
[0055] Or for example, for the jump function module, the processing logic of the algorithm function module is: when executing the main program, jump to the subroutine corresponding to the jump instruction in the main program and execute the subroutine, after completing the execution of the subroutine, jump back to the main program and continue to execute the main program. If the detection data is the target function corresponding to the jump instruction (as an example of a subroutine), and the target function can write a check flag value to the general register, the preset standard result is the check flag value written by the target function to the general register.
[0056] Or for example, for the interrupt control function module, the processing logic of the interrupt control function module is: when executing the program, if abnormal data is detected, an interrupt is triggered, the data in the interrupt status register is set as the interrupt flag value, and the interrupt processing program is executed. If the detected data is abnormal data, the preset standard result is the interrupt flag value.
[0057] In some embodiments, the detection corresponding to the register read-write function module may include: first, determining the read-write test data, and the preset standard result corresponding to the read-write test data. Among them, for the register read-write function module, the preset standard result is the read-write test data. Secondly, obtaining the data processing result of the register read-write function module. Among them, the method for obtaining the data processing result of the register read-write function module can be: calling the write instruction corresponding to the register read-write function module, and writing the read-write test data to the corresponding register; calling the read instruction corresponding to the register read-write function module, and reading the data processing result from the corresponding register. Then, compare the data processing result with the preset standard result. If the data processing result is different from the preset standard result, it is determined that the register read-write function module has a fault.
[0058] In some embodiments, the detection corresponding to the algorithm function module may include: first, determining the algorithm detection data, and the preset standard result after the algorithm detection data is processed by the algorithm of the algorithm function module. Secondly, obtaining the data processing result of the algorithm function module. Among them, the method of obtaining the data processing result of the algorithm function module can be: calling the instruction corresponding to the algorithm function module, calculating the algorithm detection data, and obtaining the data processing result of the corresponding algorithm detection data. Then, compare the data processing result with the preset standard result. If the data processing result is different from the preset standard result, it is determined that the algorithm function module has a fault.
[0059] In some embodiments, the detection corresponding to the jump function module may include: first, determining the jump detection data, and the preset standard result corresponding to the jump detection data. Among them, the jump detection data can be the function name of the target function, the address of the target function, etc., and the target function can write a check flag value to the general register; the preset standard result is the check flag value written by the target function to the general register. Secondly, obtain the data processing result of the jump function module. The way to obtain the data processing result of the jump function module can be: call the jump instruction corresponding to the jump function module, read the processing result of the target function corresponding to the jump instruction (i.e., the data processing result), such as the data in the general register corresponding to the target function. Then, compare the data processing result with the preset standard result. If the data processing result is different from the preset standard result, it is determined that the jump function module has a fault.
[0060] In some embodiments, the detection corresponding to the interrupt control function (e.g., abnormal interrupt processing function) module may include: first, determining the interrupt detection data, and the preset standard result corresponding to the interrupt detection data. Among them, the interrupt detection data may be abnormal data that causes the interrupt. If the abnormal data causes the interrupt, the interrupt control function module is in the interrupt processing state, and the data in the interrupt status register will be set to the interrupt flag value, and the preset standard result is the interrupt flag value. Secondly, the data processing result of the interrupt control function module is obtained. The method for obtaining the data processing result of the interrupt control function module may be: calling the instruction corresponding to the control function module; reading the data in the interrupt status register as the data processing result. Then, the data processing result is compared with the preset standard result. If the data processing result is different from the preset standard result, it is determined that the interrupt control function module has a fault.
[0061] It can be understood that the hardware fault detection method provided in the embodiment of the present application performs fault detection on the functional module to be detected of the processor chip through a preset instruction sequence (such as reading instructions, writing instructions, calling instructions corresponding to the functional module to be detected, etc.), without adding additional functional circuits, and the cost is low.
[0062] Specifically, Figure 1 According to an embodiment of the present application, a schematic diagram of an implementation flow of a hardware fault detection method is shown. It can be understood that Figure 1 Each step of the process shown in the figure is performed by the electronic device 100. Figure 1 The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 1 As shown, the process includes but is not limited to the following steps:
[0063] S101: Detecting a detection instruction for a function module to be detected in a processing circuit to be detected.
[0064] In some embodiments, the electronic device 100 detects an operation of detecting the functional module to be detected, such as an operation of a user (developer) calling a detection program, and determines that a detection instruction for the functional module to be detected is detected.
[0065] In other embodiments, the electronic device 100 detects a detection instruction for the functional module to be detected.
[0066] S102: Acquire detection data corresponding to the functional module to be detected.
[0067] In some embodiments, after the electronic device 100 determines that a detection instruction for a functional module to be detected is detected, it obtains detection data corresponding to the functional module to be detected.
[0068] S103: Control the function module to be detected to process the detection data to obtain a data processing result.
[0069] In some embodiments, the electronic device 100 inputs the detection data into the function module to be detected for processing to obtain a data processing result corresponding to the detection data.
[0070] For example, corresponding to the register read and write function module, the electronic device 100 calls the write instruction corresponding to the register read and write function module to write the read and write detection data into the corresponding register; and calls the read instruction corresponding to the register read and write function module to read the data processing result from the corresponding register.
[0071] Or for example, corresponding to the algorithm function module, the electronic device 100 calls the instruction corresponding to the algorithm function module, calculates the algorithm detection data, and obtains the data processing result corresponding to the algorithm detection data.
[0072] For another example, corresponding to the jump function module, the electronic device 100 calls the jump instruction corresponding to the jump function module, and reads the processing result (ie, data processing result) of the target function corresponding to the jump instruction, such as the data in the general register corresponding to the target function.
[0073] For another example, corresponding to an interrupt control function (eg, abnormal interrupt processing function) module, the electronic device 100 calls an instruction corresponding to the control function module; and reads data in an interrupt status register as a data processing result.
[0074] S104: Based on the comparison result between the data processing result and the preset standard result, determine whether the processing circuit to be detected has a fault.
[0075] In some embodiments, the electronic device 100 compares the data processing result with the preset standard result. If the data processing result is inconsistent with the preset standard result, it is determined that the functional module to be detected has a fault, that is, there is a hardware fault in the processing circuit to be detected.
[0076] On the contrary, if the data processing result is consistent with the preset standard result, it is determined that the functional module to be detected has no fault, that is, there is no hardware fault in the processing circuit to be detected.
[0077] It can be understood that by comparing the data processing result of the functional module to be detected with the preset standard result, fault detection of the functional module to be detected is achieved, without adding additional functional circuits, thus reducing costs.
[0078] It can be understood that the hardware fault detection method provided in the embodiment of the present application can be applied to any electronic device that can include a processor chip, including but not limited to user equipment (UE), mobile station (MS), mobile terminal (MT), etc. For example, mobile phone, smart TV, wearable device, tablet computer (Pad), computer with wireless transceiver function, virtual reality (VR) terminal device, augmented reality (AR) terminal device, wireless terminal in industrial control, wireless terminal in self-driving, wireless terminal in remote medical surgery, wireless terminal in smart grid, wireless terminal in transportation safety, wireless terminal in smart city, wireless terminal in smart home, etc. The embodiment of the present application does not impose any restrictions on the specific type of electronic device.
[0079] In order to more clearly illustrate the technical solutions of the present application, some technical solutions of the present application are described in detail below in conjunction with the accompanying drawings.
[0080] Figure 2a According to an embodiment of the present application, another implementation flow diagram of a hardware fault detection method is shown. It can be understood that Figure 2a Each step of the process shown in the figure is performed by the electronic device 100. Figure 2a The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 2a As shown, the process includes but is not limited to the following steps:
[0081] S201: Disable external interrupts and save context-related registers.
[0082] In some embodiments, the electronic device 100 detects an operation to detect a functional module to be detected, such as an operation by a user (developer) to call a detection program, or detects a detection instruction for a functional module to be detected, turns off the external interrupt function to avoid external interrupts causing the execution of the detection program to be interrupted, and saves context-related registers (such as system control registers, etc.).
[0083] It is understandable that the detection program may be called when the CPU is running one or more processes, so the context register needs to be saved to protect the scene so that the CPU can continue to run the current one or more processes after the detection is completed.
[0084] S202: Enable the function module to be detected.
[0085] In some embodiments, after disabling the external interrupt function and saving the context-related registers, the electronic device 100 enables the functional module to be detected, so that the processor can safely access and control the functional module to be detected.
[0086] In other embodiments, the electronic device 100 starts a timer (e.g., a watchdog timer) before enabling the function module to be detected, that is, before starting to perform fault detection on the function module to be detected. If the timer times out, for example, due to an infinite loop caused by stack damage, unexpected jumps, unexpected exceptions, etc., the timer times out, and a corresponding interrupt processing is performed, and it is determined that a hardware fault has occurred. The timing value of the timer can be set to the duration of normal execution of the detection program.
[0087] S203: Perform fault detection on the functional module to be detected.
[0088] In some embodiments, the electronic device 100 determines the detection data and the preset standard result corresponding to the detection data. Secondly, the detection data is input into the function module to be detected for detection, and the data processing result corresponding to the detection data is obtained. Then, the detection data processing result and the preset standard result are compared. If the data processing result is inconsistent with the preset standard result, it is determined that the function module to be detected has a fault.
[0089] The function module to be detected may be a register read-write function module, an algorithm function module, a jump function module, an interrupt control function module, and the like.
[0090] It can be understood that the detection method of each functional module can refer to the description of the detection method of the corresponding functional module above, and will not be repeated here.
[0091] S204: Restore context-related registers and enable external interrupts.
[0092] In some embodiments, after the detection program is completed, the electronic device 100 restores the context register to achieve the purpose of restoring the scene, so that the CPU can continue to run one or more processes that were running before executing the detection program. In addition, the electronic device 100 enables external interrupts to facilitate the running of one or more processes.
[0093] S205: Output the detection result.
[0094] In some embodiments, after the electronic device 100 completes the detection procedure, it outputs the detection result of the functional module to be detected.
[0095] It can be understood that in other embodiments, according to actual needs, the above Figure 2a The steps shown can be combined, deleted or replaced with other steps that are conducive to achieving the purpose of this application. For example, the above steps S201 and S202 can be combined into one step, and this application does not limit this.
[0096] In some embodiments, Figure 2b As shown, a pointer authentication and branch target identification (PACBTI) module 20b is provided in the processor chip 20a. The PACBTI module 20b can be used to prevent return-oriented programming (ROP) attacks and jump-oriented programming (JOP) attacks. ROP attacks and JOP attacks can tamper with the program running on the processor 20a by modifying the pointer in the stack and / or the target function of the jump instruction. The function of the PACBTI module 20b is to determine whether the pointer is modified through a pointer authentication code, and to determine whether to jump to the target function through a check flag; if it is detected that the pointer is modified and / or does not jump to the target function, an interrupt handler is entered for processing. It can be understood that the PACBTI module 20b can partially implement fault detection of the processor chip 20a, and therefore, fault detection of the PACBTI module 20b is more important.
[0097] The following takes the PACBTI module as an example of the functional module to be detected to describe in detail the hardware fault detection method provided in the embodiment of the present application.
[0098] For example, Figure 3 According to an embodiment of the present application, a flowchart of a method for detecting hardware faults in which the function module to be detected is a pointer verification and jump target identification module is shown. It can be understood that Figure 3 Each step of the process shown in the figure is performed by the electronic device 100. Figure 3 The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 3 As shown, the process includes but is not limited to the following steps:
[0099] S301: Disable external interrupts and save context-related registers.
[0100] In some embodiments, the electronic device 100 detects an operation to detect the PACBTI module, such as an operation by a user (developer) to call a detection program, or detects a detection instruction for the PACBTI module, turns off the external interrupt function to prevent the external interrupt from interrupting the execution of the detection program, and saves the context-related registers.
[0101] The context-related registers include but are not limited to system control registers, key registers, etc.
[0102] It is understandable that the detection program may be called when the CPU is running one or more processes, so the context register needs to be saved to protect the scene so that the CPU can continue to run the current one or more processes after the detection is completed.
[0103] S302: Enable the PACBTI module.
[0104] In some embodiments, after disabling the external interrupt function and saving the context-related registers, the electronic device 100 enables the PACBTI module so that the processor can safely access and control the PACBTI module.
[0105] The PACBTI module can be enabled by: enabling the PACBTI function control bit of the control register by calling a write instruction, so that the electronic device 100 can control the PACBTI module by calling a detection program. In addition, the processor state is set to a privileged security mode by writing an instruction, that is, enabling access rights, so that the electronic device 100 can securely access the PACBTI module by calling a detection program.
[0106] In other embodiments, the electronic device 100 starts a timer (e.g., a watchdog timer) before enabling the PACBTI module, i.e., before starting to perform fault detection on the PACBTI module. If the timer times out, for example, due to an infinite loop caused by stack damage, unexpected jumps, unexpected exceptions, etc., the timer times out, and a corresponding interrupt processing is performed, and it is determined that a hardware fault has occurred. The timing value of the timer can be set to the duration of normal execution of the detection program.
[0107] S303: Perform fault detection on the PACBTI module.
[0108] In some embodiments, the PACBTI module includes a key register read and write function submodule, a pointer encryption algorithm submodule, a program jump target identification submodule, and a control logic submodule. The detection of the PACBTI module is to detect each submodule of the PACBTI module.
[0109] Specifically, the detection of the PACBTI module includes: obtaining detection data and preset standard results of at least one submodule corresponding to the detection of the PACBTI module; controlling each submodule to process the detection data respectively to obtain data processing results corresponding to each submodule; if the data processing result corresponding to any submodule is different from the preset processing result, it is determined that the corresponding submodule and the pointer verification and jump target identification module have faults.
[0110] In some embodiments, the detection corresponding to the key register read and write function submodule may include:
[0111] Determine the read / write test data and the preset standard result corresponding to the read / write test data. For the key register read / write function submodule, the preset standard result is the read / write test data.
[0112] Obtain the data processing result of the key register read / write function submodule. The method of obtaining the data processing result of the key register read / write function submodule may be: calling the write instruction corresponding to the key register read / write function submodule to write the read / write detection data into the key register; calling the read instruction corresponding to the key register read / write function submodule to read the data processing result from the corresponding key register.
[0113] The data processing result is compared with the preset standard result. If the data processing result is different from the preset standard result, it is determined that the key register read and write function submodule has a fault.
[0114] Specifically, the detection of the key register read and write function submodule can refer to the following in detail. Figure 4 The relevant description in the detection flow diagram of the key register read and write function submodule is shown.
[0115] In some embodiments, the detection corresponding to the pointer encryption algorithm submodule may include:
[0116] The algorithm detection data is determined to be a detection key value (PAC_KEY), a detection modifier value (Modifier) and a detection pointer value (Pointer), as well as a preset standard result after processing the algorithm detection data based on a pointer encryption algorithm, that is, a verification pointer verification code calculated based on the detection key value, the detection modifier value and the detection pointer value based on the pointer encryption algorithm.
[0117] The data processing result of the pointer encryption algorithm submodule is obtained. The data processing result of the pointer encryption algorithm submodule can be obtained by calling the instruction corresponding to the pointer encryption algorithm submodule, calculating the algorithm detection data, and obtaining the data processing result of the corresponding algorithm detection data.
[0118] The data processing result is compared with the preset standard result. If the data processing result is different from the preset standard result, it is determined that there is a fault in the pointer encryption algorithm submodule.
[0119] Specifically, the detection of the pointer encryption algorithm submodule can be referred to in detail as follows Figure 5 The relevant description in the detection flow diagram of the pointer encryption algorithm submodule shown.
[0120] In some embodiments, the detection corresponding to the program jump target identification submodule may include:
[0121] Determine the jump detection data and the preset standard result corresponding to the jump detection data. The jump detection data may be the function name of the target function, the address of the target function, etc., and the first instruction of the target function is a branch target identification instruction. The target function may write a check flag value into a general register; the preset standard result is the check flag value written by the target function into the general register.
[0122] Obtaining the data processing result of the program jump target identification submodule. The method of obtaining the data processing result of the program jump target identification submodule can be: calling the jump instruction (such as an indirect jump instruction) corresponding to the program jump target identification submodule, and reading the data in the general register corresponding to the target function (i.e., the data processing result).
[0123] The data processing result is compared with the preset standard result. If the data processing result is different from the preset marking result, it is determined that there is a fault in the program jump target identification submodule.
[0124] Specifically, the detection of the program jump target identification submodule can be referred to in detail as follows: Figure 6 The relevant description in the detection flow diagram of the program jump target identification submodule is shown.
[0125] In some embodiments, the detection corresponding to the control logic submodule may include:
[0126] Determine the control logic detection data and the preset standard result corresponding to the control logic detection data. The control logic detection data may be abnormal data that causes an interrupt. If the abnormal data causes an interrupt, the data in the interrupt status register will be set to an interrupt flag value, and the preset standard result is the interrupt flag value. The control logic detection data may be, for example, an abnormal check pointer verification code, and / or the first instruction does not contain a target function of a branch target identification instruction.
[0127] Obtaining the data processing result of the control logic submodule. The method of obtaining the data processing result of the control logic submodule may be: calling the instruction corresponding to the control logic submodule; and reading the data in the interrupt status register as the data processing result.
[0128] The data processing result is compared with the preset standard result. If the data processing result is different from the preset standard result, it is determined that the control logic submodule has a fault.
[0129] Specifically, the detection of the control logic submodule can be referred to in detail as follows Figure 7 The relevant description is shown in the detection flow diagram of the control logic submodule.
[0130] S304: Restore context-related registers and enable external interrupts.
[0131] In some embodiments, after the detection program is completed, the electronic device 100 restores the context register to achieve the purpose of restoring the scene, so that the CPU can continue to run one or more processes that were running before executing the detection program. In addition, the electronic device 100 enables external interrupts to facilitate the running of one or more processes.
[0132] S305: Output the detection result.
[0133] In some embodiments, after the electronic device 100 completes the detection procedure, it determines the detection result of the PACBTI module.
[0134] It can be understood that the detection result of the PACBTI module can be the detection result of each sub-module of the PACBTI module (key register read and write function sub-module, pointer encryption algorithm sub-module, program jump target identification sub-module, and control logic sub-module), or it can be the overall detection result of the PACBTI module. This application does not impose specific restrictions on this.
[0135] For example, if the detection result is not 0, it means that the PACBTI module is faulty.
[0136] Or for example, taking the detection result as a 16-bit value as an example, every four-bit value in the detection result corresponds to the detection result of a submodule of the PACBTI module, that is, the values of the 0th to 3rd bits correspond to the detection result of the key register read and write function submodule, the values of the 4th to 7th bits correspond to the detection result of the pointer encryption algorithm submodule, the values of the 8th to 11th bits correspond to the detection result of the program jump target identification submodule, and the values of the 12th to 15th bits correspond to the detection result of the control logic submodule. If the detection result is not 0, it means that the corresponding submodule has a fault.
[0137] It can be understood that in other embodiments, according to actual needs, the above Figure 3 The steps shown can be combined, deleted or replaced with other steps that are conducive to achieving the purpose of this application. For example, the above steps S301 and S302 can be combined into one step, and this application does not limit this.
[0138] For example, Figure 4 According to an embodiment of the present application, a schematic diagram of a detection process of a key register read-write function submodule is shown. It can be understood that Figure 4 Each step of the process shown in the figure is performed by the electronic device 100. Figure 4 The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 4 As shown, the process includes but is not limited to the following steps:
[0139] S401: Initialize the key register group.
[0140] In some embodiments, the electronic device 100 initializes the general register set and initializes the key register set, for example, setting the data stored in the general register set and the key register set to 0.
[0141] In some embodiments, the electronic device 100 determines the read and write detection data, and the number of cycle detections.
[0142] S402: Perform a read-after-write test on the key register group.
[0143] In some embodiments, the electronic device 100 calls a write instruction to write the read / write detection data to the key register group, and after writing the read / write detection data, calls a read instruction to read the data in the key register group as the data processing result.
[0144] S403: Determine whether the check register read result is successful.
[0145] In some embodiments, if the judgment result is failure, it means that the data processing result is different from the read and write detection data, and the key register read and write function submodule has a fault, then step S404 is executed to determine the fault point. It can be understood that if the register read result fails, the electronic device 100 can set the data in the system register to 1.
[0146] In other embodiments, if the judgment result is successful, it means that the data processing result is the same as the read and write test data, and there is no fault in the key register read and write function submodule, then step S405 is executed to determine whether the detection cycle is ended. It can be understood that if the check register read result is successful, the electronic device 100 can set the data in the system register to 0.
[0147] S404: Determine whether a fault point is found.
[0148] In some embodiments, after the electronic device 100 determines that the data processing result is different from the read-write detection data, it determines that the fault point is found.
[0149] In other embodiments, after the electronic device 100 confirms that a fault point is found, it needs to further determine whether the detection cycle is ended, that is, determine whether to continue detection, and then executes step S405 to determine whether the detection cycle is ended.
[0150] S405: Determine whether the detection cycle is completed.
[0151] In some embodiments, if the judgment result is yes, step S407 is executed, the detection ends and the detection result is determined.
[0152] In other embodiments, if the judgment result is no, indicating that the detection needs to be continued, step S406 is executed to replace the written data.
[0153] S406: Replace the written data.
[0154] In some embodiments, after the electronic device 100 determines that the detection cycle has not ended, it replaces the detection data written into the key register group, that is, replaces the read-write detection data, and further executes step S402 to perform a read-after-write detection of the key register group.
[0155] S407: The detection is completed and the detection result is determined.
[0156] In some embodiments, the electronic device 100 determines that after the detection cycle ends, determines that the detection ends, and determines the detection result.
[0157] For example, if the detection result is not 0, it means that there is a fault in the key register read and write function submodule.
[0158] Or for example, taking the test result as a 16-bit numerical value, the values from bit 0 to bit 3 in the test result correspond to the test result of the key register read and write functional submodule. If bit 0 to bit 3 in the test result is not 0, it means that there is a fault in the key register read and write functional submodule.
[0159] In some other embodiments, the above step S407 may also be: the detection ends and the next submodule (such as the pointer encryption algorithm submodule) of the PACBTI module is detected. In other words, each submodule of the PACBTI module can be detected independently or serially, and this application does not make specific restrictions on this.
[0160] For example, Figure 5 According to an embodiment of the present application, a schematic diagram of a detection process of a pointer encryption algorithm submodule is shown. It can be understood that Figure 5 Each step of the process shown in the figure is performed by the electronic device 100. Figure 5 The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 5As shown, the process includes but is not limited to the following steps:
[0161] S501: Initialize the register group.
[0162] In some embodiments, the electronic device 100 initializes the general register set and initializes the key register set, for example, setting the data stored in the general register set and the key register set to 0.
[0163] In some embodiments, the electronic device 100 determines that the algorithm detection data is a detection key value, a detection modifier value, and a detection pointer value, and calculates the detection key value, the detection modifier value, and the detection pointer value based on the pointer encryption algorithm to obtain a predicted pointer verification code as a preset standard result. In addition, a write instruction is called to write the detection key value to the key register group, write the detection modifier value, the detection pointer value, and the preset standard result to the general register, and determine the number of loop detection times.
[0164] S502: Call the pointer encryption instruction to calculate the verification code.
[0165] In some embodiments, the electronic device 100 calls the pointer encryption instruction of the pointer encryption algorithm submodule to calculate the detection key value, the detection modifier value and the detection pointer value to obtain a pointer verification code as a data processing result.
[0166] S503: Determine whether the pointer verification code is successful.
[0167] In some embodiments, if the judgment result is failure, it means that the data processing result is different from the preset standard result, and the pointer encryption algorithm submodule has a fault, then step S504 is executed to determine the fault point. It can be understood that if the pointer verification code fails, the electronic device 100 can set the data in the system register to 1.
[0168] In other embodiments, if the judgment result is successful, indicating that the data processing result is the same as the preset standard result, and the pointer encryption algorithm submodule has no fault, then step S505 is executed to determine whether the detection cycle is completed. It can be understood that if the pointer verification code is successfully verified, the electronic device 100 can set the data in the system register to 0.
[0169] S504: Determine whether a fault point is found.
[0170] In some embodiments, after the electronic device 100 determines that the data processing result is different from the preset standard result, it determines that the fault point is found.
[0171] In other embodiments, after the electronic device 100 confirms that a fault point is found, it needs to further determine whether the detection cycle is ended, that is, determine whether to continue detection, and then executes step S505 to determine whether the detection cycle is ended.
[0172] S505: Determine whether the detection cycle is completed.
[0173] In some embodiments, if the judgment result is yes, step S507 is executed, the detection ends and the detection result is determined.
[0174] In some other embodiments, if the judgment result is no, indicating that the detection needs to be continued, step S506 is executed to replace the written data.
[0175] S506: Replace the written data.
[0176] In some embodiments, after the electronic device 100 determines that the detection cycle has not ended, it replaces the detection key value, the detection modifier value and the detection pointer value, and determines the corresponding pointer verification code based on the replaced detection key value, the detection modifier value and the detection pointer value as the preset standard result after the replacement. And, further executing step S502, calling the pointer encryption instruction to calculate the verification code.
[0177] S507: The detection is completed and the detection result is determined.
[0178] In some embodiments, the electronic device 100 determines that after the detection cycle ends, determines that the detection ends, and determines the detection result.
[0179] For example, if the detection result is not 0, it means that there is a fault in the pointer encryption algorithm submodule.
[0180] Or for example, taking the detection result as a 16-bit numerical value as an example, the values from the 4th to the 7th bits in the detection result correspond to the detection result of the pointer encryption algorithm submodule. If the 4th to the 7th bits in the detection result are not 0, it means that there is a fault in the pointer encryption algorithm submodule.
[0181] In some other embodiments, the above step S507 may also be: the detection is completed and the next submodule of the PACBTI module (such as the program jump target identification submodule) is detected. In other words, each submodule of the PACBTI module can be detected independently or serially, and this application does not make specific restrictions on this.
[0182] For example, Figure 6 According to an embodiment of the present application, a detection flow diagram of a program jump target identification submodule is shown. It can be understood that Figure 6 Each step of the process shown in the figure is performed by the electronic device 100. Figure 6 The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 6 As shown, the process includes but is not limited to the following steps:
[0183] S601: Initialize the register group.
[0184] In some embodiments, the electronic device 100 initializes the general register group, for example, sets the data stored in the general register group to 0.
[0185] In some embodiments, the electronic device 100 determines the jump detection data as the function name of the target function, the address of the target function, etc., and the first finger of the target function includes a branch target identification instruction. The branch target identification instruction can write a check flag value to a general register. In addition, the preset standard result is determined to be the check flag value written by the target function to the general register, and the number of loop detections is determined.
[0186] S602: Call an indirect jump instruction to jump to a target function including a branch target identification instruction.
[0187] In some embodiments, the electronic device 100 calls an indirect jump instruction and jumps to a preset target function containing a branch target identification instruction, and reads data in a general register as a data processing result.
[0188] S603: Determine whether the check flag register is successful.
[0189] In some embodiments, if the judgment result is failure, it means that the data processing result is different from the preset standard result, and the program jump target identification submodule has a fault, then step S604 is executed to determine the fault point. It can be understood that if the check flag register fails, the electronic device 100 can set the data in the system register to 1.
[0190] In other embodiments, if the judgment result is successful, indicating that the data processing result is the same as the preset standard result, and the program jump target identification submodule does not have a fault, then step S605 is executed to determine whether the detection cycle is completed. It can be understood that if the check flag register is successful, the electronic device 100 can set the data in the system register to 0.
[0191] S604: Determine whether a fault point is found.
[0192] In some embodiments, after the electronic device 100 determines that the data processing result is different from the preset standard result, it determines that the fault point is found.
[0193] In other embodiments, after the electronic device 100 confirms that a fault point is found, it needs to further determine whether the detection cycle is ended, that is, determine whether to continue detection, and then executes step S605 to determine whether the detection cycle is ended.
[0194] S605: Determine whether the detection cycle is completed.
[0195] In some embodiments, if the judgment result is yes, step S607 is executed, the detection ends and the detection result is determined.
[0196] In other embodiments, if the judgment result is no, indicating that the detection needs to be continued, step S606 is executed to replace the jump instruction and the jump target function.
[0197] S606: Replace the jump instruction and the jump target function.
[0198] In some embodiments, after the electronic device 100 determines that the detection loop has not ended, it replaces the jump instruction and the target function of the jump, and further executes step S602 to call the indirect jump instruction to jump to the target function containing the branch target identification instruction.
[0199] S607: The detection is completed and the detection result is determined.
[0200] In some embodiments, the electronic device 100 determines that after the detection cycle ends, determines that the detection ends, and determines the detection result.
[0201] For example, if the detection result is not 0, it means that there is a fault in the pointer encryption algorithm submodule.
[0202] Or for example, taking the detection result as a 16-bit numerical value as an example, the values of the 8th to 11th bits in the detection result correspond to the detection result of the program jump target identification submodule. If the 8th to 11th bits in the detection result are not 0, it means that there is a fault in the program jump target identification submodule.
[0203] In some other embodiments, the above step S607 may also be: the detection is completed and the next submodule (such as the control logic submodule) of the PACBTI module is detected. In other words, each submodule of the PACBTI module can be detected independently or serially, and this application does not make specific restrictions on this.
[0204] For example, Figure 7 According to an embodiment of the present application, a detection flow diagram of a control logic submodule is shown. It can be understood that Figure 7 Each step of the process shown in the figure is performed by the electronic device 100. Figure 7 The execution entities of each step will not be described repeatedly in the steps of the process shown. Figure 7 As shown, the process includes but is not limited to the following steps:
[0205] S701: Initialize the register group.
[0206] In some embodiments, the electronic device 100 initializes the general register set and initializes the key register set, for example, setting the data stored in the general register set and the key register set to 0.
[0207] In some embodiments, the electronic device 100 determines the detection key value, the detection modifier value, and the detection pointer value, and calls the pointer encryption instruction of the pointer encryption algorithm submodule to calculate the detection key value, the detection modifier value, and the detection pointer value to obtain an initial pointer verification code; and determines the check abnormality value of the system register and the status bit value of the status register as the preset standard result. In addition, the write instruction is called to write the initial pointer verification code and the preset standard result to the general register.
[0208] The check exception value of the system register indicates a check failure (such as a check pointer verification code failure), for example, the check exception value of the system register may be 1. The status bit value of the status register indicates that the interrupt exception is in an activated state (as an example of an interrupt flag value), for example, the status bit value of the status register may also be 1.
[0209] It can be understood that the check abnormal value is used to indicate that the data processing result corresponding to at least one sub-module among the key register read and write function sub-module, the pointer encryption algorithm sub-module, and the program jump target identification sub-module is different from the preset processing result, and the status bit value of the status register is in an activated state to indicate that the control logic sub-module is in an interrupt processing state.
[0210] S702: Determine the abnormal pointer verification code and call the pointer check instruction to trigger the pointer check exception.
[0211] In some embodiments, the electronic device 100 calls a write instruction to modify the initial pointer verification code stored in the general register to obtain an abnormal pointer verification code. In addition, a pointer check instruction is called to trigger a pointer check exception. If the pointer check function is normal, the electronic device 100 sets the data in the system register to 1.
[0212] S703: Perform interrupt processing.
[0213] In some embodiments, if a pointer check exception is triggered, the electronic device 100 may perform interrupt processing to handle the pointer check exception and avoid failure.
[0214] S704: Determine whether the verification of the system register and the status register is successful.
[0215] In some embodiments, the electronic device 100 reads the data stored in the system register and the status register as the data processing result. If the judgment result is failure, it means that the data processing result is different from the preset standard result. That is, the data stored in the system register is not a check abnormality value, and / or the state bit value of the status register indicates that the interrupt exception is in an inactive state and the control logic submodule has a fault. Then execute step S705 to determine the fault point. Among them, when the state bit value of the status register indicates that the interrupt exception is in an inactive state, the corresponding state bit value can be 0. The inactive state can be, for example, a pause state, a suspended state, etc., and this application does not make specific restrictions on this.
[0216] In other embodiments, the electronic device 100 reads the data stored in the system register and the status register as the data processing result. If the judgment result is successful, it means that the data processing result is the same as the preset standard result. That is, the data stored in the system register is the check abnormality value, and the status bit value of the status register indicates that the interrupt abnormality is in an active state, and the control logic submodule does not have a fault. Then, step S706 is executed to determine whether the detection cycle is completed.
[0217] S705: Determine that a fault point is found.
[0218] In some embodiments, after the electronic device 100 determines that the data processing result is different from the preset standard result, it determines that the fault point is found.
[0219] In other embodiments, after the electronic device 100 confirms that the fault point is found, it needs to further determine whether the detection is completed, that is, determine whether to continue the detection, and then executes step S706 to determine whether the detection is completed.
[0220] S706: Determine whether the detection is completed.
[0221] In some embodiments, if the judgment result is yes, step S709 is executed, the detection ends and the detection result is determined.
[0222] In some other embodiments, if the judgment result is no, indicating that the detection needs to be continued, step S707 is executed to initialize the register group.
[0223] S707: Initialize the register group.
[0224] In some embodiments, the electronic device 100 initializes the general register group, for example, sets the data stored in the general register group to 0.
[0225] In some embodiments, the electronic device 100 determines the check abnormality value of the system register and the interruption value of the status register as the preset standard result, and calls a write instruction to write the preset standard result to the general register.
[0226] S708: Call an indirect jump instruction to jump to a target function that does not contain a branch target identification instruction, triggering a branch identification exception.
[0227] In some embodiments, the electronic device 100 calls an indirect jump instruction to jump to a target function that does not contain a branch target identification instruction, triggering a branch identification exception. If the branch identification function is normal, the electronic device 100 sets the data in the system register to 1.
[0228] S709: The detection is completed and the detection result is determined.
[0229] In some embodiments, the electronic device 100 determines that after the detection cycle ends, determines that the detection ends, and determines the detection result.
[0230] For example, if the detection result is not 0, it means that there is a fault in the control logic submodule.
[0231] Or for example, taking the detection result as a 16-bit value, the values of the 12th to 15th bits in the detection result correspond to the detection result of the control logic submodule. If the 12th to 15th bits in the detection result are not 0, it means that there is a fault in the control logic submodule.
[0232] In some other embodiments, the above step S709 may also be: the detection ends and the next submodule (such as the pointer encryption algorithm submodule) of the PACBTI module is detected. In other words, each submodule of the PACBTI module can be detected independently or serially, and this application does not make specific restrictions on this.
[0233] Understandably, Figure 7 The flowchart shown only detects the control logic submodule once. In other embodiments, the electronic device 100 may also perform multiple rounds of detection on the control logic submodule by setting the number of cycles, and this application does not impose any limitation on this.
[0234] In summary, the hardware fault detection method proposed in this application realizes fault detection of the function modules to be detected in the processor chip by comparing the data processing results of each function module to be detected in the processor chip with the preset standard results. No additional functional circuits need to be added, thereby reducing costs.
[0235] Further, Figure 8 According to some embodiments of the present application, a schematic diagram of the structure of an electronic device 100 is shown. Figure 8As shown, the electronic device 100 includes one or more processors 101, a system memory 102, a non-volatile memory (NVM) 103, a communication interface 104, an input / output (I / O) device 105, and a system control logic 106 for coupling the processor 101, the system memory 102, the non-volatile memory 103, the communication interface 104 and the input / output (I / O) device 105. Among them:
[0236] The processor 101 can be used to control the electronic device to execute the hardware fault detection method of the present application, wherein the processor 101 may include one or more processing units, for example, a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), a microprocessor (MCU), an artificial intelligence (AI) processor or a processing module or processing circuit of a programmable logic device (FPGA) may include one or more single-core or multi-core processors. In some embodiments, the processor 101 may be a processor chip 20a, and the processor 101 also includes a PACBTI module 20b for preventing return-oriented programming ROP attacks and jump-oriented programming JOP attacks.
[0237] The system memory 102 is a volatile memory, such as a random-access memory (RAM), a double data rate synchronous dynamic random access memory (DDR SDRAM), etc. The system memory is used to temporarily store data and / or instructions.
[0238] The non-volatile memory 103 may include one or more tangible, non-transitory computer-readable media for storing data and / or instructions. In some embodiments, the non-volatile memory 103 may include any suitable non-volatile memory such as a flash memory and / or any suitable non-volatile storage device, such as a hard disk drive (HDD), a compact disc (CD), a digital versatile disc (DVD), a solid-state drive (SSD), etc. In some embodiments, the non-volatile memory 103 may also be a removable storage medium, such as a secure digital (SD) memory card, etc.
[0239] In particular, the system memory 102 and the non-volatile memory 103 may respectively include: a temporary copy and a permanent copy of the instruction 107. The instruction 107 may include: when executed by the processor 101, the electronic device 100 implements the hardware fault detection method provided in each embodiment of the present application.
[0240] The communication interface 104 may include a transceiver for providing a wired or wireless communication interface for the electronic device 100, and then communicating with any other suitable device through one or more networks. In some embodiments, the communication interface 104 may be integrated into other components of the electronic device 100, for example, the communication interface 104 may be integrated into the processor 101. In some embodiments, the electronic device 100 may communicate with other devices through the communication interface 104, for example, the electronic device 100 may obtain a hardware fault detection method to be executed from other electronic devices through the communication interface 104.
[0241] The input / output (I / O) device 105 may include input devices such as a keyboard, a mouse, etc., and output devices such as a display, etc. A user may interact with the electronic device 100 via the input / output (I / O) device 105 .
[0242] System control logic 106 may include any suitable interface controller to provide any suitable interface with other modules of electronic device 100. For example, in some embodiments, system control logic 106 may include one or more memory controllers to provide interfaces to system memory 102 and non-volatile memory 103.
[0243] In some embodiments, at least one of the processors 101 may be packaged together with the logic of one or more controllers for the system control logic 106 to form a system in package (SiP). In other embodiments, at least one of the processors 101 may also be integrated with the logic of one or more controllers for the system control logic 106 on the same chip to form a system on chip (SoC).
[0244] It can be understood that the electronic device 100 can be any electronic device that includes a processor chip, including but not limited to mobile phones, wearable devices (such as smart watches, etc.), tablet computers, desktops, laptops, handheld computers, notebook computers, ultra-mobile personal computers (ultra-mobile personal computers, UMPC), netbooks, as well as cellular phones, personal digital assistants (personal digital assistants, PDAs), augmented reality (augmented reality, AR) / virtual reality (virtual reality, VR) devices, etc., and the embodiments of the present application are not limited thereto.
[0245] Understandably, Figure 8 The structure of the electronic device 100 shown is only an example. In other embodiments, the electronic device 100 may include more or fewer components than shown, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0246] In some embodiments, the embodiments of the present application further provide a computer program product or a computer program, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the hardware fault detection method provided by the present application.
[0247] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.
[0248] Program code may be applied to input instructions to perform the functions described herein and to generate output information. The output information may be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0249] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.
[0250] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including, but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROMs), random access memories (RAMs), erasable programmable read-only memories (EPROMs), electrically erasable programmable read-only memories (EEPROMs), magnetic or optical cards, flash memory, or tangible machine-readable memories for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Accordingly, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).
[0251] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.
[0252] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.
[0253] It should be noted that in the examples and description of this patent, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of more restrictions, an element defined by the sentence "comprises one" does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0254] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be apparent to those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present application.
Claims
1. A hardware fault detection method, characterized in that: include: detecting a detection instruction for a first processing module in a first processing circuit; Acquire detection data corresponding to the first processing module; Controlling the first processing module to process the detection data to obtain a data processing result; Based on the comparison result between the data processing result and the preset standard result, it is determined whether the first processing circuit has a fault.
2. The hardware fault detection method according to claim 1, characterized in that: The preset standard result is determined by at least one of the following methods: Determine a data processing result of the detection data by a second processing module of the second processing circuit in a normal working state as the preset standard result, wherein the second processing module is of the same type as the first processing module; Based on a first software program instruction corresponding to the first processing module, the detection data is processed to obtain the preset standard result, wherein the processing logic of the first software program instruction is the same as the processing logic of the first processing module.
3. The hardware fault detection method according to claim 1, characterized in that: The first processing circuit includes at least one of the following: Processor chip, application specific integrated circuit, system on chip, high-speed data processing system, logic module on processor chip, microcontroller, microprocessor.
4. The hardware fault detection method according to claim 1, characterized in that: The first processing module is a register reading and writing function module, and, The controlling the first processing module to process the detection data to obtain a data processing result includes: Calling the write instruction corresponding to the register read / write function module to write the read / write detection data into the corresponding register; and, The read instruction corresponding to the register read-write function module is called to read the data processing result from the corresponding register.
5. The fault detection method according to claim 1, characterized in that: The first processing module is an algorithm function module, and, The controlling the first processing module to process the detection data to obtain a data processing result includes: Instructions corresponding to the algorithm function module are called to calculate the algorithm detection data to obtain data processing results corresponding to the algorithm detection data.
6. The hardware fault detection method according to claim 1, characterized in that: The first processing module is a jump function module, and, The controlling the first processing module to process the detection data to obtain a data processing result includes: Calling the jump instruction corresponding to the jump function module; The processing result of the target function corresponding to the jump instruction is read as the data processing result.
7. The hardware fault detection method according to claim 1, characterized in that: The first processing module is an interrupt control function module, and, The controlling the first processing module to process the detection data to obtain a data processing result includes: Calling the instruction corresponding to the control function module; The data in the interrupt status register is read as the data processing result, wherein, corresponding to the interrupt control function module being in the interrupt processing state, the data in the interrupt status register is an interrupt flag value.
8. The hardware fault detection method according to claim 1, characterized in that: The first processing module is a pointer verification and jump target identification module, and the method further includes: The controlling the first processing module to process the detection data to obtain a data processing result includes: Acquire detection data corresponding to at least one submodule of the pointer verification and jump target identification module, wherein the submodule of the pointer verification and jump target identification module includes at least one of the following: a key register read and write function submodule, a pointer encryption algorithm submodule, a program jump target identification submodule, and a control logic submodule; Control each of the submodules to process the detection data to obtain data processing results corresponding to each submodule.
9. The hardware fault detection method according to claim 8, characterized in that: The determining whether the first processing circuit has a fault based on the comparison result between the data processing result and the preset standard result includes: If the data processing result corresponding to any submodule is different from the preset standard result, it is determined that the corresponding submodule and the pointer verification and jump target identification module are faulty.
10. The hardware fault detection method according to claim 8, characterized in that: The detection data corresponding to the key register read-write function submodule is read-write detection data, and, The method for obtaining the preset standard result corresponding to the key register read and write function submodule is as follows: The read-write detection data is used as the preset standard result.
11. The hardware fault detection method according to claim 9, characterized in that: The controlling each of the submodules to process the detection data to obtain data processing results corresponding to each of the submodules includes: Calling the write instruction corresponding to the key register read / write function submodule to write the read / write detection data into the corresponding key register; and, The read instruction corresponding to the key register read-write function submodule is called to read the data processing result from the corresponding key register.
12. The hardware fault detection method according to claim 8, characterized in that: The detection data of the pointer encryption algorithm submodule is algorithm detection data, and the algorithm detection data includes at least one of the following: detection key value, detection modifier value, detection pointer value, and, The method for obtaining the preset standard result corresponding to the pointer encryption algorithm submodule is as follows: The algorithm detection data is calculated based on the pointer encryption algorithm corresponding to the pointer encryption algorithm submodule to obtain the preset standard result.
13. The hardware fault detection method according to claim 12, characterized in that: The controlling each of the submodules to process the detection data to obtain data processing results corresponding to each of the submodules includes: Instructions corresponding to the pointer encryption algorithm submodule are called to calculate the algorithm detection data to obtain data processing results corresponding to the algorithm detection data.
14. The hardware fault detection method according to claim 8, characterized in that: The detection data of the program jump target identification submodule is jump detection data, wherein the jump detection data includes at least one of the following: a function name of a target function, an address of a target function, the first instruction of the target function is a branch target identification instruction, and the target function is used to write a check flag value into a general register; and, The method for obtaining the preset standard result corresponding to the program jump target identification submodule is as follows: The check mark value is used as the preset standard result.
15. The hardware fault detection method according to claim 14, characterized in that: The controlling each of the submodules to process the detection data to obtain data processing results corresponding to each of the submodules includes: Calling the jump instruction corresponding to the program jump target identification submodule; The data in the general register corresponding to the target function is read as the data processing result.
16. The hardware fault detection method according to claim 8, characterized in that: The detection data of the control logic submodule is control logic detection data, wherein the control logic detection data is abnormal data for inducing an interrupt, and the control logic detection data includes at least one of the following: an abnormal check pointer verification code, a target function that does not include a branch target identification instruction; and, The method for obtaining the preset standard result corresponding to the control logic submodule is as follows: The check exception value and the interrupt flag value are used as the preset standard results, wherein the check exception value is used to indicate that the data processing result corresponding to at least one submodule of the key register read and write function submodule, the pointer encryption algorithm submodule, and the program jump target identification submodule is different from the preset processing result, and the interrupt flag value is used to indicate that the control logic submodule is in an interrupt processing state.
17. The hardware fault detection method according to claim 16, characterized in that: The controlling each of the submodules to process the detection data to obtain data processing results corresponding to each of the submodules includes: Calling the instructions corresponding to the control logic submodule; The data in the system register and the status register are read as the data processing result, wherein, corresponding to the control logic submodule being in an interrupt processing state, the data in the system register is the check abnormality value, and the data in the status register is the interrupt flag value.
18. A readable medium, characterized in that The readable medium stores instructions, which, when executed on an electronic device, enable the electronic device to execute the method according to any one of claims 1 to 17.
19. An electronic device, characterized in that: include: a memory for storing instructions to be executed by one or more processors of the electronic device, and The processor is one of the processors of an electronic device, and is used to execute the method according to any one of claims 1 to 17.
20. A program product, characterized in that The program product includes instructions, and when the instructions are executed on an electronic device, the electronic device implements the method according to any one of claims 1 to 17.
