Memory operation methods, apparatus, computer equipment and readable storage media
By generating multi-bit trigger signals of a state machine and performing key matching verification, the problem of low security in traditional memory operations is solved, achieving higher security and tamper resistance.
Patent Information
- Application Number
- CN202411785814.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-06
- Publication Date
- 2026-11-17
- Estimated Expiration
- 2044-12-06
AI Technical Summary
Traditional memory operations lack effective security verification mechanisms, making them susceptible to accidental tampering and resulting in low security.
By generating a state machine with multiple trigger signals, parsing and processing them into multiple control signals, and performing key matching verification, the final control signal is sent to the target memory for operation only after the verification is successful.
It reduces the risk of malfunctions caused by interference with a single signal, prevents unauthorized or abnormal memory operations, improves the security of memory operations, and avoids accidental tampering with memory contents.
Smart Images

Figure CN119783172B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a memory operation method, apparatus, computer device, computer-readable storage medium, and computer program product. Background Technology
[0002] With the rapid development of computer technology, memory is increasingly widely used in various embedded systems. Memory plays a crucial role in storing critical data within the system. Therefore, how to perform memory operations safely has become an important research direction.
[0003] Traditional technologies typically erase or write memory through simple, direct control methods; however, this method lacks an effective security verification mechanism, making it susceptible to accidental tampering and resulting in low security for memory operations. Summary of the Invention
[0004] Therefore, it is necessary to provide a memory operation method, apparatus, computer device, computer-readable storage medium, and computer program product that can improve the security of memory operation in response to the above-mentioned technical problems.
[0005] Firstly, this application provides a memory operation method. The method includes:
[0006] In response to an operation instruction for the target memory, a multi-bit trigger signal for the state machine is generated; the operation instruction includes an erase instruction or a write instruction.
[0007] The state machine is used to analyze and process the multi-bit trigger signals to obtain multi-bit control signals for the target memory.
[0008] The multi-bit control signal is subjected to key matching verification processing to obtain the verification result of the multi-bit control signal;
[0009] If the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory; the target memory is used to perform an erase operation or a programmable operation according to the final control signal.
[0010] In one embodiment, the controller of the target memory accesses the default value of the address control pin of the target memory and selects a non-valid code region.
[0011] In one embodiment, the step of parsing the multi-bit trigger signals through the state machine to obtain multi-bit control signals for the target memory includes:
[0012] The multi-bit trigger signals are used as multi-bit input signals of the state machine;
[0013] The multi-bit input signal is input to the state machine for parsing and processing to obtain the multi-bit output signal output by the state machine.
[0014] Based on the multi-bit output signals, determine the multi-bit control signals for the target memory.
[0015] In one embodiment, the reset field of the logic corresponding to the erase or write operation of the target memory in the controller of the target memory is the same as the reset field in the target processor corresponding to the target memory.
[0016] In one embodiment, the boot information of the target processor corresponding to the target memory is stored in a read-only memory.
[0017] In one embodiment, the method further includes:
[0018] The key information of the target memory is redundantly backed up in multiple backup memories;
[0019] The key information backed up in the multiple backup storage devices is verified to obtain the verification results of the key information backed up in the multiple backup storage devices;
[0020] Based on the verification results, the correct information is selected from the key information backed up in the multiple backup storage devices.
[0021] In one embodiment, after performing key matching verification processing on the multi-bit control signal to obtain the verification result of the multi-bit control signal, the method further includes:
[0022] If the verification result indicates that the verification of the multi-bit control signal fails, a reporting message corresponding to the verification result is generated;
[0023] The reported information is reported to the target processor corresponding to the target memory.
[0024] In one embodiment, before generating a multi-bit trigger signal for the state machine in response to an operation instruction for the target memory, the method further includes:
[0025] If the operation instruction check passes and the operation address corresponding to the operation instruction is allowed to be operated, the operation instruction issued by the target processor corresponding to the target memory is received.
[0026] Secondly, this application also provides a memory operation apparatus. The apparatus includes:
[0027] The signal generation module is used to generate multi-bit trigger signals for the state machine in response to operation instructions for the target memory; the operation instructions include erase instructions or write instructions.
[0028] The signal parsing module is used to parse and process the multi-bit trigger signals through the state machine to obtain multi-bit control signals for the target memory;
[0029] The signal verification module is used to perform key matching verification processing on the multi-bit control signal to obtain the verification result of the multi-bit control signal;
[0030] The signal transmitting module is used to convert the multi-bit control signal into a final control signal and send the final control signal to the target memory when the verification result indicates that the multi-bit control signal has passed the verification; the target memory is used to perform an erase operation or a programmable operation according to the final control signal.
[0031] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to perform the following steps:
[0032] In response to an operation instruction for the target memory, a multi-bit trigger signal for the state machine is generated; the operation instruction includes an erase instruction or a write instruction.
[0033] The state machine is used to analyze and process the multi-bit trigger signals to obtain multi-bit control signals for the target memory.
[0034] The multi-bit control signal is subjected to key matching verification processing to obtain the verification result of the multi-bit control signal;
[0035] If the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory; the target memory is used to perform an erase operation or a programmable operation according to the final control signal.
[0036] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, performs the following steps:
[0037] In response to an operation instruction for the target memory, a multi-bit trigger signal for the state machine is generated; the operation instruction includes an erase instruction or a write instruction.
[0038] The state machine is used to analyze and process the multi-bit trigger signals to obtain multi-bit control signals for the target memory.
[0039] The multi-bit control signal is subjected to key matching verification processing to obtain the verification result of the multi-bit control signal;
[0040] If the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory; the target memory is used to perform an erase operation or a programmable operation according to the final control signal.
[0041] Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, performs the following steps:
[0042] In response to an operation instruction for the target memory, a multi-bit trigger signal for the state machine is generated; the operation instruction includes an erase instruction or a write instruction.
[0043] The state machine is used to analyze and process the multi-bit trigger signals to obtain multi-bit control signals for the target memory.
[0044] The multi-bit control signal is subjected to key matching verification processing to obtain the verification result of the multi-bit control signal;
[0045] If the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory; the target memory is used to perform an erase operation or a programmable operation according to the final control signal.
[0046] The aforementioned memory operation method, apparatus, computer device, computer-readable storage medium, and computer program product, in response to an operation instruction for a target memory, generate a multi-bit trigger signal of a state machine; the operation instruction includes an erase instruction or a write instruction; the state machine parses the multi-bit trigger signal to obtain a multi-bit control signal for the target memory; the multi-bit control signal undergoes key matching verification processing to obtain a verification result; if the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory; the target memory is used to perform an erase operation or a write operation according to the final control signal. This scheme, by converting memory operation instructions into multi-bit trigger signals and parsing them through a state machine to obtain multi-bit control signals, helps reduce the risk of memory malfunction due to interference with a single signal; simultaneously, by performing key matching verification processing on the multi-bit control signals and only allowing the control signal to be sent to the target memory if the verification is successful, it helps prevent unauthorized or abnormal memory operations; thus, it helps improve the security of memory operations and avoids accidental tampering with memory contents. Attached Figure Description
[0047] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0048] Figure 1 This is a flowchart illustrating a memory operation method in one embodiment;
[0049] Figure 2 This is a flowchart illustrating a flash memory erase or burn operation in one embodiment;
[0050] Figure 3 This is a flowchart illustrating enhanced flash memory anti-tampering control in one embodiment;
[0051] Figure 4 This is a schematic diagram of the key matching logic structure between the flash memory controller and the flash memory device in one embodiment;
[0052] Figure 5 This is a schematic diagram of the multi-bit trigger signal generation structure of a flash memory controller in one embodiment;
[0053] Figure 6 This is a structural block diagram of a memory operation device in one embodiment;
[0054] Figure 7 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0056] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0057] In one exemplary embodiment, such as Figure 1 As shown, a memory operation method is provided. This embodiment illustrates the application of this method to a terminal. It is understood that this method can also be applied to a server, and to a system including both a terminal and a server, and is implemented through interaction between the terminal and the server. The terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, etc.; the server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. In this embodiment, the method includes the following steps:
[0058] Step S101: In response to an operation instruction for the target memory, a multi-bit trigger signal for the state machine is generated; the operation instruction includes an erase instruction or a write instruction.
[0059] Step S102: The multi-bit trigger signals are parsed and processed by the state machine to obtain the multi-bit control signals for the target memory.
[0060] Step S103: Perform key matching verification processing on the multi-bit control signals to obtain the verification results of the multi-bit control signals.
[0061] In step S104, if the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory; the target memory is used to perform an erase operation or a burn operation according to the final control signal.
[0062] Among them, the memory operation method can be a series of steps to control and access the memory, such as a control method for erasing or writing Flash memory.
[0063] The target memory can be a storage device that needs to be operated, such as a flash device.
[0064] The operation instructions can be commands used to control the target memory to perform specific operations, such as erase instructions (ERASE) or program instructions (PROGRAM) issued by the CPU.
[0065] The state machine can be a finite state automaton used to control the erase / burn operation of the target memory.
[0066] Among them, the multi-bit trigger signal can be multiple binary signals used to start the state machine, such as trigger[0], trigger[1], trigger[2], trigger[3], etc., where trigger represents trigger.
[0067] Among them, the multi-bit control signals can be multiple binary signals output by the state machine to control the target memory, such as ERASE[0:3] or PROGRAM[0:3] multi-bit encoded signals.
[0068] Among them, key matching verification processing can be a process of verifying the security of control signals, such as key verification using an 8-bit key (e.g., 8'hAA).
[0069] The verification result can be the output of the key matching verification process, such as status information indicating whether the keys match.
[0070] The final control signal can be obtained by combining multiple control signals through combinational logic operations.
[0071] The erase operation can be the process of clearing data from the target memory, such as a Flash memory content clearing operation triggered by the ERASE signal.
[0072] The programming operation can be the process of writing data into the target memory, such as a Flash memory data writing operation triggered by the PROGRAM (programming) signal.
[0073] Optionally, after receiving an operation instruction for the target memory (FlashDevice), the Flash Controller decodes the operation instruction into a 4-bit trigger signal [0:3]. The trigger signal [0:3] is used to start the erase / write state machine. The erase / write state machine generates a 4-bit erase control signal ERASE [0:3] or a 4-bit write control signal PROGRAM [0:3] based on the value of the trigger signal [0:3]. The erase control signal ERASE [0:3] or the write control signal PROGRAM [0:3] is verified by a key matching verification circuit. After successful verification, the erase control signal ERASE [0:3] or the write control signal PROGRAM [0:3] is subjected to combinational logic operations to obtain the final control signal for the target memory. The final control signal is then sent to the corresponding pin of the target memory (Flash Device), thereby triggering the target memory (Flash Device) to perform an erase operation or a write operation.
[0074] In the aforementioned memory operation method, in response to an operation instruction for the target memory, a multi-bit trigger signal of a state machine is generated. The operation instruction includes an erase instruction or a write instruction. The state machine parses the multi-bit trigger signal to obtain a multi-bit control signal for the target memory. Key matching verification is performed on the multi-bit control signal to obtain a verification result. If the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory. The target memory is used to perform an erase or write operation based on the final control signal. This scheme, by converting memory operation instructions into multi-bit trigger signals and parsing them through a state machine to obtain multi-bit control signals, helps reduce the risk of memory malfunctions caused by interference with a single signal. Simultaneously, by performing key matching verification on the multi-bit control signal and only allowing the control signal to be sent to the target memory if verification is successful, it helps prevent unauthorized or abnormal memory operations. Therefore, it improves the security of memory operations and prevents accidental tampering of memory contents.
[0075] In one exemplary embodiment, the controller of the target memory accesses the default value of the address control pin of the target memory and selects a non-valid code region.
[0076] The controller can be a control circuit used to control the target memory to perform data read and write operations, such as a flash controller.
[0077] The address control pin can be the input port of the target memory used to receive address information, such as the address input pin of a flash device.
[0078] The non-valid code region can be a storage space in the target memory that does not store valid program code, such as the storage region at address 32'hFFFF_FFFF.
[0079] The default value can be a preset value when the system is not specifically configured, such as the initial value automatically set by the address control pin after the system is reset.
[0080] Optionally, during the initialization phase, the Flash Controller sets the default value of the address control pins of the target memory (Flash Device) to the address value of the invalid code region. This ensures that when the control signal of the Flash Controller is subjected to external interference or an abnormal flip occurs, even if the erase or write pins of the target memory (Flash Device) are abnormally triggered, the target memory (Flash Device) will only operate on the invalid code region, thereby preventing the valid program code stored in the target memory (Flash Device) from being accidentally tampered with.
[0081] The technical solution provided in this embodiment sets the default value of the address control pin of the target memory to the non-valid code area. This is beneficial because when the erase or write pin of the target memory is abnormally triggered due to external interference, the target memory will only operate on the non-valid code area. This helps to prevent the valid program code stored in the target memory from being accidentally tampered with, thereby improving the security of memory operation.
[0082] In an exemplary embodiment, a state machine is used to parse and process multiple trigger signals to obtain multiple control signals for the target memory. Specifically, this includes: using the multiple trigger signals as multiple input signals of the state machine; inputting the multiple input signals into the state machine for parsing and processing to obtain multiple output signals from the state machine; and determining the multiple control signals for the target memory based on the multiple output signals.
[0083] Among them, the multi-bit input signal can be multiple binary signals received by the state machine to trigger the operation of the state machine, such as trigger[0], trigger[1], trigger[2], trigger[3] and other trigger signals received by the state machine.
[0084] Among them, the multi-bit output signal can be multiple binary signals output by the state machine after processing, used to control the target memory. For example, it can be multi-bit encoded signals such as ERASE[0], ERASE[1], ERASE[2], ERASE[3] or PROGRAM[0], PROGRAM[1], PROGRAM[2], PROGRAM[3] output by the state machine.
[0085] Optionally, the Flash Controller uses the multi-bit trigger signal generated by the Command Decode module as the multi-bit input signal of the erase / program FSM. After receiving the multi-bit input signal, the erase / program FSM performs timing processing and state transitions on the multi-bit input signal through multiple internal flip-flops to generate a multi-bit output signal. Based on the multi-bit output signal output by the erase / program FSM, the Flash Controller processes it through combinational logic to finally generate a multi-bit control signal for the target memory (Flash Device).
[0086] The technical solution provided in this embodiment expands a single trigger signal into a multi-bit trigger signal and uses a state machine to parse and process the multi-bit trigger signal before converting it into a multi-bit control signal. This multi-conversion mechanism increases the complexity of the trigger signal and control signal, reduces the probability of abnormal switching of the signal when it is disturbed, and thus helps to prevent the target memory from being accidentally triggered to perform erase or burn operations due to signal abnormalities.
[0087] In an exemplary embodiment, the reset domain of the logic corresponding to the erase or write operation of the target memory in the controller of the target memory is the same as the reset domain in the target processor corresponding to the target memory.
[0088] The logic can be the circuit part in the Flash controller used to control the target memory to perform erase or program operations. For example, it can be the control circuit in the Flash controller responsible for generating the ERASE (erase) signal and the PROGRAM (program) signal.
[0089] The reset domain can be the signal range within which a module or circuit in the chip is set to its initial state when it receives a reset signal. For example, it can be the signal coverage range within which the relevant control logic is kept in a reset state when the chip detects an abnormality.
[0090] The target processor can be a central processing unit that interacts with the target memory, such as a CPU (central processing unit) that sends erase or write commands to the Flash controller.
[0091] Optionally, the logic circuit in the Flash Controller responsible for controlling the erase and write operations of the target memory (FlashDevice) uses the same reset signal as the target processor (CPU) for control. When the chip detects a watchdog timeout, clock anomaly, or other abnormal conditions, the control logic for the erase and write operations in the Flash Controller enters a reset state simultaneously with the target processor (CPU). However, the logic circuit in the Flash Controller responsible for loading calibration information still maintains an independent reset domain and is reset only when the chip is powered on or when a low power supply voltage is detected.
[0092] The technical solution provided in this embodiment sets the reset domain of the logic circuit responsible for erasure and programming operations in the controller of the target memory to be the same as the reset domain of the target processor. This is beneficial for synchronously resetting the erasure / programming operation logic in the target processor and the controller of the target memory when the chip detects an anomaly, and timely terminating any memory operations that may be being executed. This helps to prevent accidental tampering with the data in the target memory in the event of a chip malfunction.
[0093] In one exemplary embodiment, the boot information of the target processor corresponding to the target memory is stored in a read-only memory.
[0094] The startup information can be the program code and data that the target processor (CPU) executes first after power-on or reset, such as a startup program used to check the integrity of subsequent code execution.
[0095] Read-only memory can be a type of memory whose contents cannot be modified after manufacturing, such as ROM (Read-Only Memory). Its characteristic is that the stored contents cannot be erased or rewritten, which can ensure the security of the boot program.
[0096] Optionally, after the chip is powered on or reset, the Flash Controller first reads the boot program of the target processor (CPU) from the read-only memory (ROM). Since the contents of the read-only memory (ROM) cannot be modified after manufacturing, the integrity and security of the boot program can be ensured. After the target processor (CPU) finishes executing the boot program, the boot program will perform an integrity check on the subsequent executable code stored in the target memory (Flash Device). Only after the verification is passed will the subsequent code be executed.
[0097] The technical solution provided in this embodiment, by storing the boot information of the target processor in a read-only memory, helps to prevent the boot information from being abnormally erased or tampered with, and ensures that the target processor can execute the correct boot program every time it is powered on or reset, thereby improving the boot reliability and operational security of the system.
[0098] In an exemplary embodiment, the method further includes: performing redundant backup processing on the key information of the target storage in multiple backup storages; performing verification processing on the key information backed up in the multiple backup storages to obtain verification results of the key information backed up in the multiple backup storages; and selecting correct information from the key information backed up in the multiple backup storages based on the verification results.
[0099] Among them, critical information can be important data that needs special protection and is stored in the target memory, such as system configuration information, user data, or critical program code.
[0100] The backup storage device can be an independent storage device used to store copies of critical information, such as a Flash Device that is physically isolated from the target storage device.
[0101] Redundancy backup processing can be a process of repeatedly storing the same critical information in two or more different backup storage devices. For example, it can be storing the critical information in specific physical spaces of two different Flash Devices.
[0102] The verification process can be a process of verifying the correctness of key information stored in the backup storage, such as by using ECC (Error Correction Code) or by using a voting mechanism.
[0103] The verification result can be the result of determining the correctness of key information obtained through verification processing, such as the status of ECC (Error Correction Code) verification passing or failing.
[0104] Among them, the correct information can be key information that has been verified and confirmed not to have been tampered with. For example, it can be data verified by ECC (Error Correction Code) in two backups, or data selected by a voting mechanism in multiple backups.
[0105] Optionally, the Flash Controller stores critical information from the target flash device in multiple different backup memories for redundant backup. When critical information needs to be read, the Flash Controller reads all the backed-up critical information from the multiple backup memories simultaneously and performs ECC (Error Check Code) verification on this backup information. If there are two backups, the Flash Controller uses ECC verification to determine which data is correct. If there are more than two backups, the Flash Controller uses a voting mechanism to select the correct information.
[0106] The technical solution provided in this embodiment performs redundant backup of the key information of the target memory in multiple backup memories and performs verification processing on the backup key information. This helps to reduce the probability of key information being tampered with at the same time and to detect tampered data in a timely manner. This is beneficial to obtaining the correct key information even if some backup data is tampered with, thus ensuring the integrity and availability of the system's key data.
[0107] In an exemplary embodiment, after performing key matching verification processing on the multi-bit control signals to obtain the verification result of the multi-bit control signals, the following steps are also included: if the verification result indicates that the verification of the multi-bit control signals fails, generating reporting information corresponding to the verification result; and reporting the reporting information to the target processor corresponding to the target memory.
[0108] The reported information can be warnings or error messages generated when abnormal operations are detected. For example, it can be Flash operation exception information generated when key verification fails, which is used to notify the target processor (CPU) of a potential illegal access attempt.
[0109] Optionally, after receiving an erase or write command from the target processor (CPU), the Flash Controller performs key matching verification on multiple control signals. When the Flash Controller detects that the key matching verification result of the multiple control signals fails, the Flash Controller immediately terminates the current erase or write operation, generates a report containing the reason for the verification failure, the time of the verification failure, and the status of the relevant control signals, and sends the report to the target processor (CPU) through the system bus, so that the target processor (CPU) can be aware of the abnormal status of the Flash Controller in a timely manner.
[0110] The technical solution provided in this embodiment generates and reports information to the target processor when the verification of multiple control signals fails. This helps to promptly detect illegal access or abnormal operation that may be suffered by the Flash memory, thereby enabling the system to quickly perceive potential data tampering risks and take corresponding protective measures, thus improving the security of memory data.
[0111] In an exemplary embodiment, before generating a multi-bit trigger signal for the state machine in response to an operation instruction for the target memory, the method further includes: receiving an operation instruction issued by the target processor corresponding to the target memory if the operation instruction passes the check and the operation address corresponding to the operation instruction is allowed to be operated.
[0112] The operation address can be the address information of the storage area to be operated in the target memory (Flash Device), such as a non-valid code area address (32'hFFFF_FFFF) or a valid code area address. The Flash Controller needs to determine whether the address is allowed to be erased or burned.
[0113] Optionally, before receiving the operation instruction issued by the target processor (CPU), the Flash Controller first performs a validity check on the operation instruction (this check can be performed by the CPU). This includes checking whether the type of the operation instruction is a valid erase command (ERASE) or programm command (PROGRAM), and checking whether the operation address corresponding to the operation instruction is located in a valid code region that can be operated. Only if the operation instruction passes the check and the operation address corresponding to the operation instruction is allowed to be operated will the Flash Controller receive the operation instruction and further generate a multi-bit trigger signal for starting the erase / programm control state machine.
[0114] The technical solution provided in this embodiment performs a double check on the operation instructions and operation address before receiving the operation instructions issued by the target processor. This helps to filter out illegal operation instructions before the instructions are executed, thereby preventing critical data in the Flash memory from being abnormally erased or rewritten and improving the security of memory operations.
[0115] The following application example illustrates the memory operation method provided in this application. This application example demonstrates the application of this method to a Flash Controller.
[0116] Related technologies:
[0117] The flash memory inside a chip can be accidentally tampered with under certain circumstances, including erase and rewrite operations. This tampering is usually related to factors such as power instability, programming flaws, or external interference. For example, when the power supply voltage fluctuates frequently around the chip's operating threshold, it may cause errors in the chip's logic circuitry, resulting in incorrect execution of erase or write instructions for the flash memory. When the program fails to properly manage flash memory operations, such as a sudden power outage during erase or write operations, it may cause abnormal states in the flash memory data. When the chip is subjected to external interference, the chip's internal registers may flip abnormally. If the abnormal flip signal happens to be the erase or write control signal for the flash device, it will lead to data tampering in the flash memory.
[0118] Tampering with the flash memory data inside a chip can lead to a variety of serious consequences, including but not limited to the following:
[0119] Data loss: Data in the flash memory storage area has been tampered with, including important system configuration information, user data, operating system or application code, etc.
[0120] System crash: If the system startup code or critical drivers are tampered with, it may cause changes to the program's running logic, making the entire system unable to start or run normally;
[0121] Security risks: If the security keys or encrypted data stored in flash memory are tampered with, the system's security may be compromised.
[0122] Reliability issues: If the flash memory is tampered with abnormally, causing system malfunctions, it will seriously affect the reliability of the product.
[0123] Therefore, ensuring the security and integrity of data in the internal flash memory of a chip is crucial for the stable operation of the device, especially in automotive chips. Effective security measures and technical means are needed to prevent data tampering.
[0124] In related technologies, the following technical means can be used to prevent the embedded flash memory of the chip from being abnormally erased or burned:
[0125] Power monitoring mechanism (means 1): When the power supply voltage is detected to be lower than the design voltage threshold by the power monitoring circuit, the chip is reset to prevent voltage instability from causing abnormal operation of the chip's internal logic.
[0126] Erasure / write protection mechanism (means 2): When the processor (CPU) is running abnormally, the erase / write program may be executed by mistake. Therefore, a protection mechanism is added to prevent accidental operation through multiple checks.
[0127] Flash memory error detection (method 3): Use error correction codes (ECC) or parity checks to detect and correct read and write errors in flash memory;
[0128] Watchdog / clock anomaly detection (method 4): When the watchdog timeout occurs or an abnormal chip clock is detected, a reset request is triggered to reset the processor (CPU) to prevent the processor from executing an erroneous program that could cause abnormal chip operation.
[0129] The above measures can reduce the probability of the chip's embedded Flash being abnormally erased / rewritten.
[0130] Reference for performing flash memory erase or write operations Figure 2 . Figure 2 The diagram illustrates the process of performing a flash memory erase / write operation, specifically including the following steps: First, Step 1: The CPU (Central Processing Unit) issues an erase / write command, followed by a key matching check. If the key matching result is negative, the process terminates; if the key matching result is positive, it continues to check if the address to be erased / written is allowed. If the address is allowed, the process terminates; if the address is allowed, it proceeds to Step 2: The Flash controller performs the erase / write operation, and then to Step 3: The relevant pins for the Flash device erase / write take effect. Afterwards, it checks if the erase / write is complete. If the completion check result is negative, it returns to Step 2; if the completion check result is positive, the process ends, and a reporting logic is sent to the CPU. The diagram also includes the reporting logic module and the reset signal control lines, indicated by dashed lines, which include two reset signal sources: watchdog / clock error reset requests and low voltage detection.
[0131] However, the above-mentioned technical methods still have the following technical defects:
[0132] Method 1: When the power supply voltage fluctuates repeatedly around the chip's critical operating voltage threshold, the reset circuit may fail to respond to voltage anomalies in a timely manner. In this case, if the chip's logic circuit malfunctions, the failure to reset promptly may lead to abnormal operations on the flash memory.
[0133] Method 2: When the processor malfunctions, the relevant erase / write protection mechanism may be mistakenly locked. Furthermore, unstable or interfered power supplies to the chip may directly affect the logic circuitry following the protection mechanism, thus bypassing the flash memory's protection mechanism.
[0134] Method 3: The storage error detection mechanism can only detect or repair partial bit errors. Once the flash memory is completely erased, the system will not be able to resume normal operation.
[0135] Method 4: Watchdog timeout and clock anomaly detection require a certain response time. Before the reset request takes effect, the processor may have already incorrectly executed flash erase and write commands. Because the flash controller needs to load chip calibration information before the processor starts, the reset range of the flash controller is smaller than that of the processor. The reset request can only reset the processor and not the flash controller. Therefore, the incorrectly triggered flash erase / write operation will still be executed.
[0136] To protect the security and integrity of data stored in flash memory, this application example proposes several enhancement technologies based on relevant technologies, providing protection at both the flash controller and system-on-chip (SoC) levels.
[0137] Figure 3An enhanced flash memory anti-tampering control process is demonstrated, specifically including the following steps and modules: First, Step 1: The CPU (Central Processing Unit) issues an erase / write command, followed by a key matching check. If the key matching result is negative, the process terminates; if the key matching result is positive, it continues to check if the address to be erased / written is allowed to be operated on. If the address is allowed to be operated on, the process terminates; if the address is allowed to be operated on, it proceeds to Step 2: The Flash controller performs the erase / write operation. It then checks the key matching of the relevant pins for the Flash device erase / write operation. If the pin key matching result is negative, the process terminates; if the pin key matching result is positive, it proceeds to Step 3: The relevant pins for the Flash device erase / write operation take effect. Afterwards, it checks if the erase / write operation is complete. If the completion check result is negative, it returns to Step 2; if the completion check result is positive, the process ends and the reporting logic is updated. The diagram also includes a reporting logic module, a secure storage mechanism module for the chip's boot code, and reset signal control lines indicated by dashed lines. These include two reset signal sources: a watchdog / clock anomaly reset request and a low-voltage detection signal. Enhanced protection mechanisms are referenced below. Figure 3 The content within the dashed box.
[0138] Specifically, the enhanced protection measures for the flash memory controller include:
[0139] The default values for the address control pins of the flash controller accessing the flash device are set in the non-valid code region;
[0140] The signals generated by the flash memory controller to control the erase / program operation of the flash memory device (ERASE / PROGRAM) can only be sent to the flash memory device after being verified by the key.
[0141] The key input / output signals of the flash memory controller's state machine for controlling the erasure / writing of flash memory devices are designed with multiple bits.
[0142] Enhanced protection measures at the system-on-chip level include:
[0143] The reset domain of the logic involved in erasing / writing flash memory devices in the flash memory controller module is the same as the reset domain of the processor (CPU). Specifically, when the chip detects an anomaly, it keeps the critical control logic in a reset state to ensure that this part of the logic will not execute abnormally.
[0144] Special protection is provided for the flash memory space storing critical program information:
[0145] a) Use read-only memory (ROM) for storage;
[0146] b) Use a backup storage mechanism.
[0147] The specific details are as follows:
[0148] The enhanced protection measures for the flash memory controller specifically include:
[0149] The default value of the address control pins for the flash memory controller to access the flash memory device is set in a non-valid code region (e.g., 32'hFFFF_FFFF). This ensures that even if the erase / write pins of the flash memory device are abnormally pulled high due to interference, the valid code region will not be erased or rewritten.
[0150] The signals generated by the flash memory controller to control the erase / write operations of the flash memory device must be verified by a key before they can be sent to the flash memory device.
[0151] a) Ensure that the contents of the flash memory device are not tampered with, as long as the keys do not match, in the event of abnormal processor operation or abnormal flipping of the erase / write signal output by the flash controller due to interference.
[0152] b) Implement key protection at the location closest to the flash memory device to prevent erroneous operations on the flash memory even if there are problems with the previous control logic.
[0153] For example, an 8-bit key (8'hAA) can be used for protection, see reference. Figure 4 . Figure 4 A key matching logic structure between a flash controller and a flash device is shown, comprising the following modules and signals: the flash controller is located at the top left, the flash device at the top right, and the key matching logic module is located at the bottom left. The flash controller is connected to the key matching logic, which is connected to the flash device. The key matching logic comprises eight flip-flop units, which are used to process eight-bit key signals: key[7], key[6], key[5], key[4], key[3], key[2], key[1], and key[0]. Each flip-flop unit has a D input (data input) and a Q output (data output), and also includes clock and reset control signal inputs. The operation signals between the flash controller and the flash device include erase and write control signals. An AND operation logic gate can be located at the output of the key matching logic to generate the final control signal output.
[0154] The start trigger signal and control signal of the erase / write state machine of the flash memory controller are both designed with multi-bit encoding. In this way, when subjected to interference, abnormal toggling of the trigger signal will not easily start the erase / write control state machine, and abnormal toggling of the control signal will not easily cause the erase / write pin signal of the flash memory device to go high.
[0155] refer to Figure 5 , Figure 5 A multi-bit trigger signal generation structure for a flash memory controller is shown, comprising the following modules and signals from left to right: First is the Flash Controller module, which includes a command decoding unit and an erase / write state machine module; below is the key matching logic module; and on the far right is the Flash Device module. Specific signal connections include: The trigger signal section uses four flip-flop (DFF) units to process trigger[3], trigger[2], trigger[1], and trigger[0] signals respectively, which are then processed by AND logic gates to generate the trigger signal. The erase signal section uses four flip-flop (DFF) units to process erase[3], erase[2], erase[1], and erase[0] signals respectively, which are then processed by AND logic gates to generate the erase signal. The write signal section also uses four flip-flop (DFF) units to process write[3], write[2], write[1], and write[0] signals respectively, which are then processed by AND logic gates to generate the write signal.
[0156] The enhanced protection measures at the system-on-chip level specifically include:
[0157] The reset domain of the logic involved in erasing / writing flash memory devices in the flash memory controller module is the same as the processor's reset domain. This ensures that when the chip detects an anomaly, it can promptly terminate any erasing / writing operations that the flash memory controller may be performing and maintain the relevant control logic in its default state. The calibration information loading logic in the flash memory controller is still reset only when the chip is powered on or when a low power supply voltage is detected.
[0158] Special protection measures are taken for the flash memory space storing critical program information:
[0159] a) The processor's boot program is stored in read-only memory (ROM). The boot program checks the integrity of subsequent executable code before execution. Since ROM cannot be erased, the security of the boot code is guaranteed. The normal boot program can be executed after the processor is reset. If flash memory tampering is detected, the system can also generate and report an alarm.
[0160] b) Redundant backups of critical information areas are performed across multiple different flash memory devices, with error correction code (ECC) verification during reads. Since the likelihood of simultaneous abnormal tampering with specific physical spaces on different flash memory devices is low, redundancy mechanisms can protect the integrity of information.
[0161] When two redundant backups are used, the information in the flash memory is verified by error correction codes, and the data that passes the verification is considered to be correct data.
[0162] When using multiple (more than two) redundant backups, the correct data can be selected through a voting mechanism.
[0163] The technical solution provided in this application example solves the problem of the stored content being tampered with when the embedded Flash memory in the chip is corrupted due to program crashes or interference causing possible chip logic abnormalities. This improves the security and reliability of the system and enhances the security of memory operations.
[0164] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.
[0165] Based on the same inventive concept, this application also provides a memory operation apparatus for implementing the memory operation method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more memory operation apparatus embodiments provided below can be found in the limitations of the memory operation method described above, and will not be repeated here.
[0166] In one exemplary embodiment, such as Figure 6 As shown, a memory operation device 600 is provided, which may include:
[0167] The signal generation module 601 is used to generate a multi-bit trigger signal of the state machine in response to an operation instruction for the target memory; the operation instruction includes an erase instruction or a write instruction.
[0168] The signal parsing module 602 is used to parse and process multi-bit trigger signals through a state machine to obtain multi-bit control signals for the target memory;
[0169] The signal verification module 603 is used to perform key matching verification processing on multi-bit control signals to obtain the verification result of the multi-bit control signals;
[0170] The signal transmission module 604 is used to convert the multi-bit control signal into a final control signal when the verification result indicates that the multi-bit control signal has been verified, and to send the final control signal to the target memory; the target memory is used to perform an erase operation or a burn operation according to the final control signal.
[0171] In one exemplary embodiment, the controller of the target memory accesses the default value of the address control pin of the target memory and selects a non-valid code region.
[0172] In an exemplary embodiment, the signal parsing module 602 is further configured to use the multi-bit trigger signal as the multi-bit input signal of the state machine; input the multi-bit input signal to the state machine for parsing processing to obtain the multi-bit output signal of the state machine; and determine the multi-bit control signal for the target memory based on the multi-bit output signal.
[0173] In an exemplary embodiment, the reset domain of the logic corresponding to the erase or write operation of the target memory in the controller of the target memory is the same as the reset domain in the target processor corresponding to the target memory.
[0174] In one exemplary embodiment, the boot information of the target processor corresponding to the target memory is stored in a read-only memory.
[0175] In an exemplary embodiment, the device 600 further includes: an information processing module, configured to perform redundant backup processing on key information of the target memory in multiple backup memories; perform verification processing on the key information backed up in the multiple backup memories to obtain verification results of the key information backed up in the multiple backup memories; and select correct information from the key information backed up in the multiple backup memories based on the verification results.
[0176] In an exemplary embodiment, the device 600 further includes: an information reporting module, configured to generate reporting information corresponding to the verification result when the verification result indicates that the verification of multiple control signals fails; and to report the reporting information to the target processor corresponding to the target memory.
[0177] In an exemplary embodiment, the device 600 further includes an instruction receiving module, configured to receive an operation instruction issued by the target processor corresponding to the target memory when the operation instruction check passes and the operation address corresponding to the operation instruction allows to be operated.
[0178] Each module in the aforementioned memory operation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0179] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, input / output interface, communication interface, display unit, and input device. The processor, memory, and input / output interface are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interface. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input / output interface is used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a memory operation method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0180] Those skilled in the art will understand that Figure 7 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0181] In one exemplary embodiment, a computer device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps in the above-described method embodiments.
[0182] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the steps in the above-described method embodiments.
[0183] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps in the above-described method embodiments.
[0184] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0185] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0186] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. A memory operation method, characterized in that, The method includes: In response to an operation instruction for the target memory, a multi-bit trigger signal for the state machine is generated; the operation instruction includes an erase instruction or a write instruction; wherein, the controller of the target memory sets the default value of the address control pin of the target memory to the address value of a non-valid code region; the non-valid code region is the storage space in the target memory that does not store valid program code; The state machine is used to analyze and process the multi-bit trigger signals to obtain multi-bit control signals for the target memory; the multi-bit trigger signals are used as multi-bit input signals for the state machine; the multi-bit input signals are input to the state machine for analysis and processing to obtain multi-bit output signals from the state machine; and the multi-bit control signals for the target memory are determined based on the multi-bit output signals. The multi-bit control signal is subjected to key matching verification processing to obtain the verification result of the multi-bit control signal; If the verification result indicates that the multi-bit control signal has passed verification, the multi-bit control signal is converted into a final control signal and sent to the target memory; the target memory is used to perform an erase operation or a programmable operation according to the final control signal; the reset field of the logic corresponding to the erase operation or programmable operation of the target memory in the controller of the target memory is the same as the reset field in the target processor corresponding to the target memory.
2. The method according to claim 1, characterized in that, The controller is a control circuit used to control the target memory to perform data read and write operations, and the address control pin is an input port of the target memory used to receive address information.
3. The method according to claim 1, characterized in that, The boot information of the target processor corresponding to the target memory is stored in a read-only memory.
4. The method according to claim 1, characterized in that, The method further includes: The key information of the target memory is redundantly backed up in multiple backup memories; The key information backed up in the multiple backup storage devices is verified to obtain the verification results of the key information backed up in the multiple backup storage devices; Based on the verification results, the correct information is selected from the key information backed up in the multiple backup storage devices.
5. The method according to claim 1, characterized in that, After performing key matching verification processing on the multi-bit control signals to obtain the verification result of the multi-bit control signals, the method further includes: If the verification result indicates that the verification of the multi-bit control signal fails, a reporting message corresponding to the verification result is generated; The reported information is reported to the target processor corresponding to the target memory.
6. The method according to any one of claims 1 to 5, characterized in that, Before generating the multi-bit trigger signal of the state machine in response to an operation instruction for the target memory, the process also includes: If the operation instruction check passes and the operation address corresponding to the operation instruction is allowed to be operated, the operation instruction issued by the target processor corresponding to the target memory is received.
7. A memory operation device, characterized in that, The device includes: A signal generation module is used to generate multi-bit trigger signals for a state machine in response to an operation instruction for the target memory; the operation instruction includes an erase instruction or a write instruction; wherein, the controller of the target memory sets the default value of the address control pin of the target memory to the address value of a non-valid code region; the non-valid code region is the storage space in the target memory that does not store valid program code; The signal parsing module is used to parse and process the multi-bit trigger signals through the state machine to obtain multi-bit control signals for the target memory; use the multi-bit trigger signals as multi-bit input signals of the state machine; input the multi-bit input signals to the state machine for parsing and processing to obtain multi-bit output signals output by the state machine; and determine the multi-bit control signals for the target memory based on the multi-bit output signals. The signal verification module is used to perform key matching verification processing on the multi-bit control signal to obtain the verification result of the multi-bit control signal; A signal transmission module is used to convert the multi-bit control signal into a final control signal and send the final control signal to the target memory when the verification result indicates that the multi-bit control signal has passed verification; the target memory is used to perform an erase operation or a programmable operation according to the final control signal; the reset field of the logic corresponding to the erase operation or programmable operation of the target memory in the controller of the target memory is the same as the reset field in the target processor corresponding to the target memory.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
System and method for verification of a secure erase operation on a storage device
CN110045919A
FPGA program upgrading method
CN117850857A
