Processor extensions to protect stacks during ring transitions

A processor implementing techniques for processor extensions to protect stacks during ring transitions is provided. In one embodiment, the processor includes a plurality of registers and a processor core, operatively coupled to the plurality of registers. The plurality of registers is used to store data used in privilege level transitions. Each register of the plurality of registers is associated with a privilege level. An indicator to change a first privilege level of a currently active application to a second privilege level is received. In view of the second privilege level, a shadow stack pointer (SSP) stored in a register of the plurality of registers is selected. The register is associated with the second privilege level. By using the SSP, a shadow stack for use by the processor at the second privilege level is identified.

TECHNICAL FIELD

Embodiments of the disclosure relate generally to microprocessors and more specifically, but without limitation, for processor extensions to protect stacks during ring transitions.

BACKGROUND

Return-oriented programming (ROP) is a computer security exploit technique in which an attacker uses software controls to execute an attacker-chosen sequence of instructions. In an ROP attack, the attacker may chain together sequences of what are known as “gadgets.” Each gadget may represent a set of one or a few instructions followed by a return from procedure instruction. The attacker may analyze code such as applications, system-level code, drivers, libraries, and the like, to locate or identify desired gadgets. In some cases, the attacker may be able to identify enough gadgets to be able to string together and perform a variety of different malicious actions.

DETAILED DESCRIPTION

Techniques for processor extensions to protect stacks during ring transitions are disclosed herein. In many situations, an instruction set architecture (ISA), such as an x86 architecture, provides at least four distinct privilege levels at a hardware platform level. The privilege levels are used to improve the reliability of an operating system (e.g., kernel) associated with the hardware platform by protecting resources from direct access by less trusted entities. In some embodiments, these privilege levels range from Ring0, the most trusted privilege level (e.g., a supervisor mode), to Ring3, or an unprivileged level (e.g., application or user mode). Each of the privilege levels requires some resources that are pre-allocated and stored away for subsequent use upon a ring transition from one privilege level to another privilege level.

In many situations, a computer system processor often has a current privilege level that controls an application instruction execution in the computer system. The processor may change its current privilege level to control accessibility of the application to system resources, such as system registers, system instructions, system memory and etc. In executing the application, the processor utilizes a data stack associated with the processor. The data stack stores both data (e.g., parameters and other data passed to subroutines, etc.) and control information for directing a control flow of the executed instruction. Typically, the control information may include one or more return addresses for one or more previously performed procedure calls. These return addresses are where a called procedure is to return the control flow when the called procedure finishes and returns.

In an ROP attack, attackers often seek to gain control of the data stack in order to hijack program control flow. For example, an attacker may perform unauthorized stack modifications of a procedure's return address stored in the data stack. The unauthorized stack modifications are used to divert the control flow of a current process to an arbitrary memory location to achieve the attacker's intent. One factor that may tend to make the data stack more vulnerable to ROP and other types of control flow subversion attacks is that the stack generally stores both the data and the control information (e.g., data and return addresses are commonly mixed together on the same stack) and thus the data stack needs to be writeable by software. Other factors that may tend to make the data stack more vulnerable to such attacks is that switching of the data stack is generally performed as an unprivileged operation or the current process may consume information like the location of the data stack from a location that may be tampered with without detection. For example, the processor in response to some events (e.g., interrupts/exceptions) may transfer control for a sequence of instructions executed at an unprivileged user level to a supervisor privilege level in order to access resources that are needed to handle that event. These factors as discussed above may tend to increase system exposure to control flow subversion attacks due to exploited bugs that allow the stack pointer and/or control flow information (e.g., return addresses) to be modified (e.g., to point to malware/attacker controlled memory).

Embodiments of the present disclosure provide techniques to protect stacks on privilege transfers from certain type of control flow subversion attacks. In some embodiments, a number of shadow stacks are provided to help protect the control information on the data stack from tampering attempts as well as to help to increase computer security. A shadow stack is a second stack separate from the data stack and is employed to store and protect information from the data stack that is used in control transfer operations. For example, the shadow stack may be used to store control information, but not the data (e.g., not parameters and other data of the type stored on the stack that user-level application programs would need to be able to write and modify).

In some embodiments, the shadow stack is writeable only by certain instructions, such as “CALL” (which is an example of a procedure calling mechanisms using a data stack) and “FAR CALL” (which is an example of a branch instruction that implements both micro branch and macro branch jump instructions) that perform control transfer operations and flows (e.g., interrupt/exception delivery). In such situations, the shadow stack may not be writeable by other software initiated stores through other instructions, such as “MOV” that transfers a plurality of bytes in a single operation and “XSAVE” that are used to store a context state to memory and restore the context state from a memory to a processor's registers. This write protection is achieve by marking the memory used for shadow stacks in the page tables as being shadow stack memory such that stores initiated by software using instructions like “MOV”, “XSAVE”, etc. do not complete and fault. Likewise, the instructions such as “CALL”, when they generate store instructions that are intended for the shadow stack memory, use specific store operations such that they complete only if the memory to which the store is performed is marked in the page tables as shadow stack memory. Otherwise, a fault occurs.

In some embodiments, the shadow stacks may optionally be configured for operation individually in an unprivileged user-level mode (e.g., a ring3privilege level) or in a privileged or supervisor privilege level mode (a ring0, ring1, or ring2privilege level). To support switching shadow stacks on privilege switches from a source privilege level to a new privilege level, the techniques described herein provide registers where each register is associated with a certain privilege level. In some embodiments, system software (e.g. system kernel or operating system) loads a shadow stack pointer (SSP) into each register. Then, the processor can access the SSP via a register associated with a particular new privilege level to identify a shadow stack to be used at that level. In operation, once the processor selects a SSP for the new privilege level, the processor does a check to verify that the SSP programmed into the register is valid for use by the processor at the new level. If the checks are successful, the processor set the shadow stack at the new privilege level as busy and pushes return address information for the source privilege level onto the shadow stack. Thereafter, embodiments of the present discloser ensure that any transition of the processor back to the source privilege level is then verified before the shadow stack is marked as not busy. This verification includes ensuring that the return address of the source privilege level pushed onto the shadow stack matches a current address associated with the data stack. In order to perform this verification, the processor uses specific load operations (e.g., “shadowStackPop” or loads with shadow stack semantics) such that if the load operation is not to memory marked as shadow stack memory in the page tables then this load does not complete but faults. Thus any attempt to point the shadow stack pointer to non-shadow stack memory is detected and prevented.

In other embodiments, the techniques described herein may be used, for example, to protect shadow stack switching as part of an interrupt/exception delivery or as part of task switching from a current task at the source privilege level to a new task at a new privilege level, to perform fast system calls (e.g., a user mode privilege transition to a mode with full control of the hardware authority) with shadow stacks, to protect shadow stacks from cross thread attacks, such as an attack from a less privileged process to a more privileged process, as well as to protect the shadow stacks during ring transitions from other types of unauthorized stack modifications employed by attackers.

FIG. 1illustrates a block diagram of a processing device to support processor extensions to protect stacks during ring transitions according to one embodiment. The processing device100may be generally referred to as “processor” or “CPU”. “Processor” or “CPU” herein shall refer to a device capable of executing instructions encoding arithmetic, logical, or I/O operations. In one illustrative example, a processor may include an arithmetic logic unit (ALU), a control unit, and a plurality of registers. In a further aspect, a processor may include one or more processing cores, and hence may be a single core processor which is typically capable of processing a single instruction pipeline, or a multi-core processor which may simultaneously process multiple instruction pipelines. In another aspect, a processor may be implemented as a single integrated circuit, two or more integrated circuits, or may be a component of a multi-chip module (e.g., in which individual microprocessor dies are included in a single integrated circuit package and hence share a single socket).

As shown inFIG. 1, processing device100may include various components. In one embodiment, processing device100may include one or more processors cores110and a memory controller unit120, among other components, coupled to each other as shown. The processing device100may also include a communication component (not shown) that may be used for point-to-point communication between various components of the processing device100. The processing device100may be used in a computing system (not shown) that includes, but is not limited to, a desktop computer, a tablet computer, a laptop computer, a netbook, a notebook computer, a personal digital assistant (PDA), a server, a workstation, a cellular telephone, a mobile computing device, a smart phone, an Internet appliance or any other type of computing device. In another embodiment, the processing device100may be used in a system on a chip (SoC) system. In one embodiment, the SoC may comprise processing device100and a memory. The memory for one such system is a DRAM memory. The DRAM memory can be located on the same chip as the processor and other system components. Additionally, other logic blocks such as a memory controller or graphics controller can also be located on the chip.

The processor core(s)110may execute instructions for the processing device100. The instructions may include, but are not limited to, pre-fetch logic to fetch instructions, decode logic to decode the instructions, execution logic to execute instructions and the like. The computing system may be representative of processing systems based on the Pentium® family of processors and/or microprocessors available from Intel® Corporation of Santa Clara, Calif., although other systems (including computing devices having other microprocessors, engineering workstations, set-top boxes and the like) may also be used. In one embodiment, a sample computing system may execute a version of an operating system, embedded software, and/or graphical user interfaces. Thus, embodiments of the disclosure are not limited to any specific combination of hardware circuitry and software.

In an illustrative example, processing core110may have a micro-architecture including processor logic and circuits. Processor cores with different micro-architectures can share at least a portion of a common instruction set. For example, similar register architectures may be implemented in different ways in different micro-architectures using various techniques, including dedicated physical registers, one or more dynamically allocated physical registers using a register renaming mechanism (e.g., the use of a register alias table (RAT), a reorder buffer (ROB) and a retirement register file).

Memory controller120may perform functions that enable the processing device100to access and communicate with memory (not shown) that includes a volatile memory and/or a non-volatile memory. In some embodiments, the memory controller120may be located on a processor die associated with processing device100, while the memory is located off the processor die. In some embodiments, the processing device100includes a cache unit130to cache instructions and/or data. The cache unit130includes, but is not limited to, a level one (L1)132, level two (L2)134, and a last level cache (LLC)136, or any other configuration of the cache memory within the processing device100. In some embodiments, the L1 cache132and L2 cache134can transfer data to and from the LLC136. In one embodiment, the memory controller120can be connected to the LLC136to transfer data between the cache unit130and memory. As shown, the cache unit130can be integrated into the processing cores110. The cache unit130may store data (e.g., including instructions) that are utilized by one or more components of the processing device100.

In some embodiments, the processing device100may execute one or more user level applications140(e.g., a user-level multithreaded application). Such user-level applications140may be executed by system software (not shown) installed at the processing device100. Examples of system software include, but are not limited to, one or more operating systems, a virtual machine monitor (VMM), a hypervisor, and the like, and combinations thereof. The user-level applications140may use instructions (e.g., instructions150) to control the processing device100as disclosed herein. The instructions150may represent macroinstructions, assembly language instructions, or machine-level instructions that are provided to the processing core110for execution.

In some embodiments, the processing core110is operative to perform an embodiment of a call procedure instruction152and an embodiment of a return from procedure instruction154as specified by the instructions150. The call procedure instruction152will often be referred to simply as a call instruction, and the return from procedure instruction154will often be referred to simply as a return instruction. The call and return instructions may represent instructions or control signals of a particular instruction set for the processing device100to execute at a certain privilege level. During operation, the processing core110may receive the call instruction152. For example, the call instruction152may be received from a calling procedure associated with user-level applications140that is calling a subroutine, routine, interrupt handler, or the like. In some embodiments, an address of the return instruction154may be pushed onto a data stack stored in memory when functions or procedures have been called.

If the call instruction152causes a change in the current privilege level of the processing device100, the processing device100performs a stack switch from the current stack to a stack defined for the new privilege level. For example, the call instruction152may cause the processing device100to change the current privilege level to access certain system resources that are not accessible at the current privilege level. In some embodiments, one or more shadow stacks stored in memory are used to help to protect the data stack from tampering and/or to help to increase computer security. The information stored on the shadow stack(s) may represent return address related information related to the return instruction154(e.g., actual return addresses, information to validate return addresses, other return address information).

To identify the current shadow stack for a particular privilege level, the processing device100includes a number of shadow stack registers170where each register is associated with a certain privilege level. As an illustrative example, the processing device100may include four (4) registers referred to as IA32_PLx_SSP where x represent a privilege level (e.g., 0, 1, 2 or 3). In some embodiments, the shadow stack registers170may be model specific registers (MSRs) or general purpose registers (GPRs). In other embodiments, various types of structures can be used as the registers170so long as they are capable of storing and providing data as described herein.

At startup of the processing device100, system software associated with the device100may program a stack pointer (SSP)175into each of the shadow stack registers170. The stack pointer (SSP)175is operative to identify a particular shadow stack for the privilege level identified by the register. For example, the SSP175may be a linear address in memory that points to the top of a shadow stack. In one embodiment, the processing device100may include shadow stack protection logic180to control access to the shadow stacks via the shadow stack registers170during ring transitions. The shadow stack protection logic may also enforce that loads and stores intended for the shadow stack may fault if the address to which this load or store is performed is not marked in the page tables as being of shadow stack type. This shadow stack protection logic may also prevent stores to shadow stack memory by software initiated stores through instructions, such as “MOV” and “XSAVE”. In some embodiments, the shadow stack protection logic180may also include an optional configurable shadow stack mode185. The shadow stack mode185may be a bit indicator that is configured to alternately enable and disable use of the shadow stacks by the processing device100. Alternatively, the shadow stacks may optionally always be enabled and the shadow stack mode185may optionally be omitted. Alternately, there may be a shadow stack mode corresponding to each of the privilege levels.

FIG. 2illustrates a system200including a memory201for supporting processor extensions to protect stacks during ring transitions according to one embodiment. In this example, the memory201stores one or more data stacks, such as data stack203. The data stacks are sometimes referred to as the call stack, the data stack, or just the stack. Data stack203may represent a stack type data structure that is operative to store both data205and control information207for directing a control flow of an executed instruction. Typically, there is a data stack203for each privilege level associated with the processing device100. As such, when the processing device100switches privilege level it also switches the data stack203like it does for the shadow stack as described in the present disclosure. The data205for each data stack may represent any of a wide variety of different types of data that can be push onto the data stack201(e.g., parameters and other data passed to subroutines, etc.). Commonly, the control information207may include one or more return addresses for one or more previously performed procedure calls. These return addresses may represent instruction addresses where a called procedure is to return control flow when the called procedure finishes and returns.

As shown inFIG. 2, the memory201also includes a plurality of shadow stacks209. The shadow stacks209are used to help protect the data stack203from certain type of control flow attacks. The shadow stacks209may represent additional stack type data structures that are separate from the data stack203. In some embodiments, the shadow stacks209may be used to store information associated with the control information207of an executed instruction but not the data205. In one illustrative example, the shadow stacks209may store a code segment (CS) descriptor, such as CS240, that specific the code segment in memory201being executed and an instruction pointer (EIP), such as EIP250, that may identify a return address related to an instruction in the data stack203as well other information. In some embodiments, the memory used to create the shadow stacks may be marked as being of shadow stack memory type in the page tables, such that loads and stores to the shadow stack fault if they are not to memory of type shadow stack. Similarly, stores not intended for the shadow stack fault if they are made to memory marked as shadow stack memory.

Although system200may include a plurality of shadow stacks209, only one shadow stack at a time may be selected as a current shadow stack210. In this regard, the shadow stacks209may individually operate in an unprivileged user-level mode (e.g., a ring3privilege level) or in a privileged or supervisor privilege level mode (a ring0, ring1, or ring2privilege level). In some embodiments, each of the shadow stacks209includes a shadow stack pointer (SSP), such as SSP220, which is operative to identify the top of the shadow stack. For example, the SSP220may be a linear address in memory201that points to the top of a current shadow stack. As noted above, the SSP220may be stored in one of the shadow stack registers170associated with a particular privilege level.

As shown, the system200may also include processing device100fromFIG. 1. In some embodiments, the processing device100may have a current privilege level that controls the execution of an application in the system200. In certain situation, the processing device100may change its current privilege level to a new privilege level in order to control accessibility of the application to resources of system200. For example, the processing device100may change its current privilege level in response to certain types of operations, such as a called procedure, an interrupt/exception handler or in response to other type of operations. In some embodiments, the processing device100may employ shadow stack protection logic180to protect the stack during the privilege level transition.

In one example of a privilege level transition, the processing device100may transition from a current privilege level (CPL) in a user mode (e.g., CPL3) to a new privilege level in a supervisor mode (e.g., CPL<3). This type of privilege level transition may be initiated, for example, by a call through a call gate that requests a change a higher privilege level or by calling an interrupt/exception handler. In response to the user mode to supervisor mode privilege level transition, the processing device100checks whether the shadow stacks209are enabled for the processing device100at the new privilege level. For example, processing device100may check the setting of the shadow stack mode185indicator to determine whether the shadow stacks209are enable or disable. If the shadow stacks209are enabled, a current SSP associated with the user mode is saved to one of the shadow stack registers170. Thereupon, the new shadow stack210is established for the supervisor mode using the SSP, such as SSP220, stored in the register associated with the new privilege level. In some embodiments, the user mode SSP is saved into the shadow stack register so that the processing device100in the supervisor mode can modify the user mode SSP when necessary, such as to do shadow stack unwinds to remove entries from the stack and other types of fix ups before returning to the user mode again.

Once the processing device100retrieves the SSP220from the register associated the new privilege level, the processing device100automatically performs several checks to verify the SSP programed in the register by using certain logic of the shadow stack protection logic180, such as the verify and set busy logic225. The automatic checks include, but are not limited to, verifying that the SSP220programed in the register is pointing to a top of supervisor shadow stack (e.g., shadow stack210, the shadow stack identified by the SSP220can be used for the current mode of platform hardware associated with the processing device100and that shadow stack is not loaded onto any other process thread. These checks may be used to prevent certain attacks, such as a cross thread where an attacker may point the register on two different processor threads to the same shadow stack to manipulate the return address consumed on one processor by making calls on the second processor.

To perform the checks to verify the SSP220, system software (e.g., kernel or OS) of the processing device100identifies a token230at the top of the shadow stack210pointed by the SSP. In some embodiments, the processing device100may (e.g., atomically) load the (e.g., 8 bytes of) token230from the address specified by the SSP220. In one embodiment, the loading of token230locks the token and/or the location (e.g., cache line) to prevent the token from being copied or modified by another processor core or processing device. In one embodiment, loading of the token is done by the processing device100using a specific shadow stack operation, such that if the address to which the load or store is performed is not memory marked as shadow stack memory in the page tables it causes a fault.

The token230comprises a plurality of bits that are used to verify the SSP220programed in the register. In some embodiments, the processing device100analyzes the plurality of bits to identify set bits that represent a linear address of the token230, a busy indicator that can be a determined bit of the token set to a value (e.g., 1 or 0) indicating whether the shadow stack210is already loaded onto any logical processor, a flag indicator that can be another determined bit of the token set to a value (e.g., 1 or 0) indicating whether the shadow stack210is for use in a certain bit mode (e.g., 32-bit or 64-bit) as well as other relevant information.

In accordance with the verify logic225, the processing device100checks that the busy indicator is not set (e.g., 0) indicating that the shadow stack210is not already loaded onto any logical processor. The processing device100also checks that the hardware platform of system200is operating in a mode that matches the bit mode represented by the flag indicator. For example, based on the flag indicator, flag the processing device100may determine that the shadow stack210is for use on a 32-bit or 64 bit machine. The processing device100may then check, for example, a platform register associated with the hardware platform to verify that the platform is in a corresponding operating mode (e.g., 32-bit or 64-bit). The processing device100also checks that the linear address recorded in the token230matches the linear address of the SSP220.

This check to match the linear addresses verifies that the register170is pointing to the top of a valid shadow stack since the linear address of an 8 byte location on the shadow stack will not appear in the contents of those 8 bytes on a shadow stack except when created by system software to initialize the token203. As such, the token230forms an indicator that the shadow stack pointer as stored in the register170is pointing to the top of a valid shadow stack. In some embodiments, the processing device100enforces that the shadow stack is aligned to 4 bytes or 8 bytes depending on whether the processing device100is in 32 bit or 64 bit mode of operation, and thus, the lower 2 bits of the shadow stack pointer220are always 0 and can be used to save the busy indicator and the flag of token230. If all of the above checks results in a correct indication, then the busy indicator of the token may be set to a value (e.g., 1) to indicate that the shadow stack pointed by the SSP220is in use at the new privilege level. In should be noted that while these checks are being performed the memory location (e.g. the cache line) containing the token230is locked by the processing device100such that it cannot be modified (e.g. set busy by another logical processor). Subsequent to setting the busy bit the processor100releases the lock on this memory location. Doing these checking operations with a lock held on the token ensures that there are no time-of-check-to-time-of-use issues. Otherwise if any of the above checks fail, the processing device100may generate a fault or alert that can be transmitted, for example, to an operating system associated with the processing device100. In some embodiments, if a fault is generated, the lock on the memory location containing the token230is released without modifying the contents of the location.

On a return to the user mode privilege level from the supervisor mode, such as a CPL0/1/2−>CPL3mode transition, the processing device100performs several checks by using certain logic, such as verify and clear busy logic225. This type of privilege level transition may be initiated, for example, by an interrupt return (IRET) instruction or a “FAR RET” instruction that shifts the next address to be executed to the instruction pointer of the CPU or other types of return instructions.

As part of the return transition to the user mode privilege level, the processing device100as directed by the verify and clear busy logic235checks whether the busy indicator in the token230is set and whether the linear address recorded in the token matches the address of the SSP220and if the SSP220is pointing to an 8 byte aligned address. If all of the above checks results in a correct indication, then the processing device100marks the token230as “free” by clearing the busy indicator in the token230. It should be noted that the token is loaded from the memory address pointed to by the SSP220using a locked load such that the location (e.g. cache line) is locked from subsequent modifications. If the verification succeeds then the busy bit is cleared and the lock is released. If the verification does not succeed then the lock is released without modifying the contents of that location. Thereafter, the processing device100retrieves the SSP for the user mode from the appropriate shadow stack register170associated with that privilege level. Otherwise, the processing device100may generate a fault indicating that the token230is not valid.

In another example of a privilege level transition, the processing device100may transition from a current supervisor mode privilege level to a new higher supervisor mode, such as a CPL2−>CPL1, CPL1−>CPL0or CPL2−>CPL0mode transition. This type of privilege level transition may be initiated, for example, by a call through a call gate that requests a change a higher privilege level or by calling and interrupt/exception handler. On such a transition, the processing device100selects the SSP220for the new privilege level from the appropriate one of the shadow stack registers170for that level. Once the processing device100retrieves the SSP220from the register associated the new privilege level, the processing device100performs several checks to verify the SSP programed in the register.

In some embodiments, the processing device100performs the checks by using verify and set busy logic225as described above. If the checks are successful, the processing device100marks the shadow stack210as busy by setting the busy indicator in the token230. Then, the processing device100pushes the CS240selector (e.g., code segment selector) identifying the code segment in memory201being executed, EIP250identifying return address information and the SSP260associated with the current privilege level onto the shadow stack of the new privilege level. In some embodiments, the processing device100may push a linear instruction pointer (LIP) (which is the EIP plus the code segment base) on the shadow stack of the new privilege level instead of the EIP250. This may be done in order to detect any attempts to change the code segment base between a call and return from the call.

On a return to the previous supervisor mode from the new supervisor mode, the processing device100ensures that such returns are to the same address where the previous call was made from. For example, the processing device100verifies that the CS240and EIP250(or LIP) from the shadow stack210matches corresponding values on the data stack203. If there is a match, then the processing device100removes or pops the CS240, EIP250and SSP260off of the shadow stack210to establish the new SSP used at the new privilege level. In some embodiments, the push and pop operations are done using specific shadow stack store and load operations, such that if the operations are to memory not marked as shadow stack memory in the page tables the operations cause a fault.

As part of the transition, the processing device100as directed by the verify and clear busy logic235checks whether the busy indicator in the token230of the shadow stack pointed to SSP220is set and whether the linear address recorded in the token230matches the address of the SSP220. If all of the above checks results in a correct indication, then the processing device100marks the token230as “free” by clearing the busy indicator in the token230.

In yet another example of a privilege level transition may be based on a mode transition of the processing device100from a user mode to a most trusted privilege level, such as CPL3−>CPL0mode transition. This type of privilege level transition may be initiated, for example, using a certain instruction like SYSCALL or SYSENTER that is designed to invoke system function calls where some of the system calls do not use the stack to perform the system call operations. In such a transition, the processing device100save the current SSP in the register associated with the user mode and switches to the shadow stack associated with CPL0privilege level by retrieving the SSP in the corresponding register. Since processing device100may be performing a system critical operation it does not verify the SSP, but it still selects one of the shadow stacks among the set of the shadow stacks as the current SSP for the new privilege level. For example, this type of privilege level transition may be initiated, for example, by a fast system call that does not use the stack to perform the system call operations. In some embodiments, if the system call needs to use the stack to make calls then it may be configured to use a new instruction provided by the processing device100to perform the verify and mark the shadow stack as busy, such as employed in the verify and set busy logic225. This operation of the verify and set busy logic225is done on a shadow stack that is selected, but not previously verified and set busy.

On a return to the previous user mode from the most trusted privilege level, such as a CPL0−>CPL3mode transition, the processing device100restores the user mode shadow stack by access the SSP stored in the register corresponding to the user mode privilege level. This type of privilege level transition may be initiated, for example, by system return or exit instructions (e.g., SYSRET or SYSEXIT). Prior to returning to CPL3, if the system call used the new instruction provided by the processing device100to verify and mark the shadow stack as busy, a complementary instruction is provided by the processing device100to verify and mark the shadow stack as free, such as employed in the verify and clear busy logic235.

FIG. 3illustrates a system300including the memory201ofFIG. 2for switching stacks as part of an interrupt or exception delivery according to one embodiment. In some embodiments, the present disclosure provides techniques to complement a shadow stack switch during delivery of certain interrupts and execution by using an interrupt shadow stack pointer table310instead of the shadow stack registers170being used to select a shadow stack pointer for the privilege level at which this interrupt or exception handler is to be executed. System software of the processing device110may program the address of the table310into a register, such as interrupt SSP table address register320. The table310is used to store the SSP220that is identified by the processing device100during a ring transition as described above with respect to system200or to cause a stack switch even without a ring transition if the interrupt or exception was configured to operate on a new shadow stack. In this regard, the selection of the new shadow stack is from one of the shadow stack pointers in the Interrupt shadow stack table310using a selector330configured for that interrupt in a interrupt descriptor table (IDT).

In operation, when an exception or interrupt occurs, the processing device100may respond with a control transfer to a certain code sequence intended to deal with such an event. This code sequence typically runs in supervisor mode. The address of this special code sequence, or routine, is retrieved by the processing device100from an Interrupt Descriptor Table (IDT), using an index into the IDT that is specific to the type of exception that occurred (e.g. one index may correspond to a page fault while another corresponds to an overflow exception). This IDT entry may further have an index into the interrupt shadow stack table310, such that when this index value is non-zero it indicates that a shadow stack switch must be performed for that interrupt or exception even when there was no privilege change required to deliver the interrupt or exception. The processing device100may use the index associated with the IDT to index the interrupt shadow stack pointer table310to identify the entry storing the SSP220. For example, the entry in the interrupt shadow stack pointer table310may also be specific to the type of exception that occurred. The SSP220may be then used by the processing device100at a new privilege level associated with the interrupt. Subsequent to selection of the SSP, the processor device100invokes certain logic (e.g., Verify and Set Busy Logic225, to ensure that the SSP220stored in the Interrupt Shadow Stack Table310points to the top of valid shadow stack for that mode of operation and that the shadow stack is not busy.

FIG. 4illustrates a system400including memory201ofFIG. 2for switching stacks as part of task switching according to one embodiment. In a task switching operation, processing device100may execute a control transfer instruction that causes a task switch from a current running task to a new task. In some embodiments, the tasks may represent units of work that the processing device100can dispatch, execute or suspend. By way of example, the tasks may be used to execute one or more of a program, a task or process, an operating-system service utility, an interrupt or exception handler, or a kernel or executive utility. In one aspect, task switches may be performed when call procedure instructions are performed, or when interrupts or exceptions occur, or otherwise.

When the processing device100preforms a task switch from a current task to a new task, the device100saves state information of the current task in a data structure in memory201referred to as a task state-segment (TSS), such as current TSS420, that corresponds to the current task, and state information of a new task427may be loaded or retrieved from another TSS (e.g., New TSS425) that corresponds to the new task427. This state information may include, but not limited to, information required for performing task switches, such as stack and instruction pointers and an110map base addresses.

The TSS represents a hardware managed data structure in memory on Intel® Architecture compatible computers that may be used to store information about tasks. For example, the TSS includes information required for the processing device100to preform task switches, such as stack pointers. Each TSS for the different tasks may include stack pointers to different stacks (e.g., data stacks used to store both control information and data) for different privilege levels. The stack pointers are used to identify the appropriate stack when privilege level changes are made due to the task switching operation. For example, a task switch operation may include switching a current task at the current privilege level to a new task at a new privilege level.

In some embodiments, shadow stacks as described herein may be used to protect the data stacks during a privilege level transition from the current task to the new task. As noted above, the shadow stack is a second stack separate from the data stack that stores and protects information from the data stack used in control transfer operations. In one embodiment, shadow stack selection information, such as shadow stack pointer430, may be stored in the TSS structure in certain Intel® Architecture compatible computers.

Referring toFIG. 4, the processing device100in operation responds to a task switch from a current task to a new task by identifying a TSS420associated with the new task. In this regard, the task switch may be initiated, for example, by a call instruction, an interrupt/exception or otherwise. In some embodiments, the processing device100retrieves an SSP430stored in the TSS420. The SSP430identifies a shadow stack410to use with the new task.

In some embodiments, the processing device100verifies SSP430by preforming checks using verify and set busy logic225as described above. If the checks are successful, the processing device100marks the shadow stack210as busy by setting the busy indicator in the token440. Then, the processing device100pushes the CS450pointer identifying the code segment of the current task being executed, EIP460identifying return address information related to the current task and the SSP470associated with the current privilege level of the current task onto the new shadow stack.

On a return from the new task to a previous task, the processing device100ensures that such returns are to the same address of the previous task. For example, the processing device100verifies that the CS450and EIP460from the shadow stack410matches corresponding values in the TSS associated with the previous task. If there is a match, then the processing device100removes or pops the CS450, EIP460and SSP470off of the shadow stack410to establish the current SSP used in the previous task. As part of the return transition to the previous task, the processing device100as directed by the verify and clear busy logic235checks whether the busy indicator in the token440is set and whether the linear address of the token440matches the address of the SSP430. If all of the above checks results in a correct indication, then the processing device100marks the token440as “free” by clearing the busy indicator in the token440.

FIG. 5illustrates a flow diagram of a method500of switching stacks on a privilege transfer or when a stack switch was caused due to selection of a non-zero index in the interrupt SSP table or due to a task switch, according to one embodiment. Method500may be performed by processing logic that may comprise hardware (e.g., circuitry, dedicated logic, programmable logic, microcode, etc.), software (such as instructions run on a processing device), firmware, or a combination thereof. In one embodiment, the processing device100inFIG. 1as direct by the shadow stack protection logic180may perform method500. Although shown in a particular sequence or order, unless otherwise specified, the order of the processes can be modified. Thus, the illustrated implementations should be understood only as examples, and the illustrated processes can be performed in a different order, and some processes may be performed in parallel. Additionally, one or more processes can be omitted in various embodiments. Thus, not all processes are required in every implementation. Other process flows are possible.

Method500begins at block510where an instruction to change a current privilege level (CPL) of a currently active application to a new privilege level is received. In block520, a shadow stack pointer (SSP) stored in a register of a plurality of registers is selected in view of the new privilege level. A shadow stack for use by a processor at the new privilege level is identified using the SSP at block530. Method500braches at block535depending on whether the change in the CPL is initiated by a call procedure instruction or return instruction. If the change is initiated by a call procedure instruction, method500proceeds to block540. Otherwise, method500proceeds to block570.

In block540, the shadow stack associated with the new privilege level is verified. If the shadow stack is valid, the shadow stack is then marked as busy in block550. Then, address pointers related to the instruction are pushed on to the shadow stack in block560. In some embodiments, the pushing of return address pointers in block560may be omitted, such as on a CPL3−>CPL0/1/2transition (e.g., a user to supervisor transition). In such cases, the CPL3 SSP may be saved to a user mode register if the transition was from CPL3−>CPL0/1/2. If the shadow stack is not valid, a fault is generated at block545.

In block570, a determination is made as to whether address pointers stored on the shadow stack match a return address related to the instruction. In some embodiments, matching of the return address pointers in block570may be omitted, such as on a CPL0/1/2−>CPL3transition (e.g., a supervisor to user mode transition). In such cases, the previously saved SSP of CPL3 may be retrieved from the user mode register if the transition was from CPL0/1/2−>CPL3. If the address pointers on the shadow stack and data stack match, the address pointers popped off of the shadow stack in block580. In addition, the SSP for the lower supervisor privilege may be popped from the shadow stack of the higher supervisor privilege in block580to establish the SSP for the lower supervisor privilege. The shadow stack is then marked as not busy or otherwise free in block590. If the address pointers do not match, a fault is generated at block575.

FIG. 6Ais a block diagram illustrating a micro-architecture for a processor600that implements techniques for processor extensions to protect stacks during ring transitions in accordance with one embodiment of the disclosure. Specifically, processor600depicts an in-order architecture core and a register renaming logic, out-of-order issue/execution logic to be included in a processor according to at least one embodiment of the disclosure.

Processor600includes a front end unit630coupled to an execution engine unit650, and both are coupled to a memory unit670. The processor600may include 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, processor600may include a special-purpose core, such as, for example, a network or communication core, compression engine, graphics core, or the like. In one embodiment, processor600may be a multi-core processor or may part of a multi-processor system.

The front end unit630includes a branch prediction unit632coupled to an instruction cache unit634, which is coupled to an instruction translation lookaside buffer (TLB)636, which is coupled to an instruction fetch unit638, which is coupled to a decode unit640. The decode unit640(also known as a decoder) may decode instructions, and generate as an output one or more micro-operations, micro-code entry points, microinstructions, other instructions, or other control signals, which are decoded from, or which otherwise reflect, or are derived from, the original instructions. The decoder640may be implemented using various different mechanisms. Examples of suitable mechanisms include, but are not limited to, look-up tables, hardware implementations, programmable logic arrays (PLAs), microcode read only memories (ROMs), etc. The instruction cache unit634is further coupled to the memory unit670. The decode unit640is coupled to a rename/allocator unit652in the execution engine unit650.

The execution engine unit650includes the rename/allocator unit652coupled to a retirement unit654and a set of one or more scheduler unit(s)656. The scheduler unit(s)656represents any number of different schedulers, including reservations stations (RS), central instruction window, etc. The scheduler unit(s)656is coupled to the physical register file(s) unit(s)658. Each of the physical register file(s) units658represents one or more physical register files, different ones of which store one or more different data types, such as scalar integer, scalar floating point, packed integer, packed floating point, vector integer, vector floating point, etc., status (e.g., an instruction pointer that is the address of the next instruction to be executed), etc. The physical register file(s) unit(s)658is overlapped by the retirement unit654to illustrate various ways in which register renaming and out-of-order execution may be implemented (e.g., using a reorder buffer(s) and a retirement register file(s), using a future file(s), a history buffer(s), and a retirement register file(s); using a register maps and a pool of registers; etc.). The execution engine unit650may include for example a power management unit (PMU)690that governs power functions of the functional units.

Generally, the architectural registers are visible from the outside of the processor or from a programmer's perspective. The registers are not limited to any known particular type of circuit. Various different types of registers are suitable as long as they are capable of storing and providing data as described herein. Examples of suitable registers include, but are not limited to, dedicated physical registers, dynamically allocated physical registers using register renaming, combinations of dedicated and dynamically allocated physical registers, etc. The retirement unit654and the physical register file(s) unit(s)658are coupled to the execution cluster(s)660. The execution cluster(s)660includes a set of one or more execution units662and a set of one or more memory access units664. The execution units662may perform various operations (e.g., shifts, addition, subtraction, multiplication) and operate 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 a number of execution units dedicated to specific functions or sets of functions, other embodiments may include only one execution unit or multiple execution units that all perform all functions. The scheduler unit(s)656, physical register file(s) unit(s)658, and execution cluster(s)660are shown as being possibly plural because certain embodiments create separate pipelines for certain types of data/operations (e.g., a scalar integer pipeline, a scalar floating point/packed integer/packed floating point/vector integer/vector floating point pipeline, and/or a memory access pipeline that each have their own scheduler unit, physical register file(s) unit, and/or execution cluster—and in the case of a separate memory access pipeline, certain embodiments are implemented in which only the execution cluster of this pipeline has the memory access unit(s)664). It should also be understood that where separate pipelines are used, one or more of these pipelines may be out-of-order issue/execution and the rest in-order.

The set of memory access units664is coupled to the memory unit670, which may include a data prefetcher680, a data TLB unit672, a data cache unit (DCU)674, and a level 2 (L2) cache unit676, to name a few examples. In some embodiments DCU674is also known as a first level data cache (L1 cache). The DCU674may handle multiple outstanding cache misses and continue to service incoming stores and loads. It also supports maintaining cache coherency. The data TLB unit672is a cache used to improve virtual address translation speed by mapping virtual and physical address spaces. In one exemplary embodiment, the memory access units664may include a load unit, a store address unit, and a store data unit, each of which is coupled to the data TLB unit672in the memory unit670. The L2 cache unit676may be coupled to one or more other levels of cache and eventually to a main memory.

In one embodiment, the data prefetcher680speculatively loads/prefetches data to the DCU674by automatically predicting which data a program is about to consume. Prefeteching may refer to transferring data stored in one memory location of a memory hierarchy (e.g., lower level caches or memory) to a higher-level memory location that is closer (e.g., yields lower access latency) to the processor before the data is actually demanded by the processor. More specifically, prefetching may refer to the early retrieval of data from one of the lower level caches/memory to a data cache and/or prefetch buffer before the processor issues a demand for the specific data being returned.

In one implementation, processor600may be the same as processing device100described with respect toFIG. 6to support processor extensions to protect stacks during ring transitions in a processing device described with respect to implementations of the disclosure.

The processor600may support one or more instructions sets (e.g., the x86 instruction set (with some extensions that have been added with newer versions); the MIPS instruction set of MIPS Technologies of Sunnyvale, Calif.; the ARM instruction set (with optional additional extensions such as NEON) of ARM Holdings of Sunnyvale, Calif.).

FIG. 6Bis a block diagram illustrating an in-order pipeline and a register renaming stage, out-of-order issue/execution pipeline implemented by processor600ofFIG. 6Aaccording to some embodiments of the disclosure. The solid lined boxes inFIG. 6Billustrate an in-order pipeline, while the dashed lined boxes illustrates a register renaming, out-of-order issue/execution pipeline. InFIG. 6B, a processor pipeline601includes a fetch stage602, a length decode stage604, a decode stage606, an allocation stage608, a renaming stage610, a scheduling (also known as a dispatch or issue) stage612, a register read/memory read stage614, an execute stage616, a write back/memory write stage618, an exception handling stage622, and a commit stage624. In some embodiments, the ordering of stages602-624may be different than illustrated and are not limited to the specific ordering shown inFIG. 6B.

FIG. 7illustrates a block diagram of the micro-architecture for a processor700that includes logic circuits to implement techniques for processor extensions to protect stacks during ring transitions in accordance with one embodiment of the disclosure. In some embodiments, an instruction in accordance with one embodiment can be implemented to operate on data elements having sizes of byte, word, doubleword, quadword, etc., as well as datatypes, such as single and double precision integer and floating point datatypes. In one embodiment the in-order front end701is the part of the processor700that fetches instructions to be executed and prepares them to be used later in the processor pipeline.

The front end701may include several units. In one embodiment, the instruction prefetcher726fetches instructions from memory and feeds them to an instruction decoder728which in turn decodes or interprets them. For example, in one embodiment, the decoder decodes a received instruction into one or more operations called “micro-instructions” or “micro-operations” (also called micro op or uops) that the machine can execute. In other embodiments, the decoder parses the instruction into an opcode and corresponding data and control fields that are used by the micro-architecture to perform operations in accordance with one embodiment. In one embodiment, the trace cache730takes decoded uops and assembles them into program ordered sequences or traces in the uop queue734for execution. When the trace cache730encounters a complex instruction, the microcode ROM732provides the uops needed to complete the operation.

Some instructions are converted into a single micro-op, whereas others need several micro-ops to complete the full operation. In one embodiment, if more than four micro-ops are needed to complete an instruction, the decoder728accesses the microcode ROM732to do the instruction. For one embodiment, an instruction can be decoded into a small number of micro ops for processing at the instruction decoder728. In another embodiment, an instruction can be stored within the microcode ROM732should a number of micro-ops be needed to accomplish the operation. The trace cache730refers to an entry point programmable logic array (PLA) to determine a correct micro-instruction pointer for reading the micro-code sequences to complete one or more instructions in accordance with one embodiment from the micro-code ROM732. After the microcode ROM732finishes sequencing micro-ops for an instruction, the front end701of the machine resumes fetching micro-ops from the trace cache730.

The out-of-order execution engine703is where the instructions are prepared for execution. The out-of-order execution logic has a number of buffers to smooth out and re-order the flow of instructions to optimize performance as they go down the pipeline and get scheduled for execution. The allocator logic allocates the machine buffers and resources that each uop needs in order to execute. The register renaming logic renames logic registers onto entries in a register file. The allocator also allocates an entry for each uop in one of the two uop queues, one for memory operations and one for non-memory operations, in front of the instruction schedulers: memory scheduler, fast scheduler702, slow/general floating point scheduler704, and simple floating point scheduler706. The uop schedulers702,704,706, determine when a uop is ready to execute based on the readiness of their dependent input register operand sources and the availability of the execution resources the uops need to complete their operation. The fast scheduler702of one embodiment can schedule on each half of the main clock cycle while the other schedulers can only schedule once per main processor clock cycle. The schedulers arbitrate for the dispatch ports to schedule uops for execution.

Register files708,710, sit between the schedulers702,704,706, and the execution units712,714,716,718,720,722,724in the execution block711. There is a separate register file708,710, for integer and floating point operations, respectively. Each register file708,710, of one embodiment also includes a bypass network that can bypass or forward just completed results that have not yet been written into the register file to new dependent uops. The integer register file708and the floating point register file710are also capable of communicating data with the other. For one embodiment, the integer register file708is split into two separate register files, one register file for the low order32bits of data and a second register file for the high order32bits of data. The floating point register file710of one embodiment has128bit wide entries because floating point instructions typically have operands from64to128bits in width.

The execution block711contains the execution units712,714,716,718,720,722,724, where the instructions are actually executed. This section includes the register files708,710, that store the integer and floating point data operand values that the micro-instructions need to execute. The processor700of one embodiment is comprised of a number of execution units: address generation unit (AGU)712, AGU714, fast ALU716, fast ALU718, slow ALU720, floating point ALU722, floating point move unit724. For one embodiment, the floating point execution blocks722,724, execute floating point, MMX, SIMD, and SSE, or other operations. The floating point ALU722of one embodiment includes a64bit by64bit floating point divider to execute divide, square root, and remainder micro-ops. For embodiments of the disclosure, instructions involving a floating point value may be handled with the floating point hardware.

In one embodiment, the ALU operations go to the high-speed ALU execution units716,718. The fast ALUs716,718, of one embodiment can execute fast operations with an effective latency of half a clock cycle. For one embodiment, most complex integer operations go to the slow ALU720as the slow ALU720includes integer execution hardware for long latency type of operations, such as a multiplier, shifts, flag logic, and branch processing. Memory load/store operations are executed by the AGUs712,714. For one embodiment, the integer ALUs716,718,720, are described in the context of performing integer operations on 64 bit data operands. In alternative embodiments, the ALUs716,718,720, can be implemented to support a variety of data bits including 16, 32, 128, 256, etc. Similarly, the floating point units722,724, can be implemented to support a range of operands having bits of various widths. For one embodiment, the floating point units722,724, can operate on 128 bits wide packed data operands in conjunction with SIMD and multimedia instructions.

In one embodiment, the uops schedulers702,704,706, dispatch dependent operations before the parent load has finished executing. As uops are speculatively scheduled and executed in processor700, the processor700also includes logic to handle memory misses. If a data load misses in the data cache, there can be dependent operations in flight in the pipeline that have left the scheduler with temporarily incorrect data. A replay mechanism tracks and re-executes instructions that use incorrect data. Only the dependent operations need to be replayed and the independent ones are allowed to complete. The schedulers and replay mechanism of one embodiment of a processor are also designed to catch instruction sequences for text string comparison operations.

The processor700also includes logic to implement store address prediction for memory disambiguation according to embodiments of the disclosure. In one embodiment, the execution block711of processor700may include a store address predictor (not shown) for implementing techniques for processor extensions to protect stacks during ring transitions in accordance with one embodiment of the disclosure.

The term “registers” may refer to the on-board processor storage locations that are used as part of instructions to identify operands. In other words, registers may be those that are usable from the outside of the processor (from a programmer's perspective). However, the registers of an embodiment should not be limited in meaning to a particular type of circuit. Rather, a register of an embodiment is capable of storing and providing data, and performing the functions described herein. The registers described herein can be implemented by circuitry within a processor using any number of different techniques, such as dedicated physical registers, dynamically allocated physical registers using register renaming, combinations of dedicated and dynamically allocated physical registers, etc. In one embodiment, integer registers store thirty-two bit integer data. A register file of one embodiment also contains eight multimedia SIMD registers for packed data.

For the discussions below, the registers are understood to be data registers designed to hold packed data, such as 64 bits wide MMXTM registers (also referred to as ‘mm’ registers in some instances) in microprocessors enabled with MMX technology from Intel Corporation of Santa Clara, Calif. These MMX registers, available in both integer and floating point forms, can operate with packed data elements that accompany SIMD and SSE instructions. Similarly, 128 bits wide XMM registers relating to SSE2, SSE3, SSE4, or beyond (referred to generically as “SSEx”) technology can also be used to hold such packed data operands. In one embodiment, in storing packed data and integer data, the registers do not need to differentiate between the two data types. In one embodiment, integer and floating point are either contained in the same register file or different register files. Furthermore, in one embodiment, floating point and integer data may be stored in different registers or the same registers.

Embodiments may be implemented in many different system types. Referring now toFIG. 8, shown is a block diagram illustrating a system800in which an embodiment of the disclosure may be used. As shown inFIG. 8, multiprocessor system800is a point-to-point interconnect system, and includes a first processor870and a second processor880coupled via a point-to-point interconnect850. While shown with only two processors870,880, it is to be understood that the scope of embodiments of the disclosure is not so limited. In other embodiments, one or more additional processors may be present in a given processor. In one embodiment, the multiprocessor system800may implement techniques for processor extensions to protect stacks during ring transitions as described herein.

Processors870and880are shown including integrated memory controller units872and882, respectively. Processor870also includes as part of its bus controller units point-to-point (P-P) interfaces876and878; similarly, second processor880includes P-P interfaces886and888. Processors870,880may exchange information via a point-to-point (P-P) interface850using P-P interface circuits878,888. As shown inFIG. 8, IMCs872and882couple the processors to respective memories, namely a memory832and a memory834, which may be portions of main memory locally attached to the respective processors.

Processors870,880may exchange information with a chipset890via individual P-P interfaces852,854using point to point interface circuits876,894,886,898. Chipset890may also exchange information with a high-performance graphics circuit838via a high-performance graphics interface839.

Chipset890may be coupled to a first bus816via an interface896. In one embodiment, first bus816may 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 disclosure is not so limited.

As shown inFIG. 8, various I/O devices814may be coupled to first bus816, along with a bus bridge818, which couples first bus816to a second bus820. In one embodiment, second bus820may be a low pin count (LPC) bus. Various devices may be coupled to second bus820including, for example, a keyboard and/or mouse822, communication devices827and a storage unit828such as a disk drive or other mass storage device, which may include instructions/code and data830, in one embodiment. Further, an audio I/O824may be coupled to second bus820. Note that other architectures are possible. For example, instead of the point-to-point architecture ofFIG. 8, a system may implement a multi-drop bus or other such architecture.

Referring now toFIG. 9, shown is a block diagram of a system900in which one embodiment of the disclosure may operate. The system900may include one or more processors910,915, which are coupled to graphics memory controller hub (GMCH)920. The optional nature of additional processors915is denoted inFIG. 9with broken lines. In one embodiment, processors910,915support processor extensions to protect stacks during ring transitions according to embodiments of the disclosure.

Each processor910,915may be some version of the circuit, integrated circuit, processor, and/or silicon integrated circuit as described above. However, it should be noted that it is unlikely that integrated graphics logic and integrated memory control units would exist in the processors910,915.FIG. 9illustrates that the GMCH920may be coupled to a memory940that may be, for example, a dynamic random access memory (DRAM). The DRAM may, for at least one embodiment, be associated with a non-volatile cache.

The GMCH920may be a chipset, or a portion of a chipset. The GMCH920may communicate with the processor(s)910,915and control interaction between the processor(s)910,915and memory940. The GMCH920may also act as an accelerated bus interface between the processor(s)910,915and other elements of the system900. For at least one embodiment, the GMCH920communicates with the processor(s)910,915via a multi-drop bus, such as a frontside bus (FSB)995.

Furthermore, GMCH920is coupled to a display945(such as a flat panel or touchscreen display). GMCH920may include an integrated graphics accelerator. GMCH920is further coupled to an input/output (I/O) controller hub (ICH)950, which may be used to couple various peripheral devices to system900. Shown for example in the embodiment ofFIG. 9is an external graphics device960, which may be a discrete graphics device, coupled to ICH950, along with another peripheral device970.

Alternatively, additional or different processors may also be present in the system900. For example, additional processor(s)915may include additional processors(s) that are the same as processor910, additional processor(s) that are heterogeneous or asymmetric to processor910, accelerators (such as, e.g., graphics accelerators or digital signal processing (DSP) units), field programmable gate arrays, or any other processor. There can be a variety of differences between the processor(s)910,915in terms of a spectrum of metrics of merit including architectural, micro-architectural, thermal, power consumption characteristics, and the like. These differences may effectively manifest themselves as asymmetry and heterogeneity amongst the processors910,915. For at least one embodiment, the various processors910,915may reside in the same die package.

Referring now toFIG. 10, shown is a block diagram of a system1000in which an embodiment of the disclosure may operate.FIG. 10illustrates processors1070,1080. In one embodiment, processors1070,1080may support processor extensions to protect stacks during ring transitions as described above. Processors1070,1080may include integrated memory and I/O control logic (“CL”)1072and1082, respectively and intercommunicate with each other via point-to-point interconnect1050between point-to-point (P-P) interfaces1078and1088respectively. Processors1070,1080each communicate with chipset1090via point-to-point interconnects1052and1054through the respective P-P interfaces1076to1094and1086to1098as shown. For at least one embodiment, the CL1072,1082may include integrated memory controller units. CLs1072,1082may include I/O control logic. As depicted, memories1032,1034coupled to CLs1072,1082and I/O devices1014are also coupled to the control logic1072,1082. Legacy I/O devices1015are coupled to the chipset1090via interface1096.

Embodiments may be implemented in many different system types.FIG. 11is a block diagram of a SoC1100in accordance with an embodiment of the disclosure. Dashed lined boxes are optional features on more advanced SoCs. InFIG. 11, an interconnect unit(s)1112is coupled to: an application processor1120which includes a set of one or more cores1102A-N and shared cache unit(s)1106; a system agent unit1110; a bus controller unit(s)1116; an integrated memory controller unit(s)1114; a set or one or more media processors1118which may include integrated graphics logic1108, an image processor1124for providing still and/or video camera functionality, an audio processor1126for providing hardware audio acceleration, and a video processor1128for providing video encode/decode acceleration; an static random access memory (SRAM) unit1130; a direct memory access (DMA) unit1132; and a display unit1140for coupling to one or more external displays. In one embodiment, a memory module may be included in the integrated memory controller unit(s)1114. In another embodiment, the memory module may be included in one or more other components of the SoC1100that may be used to access and/or control a memory. The application processor1120may include a PMU for implementing silent memory instructions and miss-rate tracking to optimize switching policy on threads as described in embodiments herein.

The memory hierarchy includes one or more levels of cache within the cores, a set or one or more shared cache units1106, and external memory (not shown) coupled to the set of integrated memory controller units1114. The set of shared cache units1106may include one or more mid-level caches, such as level 2 (L2), level 3 (L3), level 4 (L4), or other levels of cache, a last level cache (LLC), and/or combinations thereof.

In some embodiments, one or more of the cores1102A-N are capable of multi-threading. The system agent1110includes those components coordinating and operating cores1102A-N. The system agent unit1110may include for example a power control unit (PCU) and a display unit. The PCU may be or include logic and components needed for regulating the power state of the cores1102A-N and the integrated graphics logic1108. The display unit is for driving one or more externally connected displays.

The cores1102A-N may be homogenous or heterogeneous in terms of architecture and/or instruction set. For example, some of the cores1102A-N may be in order while others are out-of-order. As another example, two or more of the cores1102A-N may be capable of execution the same instruction set, while others may be capable of executing only a subset of that instruction set or a different instruction set.

The application processor1120may be a general-purpose processor, such as a Core™ i3, i5, i7, 2 Duo and Quad, Xeon™, Itanium™, Atom™ or Quark™ processor, which are available from Intel™ Corporation, of Santa Clara, Calif. Alternatively, the application processor1120may be from another company, such as ARM Holdings™, Ltd, MIPS™, etc. The application processor1120may be a special-purpose processor, such as, for example, a network or communication processor, compression engine, graphics processor, co-processor, embedded processor, or the like. The application processor1120may be implemented on one or more chips. The application processor1120may be a part of and/or may be implemented on one or more substrates using any of a number of process technologies, such as, for example, BiCMOS, CMOS, or NMOS.

FIG. 12is a block diagram of an embodiment of a system on-chip (SoC) design in accordance with the disclosure. As a specific illustrative example, SoC1200is included in user equipment (UE). In one embodiment, UE refers to any device to be used by an end-user to communicate, such as a hand-held phone, smartphone, tablet, ultra-thin notebook, notebook with broadband adapter, or any other similar communication device. Often a UE connects to a base station or node, which potentially corresponds in nature to a mobile station (MS) in a GSM network.

Here, SOC1200includes 2 cores—1206and1207. Cores1206and1207may conform to an Instruction Set Architecture, such as an Intel® Architecture Core™-based processor, an Advanced Micro Devices, Inc. (AMD) processor, a MIPS-based processor, an ARM-based processor design, or a customer thereof, as well as their licensees or adopters. Cores1206and1207are coupled to cache control1208that is associated with bus interface unit1209and L2 cache1210to communicate with other parts of system1200. Interconnect1210includes an on-chip interconnect, such as an IOSF, AMBA, or other interconnect discussed above, which potentially implements one or more aspects of the described disclosure. In one embodiment, cores1206,1207may support processor extensions to protect stacks during ring transitions as described in embodiments herein.

Interconnect1210provides communication channels to the other components, such as a Subscriber Identity Module (SIM)1230to interface with a SIM card, a boot ROM1235to hold boot code for execution by cores1206and1207to initialize and boot SoC1200, a SDRAM controller1240to interface with external memory (e.g. DRAM1260), a flash controller1245to interface with non-volatile memory (e.g. Flash1265), a peripheral control1250(e.g. Serial Peripheral Interface) to interface with peripherals, video codecs1220and Video interface1225to display and receive input (e.g. touch enabled input), GPU1215to perform graphics related computations, etc. Any of these interfaces may incorporate aspects of the disclosure described herein. In addition, the system1200illustrates peripherals for communication, such as a Bluetooth module1270, 3G modem1275, GPS1280, and Wi-Fi1185.

The computer system1300includes a processing device1302, a main memory1304(e.g., read-only memory (ROM), flash memory, dynamic random access memory (DRAM) (such as synchronous DRAM (SDRAM) or DRAM (RDRAM), etc.), a static memory1306(e.g., flash memory, static random access memory (SRAM), etc.), and a data storage device1318, which communicate with each other via a bus1330.

Processing device1302represents one or more general-purpose processing devices such as a microprocessor, central processing unit, or the like. More particularly, the processing device may be complex instruction set computing (CISC) microprocessor, reduced instruction set computer (RISC) microprocessor, very long instruction word (VLIW) microprocessor, or processor implementing other instruction sets, or processors implementing a combination of instruction sets. Processing device1302may also be one or more special-purpose processing devices such as an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a digital signal processor (DSP), network processor, or the like. In one embodiment, processing device1302may include one or processing cores. The processing device1302is configured to execute the processing logic1326for performing the operations and steps discussed herein. In one embodiment, processing device1302is the same as processor architecture100described with respect toFIG. 1that implement techniques for processor extensions to protect stacks during ring transitions as described herein with embodiments of the disclosure.

The computer system1300may further include a network interface device1308communicably coupled to a network1320. The computer system1300also may include a video display unit1310(e.g., a liquid crystal display (LCD) or a cathode ray tube (CRT)), an alphanumeric input device1312(e.g., a keyboard), a cursor control device1314(e.g., a mouse), and a signal generation device1316(e.g., a speaker). Furthermore, computer system1300may include a graphics processing unit1322, a video processing unit1328, and an audio processing unit1332.

The data storage device1318may include a machine-accessible storage medium1324on which is stored software1326implementing any one or more of the methodologies of functions described herein, such as implementing silent memory instructions and miss-rate tracking to optimize switching policy on threads in a processing device as described above. The software1326may also reside, completely or at least partially, within the main memory1304as instructions1326and/or within the processing device1302as processing logic1326during execution thereof by the computer system1300; the main memory1304and the processing device1302also constituting machine-accessible storage media.

The following examples pertain to further embodiments.

Example 1 is a processor comprising: 1) a plurality of registers to store shadow stack pointers (SSPs), wherein each register is associated with a privilege level; and 2) a processor core, operatively coupled to the plurality of registers, to: a) receive an indicator to change a first privilege level associated with a currently active application to a second privilege level; b) select, in view of the second privilege level, a shadow stack pointer (SSP) stored in a register of the plurality of registers, wherein the register is associated with the second privilege level; and c) identify, using the SSP, a shadow stack for use by the processor at the second privilege level.

In Example 2, the subject matter of Example 1, wherein the processor core is further to, responsive to detecting that the second privilege level is higher than the first privilege level, validate the SSP associated with the second privilege level.

In Example 3, the subject matter of Examples 1-2, wherein to validate the SSP, the processor core is further to validate the shadow stack identified by the SSP.

In Example 4, the subject matter of Examples 1-3, wherein to validate the shadow stack, the processor core is further to: a) determine whether a memory location associated with the shadow stack is marked as shadow stack memory; b) identify a token associated with the shadow stack; and c) verify that an address pointed to by the SSP matches an address comprised by the token.

In Example 5, the subject matter of Examples 1-4, wherein the processor core is further to, responsive to detecting that the shadow stack is not valid, generate a fault indicator.

In Example 6, the subject matter of Examples 1-5, wherein the processor core is further to, responsive to detecting that the shadow stack is valid: a) mark the token indicating that the shadow stack is busy; and b) store a return address and an SSP associated with the first privilege level in the shadow stack.

In Example 7, the subject matter of Examples 1-6, wherein the processor core is further to, responsive to detecting a return to the first privilege level from the second privilege level, verify that the return address stored in the shadow stack matches a return address stored in a stack associated with the currently active application.

In Example 8, the subject matter of Examples 1-7, wherein the processor core is further to, responsive to verifying the return address: a) restore the SSP associated with the first privilege level as a current SSP for the currently active application; and b) mark the token indicating that the shadow stack is free.

In Example 9, the subject matter of Examples 1-8, wherein the processor core is further to, responsive to detecting that the first privilege level is an application privilege level and the second privilege level is a supervisor privilege level: a) store a current SSP for the currently active application in a register associated with the application privilege level; b) select the SSP associated with the supervisor privilege level as the current SSP; c) determine whether the shadow stack identified by the SSP is to be used at the supervisor privilege level; and d) responsive to the determination, determine whether to verify the shadow stack or mark a token associated with the shadow stack as busy.

Various embodiments may have different combinations of the structural features described above. For instance, all optional features of the processor described above may also be implemented with respect to a method or process described herein and specifics in the examples may be used anywhere in one or more embodiments.

Example 10 is a method, comprising: 1) receiving, using a processing device, an indicator to change a first privilege level of a currently active application to a second privilege level; 2) selecting, in view of the second privilege level, a shadow stack pointer (SSP) stored in a register of a plurality of registers, wherein the register is associated with the second privilege level; and 3) identifying, using the SSP, a shadow stack for use by the processing device at the second privilege level.

In Example 11, the subject matter of Example 10, further comprising responsive to detecting that the second privilege level is higher than the first privilege level, validating the SSP associated with the second privilege level.

In Example 12, the subject matter of Examples 10-11, wherein to validate the SSP further comprises validating the shadow stack identified by the SSP.

In Example 13, the subject matter of Examples 10-12, wherein to validate the shadow stack, further comprises: a) determining whether a memory location associated with the shadow stack is marked as shadow stack memory; b) identifying a token associated with the shadow stack; and c) verifying that an address pointed to by the SSP matches an address comprised by the token.

In Example 14, the subject matter of Examples 10-13, further comprising responsive to detecting that the shadow stack is not valid, generating a fault indicator.

In Example 15, the subject matter of Examples 10-14, further comprising responsive to detecting that the shadow stack is valid: a) marking the token indicating that the shadow stack is busy; and a) storing a return address and an SSP associated with the first privilege level in the shadow stack.

In Example 16, the subject matter of Examples 10-15, further comprising responsive to detecting a return to the first privilege level from the second privilege level, verifying that the return address stored in the shadow stack matches a return address stored in a stack associated with the currently active application.

In Example 17, the subject matter of Examples 10-16, further comprising responsive to verifying the return address: a) restoring the SSP associated with the first privilege level as a current SSP for the currently active application; and b) marking the token indicating that the shadow stack is free.

In Example 18, the subject matter of Examples 10-17, further comprising responsive to detecting that the first privilege level is an application privilege level and the second privilege level is a supervisor privilege level: a) storing a current SSP for the currently active application in a register associated with the application privilege level; b) selecting the SSP associated with the supervisor privilege level as the current SSP; c) determining whether the shadow stack identified by the SSP is to be used at the supervisor privilege level; and d) responsive to the determination, determining whether to verify the shadow stack or mark a token associated with the shadow stack as busy.

Various embodiments may have different combinations of the structural features described above. For instance, all optional features of the processors and methods described above may also be implemented with respect to a system described herein and specifics in the examples may be used anywhere in one or more embodiments.

Example 19 is a system on chip (SoC) comprising: 1) a plurality of registers to store shadow stack pointers (SSPs), wherein each register is associated with a privilege level; and 2) a processor core, operatively coupled to the plurality of registers, to: a) receive an indicator to change a first privilege level associated with a currently active application to a second privilege level; b) select, in view of the second privilege level, a shadow stack pointer (SSP) stored in a register of the plurality of registers, wherein the register is associated with the second privilege level; and c) identify, using the SSP, a shadow stack for use by the processor at the second privilege level.

In Example 20, the subject matter of Example 19, wherein the processor core is further to, responsive to detecting that the second privilege level is higher than the first privilege level, validate the SSP associated with the second privilege level.

In Example 21, the subject matter of Examples 19-20, wherein to validate the SSP, the processor core is further to validate the shadow stack identified by the SSP.

In Example 22, the subject matter of Examples 19-21, wherein to validate the shadow stack, the processor core is further to: a) determine whether a memory location associated with the shadow stack is marked as shadow stack memory; b) identify a token associated with the shadow stack; and c) verify that an address pointed to by the SSP matches an address comprised by the token.

In Example 23, the subject matter of Examples 19-22, wherein the processor core is further to, responsive to detecting that the shadow stack is not valid, generate a fault indicator.

In Example 24, the subject matter of Examples 19-23, wherein the processor core is further to, responsive to detecting that the shadow stack is valid: a) mark the token indicating that the shadow stack is busy; and b) store a return address and an SSP associated with the first privilege level in the shadow stack.

In Example 25, the subject matter of Examples 19-24, wherein the processor core is further to, responsive to detecting a return to the first privilege level from the second privilege level, verify that the return address stored in the shadow stack matches a return address stored in a stack associated with the currently active application.

In Example 26, the subject matter of Examples 19-25, wherein the processor core is further to, responsive to verifying the return address: a) restore the SSP associated with the first privilege level as a current SSP for the currently active application; and b) mark the token indicating that the shadow stack is free.

In Example 27, the subject matter of Examples 19-26, wherein the processor core is further to, responsive to detecting that the first privilege level is an application privilege level and the second privilege level is a supervisor privilege level: a) store, a current SSP for the currently active application in a register associated with the application privilege level; b) select the SSP associated with the supervisor privilege level as the current SSP; c) determine whether the shadow stack identified by the SSP is to be used at the supervisor privilege level; and d) responsive to the determination, determine whether to verify the shadow stack or mark a token associated with the shadow stack as busy.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods described above may also be implemented with respect to a non-transitory, computer-readable storage medium. Specifics in the examples may be used anywhere in one or more embodiments.

Example 28 is a non-transitory computer readable storage medium storing executable instructions, that when executed by a processing device, cause the processing device to: 1) receive, using the processing device, an indicator to change a first privilege level associated with a currently active application to a second privilege level; 2) select, in view of the second privilege level, a shadow stack pointer (SSP) stored in a register of a plurality of registers, wherein the register is associated with the second privilege level; and 3) identify, using the SSP, a shadow stack for use by the processor at the second privilege level.

In Example 29, the subject matter of Example 28, wherein the executable instructions further cause processor device to, responsive to detecting that the second privilege level is higher than the first privilege level, validate the SSP associated with the second privilege level.

In Example 30, the subject matter of Examples 28-29, wherein to validate the SSP, the executable instructions further cause processor device to validate the shadow stack identified by the SSP.

In Example 31, the subject matter of Examples 28-30, wherein to validate the shadow stack, the executable instructions further cause processor device to: a) determine whether a memory location associated with the shadow stack is marked as shadow stack memory; b) identify a token associated with the shadow stack; and c) verify that an address pointed to by the SSP matches an address comprised by the token.

In Example 32, the subject matter of Examples 28-31, wherein the executable instructions further cause processor device to, responsive to detecting that the shadow stack is not valid, generate a fault indicator.

In Example 33, the subject matter of Examples 28-32, wherein the executable instructions further cause processor device to, responsive to detecting that the shadow stack is valid: a) mark the token indicating that the shadow stack is busy; and b) store a return address and an SSP associated with the first privilege level in the shadow stack.

In Example 34, the subject matter of Examples 28-33, wherein the executable instructions further cause processor device to, responsive to detecting a return to the first privilege level from the second privilege level, verify that the return address stored in the shadow stack matches a return address stored in a stack associated with the currently active application.

In Example 35, the subject matter of Examples 28-34, wherein the executable instructions further cause processor device to, responsive to verifying the return address: a) restore the SSP associated with the first privilege level as a current SSP for the currently active application; and b) mark the token indicating that the shadow stack is free.

In Example 36, the subject matter of Examples 28-35, wherein the executable instructions further cause processor device to, responsive to detecting that the first privilege level is an application privilege level and the second privilege level is a supervisor privilege level: a) store a current SSP for the currently active application in a register associated with the application privilege level; b) select the SSP associated with the supervisor privilege level as the current SSP; c) determine whether the shadow stack identified by the SSP is to be used at the supervisor privilege level; and d) responsive to the determination, determine whether to verify the shadow stack or mark a token associated with the shadow stack as busy.

Example 37 is a non-transitory, computer-readable storage medium including instructions that, when executed by a processor, cause the processor to perform the method of Examples 10-18.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods, systems and non-transitory, computer-readable storage mediums described above may also be implemented with respect to other type of structures. Specifics in the examples may be used anywhere in one or more embodiments.

Example 38 is an apparatus comprising: 1) a plurality of functional units of a processor; 2) means for receiving, by the processor, an indicator to change a first privilege level associated with a currently active application to a second privilege level; 3) means for selecting, in view of the second privilege level, a shadow stack pointer (SSP) stored in a register of a plurality of registers, wherein the register is associated with the second privilege level; and 4) means for identifying, using the SSP, a shadow stack for use by the processor at the second privilege level.

In Example 39, the subject matter of Example 38, further comprising the subject matter of any of Examples 1-9 and 19-27.

Example 40 is a system comprising: a memory device and a processor comprising a memory controller unit, wherein the processor is configured to perform the method of any of claims 10-18.

In Example 41, the subject matter of Example 40, further comprising the subject matter of any of Examples 1-9 and 19-27.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods described above may be implemented with respect to a processor. Specifics in the examples may be used anywhere in one or more embodiments.

Example 42 is a processor comprising: 1) a plurality of registers to store shadow stack pointers (SSPs), wherein each register is associated with a privilege level; and 2) a processor core, operatively coupled to the plurality of registers, to: a) detect an interrupt associated with a currently active application; b) select, in view of the interrupt, a shadow stack pointer (SSP) stored in a register of the plurality of registers, the SSP is associated with a privilege level for the interrupt; and c) store, in a memory data structure indexed by a field in an interrupt gate descriptor, the SSP identifying a shadow stack for use by the processor at the privilege level.

Various embodiments may have different combinations of the structural features described above. For instance, all optional features of the processor described above may also be implemented with respect to a method or process described herein and specifics in the examples may be used anywhere in one or more embodiments.

Example 43 is a method comprising: 1) detecting, using a processing device, an interrupt associated with a currently active application; 2) selecting, in view of the interrupt, a shadow stack pointer (SSP) stored in a register of the plurality of registers, the SSP is associated with a privilege level for the interrupt; and 3) storing, in a memory data structure indexed by a field in an interrupt gate descriptor, the SSP identifying a shadow stack for use by the processing device at the privilege level.

Various embodiments may have different combinations of the structural features described above. For instance, all optional features of the processors and methods described above may also be implemented with respect to a system described herein and specifics in the examples may be used anywhere in one or more embodiments.

Example 44 is a system on chip (SoC) comprising: 1) a plurality of registers to store shadow stack pointers (SSPs), wherein each register is associated with a privilege level; and 2) a processor core, operatively coupled to the plurality of registers, to: a) detect an interrupt associated with a currently active application; b) select, in view of the interrupt, a shadow stack pointer (SSP) stored in a register of the plurality of registers, the SSP is associated with a privilege level for the interrupt; and c) store, in a memory data structure indexed by a field in an interrupt gate descriptor, the SSP identifying a shadow stack for use by the processor at the privilege level.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods described above may also be implemented with respect to a non-transitory, computer-readable storage medium. Specifics in the examples may be used anywhere in one or more embodiments.

Example 45 is a non-transitory computer readable storage medium storing executable instructions, that when executed by a processing device, cause the processing device to: 1) detect, using the processing device, an interrupt associated with a currently active application; 2) select, in view of the interrupt, a shadow stack pointer (SSP) stored in a register of the plurality of registers, the SSP is associated with a privilege level for the interrupt; and 3) store, in a memory data structure indexed by a field in an interrupt gate descriptor, the SSP identifying a shadow stack for use by the processing device at the privilege level.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods, systems and non-transitory, computer-readable storage mediums described above may also be implemented with respect to other type of structures. Specifics in the examples may be used anywhere in one or more embodiments.

Example 46 is an apparatus comprising: 1) a plurality of functional units of a processor; 2) means for detecting, by the processor, an interrupt associated with a currently active application; 3) means for selecting, in view of the interrupt, a shadow stack pointer (SSP) stored in a register of the plurality of registers, the SSP is associated with a privilege level for the interrupt; and 4) means for storing, in a memory data structure indexed by a field in an interrupt gate descriptor, the SSP identifying a shadow stack for use by the processing device at the privilege level.

In Example 47, the subject matter of Example 46, further comprising the subject matter of any of Examples 42 and 44.

Example 48 is a system comprising: a memory device and a processor comprising a memory controller unit, wherein the processor is configured to perform the method of Example 43.

In Example 49, the subject matter of Example 48, further comprising the subject matter of any of Examples 42 and 44.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods described above may be implemented with respect to a processor. Specifics in the examples may be used anywhere in one or more embodiments.

Example 50 is a processor comprising: 1) a memory having a data structure to store shadow stack pointers (SSPs); and 2) a processor core, operatively coupled to the memory, to: a) detect a task switch operation to switch a current task associated with a currently active application a new task; b) identify, in view of the task switch operation, a data structure associated with the new task; and c) select an SSP from the data structure, the SSP identifying a shadow stack for use by the processing device at a privilege level associated with the new task.

Various embodiments may have different combinations of the structural features described above. For instance, all optional features of the processor described above may also be implemented with respect to a method or process described herein and specifics in the examples may be used anywhere in one or more embodiments.

Example 51 is a method comprising: 1) detecting, by the processing device, a task switch operation to switch a current task associated with a currently active application a new task; 2) identifying, in view of the task switch operation, a data structure associated with the new task; 3) selecting an SSP from the data structure, the SSP identifying a shadow stack for use by the processing device at a privilege level associated with the new task; and storing the SSP in a register of the plurality of registers associated with the privilege level.

Various embodiments may have different combinations of the structural features described above. For instance, all optional features of the processors and methods described above may also be implemented with respect to a system described herein and specifics in the examples may be used anywhere in one or more embodiments.

Example 52 is a system on chip (SoC) comprising: 1) a memory having a data structure to store shadow stack pointers (SSPs); and 2) a processor core, operatively coupled to the memory, to: a) detect a task switch operation to switch a current task associated with a currently active application a new task; b) identify, in view of the task switch operation, a data structure associated with the new task; and c) select an SSP from the data structure, the SSP identifying a shadow stack for use by the processing device at a privilege level associated with the new task.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods described above may also be implemented with respect to a non-transitory, computer-readable storage medium. Specifics in the examples may be used anywhere in one or more embodiments.

Example 53 is a non-transitory computer readable storage medium storing executable instructions, that when executed by a processing device, cause the processing device to: 1) detect, by the processing device, a task switch operation to switch a current task associated with a currently active application a new task; 2) identify, in view of the task switch operation, a data structure associated with the new task; and 3) select an SSP from the data structure, the SSP identifying a shadow stack for use by the processing device at a privilege level associated with the new task.

Various embodiments may have different combinations of the operational features described above. For instance, all optional features of the methods, systems and non-transitory, computer-readable storage mediums described above may also be implemented with respect to other type of structures. Specifics in the examples may be used anywhere in one or more embodiments.

Example 54 is an apparatus comprising: 1) a plurality of functional units of a processor; 2) means for detecting, by the processor, a task switch operation to switch a current task associated with a currently active application a new task; and 3) means for identifying, in view of the task switch operation, a data structure associated with the new task; 4) means for selecting an SSP from the data structure, the SSP identifying a shadow stack for use by the processing device at a privilege level associated with the new task.

In Example 55, the subject matter of Example 54, further comprising the subject matter of any of Examples 50 and 52.

Example 56 is a system comprising: a memory device and a processor comprising a memory controller unit, wherein the processor is configured to perform the method of Example 51.

In Example 57, the subject matter of Example 56, further comprising the subject matter of any of Examples 50 and 52.