Microprocessor and microprocessor processing method
The microprocessor employs a security ID-based branch prediction mechanism to mitigate speculative execution vulnerabilities, reducing circuit scale and ensuring secure data access while maintaining efficiency.
Patent Information
- Application Number
- PCT/JP2024/001225
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-02-22
- Filing Date
- 2024-01-18
- Publication Date
- 2024-08-29
AI Technical Summary
Existing microprocessor designs face vulnerabilities due to speculative execution, which can lead to the exposure of secret data, and the inclusion of context and program ID in branch prediction mechanisms results in an enormous circuit scale, increasing power consumption and area.
A microprocessor with an instruction address generation unit, a context buffer, and a branch prediction mechanism that uses a security ID to differentiate between legitimate and malicious branch history entries, reducing the circuit scale by using a smaller security ID instead of lengthy context and program IDs.
This approach effectively suppresses vulnerabilities while maintaining a reduced circuit scale, preventing speculative execution of malicious instructions and ensuring secure data access without excessive power or area increase.
Smart Images

Figure JP2024001225_29082024_PF_FP_ABST
Abstract
Description
Microprocessor and processing method thereof
[0001] The present invention relates to a microprocessor (arithmetic processing unit) and a processing method for a microprocessor.
[0002] A microprocessor is a semiconductor chip or processing unit on which a processing circuit is formed. Hereinafter, the term "microprocessor" will be abbreviated to "processor."
[0003] A microprocessor has circuits that speculatively execute 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 the data at the predicted address from main memory in advance, and registers it in a cache.
[0004] To explain the branch prediction mechanism, a processor executes program instructions in order. When a branch instruction (conditional branch, indirect branch, etc.) is executed, the branch destination address is determined depending on whether the condition of the conditional branch is satisfied, and the branch destination of the indirect branch is determined based on the branch destination address in the indirect branch register. For any branch instruction, the branch destination instruction address 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 what the branch destination address will be, and then speculatively executes instructions after the branch destination.
[0005] To explain the prefetch control unit, when a processor accesses data continuously, if a cache miss occurs in the primary cache, it must access a lower-level cache or main memory to read the data. Reading data from a lower-level cache or main memory involves a long latency, and this 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 thereby predicts the address of the next memory access. Then, when data is prefetched at the predicted address, the prefetched data is stored in the primary cache. Therefore, when a memory access occurs thereafter for the prefetched data, a cache hit in the primary cache is reliably achieved, 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. In other words, even instructions that are not executed by the original program are speculatively executed using a branch prediction mechanism or a prefetch mechanism. Therefore, secret data that is normally prohibited from access is read by a speculatively executed load instruction, and when a load instruction using the read secret data as an address is speculatively executed, the load data is stored at the secret data address in the cache memory. Then, by scanning the cache memory, the secret data can be identified due to the short latency to the secret data address.
[0007] Patent Document 1 describes a countermeasure to the above-mentioned processor vulnerability in which a context and program identification information (program ID) included in the context are included in the branch history information of each entry in 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 the currently running process. The context is parameter information linked to the process of the currently running program. This allows branch prediction based on the branch history information left by the currently running program, preventing speculative execution of instructions at branch target addresses in branch history left by a malicious third-party program.
[0008] Special table 2021-516384 publication Special table 2021-524621 publication
[0009] https: / / googleprojectzero.blogspot.jp / 2018 / 01 / reading-privileged-memory-with-side.html?m=1
[0010] However, the context and the program ID included in the context themselves have a long number of bits. The number of bits in a context is, for example, 100 or more, and the number of bits in a program ID is, for example, 16 or more. Meanwhile, the number of entries in a branch prediction buffer within a branch prediction mechanism is typically on the order of several hundred to several thousand. Therefore, if the context and program ID were included in the branch history information for each entry in the buffer within the branch prediction mechanism, the circuit scale of the branch prediction mechanism would become enormous, resulting in an increase in the processor's area and power consumption. Prefetch mechanisms also have similar issues.
[0011] Therefore, an object of a first aspect of this embodiment is to provide a processor and a processing method of the processor that suppresses vulnerability while suppressing an increase in the circuit scale of the branch prediction mechanism and the prefetch control unit.
[0012] a context table processing unit that extracts the security ID associated with the execution context of a process being executed; a branch prediction mechanism that compares 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 extracted from the context table processing unit, and outputs the branch target address in the second entry that matches 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.
[0013] According to the first aspect, vulnerability is suppressed while suppressing an increase in the circuit scale of the branch prediction mechanism and the prefetch control unit.
[0014] 1 is a diagram illustrating an example of the configuration of a processor core. FIG. 2 is a diagram illustrating an example of a branch prediction buffer in a branch prediction mechanism. FIG. 3 is a diagram illustrating an example of the configuration of a processor core in the first embodiment. FIG. 4 is a diagram illustrating a first example of the configuration of a context table 26 in this embodiment. FIG. 5 is a diagram illustrating an example of the configuration of a branch prediction mechanism 24 in this embodiment. FIG. 6 is a diagram illustrating an example of a branch prediction buffer BR_PRD_BUF in the branch prediction mechanism. FIG. 7 is a diagram illustrating the configuration of a context table in a modified example of the first embodiment. FIG. 8 is a diagram illustrating an example of the configuration of a processor core in the second embodiment. FIG. 9 is a diagram illustrating a first example of the configuration of a context table in the second embodiment. FIG. 10 is a diagram illustrating an example of the configuration of a branch prediction mechanism in the second embodiment. FIG. 11 is a diagram illustrating a modified example of the context table in the second embodiment. FIG. 12 is a diagram illustrating the configuration of a processor core in the third embodiment. FIG. 13 is a diagram illustrating an example of the configuration of a prefetch control unit 32 in this embodiment. FIG. 14 is a diagram illustrating an example of a flowchart of the operation of a context table. FIG. 15 is a diagram illustrating a first example of a context table and a tag of a branch prediction mechanism that has a security problem. FIG. 16 is a diagram illustrating a second example of a context table and a tag of a branch prediction mechanism that has a security problem.
[0015] [Terminology definitions] Process: A running program. Execution context: Information linked to a process, a collection of parameters such as an identifier to identify the process, an identifier to identify the virtual machine, and an identifier to identify the privilege level. Program ID: Corresponds to the process identifier within the execution context. Has a long bit length, such as 16 bits or more. Security ID: An identifier linked to the execution context. An identifier that can identify a process in the same way as the execution context or program ID. Consists of fewer bits than the execution context or program ID. For example, a few bits.
[0016] [First Embodiment] Figure 1 is a diagram showing an example of the configuration of a processor core. Generally, a processor has multiple cores, a lower-level cache shared by the multiple cores, a memory access control unit that accesses main memory, and an interface with the outside of the processor chip. The core CORE shown in Figure 1 has, excluding the lower-level cache and main memory 100, 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, and a branch prediction mechanism 24. The arithmetic unit 20 has an arithmetic circuit and a data cache unit. Of the lower-level cache and main memory 100 that are not included in the core, the lower-level cache is provided within 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 using 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 using the instruction address. If there is a cache hit, the instruction INST in the primary instruction cache 12 is returned to the instruction decoder 16. If there is a cache miss, the primary instruction cache 12 sends a memory access request to the lower-level cache 100 or 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 returned to the instruction decoder 16.
[0018] The instruction decoder 16 decodes the received instructions INST in the order of the program, and transmits the decoded instructions D_INST to the reservation station 18, and also transmits an instruction identifier INST_ID indicating the order of the instructions INST to the commitment control unit 22. The instructions D_INST stored in the input queue of the reservation station are executed out of order, with processing requests PRC_RQ for the instructions being sent to the operation unit 20 in the order in which preparation for operation is completed.
[0019] When the arithmetic unit 20 completes processing, it returns a processing completion PRC_CMP to the reservation station 18, and sends a completion notification CMP_NTF to the commit control unit 22 together with the instruction identifier. The commit control unit 22 completes the processed instructions in the order of the program instructions and updates the resources used to process the instructions. If the processed instruction is a branch instruction, the commit control unit 22 sends the instruction address, branch success / 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, we will explain the instruction address generation process of the instruction address generation unit 10. The instruction address generation unit 10 selects the 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 from the primary instruction cache 12.
[0021] Assuming that the order of a certain 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, using the instruction address INST_ADD_pc in 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 using the received fetch address INST_ADD_gen, and the branch prediction result generator 24_2 sends the branch prediction result (including branch hit / miss and branch target address) to the instruction address generator 10 based on the branch target address TAGT_ADD in the entry in the branch prediction buffer 24_3 that stores the instruction address matching the fetch address. In response to this, the instruction address generator 10 selects either the instruction address next to 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 instruction A is not a branch instruction, the branch prediction result is a branch miss, and the instruction address generator 10 selects the instruction address of instruction X next to instruction A (instruction address INST_ADD_pc in the PC) and performs an instruction fetch.
[0023] When the instruction address generation unit 10 issues an instruction fetch with the instruction address of 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 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 fetches an instruction from 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 branch prediction buffer BR_PRD_BUF in FIG. 2 has 4096 entries (entry numbers 0 to 4095). Each entry ENTRY stores, as branch history, a tag TAG in which the instruction address INST_ADD of a previously executed branch instruction is stored, 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 previously executed branch instruction. The number of entries, 4096, is just an example; a typical processor has several hundred to several thousand entries. Also, the 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 storing an instruction address that matches the comparison.The branch prediction result generation unit 24_2 then transmits the branch target address TAGT_ADD in the detected entry to the instruction address generation unit 10 together with branch match information.
[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 will be speculatively executed during execution of a regular program. Even if the address of the secret data is at a privilege level, it will be read by the speculatively executed load instruction.
[0027] Patent Document 1 describes that the tag of the branch prediction buffer in Figure 2 stores execution context and program identification information (program ID) associated with a process that 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 the branch prediction buffer within the branch prediction mechanism would result in the circuit scale of the branch prediction mechanism becoming enormous, which is not desirable.
[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, etc.
[0030] Unlike the core in FIG. 1 , the core in FIG. 3 has a context table processing unit (hereinafter referred to as the context table for simplicity) 26. The context table 26 stores an execution context EX_CNTXT and a security ID associated with the execution context that can identify the execution context. The execution context and 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. A comparator 24_1 compares the instruction fetch address INST_ADD_gen 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 below. When a program starts execution, the execution context EX_CNTXT of the program that has started execution is output from the system. The context table 26 associates the execution context EX_CNTXT with its security ID and registers it in an empty entry in the context table, extracts (outputs) the security ID associated with 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 for 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 tags in the branch prediction buffer 24_3 using the fetch address INST_ADD_gen and the security ID (SCR_ID) to determine whether there is a matching entry. The tags of entries in the branch prediction buffer store the security ID at that time in addition to the address of a branch instruction executed in the past, so that entries in the branch history of the currently executing program can be distinguished from entries in 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 example of the configuration 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 multiple entries ENTR_0 to ENTR_m-1 that respectively store an execution context EX_CNTXT, a security ID (SCR_ID) associated with it, 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 It is desirable to set it to 4.
[0035] FIG. 14 is a flowchart illustrating the operation of the context table. When a program starts executing 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 using 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. If a matching entry is found, the comparator 26_1 outputs the matching entry number MCH_ENTR_No. In this case, the execution context has already 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 thus becomes the security ID associated with the current execution context.
[0036] If the context buffer does not contain an entry that stores an execution context matching 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). If an invalid entry exists in response to the total mismatch A_UNMCH (NO in S18), the registration unit 26_4 newly registers the new execution context EX_CNTXT 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] If the valid bits VLD of all entries in the context table are true (valid) when the 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 with it (S22). 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, the branch prediction mechanism may be unable to distinguish the branch history entry of the currently executing program from the branch history entry of a malicious program, posing a security problem. This security problem will be discussed 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 at least the entries in the branch prediction buffer BR_PRD_BUF that store the same security ID as the security ID before the overwrite. The branch prediction mechanism may invalidate all entries in response to the invalidation request. Thereafter, the selection circuit 26_2 outputs the security ID and sets the security ID extraction completion flag to true (completed) (S16).
[0039] By using a security ID with only a few bits, the context table frequently overwrites the switched execution context and its security ID. Because the security ID is only a few bits, there is a possibility that the security ID before and after the overwrite will match, and therefore it is necessary to invalidate the entry in the branch prediction mechanism described above. The invalidation request will be explained in detail in the explanation of the branch prediction mechanism.
[0040] 15 is a diagram showing a first example of a context table and a tag of a branch prediction mechanism that has a security problem. The transition of the state at times T1, T2, and T3 is shown in FIG. 15. At time T1, the 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 the tag of the branch prediction mechanism at time T1 is shown in the figure.
[0041] Next, at time T2, the execution context is changed to EX_CNTXT_C, and the entry for the registered SCR_ID_B is overwritten with SCR_ID_C, which is a security ID that is not currently registered. 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, a security ID (SCR_ID_B) different from SCR_ID_C, which is a security ID associated with the execution context EX_CNTXT_C, will not be hit.
[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 for SCR_ID_C that was being registered at time T2. In other words, the security ID (SCR_ID_B) may be 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 of another TAG entry, causing a security problem.
[0044] Therefore, when the entry for registered SCR_ID_B is overwritten with the security ID SCR_ID_C that is not currently registered at time T2, it is necessary to invalidate the entry for INST_ADD_B / SCR_ID_B from the TAG of the branch prediction mechanism.
[0045] 16 is a diagram showing a second example of a context table and a tag of a branch prediction mechanism that may have a security problem. The transition of the state at times T11 and T12 is shown in FIG. 16. At time T11, the 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 the tag of the branch prediction mechanism at time T11 is shown in the figure.
[0046] Next, suppose that at time T12, the execution context is changed to EX_CNTXT_C, and the entry for SCR_ID_B that was registered at time T11 is overwritten with the same security ID (SCR_ID_B). As a result, suppose 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 the security ID (SCR_ID_B) is overwritten on an entry with the same security ID (SCR_ID_B) in the context table at time T12, it is necessary to invalidate the entry for the security ID (SCR_ID_B) in the TAG of the branch prediction mechanism. In other words, whether the security ID overwriting an entry in the context table matches the security ID of the entry to be overwritten or not, it is necessary to invalidate the entry for the overwritten security ID in the TAG of the branch prediction mechanism.
[0048] FIG. 5 is a diagram showing an example of the configuration of the branch prediction mechanism 24 according to this embodiment. The branch prediction mechanism 24 includes a comparator 24_1, a branch prediction result generator 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 hundreds to thousands of entries, and each entry stores, in a tag TAG, an instruction address (or 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, as described in FIG. 2, each entry stores a branch flag BR_FL and a target address TAGT_ADD, which is the 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 sends a branch history update request BR_HST_UPDATE along with the branch history of the branch instruction (instruction address, branch flag, target address, branch success / failure, etc.) to the branch prediction mechanism 24. In response to the branch history update request, the branch history information and security ID are registered in an empty 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 the same 4096 entries as FIG. 2. What differs from FIG. 2 is that the tag TAG of each entry stores the instruction address (or part thereof) INST_ADD of a previously executed branch instruction and a security ID (SCR_ID) linked to the execution context when that branch instruction was executed. Each entry also stores a valid bit, but this is omitted in FIG. 6.
[0051] 6 has 4096 entries arranged in ascending order of 2-bit security IDs. 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, and 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 each of the four types of security IDs.
[0052] In an actual branch prediction buffer, the number of branch histories for branch instructions in multiple executed programs differs, and the number of entries in which branch histories are registered differs for each security ID. As an example, in Figure 6, the number of entries in which branch histories are registered is the same, 1024, for each of 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 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] 5, the operations of the context table 26, instruction address generation unit 10, and branch prediction mechanism 24 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 as a new 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 operation.
[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 predict the address of the instruction to be executed next. At this time, the security ID registered in association with the execution context, which is extracted from the context table 26, 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 thereof) and security ID with the instruction address (or part thereof) and security ID in the tag section of all entries in the branch prediction buffer, and if there is 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 generation unit 24_2 returns the branch prediction result BR_PRD_RSLT (including a branch hit or miss and a target address TAGT_ADD) based on the match MCH from the comparator and the branch taken prediction from the branch taken prediction unit 24_4 to the instruction address generation unit 10. Then, the instruction address generation unit 10 generates the address of the instruction to be executed next based on the branch prediction result and executes an instruction fetch.
[0058] The type of branch instruction indicated by 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 context table 26 newly registers an execution context after switching the currently executing program, if the valid bits VLD of all entries in the context table are true (valid), the registration unit 26_4 overwrites one of the existing valid entries with the post-switch execution context and the security ID associated with it. As described in FIG. 15 , if the security ID before the overwrite is subsequently registered again in the context table as a security ID associated with a different execution context, the branch prediction mechanism may be unable to distinguish the entry for the branch history of the currently executing program from the entry for the branch history of a malicious program. Furthermore, as described in FIG. 16 , a similar security problem naturally occurs when the security ID to be overwritten is the same as the security ID of the entry to be overwritten.
[0060] Therefore, when a new entry is registered, if the valid bits VLD of all entries in the context table are true (valid), 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 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 prevents the branch prediction mechanism from responding to the instruction address generation unit as a branch prediction result the target address of the branch destination based on the branch history registered by a malicious program.
[0061] On the other hand, when registering a new execution context after the switch, the registration unit 26_4 in the context table 26 generates a security ID associated with the execution context. The registration unit may generate the security IDs in ascending or descending order, or may generate the security IDs 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 overwritten security ID will not match the security ID before the overwrite while the security ID goes around in a cycle. 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 cycle 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 randomly generated, 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 to be assigned to a newly generated security ID, the registration unit must overwrite the entry for the currently registered security ID in the context table, or perform other operations to prevent multiple entries in the context table in which the same security ID is associated with different execution contexts.
[0064] 16, however, when the registration unit 26_4 overwrites the execution context and security ID with the same security ID as the execution context and security ID in a currently registered valid entry, 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 entries in the branch prediction buffer BR_PRD_BUF.
[0065] [Modification of the First Embodiment] FIG. 7 is a diagram illustrating the configuration of a context table in a modification 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 modification, the registration unit of the context table preferably registers the post-switch execution context EX_CNTXT in entry number order (ascending or descending) in response to the all-mismatch A_UNMCH signal from the selection circuit 26_2. When registering new entries in entry number order, when the entry numbers have cycled through (entry number m−1 in ascending order, entry number 0 in descending order), 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. 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 any other order of registration.
[0066] According to this modification, it is possible to reduce the number of bits of an entry in the context table 26, thereby reducing 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 branch prediction mechanism are the same as those in the first embodiment.
[0068] Second Embodiment FIG. 8 is a diagram illustrating an example of the configuration of a processor core in a second embodiment. The difference from the core configuration example in FIG. 3 is that the security ID associated with the execution context includes a second security ID2 (SCR_ID2) in addition to the first security ID (SCR_ID) that is the same as in the first embodiment. Therefore, the entry of the context buffer in the context table 26 stores the execution context and the associated first security ID (SCR_ID) and second security ID2 (SCR_ID2). Meanwhile, the tag of the branch prediction buffer in the branch prediction mechanism 24 stores the 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 illustrates a first exemplary configuration of a context table according to the second embodiment. As illustrated in FIG. 9, each entry in the context buffer registers an execution context EX_CNTXT, a valid bit VLD, and a first security ID (SCR_ID) and a second security ID2 (SCR_ID2) as security IDs 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 simple addition and subtraction, or in ascending or descending order, or by any other method.
[0070] However, since the tag of the branch prediction buffer stores a hash generated by performing a hash operation on the instruction address (or part of it) using the second security ID2 (SCR_ID2), there is no increase in the number of bits of the tag, 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 randomly generated and the first and second security IDs (combinations of SCR_ID and SCR_ID2) are randomly assigned, thereby eliminating the need to issue an invalidation request INVD_RQ to the branch prediction mechanism. That is, even if a malicious program can generate a security ID that matches a first security ID (SCR_ID) generated in ascending or descending order, it is virtually impossible to generate a security ID that matches a randomly generated second security ID2 (SCR_ID2). Therefore, there is virtually no need to invalidate the TAG entries of the branch prediction mechanism. When the first security IDs (SCR_ID) are assigned in ascending or descending order, a malicious program can be executed as many times as the number of combinations of all bits of the first security ID to hit the TAG of the branch prediction mechanism, making it necessary to invalidate the TAG entries 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 that 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 the 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-switch execution context and has a valid bit of VLD=1 (valid), the context table newly registers the post-switch 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. The context table then 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 an example of the configuration of a branch prediction mechanism in the second embodiment. The tag of an entry in the branch prediction buffer BR_PRD_BUF is registered with a hash HASH of the instruction address (or part thereof) INST_ADD and the second security ID2 (SCR_ID2), and the first security ID (SCR_ID). Therefore, 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 the entry, and that a comparator 24_1 and a branch taken prediction unit 24_4 are provided are the same as in the first embodiment shown in 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 performs a hash calculation on the instruction address (or part of) of the executed branch instruction included in the branch history using 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 entry tag, and the valid bit VLD is enabled. The branch flag BR_FLG and 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 then predicts the next instruction address. At this time, the first and second security IDs, ID2 (SCR_ID, SCR_ID2), associated with the currently executing 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 generation unit 24_2 of the branch prediction mechanism returns the branch prediction result (including a branch miss BR_MISS) BR_PRD_RSULT to the instruction address generation unit 10. In response to this, the instruction address generation 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 generation 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 generation unit. In response to this, the instruction address generation 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 in 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 in the instruction address (or a part thereof), the number of bits in 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 in the first embodiment.
[0081] 7, in this modification, it is desirable that the registration unit 26_4 of the context table newly registers the execution context EX_CNTXT after switching in order of entry number (ascending or descending order) in response to the total mismatch A_UNMCH from the selection circuit 26_2. When newly registering in order of entry number, when the entry number has gone around once (m-1 in the case of ascending order, 0 in the case of descending order), the registration unit 26_4 outputs an invalidation request INVD_RQ to the branch prediction mechanism 24 before newly registering the execution context in the next entry, causing 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 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 a third embodiment. The core in Fig. 12 has the arithmetic unit 20, context table 26, lower-level cache, and main memory 100, which are also shown in Fig. 3. The core also has an operand address generation unit 30, a primary data cache 31, and a prefetch control unit 32.
[0085] In the case of a memory access instruction such as a load or store instruction, the decoded memory access instruction is sent to the reservation station, which then 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 using the operand address of the memory access instruction to execute a data fetch. If 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, if a cache miss occurs, a data request is issued to a lower-level cache or the main memory 100. The data response from the lower-level cache or the main memory 100 is then sent to the primary data cache 31, where the data is registered in the cache, and the data response is then 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 subsequent arithmetic instructions, etc., on the data in the register.
[0086] When a memory access instruction accesses multiple addresses consecutively, the prefetch control unit 32 prefetches data at addresses consecutive to the address that caused the cache miss from a lower-level cache or the main memory 100, and registers the read data in advance in the primary data cache. As a result, a cache hit occurs in the primary data cache in response to a data request of a memory access instruction that is subsequently executed, and a data response reaches the calculation unit 20 with short latency.
[0087] The data prefetching 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 access 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 the operand address OPR_ADD1 of a certain memory access instruction and a cache miss occurs, the operand address OPR_ADD1 that caused the cache miss is stored in the tag of an entry in 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 results in a cache miss in the primary data cache. A comparator 32_1 in the prefetch control unit 32 determines whether the second prefetch address PRF_ADD2 is an address in the positive direction (+1) or the negative 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 that is +1 with respect to the first operand address OPR_ADD1 registered in the tag, and an address ADD1-1 that is -1 with respect to the first operand address OPR_ADD1, 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 the address matches ADD1+1, the data access is determined to be an access to an address in ascending order, and if the address matches ADD1-1, the data access is determined to be an access to an address in descending order. 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, or at address ADD1-2 if the order is descending. This prefetch request is a type of speculative memory access. The prefetched data is registered in the primary data cache 31, so when the operand address generation unit 30 subsequently issues a data request for the address of the prefetched data, a cache hit is always obtained in the primary data cache, thereby shortening the latency of the data fetch.
[0091] In the next cycle, the updated operand address OPR_ADD in the prefetch queue PRF_QUE is ADD1+1 or ADD1-1, so the comparator 32_1 determines whether the operand address OPR_ADD output by the operand address generation unit 30 matches the address ADD1+2 (or ADD1-2) in the operand queue. If the determination result is a match MCH, the prefetch determination 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 as in Figure 4, the execution context provided from the system when a program starts to execute is linked to a security ID that can identify the execution context, stored in an entry in the context table, the security ID is extracted, and the security ID extraction completion flag ID_TKOUT_CMP is enabled.
[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 missed the cache, 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 at 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 in the prefetch queue in the prefetch control unit is also equivalent to the already-described examples corresponding to the configurations of the context tables in Figures 4, 7, 9, and 11.
[0098] According to the above embodiment, an execution context and a security ID with a small number of bits associated therewith are stored in a context table, and an address and a security ID are stored in the tag of an entry in a branch prediction buffer of a branch prediction mechanism and the tag of an entry in a prefetch queue of a 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 size of the branch prediction buffer. Furthermore, it makes it possible to distinguish between entries registered by a legitimate program and entries registered by a malicious program in prefetch determination by the prefetch control unit, and further reduces the circuit size of the prefetch queue.
[0099] According to the above embodiment, the number of bits of a security ID is small, and therefore the number of security IDs that can be registered in the context table is limited. Therefore, when a new execution context and its security ID are overwritten in the context table, at least the entries in the buffers in the branch prediction mechanism and prefetch control unit that store the security ID before the overwrite are invalidated. This ensures that entries registered by legitimate programs are distinguished from entries registered by malicious programs.
[0100] 10: Instruction address generation unit 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 generation unit that generates an instruction address which is a destination for fetching an instruction and outputs the instruction address to execute an instruction fetch; a context table processing unit that has a context buffer including M first entries that respectively store an execution context associated with a process by associating the execution context with a security ID capable of identifying the execution context, and extracts the security ID associated with the execution context of a process being executed; a branch prediction buffer that has N second entries that respectively store a tag that stores a branch instruction address of a branch instruction executed in the past and the security ID at the time the branch instruction was executed, and a branch target address of the branch instruction executed in the past, wherein N is greater than M, and M and N are natural numbers equal to or greater than 2; a branch prediction mechanism that compares 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 security ID in the tag of the second entry, and 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 microprocessor of claim 1, wherein the context table processing unit: when the execution context is switched, searches the M first entries for the switched execution context; if the switched execution context is registered in any of the first entries, extracts the security ID in the hit first entry; if the switched execution context is not registered and there is a vacant first entry, associates the switched execution context with the security ID that identifies the switched execution context and registers it in a vacant entry of the first entry and extracts the registered security ID; if the switched execution context is not registered and there is a vacant first entry, associates the switched execution context with the security ID that identifies the switched execution context and overwrites and registers it in the first entry, and sends an invalidation request to the branch prediction mechanism; and in response to the invalidation request, the branch prediction mechanism invalidates at least the second entry that stores the original security ID that was overwritten and registered.
3. The microprocessor of claim 2, wherein the context table processing unit, when overwriting and registering the first entry, updates the security ID in ascending or descending order, links the updated security ID to the switched execution context, and overwrites and registers the updated security ID in the first entry; when the security ID has been updated once, sends an invalidation request to the branch prediction mechanism to invalidate all of the second entries; and the branch prediction mechanism invalidates all of the second entries in response to the invalidation request.
4. The microprocessor according to claim 3, wherein the security ID is the entry number of the first entry, and the context table processing unit updates the entry number of the first entry as the security ID in ascending or descending order when overwriting and registering the first entry.
5. The microprocessor of claim 1, wherein the context table processing unit further stores an additional security ID linked to the execution context in each of the M first entries, and the branch prediction mechanism stores the instruction address, a hash of the additional security ID, and the security ID in a tag of each of the N second entries.
6. The microprocessor of claim 5, wherein the context table processing unit searches the M first entries for the switched execution context when the execution context is switched; if the switched execution context is registered in any of the first entries, extracts the security ID and additional security ID from the hit first entry; if the registration is not made and there is space in the first entry, registers the switched execution context in a vacant entry of the first entry by linking it with the security ID and additional security that identify the switched execution context and registers it in the vacant entry of the first entry and extracts the registered security ID and additional security ID; if the registration is not made and there is space in the first entry, overwrites and registers the switched execution context in the first entry by linking it with the security ID and additional security that identify the switched execution context.
7. The microprocessor of claim 1, wherein the number of bits of said security ID is less than the number of bits of a program ID that identifies said execution context and said process included in said 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 fetching; a context table processing unit that has a context buffer including M first entries that respectively store an execution context associated with a process by associating the execution context with a security ID that can identify the execution context, and extracts the security ID associated with the execution context of a process being executed; a prefetch queue that includes N second entries that respectively store an operand address when a cache miss occurs in a primary data cache in response to a data request to fetch data and tags that store the security ID when the data request is executed, wherein N is greater than M, and M and N are natural numbers equal to or greater than 2; and comparing the operand address output by the operand address 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 generation unit that generates an instruction address which is a destination of an instruction and outputs the instruction address to execute an instruction fetch; a context table processing unit that has a context buffer including M first entries for storing an execution context associated with a process by associating the execution context with a security ID capable of identifying the execution context, and extracts the security ID associated with the execution context of a process being executed; and a branch prediction mechanism that has a branch prediction buffer including N second entries, N being greater than M, and M and N being natural numbers of 2 or more, wherein the branch prediction mechanism: stores a tag for storing a branch instruction address of a branch instruction executed in the past and the security ID at the time the branch instruction was executed, and a branch target address of the branch instruction executed in the past, in each of the N second entries; compares 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; and outputs the branch target address in the second entry which 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. The microprocessor processing method of claim 9, wherein the context table processing unit: when the execution context is switched, searches the M first entries for the switched execution context; if the switched execution context is registered in any of the first entries, extracts the security ID in the hit first entry; if the switched execution context is not registered and there is a vacant first entry, associates the switched execution context with a security ID that identifies the switched execution context and registers it in a vacant entry of the first entry and extracts the registered security ID; if the switched execution context is not registered and there is a vacant first entry, associates the switched execution context with a security ID that identifies the switched execution context and overwrites and registers it in the first entry, and sends an invalidation request to the branch prediction mechanism; and in response to the invalidation request, the branch prediction mechanism invalidates at least the second entry that stores the original security ID that was overwritten and registered.
11. The microprocessor processing method of claim 10, wherein the context table processing unit, when overwriting and registering the first entry, updates the security ID in ascending or descending order, links the updated security ID to the switched execution context, and overwrites and registers the updated security ID in the first entry; when the security ID has been updated once, sends an invalidation request to the branch prediction mechanism to invalidate all of the second entries; and in response to the invalidation request, the branch prediction mechanism invalidates all of the second entries.
12. A processing method for a microprocessor as described in claim 11, wherein the security ID is the entry number of the first entry, and the context table processing unit updates the entry number of the first entry as the security ID in ascending or descending order when overwriting and registering in the first entry.
13. A processing method for a microprocessor as described in claim 9, wherein the context table processing unit further stores an additional security ID linked to the execution context in each of the M first entries, and the branch prediction mechanism stores the instruction address, a hash of the additional security ID, and the security ID in a tag of each of the N second entries.
14. The microprocessor processing method of claim 13, wherein the context table processing unit searches the M first entries for the switched execution context when the execution context is switched; if the switched execution context is registered in any of the first entries, extracts the security ID and additional security ID from the hit first entry; if the registration is not made and there is space in the first entry, registers the switched execution context in a vacant entry of the first entry by linking it with the security ID and additional security that identify the switched execution context and extracts the registered security ID and additional security ID; if the registration is not made and there is space in the first entry, overwrites and registers the switched execution context in the first entry by linking it with the security ID and additional security that identify the switched execution context.
15. The microprocessor processing method according to claim 9, wherein the number of bits of said security ID is less than the number of bits of a program ID that identifies said execution context and said process included in said execution context.
16. An apparatus comprising: an operand address generation unit that generates an operand address which is a data fetch destination and outputs the operand address to execute a data fetch; a context table processing unit having a context buffer including M first entries for storing an execution context associated with a process by associating the execution context with a security ID capable of identifying the execution context, and extracting the security ID associated with the execution context of a process being executed; and a prefetch control unit having a prefetch queue including N second entries, wherein N is greater than M, and M and N are natural numbers of 2 or more; the prefetch control unit: stores 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; and compares the operand address output by the operand address 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 a 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
Identifying dependencies of an application upon a given security context
US20070006283A1
Program execution control system, execution control method, execution control computer program
WO2007097439A1
