Data verification method, processor and electronic device

By setting up a dedicated cache in the processor to back up data and performing integrity verification, the problem of data tampering caused by the vulnerability of memory and off-chip bus to attacks is solved, and secure data detection is achieved.

CN117331741BActive Publication Date: 2026-11-27LOONGSON TECH CORP
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311309894.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-11-25
Publication Date
2026-11-27
Estimated Expiration
2040-11-25

AI Technical Summary

Technical Problem

Computer system memory and off-chip buses are vulnerable to attacks, leading to malicious data tampering, and existing technologies lack effective detection methods.

Method used

A dedicated cache is set up in the processor to back up the data stored in memory, and data integrity is verified by comparing the backup data with the actual data read.

Benefits of technology

It can accurately detect whether data has been maliciously tampered with, ensuring data security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117331741B_ABST
    Figure CN117331741B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a data checking method, a processor and an electronic device, a special cache used for storing backup data of data stored in a memory; and a processor core having a source register and a destination register, configured to: in response to a first memory access instruction, write data in the source register rs into a memory address specified by the destination register rt, and write the data into the special cache as backup data of the data written in the memory; in response to a second memory access instruction, read target data from a memory address specified by a source register, and obtain backup data corresponding to the target data from the special cache; and use the obtained backup data to check the integrity of the target data. Whether the data is maliciously tampered with can be accurately detected.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This application is a divisional application of Chinese patent application filed on November 25, 2020, with application number 202011348311.9 and the invention title "Data Verification Method, Apparatus, Processor and Electronic Equipment". Technical Field

[0002] The embodiments of the present invention relate to the field of processor technology, and in particular to a data verification method, processor, and electronic device. Background Technology

[0003] In the information age, the security of computer systems has received widespread attention. Computer systems primarily employ the von Neumann architecture. In this architecture, instructions and data are stored in the computer system's memory. The processor reads instructions from memory and caches data in the computer system's main memory via an off-chip bus. The processor then reads and writes data from main memory according to the instructions via the off-chip bus and executes the instructions to achieve the intended goal.

[0004] However, during the processor's data reading from memory, both the memory and the off-chip bus are vulnerable to attack. Common attacks include: active attacks (attackers maliciously tamper with data in memory), spoofing attacks (attackers replace data in memory with forged data), relocation attacks (attackers replace data in memory A with data in memory B), and replay attacks (attackers record data at a specific physical address in memory, and when the processor rewrites the data at that address, the attacker replaces the current data with the previously recorded data). Because memory and the off-chip bus are vulnerable to attack, data can be maliciously tampered with. Current technology lacks a method to detect whether data has been maliciously tampered with. Summary of the Invention

[0005] This invention provides a data verification method, processor, and electronic device to detect whether data read from memory has been maliciously tampered with.

[0006] In a first aspect, embodiments of the present invention provide a processor, comprising: a dedicated cache specifically used for backing up data stored in memory; and a processor core having a source register and a destination register, configured to: in response to a first memory access instruction, write data in the destination register to a memory address specified by the source register, and write the data to the dedicated cache as backup data for the data written to memory; in response to a second memory access instruction, read target data from the memory address specified by the source register, and obtain backup data corresponding to the target data from the dedicated cache; and perform integrity verification on the target data using the obtained backup data.

[0007] Secondly, embodiments of the present invention also provide an electronic device, the electronic device including the processor described above.

[0008] The processor and electronic device provided in this embodiment of the invention can accurately detect whether data has been maliciously tampered with. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 This is a schematic diagram of a computer system based on the von Neumann architecture;

[0011] Figure 2 This is a flowchart illustrating a data verification method provided in an embodiment of the present invention;

[0012] Figure 3 This is a flowchart illustrating another data verification method provided in an embodiment of the present invention;

[0013] Figure 4 This is a flowchart illustrating another data verification method provided in an embodiment of the present invention;

[0014] Figure 5 This is a flowchart illustrating another data verification method provided in an embodiment of the present invention;

[0015] Figure 6 This is a schematic diagram of the structure of a dedicated cache for a processor provided in an embodiment of the present invention;

[0016] Figure 7 This is a schematic diagram of the structure of a processor provided in an embodiment of the present invention;

[0017] Figure 8 This is a flowchart illustrating another data verification method provided in an embodiment of the present invention;

[0018] Figure 9 This is a schematic diagram of the structure of a data verification device provided in an embodiment of the present invention. Detailed Implementation

[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0020] Figure 1 This is a schematic diagram of a computer system based on the von Neumann architecture, such as... Figure 1 As shown, the computer system includes a processor 11, a memory 12, an external bus 13, and a storage 14. The processor 11 is connected to the memory 12 and the storage 14 via the external bus 13. The instructions and data of the computer program are stored in the storage 14. When the processor 11 needs to execute the program, it reads the program from the storage 14. During program execution, the processor 11 interacts with the memory 12 via the external bus 13 to read and write data according to the instructions of the computer program.

[0021] For example, when processor 11 executes a write instruction, processor 11 sends a write instruction to memory 12, and memory 12 writes data A to the corresponding physical address X in memory 12 according to the physical address X in the write instruction. When processor 11 executes a read instruction, processor 11 sends a read instruction to memory 12, and memory 12 reads data A from physical address X in memory 12 according to the read instruction.

[0022] As mentioned above, the processor reads and writes data from memory using instructions. Taking the Reduced Instruction Set Computing (RISC) as an example, the instruction structure for reading and writing data is shown in Table 1:

[0023] Table 1

[0024] opcode source operands target operands

[0025] The opcode indicates the type of instruction. For example, taking a read instruction, the opcode indicates that the instruction is a read instruction. If the source operand points to the rt register and the destination operand points to the rs register, then the meaning of this read instruction is to use the value in the rs register as the physical address and read the data at that physical address in memory into the rt register.

[0026] However, during the process of processor 11 reading data from memory 12, memory 12 and the off-chip bus 13 are vulnerable to attacks. Common attacks include: active attacks (attackers maliciously tamper with data in memory), spoofing attacks (attackers replace data in memory with forged data), relocation attacks (attackers replace data in memory A with data in memory B), and replay attacks (attackers record data at a specific physical address in memory, and when the processor rewrites the data at that physical address, the attacker replaces the current data with the previously recorded data). For example, these attacks can cause data A at physical address X in memory 12 to be tampered with into data B. When processor 11 sends a read command to memory 12 requesting to read data at physical address X in memory 12, it will read the incorrect data B, thus compromising data security.

[0027] To address the aforementioned technical problems, this invention modifies the existing read process of the processor. By setting up a dedicated cache within the processor specifically for backing up data stored in memory, the processor can perform integrity checks on the data read from memory based on the backup data in the dedicated cache, thereby identifying whether the read data has been maliciously tampered with. In other words, the processor involved in this invention includes a dedicated cache for storing backup data for data to be stored in memory, which can be located in a specific area within the processor.

[0028] The execution subject of the data verification method provided by the present invention can be a data verification device, which can be program code software or a medium storing relevant execution code, such as a USB flash drive; or, the data verification device can also be a physical device that integrates or installs relevant execution code, which can be located in a processor or can be a processor.

[0029] The following is combined with Figure 1 The computer architecture shown, taking a processor integrated or installed with relevant execution code as an example, provides a detailed description of the technical solution of the present invention through specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments.

[0030] Figure 2 This is a flowchart illustrating a data verification method provided in an embodiment of the present invention. Figure 2 As shown, the method of the present invention may include:

[0031] S101, Send the first instruction to memory.

[0032] The first instruction is used to read target data from a target physical address in memory. The target data is the data to be read by the first instruction, and the target physical address is the address in memory where the target data is stored. For example, the first instruction can be one of the instructions shown in Table 1.

[0033] For example, the first instruction is used to read target data A from the target physical address Y in memory.

[0034] S102, Receive target data sent from memory.

[0035] For example, the memory finds the target data A based on the target physical address Y in the first instruction and sends the target data A to the processor, which receives the target data A sent by the memory.

[0036] S103. Based on the target physical address, retrieve backup data of the data last written to the target physical address from the dedicated cache.

[0037] In this embodiment of the invention, a backup of the data previously written to the target physical address is pre-cached in a dedicated cache. The address of the backup data in the dedicated cache and the target physical address can be mapped, so that the processor can find the address of the target data in the dedicated cache based on the target physical address and then obtain the backup data.

[0038] For example, based on the target physical address Y, backup data B of the data last written to the target physical address is retrieved from a dedicated cache.

[0039] In the above steps, steps S101 to S102 can be executed first, followed by step S103; steps S103 can be executed first, followed by steps S101 to S102; or steps S103 can be executed simultaneously with steps S101 to S102.

[0040] S104. Determine whether the target data is the same as the backup data. If not, proceed to step S105; if yes, proceed to step S106.

[0041] If the target data A read from memory is different from the backup data B, it means that the target data A read from memory has been tampered with, and step S105 is executed. If the target data A read from memory is the same as the backup data B, it means that the target data A read from memory has not been tampered with, and step S106 is executed.

[0042] S105, The integrity check of the target data has failed.

[0043] If the processor determines that the target data read from memory has been maliciously tampered with, it can consider the integrity check to have failed and proceed to the next step as an exception to the integrity check failure. For example, if the first instruction mentioned above belongs to a program, the current program's process can be terminated.

[0044] S106. The integrity check of the target data has been passed.

[0045] Once the processor determines that the target data read from memory has not been maliciously tampered with, it can continue executing the first instruction, such as writing the target data into the corresponding register.

[0046] In this embodiment of the invention, the processor pre-caches backup data of the data previously written to the target physical address in its dedicated cache. When the processor sends a first instruction to memory and receives target data from memory, it compares the target data retrieved from memory with the backup data retrieved from the dedicated cache. If they are inconsistent, it indicates that the target data B read from memory has been tampered with, and data security is threatened. The data verification method provided by this embodiment of the invention can accurately detect whether data has been maliciously tampered with.

[0047] Figure 3 This is a flowchart illustrating another data verification method provided in this embodiment of the invention. This embodiment focuses on how backup data of the data previously written to the target physical address is pre-stored in a dedicated cache. Figure 2 On the basis of, such as Figure 3 As shown, prior to step S101, the method of the present invention may further include:

[0048] S201. Send a second instruction to memory; the second instruction is used to write the target data into the target physical address in memory.

[0049] For example, the processor sends a second instruction to the memory, and the memory writes the target data B into the target physical address Y according to the target physical address Y and the target data B in the second instruction.

[0050] The second instruction sent to memory can be either sent during the program initialization phase or during the program execution phase.

[0051] S202. Write the backup data of the target data into a dedicated cache.

[0052] In the above steps, step S201 can be executed first, followed by step S202, or step S202 can be executed first, followed by step S201, or steps S201 and S202 can be executed simultaneously.

[0053] It should be understood that the second instruction can be executed at least once before step S101. When the second instruction is executed two or more times, the target data written by the processor to the target physical address Y in memory can be different, and each write will overwrite the previous target data, and the backup data of the target data in the dedicated cache will also be overwritten synchronously.

[0054] Before step S101 in this embodiment, a second instruction is executed during the program initialization stage and / or program execution stage. While writing the target data into memory, the backup data of the target data is simultaneously written into a dedicated cache. This is so that when performing a read operation such as the first instruction mentioned above, the processor can compare the target data read from memory with the backup data of the data previously written to the target physical address, and accurately detect whether the data has been maliciously tampered with.

[0055] This invention also provides a data verification method. When the target data is critical data, the critical data is verified. When the target data is non-critical data, the non-critical data is processed using existing reading methods without data verification. Figure 4 and Figure 5 This section will focus on how to implement data validation for critical data.

[0056] Figure 4 This is a flowchart illustrating another data verification method provided in an embodiment of the present invention. Figure 4 As shown, in Figure 2 Based on this, prior to step S103, the method of the present invention may further include:

[0057] S301. Determine whether the target data is critical data. If yes, execute step S101 above; otherwise, continue execution according to the existing read instruction. That is, do not verify non-critical data, for example, write non-critical data into the corresponding register.

[0058] Key data can be important data during program execution, such as sensitive data, account passwords, keys, etc.

[0059] One possible implementation of a method to determine whether target data is critical data is to determine whether the target data is critical data based on the type of the first instruction.

[0060] The type of the first instruction corresponds to the identifier of the target data declaration in the source program. This identifier indicates whether the target data is critical data. For example, if variable `key` is critical data and variable `temp` is non-critical data, a new variable declaration can be defined in the source program to indicate that the variable is critical data. For instance, `key` can be declared as critical data and `temp` as non-critical data in the following way:

[0061] Security double key;

[0062] Double temp;

[0063] In this context, `Security double` represents a variable declaration for critical data, while `Double` represents a variable declaration for non-critical data.

[0064] For example, taking a reduced instruction set as an example, the type of the first instruction is identified by the opcode. This invention can extend the opcode based on existing opcodes. The extended opcode is used to indicate that the target data being read is critical data (the extended opcode can also indicate that the target data being written is critical data). This extended opcode can implicitly indicate that the data verification method described above should be executed when reading the target data. Optionally, the extended opcode can also indicate the number of bytes of data to be read by the first instruction. For example, the extended opcode can be shown in Table 2.

[0065] Table 2

[0066] Extended opcodes meaning K1 Read 1 byte of key data K2 Read 2 bytes of key data K3 Read 4 bytes of key data K4 Read 8 bytes of key data K5 Write 1 byte of key data K6 Write 2 bytes of key data K7 Write 4 bytes of key data K8 Write 8 bytes of key data

[0067] Another possible implementation of the method to determine whether target data is critical data is to determine whether the target data is critical data based on the variable-length bits of the first instruction.

[0068] For example, taking the Reduced Instruction Set Computing (RISC) as an example, when the opcode is set to 1111, the instruction structure also includes variable-length bits, as shown in Table 3:

[0069] Table 3

[0070] opcode source operands target operands Variable length

[0071] In this example, a variable-length bit can be used to mark whether the target data is critical data. Optionally, the variable-length bit can also indicate the number of bytes of data that the first instruction needs to read. For example, different values ​​can be set for the variable-length bit to mark whether the target data read by the first instruction is critical data and to indicate the number of bytes of data that the first instruction needs to read, similar to the extended opcodes shown in Table 2. The meaning of each extended opcode will not be elaborated here.

[0072] Another possible implementation of the method for determining whether target data is critical data is to determine whether the target data is critical data based on the target's physical address. For example, data stored within a specific physical address range can be identified as critical data.

[0073] Those skilled in the art will understand that after the source program is compiled, for instructions in the source program that include the variable `key`, a `Security double` is declared based on that variable, and the compiled processor instructions are the first instructions for processing critical data. For instructions in the source program that include the variable `temp`, the compiled processor instructions are instructions for processing non-critical data, such as non-sensitive data, non-account passwords, and non-keys.

[0074] Those skilled in the art will understand that the above embodiments are illustrated using a reduced instruction set as an example. For processors using other instruction sets, the same approach of the present invention can be used, and this embodiment will not elaborate further.

[0075] This embodiment determines whether the target data is critical data before sending the first instruction to memory. If the target data is critical data, it performs data verification to check whether the critical data has been tampered with. If the target data is non-critical data, it is processed using existing reading methods without data verification. This method can perform data verification only on critical data, resulting in minimal performance loss and power consumption for the processor.

[0076] correspond Figure 4 The method Figure 5 This is a flowchart illustrating another data verification method provided in an embodiment of the present invention. Figure 5 As shown, in Figure 3 Based on this, prior to step S201, the method of the present invention may further include:

[0077] S401. Determine whether the target data is critical data. If yes, execute step S201 above; otherwise, continue execution according to the standard write instruction. That is, do not verify non-critical data, and directly write the target data to the target physical address in memory.

[0078] One possible implementation for identifying target data as critical data is based on the type of the second instruction. Another possible implementation is based on the variable-length bits of the second instruction. Yet another possible implementation is based on the target's physical address.

[0079] The type of the second instruction corresponds to the identifier of the target data declaration in the source program. The identifier of the declaration is used to indicate whether the target data is critical data.

[0080] This embodiment can be referred to in detail. Figure 4 The embodiments shown are not described in detail here.

[0081] This embodiment determines whether the target data is critical data before sending the second instruction to memory. If the target data is critical data, it is cached for future data verification to check whether the critical data has been tampered with. If the target data is non-critical data, it is processed using the existing write method without caching. This method can perform data verification only on critical data, resulting in minimal performance loss and power consumption for the processor.

[0082] In the above embodiments, the dedicated cache includes multiple data blocks, for example, Figure 6 This is a schematic diagram of the structure of a dedicated cache for a processor provided in an embodiment of the present invention. Figure 6 As shown, the dedicated cache comprises Q groups, each containing R data blocks. Each data block also corresponds to a flag and a status bit, where Q is an integer greater than or equal to 1, and R is an integer greater than or equal to 1. When the flag is not empty, it indicates the mapping relationship between physical addresses and data blocks, representing that the data block caches the data corresponding to that physical address in memory. When no flag is present, it indicates that the data block is not mapped to any physical address. The status bit indicates whether the data block has already stored data.

[0083] exist Figure 6 Building upon that, this embodiment focuses on how to write target data from a dedicated cache.

[0084] This method may specifically include:

[0085] Based on the target physical address, determine whether there is a first data block corresponding to the target physical address among multiple data blocks. The marker of the first data block includes: the mapping relationship between the target physical address and the address of the first data block;

[0086] If the first data block is included among multiple data blocks, then the backup data is written into the first data block, and the status bit corresponding to the first data block is set.

[0087] If the first data block is not included in the multiple data blocks, the backup data is written into the second data block, and the mapping relationship between the target physical address and the address of the second data block is added to the tag of the second data block. Also, the status bit corresponding to the second data block is set. The second data block is a data block that does not correspond to any physical address among the multiple data blocks.

[0088] Since the status bits are used to indicate whether the data block has been saved, checking the status bits can quickly identify whether the data block contains backup data of the target data.

[0089] For example, based on the mapping relationship between physical addresses and data block addresses in the tags, when a physical address within a tag is the same as the target physical address, it indicates that the first data block is included. In this case, the backup data of the target data is written into the first data block, and the status setting corresponding to the first data block is set. When no physical address within a tag is the same as the target physical address, it indicates that the first data block does not exist. In this case, a data block with a status bit of 0 can be searched in this group of data blocks (for example, searching in the order from the first block to the last block). When a data block with a status bit of 0 is found, the mapping relationship between the target physical address and the address of this data block is added to the tags, the backup data of the target data is written into this data block, and the status setting corresponding to the target data block is set. At this time, this data block is the second data block. If no data block with a status bit of 0 is found, no processing can be performed and the data block can be returned directly, that is, the backup data of the target data is not saved in the dedicated cache. Alternatively, the backup data can be used to overwrite other cached data blocks. For example, the backup data can be used to overwrite data blocks whose cache duration is longer than a preset duration.

[0090] exist Figure 6 Building upon that, this embodiment focuses on how to read target data from a dedicated cache.

[0091] This method may specifically include:

[0092] The first data block is determined based on the target physical address. For example, the first data block can be obtained based on the mapping relationship between the physical address and the data block address in the tag.

[0093] Obtain the status bit corresponding to the first data block. Determine if the status bit of the first data block is set. If yes, it means the dedicated cache contains backup data of the target data, and the backup data of the target data is obtained from the first data block. Optionally, if no, it means the dedicated cache does not contain backup data of the target data. In this case, the first instruction can continue to be executed, for example, writing the target data into the corresponding register. Alternatively, the next step can be processed as an exception for integrity verification failure.

[0094] exist Figure 6 The dedicated cache structure shown may also include a status bit register and a data register. After obtaining the target data block (first data block) based on the target physical address, the status bits of the target data block can be written to the status bit register, and the backup data of the target data can be written to the data register. When obtaining the status bits of the target data block, the processor can obtain the status bits of the target data block from the status bit register, and the processor can specifically obtain the backup data of the data last written to the target physical address from the data register.

[0095] This embodiment adopts... Figure 6When using the dedicated cache shown, the above method can be used in conjunction with it. When executing a write instruction (second instruction), backup data of the target data is saved in the dedicated cache. When executing a read instruction (first instruction), the data read from memory is compared with the backup data in the dedicated cache, thereby verifying whether the data has been maliciously tampered with.

[0096] To better understand the technical solution of this invention, the method provided by this invention is illustrated below through an example:

[0097] In the following example, a dedicated cache is as follows: Figure 6 The diagram includes Q groups, each group containing R data blocks. Each data block also corresponds to a flag and a status bit, and includes a status bit register and a data register. Figure 7 This is a schematic diagram of the structure of a processor provided in an embodiment of the present invention, such as... Figure 7 As shown, the processor may include a processor core 111, a data verification module 112, and a memory access module 113, wherein the data verification module 112 includes a dedicated cache.

[0098] First, in the source code, to distinguish between critical and non-critical data, for example, a two-byte critical data can be defined by defining a new variable declaration "Security double", while non-critical data uses existing variable declarations, for example:

[0099] Security double key;

[0100] Double temp;

[0101] Key represents critical data, while temp represents non-critical data.

[0102] After the source program is compiled, it uses the load / store memory access instructions to read and write the non-critical data `temp`. This method can perform read and write operations using existing methods, without needing to validate the non-critical data `temp` or save it to a cache, which will not be elaborated further here.

[0103] For reading and writing critical data keys, newly added memory access instructions (such as SLoad / SStore) are used to process the variable keys. These instructions allow data to be backed up in a dedicated cache when a write instruction is executed, and the read data is compared with the data in the dedicated cache when a read instruction is executed to verify whether the data has been maliciously tampered with. The SLoad instruction is the first instruction mentioned above, and the SStore instruction is the second instruction mentioned above. Since the key is two bytes, for example, the opcode for SLoad can be K2 in Table 2, and the opcode for SStore can be K6 in Table 2. The following section focuses on SLoad and SStore for critical data keys. Figure 8 This is a flowchart illustrating another data verification method provided in an embodiment of the present invention, as shown below. Figure 8 As shown:

[0104] During program initialization or execution, the processor needs to write critical data (key) into memory. The process is as follows:

[0105] ① The processor core 111 sends the instruction SStore rt,rs to the data verification module 112. (Those skilled in the art will understand that in assembly language, mnemonics are used to replace the opcodes of machine instructions, and address symbols or labels are used to replace the physical addresses of instructions or operands.) The physical address in the rt register is P, and the data in the rs register is key.

[0106] This instruction instructs the data key in the rs register to be written to the physical address P in memory, and the opcode type is K6.

[0107] ② The data verification module 112 determines, based on the instruction's opcode (K6), that the instruction is a write operation for critical data. At this point, the backup data of the data key in the rs register is written to the data block in the dedicated cache.

[0108] ③ The data verification module 112 sends the instruction SStore rt,rs to the memory access module 113.

[0109] ④ The memory access module 113 writes the data key in the rs register to the physical address P in memory via the external bus.

[0110] In another phase of program execution, the processor needs to read critical data (key) from memory, as follows:

[0111] ⑤ The processor core 111 sends the instruction SLoad rt,rs to the data verification module 112. The physical address in the rs register is P, and the rt register is used to store the data key read from memory.

[0112] ⑥ The data verification module 112 determines that the instruction is a read operation for key data based on the operation code K2 (see Table 2). At this time, it finds the data block containing the backup data of the data key in the dedicated cache according to the physical address P, writes the status bit of the backup data to the status bit register, and writes the backup data to the data register.

[0113] ⑦ The data verification module 112 sends the instruction SLoad rt,rs to the memory access module 113.

[0114] ⑧ The memory access module 113 reads the data key from the physical address P in the memory through the external bus and sends the data key read from the memory to the data verification module 112.

[0115] ⑨ The data verification module 112 determines whether the data key read from memory is equal to the backup data of the data key. If yes, the verification is successful, and the data verification module 112 sends the data key read from memory to the processor core 111 so that the processor core 111 can store the data key read from memory into the register. If no, the verification fails, and the data verification module 112 sends an exception indicating that the integrity verification failed to the processor core 111.

[0116] The processor core 111, based on the exception of the integrity check failure, terminates the process of the current program according to pre-designed rules, such as terminating the process of the current program.

[0117] Optionally, before step ⑨, the data verification module 112 may first determine whether the status bit register is set. If not, it directly sends the data key read from memory to the processor core 111 so that the processor core 111 can store the data key read from memory into the register. If yes, it continues to execute step ⑨.

[0118] The embodiments of the present invention, through the above method, can accurately detect whether key data has been maliciously tampered with; on the other hand, only key data is verified, resulting in minimal performance loss and power consumption for the processor.

[0119] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0120] Figure 9 This is a schematic diagram of a data verification device provided in an embodiment of the present invention. This device is applied to a processor, such as... Figure 9 As shown, the device includes: a transmitting module 21, a receiving module 22, and a processing module 23. Among them,

[0121] Sending module 21 is used to send a first instruction to memory; the first instruction is used to read target data from the target physical address in memory;

[0122] Receiver module 22 is used to receive target data sent from memory;

[0123] Processing module 23 is used to retrieve backup data of the data last written to the target physical address from a dedicated cache based on the target physical address; when the target data is different from the backup data, the integrity check of the target data is determined to have failed.

[0124] Optionally, in some embodiments, the processing module 23 is further configured to determine that the integrity check of the target data has passed when the target data is the same as the backup data after obtaining the backup data of the data last written to the target physical address from the dedicated cache according to the target physical address.

[0125] Optionally, in some embodiments, the processing module 23 is further configured to determine that the target data is critical data before retrieving backup data of the data last written to the target physical address from the dedicated cache based on the target physical address.

[0126] Optionally, in some embodiments, the processing module 23 is specifically used to determine the target data as key data based on the type of the first instruction.

[0127] Optionally, in some embodiments, the type of the first instruction corresponds to the identifier of the target data declaration in the source program, and the identifier of the declaration is used to characterize whether the target data is critical data.

[0128] Optionally, in some embodiments, the sending module 21 is further configured to send a second instruction to the memory before sending the first instruction to the memory; the second instruction is configured to write the target data into the target physical address of the memory.

[0129] The processing module 23 is also used to write backup data of the target data into a dedicated cache.

[0130] Optionally, in some embodiments, the processing module 23 is further configured to determine that the target data is critical data before writing the backup data of the target data into a dedicated cache.

[0131] Optionally, in some embodiments, the processing module 23 is specifically used to determine the target data as key data based on the type of the second instruction.

[0132] Optionally, in some embodiments, the type of the second instruction corresponds to the identifier of the target data declaration in the source program, and the identifier of the declaration is used to characterize whether the target data is critical data.

[0133] Optionally, in some embodiments, the dedicated cache includes multiple data blocks;

[0134] The processing module 23 is specifically used to determine whether a first data block corresponding to the target physical address exists among multiple data blocks based on the target physical address; when the first data block is included among the multiple data blocks, the backup data is written into the first data block and the status bit corresponding to the first data block is set; when the first data block is not included among the multiple data blocks, the backup data is written into the second data block, and the mapping relationship between the target physical address and the address of the second data block is added to the tag of the second data block, and the status bit corresponding to the second data block is set.

[0135] The second data block is a data block among multiple data blocks that does not correspond to any physical address; the marking of the first data block includes: the mapping relationship between the target physical address and the address of the first data block.

[0136] Optionally, in some embodiments, the processing module 23 is specifically used to determine the first data block according to the target physical address; obtain the status bit corresponding to the first data block; and obtain backup data from the first data block when the status bit of the first data block is set.

[0137] This invention Figure 9 The data verification device provided in the illustrated embodiment can perform the operations of the processor in the above method embodiment. For example, the data verification device can be the processor itself, or it can be a data verification device disposed in the processor.

[0138] This invention also provides a processor that can be used to execute any of the data verification methods provided above.

[0139] This invention also provides an electronic device, which includes the processor described above. This electronic device may be, for example, a terminal device, a server, etc.

[0140] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A processor, characterized in that, include: A dedicated cache, specifically for backing up data stored in memory; as well as The processor core has source and destination registers and is configured as follows: In response to the first memory access instruction, the data in the source register rs is written to the memory address specified by the destination register rt, and the data is written to the dedicated cache as backup data for the data written to memory; In response to the second memory access instruction, target data is read from the memory address specified by the source register, and backup data corresponding to the target data is retrieved from the dedicated cache; as well as The integrity of the target data is verified using the acquired backup data.

2. The processor according to claim 1, characterized in that, The processor also includes a data verification module, which includes the dedicated cache. The processor core is configured to load the target data into the destination register when the data verification module determines that the target data is the same as the acquired backup data.

3. The processor according to claim 1, characterized in that, The dedicated cache includes multiple data blocks and a status bit register corresponding to each data block. The processor is configured as follows: The backup data is written into a dedicated cache data block corresponding to the memory address, and the corresponding status bit register is set.

4. The processor according to claim 3, characterized in that, The processor is configured to load the target data into the destination register when it determines that the status bit register of the dedicated cache data block corresponding to the target data is not set.

5. An electronic device, characterized in that, The processor included in any one of claims 1-4.

6. A data verification method, executed on a processor, said processor comprising: A dedicated cache for storing backup data to be stored in memory, and a processor core, having source and destination registers, the method comprising: In response to the first memory access instruction, the data in the source register rs is written to the memory address specified in the destination register rt, and the data is also written to the dedicated cache as backup data for the data written to memory; In response to the second memory access instruction, target data is read from the memory address specified in the source register, and backup data corresponding to the target data is retrieved from the dedicated cache; and The integrity of the target data is verified using the acquired backup data.

7. The method according to claim 6, characterized in that, The processor also includes a data verification module, which includes the dedicated cache. The method includes: when the data verification module determines that the target data is the same as the acquired backup data, loading the target data into the destination register.

8. The method according to claim 7, characterized in that, The dedicated cache includes multiple data blocks and a status bit register corresponding to the data blocks. The method further includes: The backup data is written into a dedicated cache data block corresponding to the memory address, and the corresponding status bit register is set.

9. The method according to claim 8, characterized in that, The method further includes loading the target data into the destination register when it is determined that the status bit register of the dedicated cache data block corresponding to the target data is not set.

Citation Information

Patent Citations

  • Mixed memory data backup system and method

    CN105183379A

  • Mobile communication terminal having a radio frequency calibration data recovering function and a method of backing up and restoring calibration data

    US20070093266A1