Microprocessor and processing method of microprocessor

By using a context buffer and security ID-based branch prediction mechanism, the circuit scale and power consumption of microprocessors are reduced, and security vulnerabilities are mitigated, ensuring effective differentiation between legitimate and malicious program entries.

JP2024119606APending Publication Date: 2024-09-03FUJITSU LTD
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
JP2023026627
Authority / Receiving Office
JP · JP
Patent Type
Applications
Current Assignee / Owner
Filing Date
2023-02-22
Publication Date
2024-09-03

AI Technical Summary

Technical Problem

The inclusion of context and program ID in branch prediction mechanisms and prefetch control units results in an enormous circuit scale, increasing the area and power consumption of microprocessors, while also posing security vulnerabilities due to speculative execution of malicious programs.

Method used

Implement a context buffer with M entries storing execution contexts associated with a security ID, a context table processing unit, and a branch prediction mechanism that compares instruction addresses with security IDs to suppress circuit scale and prevent speculative execution of malicious instructions.

Benefits of technology

This approach effectively reduces the circuit scale and power consumption while preventing security vulnerabilities by distinguishing between legitimate and malicious program entries, thus enhancing processor security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 2024119606000001
    Figure 2024119606000001
Patent Text Reader

Abstract

To prevent a malicious program from performing speculative execution and to suppress a scale of a branch prediction buffer of a branch prediction mechanism.SOLUTION: Several bits of security ID associated with an execution context are registered in a context table, and an instruction address that is executed for a tag of an entry within a branch prediction buffer of a branch prediction mechanism and a security ID at execution time are stored. The branch prediction mechanism searches the entry within the branch prediction buffer using a branch prediction target instruction address and a security ID associated with the execution context at branch prediction time, and responds a branch target address of a correspondent entry to an instruction address generation unit. The number of bits of the security ID is lower than the number of bits of a program ID that identifies the execution context and a process which is included in the execution context.SELECTED DRAWING: Figure 5
Need to check novelty before this filing date? Find Prior Art

Description

[Technical field]

[0001] The present invention relates to a microprocessor (arithmetic processing device) and a processing method of the microprocessor. [Background technology]

[0002] A microprocessor is a semiconductor chip or a processing device in which a processing circuit is formed. Hereinafter, microprocessors will be abbreviated to "processors."

[0003] A microprocessor has circuits for speculatively executing memory accesses, such as a branch prediction mechanism and a prefetch control unit. The branch prediction mechanism predicts the branch destination address of a branch instruction based on the branch history, and prefetches and speculatively executes the instruction at the predicted branch destination address. The prefetch control unit predicts future memory access destinations, reads data at the predicted addresses from the main memory in advance, and registers them in a cache.

[0004] To explain the branch prediction mechanism, a processor executes processing in the order of program instructions. When executing a branch instruction (conditional branch, indirect branch, etc.), the branch destination address is determined depending on whether the condition of the conditional branch is satisfied or not, and the branch destination of the indirect branch is determined by the branch destination address in the indirect branch register. For any branch instruction, the instruction address of the branch destination is not determined until the processing of the instruction preceding the branch instruction is completed. To eliminate waste due to this waiting time, the branch prediction mechanism predicts whether the instruction at the address to be fetched from memory is a branch instruction, whether the branch instruction will branch, and where the branch destination address will be, and then speculatively executes instructions after the branch destination.

[0005] The prefetch control unit will now be described. When a processor accesses data continuously, if a cache miss occurs in the primary cache, it is necessary to access a lower cache or main memory to read the data. When reading data from a lower cache or main memory, the latency is long, and the waiting time is wasted. Therefore, when a memory access is performed and a cache miss occurs in the primary cache, the prefetch control unit stores the address, determines the address direction of the memory access based on the address of the next memory access, and predicts the address of the next memory access accordingly. Then, when data is prefetched at the predicted address, the prefetched data is stored in the primary cache. Therefore, when a memory access occurs later for the prefetched data, a cache hit is surely achieved in the primary cache, and the data can be fetched in a short time.

[0006] On the other hand, according to Non-Patent Document 1, speculative execution by a processor carries the risk of secret data being stolen by a malicious third party. That is, even instructions that are not executed by the original program are speculatively executed by a branch prediction mechanism or a prefetch mechanism. Therefore, secret data that is normally prohibited from being accessed is read by a speculatively executed load instruction, and when a load instruction with the read secret data as its address is speculatively executed, the load data is stored at the address of the secret data in the cache memory. After that, when the cache memory is scanned, the secret data is identified due to the short latency to the address of the secret data.

[0007] Patent Document 1 describes a countermeasure against the vulnerability of the above-mentioned processor, in which a context and program identification information (program ID) contained in the context are included in the branch history information of each entry of a buffer in a branch prediction mechanism, and branch prediction is performed based on the branch history information corresponding to the context and program ID of a running process. A context is parameter information linked to a process of a running program. This allows branch prediction based on branch history information left by a running program, and prevents speculative execution of an instruction at a branch target address of a branch history left by a malicious third party program. [Prior art documents] [Patent documents]

[0008] [Patent Document 1] Special Publication No. 2021-516384 [Patent Document 2] Special Publication No. 2021-524621 [Non-patent literature]

[0009] [Non-Patent Document 1] https: / / googleprojectzero.blogspot.jp / 2018 / 01 / reading-privileged-memory-with-side.html?m=1 Summary of the Invention [Problem to be solved by the invention]

[0010] However, the context and the program ID included in the context themselves have a long number of bits. The number of bits of the context is, for example, 100 bits or more, and the number of bits of the program ID is, for example, 16 bits or more. Meanwhile, the number of entries in the branch prediction buffer in the branch prediction mechanism is usually on the order of several hundred to several thousand. Therefore, if the context and the program ID are included in the branch history information of each entry in the buffer in the branch prediction mechanism, the circuit scale of the branch prediction mechanism will become enormous, leading to an increase in the area and power consumption of the processor. The prefetch mechanism also has a similar problem.

[0011] Therefore, an object of a first aspect of the present embodiment is to provide a processor and a processing method thereof that suppresses vulnerability while suppressing an increase in the circuit scale of a branch prediction mechanism and a prefetch control unit. [Means for solving the problem]

[0012] A first aspect of the present embodiment is a method for fetching an instruction from a memory controller, comprising: an instruction address generating unit that generates an instruction address that is a fetch destination of an instruction and outputs the instruction address to execute an instruction fetch; a context table processing unit including M first entries for storing execution contexts associated with processes and associated with security IDs capable of identifying the execution contexts, the context table processing unit extracting the security IDs associated with the execution contexts of a running process; a branch prediction buffer including a tag for storing a branch instruction address of a previously executed branch instruction and the security ID at the time when the branch instruction was executed, and N second entries for storing a branch target address of the previously executed branch instruction, wherein N is greater than M, and M and N are natural numbers of 2 or more; a branch prediction mechanism for comparing an instruction address output by the instruction address generation unit and the security ID extracted from the context table processing unit with the branch instruction address and the security ID in the tag of the second entry, and outputting the branch target address in the second entry that matches in the comparison to the instruction address generation unit, The instruction address generation unit is a microprocessor that executes the instruction fetch based on the branch target address output from the branch prediction mechanism. Effect of the Invention

[0013] According to the first aspect, it is possible to suppress an increase in the circuit scale of a branch prediction mechanism and a prefetch control unit while suppressing vulnerability. [Brief description of the drawings]

[0014] [Figure 1] FIG. 2 is a diagram illustrating an example of the configuration of a core of a processor. [Diagram 2] FIG. 2 illustrates an example of a branch prediction buffer in a branch prediction mechanism. [Diagram 3] FIG. 2 illustrates an example of a configuration of a core of a processor according to the first embodiment; [Figure 4] 2 is a diagram showing a first configuration example of a context table 26 in the present embodiment. FIG. [Diagram 5] 2 is a diagram illustrating an example of the configuration of a branch prediction mechanism 24 according to the present embodiment. [Figure 6] FIG. 2 is a diagram illustrating an example of a branch prediction buffer BR_PRD_BUF in the branch prediction mechanism. [Figure 7] FIG. 13 is a diagram illustrating a configuration of a context table in a modified example of the first embodiment. [Figure 8] FIG. 11 illustrates an example of a configuration of a core of a processor according to a second embodiment. [Figure 9] FIG. 13 is a diagram illustrating a first configuration example of a context table in the second embodiment. [Figure 10] FIG. 11 illustrates an example of a configuration of a branch prediction mechanism according to a second embodiment; [Figure 11] FIG. 13 is a diagram illustrating a modified example of the context table in the second embodiment. [Figure 12] FIG. 13 is a diagram illustrating a configuration of a core of a processor according to a third embodiment. [Figure 13]2 is a diagram illustrating an example of the configuration of a prefetch control unit 32 in the present embodiment. FIG. [Figure 14] FIG. 13 illustrates an example of a flowchart of the operation of the context table. [Figure 15] FIG. 13 is a diagram showing a first example of a context table and a TAG of a branch prediction mechanism that may have a security problem. [Figure 16] FIG. 13 is a diagram illustrating a second example of a context table and a TAG of a branch prediction mechanism that have a security problem. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0015] [Terminology definition] Processes: Running programs. Execution context: Information associated with a process; a collection of parameters such as an identifier that identifies the process, an identifier that identifies the virtual machine, and an identifier that identifies the privilege level. Program ID: It corresponds to the process identifier in the execution context. It has a long bit length, such as 16 bits or more. Security ID: An identifier associated with an execution context. An identifier that can identify a process in the same way as an execution context or program ID. It consists of fewer bits than an execution context or program ID. For example, it is a few bits.

[0016] [First embodiment] FIG. 1 is a diagram showing an example of the configuration of a processor core. Generally, a processor has multiple cores, a lower cache shared by the multiple cores, a memory access control unit that accesses a main memory, and an interface with the outside of the processor chip. The core CORE shown in FIG. 1 has an instruction address generation unit 10, a primary instruction cache 12, an instruction decoder 16, a reservation station 18, an arithmetic unit 20, a commit control unit 22, a program counter PC, a branch prediction mechanism 24, and the like, excluding the lower cache and main memory 100. The arithmetic unit 20 has an arithmetic circuit and a data cache unit. Of the lower cache and main memory 100 that are not included in the core, the lower cache is provided in the processor chip outside the core, and the main memory is provided outside the processor chip.

[0017] The instruction address generation unit 10 generates an instruction address to be fetched, and fetches an instruction at the generated instruction address INST_ADD_gen. The instruction address generation unit 10 sends a memory access request to fetch an instruction to the primary instruction cache 12, and searches the primary instruction cache with the instruction address. If there is a cache hit, the instruction INST in the primary instruction cache 12 is responded to the instruction decoder 16. If there is a cache miss, the primary instruction cache 12 transmits a memory access request to the lower cache 100, or transmits it to the external main memory 100 via a memory access control unit (not shown). The instruction INST read in response to this memory access request is responded to the instruction decoder 16.

[0018] The instruction decoder 16 decodes the received instruction INST in the order of the program, and transmits the decoded instruction D_INST to the reservation station 18, and also transmits an instruction identifier INST_ID indicating the order of the instruction INST to the commitment control unit 22. The instruction D_INST stored in the input queue of the reservation station is executed out of order by sending a processing request PRC_RQ for that instruction to the operation unit 20 in the order in which preparation for operation is completed.

[0019] When the arithmetic unit 20 finishes processing, it returns a processing completion PRC_CMP to the reservation station 18, and sends a completion notification CMP_NTF together with the instruction identifier to the commit control unit 22. The commit control unit 22 completes the instructions that have been processed in the order of the instructions in the program, and updates the resources used to process the instructions. If the instruction that has been processed is a branch instruction, the commit control unit 22 sends the instruction address, branch success or failure, and branch destination address as branch history information to the branch prediction mechanism 24. The branch prediction mechanism 24 stores the received branch history information in the branch prediction buffer 24_3.

[0020] Next, a description will be given of the instruction address generation process of the instruction address generation unit 10. The instruction address generation unit 10 selects an instruction address to be next fetched from the instruction address INST_ADD_pc in the program counter PC, the target address TAGT_ADD predicted by the branch prediction mechanism 24, etc., and executes the instruction fetch in the primary instruction cache 12.

[0021] Assuming that the order of a program is instruction A followed by branch instruction X, the start address of instruction A, which is the start instruction of the program, is stored in the program counter PC. The instruction address generation unit 10 issues an instruction fetch request (instruction read request) to the primary instruction cache 12 with the instruction address INST_ADD_pc of the PC as the fetch address INST_ADD_gen. In parallel with issuing the instruction fetch request, the instruction address generation unit 10 sends the fetch address INST_ADD_gen to the branch prediction mechanism 24.

[0022] In the branch prediction mechanism 24, the comparator 24_1 searches for the instruction address of the branch history stored in the branch prediction buffer 24_3 with the received fetch address INST_ADD_gen, and the branch prediction result generating unit 24_2 transmits the branch prediction result (including the branch hit / miss and the branch target address) to the instruction address generating unit 10 based on the branch target address TAGT_ADD in the entry in the branch prediction buffer 24_3 that stores the instruction address that matches the fetch address. In response to this, the instruction address generating unit 10 selects either the next instruction address of the fetch address INST_ADD_gen in the PC or the branch target address TAGT_ADD included in the branch prediction result based on the branch prediction result, and issues an instruction fetch. Since the instruction A is not a branch instruction, the branch prediction result is a branch miss, and the instruction address generating unit 10 selects the instruction address of the next instruction X of the instruction A (the instruction address INST_ADD_pc of the PC) and performs the instruction fetch.

[0023] When the instruction address generation unit 10 issues an instruction fetch with the instruction address of the branch instruction X, it sends the instruction address INST_ADD_gen to the branch prediction mechanism 24. When the branch prediction mechanism 24 receives the instruction address of the branch instruction X, it detects a branch hit in the branch prediction buffer 24_3 and sends a branch prediction result including a branch hit flag and a branch target address to the instruction address generation unit 10. The instruction address generation unit 10 then selects a branch target address and performs an instruction fetch to the primary instruction cache 12 based on the branch target address.

[0024] FIG. 2 is a diagram showing an example of a branch prediction buffer in a branch prediction mechanism. The example of the branch prediction buffer BR_PRD_BUF in FIG. 2 has 4096 entries (entry numbers 0 to 4095). In each entry ENTRY, a tag TAG in which an instruction address INST_ADD of a branch instruction executed in the past is stored as a branch history, a branch flag BR_FLG indicating the type of branch instruction, and a branch target address TAGT_ADD indicating the branch destination address of the branch instruction executed in the past are stored. The number of entries 4096 is an example, and a normal processor has several hundred to several thousand entries. Also, a valid bit for each entry is omitted.

[0025] The branch prediction mechanism 24 searches the tag of the entry in the branch prediction buffer, and the comparator 24_1 compares the fetch address INST_ADD_gen sent from the instruction address generation unit with the instruction address INST_ADD in the tag to detect an entry that stores an instruction address that matches the comparison. Then, the branch prediction result generation unit 24_2 transmits the branch target address TAGT_ADD in the detected entry to the instruction address generation unit 10 together with information on the branch match.

[0026] According to Non-Patent Document 1, if a malicious program registers the address of a load instruction to load secret data as a malicious fake branch history in the branch target address TAGT_ADD of an entry in the branch prediction buffer, the load instruction to the secret data is speculatively executed during execution of a regular program. Even if the address of the secret data is at a privilege level, it is read by the speculatively executed load instruction.

[0027] Patent document 1 describes a method in which the tag of the branch prediction buffer in Figure 2 stores execution context and program identification information (program ID) associated with a process, which is a running program, and isolates entries belonging to legitimate programs from entries belonging to malicious programs.

[0028] However, since the number of bits of the execution context and program identification information is usually large, ranging from several tens to several hundreds of bits, storing the execution context and program ID in several thousand entries of a branch prediction buffer in a branch prediction mechanism would undesirably enlarge the circuit scale of the branch prediction mechanism.

[0029] Fig. 3 is a diagram showing an example of the configuration of a processor core in the first embodiment. Similar to the example of the configuration of the core in Fig. 1, the core in Fig. 3 includes an instruction address generation unit 10, a primary instruction cache 12, an instruction decoder 16, a reservation station 18, an arithmetic unit 20, a commit control unit 22, a program counter PC, a branch prediction mechanism 24, and the like.

[0030] Unlike the core in FIG. 1, the core in FIG. 3 has a context table processing unit (hereinafter, for simplicity, referred to as a context table) 26. The context table 26 stores an execution context EX_CNTXT and a security ID that is linked to the execution context and can identify the execution context. The execution context and the security ID are as defined above. In addition, in the core in FIG. 3, each entry in the branch prediction buffer 24_3 in the branch prediction mechanism 24 stores a security ID in addition to an instruction address as tag information. Then, a comparator 24_1 compares the fetch address INST_ADD_gen of the instruction from the instruction address generation unit 10 and the security ID (SCR_ID) from the context table 26 with the instruction address and security ID of each entry in the branch prediction buffer 24_3 to search for a matching entry.

[0031] The general operation of the core in Fig. 3 will be described. When a program starts to be executed, the execution context EX_CNTXT of the program that has started to be executed is output from the system. The context table 26 registers the execution context EX_CNTXT in an empty entry in the context table by linking it to its security ID, extracts (outputs) the security ID linked to the execution context EX_CNTXT, and outputs a security ID extraction completion flag ID_TKOUT_CMP to the instruction address generation unit 10. This security ID extraction completion flag is a kind of valid bit of the output security ID.

[0032] When the fetch completion flag ID_TKOUT_CMP becomes true (completed), the instruction address generation unit 10 sends the instruction fetch address INST_ADD_gen to the branch prediction mechanism 24, and the branch prediction mechanism 24 searches the tag in the branch prediction buffer 24_3 for the fetch address INST_ADD_gen and the security ID (SCR_ID) to determine whether there is a matching entry. Since the tag of the entry in the branch prediction buffer stores the security ID at that time in addition to the branch instruction address executed in the past, it is possible to distinguish the entry of the branch history of the currently executing program from the entry of the branch history of a malicious program.

[0033] The security ID is, for example, a few bits, which is much smaller than the number of bits (tens to hundreds) of the execution context or program ID, so that an increase in the circuit scale of the branch prediction buffer in the branch prediction mechanism can be suppressed.

[0034] 4 is a diagram showing a first configuration example of the context table 26 in this embodiment. The context table 26 has a comparator 26_1, a selection circuit 26_2, and a context buffer CNTXT_BUF. The context buffer CNTXT_BUF has a plurality of entries ENTR_0 to ENTR_m-1 that respectively store an execution context EX_CNTXT, a security ID (SCR_ID) linked thereto, and a valid bit VLD. The number of entries M in this context buffer CNTXT_BUF is a number based on the number of bits of the security ID. For example, if the security ID is 2 bits, the number of entries M is a maximum of 2. 2 =4 is preferable.

[0035] 14 is a diagram showing an example of a flowchart of the operation of the context table. When the execution of a certain program is started and the execution context EX_CNTXT is switched (YES in S10), the context table 26 searches for an entry in the context buffer CNTXT_BUF with the switched execution context EX_CNTXT (S12). The comparator 26_1 compares the switched execution context EX_CNTXT with the execution context EX_CNTXT in each entry in the context buffer CNTXT_BUF, and if a matching entry exists, outputs the matching entry number MCH_ENTR_No. In this case, the execution context has been registered in the context buffer (YES in S14). Therefore, the selection circuit 26_2 extracts (outputs) the security ID (SCR_ID) of the matching entry number, and sets the security ID extraction completion flag ID_TKOUT_CMP to true (completed) (S16). The extracted security ID becomes the security ID associated with the current execution context.

[0036] If there is no entry in the context buffer that stores an execution context that matches the execution context EX_CNTXT and whose valid bit is true (valid), the comparator outputs a total mismatch A_UNMCH to the registration unit 26_4. In this case, the execution context is not registered in the context buffer (NO in S14). In response to the total mismatch A_UNMCH, if there is an invalid entry (NO in S18), the registration unit 26_4 newly registers the execution context EX_CNTXT after the switch and a security ID that can identify it in the invalid entry in the context buffer, and changes the valid bit VLD of the registered entry to true (valid) (S20). At the same time, the selection circuit 26_2 outputs the security ID and sets the security ID extraction completion flag ID_TKOUT_CMP to true (completed) (S16).

[0037] When the valid bits VLD of all the entries in the context table are true (valid) when the above-mentioned post-switch execution context is newly registered (YES in S18), the registration unit 26_4 overwrites one of the existing valid entries with the post-switch execution context and the security ID associated therewith (S22). If the security ID before the overwriting is subsequently registered in the context table again as a security ID associated with a different execution context, the branch prediction mechanism may not be able to distinguish the entry of the branch history of the currently executing program from the entry of the branch history of a malicious program, which may cause a security problem. This security problem will be described later with reference to FIG. 15.

[0038] Therefore, the registration unit 26_4 outputs an invalidation request INV_RQ having the security ID before the overwrite to the branch prediction mechanism 24 (S22). In response to the invalidation request INV_RQ, the branch prediction mechanism 24 invalidates entries in the branch prediction buffer BR_PRD_BUF that store at least the same security ID as the security ID before the overwrite. In response to the invalidation request, the branch prediction mechanism may invalidate all entries. Thereafter, the selection circuit 26_2 outputs the security ID and sets the security ID fetch completion flag to true (completed) (S16).

[0039] By making the security ID a few bits, the switched execution context and its security ID are frequently overwritten in the context table. Because the security ID is a few bits, there is a possibility that the security ID before and after the overwrite will match, so it is necessary to invalidate the entry of the branch prediction mechanism mentioned above. The invalidation request will be explained in detail in the explanation of the branch prediction mechanism.

[0040] Fig. 15 is a diagram showing a first example of a context table and a tag of a branch prediction mechanism having a security problem. Fig. 15 shows state transitions at times T1, T2, and T3. At time T1, security IDs SCR_ID_A and SCR_ID_B are registered in the context table in association with the respective execution contexts EX_CNTXT_A and EX_CNTXT_B. An example of a tag of the branch prediction mechanism at time T1 is as shown in the figure.

[0041] Next, at time T2, the execution context is changed to EX_CNTXT_C, and the unregistered security ID SCR_ID_C is overwritten on the registered entry SCR_ID_B. As a result, INST_ADD_C / SCR_ID_C is recorded as a new instruction address / security ID in the TAG entry of the branch prediction mechanism. In this state, there is no hit for a security ID (SCR_ID_B) different from the security ID SCR_ID_C associated with the execution context EX_CNTXT_C.

[0042] However, at time T3, the execution context is changed to EX_CNTXT_D, and the security ID (SCR_ID_B) that was not being registered at time T2 but was being registered at time T1 may be overwritten by the entry of SCR_ID_C being registered at time T2. In other words, the security ID (SCR_ID_B) is reused. This is because the number of bits in the security ID is small, so the same security ID (SCR_ID_B) is frequently reused.

[0043] As a result, at time T3, INST_ADD_D / SCR_ID_B is recorded as a new instruction address / security ID in the TAG entry of the branch prediction mechanism, and the security ID becomes the same as INST_ADD_B / SCR_ID_B in another TAG entry, causing a security problem.

[0044] Therefore, when the unregistered security ID SCR_ID_C is overwritten on the registered entry of SCR_ID_B at time T2, it is necessary to invalidate the entry of INST_ADD_B / SCR_ID_B from the TAG of the branch prediction mechanism.

[0045] Fig. 16 is a diagram showing a second example of a context table and a tag of a branch prediction mechanism having a security problem. Fig. 16 shows state transitions at times T11 and T12. At time T11, security IDs SCR_ID_A and SCR_ID_B are registered in the context table in association with the respective execution contexts EX_CNTXT_A and EX_CNTXT_B. An example of a tag of the branch prediction mechanism at time T11 is as shown in the figure.

[0046] Next, assume that at time T12, the execution context is changed to EX_CNTXT_C, and the entry for SCR_ID_B registered at time T11 is overwritten with the same security ID (SCR_ID_B). As a result, assume that INST_ADD_C / SCR_ID_B is recorded as a new instruction address / security ID in the entry for the TAG of the branch prediction mechanism. In this state, the security ID (SCR_ID_B) associated with the execution context EX_CNTXT_C and the security ID (SCR_ID_B) associated with the execution context EX_CNTXT_B are registered twice in the TAG of the branch prediction mechanism at time T12, which poses a security problem.

[0047] Therefore, even in this case, when an entry with the same security ID (SCR_ID_B) is overwritten in the context table at time T12, it is necessary to invalidate the entry with the security ID (SCR_ID_B) in the TAG of the branch prediction mechanism. In other words, in both cases where the security ID overwriting an entry in the context table matches the security ID of the entry to be overwritten and where it does not match, it is necessary to invalidate the entry with the security ID to be overwritten in the TAG of the branch prediction mechanism.

[0048] 5 is a diagram showing a configuration example of the branch prediction mechanism 24 in this embodiment. The branch prediction mechanism 24 has a comparator 24_1, a branch prediction result generating unit 24_2, a branch prediction buffer 24_3 (BR_PRD_BUF), and a branch taken prediction unit 24_4. As described in FIG. 2, the branch prediction buffer 24_3 has several hundred to several thousand entries, and each entry stores, in a tag TAG, an instruction address (or a part thereof) INST_ADD of a previously executed branch instruction, and a security ID (SCR_ID) associated with the execution context when the branch instruction was executed. Furthermore, each entry stores, as described in FIG. 2, a branch flag BR_FL and a target address TAGT_ADD, which is a branch destination address.

[0049] When the execution of the branch instruction is completed, in response to a completion notification CMP_NTF sent from the reservation station 18, the commit control unit 22 transmits a branch history update request BR_HST_UPDATE together with the branch history of the branch instruction (instruction address, branch flag, target address, branch success or failure, etc.) to the branch prediction mechanism 24. In response to the branch history update request, the branch history information and the security ID are registered in a free entry of the branch prediction buffer 24_3 (BR_PRD_BUF) in the branch prediction mechanism.

[0050] Fig. 6 is a diagram showing an example of a branch prediction buffer BR_PRD_BUF in a branch prediction mechanism. For comparison with Fig. 2, the branch prediction buffer in Fig. 6 also has 4096 entries, the same as Fig. 2. What is different from Fig. 2 is that the tag TAG of each entry stores the instruction address (or part of it) INST_ADD of a previously executed branch instruction, and a security ID (SCR_ID) linked to the execution context when the branch instruction was executed. Each entry stores a valid bit, but this is omitted in Fig. 6.

[0051] In the branch prediction buffer shown in Fig. 6, 4096 entries are arranged in ascending order of 2-bit security ID. As an example, 1024 entries E_SCR_ID_00 with security ID=00, 1024 entries E_SCR_ID_01 with security ID=01, 1024 entries E_SCR_ID_10 with security ID=10, and 1024 entries E_SCR_ID_11 with security ID=11 are arranged. In other words, the branch history (instruction address INST_ADD, branch flag BR_FLG indicating the type of instruction, target address TAGT_ADD) of branch instructions executed in the past in the program of the execution context associated with each security ID is stored in each of the 1024 entries for four types of security ID.

[0052] In an actual branch prediction buffer, the number of branch histories for branch instructions in multiple executed programs is different, and the number of entries in which branch histories are registered is different for each security ID. As an example, Figure 6 shows that the number of entries in which branch histories are registered is the same, 1024, for each of the four security IDs.

[0053] The M entries in the context table in Fig. 4 store the execution contexts of the most recent M programs associated with the M security IDs, respectively. Correspondingly, the entries in the branch prediction buffer BR_PRD_BUF in Fig. 5 and Fig. 6 store the branch history of branch instructions in the programs associated with the most recent M security IDs.

[0054] The operations of the context table 26, instruction address generation unit 10, and branch prediction mechanism 24 shown in Fig. 5 will be described below. When the context table 26 is able to extract (output) a security ID after (1) not registering the switched execution context EX_CNTXT because it has already been registered, (2) registering it in an invalid entry because it has not been registered, or (3) overwriting and registering it in a valid entry because it has not been registered, it outputs a valid security ID extraction completion flag ID_TKOUT_CMP to the instruction address generation unit 10. In response to this completion of valid extraction, the instruction address generation unit 10 starts operating.

[0055] The instruction address generation unit 10 issues an instruction fetch to the primary instruction cache with the generated instruction address INST_ADD_gen, and also sends the generated instruction address (or a part of it) INST_ADD_gen to the branch prediction mechanism 24 to make it predict the address of the instruction to be executed next. At this time, the security ID that is extracted from the context table 26 and registered in association with the execution context is also sent to the branch prediction mechanism 24.

[0056] The comparator 24_1 in the branch prediction mechanism compares the received instruction address (or part of it) and security ID with the instruction address (or part of it) and security ID in the tag section of all entries in the branch prediction buffer, and in the case of a mismatch UMCH, no branch prediction is performed, and the branch prediction result generation unit 24_2 returns the branch prediction result BR_PRD_RSLT of the branch miss BR_MISS to the instruction address generation unit 10.

[0057] On the other hand, if there is a match MCH in any entry, the branch prediction result generating unit 24_2 returns the branch prediction result BR_PRD_RSLT (including a branch hit or miss and a target address TAGT_ADD) to the instruction address generating unit 10 based on the match MCH from the comparator and the branch taken prediction from the branch taken predicting unit 24_4, etc. Then, the instruction address generating unit 10 generates an instruction address to be executed next based on the branch prediction result, and executes an instruction fetch.

[0058] The type of branch instruction of the branch flag BR_FLG is a conditional branch, an indirect branch, etc. The branch flag BR_FLG is used, for example, to check the type of branch instruction after the instruction decoder 16 decodes the fetched branch instruction.

[0059] As described above, when the valid bits VLD of all entries in the context table 26 are true (valid) when a new execution context after switching of the currently executing program is registered in the context table 26, the registration unit 26_4 overwrites one of the existing valid entries with the execution context after switching and the security ID associated therewith. As described in FIG. 15, if the security ID before the overwrite is subsequently registered in the context table again as a security ID associated with a different execution context, there is a possibility that the branch prediction mechanism will not be able to distinguish an entry of the branch history of the currently executing program from an entry of the branch history of a malicious program. Also, as described in FIG. 16, if the security ID to be overwritten is the same as the security ID of the entry to be overwritten, a similar security problem will naturally occur.

[0060] Therefore, when the valid bits VLD of all the entries in the context table are true (valid) at the time of new registration, the registration unit 26_4 in the context table sends an invalidation request INV_RQ including the security ID before overwriting to the branch prediction mechanism 24. In response to the invalidation request IVLD_RQ, the branch prediction mechanism 24 invalidates at least the entries in the branch prediction buffer BR_PRD_BUF that store the security ID before overwriting. Alternatively, the branch prediction mechanism 24 may invalidate all the entries in the branch prediction buffer. After completing the invalidation of the entries in the branch prediction mechanism 24, the branch prediction mechanism starts the prediction process of the instruction address. This makes it possible to prevent the branch prediction mechanism from responding to the instruction address generation unit with the target address of the branch destination as the branch prediction result based on the branch history registered by a malicious program.

[0061] On the other hand, when the registration unit 26_4 in the context table 26 newly registers the execution context after the switching, the registration unit 26_4 generates a security ID associated with the execution context. The registration unit may generate the security ID in ascending or descending order, or may generate the security ID randomly.

[0062] When security IDs are generated in ascending order, for example, 00, 01, 10, and 11 when the security ID is 2 bits, the security ID to be overwritten will not match the security ID before the overwrite while the security ID goes around in a circle. Therefore, the registration unit 26_4 sends an invalidation request to the branch prediction mechanism 24 only when the security ID goes around in a circle and generates 00 again. In this case, in response to the invalidation request, the branch prediction mechanism invalidates all entries in the branch prediction buffer. This reduces the frequency of invalidation processing.

[0063] Furthermore, when a security ID is generated randomly, the registration unit does not assign a security ID currently registered in the context table to a newly generated security ID. If a security ID currently registered in the context table is assigned to a newly generated security ID, the registration unit must overwrite the entry of the currently registered security ID in the context table to prevent multiple entries in the context table in which the same security ID is associated with different execution contexts.

[0064] 16, when the registration unit 26_4 overwrites the above-mentioned execution context and security ID to a valid entry in which the same security ID is being registered, it sends an invalidation request IVLD_RQ having the security ID before the overwrite to the branch prediction mechanism 24. In this case, in response to the invalidation request IVLD_RQ, the branch prediction mechanism 24 invalidates the entry in the branch prediction buffer BR_PRD_BUF that stores the security ID before the overwrite, or invalidates all the entries in the branch prediction buffer BR_PRD_BUF.

[0065] [Modification of the first embodiment] FIG. 7 is a diagram showing a configuration of a context table in a modified example of the first embodiment. The context table 26 in FIG. 7 uses entry numbers ENTR_0 to ENTR_m-1 in the context buffer CNTXT_BUF as security IDs (SCR_ID). In this modified example, it is preferable that the registration unit of the context table newly registers the execution context EX_CNTXT after switching in the order of entry numbers (ascending or descending order) in response to the all-mismatch A_UNMCH from the selection circuit 26_2. In the case of new registration in the order of entry numbers, when the entry numbers go around once (entry number m-1 in the case of ascending order, entry number 0 in the case of descending order), when the execution context is newly registered in the next entry, the registration unit 26_4 outputs an invalidation request INVD_RQ to the branch prediction mechanism 24 to have the branch prediction mechanism 24 invalidate all entries in the branch prediction buffer. The next entry number after going around the entry numbers does not have to be fixed to 0 in ascending order or m-1 in descending order, but may be registered at any entry number and then further registered in ascending or descending order, or in any other order.

[0066] According to this modification, it is possible to reduce the number of bits of an entry in the context table 26, thereby suppressing the circuit resources of the context table. In this modification, an instruction address and an entry number of the context table are registered in the tag of an entry of the branch prediction buffer in the branch prediction mechanism.

[0067] Other than the above, the operations of the context table and the branch prediction mechanism are the same as those in the first embodiment.

[0068] [Second embodiment] 8 is a diagram showing an example of a configuration of a processor core in the second embodiment. The difference from the core configuration example in FIG. 3 is that the security ID associated with the execution context has a second security ID2 (SCR_ID2) in addition to the first security ID (SCR_ID) same as in the first embodiment. Therefore, the entry of the context buffer in the context table 26 stores the execution context and the first security ID (SCR_ID) and second security ID2 (SCR_ID2) associated therewith. Meanwhile, the tag of the branch prediction buffer in the branch prediction mechanism 24 stores a hash value obtained by hashing the instruction address (or a part thereof) with the second security ID2 (SCR_ID2) and the first security ID (SCR_ID).

[0069] Fig. 9 is a diagram showing a first configuration example of a context table in the second embodiment. As shown in Fig. 9, in each entry in the context buffer, an execution context EX_CNTXT, a valid bit VLD, and a first security ID (SCR_ID) and a second security ID2 (SCR_ID2) are registered as a security ID with a small number of bits associated with the execution context. It is preferable to generate the second security ID2 (SCR_ID2) randomly. However, the second security ID2 (SCR_ID2) may be generated by any method, such as by simple addition and subtraction, or by generating it in ascending or descending order.

[0070] However, since the tag of the branch prediction buffer stores a hash generated by hashing the instruction address (or part of it) with the second security ID2 (SCR_ID2), the number of bits of the tag does not increase, and there is no increase in the circuit size of the buffer of the branch prediction mechanism compared to the first embodiment.

[0071] In the second embodiment, the second security ID2 is generated randomly, and the first and second security IDs (combinations of SCR_ID and SCR_ID2) are randomly assigned, making it unnecessary to issue an invalidation request INVD_RQ to be sent to the branch prediction mechanism. That is, even if a malicious program can generate a security ID that matches the first security ID (SCR_ID) generated in ascending or descending order, it is practically impossible to generate a security ID that matches the randomly generated second security ID2 (SCR_ID2). Therefore, there is practically no need to invalidate the TAG entry of the branch prediction mechanism. When the first security ID (SCR_ID) is assigned in ascending or descending order, the first security ID can be hit by executing a malicious program for the number of combinations of all bits, so that it is necessary to invalidate the TAG entry of the branch prediction mechanism.

[0072] When the post-switch execution context EX_CNTXT is output from the system side, the context table 26 searches the context table for the post-switch execution context, and if an entry exists which stores the same execution context as the post-switch execution context and has a valid bit VLD=1 (valid), it extracts the first security ID (SCR_ID) and second security ID2 (SCR_ID2) from that entry and outputs an ID extraction completion flag ID_TKOUT_CMP to the instruction address generation unit 10.

[0073] If there is no entry that stores the same execution context as the post-switching execution context and has a valid bit of VLD=1 (valid), the context table newly registers the post-switching execution context and the first security ID (SCR_ID) and second security ID2 (SCR_ID2) associated with it in an entry. In this case, if there is an entry with a valid bit of VLD=0 (invalid), it is registered in that entry. If there is only an entry with a valid bit of VLD=1 (valid), it is overwritten and registered in one of the entries. Then, the context table sets the valid bit of the registered entry to VLD=1 (valid), and extracts the first security ID (SCR_ID) and second security ID2 (SCR_ID2) associated with the execution context.

[0074] Fig. 10 is a diagram showing a configuration example of a branch prediction mechanism in the second embodiment. As tags for entries in the branch prediction buffer BR_PRD_BUF, a hash HASH of an instruction address (or a part thereof) INST_ADD and a second security ID2 (SCR_ID2), and a first security ID (SCR_ID) are registered. For this purpose, a hash calculator 24_5 is provided. The fact that a branch flag BR_FLG and a branch target address TAGT_ADD are registered in an entry, and that a comparator 24_1 and a branch taken prediction unit 24_4 are provided are the same as those in the first embodiment of Fig. 5.

[0075] When a branch instruction is completed, the commit control unit 22 sends a branch history update request BR_HST_UPDATE to the branch prediction mechanism 24, and registers the branch history attached to the branch history update request in an entry in the branch prediction buffer. At this time, the hash calculator 24_5 in the branch prediction mechanism hash-calculates the instruction address (or a part thereof) of the executed branch instruction included in the branch history with the second security ID2 (SCR_ID2) extracted from the context table, and the hash value HASH and the first security ID (SCR_ID) are registered in the tag of the entry, and the valid bit VLD is enabled. The branch flag BR_FLG and the target address TAGT_ADD are also registered in the same manner as in FIG. 5.

[0076] The instruction address INST_ADD_gen generated by the instruction address generation unit 10 is sent to the branch prediction mechanism 24, which predicts the next instruction address. At this time, the first and second security IDs, ID2 (SCR_ID, SCR_ID2), associated with the currently executed execution context retrieved from the context table 26, are output to the branch prediction mechanism. The comparator 24_1 causes the hash calculator 24_5 to perform a hash operation on the instruction address (or a part thereof) INST_ADD_gen with the second security ID2 (SCR_ID2), and compares the hash value HASH and the first security ID (SCR_ID) with the tag of the entry in the branch prediction buffer.

[0077] If the comparison result is a mismatch UMCH, the branch prediction result generating unit 24_2 of the branch prediction mechanism returns a branch prediction result (including a branch miss BR_MISS) BR_PRD_RSULT to the instruction address generating unit 10. In response to this, the instruction address generating unit issues an instruction fetch to the primary instruction cache at the instruction address next to the current instruction address INST_ADD_gen.

[0078] On the other hand, if the comparison result is a match MCH, the branch prediction result generating unit 24_2 returns the branch prediction result BR_PRD_RSULT (including the branch hit BR_HIT and the target address TAGT_ADD) to the instruction address generating unit. In response to this, the instruction address generating unit fetches an instruction from the primary instruction cache using the target address TAGT_ADD.

[0079] 9 generates a first security ID (SCR_ID) and a second security ID2 (SCR_ID2) when a new execution context is registered. Moreover, since the number of bits of the hash of the instruction address (or a part thereof) and the second security ID2 (SCR_ID2) is the same as or less than the number of bits of the instruction address (or a part thereof), the number of bits of the tag of the branch prediction buffer of the branch prediction mechanism does not increase.

[0080] Fig. 11 is a diagram showing a modified example of the context table in the second embodiment. The context table in Fig. 11 uses entry numbers ENTR_0 to ENTR_m-1 of the context buffer as the first security ID. This corresponds to the modified example of Fig. 7 of the first embodiment.

[0081] 7, in this modification, it is preferable that the registration unit 26_4 of the context table newly registers the execution context EX_CNTXT after switching in the order of entry numbers (ascending or descending order) in response to the total mismatch A_UNMCH from the selection circuit 26_2. When newly registering in the order of entry numbers, when the entry numbers go around once (m-1 in the case of ascending order, 0 in the case of descending order), before newly registering the execution context in the next entry, the registration unit 26_4 outputs an invalidation request INVD_RQ to the branch prediction mechanism 24 to cause the branch prediction mechanism 24 to invalidate all entries in the branch prediction buffer.

[0082] Other than the above, the operations of the context table and the branch prediction mechanism are the same as those in the first embodiment.

[0083] According to this modification, it is possible to reduce the number of bits of an entry in the context table 26, thereby suppressing the circuit resources of the context table. In this modification, the instruction address (or a part thereof), the hash of the second security ID2 (SCR_ID2), and the entry number ENTR_NO of the context table are registered in the tag of the entry of the branch prediction buffer in the branch prediction mechanism.

[0084] [Third embodiment] Fig. 12 is a diagram showing the configuration of a processor core in the third embodiment. The core in Fig. 12 has the arithmetic unit 20, context table 26, lower cache, and main memory 100, which are also shown in Fig. 3. The core also has an operand address generation unit 30, a first data cache 31, and a prefetch control unit 32.

[0085] In the case of a memory access instruction such as a load / store instruction, the decoded memory access instruction is sent to the reservation station, which issues a process to the operand address generation unit 30. The operand address generation unit 30 issues a data request to the primary data cache 31 with the operand address of the memory access instruction to execute a data fetch. When a cache hit occurs in the primary data cache, the hit data is returned as a data response to the arithmetic unit 20. On the other hand, when a cache miss occurs, a data request is issued to a lower cache or the main memory 100. Then, the data response from the lower cache or the main memory 100 is sent to the primary data cache 31 to register the data in the cache, and further, the data response is sent from the primary data cache to the arithmetic unit 20. As a result, the arithmetic unit 20 stores the received data in a specified register, and executes a subsequent arithmetic instruction or the like for the data in the register.

[0086] When a memory access instruction accesses multiple addresses consecutively, the prefetch control unit 32 prefetches data of addresses consecutive to the address where a cache miss occurred from a lower cache or the main memory 100, and registers the read data in advance in the primary data cache. As a result, in response to a data request of a memory access instruction executed thereafter, a cache hit occurs in the primary data cache, and a data response arrives at the calculation unit 20 with a short latency.

[0087] The prefetching of data performed by the prefetch control unit 32 is a speculative memory access. Therefore, it is conceivable that a malicious program may attempt to access data in a memory area that is prohibited from being accessed by using the speculative memory access of the prefetch function. In the third embodiment, the speculative memory access of the prefetch control unit is permitted only during the execution of a normal program.

[0088] 13 is a diagram showing an example of the configuration of the prefetch control unit 32 in this embodiment. The prefetch control unit 32 has a comparator 32_1, a prefetch determination unit 32_2, a prefetch queue PRF_QUE, and an address generator ADD_GEN. To briefly explain the operation of the prefetch control unit 32, when the operand address generation unit 30 issues a data request to the primary data cache with an operand address OPR_ADD1 of a certain memory access instruction and a cache miss occurs, the operand address OPR_ADD1 that has caused the cache miss is stored in the tag of an entry of the prefetch queue PRF_QUE.

[0089] When data access to consecutive addresses is executed, a data request by the next prefetch address PRF_ADD2 also causes a cache miss in the primary data cache. A comparator 32_1 in the prefetch control unit 32 judges whether the second prefetch address PRF_ADD2 is an address in the plus direction (+1) or the minus direction (-1) of the first prefetch address PRF_ADD1 registered in the tag of the prefetch queue PRF_QUE. In the example of Fig. 13, the address generator ADD_GEN generates an address ADD1+1, which is +1, and an address ADD1-1, which is -1, for the first operand address OPR_ADD1 registered in the tag, and the comparator 32_1 compares the operand address OPR_ADD output by the operand address generation unit 30 with the addresses ADD1+1 and ADD1-1 generated by the address generator, respectively. If it matches the address ADD1+1, it determines that the data access is an access to an address in ascending order, and if it matches the address ADD1-1, it determines that the data access is an access to an address in descending order. Then, based on the determination result, the prefetch control unit 32 updates the operand address OPR_ADD in the tag of the entry in the prefetch queue PRF_QUE to ADD1+1 or ADD1-1.

[0090] Based on the above determination, the prefetch determination unit 32_2 issues a prefetch request to the lower cache or main memory at address ADD1+2 if the order is ascending, and issues a prefetch request at address ADD1-2 if the order is descending. This prefetch request is a kind of speculative memory access. Since the prefetched data is registered in the primary data cache 31, when the operand address generation unit 30 subsequently issues a data request to the address of the prefetched data, a cache hit is always obtained in the primary data cache, and the latency of the data fetch is shortened.

[0091] In the next cycle, since the updated operand address OPR_ADD in the prefetch queue PRF_QUE is ADD1+1 or ADD1-1, the comparator 32_1 judges whether the operand address OPR_ADD output by the operand address generation unit 30 matches the address ADD1+2 in the operand queue (or matches ADD1-2). If the judgment result is a match MCH, the prefetch judgment unit 32_2 issues a prefetch request to the address ADD1+3 (or ADD1-3).

[0092] A malicious program registers a desired operand address in the tag of the prefetch queue PRF_QUE and attempts to access data that is prohibited from being accessed by a speculative prefetch request during execution of a legitimate program.

[0093] Therefore, the processor core of the third embodiment has a context table 26, and similarly to FIG. 4, associates the execution context provided from the system when a program starts to execute with a security ID that can identify the execution context, stores it in an entry in the context table, extracts the security ID, and enables the security ID extraction completion flag ID_TKOUT_CMP.

[0094] On the other hand, when a cache miss occurs in the primary data cache for a data request issued by the operand address generation unit, a cache miss $MISS is sent to the prefetch control unit 32 along with the operand address OPR_ADD that has been missed, and in response to the cache miss, the prefetch control unit 32 registers the operand address OPR_ADD together with the security ID (SCR_ID) being retrieved from the context table in the tag of an entry in the prefetch queue PRF_QUE.

[0095] When the operand address generation unit 30 issues a data request with a certain operand address, the comparator 32_1 and prefetch determination unit 32_2 of the prefetch control unit 32 perform the above-mentioned prefetch control and speculatively execute the prefetch request PRF_RQ.

[0096] As in the first embodiment, when the context table issues an invalidation request INVD_RQ (with or without a security ID) when registering a new execution context in a valid entry in the context buffer, the prefetch control unit invalidates at least the entries in the prefetch queue PRR_QUE that store the same security ID as the security ID of the invalidation request, or invalidates all entries in the prefetch queue.

[0097] The context table of the third embodiment may have any of the configurations shown in Figures 4, 7, 9, and 11. The tag information of the entries of the prefetch queue in the prefetch control unit is also equivalent to the previously described examples corresponding to the configurations of the context tables in Figures 4, 7, 9, and 11.

[0098] According to the above embodiment, the execution context and a security ID with a small number of bits associated therewith are stored in the context table, and the address and the security ID are stored in the tag of an entry in the branch prediction buffer of the branch prediction mechanism and the tag of an entry in the prefetch queue of the prefetch control unit. This makes it possible to distinguish between entries registered by a legitimate program and entries registered by a malicious program in branch prediction by the branch prediction mechanism, and further reduces the circuit scale of the branch prediction buffer. Also, in prefetch judgment by the prefetch control unit, it is possible to distinguish between entries registered by a legitimate program and entries registered by a malicious program, and further reduces the circuit scale of the prefetch queue.

[0099] According to the above embodiment, the number of bits of the security ID is small, and the number of security IDs that can be registered in the context table is small. Therefore, when a new execution context and its security ID are overwritten in the context table, at least the entries that store the security ID before the overwrite among the entries of the buffer in the branch prediction mechanism and the prefetch control unit are invalidated. This makes it possible to reliably distinguish between entries registered by a legitimate program and entries registered by a malicious program. [Explanation of symbols]

[0100] 10: Instruction address generator 12: Primary instruction cache 24: Branch prediction mechanism 24_3, BR_PRD_BUF: Branch prediction buffer 26: Context table EX_CNTXT: Execution context SCR_ID, SCR_ID2: Security ID 30: Operand address generation unit 31: Primary data cache 32: Prefetch control unit PRF_QUE: Prefetch queue

Claims

1. an instruction address generating unit that generates an instruction address that is a destination of an instruction and outputs the instruction address to execute an instruction fetch; a context table processing unit including M first entries for storing execution contexts associated with processes and associated with security IDs capable of identifying the execution contexts, the context table processing unit extracting the security IDs associated with the execution contexts of a running process; a branch prediction buffer including a tag for storing a branch instruction address of a previously executed branch instruction and the security ID at the time when the branch instruction was executed, and N second entries for storing branch target addresses of the previously executed branch instructions, respectively, wherein the N is greater than the M, and the M and N are natural numbers equal to or greater than 2; comparing the instruction address output by the instruction address generation unit and the security ID extracted from the context table processing unit with the branch instruction address and the security ID in the tag of the second entry; a branch prediction mechanism that outputs the branch target address in the second entry that matches in the comparison to the instruction address generation unit, The instruction address generation unit executes the instruction fetch based on the branch target address output from the branch prediction mechanism.

2. The context table processing unit When the execution context is switched, searching the M first entries in the switched execution context; If the switched execution context is registered in any of the first entries, the security ID in the hit first entry is retrieved; If the registration has not been made and the first entry has a vacant entry, the switched execution context is associated with a security ID that identifies the switched execution context, and the associated security ID is registered in a vacant entry of the first entry, and the registered security ID is extracted. if the registration has not been made and there is no free space in the first entry, the switched execution context is associated with a security ID that identifies the switched execution context, and the switched execution context is overwritten and registered in the first entry, and an invalidation request is sent to the branch prediction mechanism; 2. The microprocessor according to claim 1, wherein said branch prediction mechanism, in response to said invalidation request, invalidates at least said second entry that stores said original security ID that was overwritten and registered.

3. The context table processing unit When overwriting and registering the first entry, the security ID is updated in ascending or descending order, and the updated security ID is associated with the switched execution context and overwritten and registered in the first entry; When the security ID has been updated once, an invalidation request for invalidating all of the second entries is sent to the branch prediction mechanism; 3. The microprocessor of claim 2, wherein said branch prediction mechanism is responsive to said invalidation request to invalidate all of said second entries.

4. the security ID is the entry number of the first entry, 4. The microprocessor according to claim 3, wherein said context table processing unit updates, when overwriting and registering in said first entry, said entry number of said first entry as said security ID in ascending order or descending order.

5. the context table processing unit further stores an additional security ID associated with the execution context in each of the M first entries; 2. The microprocessor of claim 1, wherein said branch prediction mechanism stores said instruction address, a hash of said additional security ID, and said security ID in a tag of each of said N second entries.

6. The context table processing unit When the execution context is switched, searching the M first entries in the switched execution context; If the switched execution context is registered in any of the first entries, the security ID and the additional security ID in the hit first entry are retrieved; If the registration has not been made and there is a vacant entry in the first entry, the switched execution context is associated with a security ID and an additional security for identifying the switched execution context, and registered in a vacant entry in the first entry, and the registered security ID and additional security ID are extracted.

6. The microprocessor according to claim 5, wherein if the registration has not been made and there is no space in the first entry, the switched execution context is linked to a security ID and additional security that identify the switched execution context and overwrites and registers it in the first entry.

7. 2. The microprocessor of claim 1, wherein the number of bits of the security ID is less than the number of bits of a program ID that identifies the execution context and the process included in the execution context.

8. an operand address generation unit that generates an operand address that is a data fetch destination and outputs the operand address to execute data fetch; a context table processing unit including M first entries for storing execution contexts associated with processes and associated with security IDs capable of identifying the execution contexts, the context table processing unit extracting the security IDs associated with the execution contexts of a running process; a prefetch queue including N second entries for storing an operand address when a cache miss occurs in a primary data cache in response to a data request to fetch data and a tag for storing the security ID when the data request is executed, the N being greater than the M, and the M and N being natural numbers equal to or greater than 2; comparing the operand address output by the operand address processor and the security ID extracted from the context table processing unit with a pair of operand addresses and the security ID adjacent to the operand address in the tag of the second entry; a prefetch control unit that executes data prefetch in a cache lower than the primary data cache or in a main memory based on the operand address that matches in the comparison out of the pair of operand addresses.

9. an instruction address generating unit that generates an instruction address that is a destination of an instruction and outputs the instruction address to execute an instruction fetch; a context table processing unit including M first entries for storing execution contexts associated with processes and associated with security IDs capable of identifying the execution contexts, the context table processing unit extracting the security IDs associated with the execution contexts of a running process; a branch prediction mechanism having a branch prediction buffer including N second entries, said N being greater than said M, said M and said N being natural numbers equal to or greater than 2; The branch prediction mechanism includes: storing a tag for storing a branch instruction address of a previously executed branch instruction and the security ID at the time when the branch instruction was executed, and a branch target address of the previously executed branch instruction in each of the N second entries; comparing the instruction address output by the instruction address generation unit and the security ID extracted from the context table processing unit with the branch instruction address and the security ID in the tag of the second entry; outputting the branch target address in the second entry that matches in the comparison to the instruction address generation unit; A processing method for a microprocessor, wherein the instruction address generation unit executes the instruction fetch based on the branch target address output from the branch prediction mechanism.

10. an operand address generation unit that generates an operand address that is a data fetch destination and outputs the operand address to execute data fetch; a context table processing unit including M first entries for storing execution contexts associated with processes and associated with security IDs capable of identifying the execution contexts, the context table processing unit extracting the security IDs associated with the execution contexts of a running process; a prefetch control unit having a prefetch queue including N second entries, the N being greater than the M, and the M and N being natural numbers equal to or greater than 2; The prefetch control unit storing, in each of the N second entries, an operand address when a cache miss occurs in a primary data cache in response to a data request to fetch data and the security ID when the data request is executed; comparing the operand address output by the operand address processor and the security ID extracted from the context table processing unit with a pair of operand addresses and the security ID adjacent to the operand address in the tag of the second entry; A processing method of a microprocessor, comprising: executing data prefetch in a cache lower than the primary data cache or in a main memory based on the operand address of the pair of operand addresses that matches in the comparison.

Citation Information

Patent Citations

  • Encoding the input to the branch prediction circuit

    JP2021504800A

  • Branch prediction cache for multiple software workloads

    JP2021524621A

  • Encoding of input to storage circuitry

    US20190163902A1

  • Pipelines for Secure Multithread Execution

    US20220229667A1

  • Secure control flow prediction

    US20220292183A1