Processor, method, system and instructions for protecting shadow stack

By introducing the shadow stack protection mechanism and using the shadow stack register and descriptor table to manage the shadow stack, the problem that the data stack of existing processors is susceptible to control flow subversion in ROP and JOP attacks is solved, achieving higher security and system stability.

CN112988624BActive Publication Date: 2024-10-29INTEL CORP
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110256487.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2016-05-26
Publication Date
2024-10-29
Estimated Expiration
2036-05-26

AI Technical Summary

Technical Problem

When existing processors face attacks such as Return-Oriented Programming (ROP) and Jump-Oriented Programming (JOP), the conventional data stack is susceptible to control flow subversion and lacks an effective protection mechanism, resulting in insufficient security.

Method used

Introduce a shadow stack protection mechanism, manage the shadow stack through the shadow stack register and shadow stack descriptor table, limit the access rights of the shadow stack, and implement instructions to save and restore the shadow stack pointer in the processor to ensure the integrity and security of the shadow stack sex.

Benefits of technology

Effectively prevent attacks such as ROP and JOP, enhance processor security, prevent control flow subversion, ensure the protection and integrity of the shadow stack, and improve system security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112988624B_ABST
    Figure CN112988624B_ABST
Patent Text Reader

Abstract

The present application discloses a processor, method, system and instruction for protecting a shadow stack. A processor of one aspect of the present invention includes a decoding unit for decoding an instruction. The processor also includes an execution unit coupled to the decoding unit. The execution unit is used to determine in response to the instruction that an attempted change to a shadow stack pointer of a shadow stack due to the instruction will cause the shadow stack pointer to exceed an allowed range. The execution unit is also used to cause an exception in response to determining that the attempted change to the shadow stack pointer will cause the shadow stack pointer to exceed the allowed range. Other processors, methods, systems and instructions are disclosed.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This invention patent application is a divisional application of the invention patent application with international application number PCT / US2016 / 034364, international application date May 26, 2016, application number 201680029980.5 entering the Chinese national phase, and name “Processor, method, system and instruction for protecting shadow stack”. Background Art Technical Field

[0002] Embodiments described herein generally relate to processors. Specifically, embodiments described herein generally relate to processors with enhanced security. Technical Background

[0004] Return-oriented programming (ROP) and jump-oriented programming (JOP) are computer security exploitation techniques that attackers can use to gain control of a computer system or other electronic device and perform malicious actions. In these techniques, the attacker gains control of the call stack in order to hijack the program control flow.

[0005] The control of the call stack is often realized by buffer overflow utilization or attack. In buffer overflow, the function that does not fully perform boundary checking before storing data in the memory can accept more data than the data that can be properly stored. For example, an attacker can send more data than the data that can be properly stored by the web browser to the web browser. If the data is stored on the stack, some data may exceed the storage space allocated to the variable of the function and rewrite the return address. The return address can represent the address stored on the stack by the calling program instruction, and the calling program instruction is intended to redirect the control flow back to the calling function after the called program has been completed. However, in the buffer overflow attack or utilization, different return addresses can be used to rewrite the return address. This may allow the attacker to transfer the control flow to different return addresses, start executing code at different return addresses and perform actions that may not be expected and / or malicious.

[0006] For example, in a ROP attack, an attacker may link together a sequence of things called "gadgets". Each gadget may represent a set of one or more instructions, followed by a return instruction from the program. An attacker may analyze code (e.g., an application, system-level code, a driver, a library, etc.) to locate or identify a desired gadget. For example, an attacker may scan the opcode of a return instruction from a program. The previous instructions before this identified return instruction from a program may represent different types of gadgets with different functions. By way of example, an attacker may identify a pop stack instruction before a return instruction as a first gadget, a register-to-register move instruction before a return instruction as a second gadget, and so on. In some cases, an attacker may be able to identify enough gadgets to be able to string together and perform a variety of different malicious actions.

[0007] Typically, initially, a buffer overflow attack can be used to hijack the return address on the stack and thereby hijack the control flow. The address of the first instruction of the first applet can be stored on the stack so that the control flow is transferred to the first applet. The control flow can be transferred to the first instruction of the first applet selected by the attacker, rather than returning to the caller associated with the caller instruction. Then, the return instruction of the first applet can transfer the control flow to the second applet. In this way, the return addresses of a series of applets can be stored sequentially on the stack and jump according to the return instruction of the linked applet. By linking the applets together in a specific order, an attacker may be able to create new program functions from existing code. An attacker may use this for undesirable or harmful purposes, such as, for example, stealing confidential information, interfering with or attacking other applications, sending emails, sending text messages, posting tweets, or exploiting kernel vulnerabilities. BRIEF DESCRIPTION OF THE DRAWINGS

[0008] The present invention may be best understood by referring to the following description and accompanying drawings which illustrate embodiments. In the drawings:

[0009] Figure 1 is a block diagram of an embodiment of a computer system in which embodiments of the invention may be implemented.

[0010] Figure 2 is a block diagram of an embodiment of a set of shadow stack registers and an embodiment of a set of shadow stack descriptor table registers.

[0011] Figure 3 is a block diagram of an embodiment of a shadow stack descriptor table.

[0012] Figure 4is a block diagram of one specific example embodiment suitable for a shadow stack descriptor table (SSDT) ​​entry.

[0013] Figure 5 is a block diagram of an example embodiment of a shadow stack descriptor table selector.

[0014] Figure 6 is a block diagram of an embodiment of an example embodiment of a 32-bit Task State Segment structure.

[0015] Figure 7 is a block diagram of an example embodiment of a 64-bit task state fragment structure.

[0016] Figure 8 is a block diagram of an embodiment of a processor operable to execute an embodiment of a call program instruction and an embodiment of a return from program instruction.

[0017] Fig. 9 is a block flow diagram of an embodiment of a method of executing an embodiment of a save shadow stack pointer instruction.

[0018] Fig.10 is a block diagram of an embodiment of a processor operable to execute an embodiment of a save shadow stack pointer instruction.

[0019] Fig.11 is a block flow diagram of an embodiment of a method of executing an embodiment of a restore shadow stack pointer instruction.

[0020] Fig.12 is a block diagram of an embodiment of a processor operable to execute an embodiment of a restore shadow stack pointer instruction.

[0021] Fig.13A is a block diagram illustrating an embodiment of an in-order pipeline and an embodiment of a register renaming out-of-order issue / execution pipeline.

[0022] Fig. 13B is a block diagram of an embodiment of a processor core including a front end unit coupled to an execution engine unit, and both the front end unit and the execution engine unit are coupled to a memory unit.

[0023] Fig.14A is a block diagram of an embodiment of a single processor core along with its connection to the on-die interconnect network and along with its local subset of the Level 2 (L2) cache.

[0024] Fig. 14B yes Fig.14A A block diagram of an embodiment of an expanded view of a portion of a processor core.

[0025] Fig.15is a block diagram of an embodiment of a processor that may have more than one core, may have an integrated memory controller, and may have integrated graphics.

[0026] Fig.16 is a block diagram of a first embodiment of a computer architecture.

[0027] Fig.17 is a block diagram of a second embodiment of a computer architecture.

[0028] Fig.18 is a block diagram of a third embodiment of a computer architecture.

[0029] Fig.19 is a block diagram of a fourth embodiment of a computer architecture.

[0030] Fig. 20 is a block diagram of using a software instruction converter to convert binary instructions in a source instruction set into binary instructions in a target instruction set according to an embodiment of the present invention. DETAILED DESCRIPTION

[0031] Disclosed herein are shadow stack protection instructions, processors for executing the instructions, methods performed by the processors when processing or executing the instructions, and systems incorporating one or more processors for processing or executing the instructions. Shadow stack protection logic is also disclosed. In the following description, many specific details (e.g., specific instruction operations, data formats, processor configurations, microarchitecture details, operation sequences, etc.) are described. However, embodiments may be practiced without these specific details. In other instances, well-known circuits, structures, and techniques are not shown in detail to avoid blurring the understanding of this specification.

[0032] Figure 1 1 is a block diagram of an embodiment of a computer system 100 in which embodiments of the present invention may be implemented. In various embodiments, the computer system may represent a desktop computer system, a laptop computer system, a notebook computer, a tablet computer, a netbook, a portable personal computer, a smart phone, a cellular phone, a server, a network element (e.g., a router or switch), a smart television, a nettop, a set-top box, a video game console, a media player, or another type of computer system or electronic device.

[0033] The computer system includes a processor 101 and a memory 114. When the processor and the memory are deployed together in the system, they can be coupled to each other through an interconnect mechanism 198. The interconnect mechanism can include one or more buses or other interconnects, one or more hubs or other chipset components, and combinations thereof. Various ways of coupling the processor to the memory that are well known in the art are suitable. Although the memory is shown in the illustrated embodiment, other embodiments relate to a processor that is not separately coupled to the memory (e.g., not deployed in the computer system). Examples of different types of memory include, but are not limited to, dynamic random access memory (DRAM), flash memory, and other types of memory that are commonly used for main memory.

[0034] The memory may store privileged system software 115. Examples of suitable privileged system software include, but are not limited to, one or more operating systems, virtual machine monitors (VMMs), hypervisors, and the like, and combinations thereof. The memory also stores one or more user-level applications 116. In some embodiments, the user-level applications may optionally include one or more user-level multithreaded applications. As will be further explained below, such user-level multithreaded applications may optionally use instructions disclosed herein to help improve the efficiency of performing user-level multithreading and / or performing user-level task switching.

[0035] During operation, the memory may also store a stack 119. The stack is sometimes referred to as a call stack, a data stack, or simply a stack. The stack may represent a stack-type data structure operable to store both data 118 and control 117. The data may represent any type of data (e.g., parameters and other data passed to a subroutine, etc.) that the software wants to push into the stack. Typically, control may include one or more return addresses for one or more previously executed program calls. These return addresses may represent instruction addresses to which the called program will return control flow when the called program completes and returns.

[0036] As discussed in the background section, in return-oriented programming (ROP), jump-oriented programming (JOP) and other control flow subversion attacks, attackers often attempt to gain control of the stack in order to hijack program control flow. One factor that may tend to make conventional data stacks more vulnerable to ROP, JOP or other control flow subversion attacks is that stacks typically store data 118 and control 117 (e.g., on the same stack, data and return addresses are typically mixed together). Another factor that may tend to make conventional stacks more vulnerable to such attacks is that switching to the stack can typically be performed as a non-privileged operation. Both of these factors may tend to increase exposure to control flow subversion due to vulnerabilities that allow stack pointers and / or control flow information (e.g., return addresses) to be modified (e.g., to point to malware / attacker-controlled memory).

[0037] In some embodiments, one or more shadow stacks 120 may be included and may be used to help protect the stack 119 from tampering and / or help increase computer security.(Multiple) shadow stacks may represent one or more additional stack-type data structures that are separate from the stack 119. As shown, in some embodiments,(multiple) shadow stacks may be used to store control information 121 instead of data (e.g., parameters and other data that are not of the type stored on the stack, and user-level applications will need to be able to write and modify the parameters and other data). The control information stored on the(multiple) shadow stacks may represent return address related information (e.g., actual return address, information for verifying the return address, other return address information). As a possible example,(multiple) shadow stacks may be used to store a copy of any return address that has been pushed onto the stack 119 when a function or program has been called (e.g., a copy of each return address that has also been pushed onto the general call stack in the call chain). In some embodiments, each shadow stack may also include a shadow stack pointer (SSP), which is operable to identify the top of the shadow stack. In some embodiments, the shadow stack(s) may optionally be configured to run independently in a non-privileged user-level mode (e.g., ring 3 privilege level) or in a privileged or hypervisor privilege level mode (ring 0, ring 1, or ring 2 privilege level). In one aspect, multiple shadow stacks may be configured in the system, but only one shadow stack per logical processor may be configured as the current shadow stack at a time.

[0038] As shown, (multiple) shadow stacks 120 may be stored in memory 114. In some embodiments, (multiple) current or active shadow stacks may be defined by a linear address range to help detect and prevent stack overflow and / or stack underflow when performing push and / or pop operations on the shadow stack. In some embodiments, optionally, to help provide additional protection, (multiple) shadow stacks may be stored in a protected or access-controlled portion of memory to which the non-privileged user-level application 116 has limited and / or incomplete access. Different ways of providing a suitable protected portion of memory for storing (multiple) shadow stacks are possible. In some embodiments, (multiple) shadow stacks may optionally be stored in a portion of memory protected by paging access control. For example, privileged system software 115 (e.g., an operating system) may configure access permissions (e.g., read-write-execute access permissions) in a page table entry corresponding to a page storing (multiple) shadow stacks so that the page is readable but not writable or executable. This may help prevent user-level instructions (e.g., store to memory instructions, move to memory instructions, etc.) from being able to write data into or modify data in (multiple) shadow stacks. As another option, in some embodiments, the shadow stack(s) may optionally be stored in memory using similar access control protections (e.g., for A portion of a secure enclave protected by Software Guard Extensions (SGX) (access control protection for a secure enclave or other protected container, isolated execution environment, etc.).

[0039] Refer again Figure 1 In some embodiments, the processor 101 may be a general-purpose processor (e.g., of the type commonly used as a central processing unit (CPU) in a desktop computer, laptop computer, or other computer system). Alternatively, the processor may be a special-purpose processor. Examples of suitable special-purpose processors include, but are not limited to, network processors, communication processors, cryptographic processors, graphics processors, coprocessors, embedded processors, digital signal processors (DSPs), and controllers (e.g., microcontrollers). The processor may have any of the following architectures: various complex instruction set computing (CISC) architectures, reduced instruction set computing (RISC) architectures, very long instruction word (VLIW) architectures, hybrid architectures, other types of architectures, or a combination of different architectures (e.g., different cores may have different architectures).

[0040] In some embodiments, the processor may have one or more instructions or logic to help manage and protect the (multiple) shadow stacks. The processor has an instruction set 102. The instruction set is part of the instruction set architecture (ISA) of the processor and includes native instructions that the processor is operable to execute. The instructions of the instruction set may represent macroinstructions, assembly language instructions, or machine-level instructions that are provided to the processor for execution, as opposed to microinstructions, micro-operations, or other decoded instructions or control signals that have been decoded from the instructions of the instruction set.

[0041] As shown, in the illustrated embodiment, the instruction set includes an embodiment of a call program or call instruction 103. The instruction set also includes an embodiment of a return from program instruction or return instruction 104. The instruction set also includes an embodiment of a save shadow stack pointer instruction 105. The instruction set also includes an embodiment of a restore shadow stack pointer instruction 106. In other embodiments, optionally, the processor may instead include only as few as any single instruction in these instructions. Embodiments relate to a processor for executing (e.g., decoding and executing) any one or more of these instructions. Other embodiments relate to methods of executing (e.g., decoding and executing) any of these instructions.

[0042] In some embodiments, the processor may include at least one processing element or logical processor 108. For simplicity, only a single logical processor is shown, although it will be understood that the processor may include other logical processors, alternatively. Examples of suitable logical processors include, but are not limited to, cores, hardware threads, thread units, thread slots, and other logical processors. The logical processor is operable to process instructions of an instruction set. The logical processor may have a pipeline or logic for processing instructions. By way of example, each pipeline may include an instruction acquisition unit for acquiring instructions, an instruction decoding unit for decoding instructions, an execution unit for executing decoded instructions, registers for storing source and destination operands of instructions, and the like. The scope of the present invention is not limited to any known type or design of pipeline. In some embodiments, the logical processor is operable to process (e.g., decode, execute, etc.) any one or more instructions of a call instruction, a return instruction, a save shadow stack pointer instruction, and a restore shadow stack pointer instruction.

[0043] As shown, at least some of the logic of the at least one processing element or logical processor 108 may be part of the processor's shadow stack protection logic 110. In some embodiments, the shadow stack protection logic may also include an optional configurable shadow stack mode 111. The shadow stack mode may be operable to be configured to alternately enable or disable the shadow stack. Alternatively, optionally, the shadow stack may always be enabled, and optionally, the shadow stack mode may be omitted. The shadow stack protection logic may also include an embodiment of one or more shadow stack registers 112. The (multiple) shadow stack registers may be operable to specify details related to the current shadow stack.

[0044] The shadow stack protection logic may also include an embodiment of one or more shadow stack descriptor tables (SSDT) ​​registers 113. (Multiple) SSDT registers are operable to specify details related to one or more SSDTs 122. As shown, the SSDT may be stored in a memory. In some embodiments, (multiple) SSDTs may be stored in a protected memory of the same or similar type as the (multiple) shadow stacks. In some embodiments, (multiple) SSDTs may represent tables or other data structures operable to store information or details related to (multiple) shadow stacks, and the corresponding programs may use the (multiple) shadow stacks and / or switch between them. By way of example, privileged system software (e.g., an operating system) may store details related to the shadow stack in the SSDT. In some embodiments, the processor may use the SSDT to establish the current shadow stack and control access to the shadow stack. By way of example, the SSDT may have multiple entries, and each entry may define the scope of the corresponding shadow stack that the program is allowed to use during program execution.

[0045] Figure 2 is a block diagram of an embodiment of a set of shadow stack registers 212 and an embodiment of a set of SSDT registers 213. The shadow stack registers and SSDT registers may be included in a set of control registers 224 of the processor.

[0046] The shadow stack registers are operable to specify a valid range of a current or active shadow stack, which is used to protect the portion of the memory used to store the current or active shadow stack and control access to it. In some embodiments, the range can be specified by a linear address range. The shadow stack registers include a shadow stack base (SSP base) register 225, a shadow stack limit (SSP limit) register 226, and a shadow stack pointer (SSP) register 227. The SSP base register is operable to store the base address of the shadow stack. In one aspect, the SSP base address can be the lowest linear address of the shadow stack. The SSP limit register is operable to store the limit of the shadow stack. In one aspect, the SSP base address can be the highest linear address of the shadow stack. The SSP base address to the SSP limit can together specify a certain memory range as a shadow stack. Memory access control in the processor (e.g., a memory management unit, etc.) can use the SSP base address and the SSP limit to control access to the shadow stack. In some embodiments, user-level store to memory instructions, etc., may not be able to write to the shadow stack. Attempts to write or modify the shadow stack range can be prevented by the processor's hardware (e.g., an exception can be raised). The SSP register is operable to store the address of the current top of the shadow stack. For example, the SSP register may store a linear address representing the current top of the shadow stack between the SSP base address and (SSP limit - 1).

[0047] SSDT register 213 is operable to specify the effective range of the current or active SSDT, which is used to protect the portion of the memory used to store the current or active SSDT and control access to it. In some embodiments, there may be two different types of active SSDTs in the processor at a given time. That is, there may be a current or active privileged level or hypervisor SSDT (SSDT-S) and a current or active user-level SSDT (SSDT-U). In some embodiments, two registers can be used to program each type of SSDT in these different types of SSDTs into the processor. In some embodiments, the SSDT registers may include a first pair of registers 228, 229 for specifying the effective range of the current or active user-level SSDT (SSDT-U) and a second pair of registers 230, 231 for specifying the effective range of the current or active hypervisor SSDT (SSDT-S). User SSDT base register 228 can specify the base address of SSDT-U as, for example, the lowest linear address of page alignment (e.g., 4K page alignment). User SSDT limit register 229 can specify the limit of SSDT-U as, for example, the highest linear address of page alignment. The hypervisor SSDT base register 230 may specify the base address of the SSDT-S as, for example, the lowest linear address that is page aligned. The hypervisor SSDT limit register 231 may specify the limits of the SSDT-S as, for example, the highest linear address that is page aligned. The hypervisor SSDT (SSDT-S) may be programmed into the processor once by privileged system software (e.g., an operating system), and thereafter there may not generally be a need to change it. There may be a different user SSDT (SSDT-U) per user process that is active when a new user process is scheduled.

[0048] Figure 3 is a block diagram of an embodiment of an SSDT 322. An SSDT may represent a table or other data structure that may be stored in a memory. The SSDT may be operable to store information or details related to one or more shadow stacks, allowing a corresponding program to use and / or switch between the one or more shadow stacks. By way of example, an operating system or other privileged system software may store the range of each allowed shadow stack in the SSDT. Thereafter, the SSDT may be checked (e.g., by a processor) to determine the allowed range of shadow stacks and control access to the shadow stacks.

[0049] The SSDT shown is arranged as a table having multiple rows and columns. Different rows can represent different entries corresponding to different valid or invalid shadow stacks that the corresponding program is allowed to use during program execution. In the example shown, there are first entries 335-1 to Nth entries 335-N, where the number of entries (N) can be any appropriate number desired by a particular implementation. By way of example, each application can have its own shadow stack, which is defined by the entries and their SSP base addresses and SSP limits. The SSDT shown has three columns.

[0050] The first column stores the validity indicators of the corresponding entries. As shown, there may be a first validity indicator 336-1 for the first entry and an Nth validity indicator 336-N for the Nth entry. Each validity indicator is operable to indicate whether the corresponding shadow stack is valid or invalid. For example, each validity indicator may have a first value (e.g., set to binary one) for indicating that the corresponding shadow stack is valid, or may have a second different value (e.g., cleared to binary zero) for indicating that the corresponding shadow stack is invalid.

[0051] The second and third columns specify or store the valid range of the shadow stack. Specifically, the second column stores the shadow stack base address (SSP base address), and the third column stores the shadow stack limit (SSP limit). As shown, there may be a first SSP base address 337-1 for the first entry and an Nth SSP base address 337-N for the Nth entry. Similarly, there may be a first SSP limit 338-1 for the first entry and an Nth SSP limit 338-N for the Nth entry. In some embodiments, the SSP base address and the SSP limit may represent the lowest and highest linear addresses of the corresponding shadow stack, respectively. Alternatively, in other embodiments, the data in the first, second, and third columns may be rearranged in various ways. Furthermore, in other embodiments, optionally, in addition to this class table structure or arrangement, other data structures or data arrangements may be used.

[0052] Figure 4is a block diagram of a specific example embodiment suitable for SSDT entry 435. The specifically illustrated SSDT entry is sixteen bytes wide. The least significant bit (bit [0]) represents and / or is used to store a validity indicator. When bit [0] is set to binary one, the validity indicator has a valid indication, and when bit [0] is cleared to binary zero, it has an invalid indication. Alternatively, the opposite convention is also possible. Bits [11:1] and bits [74:64] may represent currently reserved bits (rsvd). In a specific embodiment, when bit [0] is set to binary one and all reserved bits in bits [74:64] and bits [11:1] are cleared to binary zero, the entry may be valid, or otherwise, may be invalid. Alternatively, optionally, the reserved bits may be ignored. Bits [63:12] represent and / or are used to store an SSP base address. Bits [127:75] represent and / or are used to store SSP limits. As mentioned before, the SSP base address and SSP limit can be used to specify or limit the effective range of the shadow stack corresponding to the entry. In other embodiments, SSDT entries of other sizes can be used, and the validity indicator, SSP base address and SSP limit can be rearranged or relocated in various ways.

[0053] You can use the SSDT selector to index a given entry or row of the SSDT. Figure 5is a block diagram of an example embodiment of an SSDT selector 540. The specifically shown SSDT selector is a 32-bit number. Alternatively, optionally, the SSDT selector may be wider or narrower than 32 bits. Bit

[31] of the specifically shown SSDT selector stores or represents a user-hypervisor indicator. When bit

[31] is set to binary one, the user-hypervisor indicator may have a user indication. When bit

[31] is cleared to binary zero, the user-hypervisor indicator may have a hypervisor indication. Alternatively, the opposite convention is also possible. The specifically shown SSDT bits [30:0] store or represent an SSDT index. The SSDT index may be used to index into the SSDT and / or select a particular row or entry of the SSDT. When the user-hypervisor indicator has a user indication, the SSDT index may index into a user SSDT (SSDT-U), and when the user-hypervisor indicator has a hypervisor indication, the SSDT index may index into a hypervisor SSDT (SSDT-S). In some embodiments, the SSDT selector may only be valid and / or only be allowed to select or index an SSDT entry when the SSDT index in bits [30:0] is within the allowed range or boundaries of the corresponding SSDT. In addition, the SSDT selector may only select a valid shadow stack for the selected or indexed SSDT entry or indicate that it is valid (e.g., bit [0] is set to binary one and all reserved bits are cleared).

[0054] In different embodiments, the shadow stack selection information may be stored in different places. As one possible example, in some embodiments, the shadow stack selection information may be stored in certain In another embodiment, the shadow stack selection information may be included in a task state segment (TSS) structure in a compatible computer. Alternatively, in other embodiments, the shadow stack selection information may be included in a different data structure in the memory. In still other embodiments, the shadow stack selection information may be included in a control register of the processor. Combinations of this approach may also be suitable.

[0055] Figure 6 is a block diagram of an example embodiment of a 32-bit task state segment (TSS) structure 645. The TSS may represent A hardware managed data structure in memory on an architecture-compatible computer that can be used to store information related to a task. The processor and privileged system software can use the TSS and the information stored therein to perform stack switches and / or task switches. The processor can have a task register (e.g., a fragment register for storing a fragment selector) that can point to or indicate a valid TSS fragment descriptor. To enhance security, the TSS can be stored in a memory to which access is controlled and / or which can only be accessed by privileged software.

[0056] If the operating system or other privileged system software uses a processor privilege level protection mechanism, the task execution space may include different stacks of different privilege levels (e.g., call stacks for storing both control and data). As shown, the 32-bit TSS has three 32-bit stack pointers labeled ESP0, ESP1, and ESP2, which are offsets in the SS0, SS1, and SS2 stack fragments, respectively. In other embodiments, fewer or more stack pointers may be used, optionally. These three 32-bit stack pointers may point to or identify three different stacks of three different corresponding privilege levels. Specifically, ESP0 may correspond to privilege level zero; ESP1 may correspond to privilege level one; and ESP2 may correspond to privilege level two. When a privilege level change is made to a processor running in 32-bit mode, the 32-bit stack pointer may be used to identify the appropriate stack. As shown, the 32-bit TSS also has three corresponding 32-bit stack fragment selectors (labeled SS0, SS1, and SS2). As an example, when a processor transitions from user level to privilege level zero, the processor may retrieve a stack pointer ESP0 and a stack segment selector SS0 appropriate for the target privilege level zero and store their values ​​in the processor's ESP and SS registers.

[0057] In some embodiments, if the operating system or other privileged system software uses a processor privilege level protection mechanism, different shadow stacks of different privilege levels may also exist. As shown, in some embodiments, the 32-bit TSS may also have three 32-bit shadow stack selectors (labeled as SSDT selector 0, SSDT selector 1, and SSDT selector 2). In other embodiments, optionally, fewer or more shadow stack selectors may be used. These three 32-bit shadow stack selectors may point to or otherwise identify three different corresponding shadow stack descriptor table (SSDT) ​​entries of three different corresponding privilege levels. For example, SSDT selector 0 may identify the SSDT entry of the shadow stack that will be used at privilege level zero; SSDT selector 1 may identify the SSDT entry of the shadow stack that will be used at privilege level one; and SSDT selector 2 may identify the SSDT entry of the shadow stack that will be used at privilege level two. SSDT entries may be used to store shadow stack base addresses (SSP base addresses) and limits (SSP limits) for different allowed shadow stacks for corresponding processes or tasks. When there is a privilege level change in the memory running in 32-bit mode, the 32-bit shadow stack selector (SSDT selector 0, SSDT selector 1 and SSDT selector 2) can be used to identify the appropriate SSDT entry of the target privilege level. For example, when the processor changes from user level to privilege level zero, the processor (in addition to retrieving ESP0 and SS0) can retrieve the 32-bit shadow stack selector SSDT selector 0 suitable for privilege level zero. The retrieved 32-bit shadow stack selector can point to the corresponding SSDT entry, and the shadow stack base address (SSP base address) and shadow stack limit (SSP limit) can be obtained at the SSDT entry. This can allow different privilege levels to use different shadow stacks, and can also allow different shadow stacks to be used for different processes. Accordingly, when there is a privilege level change in the processor, the 32-bit shadow stack selector in the TSS can be used to switch the shadow stack. The 32-bit TSS also includes a TSS SSP 649 and a TSS SSDT selector 648 for setting up a shadow stack when scheduling tasks for execution through the corresponding TSS. When the processor performs a task switch, it can save the SSP of the current task to the TSS SSP field of the TSS of the current task. Subsequently, the processor can load the TSS SSDT selector from the TSS of the new task and use it to locate the SSP base address and SSP limit of the shadow stack of the new task. Then, the value of the TSS SSP field from the TSS of the new task can be used to establish the SSP of the new task. The displayed position and arrangement of the SSDT selector, TSSSSP and TSS SSDT are not necessary. In other embodiments, optionally, these fields can be located elsewhere and can be rearranged in various ways.

[0058] The 32-bit TSS also has a data field for performing task switching. Typically, a task can represent a work unit that a processor can schedule, execute and suspend. By way of example, a task can be used to perform one or more of the following: a program, a task or a process, an operating system service utility, an interrupt or an exception handler, or a kernel or an execution utility. On the one hand, a task switch can be performed when a call program instruction is executed, when a jump to a program instruction is executed, when an interrupt or an exception occurs, or in other ways. When performing a task switch from a current task to a new task, the state of the current task can be stored in the TSS corresponding to the current task, and the state of the new task can be loaded or retrieved from the TSS corresponding to the new task. As shown, the 32-bit TSS can include a state save field 646 for storing different types of processor states. For example, this field can store CR3 or a page directory base address register (PDBR), an instruction pointer (EIP), an EFLAGS register, a general register (e.g., EAX, ECX, EDX, etc.), a fragment selector (e.g., ES, CS, SS, etc.). The 32-bit TSS may also have other fields 647, which are not described herein for simplicity.

[0059] Figure 7 7 is a block diagram of an example embodiment of a 64-bit TSS structure 745. The 64-bit TSS has certain similarities to the 32-bit TSS. To avoid obscuring the description, the different or new features of the 64-bit TSS will be primarily described.

[0060] In 64-bit mode, as in 32-bit mode, if the operating system or other privileged system software uses the processor privilege level protection mechanism, the task execution space may include different stacks of different privilege levels (e.g., call stacks for storing both control and data). As shown, the 64-bit TSS has three 64-bit stack pointers (labeled as (RSP0, RSP1, and RSP2). Each of the 64-bit stack pointers is divided into a high and low 32-bit portion. These three 64-bit stack pointers may roughly correspond to the 32-bit stack pointers ESP0, ESP1, ESP2, respectively. In other embodiments, optionally, fewer or more stack pointers may be used. RSP0 may correspond to privilege level zero; RSP1 may correspond to privilege level one; and RSP2 may correspond to privilege level two. When a privilege level change occurs in a processor running in 64-bit mode, the 64-bit stack pointer may be used to identify the appropriate stack.

[0061] In some embodiments, if the operating system or other privileged system software uses a processor privilege level protection mechanism, different shadow stacks of different privilege levels may also exist. As shown, in some embodiments, the 64-bit TSS may also have three 64-bit shadow stack selectors (labeled as SSDT selector 0, SSDT selector 1, and SSDT selector 2). In other embodiments, optionally, fewer or more shadow stack selectors may be used. Each of the three 64-bit shadow stack selectors may point to or otherwise identify different corresponding shadow stack descriptor table (SSDT) ​​entries under different corresponding execution privilege levels. SSDT selector 0 may point to an SSDT entry of a shadow stack that will be used at privilege level zero; SSDT selector 1 may point to an SSDT entry of a shadow stack that will be used at privilege level one; and SSDT selector 2 may point to an SSDT entry of a shadow stack that will be used at privilege level two. When a privilege level change occurs in a processor running in 64-bit mode, the 64-bit shadow stack selector may be used to identify the appropriate SSDT entry of the target privilege level. As described previously, the identified SSDT may store the shadow stack base addresses (SSP base addresses) and SSP limits (SSP limits) of different allowed shadow stacks of the corresponding task or process.

[0062] In 64-bit mode, there is also a mechanism for switching stacks when being called as interrupt stack table (IST).This mechanism can allow interrupt handling program to use different stacks (for example, the call stack of storage control and data).64 TSS includes seven interrupt stack table selector fields IST1 to IST7.Each field in these fields has lower half and upper half.Therefore, these seven interrupt stack selector fields can allow up to seven different stacks to be used for interrupt handling.The interrupt descriptor table entry for calling interrupt or exception handling program can be programmed with the IST index for selecting one of these seven stacks from IST.

[0063] In certain embodiments, optionally, mechanism can also be used to switch stack during terminal or exception handling.In certain embodiments, optionally, 64 TSS can include seven interrupt shadow stack tables SSDT selectors for each IST index IST1 to IST7.Each field in these fields can be used to specify the shadow stack that will be used for interrupt handling.Therefore, these seven interrupt shadow stack selector fields can allow up to seven different shadow stacks to be used for interrupt handling.By way of example, when interruption or exception occurs, both can be used for selecting or identifying new stack by interrupt stack table selector field (for example, IST3), and can be used for selecting or identifying new shadow stack by interrupt shadow stack table selector field (for example, SSDT selector IST3).

[0064] The illustrated positions and arrangements of the SSDT selector and SSDT selectors IST1 to IST7 are not required. In other embodiments, these fields may optionally be located elsewhere and may be rearranged in various ways.

[0065] Now, although 32-bit mode and 32-bit TSS include hardware-managed task switching capabilities, most modern host operating systems do not use these hardware-managed task switching capabilities. Accordingly, 64-bit TSS omits many of these hardware-managed task switching capabilities. When performing a task switch from a current task to a new task, the state of the current task is not saved in the 64-bit TSS, and the state of the new task is not retrieved from the 64-bit TSS. The 64-bit TSS does not include the state save field 646 included in the 32-bit TSS.

[0066] Figure 8 8 is a block diagram of an embodiment of a processor 801 operable to execute an embodiment of a call program instruction 803 and an embodiment of a return from program instruction 804. To simplify the description, the call program instruction will often be simply referred to as a call instruction, and the return from program instruction will often be simply referred to as a return instruction. The call and return instructions may represent instructions or control signals of an instruction set of a processor.

[0067] During operation, the processor may receive a call instruction 803. For example, a call instruction may be received from a caller that calls a subroutine, a routine, a handler, etc. For example, an instruction may be received from a memory via a bus or other interconnection. In some embodiments, the call instruction may explicitly specify (e.g., by one or more fields or bit sets) or otherwise indicate (e.g., implicitly indicate) a return address 873 as a source operand. Without limitation, the return address may generally be the address of the next instruction after the call instruction in the program. As an example, the instruction may have a source operand specifying field for specifying a register or other storage location where the return address will be stored. Alternatively, optionally, the register or other storage location may be implicit to the instruction (e.g., implicit to the opcode of the instruction). As yet another option, the instruction may have an intermediate or other field for providing an indication of the return address. The indicated return address may be an actual address or an offset from the return address (e.g., an offset from the instruction after the call instruction) to the return address.

[0068] The processor also includes a set of registers 872. In some embodiments, the registers may represent general purpose registers. As shown, in some embodiments, the return address 873 may optionally be stored in a register. Alternatively, other storage locations may be used.

[0069] The processor also includes a decoding unit or decoder 870. The decoding unit can receive a call instruction and decode it into one or more decoded instructions or control signals. The processor also includes a call execution unit 871C, which is coupled to the decoding unit 870 and the register 872 and is operable to be coupled to or otherwise communicate with a memory 874. The call execution unit can receive the one or more decoded instructions or control signals. The call execution unit can also receive an indicated return address 873. In some embodiments, the call execution unit is responsive to and / or as a result of the call instruction (e.g., in response to the one or more decoded instructions or control signals decoded therefrom) and is operable to push or otherwise store the return address and CS (in the case of a remote call) onto a stack 875. In some embodiments, the call execution unit is responsive to and / or as a result of the call instruction (e.g., in response to the one or more decoded instructions or control signals decoded therefrom) and is also operable to push or otherwise store the return address and CS (in the case of a remote call) onto a shadow stack 877.

[0070] In some embodiments, the call execution unit is operable to: push or otherwise store the return address and CS (in the case of a remote call) onto the shadow stack even when the access rights associated with the shadow stack indicate that the shadow stack is not writable. For example, in some embodiments, the portion of the memory with the shadow stack can be protected by paging. In some embodiments, privileged system software (e.g., operating system) can configure access rights for pages with shadow stacks in page table entries so as to make the pages non-writable (e.g., so as to make the pages read-only). In some embodiments, this can effectively prevent other instructions stored in memory, written to memory, moved to memory, and the same instruction set from being able to be stored or written into the shadow stack. However, the call execution unit in response to the call instruction is operable to: store the return address on the stack even when such access rights indicate that the shadow stack is not writable. That is, the call execution unit in response to the call instruction can ignore the non-writable access rights for pages used for the shadow stack in the page table entries. However, such access protection can effectively prevent user-level software (e.g., store to memory instructions) from being able to modify the shadow stack contents. Moreover, similar heterogeneous storage capabilities may alternatively be implemented under other different types of access permissions (e.g., of the type used for protected enclaves or other protected containers).

[0071] In some embodiments, before the call execution unit stores the return address on the shadow stack, the call execution unit is operable to perform one or more additional security checks or protections. In some embodiments, the call execution unit may check whether the shadow stack is enabled. If the shadow stack is enabled, the call execution unit may continue, or otherwise, it may stop without storing the return address on the shadow stack.

[0072] In some embodiments, before pushing or storing the return address on the shadow stack, the call execution unit is operable to check or determine whether pushing or storing the new return address will cause the shadow stack pointer (SSP) to exceed the boundaries defined by the shadow stack base address (e.g., exceed the SSP base address). For example, the call execution unit is operable to subtract the shadow stack width required to process the return address (e.g., the number of bytes to be pushed) from the current SSP. The shadow stack can grow downward as a conventional stack normally does. When the shadow stack is empty, the lowest address or SSP can be used. Before performing the store, storing the return address on the stack can decrement or reduce the shadow stack address or SSP. By way of example, in some Intel architecture processors, the shadow stack width can be 4 bytes or 8 bytes, depending on the mode. The call execution unit is operable to determine: after decrementing the SSP by the width of the shadow stack, whether the resulting SSP is less than the shadow stack base address (SSP base address). If so, the attempted push of the return address can be considered to be out of bounds and the view push can not be performed. For example, a stack fault (#SS) or other abnormal condition can be asserted. Otherwise, the calling execution unit may push or store the return address onto the shadow stack at the resulting decrement or reduction of SSP.

[0073] This checking and preventing the shadow stack from exceeding the allowed shadow stack range can help prevent data from being stored outside the protected shadow stack in general / standard unprotected memory. Otherwise, this may allow the return address to exist outside the protected shadow stack range, where the return address may be modified or tampered with. Accordingly, the shadow stack range can help ensure that only call instructions are allowed to store return addresses within the shadow stack protection range.

[0074] Subsequently, the processor may receive a return instruction 804. For example, a return instruction may be the last instruction of a called subroutine, handler, routine, or program that returns control flow to the program that has called the control flow.

[0075] The decode unit 870 may receive a return instruction and decode it into one or more decoded instructions or control signals. The processor includes a return execution unit 871R coupled to the decode unit 870 and operable to be coupled to or otherwise communicate with a memory 874. The return execution unit may be either the same execution unit as the execution unit for the call instruction or a different execution unit. Different execution units are shown to improve clarity of the description, although this is not required.

[0076] In some embodiments, the return execution unit 871R is operable in response to a return instruction and / or as a result of a return instruction (e.g., in response to the one or more decoded instructions or control signals decoded therefrom) to pop or otherwise receive 882 a return address 876 (and CS in the case of a remote call) from the stack 875 and to pop or otherwise receive 884 a return address 878 (and CS in the case of a remote call) from the shadow stack 877. In some embodiments, the return execution unit is operable in response to a return instruction and / or as a result of a return instruction to return control flow to a return address using or based on a return address (e.g., return address information) stored on the shadow stack.

[0077] In some embodiments, the return execution unit is operative to verify or ensure the integrity of the return address stored on the stack in response to the return instruction and / or as a result of the return instruction. For example, the return execution unit is operative to determine whether the return addresses stored on the stack and the shadow stack are equal, matched, or otherwise consistent. The return execution unit is operative to compare the return address on the stack with the return address information on the shadow stack (e.g., a copy of the return address, a hash of the return address, etc.). In some embodiments, the same return address can be stored on both the stack and the shadow stack so that the two values ​​should be equal or identical in order to match or be consistent. If it is determined that the return address information is consistent, the return execution unit may allow the control flow to be transferred to the return address. For example, the return execution unit is operative to cause the return address to be stored in the instruction pointer register 880. On the contrary, if it is determined that the return address information is inconsistent, the return execution unit may not allow the control flow to be transferred to the return address on the stack. For example, the return execution unit is operative to cause an exception 885 (e.g., a control protection exception) to a handler module (e.g., a privileged system). Advantageously, confining or limiting the transfer of control flow to return addresses on the stack in the event of mismatched or inconsistent information can help prevent ROP and other control flow subversion attacks, or at least make such attacks significantly more difficult to initiate.

[0078] Alternatively, the return execution unit can use the return address information stored on the shadow stack to provide protection in other ways, rather than comparing the return address information stored on the stack and the shadow stack. For example, in other embodiments, the return execution unit is responsive to a return instruction and / or as a result of a return instruction and is operable to use the return address on the shadow stack to rewrite the return address on the stack. In still other embodiments, the return execution unit is operable to use the return address stored on the shadow stack to directly transfer control flow to jump or otherwise return to the return address, rather than using the return address on the stack. For example, the return address on the shadow stack can be stored in the instruction pointer register.

[0079] In some embodiments, optionally, before the return execution unit pops up or otherwise retrieves the return address from the shadow stack, the return execution unit is operable to perform one or more additional security checks or protections. In some embodiments, the return execution unit is operable to check whether the shadow stack is enabled. If the shadow stack is enabled, the return execution unit can continue, or otherwise, it can stop without storing and retrieving the return address from the shadow stack. In some embodiments, before the return address is popped up or retrieved from the shadow stack, the return execution unit is operable to check or determine whether the pop-up or retrieved return address will be read from an address outside the allowed boundary defined by the shadow stack limit (SSP limit). The shadow stack can grow downward as a conventional stack usually does. As the return address is popped up or otherwise deleted from the stack, the shadow stack address or SSP can be incremented or otherwise increased after reading the content from the shadow stack. The return execution unit is operable to: before reading the first or last byte of the content from the shadow stack, determine whether the SSP exceeds the limit (SSP limit-1). By way of example, in some Intel architecture processors, depending on the mode, the shadow stack width can be 4 bytes or 8 bytes. If so, then attempting to pop or delete the return address or data from the shadow stack may be considered out of bounds and the operation may not be performed. For example, the return execution unit may assert a stack fault (#SS) or other abnormal condition. Therefore, attempting to perform a shadow stack operation outside the shadow bounds defined by the privileged system software may fail or cause an exception. Otherwise, the current contents of the top of the shadow stack [SSP] may be popped or retrieved from the shadow stack.

[0080] This check and prevention of shadow stack beyond the allowed shadow stack range can help prevent access to data outside the protected shadow stack in general / standard unprotected memory. Otherwise, this may allow the return address that may be modified outside the protected shadow stack range to be used by the return instruction. Accordingly, the shadow stack range can help ensure that only the return instruction is allowed to retrieve the return address from the shadow stack protection range.

[0081] Also disclosed herein are save SSP instructions and restore SSP instructions. In some embodiments, these instructions can be used to help manage and protect SSP during user-level or user-mode thread switching. Thread switching can involve stopping the execution of a first thread (e.g., on a hardware thread, core, or other logical processor) and starting the execution of a second thread. Typically, such thread switching also involves context switching. In context switching, the current context or state of the stopped thread (e.g., the first thread) can be saved. Then, when the stopped thread is restarted later, the saved context or state can be restored so that the restarted thread can restart at the point where it stopped. The shadow stack context including the SSP represents the context that should also be saved and restored (and in a safe and protected manner). The save SSP instruction and the restore SSP instruction can help switch the shadow stack and save and restore the SSP in a safe and protected manner that does not compromise the security of the shadow stack. In some embodiments, user-level applications should not be able to manipulate the SSP arbitrarily. For example, when switching from a first thread to a second thread, it can only be allowed to switch to the same point in the second thread where the execution was stopped before, rather than any other arbitrary point. In other words, when switching to the second thread, the user-level application may only be able to use the same SSP that the second thread had before (when it last stopped running). Advantageously, in some embodiments, the Save SSP instruction and the Restore SSP instruction may be user-level instructions that may be executed under non-privileged or user-level execution privileges. This may help avoid the need to have privileged system software perform save and restore of the SSP and facilitate user-level multithreading.

[0082] Fig. 9 is a block flow diagram of an embodiment of a method 987 of executing an embodiment of a save shadow stack pointer instruction. In various embodiments, the method may be performed by a processor, an instruction processing apparatus, or other digital logic device.

[0083] The method includes receiving a save shadow stack pointer instruction at box 988. In various aspects, the instruction may be received at a processor or a portion thereof (e.g., an instruction fetch unit, a decode unit, a bus interface unit, etc.). In various aspects, the instruction may be received from a source outside the processor and / or outside the die (e.g., from a memory, an interconnect, etc.), or from a source on the processor and / or on the die (e.g., from an instruction cache, an instruction queue, etc.). In various embodiments, the save shadow stack pointer instruction may specify (e.g., explicitly specify) or otherwise indicate (e.g., implicitly indicate) a destination register, a location in a memory, or other storage location. By way of example, optionally, the destination storage location may be a general register that may be either explicitly specified or implicitly indicated by the instruction.

[0084] At block 989, a current shadow stack pointer (SSP) may be pushed or otherwise stored into the current shadow stack in response to and / or as a result of the instruction. In some embodiments, the current SSP may be accessed from a control register of the processor and may then be stored into the current top of the current shadow stack.

[0085] At block 990, after the current SSP is stored in the current shadow stack, a new or updated SSP (e.g., reflecting any decrement or reduction of the SSP due to the store or push) may be stored in the indicated destination storage location in response to and / or as a result of the instruction. Without limitation, the software may save the SSP stored in the destination so that it may be presented again (e.g., by a resume SSP instruction) when switching back to the stopped thread. This may facilitate resuming execution at the point where execution of the thread was stopped.

[0086] The methods presented involve architectural operations (e.g., operations visible from a software perspective). In other embodiments, the methods may optionally include one or more micro-architectural operations. By way of example, instructions may be fetched, decoded, and dispatched out of order, source operands may be accessed, an execution unit may perform micro-architectural operations to implement instructions, and the like.

[0087] Fig.10 is a block diagram of an embodiment of a processor 1001 operable to execute an embodiment of a Save SSP instruction 1005. In some embodiments, the processor 1001 may execute Fig. 9Method 987. Optionally, the components, features, and specific optional details described herein for processor 1001 also apply to method 987. Alternatively, method 987 may be performed by and / or within a similar or different processor or device. In addition, processor 1001 may perform a method similar to or different from method 987.

[0088] During operation, the processor may receive a Save SSP instruction 1005. For example, the instruction may be received from a memory via a bus or other interconnect. The instruction may represent an instruction or control signal of an instruction set of the processor. In some embodiments, the Save SSP instruction may explicitly specify (e.g., via one or more fields or bit sets) or otherwise indicate (e.g., implicitly indicate) a destination storage location 1097 where the result is to be stored. As an example, the instruction may have a destination designation field for specifying a register, memory location, or other storage location as the destination storage location. Alternatively, optionally, one or more of these storage locations may be implicit to the instruction (e.g., implicit to the opcode of the instruction). As shown, in some embodiments, optionally, the destination storage location (DEST) 1097 may be a register of a set of registers 1072 (e.g., general purpose registers) of the processor.

[0089] The processor also includes a decode unit or decoder 1070. The decode unit may receive and decode the Save SSP instruction into one or more decoded instructions or control signals. The processor also includes a Save SSP execution unit 1071. The Save SSP execution unit may also be simply referred to as an execution unit. The execution unit is coupled to the decode unit 1070 and the register 1072. The execution unit is also coupled to the SSP register 1012 of the processor. When the processor is deployed in a system, the execution unit may be operable to couple to or otherwise communicate with the memory 1074. The execution unit may receive the one or more decoded instructions or control signals.

[0090] In some embodiments, the execution unit is further operable to retrieve or otherwise receive the current SSP 1096 from the SSP register 1012 in response to and / or as a result of the save SSP instruction (e.g., in response to the one or more decoded instructions or control signals decoded therefrom). The execution unit is further operable to push or otherwise store the received current SSP 1096 onto the shadow stack 1077 as the current SSP 1092 in response to and / or as a result of the instruction. In other words, the execution unit may save a copy of the current SSP 1096 on the shadow stack. The shadow stack may provide a secure and protected place to store the current SSP where user-level software cannot modify the current SSP or tamper with the current SSP. Optionally, the shadow stack may also store return address information 1017, although this is not required.

[0091] The execution unit is also operable to store a new or updated current SSP 1091 to a destination storage location 1097 indicated by the instruction after the current SSP is stored in the shadow stack in response to the instruction and / or as a result of the instruction. The new SSP may reflect the decrement or reduction of the SSP caused by storing the current SSP on the shadow stack. The new SSP stored in the destination represents the point at which the thread stops executing or stops. Without limitation, the software can save the new SSP so that the new SSP can be presented when the thread is restarted or switched back to the thread at the point where the thread has stopped before. By way of example, as will be further discussed below, the new SSP may be provided as a source operand of the restore SSP instruction. However, in some embodiments, the destination storage location may not be a fully protected location (e.g., the destination storage location may be a general register, a location in a general / conventional memory, etc.), and the software may be able to modify the new SSP in the destination storage location. Accordingly, as will be discussed further below, the current SSP 1092 stored on the shadow stack may be used to validate any such presented SSP (eg, in response to and / or as a result of a restore SSP instruction).

[0092] In some embodiments, before storing the current SSP 1092 on the shadow stack, the execution unit is operative, in response to and / or as a result of an instruction, to check or determine whether pushing or storing the current SSP onto the shadow stack will cause the SSP to exceed the allowed boundaries defined by the shadow stack base address for the current shadow stack. For example, the execution unit is operative to subtract the shadow stack width required to process the current SSP (e.g., the number of bytes to be pushed) from the current SSP. The execution unit is operative to determine whether the resulting SSP will be less than the shadow stack base address. If so, the attempted push of the current SSP may be considered out of bounds and the attempted push may not be performed. For example, a stack fault (#SS) or other abnormal condition may be asserted. Otherwise, the execution unit may store the current SSP onto the shadow stack at the resulting decrement or reduction SSP.

[0093] Fig.11 1 is a block flow diagram of an embodiment of a method 1101 of executing an embodiment of a restore shadow stack pointer instruction. In various embodiments, the method may be executed by a processor, an instruction processing apparatus, or other digital logic device.

[0094] The method includes receiving a restore shadow stack pointer instruction at block 1102. In some embodiments, the restore SSP instruction may specify (e.g., explicitly specify) or otherwise indicate (e.g., implicitly indicate) an SSP and may specify or otherwise indicate a shadow stack descriptor table (SSDT) ​​selector. By way of example, the instruction may specify or indicate a register (e.g., a general register) or other storage location having SSP and SSDT selectors.

[0095] The method includes performing a plurality of authentications or protections in response to and / or as a result of the instructions.

[0096] At block 1103, a determination may be made as to whether an SSDT selector (e.g., an SSDT selector provided by an instruction) indicates a valid entry in the SSDT. If the SSDT selector does not indicate a valid entry in the SSDT (i.e., if a "yes" determination is made), the method may proceed to block 1104. Otherwise, (i.e., if a "no" determination is made) the method may proceed to block 1108.

[0097] At block 1104, a determination may be made as to whether the SSP indicated by the instruction is within the SSP base address and SSP limits specified in the entry of the SSDT indicated or selected by the SSDT selector (e.g., the SSDT selector provided by the instruction). If the SSP is within the SSP base address and SSP limits (i.e., if a "yes" determination), the method may proceed to block 1105. Otherwise, (i.e., if a "no" determination) the method may proceed to block 1108.

[0098] At block 1105, a determination may be made as to whether the SSP indicated by the instruction is equal to, matches, or otherwise consistent with the SSP received from the shadow stack. In some embodiments, the SSP received from the shadow stack may be the SSP stored there by a previous save SSP instruction. In other embodiments, a hash may be used for one of the SSP values ​​so that consistency need not be so constrained to matching or being equal, but may be consistency achieved through a transformation (e.g., a hash). If the SSPs are consistent (i.e., if a "yes" determination is made), the method may proceed to block 1106. Otherwise, (i.e., if a "no" determination is made) the method may proceed to block 1108.

[0099] If any of the verification or protection of blocks 1103, 1104, and 1105 fails, the method may proceed to block 1108. At block 1108, an exception may be raised, and then the instruction may complete without restoring the shadow stack state or context.

[0100] Alternatively, if all items in the verification or protection of blocks 1103, 1104, and 1105 succeed, the method can proceed to block 1107. At block 1107, the shadow stack state or context can be restored in response to and / or as a result of the instruction. In some embodiments, as shown at block 1107, the SSP base address and SSP limit obtained from the entry of the SSDT selected by the SSDT selector can be stored in a control register of the processor (e.g., shadow stack register 112). In some embodiments, as shown at block 1107, the SSP can also be stored in a control register of the processor (e.g., shadow stack register 112). In some embodiments, the verified SSP of the source operand from the instruction can be stored in the control register. In other embodiments, the SSP retrieved from the shadow stack can be stored in the control register.

[0101] The methods presented involve architectural operations (e.g., operations visible from a software perspective). In other embodiments, the methods may optionally include one or more micro-architectural operations. By way of example, instructions may be fetched, decoded, and dispatched out of order, source operands may be accessed, an execution unit may perform micro-architectural operations to implement instructions, and the like.

[0102] Fig.12 is a block diagram of an embodiment of a processor 1201 operable to execute an embodiment of a Resume SSP instruction 1206. The instruction may represent an instruction of an instruction set of the processor or a control signal.

[0103] In some embodiments, the restore SSP instruction may explicitly specify (e.g., through one or more fields or bit sets) or otherwise specify (e.g., implicitly indicate) a first source operand (SRC1) 1295 for storing the SSP 1291, and may specify or otherwise indicate a second source operand (SRC2) 1294 for storing a shadow stack descriptor table (SSDT) ​​selector 1299. As an example, the instruction may have source and / or destination operand designation fields for specifying registers, memory locations, and other storage locations for the operands. Alternatively, one or more of these operands may be implicit to the instruction (e.g., implicit to the opcode of the instruction). As shown, in some embodiments, the first and second source operands may optionally be stored in registers of a set of registers 1272 (e.g., general purpose registers) of the processor. Alternatively, a memory location or other storage location may optionally be used for one or more of these operands.

[0104] The processor also includes a decoding unit or decoder 1270. The decoding unit can receive the restore SSP instruction and decode it into one or more decoded instructions or control signals. The processor also includes a restore SSP execution unit 1271. The restore SSP execution unit can also be simply referred to as an execution unit. The execution unit is coupled to the decoding unit and the register. When the processor is deployed in the system, the execution unit can be operated to be coupled to the memory 1274 or otherwise communicate with it. The execution unit can receive the one or more decoded instructions or control signals. The execution unit can also receive the SSP 1291 and the SSDT selector 1299.

[0105] In some embodiments, the execution unit 1271 is further operable to perform multiple verifications or protections before restoring the shadow stack context or state in response to an instruction and / or as a result of a restore SSP instruction (e.g., in response to the one or more decoded instructions or control signals decoded therefrom). In some embodiments, the execution unit is operable to use the SSDT selector 1299 to select or indicate an entry 1235 in the SSDT 1222 in response to an instruction and / or as a result of an instruction, and to determine whether the entry is valid or invalid. If the entry is invalid, the instruction can be completed without restoring the shadow stack state or context and in some embodiments an exception 1293 can be raised (e.g., to the handler module 1279). Otherwise, the execution unit can continue to perform one or more other verifications. In some embodiments, the execution unit can be performed as described above for Figure 3 The validity is determined as mentioned (eg, using the value of the validity indicator and (optionally) reserved bits).

[0106] In some embodiments, the execution unit is operable to determine, in response to and / or as a result of the instruction, whether the SSP 1291 indicated by the first source operand is within the SSP base address 1237 and SSP limits 1238 specified by the verified valid entry 1235 of the SSDT 1222 selected by the SSDT selector 1299. If the SSP is not within the SSP base address and SSP limits, the instruction may complete without restoring the shadow stack state or context, and in some embodiments may raise an exception 1293. Otherwise, the execution unit may continue to perform one or more other verifications.

[0107] In some embodiments, the execution unit is operable to determine, in response to an instruction and / or as a result of an instruction, whether the SSP 1291 of the first source operand is equal to, matches, or otherwise consistent with the current SSP 1292 stored on the shadow stack 1277. In some embodiments, the SSP 1292 may have been stored on the shadow stack by a previous save SSP instruction (e.g., instruction 1005). If they do not match or are otherwise inconsistent, the instruction may be completed without restoring the shadow stack state or context, and in some embodiments, an exception 1293 may be raised. Otherwise, in some embodiments, the execution unit may determine that the SSDT selector 1299 and SSP 1291 indicated by the instruction are sufficiently verified. This consistency check may help ensure that user-level applications cannot arbitrarily manipulate the SSP.

[0108] In some embodiments, the execution unit is optionally operable to zero, invalidate, change, or otherwise compromise the current SSP 1292 stored on the shadow stack in response to and / or as a result of an instruction, although this is not required. This can help ensure that the current SSP can only be used once and cannot be reused, which can help provide further protection.

[0109] In some embodiments, the execution unit is operable to store the shadow stack context or state after fully validating the SSDT selector 1299 and the SSP 1291 in response to and / or as a result of an instruction. For example, in some embodiments, the execution unit is operable to store the SSP base 1237 from the entry 1235 in the SSP base register 1225 in the set of shadow stack registers 1212 of the processor, to store the SSP limit 1238 from the entry in the SSP limit register 1226, and to store the SSP in the SSP register 1227. In some embodiments, the SSP 1291 of the first source operand may be stored in the SSP register 1227. In other embodiments, the SSP 1292 from the shadow stack may be stored in the SSP register 1227.

[0110] It should be understood that this is merely one illustrative example embodiment of a Restore SSP instruction and a processor for executing the Restore SSP instruction. In other embodiments, optionally, fewer or more validations may be performed before restoring the shadow stack context, depending on the desired level of protection for a particular implementation. Other embodiments relate to a Restore SSP instruction optionally with any one or more of the validations or protections described above in addition to other validations or protections.

[0111] Already targeted Figure 8 , Fig.10 and Fig.12 Processors are shown and described. In some embodiments, these processors can be general purpose processors (e.g., of the type described previously). Alternatively, the processor can be a special purpose processor (e.g., of the type described previously). The processor can have a CISC, RISC, VLIW, hybrid, or other architecture or a combination thereof.

[0112] Figure 8 , Fig.10 and Fig.12The decode unit is operable to decode the received higher-level instructions and output one or more relatively low-level instructions or control signals (e.g., one or more microinstructions, micro-operations, microcode entry points, decoded instructions or control signals, etc.) that reflect, represent, and / or are derived from the received relatively high-level instructions. In some embodiments, the decode unit may include one or more input structures (e.g., (multiple) ports, (multiple) interconnections, interfaces) for receiving instructions, instruction recognition and decoding logic coupled thereto for recognizing and decoding instructions, and one or more output structures (e.g., (multiple) ports, (multiple) interconnections, interfaces) coupled thereto for outputting (multiple) lower-level instructions or (multiple) control signals. The decode unit may be implemented using a variety of different mechanisms, including, but not limited to: a microcode read-only memory (ROM), a lookup table, a hardware implementation, a programmable logic array (PLA), and other mechanisms suitable for implementing the decode unit.

[0113] In some embodiments, alternatively, instruction simulators, converters, deformers, interpreters or other instruction conversion modules can be used, rather than instructions being directly provided to the decoding unit. Various types of instruction conversion modules can be implemented in software, hardware, firmware or a combination thereof. In some embodiments, the instruction conversion module can be located outside the processor, such as, for example, on a separate die and / or in a memory (e.g., static, dynamic or runtime simulation module). By way of example, the instruction conversion module can receive instructions that may belong to a first instruction set, and instructions can be simulated, converted, deformed, interpreted or otherwise converted to one or more corresponding intermediate instructions or control signals (which may belong to a second different instruction set). One or more intermediate instructions or control signals of the second instruction set can be provided to the decoding unit, and the decoding unit can decode them into one or more lower-level instructions or control signals that can be executed by the native hardware (e.g., execution unit) of the processor.

[0114] Figure 8 , Fig.10 and Fig.12 A register may represent an on-die storage location operable to store data. A register may represent an architecturally visible or architectural register visible to software and / or a programmer, and / or a register indicated by an instruction of an instruction set of a processor for identifying an operand. These architectural registers are contrasted with other non-architectural registers (e.g., temporary registers, reorder buffers, retirement registers, etc.) in a given microarchitecture. Registers may be implemented in different microarchitectures and are not limited to any particular type of design. Examples of suitable types of registers include, but are not limited to, dedicated physical registers, dynamically allocated physical registers using register renaming, and combinations thereof.

[0115] Figure 8 , Fig.10 and Fig.12 The execution unit may be coupled to the decoding unit to receive the one or more decoded or otherwise converted instructions or control signals representing and / or derived from the decoded instructions. The execution unit is operable to perform the described operations of the corresponding instructions in response to the instructions and / or as a result of the corresponding instructions (e.g., in response to one or more instructions or control signals decoded from the corresponding instructions). The execution unit and / or the processor may include specific or specific logic (e.g., transistors, integrated circuit systems, or other hardware that may be combined with firmware (e.g., instructions stored in non-volatile memory) and / or software) that is operable to execute the corresponding instructions.

[0116] To avoid obscuring the description, the Figure 8 , Fig.10 and Fig.12 However, the processor may optionally include other processor components. For example, various different embodiments may include the following: Fig.15 Various different combinations and configurations of components shown and described for any of the processors. All of the components of the processor may be coupled together to allow them to function as intended.

[0117] Exemplary Core Architectures, Processors, and Computer Architectures

[0118] Processor cores can be implemented in different ways, for different purposes and in different processors. For example, implementations of such cores may include: 1) a general-purpose in-order core intended for general-purpose computing; 2) a high-performance out-of-order core intended for general-purpose computing; 3) a dedicated core intended primarily for graphics and / or scientific (throughput) computing. Implementations of different processors may include: 1) a CPU including one or more general-purpose in-order cores intended for general-purpose computing and / or one or more general-purpose out-of-order cores intended for general-purpose computing; and 2) a coprocessor including one or more dedicated cores intended primarily for graphics and / or science (throughput). Such different processors lead to different computer system architectures, which may include: 1) a coprocessor on a separate chip from the CPU; 2) a coprocessor on a separate die in the same package as the CPU; 3) a coprocessor on the same die as the CPU (in this case, such a coprocessor is sometimes referred to as dedicated logic, such as integrated graphics and / or scientific (throughput) logic or dedicated cores); and 4) a system on a chip, which may include the described CPU (sometimes referred to as (multiple) application cores or (multiple) application processors), the above coprocessors, and additional functions on the same die. An exemplary core architecture is described next, followed by a description of exemplary processor and computer architectures.

[0119] Exemplary Core Architecture

[0120] In-order and out-of-order core block diagram

[0121] Fig.13A is a block diagram illustrating both an exemplary in-order pipeline and an exemplary register renaming out-of-order issue / execution pipeline according to embodiments of the present invention. Fig. 13B is a block diagram illustrating both an exemplary embodiment of an in-order architecture core and an exemplary register renaming out-of-order issue / execution architecture core to be included in a processor in accordance with embodiments of the present invention. Fig.13A and Fig. 13B The solid line boxes in show the in-order pipeline and in-order core, while the optional addition of dashed line boxes shows the register renaming out-of-order issue / execution pipeline and core. The out-of-order aspect will be described assuming that the in-order aspect is a subset of the out-of-order aspect.

[0122] exist Fig.13A , the processor pipeline 1300 includes an acquisition stage 1302, a length decoding stage 1304, a decoding stage 1306, an allocation stage 1308, a renaming stage 1310, a scheduling (also known as dispatch or issue) stage 1312, a register read / memory read stage 1314, an execution stage 1316, a write back / memory write stage 1318, an exception handling stage 1322, and a commit stage 1324.

[0123] Fig. 13B A processor core 1390 is shown, the processor core comprising a front end unit 1330 coupled to an execution engine unit 1350, and both the execution engine unit and the front end unit are coupled to a memory unit 1370. The core 1390 may be a reduced instruction set computing (RISC) core, a complex instruction set computing (CISC) core, a very long instruction word (VLIW) core, or a hybrid or alternative core type. As yet another option, the core 1390 may be a special purpose core, such as, for example, a network or communication core, a compression engine, a coprocessor core, a general purpose computing graphics processing unit (GPGPU) core, a graphics core, etc.

[0124] The front end unit 1330 includes a branch prediction unit 1332 coupled to an instruction cache unit 1334, the instruction cache unit is coupled to an instruction translation lookaside buffer (TLB) 1336, the instruction translation lookaside buffer is coupled to an instruction fetch unit 1338, and the instruction fetch unit is coupled to a decode unit 1340. The decode unit 1340 (or decoder) can decode the instruction and generate one or more micro-operations, microcode entry points, microinstructions, other instructions or other control signals decoded from the original instruction or otherwise reflecting the original instruction or derived from the original instruction as output. The decode unit 1340 can be implemented using a variety of different mechanisms. Examples of suitable mechanisms include, but are not limited to: a lookup table, a hardware implementation, a programmable logic array (PLA), a microcode read-only memory (ROM), etc. In one embodiment, the core 1390 includes a microcode ROM or other medium that stores microcode for certain macroinstructions (e.g., in the decode unit 1340 or within the front end unit 1330). Decode unit 1340 is coupled to rename / allocator unit 1352 in execution engine unit 1350 .

[0125] The execution engine unit 1350 includes a rename / allocator unit 1352 coupled to a retirement unit 1354 and a set of one or more scheduler units 1356. The scheduler unit(s) 1356 represent any number of different schedulers, including reservation stations, central instruction windows, etc. The scheduler unit(s) 1356 are coupled to the physical register file(s) unit(s) 1358. The physical register units 1358 each represent one or more physical register files, where different physical register files store one or more different data types, such as scalar integers, scalar floating points, packed integers, packed floating points, vector integers, vector floating points, status (e.g., an instruction pointer as the address of the next instruction to be executed), etc. In one embodiment, the physical register file(s) unit(s) 1358 include a vector register unit, a write mask register unit, and a scalar register unit. These register units may provide architectural vector registers, vector mask registers, and general purpose registers. The physical register file(s) unit(s) 1358 overlap with the retirement unit(s) 1354 to illustrate various ways in which register renaming and out-of-order execution may be implemented (e.g., using reorder buffer(s) and retirement register file(s); using future(s) stack(s), history buffer(s) and retirement register file(s); using register maps and register pools; etc.). The retirement unit(s) 1354 and the physical register file(s) unit(s) 1358 are coupled to execution cluster(s) 1360. The execution cluster(s) 1360 include a set of one or more execution units 1362 and a set of one or more memory access units 1364. The execution units 1362 may perform various operations (e.g., shifts, additions, subtractions, multiplications) and on various types of data (e.g., scalar floating point, packed integer, packed floating point, vector integer, vector floating point). While some embodiments may include multiple execution units dedicated to a particular function or set of functions, other embodiments may include only one execution unit or include multiple execution units that all perform all functions. Scheduler unit(s) 1356, physical register file(s) units 1358, and execution cluster(s) 1360 are shown as possibly plural because certain embodiments create separate pipelines for certain types of data / operations (e.g., scalar integer pipelines, scalar floating point / packed integer / packed floating point / vector integer / vector floating point pipelines, and / or memory access pipelines, each of which has its own scheduler unit, physical register file(s) units, and / or execution clusters, and in the case of separate memory access pipelines, certain embodiments are implemented in which only the execution cluster of that pipeline has memory access unit(s) 1364).It should also be understood that where separate pipelines are used, one or more of these pipelines may not be issue / execute pipelines, and the rest may be in-order pipelines.

[0126] The set of memory access units 1364 are coupled to a memory unit 1370, which includes a data TLB unit 1372 coupled to a data cache unit 1374, which is coupled to a level 2 (L2) cache unit 1376. In an exemplary embodiment, the memory access unit 1364 may include a load unit, a store address unit, and a store data unit, each coupled to the data TLB unit 1372 in the memory unit 1370. The instruction cache unit 1334 is further coupled to a level 2 (L2) cache unit 1376 in the memory unit 1370. The L2 cache unit 1376 is coupled to one or more other levels of cache and ultimately to the main memory.

[0127] By way of example, an exemplary register renaming out-of-order issue / execute core architecture may implement pipeline 1300 as follows: 1) instruction fetch 1338 performs fetch and length decode stages 1302 and 1304; 2) decode unit 1340 performs decode stage 1306; 3) rename / allocator unit 1352 performs allocate stage 1308 and rename stage 1310; 4) (multiple) scheduler units 1356 perform schedule stage 1312; 5) (multiple) physical register file units 1358 and memory units 1370 perform register read / memory read stage 1314; execution cluster 1360 performs execute stage 1316; 6) memory unit 1370 and (multiple) physical register file units 1358 perform write back / memory write stage 1318; 7) various units may be involved in exception handling stage 1322; and 8) retirement unit 1354 and (multiple) physical register file units 1358 perform commit stage 1324.

[0128] Core 1390 may support one or more instruction sets (e.g., the x86 instruction set (with some extensions that newer versions have added); the MIPS instruction set from MIPS Technologies, Inc. of Sunnyvale, California; the ARM instruction set from ARM Holdings, Inc. of Sunnyvale, California (with optional additional extensions, such as NEON)), including the instruction(s) described herein. In one embodiment, core 1390 includes logic to support packed data instruction set extensions (e.g., AVX1, AVX2), thereby allowing operations used by many multimedia applications to be performed using packed data.

[0129] It should be understood that a core may support multithreading (executing two or more operations or sets of threads in parallel), and may accomplish multithreading in a variety of ways, including time-division multithreading, simultaneous multithreading (where a single physical core provides a logical core for each of the threads that the physical core is simultaneously multithreading), or a combination thereof (e.g., time-division fetch and decode and subsequent processing such as Hyper-Threading (Simultaneous Multithreading).

[0130] Although register renaming is described in the context of out-of-order execution, it should be understood that register renaming can be used in an in-order architecture. Although the illustrated embodiment of the processor also includes separate instruction and data cache units 1334 / 1374 and a shared L2 cache unit 1376, alternative embodiments may have a single internal cache for both instructions and data, such as a level 1 (L1) internal cache, or multiple levels of internal caches. In some embodiments, the system may include a combination of internal caches and external caches external to the core and / or processor. Alternatively, all caches may be external to the core and / or processor.

[0131] Certain Exemplary In-Order Core Architectures

[0132] Fig.14A and Fig. 14B A block diagram of a more specific exemplary in-order core architecture is shown, where the core is one of multiple logic blocks in a chip (including other cores of the same type and / or different types). Depending on the application, the logic blocks communicate through a high-bandwidth interconnect network (e.g., a ring network) with some fixed-function logic, memory I / O interfaces, and other necessary I / O logic.

[0133] Fig.14A 1404, and a block diagram of a single processor core, together with its connection to an on-die interconnect network 1402, and together with its local subset of a level 2 (L2) cache 1404, according to an embodiment of the present invention. In one embodiment, the instruction decoder 1400 supports the x86 instruction set with a packed data instruction set extension. The L1 cache 1406 allows low latency access to cache memory in the scalar and vector units. Although in one embodiment (to simplify the design), the scalar unit 1408 and the vector unit 1410 use separate register sets (scalar registers 11412 and vector registers 1414, respectively), and data transferred between them is written to memory and then read back from the level 1 (L1) cache 1406, alternative embodiments of the present invention may use different approaches (e.g., using a single register set or including a communication path that allows data to be transferred between two register files without being written and read back).

[0134] The local subset of L2 cache 1404 is part of the global L2 cache, which is divided into multiple separate local subsets, one for each processor core. Each processor core has a direct access path to its own local subset of L2 cache 1404. The data read by the processor core is stored in its L2 cache subset 1404 and can be quickly accessed, accessing its local L2 cache subset in parallel with other processor cores. The data written by the processor core is stored in its own L2 cache subset 1404, and if necessary, it is crossed out from other subsets. The ring network ensures the coherence of shared data. The ring network is bidirectional, allowing media such as processor cores, L2 caches and other logic blocks to communicate with each other within the chip. Each ring data path is 1012 bits wide in each direction.

[0135] Fig. 14B According to an embodiment of the present invention Fig.14A An expanded view of a portion of a processor core in FIG. Fig. 14B The L1 data cache 1406A portion of the L1 cache 1404 is included, as well as more details about the vector unit 1410 and vector registers 1414. Specifically, the vector unit 1410 is a 16-bit wide vector processing unit (VPU) (see 16-bit wide ALU 1428) that executes one or more of integer, single precision floating point, and double precision floating point instructions. The VPU supports mixing of register inputs with a mixing unit 1420, digital conversion with conversion units 1422A to 1422B, and copying of memory inputs with a copy unit 1424. Write mask registers 1426 allow prediction of result vector writes.

[0136] Processor with integrated memory controller and graphics

[0137] Fig.15 is a block diagram of a processor 1500 that may have more than one core, may have an integrated memory controller, and may have integrated graphics in accordance with an embodiment of the present invention. Fig.15 The solid line box in the figure shows a processor 1500 having a single core 1502A, a system agent 1510, a set of one or more bus controller units 1516, while the optional addition of the dashed line box shows an alternative processor 1500 having multiple cores 1502A to 1502N, a set of one or more integrated memory controller units 1514 in the system agent unit 1510, and dedicated logic 1508.

[0138] Thus, different implementations of processor 1500 may include: 1) a CPU with dedicated logic 1508 as integrated graphics and / or scientific (throughput) logic (which may include one or more cores) and cores 1502A to 1502N as one or more general purpose cores (e.g., general purpose in-order cores, general purpose out-of-order cores, combinations of both); 2) a coprocessor, where cores 1502A to 1502N are a large number of dedicated cores intended primarily for graphics and / or scientific (throughput); and 3) a coprocessor, where cores 1502A to 1502N are a large number of general purpose in-order cores. Thus, processor 1500 may be a general purpose processor, a coprocessor, or a dedicated processor, such as a network or communication processor, a compression engine, a graphics processor, a GPGPU (general purpose graphics processing unit), a high throughput integrated many-core (MIC) coprocessor (including 30 or more cores), an embedded processor, etc. The processor may be implemented on one or more chips. Processor 1500 may be part of one or more substrates and / or may be implemented on one or more substrates using any of a variety of processing technologies such as, for example, BiCMOS, CMOS, or NMOS.

[0139] The memory hierarchy includes one or more levels of cache within the core, a set of one or more shared cache units 1506, and external memory (not shown) coupled to the set of integrated memory controller units 1514. The set of shared cache units 1506 may include one or more mid-level caches, such as level 2 (L2), level 3 (L3), level 4 (L4), or other levels of cache, a final cache (LLC), and / or combinations thereof. While in one embodiment, a ring-based interconnect unit 1512 interconnects the integrated graphics logic 1508, the set of shared cache units 1506, and the system agent unit 1510 / (multiple) integrated memory controller units 1514, alternative embodiments may use any number of known techniques for interconnecting such units. In one embodiment, coherency is maintained between the one or more cache units 1506 and the cores 1502A to 1502N.

[0140] In some embodiments, one or more of the cores 1502A to 1502N are capable of multithreading. System agent 1510 includes those components that coordinate and operate cores 1502A to 1502N. System agent unit 1510 may include, for example, a power control unit (PCU) and a display unit. The PCU may be or include logic and components required to regulate the power state of cores 1502A to 1502N and integrated graphics logic 1508. The display unit is used to drive one or more externally connected displays.

[0141] The cores 1502A-1502N may be homogeneous or heterogeneous with respect to the architectural instruction set; that is, two or more of the cores 1502A-1502N may be capable of executing the same instruction set, while other cores may be capable of executing only a subset of the instruction set or a different instruction set.

[0142] Exemplary Computer Architecture

[0143] Figures 16 to 20 is a block diagram of an exemplary computer architecture. Other system designs and configurations known in the art for laptop computers, desktop computers, handheld PCs, personal digital assistants, engineering workstations, servers, network devices, network hubs, switches, embedded processors, digital signal processors (DSPs), graphics devices, video game devices, set-top boxes, microcontrollers, cellular phones, portable media players, handheld devices, and various other electronic devices are also suitable. In general, a plurality of systems and electronic devices that can incorporate the processors and / or other execution logic disclosed herein are generally suitable.

[0144] Now refer to Fig.16 , a block diagram of a system 1600 according to one embodiment of the present invention is shown. The system 1600 may include one or more processors 1610, 1615 coupled to a controller hub 1620. In one embodiment, the controller hub 1620 includes a graphics memory controller hub (GMCH) 1690 and an input / output hub (IOH) 1650 (which may be on separate chips); the GMCH 1690 includes memory and a graphics controller, to which a memory 1640 and a coprocessor 1645 are coupled; and the IOH 1650 couples an input / output (I / O) device 1660 to the GMCH 1690. Alternatively, one or both of the memory and the graphics controller are integrated within a processor (as described herein), and the memory 1640 and the coprocessor 1645 are directly coupled to the processor 1610 and the controller hub 1620 in a single chip through the IOH 1650.

[0145] Fig.16 The optional nature of the additional processor 1615 is indicated by dashed lines in FIG. Each processor 1610 , 1615 may include one or more processing cores described herein and may be some version of processor 1500 .

[0146] The memory 1640 may be, for example, a dynamic random access memory (DRAM), a phase change memory (PCM), or a combination of both. For at least one embodiment, the controller hub 1620 communicates with the processor(s) 1610, 1615 via a multi-drop bus (e.g., a front side bus (FSB), a point-to-point interface such as a Quick Path Interconnect (QPI), or a similar connection 1695).

[0147] In one embodiment, coprocessor 1645 is a special purpose processor, such as a high throughput MIC processor, a network or communication processor, a compression engine, a graphics processor, a GPGPU, an embedded processor, etc. In one embodiment, controller hub 1620 may include an integrated graphics accelerator.

[0148] There may be various differences between the physical resources 1610 , 1615 in terms of a range of metrics including architectural, microarchitectural, thermal, power consumption characteristics, and the like.

[0149] In one embodiment, processor 1610 executes instructions that control general types of data processing operations. Coprocessor instructions may be embedded in the instructions. Processor 1610 identifies these coprocessor instructions as being of a type that should be executed by an attached coprocessor 1645. Accordingly, processor 1610 issues these coprocessor instructions (or control signals representing coprocessor instructions) on a coprocessor bus or other interconnect to coprocessor 1645. Coprocessor(s) 1645 accept and execute the received coprocessor instructions.

[0150] Now refer to Fig.17 , a block diagram of a first more specific exemplary system 1700 according to an embodiment of the present invention is shown. Fig.17 As shown, multiprocessor system 1700 is a point-to-point interconnect system and includes a first processor 1770 and a second processor 1780 coupled via a point-to-point interconnect 1750. Processors 1770 and 1780 may each be a version of processor 1500. In one embodiment of the present invention, processors 1770 and 1780 are processors 1610 and 1615, respectively, and coprocessor 1738 is coprocessor 1645. In another embodiment, processors 1770 and 1780 are processor 1610 and coprocessor 1645, respectively.

[0151] Processors 1770 and 1780 are shown as including integrated memory controller (IMC) units 1772 and 1782, respectively. Processor 1770 also includes point-to-point (PP) interfaces 1776 and 1778 as part of its bus controller unit; similarly, second processor 1780 includes PP interfaces 1786 and 1788. Processors 1770, 1780 can exchange information via point-to-point (PP) interface 1750 using PP interface circuits 1778, 1788. Fig.17 As shown, IMCs 1772 and 1782 couple the processors to corresponding memories (ie, memory 1732 and memory 1734), which may be portions of main memory locally attached to the corresponding processors.

[0152] Processors 1770, 1780 may each exchange information with chipset 1790 via separate PP interfaces 1752, 1754 using point-to-point interface circuits 1776, 1794, 1786, 1798. Alternatively, chipset 1790 may exchange information with coprocessor 1738 via high performance interface 1739. In one embodiment, coprocessor 1738 is a special purpose processor, such as a high throughput MIC processor, a network or communication processor, a compression engine, a graphics processor, a GPGPU, an embedded processor, etc.

[0153] A shared cache (not shown) may be included in either processor or external to both processors but connected to the processors via the PP interconnect so that if the processors are placed in a low power mode, local cache information of either or both processors may be stored in the shared cache.

[0154] Chipset 1790 may be coupled to first bus 1716 via interface 1796. In one embodiment, first bus 1716 may be a peripheral component interconnect (PCI) bus, or a bus such as a PCI Express bus or another third generation I / O interconnect bus, although the scope of the invention is not limited in this regard.

[0155] like Fig.17As shown, different I / O devices 1714 can be coupled to the first bus 1716 along with a bus bridge 1718, which can couple the first bus 1716 to a second bus 1720. In one embodiment, one or more additional processors 1715 (e.g., a coprocessor, a high throughput MIC processor, a GPGPU, an accelerator (e.g., a graphics accelerator or a digital signal processing (DSP) unit), a field programmable gate array, or any other processor) are coupled to the first bus 1716. In one embodiment, the second bus 1720 can be a low pin count (LPC) bus. In one embodiment, various devices can be coupled to the second bus 1720, including, for example, a keyboard and / or mouse 1722, communication devices 1727, and a storage unit 1728 (e.g., a disk drive or other mass storage device) which may include instructions / code and data 1730. Further, an audio I / O 1724 can be coupled to the second bus 1720. Note that other architectures are possible. For example, instead of Fig.17 Instead of a point-to-point architecture, the system may implement a multi-drop bus or other such architecture.

[0156] Now refer to Fig.18 , a block diagram of a second more specific exemplary system 1800 according to an embodiment of the present invention is shown. Fig.17 and Fig.18 The same elements in FIG. 18 have the same reference numerals and have been omitted from FIG. Fig.17 to avoid using Fig.18 Other aspects are vague.

[0157] Fig.18 It is shown that processors 1770, 1780 may include integrated memory and I / O control logic ("CL") 1772 and 1782, respectively. Thus, CL 1772, 1782 includes an integrated memory controller unit and includes I / O control logic. Fig.18 It is shown that not only the memories 1732, 1734 are coupled to the CL 1772, 1782, but also the I / O devices 1814 are coupled to the control logic 1772, 1782. Legacy I / O devices 1815 are coupled to the chipset 1790.

[0158] Now refer to Fig.19 , shows a block diagram of a SoC 1900 according to an embodiment of the present invention. Fig.15 Similar components in FIG. 1 have the same reference numbers. In addition, dashed boxes are optional features for more advanced SoCs. Fig.19, interconnect unit(s) 1902 are coupled to: application processor 1910, which includes a set of one or more cores 182A to 182N and shared cache unit(s) 1506; system agent unit 1510; bus controller unit(s) 1516; integrated memory controller unit(s) 1514; a set of one or more coprocessors 1920, which may include integrated graphics logic, image processor, audio processor, and video processor; static random access memory (SRAM) unit 1930; direct memory access (DMA) unit 1932; and display unit 1940, which is used to couple to one or more external displays. In one embodiment, coprocessor(s) 1920 are special purpose processors, such as, for example, network or communication processors, compression engines, GPGPUs, high throughput MIC processors, embedded processors, etc.

[0159] Embodiments of the mechanisms disclosed herein may be implemented in hardware, software, firmware, or a combination of such implementations. Embodiments of the present invention may be implemented as a computer program or program code executed on a programmable system comprising at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device.

[0160] like Fig.17 Program codes such as the code 1730 shown can be applied to input instructions to perform the functions described herein and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system with a processor, such as, for example: a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0161] The program code can be implemented in a high-level program or object-oriented programming language to communicate with the processing system. If desired, the program code can also be implemented in an assembly or machine language. In fact, the scope of the mechanism described herein is not limited to any specific programming language. In any case, the language can be a compiled or interpreted language.

[0162] One or more aspects of at least one embodiment may be implemented by representative instructions stored on a machine-readable medium, which represent various logic within a processor, and which, when read by a machine, causes the machine to fabricate logic for performing the techniques described herein. Such representations, known as "IP cores," may be stored on a tangible machine-readable medium and provided to various customers or manufacturing facilities to be loaded into a fabrication machine that actually fabricates the logic or processor.

[0163] Such machine-readable storage media may include, but are not limited to: a non-transitory tangible arrangement of an article manufactured or formed by a machine or device, including storage media such as a hard disk; any other type of disk, including floppy disks, optical disks, compact disk-read only memory (CD-ROM), compact disk-rewritable (CD-RW), and magneto-optical disks; semiconductor devices, such as read-only memory (ROM); random access memory (RAM), such as dynamic random access memory (DRAM), static random access memory (SRAM); erasable programmable read-only memory (EPROM); flash memory; electrically erasable programmable read-only memory (EEPROM); phase change memory (PCM); magnetic card or optical card; or any other type of medium suitable for storing electronic instructions.

[0164] Therefore, embodiments of the present invention also include non-transitory tangible machine-readable media containing instructions or containing design data (e.g., hardware description language (HDL)), which define the structures, circuits, devices, processors and / or system features described herein. Such embodiments may also be referred to as program products.

[0165] Emulation (including binary conversion, code deformation, etc.)

[0166] In some cases, an instruction converter may be used to convert instructions from a source instruction set to a target instruction set. For example, the instruction converter may convert (e.g., using static binary translation, dynamic binary translation including dynamic compilation), deform, simulate, or otherwise convert instructions to one or more other instructions to be processed by the core. The instruction converter may be implemented in software, hardware, firmware, or a combination thereof. The instruction converter may be on the processor, off the processor, or partially on the processor and partially off the processor.

[0167] Fig. 20 1 is a block diagram comparing the use of a software instruction converter for converting binary instructions in a source instruction set into binary instructions in a target instruction set according to an embodiment of the present invention. In the illustrated embodiment, the instruction converter is a software instruction converter, however, alternatively, the instruction converter may be implemented in software, firmware, hardware, or various combinations thereof. Fig. 20It is shown that an x86 compiler 2004 can be used to compile a program in a high-level language 2002 to generate an x86 binary code 2006 that can be natively executed by a processor 2016 having at least one x86 instruction set core. A processor 2016 having at least one x86 instruction set core represents any processor that can perform substantially the same functions as an Intel processor having at least one x86 instruction set core by compatibly executing or otherwise processing: (1) a substantial portion of the instruction set of an Intel x86 instruction set core, or (2) an object code version of an application or other software that is targeted to run on an Intel processor having at least one x86 instruction set core in order to achieve substantially the same results as an Intel processor having at least one x86 instruction set core. The x86 compiler 2004 represents a compiler that can be operated to generate x86 binary code 2006 (e.g., object code) that can be executed on a processor having at least one x86 instruction set core 2016 with or without additional link processing. Similarly, Fig. 20 A program in a high-level language 2002 is shown that can be compiled using an alternative instruction set compiler 2008 to generate an alternative instruction set binary code 210 that can be natively executed by a processor that does not have at least one x86 instruction set core 214 (e.g., a processor that has multiple cores that execute the MIPS instruction set of MIPS Technologies, Inc. of Sunnyvale, California and / or execute the ARM instruction set of ARM Holdings, Inc. of Sunnyvale, California). The instruction converter 2012 is used to convert the x86 binary code 2006 into code that can be natively executed by a processor that does not have an x86 instruction set core 2014. This converted code is unlikely to be the same as the alternative instruction set binary code 2010 because it is difficult to make an instruction converter that can achieve this; however, the converted code will complete the general operation and be composed of instructions from the alternative instruction set. Therefore, the instruction converter 2012 represents software, firmware, hardware, or a combination thereof that allows a processor or other electronic device that does not have an x86 instruction set processor or core to execute the x86 binary code 2006 through simulation, emulation, or any other process.

[0168] Optionally, for Figures 1 to 7 The components, features and details described in any one of the above may also be applicable to Figures 8 to 12 In addition, optionally, the components, features, and details described for any of the devices may also apply to any method that may be performed by and / or with such a device in an embodiment. Any of the processors described herein may include any of the processors described herein (e.g., FIG. 13 to FIG. 14 ). Fig.15) disclosed in any of the computer systems described herein. In some embodiments, the computer system may include dynamic random access memory (DRAM). Alternatively, the computer system may include some type of volatile memory or flash memory that does not require refreshing. The instructions disclosed herein may be executed using any processor shown herein on any of the systems shown herein having any of the microarchitectures shown herein.

[0169] In the specification and claims, the terms "coupled" and "connected" and their derivatives may be used. These terms are not intended to be synonymous with each other. Rather, in an embodiment, "connected" may be used to indicate that two or more elements are in direct physical and / or electrical contact. "Coupled" may mean that two or more elements are in direct physical and / or electrical contact with each other. However, "coupled" may also mean that two or more elements are not in direct contact with each other, but still cooperate or interact with each other. For example, an execution unit may be coupled to a register and / or a decoding unit through one or more intermediate components. In the accompanying drawings, arrows are used to illustrate connections and couplings.

[0170] The term "and / or" may have been used. As used herein, the term "and / or" means one or the other or both (eg, A and / or B means A or B or both A and B).

[0171] In the above description, many specific details have been set forth in order to provide a thorough understanding of the embodiments. However, other embodiments may be practiced without some of these specific details. The scope of the present invention is not determined by the specific embodiments provided above, but by the claims below. In other cases, known circuits, structures, devices, and operations have been shown in block diagram form and / or not in detail to avoid blurring the understanding of the specification. Where deemed appropriate, reference numbers or endpoint portions of reference numbers have been repeated in the accompanying drawings to indicate corresponding or similar elements, which may optionally have similar or identical characteristics, unless otherwise noted or clearly apparent.

[0172] Certain operations may be performed by hardware components or may be embodied in machine-executable or circuit-executable instructions, which may be used to cause and / or result in a machine, circuit, or hardware component (e.g., a processor, a portion of a processor, a circuit, etc.) being programmed with instructions to perform these operations. Alternatively, operations may also be performed by a combination of hardware and software. A processor, machine, circuit, or hardware, which may include specific or concrete circuitry or other logic (e.g., hardware that may be combined with firmware and / or software), may be operable to execute and / or process instructions and store results in response to the instructions.

[0173] Some embodiments include articles (e.g., computer program products) that include machine-readable media. The medium may include a mechanism for providing (e.g., storing) information in a machine-readable form. The machine-readable medium may provide or have stored thereon instructions or sequences of instructions that, if and / or when executed by a machine, are operable to cause the machine to perform and / or cause the machine to perform one or more operations, methods, or techniques disclosed herein.

[0174] In some embodiments, the machine-readable medium may include a non-transient machine-readable storage medium. For example, a non-transient machine-readable storage medium may include a floppy disk, an optical storage medium, an optical disc, an optical data storage device, a CD-ROM, a magnetic disk, a magneto-optical disk, a read-only memory (ROM), a programmable ROM (PROM), an erasable programmable ROM (EPROM), an electrically erasable programmable ROM (EEPROM), a random access memory (RAM), a static RAM (SRAM), a dynamic RAM (DRAM), a flash memory, a phase change memory, a phase change data storage material, a non-volatile memory, a non-volatile data storage device, a non-transient memory, a non-transient data storage device, etc. The non-transient machine-readable storage medium does not consist of a transient propagation signal. In some embodiments, the storage medium may include a tangible medium, and the tangible medium includes a solid substance.

[0175] Examples of suitable machines include, but are not limited to, general purpose processors, special purpose processors, digital logic circuits, integrated circuits, etc. Other examples of suitable machines include computer systems or other electronic devices including processors, digital logic circuits, or integrated circuits. Examples of such computing systems or electronic devices include, but are not limited to, desktop computers, laptop computers, notebook computers, tablet computers, netbooks, smart phones, cellular phones, servers, network devices (e.g., routers and switches), mobile Internet devices (MIDs), media players, smart televisions, nettops, set-top boxes, and video game controllers.

[0176] Throughout the specification, references to "one embodiment," "an embodiment," "one or more embodiments," "some embodiments," for example, indicate that a particular feature may be included but is not necessarily required in the practice of the invention. Similarly, in the specification, various features are sometimes grouped together in a single embodiment, figure, or description thereof to simplify the disclosure and aid in understanding the various inventive aspects. However, this method of disclosure is not to be interpreted as reflecting an intention that the invention requires more features than are expressly stated in each claim. On the contrary, as reflected in the claims below, inventive aspects lie in less than all of the features of a single disclosed embodiment. Accordingly, the claims following the detailed description are hereby expressly incorporated into the detailed description, with each claim independently representing a separate embodiment of the invention.

[0177] Example Embodiments

[0178] The following examples relate to further embodiments. The details in the examples may be used anywhere in one or more embodiments.

[0179] Example 1 is a processor, the processor comprising: a decoding unit, the decoding unit is used to decode an instruction; and an execution unit, the execution unit is coupled to the decoding unit. The execution unit is responsive to the instruction to: determine that an attempted change to a shadow stack pointer (SSP) of a shadow stack caused by the instruction will cause the SSP to exceed an allowed range; and in response to determining that the attempted change to the SSP will cause the SSP to exceed the allowed range, raise an exception.

[0180] Example 2 includes the processor of claim 1, wherein the execution unit is responsive to the instruction to compare the attempted change to the SSP to an SSP base address and an SSP limit specifying the allowed range.

[0181] Example 3 includes the processor of claim 2, wherein the SSP base address is used to represent a lowest allowed logical address of the shadow stack, and the SSP limit is used to represent a highest allowed logical address of the shadow stack.

[0182] Example 4 includes the processor of claim 2, wherein the SSP base address and the SSP limit are to be specified by privileged system software.

[0183] Example 5 includes the processor of claim 2, wherein the SSP base address and the SSP limit are to be stored in a control register of the processor.

[0184] Example 6 includes the processor of claim 1, wherein the execution unit is responsive to the instruction to determine that an attempt to push data into the shadow stack due to the instruction will cause the SSP to exceed the allowed range and will cause data to be stored outside the allowed range.

[0185] Example 7 includes the processor of claim 1, wherein the execution unit is responsive to the instruction to determine that an attempt to pop data from the shadow stack due to the instruction will cause a value to be read outside of the allowed range.

[0186] Example 8 includes the processor of claim 1, wherein the decode unit is to decode the instruction to indicate a shadow stack selector, and wherein the execution unit is to select the shadow stack using the shadow stack selector in response to the instruction.

[0187] Example 9 includes a processor as described in claim 8, wherein the decoding unit is used to decode the instruction used to indicate a shadow stack descriptor table (SSDT) ​​selector as the shadow stack selector, wherein the SSDT selector is used to select an entry in a shadow stack descriptor table (SSDT) ​​that corresponds to the shadow stack.

[0188] Example 10 includes the processor of claim 9, wherein the entry in the SSDT is to store an SSP base address and an SSP limit for specifying the allowed range.

[0189] Example 11 includes the processor of claim 8, wherein the execution unit is responsive to the instruction to determine whether the shadow stack to be selected by the shadow stack selector is valid.

[0190] Example 12 includes the processor of claim 11, wherein the decode unit is to decode the instruction indicating a shadow stack descriptor table (SSDT) ​​selector as the shadow stack selector. Also, optionally, wherein the SSDT selector is used to select an entry in a shadow stack descriptor table (SSDT) ​​to correspond to the shadow stack. Also, optionally, wherein the execution unit is responsive to the instruction to determine whether the shadow stack is valid based at least in part on a validity indicator of the entry.

[0191] Example 13 includes a processor as described in any one of claims 1 to 12, wherein the processor is used in conjunction with raising the exception to: obtain a shadow stack descriptor table (SSDT) ​​selector from a task state fragment structure; and use the shadow stack descriptor table (SSDT) ​​selector to determine an allowed range of a second SSP of a second shadow stack to be used by a handler for handling the exception.

[0192] Example 14 includes the processor of any one of claims 1 to 12, wherein the allowed range is an allowed linear address range.

[0193] Example 15 includes the processor of any one of claims 1 to 12, wherein the allowed range is to be specified by privileged system software.

[0194] Example 16 includes the processor of any one of claims 1 to 12, wherein the shadow stack is used to store a copy of the return address stored on the call stack and is not used to store user-level data passed as a parameter to the called program.

[0195] Example 17 is a processor comprising: a decoding unit for decoding a save shadow stack pointer instruction; and an execution unit coupled to the decoding unit. The execution unit is responsive to the shadow stack pointer instruction to: determine that pushing a shadow stack pointer (SSP) value into a shadow stack will not cause the SSP to exceed an allowed range; and after determining that pushing the SSP value into the shadow stack will not cause the SSP to exceed the allowed range, push the SSP value into the shadow stack.

[0196] Example 18 includes the processor of claim 17, wherein the decode unit is to decode the save shadow stack pointer instruction to indicate a destination storage location, and wherein the execution unit is to store a current SSP in the destination storage location after pushing the SSP value into the shadow stack in response to the save shadow stack pointer instruction.

[0197] Example 19 includes the processor of any one of claims 17 to 18, wherein the decode unit is to decode the save shadow stack pointer instruction that would be a user-level instruction.

[0198] Example 20 is a processor, the processor comprising: a decoding unit, the decoding unit is used to decode a restore shadow stack pointer instruction. The restore shadow stack pointer instruction is used to indicate a given shadow stack pointer (SSP) value. An execution unit is coupled to the decoding unit. The execution unit is responsive to the restore shadow stack pointer instruction to determine that the given SSP value does not exceed an allowed range of a corresponding shadow stack. The execution unit is also used to determine that the given SSP value indicated by the instruction is consistent with the SSP value received from the corresponding shadow stack. The execution unit is also used to change the SSP of the corresponding shadow stack to the given SSP value.

[0199] Example 21 includes the processor of claim 20, wherein the execution unit is responsive to the instruction to determine that the given SSP value is within an SSP base address and an SSP limit specifying the allowed range.

[0200] Example 22 includes the processor of claim 21, wherein the SSP base address is used to represent a lowest allowed logical address of the shadow stack, and the SSP limit is used to represent a highest allowed logical address of the shadow stack.

[0201] Example 23 includes the processor of claim 20, wherein the decode unit is to decode the restore shadow stack pointer instruction to indicate a shadow stack selector for selecting the corresponding shadow stack.

[0202] Example 24 includes the processor of claim 23, wherein the decoding unit is to decode the instruction indicating a shadow stack descriptor table (SSDT) ​​selector as the shadow stack selector. Also, optionally, wherein the execution unit is responsive to the instruction to use the SSDT selector to select an entry in a shadow stack descriptor table (SSDT), and wherein the entry is used to specify the allowed range of the shadow stack.

[0203] Example 25 includes the processor of any one of claims 20 to 24, wherein the execution unit, in response to the instruction, is further operable to corrupt the SSP value that has been saved on the corresponding shadow stack prior to making the change to the given SSP value.

[0204] Example 26 includes the processor of any one of claims 20 to 24, wherein the decode unit is to decode the save shadow stack pointer instruction that would be a user-level instruction.

[0205] Example 27 is a processor comprising: a decoding unit for decoding a return instruction; and an execution unit coupled to the decoding unit. The execution unit is responsive to the return instruction to: receive a return address from a stack; and determine that popping a return address from a shadow stack does not cause a value to be read outside an allowed range of the shadow stack. The execution unit is also used to: receive the return address from the shadow stack; and determine that the return address from the stack is consistent with the return address from the shadow stack. The execution unit is also used to store one of the return address from the stack and the return address from the shadow stack in an instruction pointer register.

[0206] Example 28 includes the processor of claim 27, wherein the allowed range is an allowed linear address range specified by privileged system software.

[0207] Example 29 is a system for processing instructions, the system comprising an interconnect and a processor coupled to the interconnect. The processor is configured to receive instructions. The processor is configured in response to the instructions to: determine that an attempted change to a shadow stack pointer (SSP) of a shadow stack due to the instruction will cause the SSP to exceed an allowed range; and raise an exception in response to determining that the attempted change to the SSP will cause the SSP to exceed the allowed range. The system also includes a dynamic random access memory (DRAM) coupled to the interconnect. The DRAM stores an instruction set of privileged system software, the instruction set being configured to cause the processor to perform operations including the following when executed by the processor: determining the allowed range of the SSP; and storing the allowed range of the SSP in an access-protected portion of the DRAM.

[0208] Example 30 includes the system of claim 29, wherein the allowed range comprises a linear address range, and wherein the instruction is a user-level instruction.

[0209] Example 31 includes a processor as described in any of Examples 1 to 16, the processor further comprising: an optional branch prediction unit for predicting branches; and an optional instruction prefetch unit coupled to the branch prediction unit, the instruction prefetch unit for prefetching instructions including the instruction. Optionally, the processor may also include an optional level 1 (L1) instruction cache coupled to the instruction prefetch unit, the L1 instruction cache for storing instructions; an optional L1 data cache for storing data; and an optional level 2 (L2) cache for storing data and instructions. Optionally, the processor may also include an instruction fetch unit, the instruction fetch unit coupled to the decode unit, the L1 instruction cache, and the L2 cache to fetch the instruction from one of the L1 instruction cache and the L2 cache in some cases and to provide the instruction to the decode unit. Optionally, the processor may further include a register renaming unit for renaming registers; an optional scheduler for scheduling one or more operations that have been decoded from the instruction for execution; and an optional commit unit for committing the execution result of the instruction.

[0210] Example 32 includes a processor or other apparatus as described in any of Examples 1 to 16 and optionally includes any combination of optional dynamic random access memory (DRAM), optional graphics device, and optional wireless transceiver.

[0211] Example 33 is a processor or other apparatus substantially as described herein.

[0212] Example 34 is a processor or other apparatus for executing (eg, having components for executing or being operable to execute) any instructions substantially as described herein.

[0213] Example 35 is a computer system or other electronic device, comprising a processor having a decoding unit, the decoding unit being used to decode instructions of a first instruction set. The processor also has one or more execution units. The electronic device also includes a storage device coupled to the processor. The storage device is used to store a first instruction, which may be any instruction in the instructions substantially as disclosed herein, and the first instruction will belong to a second instruction set. The storage device is also used to store instructions for converting the first instruction into one or more instructions of the first instruction set. The one or more instructions of the first instruction set, when executed by the processor, will cause the processor to emulate the first instruction.

Claims

1. A processor, comprising: A shadow stack pointer SSP register, used to store SSP, including a first SSP for identifying the top of a first shadow stack, the SSP register being used to indicate a current SSP of a current shadow stack; A decoding unit, used for decoding a shadow stack protection instruction, wherein the shadow stack protection instruction is used for indicating a second SSP, and the second SSP is used for identifying the top of the second shadow stack; as well as an execution unit, coupled to the decoding unit, and configured to perform the following operations in response to the shadow stack protection instruction: performing a plurality of security checks, including determining whether the second SSP is consistent with a value stored on the second shadow stack; Wherein, if at least one of the security checks fails, the execution unit is further configured to: not making the second SSP the current SSP; and Causes an exception; and in, If all the security checks are successful, the execution unit is further configured to: changing the value stored on the second shadow stack; and The SSP register is updated to the second SSP to make the second SSP the current SSP.

2. The processor of claim 1, wherein: The shadow stack protection instruction is an instruction to restore the shadow stack pointer.

3. The processor of claim 1, wherein: The second SSP is a linear address.

4. The processor of claim 1, wherein: The decoding unit is used to decode the call instruction, and the processor further includes an execution unit for executing the call instruction, including: Store the return address on the current stack; and The return address is stored on the current shadow stack.

5. The processor of claim 1, wherein: The decoding unit is used to decode a save shadow stack pointer instruction, and the processor is further used to execute the save shadow stack pointer instruction to store the first SSP to the first shadow stack.

6. The processor of claim 1, wherein: The processor is configured to save the current SSP to a field of a task state segment TSS structure in a memory in response to a task switch.

7. The processor of claim 1, wherein: The first and second shadow stacks each correspond to one privilege level among a plurality of different privilege levels.

8. A method comprising: Storing a first shadow stack pointer SSP in an SSP register to identify a top of the first shadow stack, wherein the SSP register is used to indicate a current SSP of the current shadow stack; Decoding a shadow stack protection instruction, wherein the shadow stack protection instruction indicates a second SSP, and the second SSP identifies a top of a second shadow stack; performing a plurality of security checks in response to the shadow stack protection instruction, including determining whether the second SSP is consistent with a value stored on the second shadow stack; Determining that the security checks are all successful; and In response to determining that the security checks are all successful: changing the value stored on the second shadow stack; and The SSP register is updated to the second SSP to make the second SSP the current SSP.

9. The method of claim 8, wherein: Decoding the shadow stack protection instruction includes decoding a restore shadow stack pointer instruction.

10. The method of claim 8, wherein: The second SSP is a linear address.

11. The method of claim 8, further comprising: Decode the call instruction; as well as Executing the calling instruction includes: Store the return address on the current stack; as well as The return address is stored on the current shadow stack.

12. The method of claim 8, further comprising: Decode and save shadow stack pointer instructions; as well as The save shadow stack pointer instruction is executed, wherein executing the save shadow stack pointer instruction includes storing the first SSP to the first shadow stack.

13. The method of claim 8, further comprising, in response to a task switch, saving the current SSP to a field of a task state segment (TSS) structure in memory.

14. The method of claim 8, wherein: The first and second shadow stacks each correspond to one privilege level among a plurality of different privilege levels.

15. A processor, comprising: A shadow stack pointer SSP register, used to store an SSP, including a first SSP for pointing to a first shadow stack, wherein the SSP register is used to indicate a current SSP of a current shadow stack; A first circuit is configured to decode an instruction, wherein the instruction is configured to indicate a second SSP, wherein the second SSP is configured to point to a second shadow stack; and A second circuit is coupled to the first circuit, and the second circuit is used to execute the instruction to perform the following operations: performing a plurality of security checks, including determining whether the second SSP is consistent with a value stored on the second shadow stack; Wherein, if at least one of the plurality of security checks fails, the second circuit is further configured to: not making the second SSP the current SSP; and Causes an exception; and Wherein, if the multiple security checks are successful, the second circuit is further configured to: changing the value stored on the second shadow stack; and The SSP register is updated to the second SSP to make the second SSP the current SSP.

16. The processor of claim 15, wherein: The first and second shadow stacks each correspond to one of a plurality of different privilege levels, and wherein the processor is configured to save the current SSP to a field of a task state segment (TSS) structure in memory in response to a task switch.

17. A computer system comprising: Dynamic random access memory DRAM; as well as A processor coupled to the DRAM, the processor comprising: A shadow stack pointer SSP register, used to store an SSP, including a first SSP for pointing to a first shadow stack, wherein the SSP register is used to indicate a current SSP of a current shadow stack; a decoding unit, configured to decode an instruction, wherein the instruction is configured to indicate a second SSP, wherein the second SSP is configured to point to a second shadow stack; and An execution unit, coupled to the decoding unit, configured to perform the following operations in response to the instruction: performing a plurality of security checks, including determining whether the second SSP is consistent with a value stored on the second shadow stack; Wherein, if at least one of the security checks fails, the execution unit is further configured to: not making the second SSP the current SSP; and Causes an exception; and If all the security checks are successful, the execution unit is further configured to: changing the value stored on the second shadow stack; and The SSP register is updated to the second SSP to make the second SSP the current SSP.

18. The computer system of claim 17, wherein: The computer system further includes a mass storage device coupled to the processor, wherein the first and second shadow stacks each correspond to one of a plurality of different privilege levels.

19. The computer system of claim 17, wherein: The computer system further includes a communication device coupled to the processor, and wherein the decoding unit is configured to decode a second instruction, and the processor is further configured to execute the second instruction to store the first SSP to the first shadow stack.

20. The computer system of claim 19, wherein: The computer system further comprises a coprocessor coupled to the processor, and wherein the decoding unit is used to decode a call instruction, the processor further comprises an execution unit for executing the call instruction, including: Store the return address on the current stack; and The return address is stored on the current shadow stack.

21. The computer system of claim 20, wherein: The coprocessor comprises a network processor, and wherein the processor is operable to save the current SSP to a field of a task state segment (TSS) structure in memory in response to a task switch.

22. A machine-readable medium having program code stored thereon, the program code, when executed by a machine, causing the machine to perform the operations of any one of the methods of claims 8-14.

23. A computer program product comprising a computer program which, when executed by a processor, causes the processor to perform the operations of the method of any one of claims 8 to 14.

Citation Information

Patent Citations

  • Apparatus, system and method for protecting function return address

    US20040168078A1

  • Method for saving and restoring the state of a CPU executing code in protected mode

    US5497494A

  • Virtual shadow registers and virtual register windows

    US6128728A

  • Processor, processing device, and method for creating program

    WO2015044993A1