Self-checking method and device of memory management unit, electronic equipment and storage medium
By using pre-set self-test strategies in the memory management unit and combining the self-test methods of user-state and memory-state programs, the problem that the memory management unit cannot self-test is solved, and timely detection and processing of faults is achieved, and the stability of the microkernel operating system is improved.
Patent Information
- Application Number
- CN202510101004.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-05-16
AI Technical Summary
In the prior art, memory management units cannot conduct self-tests, resulting in failures in time to detect their own faults, affecting the stability of the microkernel operating system.
By obtaining pre-set self-test policy, the self-test policy includes user-state self-test method and memory-state verification method. The user-state program executes the user-state self-test method to generate self-test information. The memory program executes the memory-state verification method to verify the self-test information, obtains the self-test verification result and sends it to the user-state program. The user-state program determines the self-test result of the memory management unit based on the results.
The self-test of the memory management unit is realized, which avoids the delay in failure detection caused by inability to self-test and improves the stability of the microkernel operating system.
Smart Images

Figure CN120011122A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of industrial control technology, and in particular to a self-checking method, device, electronic device and storage medium of a memory management unit. Background Art
[0002] In industrial production scenarios, microkernel operating systems are a common system. Microkernel operating systems store the core system scheduling, memory management and other parts in the kernel state, and non-core functions such as storage management and peripheral management in the user state, so that the microkernel operating system has a more compact size and reduces the redundancy generated by the microkernel operating system, improving the overall stability and real-time performance of the microkernel operating system. Since it is a modular structure, each function can form a module independently. Therefore, in order to make the modules interact with each other, it is necessary to implement it through the inter-process communication (IPC) message mechanism. At the same time, modularization facilitates the addition and deletion of microkernel operating system functions, and has a certain degree of flexibility. The overall system will not crash due to the modification of a function or the occurrence of an error, which greatly improves the reliability of the system.
[0003] Modern central processing units (CPUs) all have MMU (Memory Management Unit), whose main function is to realize the conversion between virtual addresses and physical addresses, and provide functions such as access control and cache management. The MMU memory management mechanism is an important component of the microkernel operating system, which can improve the stability and security of the system. The kernel state and user state of the microkernel operating system both use MMU for mapping virtual addresses to physical addresses and security management. Based on the memory management characteristics of the microkernel operating system, the user state can obtain virtual address and physical address pairs at the same time when applying for memory through the memory mapping interface.
[0004] The normal operation of the operating system is inseparable from the stable and reliable virtual address to physical mapping provided by the MMU. Once the MMU fails, the operating system will not be able to run normally. In related technologies, the memory management unit cannot perform self-checks, resulting in the inability to detect its own faults in a timely manner, affecting the stability of the microkernel operating system. Summary of the invention
[0005] In view of this, an embodiment of the present application provides a self-check method, device, electronic device and storage medium for a memory management unit to solve the problem in the prior art that the memory management unit is unable to perform self-check, resulting in the inability to detect its own faults in time, affecting the stability of the microkernel operating system.
[0006] In a first aspect of an embodiment of the present application, a self-test method for a memory management unit is provided, the method comprising: obtaining a pre-set self-test strategy, the self-test strategy comprising a user-state self-test method and a memory-state verification method; executing the user-state self-test method in the self-test strategy by a user-state program to generate self-test information; executing the memory-state verification method corresponding to the self-test strategy by a memory-state program to perform self-test verification on the self-test information to obtain a self-test verification result, and sending the self-test verification result to the user-state program, so that the user-state program determines the self-test result of the memory management unit through the self-test verification result.
[0007] According to a second aspect of an embodiment of the present application, a self-checking device for a memory management unit is provided, the device comprising: a policy module, for obtaining a pre-set self-checking strategy, the self-checking strategy comprising a user-state self-checking method and a memory-state verification method; a self-checking module, for executing the user-state self-checking method in the self-checking strategy through a user-state program to generate self-checking information; executing the memory-state verification method corresponding to the self-checking strategy through a memory-state program, performing self-checking verification on the self-checking information, obtaining a self-checking verification result, and sending the self-checking verification result to the user-state program, so that the user-state program determines the self-checking result of the memory management unit through the self-checking verification result.
[0008] According to a third aspect of an embodiment of the present application, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.
[0009] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, which stores a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0010] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the self-checking method of the memory management unit in the embodiments of the present application obtains a pre-set self-checking strategy, wherein the self-checking strategy includes a user-state self-checking method and a memory-state verification method; the user-state self-checking method in the self-checking strategy is executed by the user-state program to generate self-checking information; the memory-state verification method corresponding to the self-checking strategy is executed by the memory-state program to perform self-checking verification on the self-checking information to obtain a self-checking verification result, and the self-checking verification result is sent to the user-state program, so that the user-state program determines the self-checking result of the memory management unit through the self-checking verification result. The present application pre-sets a self-checking strategy so that the memory management unit can generate self-checking information through the user-state self-checking method in the self-checking strategy, and then verifies the self-checking information through the memory-state verification method, thereby realizing the self-checking of the memory management unit and avoiding the problem in the related art that the memory management unit cannot perform self-checking, resulting in the inability to timely discover its own faults, thereby affecting the stability of the microkernel operating system. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0012] Figure 1 It is a basic schematic diagram of a self-checking method of a memory management unit provided in an embodiment of the present application;
[0013] Figure 2 This is a basic schematic diagram of kernel-mode and user-mode virtual address conversion provided by an embodiment of the present application;
[0014] Figure 3 It is a flowchart of another self-checking method of a memory management unit provided in an embodiment of the present application;
[0015] Figure 4 It is a flowchart of another self-checking method of a memory management unit provided in an embodiment of the present application;
[0016] Figure 5 It is a flowchart of another self-checking method of a memory management unit provided in an embodiment of the present application;
[0017] Figure 6 It is a flowchart of another optional self-checking method of a memory management unit provided in an embodiment of the present application;
[0018] Figure 7 It is a flowchart of another optional self-checking method of a memory management unit provided in an embodiment of the present application;
[0019] Figure 8 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0020] Fig. 9 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0021] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.
[0022] A self-check method and device for a memory management unit according to an embodiment of the present application will be described in detail below with reference to the accompanying drawings.
[0023] Figure 1 A self-checking method of a memory management unit is provided in an embodiment of the present application, such as Figure 1 As shown, the method includes:
[0024] S101, obtaining a preset self-checking strategy, where the self-checking strategy includes a user state self-checking method and a memory state verification method;
[0025] S102, executing the user-mode self-check method in the self-check strategy through the user-mode program to generate self-check information;
[0026] S103, executing the memory state verification method corresponding to the self-test strategy through the memory state program, performing self-test verification on the self-test information, obtaining a self-test verification result, and sending the self-test verification result to the user state program, so that the user state program determines the self-test result of the memory management unit through the self-test verification result.
[0027] It can be understood that the method provided by the present application is applied to a memory management unit, and it can be understood that the memory management unit is used to map and securely manage virtual addresses and physical addresses. Among them, user-mode programs use user-mode virtual addresses, and kernel-mode programs use memory-mode virtual addresses; Figure 2 As shown, the kernel state virtual address uses the base address register 1 of the MMU and the kernel state address translation table to realize the mapping of the kernel state virtual address to the peripheral physical address, and the user state virtual address uses the base address register 0 of the MMU and the user state address translation table to realize the mapping of the user state virtual address to the peripheral physical address. Among them, the microkernel operating system uses the MMU memory management unit so that both the user state and the kernel state can use continuous virtual addresses and the kernel state and the user state virtual addresses are physically isolated and cannot access each other, thereby improving the stability and security of the system.
[0028] In some examples, the present application pre-sets a self-check strategy, which includes a user-state self-check method and a memory-state verification method. The user-state self-check method is executed by a user-state program, and the memory-state verification method is executed by a memory-state program.
[0029] After obtaining the self-test strategy, the present application will generate self-test information by executing the user-state self-test method in the self-test strategy through the user state, and then execute the memory-state verification method corresponding to the self-test strategy through the memory-state program to perform self-test verification on the self-test information to obtain a self-test verification result, which includes information on whether the verification passed or failed.
[0030] In the present application, after obtaining the above-mentioned self-test verification result, the user-mode program will determine the self-test result of the memory management unit through the self-test verification result; illustratively, when the self-test verification result is failed, it is determined that the memory management unit self-test has failed and a fault exists; when the self-test verification result is passed, it is determined that the memory management unit self-test has succeeded and no fault exists.
[0031] In some examples, the memory management unit of the present application is also provided with a translation lookaside buffer (TLB), which is a cache structure provided by the MMU memory management unit for accelerating the conversion of virtual memory addresses to physical memory addresses. The mapping relationship between the virtual address and the physical address that has been mapped in the microkernel operating system is cached in the TLB. When the processor performs addressing, it first searches the TLB for the corresponding physical address based on the virtual address for access. When the MMU has a hardware or software failure, the microkernel operating system will not immediately have an address access failure problem, which allows it to complete the MMU fault diagnosis and notify the upper layer application within a certain period of time.
[0032] It can be understood that the memory management unit in the present application may periodically obtain a pre-set self-test strategy and subsequently perform a self-test based on the obtained self-test strategy; in some examples, the memory management unit may also obtain a pre-set self-test strategy upon receiving a self-test instruction.
[0033] According to the technical solution provided in the embodiment of the present application, a pre-set self-test strategy is obtained, and the self-test strategy includes a user-state self-test method and a memory-state verification method; the user-state self-test method in the self-test strategy is executed by a user-state program to generate self-test information; the memory-state verification method corresponding to the self-test strategy is executed by the memory-state program to perform self-test verification on the self-test information to obtain a self-test verification result, and the self-test verification result is sent to the user-state program, so that the user-state program determines the self-test result of the memory management unit through the self-test verification result. The present application pre-sets a self-test strategy so that the memory management unit can generate self-test information through the user-state self-test method in the self-test strategy, and then verifies the self-test information through the memory-state verification method, thereby realizing self-test of the memory management unit, thereby avoiding the problem in the related art that the memory management unit cannot perform self-test, resulting in the inability to timely discover its own faults, thereby affecting the stability of the microkernel operating system.
[0034] In some examples, the number of self-check strategies is multiple, such as Figure 3 As shown, obtain the preset self-check strategy, including:
[0035] S301, obtaining the self-check strategy arranged in front;
[0036] S302: When the previously arranged self-check strategy is executed and the self-check result of the memory management unit is passed, obtain the next self-check strategy.
[0037] It can be understood that when there are multiple self-check strategies, the present application will first sort the multiple self-check strategies, and then obtain the self-check strategy arranged in front, and perform self-check according to the self-check strategy arranged in front. After the execution is completed according to the self-check strategy arranged in front, the present application will obtain the next self-check strategy, and perform self-check according to the next self-check strategy obtained, until all self-check strategies are executed.
[0038] It can be understood that in order to avoid the problem of resource waste caused by subsequent meaningless self-tests, the present application will only obtain the next self-test strategy when the self-test result of the memory management unit is passed. If the self-test result of the memory management unit is a self-test failure when executing any self-test strategy, the self-test process of the memory management unit will be directly exited, and the self-test result will be output, thereby avoiding the problem of resource waste caused by subsequent meaningless self-tests.
[0039] In some examples, when there are multiple self-check strategies, obtaining a pre-set self-check strategy also includes: randomly obtaining a self-check strategy, and after the randomly obtained self-check strategy is acquired and executed, randomly obtaining another self-check strategy (removing the self-check strategy after execution and randomly obtaining the self-check strategy), and performing self-check according to the next self-check strategy obtained until all self-check strategies are executed.
[0040] For example, the pre-set self-checking strategies include configuration self-checking strategy, address mapping function self-checking strategy and self-generated fault self-checking strategy. Figure 4 As shown, the self-check method of the memory management unit in the present application is periodically called by the upper-layer security application to implement periodic self-check diagnosis of the memory management unit. Among them, in order to ensure that the operation of the microkernel operating system does not cause abnormalities during the self-check diagnosis of the memory management unit, the microkernel operating system is temporarily suspended by disabling global interrupts and using privileged commands to make the central processing unit enter the privileged management mode during the self-check diagnosis of the memory management unit, and then the configuration self-check strategy, address mapping function self-check strategy and autonomous generation fault self-check strategy are obtained in sequence, so that the memory management unit performs configuration self-check, address mapping self-check and autonomous production fault self-check respectively. The memory management unit executes the next self-check strategy after each self-check strategy passes the self-check, and directly terminates the self-check when the self-check fails, and then collects the diagnosis report and reports it to the security application.
[0041] According to the technical solution provided in the embodiment of the present application, a self-check strategy arranged in front is obtained; when the self-check strategy arranged in front is executed and the self-check result of the memory management unit is passed, the next self-check strategy is obtained, thereby realizing self-check of the memory management unit in sequence through multiple ways, thereby improving the accuracy of the self-check, and the present application obtains the next self-check strategy only when the previous self-check strategy is executed and the self-check result of the memory management unit is passed, thereby avoiding the problem of waste of resources caused by subsequent meaningless self-checks.
[0042] It can be understood that the memory management unit is equipped with enable registers, attribute registers, control registers, base address registers and other registers. The above registers jointly realize the normal operation of the memory management unit. If the configuration of any of the registers fails, it may cause the memory management unit to fail to operate, and then cause the microkernel system to run unstable.
[0043] Continuing with the above example, the self-check strategy provided by the present application includes a configuration self-check strategy, which is used to determine whether there is any abnormality in the configuration of the memory management unit self-check register; it can be understood that the existing configuration information (such as the initial value of the parameter in the register) can only be read and written in the kernel state. Based on the above reasons, the present application uses a user state program to read the configuration information of the register, and then compares the read configuration information with the configuration information of the register saved by the memory state program, so as to determine whether there is any abnormality in the configuration information of the register.
[0044] Specifically, the user state self-test method in the self-test strategy is executed by the user state program to generate self-test information, including: executing the user state self-test method by the user state program to read the configuration information of the register, and generating the self-test information according to the configuration information of the register. Figure 5 As shown, when the memory management unit performs self-test according to the configuration self-test policy, the configuration information stored in the register is first read through the user mode program, and self-test information is generated according to the configuration information.
[0045] It can be understood that since the interaction between various modules in the microkernel operating system needs to be implemented through the IPC message mechanism, generating self-test information based on the configuration information includes: generating an IPC message header, and generating self-test information based on the configuration information and the IPC message header; in some examples, in order to ensure the accuracy of the configuration information, generating self-test information based on the configuration information includes: generating an IPC message header and verification information, and generating self-test information based on the configuration information, the IPC message header, and the verification information.
[0046] After receiving the self-test information, the kernel state program will verify the self-test information and obtain a self-test verification result. Specifically, the memory state program executes a memory state verification method corresponding to the self-test strategy to perform self-test verification on the self-test information and obtain a self-test verification result, including: executing the memory state verification method through the memory state program to parse the self-test information and obtain the configuration information carried in the self-test information; obtaining the saved target configuration information through the memory state program, and comparing the configuration information carried in the parsed self-test information with the target configuration information to obtain a self-test verification result.
[0047] like Figure 5 As shown, after receiving the self-test information, the kernel-state program parses the self-test information to obtain the configuration information carried in the self-test information, and then compares the configuration information with the saved target configuration information, and generates a self-test verification result based on the comparison result, and the self-test verification result is used by the user-state program to determine the self-test result of the memory management unit. Specifically, the kernel-state program sends the self-test verification result to the user-state program. After receiving the self-test verification result, if the self-test verification result indicates that the configuration information matches the saved target configuration information, the user-state program determines that the configuration self-test result of the memory management unit is a configuration self-test pass (self-test success); if the self-test verification result indicates that the configuration information does not match the saved target configuration information, the user-state program determines that the configuration self-test result of the memory management unit is a configuration self-test failure (self-test failure).
[0048] It can be understood that if during the process of the memory management unit performing configuration self-test, the user-state program times out and does not receive the self-test verification result returned by the memory-state program (the user-state program starts timing after sending the self-test information to the memory-state program. If the timing reaches the preset timeout duration and the self-test verification result returned by the memory-state program is not received, it is determined that the self-test verification result returned by the memory-state program has not been received due to the timeout), the user-state program determines that the configuration self-test result of the memory management unit is that the configuration self-test has failed.
[0049] It can be understood that an important function of the memory management unit is to perform mapping and security management of virtual addresses and physical addresses. If the address mapping function fails, it will cause address access failure problems in the microkernel operating system. In order to determine whether there is a failure in the address mapping function of the memory management unit, the present application proposes an address mapping function self-check strategy.
[0050] Continuing with the above example, when the memory management unit executes the address mapping function self-test strategy, the present application applies for a memory block through a user-state program, writes test data in the applied memory block, and subsequently verifies the test in the memory block through the user-state program, thereby determining whether the address mapping function of the memory management unit fails. When the memory management unit executes the address mapping function self-test strategy, the user-state self-test method in the self-test strategy is executed by the user-state program to generate self-test information, including: executing the user-state self-test method through the user-state program to apply for a memory block from the memory mapping interface, and obtaining the virtual address and physical address corresponding to the memory block; generating test data according to a data generation algorithm, and writing the test data into the memory block through a virtual address, and generating self-test information according to the physical address and the data generation algorithm.
[0051] For example, Figure 6 As shown, when the memory management unit executes the address mapping function self-test strategy, the user-mode program applies for a memory block of, for example, 4096 bytes in size through the memory mapping interface provided by the microkernel operating system, and the memory management unit returns the virtual address va_user and the corresponding physical address pa of the memory block through the memory mapping interface; then a prefabricated data generation algorithm is used to generate test data, such as generating 0-1024 unsigned data occupying 4 bytes; the test data is written into the applied memory block by accessing the virtual address va_user; and then the address mapping self-test information carrying the physical address pa, data algorithm and data length l en is sent to the kernel-mode program.
[0052] In some examples, in order to determine whether the address mapping function of the memory management unit fails, the present application also needs to verify the above self-test information through the memory state program. Therefore, the address mapping function self-test strategy is set in the present application. In the process of the memory management unit performing self-test according to the address mapping function self-test strategy, the memory state verification method corresponding to the self-test strategy is executed by the memory state program to perform self-test verification on the self-test information and obtain the self-test verification result, including: executing the memory state verification method through the memory state program to parse the self-test information and obtain the physical address and data generation algorithm carried in the self-test information; generating target test data according to the data generation algorithm, and obtaining the test data according to the physical address and the memory mapping interface; comparing the test data with the target test data to obtain the self-test verification result. Among them, if the test data is consistent with the target test data, the self-test verification result with consistent data is sent to the user state program, and if the test data is inconsistent with the target test data, the self-test verification result with inconsistent data is sent to the user state program.
[0053] Among them, if the self-test verification result indicates that the test data and the target test data are consistent, the user-state program determines that the address mapping function self-test result of the memory management unit is that the address mapping function self-test passed (self-test succeeded); if the self-test verification result indicates that the test data and the target test data are consistent, the user-state program determines that the address mapping function self-test result of the memory management unit is that the address mapping function self-test failed (self-test failed).
[0054] It can be understood that if during the process of the memory management unit performing the address mapping function self-test, the user-state program times out and does not receive the self-test verification result returned by the memory-state program (the user-state program starts timing after sending the self-test information to the memory-state program. If the timing reaches the preset timeout duration and the self-test verification result returned by the memory-state program is not received, it is determined that the self-test verification result returned by the memory-state program has not been received due to the timeout), the user-state program determines that the address mapping function self-test result of the memory management unit is that the address mapping function self-test has failed.
[0055] Exemplarily, during the process of the memory management unit performing self-test of the address mapping function, the kernel-state program receives the self-test message and parses it to obtain the physical address pa, the data generation algorithm and the data length l en; then the kernel-state program maps and obtains the virtual address va_kernel l of pa in the kernel state through the memory mapping interface; the kernel-state program uses va_kernel l to access and obtain the l en length data and generates target test data according to the data generation algorithm, and compares the target test data with the test data, such as comparing whether the read data is 0-1024 data; the kernel-state program collects the self-test verification results and sends the self-test verification results to the user-state program; after receiving the self-test verification results of the kernel-state program, the user-state program generates a successful or abnormal self-test result based on the results.
[0056] It can be understood that the address mapping page table is an important input parameter for address mapping of the memory management unit, which is generally stored in the memory. When there is an error in the input page table data of the MMU, the MMU will generate corresponding errors such as alignment errors, permission errors, conversion errors, address size errors, access attribute errors, etc., causing the central processing unit to fall into a corresponding abnormal interrupt. In order to determine whether the memory management unit can handle the above-mentioned fault, the present application also provides a self-generated fault self-checking strategy. When the memory management unit performs self-generated fault self-checking, the diagnostic identifier is written to a pre-set register through a user state program. The diagnostic identifier is used to trigger the abnormal interrupt of the memory management unit. When the MMU active fault self-checking diagnosis is performed, this step writes a diagnostic identifier to a specific general register through a user state program, and realizes the construction of the above-mentioned MMU address mapping page table to trigger the MMU fault to generate a corresponding processor abnormal interrupt.
[0057] Continuing with the above example, when the memory state program determines that the memory management unit has entered an abnormal interrupt, it performs abnormal recovery processing and generates diagnostic information to the user state program based on the abnormal recovery processing result, so that the user state program generates a fault self-check result based on the diagnostic information. Figure 7 As shown, the user-state program first generates a diagnostic identifier, and then writes the diagnostic identifier into a pre-set register, so that the memory management unit enters the MMU fault (triggering an active fault), and the processor abnormal interruption causes the microkernel operating system to enter the kernel-state interrupt processing function. The processing function identifies the identifier register to determine whether it is an active fault exception; when it is an active exception, the MMU fault interrupt processing is performed, mainly to implement the processor pointer (Program Counter, PC) calculation and stack recovery processing. Then the kernel-state program sends active fault diagnostic information to the user-state program; the user-state program receives the kernel-state active fault self-check diagnostic message, and the diagnostic information indicates that the processor pointer (Program Counter, PC) calculation and stack recovery are completed, then the fault self-check result of the memory management unit is determined to be a successful active fault self-check. If the user-state program receives the kernel-state active fault self-check diagnostic message, and the diagnostic information indicates that the processor pointer (Program Counter, PC) calculation and stack recovery fail, then the fault self-check result of the memory management unit is determined to be a failed active fault self-check.
[0058] Similarly, if during the process of the memory management unit performing autonomous fault self-test, the user-state program times out and does not receive the diagnostic information returned by the memory-state program (the user-state program starts timing after writing the diagnostic identifier. If the timing reaches the preset timeout duration and the diagnostic information returned by the memory-state program is not received, it is determined that the diagnostic information returned by the memory-state program has not been received due to the timeout), the user-state program determines that the result of the autonomous fault self-test of the memory management unit is that the address mapping function self-test has failed.
[0059] It can be understood that in order to avoid the situation where a fault exists in the memory management unit, which causes the stability of the microkernel operating system (or causes a fault in the microkernel operating system) when the self-test result fails (self-test fails), the present application sends the self-test verification result to the user state program, so that the user state program determines the self-test result of the memory management unit through the self-test verification result. The method also includes: when the self-test result of the memory management unit is a self-test failure, sending the self-test result to the upper-level application, so that the upper-level application performs a pre-set guided security control to avoid security accidents.
[0060] All the above optional technical solutions can be arbitrarily combined to form optional embodiments of the present application, which will not be described one by one here.
[0061] The following is an embodiment of the method of the present application. For details not disclosed in the embodiment of the method of the present application, please refer to the above-mentioned system embodiment of the present application.
[0062] This embodiment also provides a self-checking device of a memory management unit, such as Figure 8 As shown, the device comprises:
[0063] The policy module 801 is used to obtain a preset self-checking policy, which includes a user-mode self-checking method and a memory-mode verification method;
[0064] The self-check module 802 is used to execute the user-state self-check method in the self-check strategy through the user-state program to generate self-check information; execute the memory-state verification method corresponding to the self-check strategy through the memory-state program to perform self-check verification on the self-check information, obtain the self-check verification result, and send the self-check verification result to the user-state program, so that the user-state program determines the self-check result of the memory management unit through the self-check verification result.
[0065] In some examples, the self-check module 802 is further used to obtain a previously arranged self-check strategy; when the previously arranged self-check strategy is executed and the self-check result of the memory management unit is passed, the next self-check strategy is obtained.
[0066] In some examples, the self-test strategy includes a configuration self-test strategy; the self-test module 802 is also used to execute a user-state self-test method through a user-state program to read the configuration information of the register and generate self-test information based on the configuration information of the register; execute a memory-state verification method through a memory-state program to parse the self-test information and obtain the configuration information carried in the self-test information; obtain the saved target configuration information through the memory-state program, and compare the configuration information carried in the parsed self-test information with the target configuration information to obtain a self-test verification result.
[0067] In some examples, the self-test strategy includes an address mapping function self-test strategy, and the self-test module 802 is also used to execute a user-state self-test method through a user-state program to apply for a memory block from a memory mapping interface and obtain a virtual address and a physical address corresponding to the memory block; generate test data according to a data generation algorithm, write the test data to the memory block through a virtual address, and generate self-test information according to the physical address and the data generation algorithm; execute a memory-state verification method through a memory-state program to parse the self-test information and obtain the physical address and data generation algorithm carried in the self-test information; generate target test data according to the data generation algorithm, and obtain the test data according to the physical address and the memory mapping interface; compare the test data with the target test data to obtain a self-test verification result.
[0068] In some examples, the self-test module 802 is also used to write a diagnostic flag to a pre-set register through a user-state program, and the diagnostic flag is used to trigger an abnormal interrupt of the memory management unit; when the memory-state program determines that the memory management unit has entered an abnormal interrupt, an abnormal recovery process is performed, and diagnostic information is generated to the user-state program based on the abnormal recovery process result, so that the user-state program generates a fault self-test result based on the diagnostic information.
[0069] In some examples, the self-check module 802 is also used to send the self-check result to the upper-layer application when the self-check result of the memory management unit is a self-check failure, so that the upper-layer application performs a pre-set guided security control.
[0070] According to the technical solution provided by the embodiment of the present application, the device provided by the present embodiment obtains a pre-set self-test strategy, the self-test strategy includes a user-state self-test method and a memory-state verification method; executes the user-state self-test method in the self-test strategy through a user-state program to generate self-test information; executes the memory-state verification method corresponding to the self-test strategy through a memory-state program to perform self-test verification on the self-test information to obtain a self-test verification result, and sends the self-test verification result to the user-state program, so that the user-state program determines the self-test result of the memory management unit through the self-test verification result. The present application pre-sets a self-test strategy so that the memory management unit can generate self-test information through the user-state self-test method in the self-test strategy, and then verifies the self-test information through the memory-state verification method, thereby realizing self-test of the memory management unit, thereby avoiding the problem in the related art that the memory management unit cannot perform self-test, resulting in the inability to timely discover its own faults, thereby affecting the stability of the microkernel operating system.
[0071] Fig. 9 Schematic diagram of an electronic device 9 provided in an embodiment of the present application. Fig. 9 As shown, the electronic device 9 of this embodiment includes: a processor 901, a memory 902, and a computer program 903 stored in the memory 902 and executable on the processor 901. When the processor 901 executes the computer program 903, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 901 executes the computer program 903, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0072] The electronic device 9 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 9 may include, but is not limited to, a processor 901 and a memory 902. Those skilled in the art will appreciate that Fig. 9 The electronic device 9 is merely an example and does not limit the electronic device 9 , and may include more or less components than those shown in the figure, or different components.
[0073] The processor 901 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.
[0074] The memory 902 may be an internal storage unit of the electronic device 9, for example, a hard disk or memory of the electronic device 9. The memory 902 may also be an external storage device of the electronic device 9, for example, a plug-in hard disk, a smart memory card (Smart Med ia Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. equipped on the electronic device 9. The memory 902 may also include both an internal storage unit of the electronic device 9 and an external storage device. The memory 902 is used to store computer programs and other programs and data required by the electronic device.
[0075] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units.
[0076] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of regional requirements and patent practice. For example, in some areas, according to regional requirements and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0077] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A self-checking method for a memory management unit, characterized in that: The method comprises: Obtaining a preset self-check strategy, wherein the self-check strategy includes a user state self-check method and a memory state verification method; Executing the user-mode self-checking method in the self-checking strategy through a user-mode program to generate self-checking information; The memory state verification method corresponding to the self-test strategy is executed by the memory state program, the self-test information is self-tested and verified, a self-test verification result is obtained, and the self-test verification result is sent to the user state program, so that the user state program determines the self-test result of the memory management unit through the self-test verification result.
2. The method according to claim 1, characterized in that: The number of the self-check strategies is multiple, and obtaining the preset self-check strategies includes: Obtain the self-check strategy arranged in front; When the previously arranged self-check strategy is executed and the self-check result of the memory management unit is passed, the next self-check strategy is obtained.
3. The method according to claim 1, characterized in that The self-check strategy includes configuring a self-check strategy; Executing the user-mode self-checking method in the self-checking strategy through a user-mode program to generate self-checking information includes: Executing the user-state self-test method through the user-state program to read the configuration information of the register, and generating the self-test information according to the configuration information of the register; Executing the memory state verification method corresponding to the self-check strategy through the memory state program, performing self-check verification on the self-check information, and obtaining a self-check verification result, including: Executing the memory state verification method through the memory state program to parse the self-test information and obtain the configuration information carried in the self-test information; The stored target configuration information is obtained through the memory state program, and the configuration information carried in the self-test information obtained by parsing is compared with the target configuration information to obtain the self-test verification result.
4. The method according to claim 1, characterized in that: The self-check strategy includes an address mapping function self-check strategy, and the user-state self-check method in the self-check strategy is executed by a user-state program to generate self-check information, including: Executing the user-state self-checking method through the user-state program to apply for a memory block from a memory mapping interface and obtain a virtual address and a physical address corresponding to the memory block; Generate test data according to a data generation algorithm, write the test data into the memory block through the virtual address, and generate the self-test information according to the physical address and the data generation algorithm; Executing the memory state verification method corresponding to the self-check strategy through the memory state program, performing self-check verification on the self-check information, and obtaining a self-check verification result, including: Executing the memory state verification method through the memory state program to parse the self-test information and obtain the physical address and the data generation algorithm carried in the self-test information; Generate target test data according to the data generation algorithm, and obtain the test data according to the physical address and the memory mapping interface; The test data is compared with the target test data to obtain the self-test verification result.
5. The method according to claim 1, characterized in that After obtaining the preset self-check strategy, the method further includes: Writing a diagnostic flag into a preset register through the user state program, wherein the diagnostic flag is used to trigger an abnormal interrupt of the memory management unit; When the memory state program determines that the memory management unit enters an abnormal interrupt, an abnormal recovery process is performed, and diagnostic information is generated to the user state program based on the abnormal recovery process result, so that the user state program generates a fault self-check result based on the diagnostic information.
6. The method according to claim 5, characterized in that After sending the self-test verification result to the user state program so that the user state program determines the self-test result of the memory management unit through the self-test verification result, the method further includes: In the case where the self-check result of the memory management unit is a self-check failure, the self-check result is sent to an upper layer application, so that the upper layer application performs a preset guidance security control.
7. A self-checking device for a memory management unit, characterized in that: The device comprises: A strategy module, used to obtain a preset self-check strategy, wherein the self-check strategy includes a user state self-check method and a memory state verification method; A self-check module is used to execute the user-state self-check method in the self-check strategy through a user-state program to generate self-check information; execute the memory-state verification method corresponding to the self-check strategy through a memory-state program to perform self-check verification on the self-check information to obtain a self-check verification result, and send the self-check verification result to the user-state program, so that the user-state program determines the self-check result of the memory management unit through the self-check verification result.
8. The device according to claim 7, characterized in that The self-check module is also used to obtain the self-check strategy arranged in front; when the self-check strategy arranged in front is executed and the self-check result of the memory management unit is passed, the next self-check strategy is obtained.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Cited By
Memory management unit verification method and device, equipment and storage medium
CN122132187A