Processor and attack detection method thereof
By recording the execution status of jump instructions and determining their legality in the processor's privileged mode, the problem of detecting JOP attacks is solved, thus improving processor security.
Patent Information
- Application Number
- CN202210889931.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-27
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2042-07-27
AI Technical Summary
Existing technologies cannot effectively detect and defend against jump-directed programming (JOP) attacks, which allow attackers to tamper with register contents to redirect programs to addresses of tools they have built, thus posing a security threat.
In the privileged mode of the processor, the execution status of jump instructions is recorded through special registers. When jumping, it is determined whether the corresponding instruction is legal and whether the parameters match the recorded content, and a warning message is issued to defend against attacks.
It effectively detects and defends against JOP attacks, ensuring that programs jump to legitimate addresses and improving processor security.
Smart Images

Figure CN117521053B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a processor and an attack detection method thereof, and more specifically to a processor and an attack detection method thereof for detecting jump-oriented programming (JOP) attacks. Background Technology
[0002] Jump-oriented programming (JOP) attacks exploit jump instructions in a program (e.g., ARM's BR and BLR instructions, and RISC-V's JR and JALR instructions). Specifically, when a program executes a jump instruction normally, it obtains the target address from the specified register. If an attacker modifies the contents of this register using stack overflow, the target address can be altered. By modifying the register contents, the attacker can jump to the address of a gadget they have created during program execution, thus performing a JOP attack. Therefore, it is necessary to develop relevant detection and warning methods to prevent JOP attacks. Summary of the Invention
[0003] One embodiment of this application relates to an attack detection method for a processor, characterized by comprising: executing a first jump-related instruction in a first privilege level mode; setting a first field of a first register to a first jump status parameter based on the execution of the first jump-related instruction, wherein the first register is used in the first privilege level mode, and the first field is used to record the execution status of the first jump-related instruction; jumping to a first corresponding instruction in a specified register of the first jump-related instruction; determining whether the first corresponding instruction is a valid instruction and whether the first parameter of the first corresponding instruction is equal to the first jump status parameter of the first field of the first register to obtain a first determination result; and determining whether to issue a warning message based on the first determination result.
[0004] Another embodiment of this application relates to a processor. The processor includes a first register and an execution unit, the execution unit being electrically connected to the first register, and configured to: execute a first jump-related instruction in a first privilege level mode; based on the execution of the first jump-related instruction, set a first field of the first register to a first jump status parameter, wherein the first field is used to record the execution status of the first jump-related instruction; jump to a first corresponding instruction in a specified register of the first jump-related instruction; determine whether the first corresponding instruction is a valid instruction and whether the first parameter of the first corresponding instruction is equal to the first jump status parameter of the first field of the first register to obtain a first determination result; and determine whether to issue a warning message based on the first determination result.
[0005] The processor and attack detection method described in this application can record the execution status through a special register of this privileged mode when executing jump-related instructions. Upon jumping to the corresponding instruction at the destination address, it determines whether the instruction is valid and whether its parameters match the content recorded in the special register. Attack detection is achieved by determining whether the instruction is valid or whether its parameters match the content recorded in the special register, and an alert message is issued when necessary. Attached Figure Description
[0006] The aspects of this disclosure will be better understood from the following embodiments when read in conjunction with the accompanying drawings. It should be noted that, in accordance with standard industry practice, the various structures are not drawn to scale. In fact, the dimensions of the various structures may be arbitrarily increased or decreased for clarity of explanation.
[0007] Figure 1 This is a block diagram of a processor according to one embodiment.
[0008] Figures 2A to 2C These are schematic diagrams illustrating some examples of JOP attack detection.
[0009] Figure 3 This is a block diagram of a processor according to one embodiment.
[0010] Figures 4A to 4C These are schematic diagrams illustrating some examples of JOP attack detection.
[0011] Figure 5 This is a block diagram of a processor according to one embodiment.
[0012] Figures 6A to 6C These are schematic diagrams illustrating some examples of JOP attack detection.
[0013] Figure 7 This is a block diagram of a processor according to one embodiment.
[0014] Figures 8A to 8C These are schematic diagrams illustrating some examples of JOP attack detection.
[0015] Figure 9 This is a block diagram of a processor according to one embodiment.
[0016] Figure 10 This is a flowchart of an attack detection method according to one embodiment.
[0017] Figures 11A to 11C This is a flowchart of an attack detection method according to one embodiment.
[0018] Figures 12A to 12C This is a flowchart of an attack detection method according to one embodiment.
[0019] Figures 13A to 13B This is a flowchart of an attack detection method according to one embodiment. Detailed Implementation
[0020] The following disclosure provides numerous different embodiments or examples of various components for implementing the provided subject matter. Specific examples of components and arrangements are described below to simplify this disclosure. Of course, such examples are merely illustrative and are not intended to be limiting. For example, in the following description, embodiments in which a first component is formed above or on a second component may include instances in which the first and second components are in direct contact, and embodiments in which additional components may be formed between the first and second components such that the first and second components are not in direct contact. Furthermore, reference numerals and / or letters may be repeated in various instances of this disclosure. This repetition is for simplicity and clarity and does not in itself indicate a relationship between the various embodiments and / or configurations discussed.
[0021] Furthermore, for ease of description, spatial relative terms such as “below,” “under,” “below,” “above,” “above,” and similar terms may be used herein to describe the relationship of one component or member to another component or member illustrated in the figures. In addition to the orientations depicted in the figures, spatial relative terms are intended to cover different orientations of the device during use or operation. The device may be oriented in other ways (rotated 90 degrees or otherwise) and therefore the spatial relative descriptors used herein may be interpreted in the same way.
[0022] As used herein, terms such as “first,” “second,” and “third” describe various components, parts, areas, layers, and / or sections, but such components, parts, areas, layers, and / or sections should not be limited by such terms. Such terms are used only to distinguish one component, part, area, layer, or section from another. The use of terms such as “first,” “second,” and “third” herein does not imply sequence or order unless explicitly indicated by the context.
[0023] The singular forms "a," "an," and "the" may also include plural forms unless the context explicitly indicates otherwise. The term "connection," along with its derivatives, may be used herein to describe structural relationships between components. "Connection" may be used to describe two or more components in direct physical or electrical contact with each other. "Connection" may also be used to indicate two or more components in direct or indirect physical or electrical contact with each other (with intervening components between them), and / or two or more components cooperating or interacting with each other.
[0024] Figure 1 This is a block diagram of an embodiment of the processor 1 of this application. The processor 1 includes a register 11 and an execution unit 13. The execution unit 13 is coupled / electrically connected to the register 11. The register 11 is used in a first privilege level mode, and more specifically, the register 11 is used to record the instruction jump state in the first privilege level mode. Data and signals are transmitted between components through electrical connections. Related details and operations will be further described below.
[0025] In some embodiments, execution unit 13 loads and executes a program, and executes a first jump-related instruction in the program in a first privilege level mode. Based on the execution of the first jump-related instruction, execution unit 13 sets field 110 of register 11 to a first jump status parameter. Field 110 of register 11 is used to record the execution status of the first jump-related instruction.
[0026] Next, during program execution, execution unit 13 jumps to the corresponding instruction in the specified register of the first jump-related instruction. Execution unit 13 determines whether the corresponding instruction is a valid instruction and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 110 of register 11.
[0027] When execution unit 13 determines that the corresponding instruction is invalid, execution unit 13 issues a warning message. When execution unit 13 determines that the corresponding instruction is valid, execution unit 13 further determines whether the parameter of the corresponding instruction is equal to the first jump status parameter of field 110 of register 11. When execution unit 13 determines that the parameter of the corresponding instruction is not equal to the first jump status parameter of field 110 of register 11, execution unit 13 issues a warning message. When execution unit 13 determines that the parameter of the corresponding instruction is equal to the first jump status parameter of field 110 of register 11, execution unit 13 does not issue a warning message. To better understand the technology of this application, examples will be used to illustrate it below.
[0028] Figures 2A to 2CThese are schematic diagrams illustrating some examples of jump-oriented programming (JOP) attack detection in this application. It should be noted that these examples operate under a RISC-V architecture, and the jump-related instructions include the existing jump instruction JR and jump and link instruction JALR under the RISC-V architecture. The corresponding jump status parameter of JR is a first value (e.g., '01'), the corresponding jump status parameter of JALR is a second value (e.g., '10'), and the corresponding jump status parameter of other instructions is a third value (e.g., '00'). Furthermore, in these examples, the legitimate instruction is the BLD of this application's architecture, and the parameter of the legitimate instruction BLD is #IMM (the execution mode of the instruction BLD can be, for example, BLD #IMM). In some embodiments, the aforementioned legitimate instruction BLD can be implemented using the existing addition instruction ADDI under the RISC-V architecture (e.g., ADDI X0, X0, #IMM). However, these examples are not intended to limit the implementation of this application.
[0029] Please refer to Figure 2A Specifically, execution unit 13 loads and executes program PG11, and executes the jump instruction JR in program PG11 in machine mode (M-mode). Based on the execution of the jump instruction JR, execution unit 13 sets field 110 of register 11 to the first jump status parameter. The value of the first jump status parameter is '01'.
[0030] Next, during the execution of program PG11, execution unit 13 jumps to the corresponding instruction in the specified register X9 of the jump instruction JR. Execution unit 13 determines whether the corresponding instruction is a valid instruction BLD and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 110 of register 11. In this example, execution unit 13 determines that the corresponding instruction is the instruction ADD, not the valid instruction BLD. Therefore, execution unit 13 issues a warning message (i.e., an exception report).
[0031] Please refer to Figure 2B Specifically, execution unit 13 loads and executes program PG12, and executes the jump and link instruction JALR in program PG12 in supervisor mode (S-mode). Based on the execution of the jump and link instruction JALR, execution unit 13 sets field 110 of register 11 to the first jump status parameter. The value of the first jump status parameter is '10'.
[0032] Next, during the execution of program PG12, execution unit 13 jumps to the instruction corresponding to the jump and link instruction JALR in the specified register X2. Execution unit 13 determines whether the corresponding instruction is a valid instruction BLD and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 110 of register 11. If the parameter of the corresponding instruction is equal to the first value '01', it means that the corresponding instruction should correspond to the jump instruction JR; if the parameter of the corresponding instruction is equal to the second value '10', it means that the corresponding instruction should correspond to the jump and link instruction JALR; if the parameter of the corresponding instruction is equal to the third value '11', it means that the corresponding instruction should correspond to either the jump instruction JR or the jump and link instruction JALR; and if the parameter of the corresponding instruction is equal to the fourth value '00', it means that the corresponding instruction should correspond to other instructions.
[0033] In this example, execution unit 13 determines that the corresponding instruction is a valid instruction BLD, and further determines that the parameter of BLD is not equal to the first jump status parameter of field 110 of register 11. In other words, it determines that the parameter '01' of the corresponding instruction is not the second value '10' that should be corresponding to it. Therefore, execution unit 13 issues a warning message (i.e., an exception report).
[0034] Please refer to Figure 2C Specifically, execution unit 13 loads and executes program PG13, and executes the jump and link instruction JALR in program PG13 in hypervisor-extended supervisor mode (HS-mode). Based on the execution of the jump and link instruction JALR, execution unit 13 sets field 110 of register 11 to the first jump status parameter. The value of the first jump status parameter is '10'.
[0035] Next, during the execution of program PG13, execution unit 13 jumps to the corresponding instruction in register X3 of the jump and link instruction JALR. Execution unit 13 determines whether the corresponding instruction is a valid instruction BLD and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 110 of register 11. In this example, execution unit 13 determines that the corresponding instruction is a valid instruction BLD, and further determines that the parameter of BLD is equal to the first jump status parameter in field 110 of register 11. Therefore, execution unit 13 continues the execution of the program.
[0036] Figure 3This is a block diagram of an embodiment of the processor 3 of this application. The processor 3 includes a register 31 and an execution unit 33. The execution unit 33 is coupled / electrically connected to the register 31. In this embodiment, the register 31 is used for both a first privilege level mode and a second privilege level mode. More specifically, the register 31 is used to record various instruction jump states in the second privilege level mode, including fields 310 and 312. Field 310 records the execution state of jump-related instructions in the lower privilege level mode, and field 312 records the execution state of jump-related instructions in the higher privilege level mode. Data and signals are transmitted between components via electrical connections. Related details and operations will be further described below.
[0037] In some embodiments, execution unit 33 loads and executes a program, and executes a first jump-related instruction in the program in a first privilege level mode (a lower privilege level mode). Based on the execution of the first jump-related instruction, execution unit 33 sets field 310 of register 31 to a first jump status parameter. Subsequently, execution unit 33 receives a first interrupt in the first privilege level mode, and enters (i.e., traps to) a second privilege level mode (a higher privilege level mode) based on the first interrupt. To avoid the execution status after the first interrupt affecting the jump status record, execution unit 33 stores the value of field 310 of register 31 into field 312 of register 31 based on the first interrupt.
[0038] Next, during program execution, execution unit 33 executes the second jump-related instruction in the second privilege level mode. Based on the execution of the second jump-related instruction, execution unit 33 sets field 310 of register 31 to the second jump status parameter. Subsequently, execution unit 33 jumps to the corresponding instruction in the specified register of the second jump-related instruction. Execution unit 33 determines whether the corresponding instruction is a valid instruction and whether the parameter of the corresponding instruction is equal to the second jump status parameter in field 310 of register 31.
[0039] When execution unit 33 determines that the corresponding instruction is invalid, execution unit 33 issues a warning message. When execution unit 33 determines that the corresponding instruction is valid, execution unit 33 further determines whether the parameter of the corresponding instruction is equal to the second jump status parameter of field 310 in register 31. When execution unit 33 determines that the parameter of the corresponding instruction is not equal to the second jump status parameter of field 310 in register 31, execution unit 33 issues a warning message. When execution unit 33 determines that the parameter of the corresponding instruction is equal to the second jump status parameter of field 310 in register 31, execution unit 33 does not issue a warning message.
[0040] Next, during program execution, execution unit 33 executes the first interrupt return. Based on the first interrupt return, execution unit 33 returns to the first privilege level mode and stores the value of field 312 of register 31 into field 310 of register 31. Subsequently, execution unit 33 jumps to the corresponding instruction in the specified register of the first jump-related instruction. Execution unit 33 determines whether the corresponding instruction is a valid instruction and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 310 of register 31.
[0041] When execution unit 33 determines that the corresponding instruction is invalid, execution unit 33 issues a warning message. When execution unit 33 determines that the corresponding instruction is valid, execution unit 33 further determines whether the parameter of the corresponding instruction is equal to the first jump status parameter of field 310 of register 31. When execution unit 33 determines that the parameter of the corresponding instruction is not equal to the first jump status parameter of field 310 of register 31, execution unit 33 issues a warning message. When execution unit 33 determines that the parameter of the corresponding instruction is equal to the first jump status parameter of field 310 of register 31, execution unit 33 does not issue a warning message. To better understand the technology of this application, examples will be used to illustrate it below.
[0042] Figures 4A to 4C This is a schematic diagram illustrating an example of JOP attack detection in this application. It should be noted that this example operates under a RISC-V architecture, and the jump-related instructions include the existing jump instruction JR and jump and link instruction JALR under the RISC-V architecture. The corresponding jump status parameter of JR is a first value (e.g., '01'), the corresponding jump status parameter of JALR is a second value (e.g., '10'), and the corresponding jump status parameter of other instructions is a third value (e.g., '00'). Furthermore, in this example, the legitimate instruction is BLD in this application's architecture, and the parameter of the legitimate instruction BLD is #IMM (the execution mode of the instruction BLD can be, for example, BLD #IMM). In some implementations, the aforementioned legitimate instruction BLD can be implemented using the existing addition instruction ADDI under the RISC-V architecture (e.g., ADDI X0, X0, #IMM). Furthermore, in this example, the lower-privilege mode is virtualized user mode (VU-mode), and the higher-privilege mode is virtualized supervisor mode (VS-mode). However, these examples are not intended to limit the implementation of this application.
[0043] Please refer to Figure 4AExecution unit 33 loads and executes program PG31, and executes the jump instruction JR in program PG31 in VU-mode. Based on the execution of the jump instruction JR, execution unit 33 sets field 310 of register 31 to the first jump status parameter. The value of the first jump status parameter is '01'. Subsequently, execution unit 33 receives the first interrupt and enters (i.e., traps to) VS-mode based on the first interrupt. To avoid the execution status after the first interrupt affecting the jump status record, execution unit 33, based on the first interrupt, stores the value of field 310 of register 31 into field 312 of register 31, and sets the value of field 310 of register 31 to '00'.
[0044] Please refer to Figure 4B During program execution, execution unit 33 executes the jump and link instruction JALR in VS-mode. Based on the execution of the jump and link instruction JALR, execution unit 33 sets field 310 of register 31 to the second jump status parameter. The value of the second jump status parameter is '10'. Subsequently, execution unit 33 jumps to the corresponding instruction in the specified register X2 of the jump and link instruction JALR. Execution unit 33 determines whether the corresponding instruction is a valid instruction BLD and whether the parameter of the corresponding instruction is equal to the second jump status parameter in field 310 of register 31. In this example, execution unit 33 determines that the corresponding instruction is a valid instruction BLD, and further determines that the parameter of BLD is equal to the second jump status parameter in field 310 of register 31. Therefore, execution unit 33 continues program execution. Next, during program execution, execution unit 33 executes the first interrupt return. Execution unit 33 returns to VU-mode based on the first interrupt return, stores the value of field 312 of register 31 into field 310 of register 31, and sets the value of field 312 of register 31 to '00'.
[0045] Please refer to Figure 4C Execution unit 33 jumps to the corresponding instruction in the specified register X1 of the jump instruction JR. Execution unit 33 determines whether the corresponding instruction is a valid instruction BLD and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 310 of register 31. If the parameter of the corresponding instruction is equal to the first value '01', it means that the corresponding instruction should correspond to the jump instruction JR; if the parameter of the corresponding instruction is equal to the second value '10', it means that the corresponding instruction should correspond to the jump and link JALR; if the parameter of the corresponding instruction is equal to the third value '11', it means that the corresponding instruction should correspond to the jump instruction JR or the jump and link JALR; if the parameter of the corresponding instruction is equal to the fourth value '00', it means that the corresponding instruction should correspond to other instructions.
[0046] In this example, execution unit 33 determines that the corresponding instruction is a valid instruction BLD, and further determines that the parameter of BLD is not equal to the first jump status parameter of field 310 of register 31. In other words, it determines that the parameter '10' of the corresponding instruction is not the first value '01' that should be corresponding to it. Therefore, execution unit 33 issues a warning message (i.e., an exception report).
[0047] Figure 5 This is a block diagram of an embodiment of the processor 5 of this application. The processor 5 includes registers 51A and 51B and an execution unit 53. The execution unit 53 is coupled / electrically connected to registers 51A and 51B. In this embodiment, register 51A is used for a first privilege level mode, and register 51B is used for a second privilege level mode. More specifically, register 51A is used to record various instruction jump states in the first privilege level mode, including fields 510A and 512A. Field 510A records the execution state of jump-related instructions in the first privilege level mode, and field 512A records the execution state of jump-related instructions in the previous privilege level mode. Register 51B is used to record various instruction jump states in the second privilege level mode, including fields 510B and 512B. Field 510B records the execution state of jump-related instructions in the second privilege level mode, and field 512B records the execution state of jump-related instructions in the previous privilege level mode. Data and signals are transmitted between components through electrical connections. Related details and operations will be further described below.
[0048] In some embodiments, execution unit 53 loads and executes a program, and executes a first jump-related instruction in the program in a first privilege level mode (a lower privilege level mode). Based on the execution of the first jump-related instruction, execution unit 53 sets field 510A of register 51A to a first jump status parameter. Subsequently, execution unit 53 receives a first interrupt in the first privilege level mode and enters (i.e., traps to) a second privilege level mode (a higher privilege level mode) based on the first interrupt. To avoid the execution status after the first interrupt affecting the jump status record, execution unit 53 stores the value of field 510A of register 51A to field 512B of register 51B based on the first interrupt.
[0049] Next, during program execution, execution unit 53 executes the second jump-related instruction in the second privilege level mode. Based on the execution of the second jump-related instruction, execution unit 53 sets field 510B of register 51B to the second jump status parameter. Subsequently, execution unit 53 jumps to the corresponding instruction in the specified register of the second jump-related instruction. Execution unit 53 determines whether the corresponding instruction is a valid instruction and whether the parameter of the corresponding instruction is equal to the second jump status parameter in field 510B of register 51B.
[0050] When execution unit 53 determines that the corresponding instruction is invalid, execution unit 53 issues a warning message. When execution unit 53 determines that the corresponding instruction is valid, execution unit 53 further determines whether the parameter of the corresponding instruction is equal to the second jump status parameter of field 510B in register 51B. When execution unit 53 determines that the parameter of the corresponding instruction is not equal to the second jump status parameter of field 510B in register 51B, execution unit 53 issues a warning message. When execution unit 53 determines that the parameter of the corresponding instruction is equal to the second jump status parameter of field 510B in register 51B, execution unit 53 does not issue a warning message.
[0051] Next, during program execution, execution unit 53 executes the first interrupt return. Based on the first interrupt return, execution unit 53 returns to the first privilege level mode and stores the value of field 512B of register 51B into field 510A of register 51A. Subsequently, execution unit 53 jumps to the corresponding instruction in the specified register of the first jump-related instruction. Execution unit 53 determines whether the corresponding instruction is a valid instruction and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 510A of register 51A.
[0052] When execution unit 53 determines that the corresponding instruction is invalid, execution unit 53 issues a warning message. When execution unit 53 determines that the corresponding instruction is valid, execution unit 53 further determines whether the parameter of the corresponding instruction is equal to the first jump status parameter of field 510A in register 51A. When execution unit 53 determines that the parameter of the corresponding instruction is not equal to the first jump status parameter of field 510A in register 51A, execution unit 53 issues a warning message. When execution unit 53 determines that the parameter of the corresponding instruction is equal to the first jump status parameter of field 510A in register 51A, execution unit 53 does not issue a warning message. To better understand the technology of this application, examples will be used to illustrate it below.
[0053] Figures 6A to 6CThis is a schematic diagram illustrating an example of JOP attack detection in this application. It should be noted that this example operates under a RISC-V architecture, and the jump-related instructions include the existing jump instruction JR and jump and link instruction JALR under the RISC-V architecture. The corresponding jump status parameter of JR is a first value (e.g., '01'), the corresponding jump status parameter of JALR is a second value (e.g., '10'), and the corresponding jump status parameter of other instructions is a third value (e.g., '00'). Furthermore, in this example, the legitimate instruction is BLD in this application's architecture, and the parameter of the legitimate instruction BLD is #IMM (the execution mode of the instruction BLD can be, for example, BLD #IMM). In some embodiments, the aforementioned legitimate instruction BLD can be implemented using the existing addition instruction ADDI under the RISC-V architecture (e.g., ADDI X0, X0, #IMM). However, these examples are not intended to limit the implementation of this application.
[0054] Please refer to Figure 6A Execution unit 53 loads and executes program PG51, and executes the jump instruction JR in program PG51 in VU-mode. Based on the execution of the jump instruction JR, execution unit 53 sets field 510A of register 51A to the first jump status parameter. The value of the first jump status parameter is '01'. Subsequently, execution unit 53 receives the first interrupt and enters (i.e., traps to) HS-mode based on the first interrupt. To avoid the execution status after the first interrupt affecting the jump status record, execution unit 53, based on the first interrupt, stores the value of field 510A of register 51A to field 512B of register 51B, and sets the value of field 510A of register 51A to '00'.
[0055] Please refer to Figure 6BDuring program execution, execution unit 53 executes the jump and link instruction JALR in HS-mode. Based on the execution of the jump and link instruction JALR, execution unit 53 sets field 510B of register 51B to the second jump status parameter. The value of the second jump status parameter is '10'. Subsequently, execution unit 53 jumps to the corresponding instruction in the specified register X2 of the jump and link instruction JALR. Execution unit 53 determines whether the corresponding instruction is a valid instruction BLD and whether the parameter of the corresponding instruction is equal to the second jump status parameter in field 510B of register 51B. In this example, execution unit 53 determines that the corresponding instruction is a valid instruction BLD, and further determines that the parameter of BLD is equal to the second jump status parameter in field 510B of register 51B. Therefore, execution unit 53 continues program execution. Next, during program execution, execution unit 53 executes the first interrupt return. Execution unit 53 returns to VS-mode based on the first interrupt return, stores the value of field 512B of register 51B into field 510A of register 51A, and sets the value of field 512B of register 51B to '00'.
[0056] Please refer to Figure 6C Execution unit 53 jumps to the corresponding instruction in the specified register X1 of the jump instruction JR. Execution unit 53 determines whether the corresponding instruction is a valid instruction BLD and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 510A of register 51A. If the parameter of the corresponding instruction is equal to the first value '01', it means that the corresponding instruction should correspond to the jump instruction JR; if the parameter of the corresponding instruction is equal to the second value '10', it means that the corresponding instruction should correspond to the jump and link JALR; if the parameter of the corresponding instruction is equal to the third value '11', it means that the corresponding instruction should correspond to the jump instruction JR or the jump and link JALR; if the parameter of the corresponding instruction is equal to the fourth value '00', it means that the corresponding instruction should correspond to other instructions.
[0057] In this example, execution unit 53 determines that the corresponding instruction is a valid instruction BLD, and further determines that the parameter of BLD is not equal to the first jump status parameter of field 510A of register 51A. In other words, it determines that the parameter '10' of the corresponding instruction is not the first value '01' that should be corresponding to it. Therefore, execution unit 53 issues a warning message (i.e., an exception report).
[0058] Figure 7This is a block diagram of an embodiment of the processor 7 of this application. The processor 7 includes registers 71A and 71X and an execution unit 73. The execution unit 73 is coupled / electrically connected to registers 71A and 71X. In this embodiment, register 71A is used for a first privilege level mode, and register 71X is a temporary register. Furthermore, register 71A is used to record various instruction jump states in the first privilege level mode, including fields 710A and 712A. Field 710A is used to record the execution state of jump-related instructions executed in the first privilege level mode, and field 712A is used to record the execution state of jump-related instructions executed in the previous privilege level mode. Data and signals are transmitted between components through electrical connections. Related details and operations will be further described below.
[0059] In some embodiments, execution unit 73 loads and executes a program, and prepares to execute the first jump-related instruction in the program in a first privilege level mode. Before executing the first jump-related instruction, execution unit 73 stores the entire value of register 71A into register 71X. Based on the execution of the first jump-related instruction, execution unit 73 sets field 710A of register 71A to the first jump status parameter. Subsequently, execution unit 73 receives a first interrupt in the first privilege level mode, and enters (i.e., traps to) the same privilege level mode (i.e., the first privilege level mode) based on the first interrupt. To avoid the execution status after the first interrupt affecting the jump status record, execution unit 73 stores the value of field 710A of register 71A into field 712A of register 71A based on the first interrupt.
[0060] Next, during program execution, execution unit 73 executes the first interrupt return. Based on the first interrupt return, execution unit 73 returns to the first privilege level mode and stores the value of field 712A of register 71A into field 710A of register 71A. Subsequently, execution unit 73 jumps to the corresponding instruction in the specified register of the first jump-related instruction. Execution unit 73 determines whether the corresponding instruction is a valid instruction and whether the parameter of the corresponding instruction is equal to the first jump status parameter in field 710A of register 71A.
[0061] When execution unit 73 determines that the corresponding instruction is a valid instruction and that the parameter of the corresponding instruction is equal to the first jump status parameter of field 710A in register 71A, execution unit 73 does not issue a warning message. Subsequently, after executing the corresponding instruction, execution unit 73 stores the entire value of register 71X into register 71A. To better understand the technology of this application, examples will be provided below.
[0062] Figures 8A to 8CThis is a schematic diagram illustrating an example of JOP attack detection in this application. It should be noted that this example operates under a RISC-V architecture, and the jump-related instructions include the existing jump instruction JR and jump and link instruction JALR under the RISC-V architecture. The corresponding jump status parameter of JR is a first value (e.g., '01'), the corresponding jump status parameter of JALR is a second value (e.g., '10'), and the corresponding jump status parameter of other instructions is a third value (e.g., '00'). Furthermore, in this example, the legitimate instruction is BLD in this application's architecture, and the parameter of the legitimate instruction BLD is #IMM (the execution mode of the instruction BLD can be, for example, BLD #IMM). In some embodiments, the aforementioned legitimate instruction BLD can be implemented using the existing addition instruction ADDI under the RISC-V architecture (e.g., ADDI X0, X0, #IMM). However, these examples are not intended to limit the implementation of this application.
[0063] Please refer to Figure 8A In detail, execution unit 73 loads and executes program PG71, and prepares to execute the jump instruction JR in program PG71 in HS-mode. Before executing the jump instruction JR, execution unit 73 executes the instruction CSRREAD to store the entire value of register 71A into register 71X. Based on the execution of the jump instruction JR, execution unit 73 sets field 710A of register 71A to the first jump status parameter. The value of the first jump status parameter is '01'.
[0064] Subsequently, execution unit 73 receives the first interrupt in the first privilege level mode and enters (i.e., traps to) the same privilege level mode (i.e., the first privilege level mode) based on the first interrupt. To avoid the execution status after the first interrupt affecting the jump status record, execution unit 73, based on the first interrupt, stores the value of field 710A of register 71A into field 712A of register 71A, and sets the value of field 710A of register 71A to '00'.
[0065] Please refer to Figure 8B During the execution of the program, execution unit 73 performs a first interrupt return. Based on the execution of the first interrupt return, execution unit 73 returns to the first privilege level mode, stores the value of field 712A of register 71A into field 710A of register 71A, and sets the value of field 712A of register 71A to '00'.
[0066] Please refer to Figure 8CExecution unit 73 jumps to the corresponding instruction in register X9 specified by the jump instruction JR. Execution unit 73 determines whether the corresponding instruction is a valid instruction and whether its parameter is equal to the first jump status parameter in field 710A of register 71A. In this example, execution unit 73 determines that the corresponding instruction is the valid instruction BLD, and further determines that the parameter of BLD is equal to the first jump status parameter in field 710A of register 71A. Therefore, execution unit 73 continues program execution and executes the instruction CSRWRITE to store the entire value of register 71X into register 71A.
[0067] Figure 9 This is a block diagram of an embodiment of the processor 9 of this application. The processor 9 includes registers 91A, 91B, 91C and an execution unit 93. The execution unit 93 is coupled / electrically connected to registers 91A, 91B, 91C. In this embodiment, register 91A is used for a first privilege level mode (e.g., VS-mode), register 91B is used for a second privilege level mode (e.g., HS-mode), and register 91C is used for a third privilege level mode (e.g., M-mode).
[0068] Register 91A is used to record various instruction jump states in the first privilege level mode, including fields 910A, 912A, 914A, and 916A. Field 910A is used to record the execution state of jump-related instructions in the first privilege level mode, field 912A is used to record the execution state of jump-related instructions in the previous privilege level mode, field 914A is the first enabled state field, used to record the detection enabled state of the first privilege level mode (i.e., whether the attack detection function of this application is enabled in the first privilege level mode), and field 916A is the second enabled state field, used to record the detection enabled state of the second privilege level mode (i.e., whether the attack detection function of this application is enabled in the second privilege level mode).
[0069] Register 91B is used to record various instruction jump states in the second privilege level mode, including fields 910B, 912B, 914B, and 916B. Field 910B is used to record the execution state of jump-related instructions in the second privilege level mode, field 912A is used to record the execution state of jump-related instructions in the previous privilege level mode, field 914A is the first enabled state field, used to record the detection enabled state of the first privilege level mode (i.e., whether the attack detection function of this application is enabled in the first privilege level mode), and field 916B is the second enabled state field, used to record the detection enabled state of the second privilege level mode (i.e., whether the attack detection function of this application is enabled in the second privilege level mode).
[0070] Register 91C is used to record various instruction jump states in the third privilege level mode, including fields 910C, 912C, 914C, 916C, and 918C. Field 910C is used to record the execution state of jump-related instructions in the third privilege level mode; field 912C is used to record the execution state of jump-related instructions in the previous privilege level mode; field 914C is the first enabled state field, used to record the detection enabled state of the first privilege level mode (i.e., whether the attack detection function of this application is enabled in the first privilege level mode); field 916C is the second enabled state field, used to record the detection enabled state of the second privilege level mode (i.e., whether the attack detection function of this application is enabled in the second privilege level mode); and field 918C is the third enabled state field, used to record the detection enabled state of the third privilege level mode (i.e., whether the attack detection function of this application is enabled in the third privilege level mode).
[0071] It should be noted that processor 9 can perform the same functions as processors 1, 3, 5 and 7 mentioned above, which will not be repeated here.
[0072] Some embodiments of this application include an attack detection method for a processor, the flowchart of which is shown below. Figure 10 As shown. The data manipulation methods of these embodiments are implemented by a processor (such as the processor in the previous embodiments), and the detailed steps of the method are as follows. First, step S1001 is executed, in the first privilege level mode, a first jump-related instruction is executed. Step S1002 is executed, based on the execution of the first jump-related instruction, the first field of the first register is set to a first jump status parameter. Wherein, the first register is used in the first privilege level mode, and the first field of the first register is used to record the execution status of the first jump-related instruction.
[0073] Execute step S1003, jump to the corresponding instruction in the specified register of the first jump-related instruction. Execute step S1004, determine whether the corresponding instruction is a valid instruction. If step S1004 determines that the corresponding instruction is not a valid instruction, execute step S1007, issue a warning message. If step S1004 determines that the corresponding instruction is a valid instruction, execute step S1005, determine whether the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register.
[0074] If in step S1005 it is determined that the parameter of the corresponding instruction is not equal to the first jump status parameter of the first field of the first register, then step S1007 is executed and a warning message is issued. If in step S1005 it is determined that the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register, then step S1006 is executed and the program continues to execute.
[0075] Some embodiments of this application include an attack detection method for a processor, the flowchart of which is shown below. Figures 11A to 11C As shown. The data manipulation methods of these embodiments are implemented by a processor (such as the processor in the previous embodiments), and the detailed steps of the method are as follows. First, step S1101 is executed, in the first privilege level mode, a first jump-related instruction is executed. Step S1102 is executed, based on the execution of the first jump-related instruction, the first field of the first register is set to a first jump status parameter. Wherein, the first register is used in the first privilege level mode, and the first field of the first register is used to record the execution status of the first jump-related instruction.
[0076] Step S1103 is executed, and a first interrupt is received in the first privilege level mode. Step S1104 is executed, and based on the first interrupt, the value of the first field of the first register is stored in the second field of the first register. Step S1105 is executed, and the system enters the second privilege level mode. Step S1106 is executed, and a second jump-related instruction is executed in the second privilege level mode. Step S1107 is executed, and based on the execution of the second jump-related instruction, the first field of the first register is set to the second jump status parameter. The first register is used in the second privilege level mode.
[0077] Execute step S1108 to jump to the corresponding instruction in the specified register of the second jump-related instruction. Execute step S1109 to determine whether the corresponding instruction is a valid instruction. If step S1109 determines that the corresponding instruction is not a valid instruction, execute step S1118 to issue a warning message. If step S1109 determines that the corresponding instruction is a valid instruction, execute step S1110 to determine whether the parameter of the corresponding instruction is equal to the second jump status parameter of the first field of the first register.
[0078] If, in step S1110, it is determined that the parameter of the corresponding instruction is not equal to the second jump status parameter of the first field of the first register, step S1118 is executed, and a warning message is issued. If, in step S1110, it is determined that the parameter of the corresponding instruction is equal to the second jump status parameter of the first field of the first register, step S1111 is executed, and the execution of the program continues.
[0079] Execute step S1112 to return from the first interrupt. Execute step S1113 to store the value of the second field of the first register into the first field of the first register based on the execution of the first interrupt return. Execute step S1114 to jump to the corresponding instruction in the specified register of the first jump-related instruction. Execute step S1115 to determine whether the corresponding instruction is a valid instruction. If it is determined in step S1115 that the corresponding instruction is not a valid instruction, execute step S1118 to issue a warning message. If it is determined in step S1115 that the corresponding instruction is a valid instruction, execute step S1116 to determine whether the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register.
[0080] If in step S1116 it is determined that the parameter of the corresponding instruction is not equal to the first jump status parameter of the first field of the first register, then step S1118 is executed and a warning message is issued. If in step S1116 it is determined that the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register, then step S1117 is executed and the program continues to execute.
[0081] Some embodiments of this application include an attack detection method for a processor, the flowchart of which is shown below. Figures 12A to 12C As shown. The data manipulation methods of these embodiments are implemented by a processor (such as the processor in the previous embodiments), and the detailed steps of the method are as follows. First, step S1201 is executed, in the first privilege level mode, a first jump-related instruction is executed. Step S1202 is executed, based on the execution of the first jump-related instruction, the first field of the first register is set to a first jump status parameter. Wherein, the first register is used in the first privilege level mode, and the first field of the first register is used to record the execution status of the first jump-related instruction.
[0082] Step S1203 is executed, and a first interrupt is received in the first privilege level mode. Step S1204 is executed, and based on the first interrupt, the value of the first field of the first register is stored in the first field of the second register. The second register is used in the second privilege level mode. Step S1205 is executed, and the system enters the second privilege level mode. Step S1206 is executed, and a second jump-related instruction is executed in the second privilege level mode. Step S1207 is executed, and based on the execution of the second jump-related instruction, the second field of the second register is set to the second jump status parameter.
[0083] Execute step S1208 to jump to the corresponding instruction in the specified register of the second jump-related instruction. Execute step S1209 to determine whether the corresponding instruction is a valid instruction. If step S1209 determines that the corresponding instruction is not a valid instruction, execute step S1218 to issue a warning message. If step S1209 determines that the corresponding instruction is a valid instruction, execute step S1210 to determine whether the parameter of the corresponding instruction is equal to the second jump status parameter of the second field of the second register.
[0084] If, in step S1210, it is determined that the parameter of the corresponding instruction is not equal to the second jump status parameter of the second field of the second register, step S1218 is executed, and a warning message is issued. If, in step S1210, it is determined that the parameter of the corresponding instruction is equal to the second jump status parameter of the second field of the second register, step S1211 is executed, and program execution continues.
[0085] Execute step S1212 to return from the first interrupt. Execute step S1213 to store the value of the first field of the second register into the first field of the first register based on the execution of the first interrupt return. Execute step S1214 to jump to the corresponding instruction in the specified register of the first jump-related instruction. Execute step S1215 to determine whether the corresponding instruction is a valid instruction. If it is determined in step S1215 that the corresponding instruction is not a valid instruction, execute step S1218 to issue a warning message. If it is determined in step S1215 that the corresponding instruction is a valid instruction, execute step S1216 to determine whether the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register.
[0086] If, in step S1216, it is determined that the parameter of the corresponding instruction is not equal to the first jump status parameter of the first field of the first register, step S1218 is executed, and a warning message is issued. If, in step S1216, it is determined that the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register, step S1217 is executed, and the execution of the program continues.
[0087] Some embodiments of this application include an attack detection method for a processor, the flowchart of which is shown below. Figures 13A to 13BAs shown. The data manipulation methods of these embodiments are implemented by a processor (such as the processor in the previous embodiments), and the detailed steps of the method are as follows. First, step S1301 is executed, storing the value of the first register into the second register in the first privilege level mode. Step S1302 is executed, executing a first jump-related instruction in the first privilege level mode. Step S1303 is executed, setting the first field of the first register to a first jump status parameter based on the execution of the first jump-related instruction. Wherein, the first register is used in the first privilege level mode, and the first field of the first register is used to record the execution status of the first jump-related instruction.
[0088] Execute step S1304: Receive a first interrupt in the first privilege level mode. Execute step S1305: Based on the first interrupt, store the value of the first field of the first register into the second field of the first register. Execute step S1306: Enter the same privilege level mode (i.e., the first privilege level mode). Execute step S1307: Execute the first interrupt return. Execute step S1308: Based on the execution of the first interrupt return, store the value of the second field of the first register into the first field of the first register. Execute step S1309: Jump to the corresponding instruction in the specified register of the first jump-related instruction. Execute step S1310: Determine whether the corresponding instruction is a valid instruction. If it is determined in step S1310 that the corresponding instruction is not a valid instruction, execute step S1315: Issue a warning message. If it is determined in step S1310 that the corresponding instruction is a valid instruction, execute step S1311: Determine whether the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register.
[0089] If, in step S1311, it is determined that the parameter of the corresponding instruction is not equal to the first jump status parameter of the first field of the first register, step S1315 is executed, and a warning message is issued. If, in step S1311, it is determined that the parameter of the corresponding instruction is equal to the first jump status parameter of the first field of the first register, step S1312 is executed, and the corresponding instruction is executed. Step S1313 is executed, and the value of the second register is stored in the first register. Step S1314 is executed, and the execution of the program continues.
[0090] The processor and attack detection method of this application can effectively detect whether the corresponding instruction after the execution of the jump-related instruction is legal through the architecture of legal instructions, and further determine whether it may be subject to JOP attack based on the result, so as to decide whether to report the relevant exception handling.
[0091] The foregoing description briefly outlines the features of certain embodiments of this application, enabling those skilled in the art to more fully understand the various forms of this disclosure. Those skilled in the art will readily recognize that this disclosure serves as a basis for designing or modifying other processes and structures to achieve the same objectives and / or advantages as the embodiments described herein. Those skilled in the art should understand that these equivalent embodiments remain within the spirit and scope of this disclosure, and various changes, substitutions, and modifications can be made without departing from the spirit and scope of this disclosure.
Claims
1. An attack detection method for processors, characterized in that, include: Execute the first jump-related instructions in the first privilege level mode; Based on the execution of the first jump-related instruction, the first field of the first register is set to the first jump status parameter, wherein the first register is used for the first privilege level mode, and the first field of the first register is used to record the execution status of the first jump-related instruction; Jump to the first corresponding instruction in the specified register of the first jump-related instruction; The first judgment result is obtained by determining whether the first corresponding instruction is a valid instruction and whether the first parameter of the first corresponding instruction is equal to the first jump status parameter of the first field of the first register; and Whether to issue a warning message will be determined based on the first judgment result.
2. The attack detection method according to claim 1, characterized in that, When the first determination result is that the first corresponding instruction is not a legal instruction or the first parameter of the first corresponding instruction is not equal to the first jump status parameter of the first field of the first register, the warning message is issued. If the first determination result is that the first corresponding instruction is a valid instruction and the first parameter of the first corresponding instruction is equal to the first jump status parameter of the first field of the first register, the warning message is not issued.
3. The attack detection method according to claim 1, characterized in that, Also includes: The first interrupt was received in the first privileged mode; Based on the first interrupt, the value of the first field in the first register is stored in the second field of the first register; Returning from the first interrupt; Based on the execution of the first interrupt return, the value of the second field of the first register is stored in the first field of the first register.
4. The attack detection method according to claim 3, characterized in that, Also includes: Upon receiving the first interrupt, it enters the second privileged mode; Execute the second jump-related instructions in the second privilege level mode; Based on the execution of the second jump-related instruction, the first field of the first register is set to the second jump status parameter, wherein the first register is used for the second privilege level mode; Jump to the second corresponding instruction in the specified register of the second jump-related instruction; The second determination result is obtained by determining whether the second corresponding instruction is a valid instruction and whether the second parameter of the second corresponding instruction is equal to the second jump status parameter of the first field of the first register; and The decision on whether to issue the warning message is based on the second judgment result.
5. The attack detection method according to claim 4, characterized in that, Also includes: When the second determination result is that the second corresponding instruction is not a legal instruction or the second parameter of the second corresponding instruction is not equal to the second jump status parameter of the first field of the first register, the warning message is issued. If the second determination result is that the second corresponding instruction is a valid instruction and the second parameter of the second corresponding instruction is equal to the second jump status parameter of the first field of the first register, the warning message is not issued.
6. The attack detection method according to claim 3, characterized in that, Also includes: Before executing the first jump-related instruction, the value of the first register is stored in the second register.
7. The attack detection method according to claim 6, characterized in that, Also includes: When it is determined that the first corresponding instruction is a valid instruction, after executing the first corresponding instruction, the value of the second register is stored in the first register.
8. The attack detection method according to claim 1, characterized in that, Also includes: The first interrupt was received in the first privileged mode; Based on the first interrupt, the value of the first field in the first register is stored in the first field of the second register; Returning from the first interrupt; Based on the execution of the first interrupt return, the value of the first field in the second register is stored in the first field of the first register.
9. The attack detection method according to claim 8, characterized in that, Also includes: Upon receiving the first interrupt, it enters the second privileged mode; Execute the second jump-related instructions in the second privilege level mode; Based on the execution of the second jump-related instruction, the second field of the second register is set to the second jump status parameter, wherein the second register is used for the second privilege level mode; Jump to the second corresponding instruction in the specified register of the second jump-related instruction; The second determination result is obtained by determining whether the second corresponding instruction is a valid instruction and whether the second parameter of the second corresponding instruction is equal to the second jump status parameter of the second field of the second register; and The decision on whether to issue the warning message is based on the second judgment result.
10. The attack detection method according to claim 9, characterized in that, Also includes: When the second determination result is that the second corresponding instruction is not a valid instruction or the second parameter of the second corresponding instruction is not equal to the second jump status parameter of the second field of the second register, the warning message is issued. If the second determination result is that the second corresponding instruction is a valid instruction and the second parameter of the second corresponding instruction is equal to the second jump status parameter of the second field of the second register, the warning message is not issued.
11. A processor, characterized in that, include: The first register is used in the first privilege level mode; The execution unit, electrically connected to the first register, is used to: Execute the first jump-related instructions in the first privilege level mode; Based on the execution of the first jump-related instruction, the first field of the first register is set to the first jump status parameter, wherein the first field is used to record the execution status of the first jump-related instruction; Jump to the first corresponding instruction in the specified register of the first jump-related instruction; The first judgment result is obtained by determining whether the first corresponding instruction is a valid instruction and whether the first parameter of the first corresponding instruction is equal to the first jump status parameter of the first field of the first register; and Whether to issue a warning message will be determined based on the first judgment result.
12. The processor according to claim 11, characterized in that, The execution unit is also used for: When the first determination result is that the first corresponding instruction is not a legal instruction or the first parameter of the first corresponding instruction is not equal to the first jump status parameter of the first field of the first register, the warning message is issued. If the first determination result is that the first corresponding instruction is a valid instruction and the first parameter of the first corresponding instruction is equal to the first jump status parameter of the first field of the first register, the warning message is not issued.
13. The processor according to claim 11, characterized in that, The execution unit is also used for: The first interrupt was received in the first privileged mode; Based on the first interrupt, the value of the first field in the first register is stored in the second field of the first register; Returning from the first interrupt; Based on the execution of the first interrupt return, the value of the second field of the first register is stored in the first field of the first register.
14. The processor according to claim 13, characterized in that, The execution unit is also used for: Upon receiving the first interrupt, it enters the second privileged mode; Execute the second jump-related instructions in the second privilege level mode; Based on the execution of the second jump-related instruction, the first field of the first register is set to the second jump status parameter, wherein the first register is used for the second privilege level mode; Jump to the second corresponding instruction in the specified register of the second jump-related instruction; The second determination result is obtained by determining whether the second corresponding instruction is a valid instruction and whether the second parameter of the second corresponding instruction is equal to the second jump status parameter of the first field of the first register; and The decision on whether to issue the warning message is based on the second judgment result.
15. The processor according to claim 14, characterized in that, The execution unit is also used for: When the second determination result is that the second corresponding instruction is not a legal instruction or the second parameter of the second corresponding instruction is not equal to the second jump status parameter of the first field of the first register, the warning message is issued. If the second determination result is that the second corresponding instruction is a valid instruction and the second parameter of the second corresponding instruction is equal to the second jump status parameter of the first field of the first register, the warning message is not issued.
16. The processor according to claim 13, characterized in that, The execution unit is also used for: Before executing the first jump-related instruction, the value of the first register is stored in the second register; When it is determined that the first corresponding instruction is a valid instruction, after executing the first corresponding instruction, the value of the second register is stored in the first register.
17. The processor according to claim 11, characterized in that, The execution unit is also used for: The first interrupt was received in the first privileged mode; Based on the first interrupt, the value of the first field in the first register is stored in the first field of the second register; Returning from the first interrupt; Based on the execution of the first interrupt return, the value of the first field in the second register is stored in the first field of the first register.
18. The processor according to claim 17, characterized in that, The execution unit is also used for: Upon receiving the first interrupt, it enters the second privileged mode; Execute the second jump-related instructions in the second privilege level mode; Based on the execution of the second jump-related instruction, the second field of the second register is set to the second jump status parameter, wherein the second register is used for the second privilege level mode; Jump to the second corresponding instruction in the specified register of the second jump-related instruction; The second determination result is obtained by determining whether the second corresponding instruction is a valid instruction and whether the second parameter of the second corresponding instruction is equal to the second jump status parameter of the second field of the second register; and The decision on whether to issue the warning message is based on the second judgment result.
19. The processor according to claim 18, characterized in that, The execution unit is also used for: When the second determination result is that the second corresponding instruction is not a valid instruction or the second parameter of the second corresponding instruction is not equal to the second jump status parameter of the second field of the second register, the warning message is issued. If the second determination result is that the second corresponding instruction is a valid instruction and the second parameter of the second corresponding instruction is equal to the second jump status parameter of the second field of the second register, the warning message is not issued.
20. The processor according to claim 11, characterized in that, The first jump-related instruction includes: a jump instruction and a jump and link instruction. When the first jump-related instruction is the jump instruction, the first jump status parameter is a first value. When the first jump-related instruction is the jump and link instruction, the first jump status parameter is a second value. The first parameter of the first corresponding instruction being equal to the first value indicates that the first corresponding instruction corresponds to the jump instruction. The first parameter of the first corresponding instruction being equal to the second value indicates that the first corresponding instruction corresponds to the jump and link instruction. The first parameter of the first corresponding instruction being equal to the third value indicates that the first corresponding instruction corresponds to either the jump instruction or the jump and link instruction.
Citation Information
Patent Citations
Control flow integrity protection method and device
CN111898120A
Apparatus and method for detecting code reuse attack
KR1020180039830A
