A protection and diagnosis method and device for embedded multi-core processor
By classifying the memory space of the multi-core processor and implanting probes, real-time monitoring of applications is achieved, and the security of data reading and program operation in multi-core processors is solved, improving the security and reliability of the device.
Patent Information
- Application Number
- CN202111458132.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-01
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2041-12-01
AI Technical Summary
In multi-core processors, it is difficult for the prior art to realize real-time monitoring and data reading of processor memory space, resulting in high risk of device failure and the security and reliability of program operation cannot be guaranteed.
Classify the processor memory space into code segment space and data segment space, and implant verification code probes and run probes based on different spatial attributes to monitor the application's code and data content in real time, and handle exceptions through guardian tasks.
Real-time monitoring of the operation of multi-core processor applications is achieved, ensuring the accuracy of data and code, improving the security and reliability of the device, and reducing the risk of failure.
Smart Images

Figure CN114416517B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and more specifically, to a protection and diagnosis method and device for an embedded multi-core processor. Background Art
[0002] At present, in embedded control devices, with the update and upgrade of embedded chip technology, the use of multi-core processors is becoming more and more common, the functions of devices are becoming more and more complex, and the performance requirements are becoming higher and higher. Therefore, multi-threaded application architectures are beginning to be used extensively in embedded devices.
[0003] Along with this, various problems have also emerged in multi-core processors, such as the risk of device software failure due to various reasons, abnormal memory reversal due to hardware failure, and incorrect data content writing due to software defects. In industries with high reliability and safety requirements, accidents caused by equipment failures will lead to huge safety risks and economic losses. In response to the above problems, in the prior art, data security check engines, security check resource libraries, etc. are often used to read and check the data to be detected. However, this method, on the one hand, has a large demand for data reading, which affects the effective operating rate of the processor, resulting in the data checking process occupying a large amount of system resources. On the other hand, the present invention cannot realize real-time monitoring of the application running process, so it is impossible to quickly ensure the overall health of the processor when a task of the application overflows.
[0004] Data probes are a monitoring technology specifically used to obtain data information in applications and are widely used in various applications. However, data probes in the prior art are mostly based on data transmission hardware devices on network links to monitor network traffic, or are used in a single application to monitor the operation of the application interface.
[0005] The prior art does not yet include a technical solution for monitoring program execution and data reading between multi-core structures based on data probes in a processor. Therefore, during program execution and data reading of a multi-core processor, it is difficult to ensure the security of multi-core data usage during the execution of different multi-core applications, and it is also impossible to ensure that program execution is effective, reliable, and does not overflow.
[0006] In view of the above problems, the present invention provides a protection and diagnosis method for an embedded multi-core processor. Summary of the invention
[0007] In order to solve the deficiencies in the prior art, the purpose of the present invention is to provide a protection and diagnosis method for an embedded multi-core processor, classify the memory space of each core in the processor into code segment space and data segment space, and implant different types of probes based on different space attributes to achieve comprehensive monitoring of data, program code, and program operation status.
[0008] The present invention adopts the following technical solution.
[0009] The first aspect of the present invention relates to a protection and diagnosis method for an embedded multi-core processor, wherein the method comprises the following steps: step 1, allocating application memory space to each core of the embedded multi-core processor and setting space attributes; step 2, implanting verification code probes and operation probes into the memory space whose space attributes are code segments, and implanting operation probes into the application to verify the application based on the probes; step 3, based on the verification results, executing a daemon task to process the application.
[0010] Preferably, the daemon task and system boot are deployed to the zeroth core of the multi-core processor, and the application is deployed to the cores other than the zeroth core in the multi-core processor; when starting the multi-core processor, the zeroth core is started first, and then the application in the other cores is started based on the daemon task and system boot.
[0011] Preferably, the memory space includes a code segment space and a data segment space; the space attributes include a code segment and a data segment, wherein the code segment attribute is a read-only mode, and the data segment attribute is a read-write mode.
[0012] Preferably, the daemon task implants a checksum probe into the code segment space and an operation probe into the application scheduling interface; wherein the checksum probe is used to detect whether the code content stored in the code segment space of the application is accurate based on a preset periodic interval; and the operation probe is used to detect whether the operation data of the application is accurate.
[0013] Preferably, the method for the check code probe to detect the code content in the code segment space is: step 2.1.1, obtain the code content stored in the code segment space, and calculate the check code of the code content; step 2.1.2, call the check code field pre-stored in the daemon task, and compare the check code of the code content with the check code field; step 2.1.3, when the comparison result is consistent, it is determined that the current code content is accurate, and when the comparison result is inconsistent, it is determined that the current code content has been tampered with, and an alarm event is triggered.
[0014] Preferably, the running probe verifies the running data as follows: Step 2.2.1, the running probe monitors the scheduling frequency, running time, and network resource occupancy of the interface in the application in real time, and resets the software timer; Step 2.2.2, when the execution time of the software timer exceeds the task threshold, the current task of the application is interrupted; Step 2.2.3, when the network resource occupancy exceeds the occupancy threshold, the current task of the application is interrupted.
[0015] Preferably, the data segment space includes a common data space and a key data space; and the key data space is implemented based on a calibration process of the application program.
[0016] Preferably, the daemon task implants a checksum probe into the critical data space.
[0017] Preferably, the method for the check code probe to detect the data content in the key data space is: step 2.3.1, when the application reads the data content in the key data space, the check code probe starts to check the data content; step 2.3.2, the verification is implemented in the same way as in step 2.1.2; step 2.3.3, when the verification is successful, the data content is determined to be accurate, and the data content is provided to the application; when the verification fails, the data content is determined to be incorrect, and an alarm event is triggered.
[0018] Preferably, when the daemon task triggers an alarm event, it interrupts the application corresponding to the code content, or interrupts the application's reading of the data content; wherein the alarm event records and stores event time, error code, error data, task scheduling frequency, task running time and task network resource occupancy information.
[0019] Preferably, a hardware timer reset circuit is used to monitor the guardian task; the guardian task sends a reset instruction to the timer at a set time interval to instruct the timer to reset and restart the timing; when the timer timing exceeds the set value, the timer reset circuit restarts the multi-core processor.
[0020] A second aspect of the present invention relates to a protection and diagnosis device for an embedded multi-core processor, wherein the device is used to implement a protection and diagnosis method for an embedded multi-core processor as described in any one of the first aspect of the present invention.
[0021] The beneficial effect of the present invention is that, compared with the prior art, the protection and diagnosis method of an embedded multi-core processor in the present invention is used to classify the memory space of each core in the processor into a code segment space and a data segment space, and implant different types of probes based on different space attributes to achieve comprehensive monitoring of data, program code, and program operation. The method of the present invention is simple, occupies less resources, and can obtain the application operation status of each core in the multi-core processor in real time and accurately, and whether the application code and data content are accurate.
[0022] The beneficial effects of the present invention also include:
[0023] 1. Since the data content is divided into key data and common data in the present invention, a balance is achieved between the calling speed and accuracy in the process of the application calling the data. Moreover, the key data calibration method is implemented by the application itself, which not only improves the autonomy of the application, but also increases the confidence for the selection of key data.
[0024] 2. In the present invention, other applications can be executed only after the guard task is executed, which fully guarantees the priority of the guard task related functions in the multi-core processor and ensures the safety of the multi-core processor. In addition, through the timer reset circuit, when the guard task fails, the guard task can also be restarted in time, further realizing the safety of the multi-core processor under abnormal conditions.
[0025] 3. The present invention uses two types of probes, namely, check code probe and operation probe, to perform reasonable detection on the contents such as code or data, thereby comprehensively ensuring the security of the multi-core processor. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] Figure 1 A schematic flow chart of the steps of a protection and diagnosis method for an embedded multi-core processor of the present invention;
[0027] Figure 2 A schematic diagram of the operation mode of the daemon program between the cores in a multi-core processor in a protection and diagnosis method of an embedded multi-core processor of the present invention;
[0028] Figure 3 It is a schematic diagram of the operation mode of the checksum probe in the code segment space in the protection and diagnosis method of the embedded multi-core processor of the present invention;
[0029] Figure 4 It is a schematic diagram of the operation mode of the check code probe in the key data space in the protection and diagnosis method of the embedded multi-core processor of the present invention;
[0030] Figure 5The present invention is a schematic flow chart of the steps of restarting a guard task failure in a protection and diagnosis method for an embedded multi-core processor. DETAILED DESCRIPTION
[0031] The present application is further described below in conjunction with the accompanying drawings. The following embodiments are only used to more clearly illustrate the technical solution of the present invention, and cannot be used to limit the protection scope of the present application.
[0032] Figure 1 FIG. 1 is a flow chart of the steps of a protection and diagnosis method for an embedded multi-core processor of the present invention. Figure 1 As shown, the first aspect of the present invention relates to a protection and diagnosis method for an embedded multi-core processor, wherein the method includes steps 1 to 3.
[0033] Step 1: allocate application memory space to each core of the embedded multi-core processor and set space attributes.
[0034] First of all, it should be noted that the method of the present invention provides a memory protection mechanism when the embedded device is running. From the hardware level, the present invention provides a set of fault detection methods to detect running faults in real time, including code segment anomalies, key data segment anomalies, application program anomalies and other functions.
[0035] In order to achieve the above functions, in the present invention, the daemon task and system boot are deployed in the zeroth core of the multi-core processor, and the application is deployed in the other cores of the multi-core processor except the zeroth core; when starting the multi-core processor, the zeroth core is started first, and then the application in the other cores is started based on the daemon task and system boot.
[0036] It is understandable that the zeroth core in the multi-core processor of the present invention can be used to deploy monitoring and management functions for other processors in the entire multi-core processor. For example, the guard function of the present invention can be deployed, as well as the boot function for other processors.
[0037] Figure 2 The schematic diagram of the operation mode of the daemon program between the cores in the multi-core processor in the protection and diagnosis method of the embedded multi-core processor of the present invention is shown in FIG. Figure 2 As shown, specifically, before using the multi-core processor for the first time, the memory space of other cores in the multi-core processor can be divided to allocate appropriate memory space for the application program to be installed. Specifically, in the present invention, the memory management unit can be used to manage the virtual memory and the physical memory first, and a mapping relationship between the virtual address and the physical address can be created. After the overall construction of the virtual storage space is completed, the memory space can be allocated.
[0038] During the allocation process, the present invention divides the memory space into two different space types: code segment space and data segment space. The code segment space can be used exclusively to store code, and the data segment space can be used exclusively to store data.
[0039] Preferably, the memory space includes a code segment space and a data segment space; the space attributes include a code segment and a data segment, wherein the code segment attribute is a read-only mode, and the data segment attribute is a read-write mode.
[0040] Specifically, in order to make the corresponding storage content in the memory space safe and accurate, the content in the code segment space is set to read-only attribute. Since the content stored in the code segment space is the original code of the application, the possibility of content update and modification is relatively small. Therefore, the present invention places the logic of upgrading and updating this part of the code outside the guardian task when the application initiates the upgrade, so that under the control of the guardian task, all code content in the code segment space cannot be modified.
[0041] On the other hand, the data segment code can be set to a configurable mode that can be read and written, so that the application itself can modify the data content generated during its operation in real time.
[0042] Step 2: implant a verification code probe and a running probe into the memory space whose space attribute is the code segment, and implant a running probe into the application program to verify the application program based on the probe.
[0043] After completing the reasonable division and allocation of memory space, the application can be verified based on the implanted probes.
[0044] Preferably, the daemon task implants a checksum probe into the code segment space and an operation probe into the application scheduling interface; wherein the checksum probe is used to detect whether the code content stored in the code segment space of the application is accurate based on a preset periodic interval; and the operation probe is used to detect whether the operation data of the application is accurate.
[0045] It is understandable that the guard task in the present invention can implant corresponding probes into the corresponding memory space. The probes used in the present invention include two different types: check code probes and operation probes.
[0046] Generally speaking, the operation mode of the check code probe is to obtain data through the probe, generate the check code of the obtained data based on the check algorithm, obtain the original check code pre-existing in the daemon task, and compare the two check codes. When the check codes are the same, it means that the obtained data has not been tampered with. If there is a difference between the two check codes, it means that the obtained data is abnormal.
[0047] On the other hand, the present invention can also set up a running probe. This probe can be implanted in the input and output interface of the application program. In this way, the probe can obtain relevant information of the application program in real time and judge problems in the program running process through the content of this information.
[0048] Specifically, due to its verification characteristics, the checksum probe can only be used to detect the code content in the code segment space. The operation probe is generally used to detect the running data of the application. It can be seen that the checksum probe can monitor the integrity and accuracy of the program code content, while the operation probe is used to determine whether the program task scheduling and program operation are normal.
[0049] Since the daemon task has the highest priority and is started before other applications, when the daemon task probe finds an abnormality, it can issue a command to interrupt other running applications or interrupt a task of other running applications, and provide a corresponding exception handling mechanism after the program or task is interrupted.
[0050] Figure 3 The schematic diagram of the operation mode of the checksum probe in the code segment space in the protection and diagnosis method of the embedded multi-core processor of the present invention is shown in FIG. Figure 3 As shown, preferably, the method for detecting the code content in the code segment space by the check code probe is: step 2.1.1, obtaining the code content stored in the code segment space, and calculating the check code of the code content; step 2.1.2, calling the check code field pre-stored in the daemon task, and comparing the check code of the code content with the check code field; step 2.1.3, when the comparison result is consistent, it is determined that the current code content is accurate, and when the comparison result is inconsistent, it is determined that the current code content has been tampered with, and an alarm event is triggered.
[0051] Specifically, after the probe obtains the code content stored in the code segment space, it will use the verification method to calculate the verification code. The verification code is relatively fast and accurate. Therefore, after the verification probe is first placed in the determined code segment space that is prohibited from modification, the code content therein can be read and written for the first time, and the first obtained verification code can be stored as a verification code field in the daemon. When the daemon needs to verify the code content, it can compare whether the currently obtained verification code is consistent with the content in the verification code field. If they are consistent, it means that the content in the memory space is consistent with the original content and the code has not been tampered with. However, if the verification code is inconsistent, the read-only attribute of the current space can indicate that the code content has been maliciously tampered with.
[0052] In this case, the probe will trigger an alarm event and repair the corresponding code content. This part is described in detail in step 3.
[0053] Preferably, the running probe verifies the running data in the following manner: Step 2.2.1, the running probe monitors the scheduling frequency, running time, and network resource occupancy of the interface in the application in real time, and resets the software timer; Step 2.2.2, when the execution time of the software timer exceeds the task threshold, the current task of the application is interrupted; Step 2.2.3, when the network resource occupancy exceeds the occupancy threshold, the current task of the terminal application is terminated.
[0054] The operation probe in the present invention can monitor the scheduling of the application structure in real time, such as recording the running time of each interface for data transmission and reception, and the occupancy of network resources. First of all, for the occupancy of network resources, which can also be called thread occupancy, the data situation of each stack can be recorded, such as whether an overflow occurs. In the process of interface data transmission and reception, if a stack overflow is caused, a program exception may be caused. In this case, the judgment of the exception can be achieved based on the comparison result between the network resource occupancy and the occupancy threshold. When the stack overflows, the data content in the stack must be damaged, so the application interruption can be triggered according to this situation, and an alarm can be issued to solve the current problem.
[0055] Secondly, for the running time, the starting time and the ending time of each application task can be recorded. If the running time of a task exceeds the set task running time limit, that is, the task threshold in the present invention, the same method is used to terminate the task, or in serious cases, terminate the application.
[0056] Preferably, the data segment space includes a common data space and a key data space; and the key data space is implemented based on a calibration process of the application program.
[0057] It is understandable that the data segment space in the present invention includes a common data space and a key data space. For the common data space, the present invention may not implement probe implantation. For the key data space, the present invention may implant a check code probe to implement the accuracy verification of the key data.
[0058] Generally speaking, key data can be data content that is frequently read by some applications. This data does not belong to the code of the application itself, but due to the key nature of its data content, it should not be rewritten after it is first stored. The division of key data and ordinary data can be completed through the application's own definition. For example, key data can be defined according to the calibration process of the application.
[0059] Preferably, the daemon task implants a checksum probe into the critical data space. The daemon task implants the checksum probe into the critical data space according to the calibration of the application program, while ignoring operations on the common data space.
[0060] Figure 4 The schematic diagram of the operation mode of the check code probe in the key data space in the protection and diagnosis method of the embedded multi-core processor of the present invention is shown in FIG. Figure 4 As shown, preferably, the method for the check code probe to detect the data content in the key data space is: step 2.3.1, when the application reads the data content in the key data space, the check code probe starts to check the data content; step 2.3.2, the verification is implemented in the same way as in step 2.1.2; step 2.3.3, when the verification is successful, the data content is determined to be accurate, and the data content is provided to the application; when the verification fails, the data content is determined to be incorrect, and an alarm event is triggered.
[0061] It can be understood that the verification method of the verification code probe on the data content in the key data space in the present invention is similar to the verification method of the verification code probe on the code content. When the verification fails, an alarm event will be issued.
[0062] Preferably, when the daemon task triggers an alarm event, it interrupts the application corresponding to the code content, or interrupts the application's reading of the data content; wherein the alarm event records and stores event time, error code, error data, task scheduling frequency, task running time and task network resource occupancy information.
[0063] When the daemon task triggers an alarm event, the present invention can select to interrupt the application program or interrupt a task process of the application program based on the type of the alarm event.
[0064] The alarm event can be used to store different event-related contents according to the different probe types. For example, for the check code implanted in the code segment space, the time and error code of the event can be recorded. For the check code implanted in the data segment space, the time and error data of the event can be recorded. In addition, in the present invention, for the alarm event issued by the running pointer, the cause of the alarm can be obtained according to the task scheduling frequency, task running time, and task network resource occupancy information, and a corresponding fault handling method can be provided based on the cause.
[0065] Figure 5 The figure is a flow chart of the steps of restarting a guard task failure in a protection and diagnosis method for an embedded multi-core processor of the present invention. Figure 5As shown, preferably, a hardware timer reset circuit is used to monitor the guardian task; the guardian task sends a reset instruction to the timer at a set time interval to instruct the timer to restart the timing after resetting; when the timer timing exceeds the set value, the timer reset circuit restarts the multi-core processor.
[0066] In the present invention, the timer reset circuit can monitor the state of the guard task. According to the principle of the timer, when the guard task does not send a reset instruction for a long time, the timer count will exceed the set value. At this time, the timer reset circuit will restart the multi-core processor, and then execute the startup of other applications after starting the guard task first.
[0067] In this way, it is fully guaranteed that other applications can only run when the daemon task is turned on. Therefore, the daemon task can always monitor the status of the timer and protect the multi-core processor based on the status.
[0068] Step 3: Based on the verification result, execute the daemon task to process the application.
[0069] In the present invention, different operations can be performed based on different verification results. For example, when the alarm event indicates that the code or data of a certain space is incorrect, the guardian task can instruct the processor to read the corresponding information segment from the local backup content and re-overwrite the current space with the correct code or data. The processor can also obtain accurate information content from other devices through network communication.
[0070] When the alarm event indicates that a problem has occurred during the program operation, the daemon task can interrupt the current task of the application, delete the data under the current task, and re-execute the current task, or check the cause of the problem. If there is a malicious attack, the network port will be interrupted in time.
[0071] A second aspect of the present invention relates to a protection and diagnosis device for an embedded multi-core processor, wherein the device is used to implement a protection and diagnosis method for an embedded multi-core processor as described in the first aspect of the present invention.
[0072] The beneficial effect of the present invention is that, compared with the prior art, the protection and diagnosis method of an embedded multi-core processor in the present invention is used to classify the memory space of each core in the processor into a code segment space and a data segment space, and implant different types of probes based on different space attributes to achieve comprehensive monitoring of data, program code, and program operation. The method of the present invention is simple, occupies less resources, and can obtain the application operation status of each core in the multi-core processor in real time and accurately, and whether the application code and data content are accurate.
[0073] The applicant of the present invention has made a detailed explanation and description of the implementation examples of the present invention in conjunction with the drawings in the specification. However, those skilled in the art should understand that the above implementation examples are only preferred implementation schemes of the present invention, and the detailed description is only to help readers better understand the spirit of the present invention, but not to limit the scope of protection of the present invention. On the contrary, any improvements or modifications based on the inventive spirit of the present invention should fall within the scope of protection of the present invention.
Claims
1. A protection and diagnosis method for an embedded multi-core processor, characterized in that: The method comprises the following steps: Step 1, allocating application memory space to each core of the embedded multi-core processor and setting space attributes; Deploy a daemon task and a system boot to the zeroth core of the multi-core processor, and deploy the application to other cores of the multi-core processor except the zeroth core; When starting the multi-core processor, first start the zeroth core, and then start the application programs in the other cores based on the daemon task and the system boot; Step 2, implanting a verification code probe into the memory space whose space attribute is a code segment, and implanting a running probe into the application, so as to verify the application based on the probe; Step 3, based on the verification result, executing a daemon task to process the application; The daemon task implants a checksum probe into the code segment space and an operation probe into the application scheduling interface; The verification code probe is used to detect whether the code content stored in the code segment space of the application is accurate based on a preset periodic interval; The operation probe is used to detect whether the operation data of the application is accurate.
2. The method for protecting and diagnosing an embedded multi-core processor according to claim 1, characterized in that: The memory space includes a code segment space and a data segment space; The space attributes include a code segment and a data segment, wherein the code segment attribute is a read-only mode, and the data segment attribute is a read-write mode.
3. The protection and diagnosis method of an embedded multi-core processor according to claim 2, characterized in that: The method for the verification code probe to detect the code content in the code segment space is: Step 2.1.1, obtaining the code content stored in the code segment space, and calculating the check code of the code content; Step 2.1.2, calling the verification code field pre-stored in the guard task, and comparing the verification code of the code content with the verification code field; Step 2.1.3: When the comparison results are consistent, it is determined that the current code content is accurate; when the comparison results are inconsistent, it is determined that the current code content has been tampered with, and an alarm event is triggered.
4. The method for protecting and diagnosing an embedded multi-core processor according to claim 2, characterized in that: The method for the operation probe to verify the operation data is: Step 2.2.1, the operation probe monitors the scheduling frequency, running time, and network resource occupancy of the interface in the application in real time, and resets the software timer; Step 2.2.2, when the execution time of the software timer exceeds the task threshold, interrupting the current task of the application; Step 2.2.3: when the network resource occupancy exceeds a threshold, interrupt the current task of the application.
5. The method for protecting and diagnosing an embedded multi-core processor according to claim 2, characterized in that: The data segment space includes a common data space and a key data space; and, The critical data space is implemented based on a calibration process of the application.
6. A method for protecting and diagnosing an embedded multi-core processor according to claim 5, characterized in that: The daemon task implants the checksum probe into the critical data space.
7. A protection and diagnosis method for an embedded multi-core processor according to claim 6, characterized in that: The method for the verification code probe to detect the data content in the key data space is: Step 2.3.1, when the application reads the data content in the key data space, the verification code probe starts to verify the data content; Step 2.3.2, implement verification in the same manner as in step 2.1.2; Step 2.3.3, when the verification succeeds, the data content is determined to be accurate and the data content is provided to the application; when the verification fails, the data content is determined to be incorrect and an alarm event is triggered.
8. A method for protecting and diagnosing an embedded multi-core processor according to claim 3, 4 or 6, characterized in that: When the daemon task triggers an alarm event, the application corresponding to the code content is interrupted, or the reading of data content by the application is interrupted; The alarm event records and stores event time, error code, error data, task scheduling frequency, task running time and task network resource occupancy information.
9. The method for protecting and diagnosing an embedded multi-core processor according to claim 1, characterized in that: A hardware timer reset circuit is used to monitor the daemon task; The daemon task sends a reset instruction to the timer at a set time interval to instruct the timer to reset and restart; When the timing of the timer exceeds a set value, the timer reset circuit restarts the multi-core processor.
10. A protection and diagnosis device for an embedded multi-core processor, characterized in that: The device is used to implement a protection and diagnosis method for an embedded multi-core processor as described in any one of claims 1-9.
Citation Information
Patent Citations
Multi-core parallel system processing method based on hardware protection
CN107357666A
Heterogeneous platform-oriented multi-level storage structure memory detection method
CN112631893A
