# US 2022/0283813 A1 · Flexible return and event delivery

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2022/0283813 A1
- Document ID: US20220283813A1
- Status: Published application
- Kind: A1
- Application number: 17/359,534
- Filed: 2021-06-26
- Published: 2022-09-08
- Earliest claimed: 2021-03-02
- Assignees: Intel Corporation
- Applicants: Intel Corporation
- Inventors: Gilbert Neiger; H. Peter Anvin; Vedvyas Shanbhogue; Deepak Gupta
- Web page: https://patentgrep.com/patent/US20220283813A1

## CPC

- G06F 9/30076: {to perform miscellaneous control operations, e.g. NOP}
- G06F 9/30145: {Instruction analysis, e.g. decoding, instruction word fields}
- G06F 9/30043: {LOAD or STORE instructions; Clear instruction}
- G06F 9/30054: {Unconditional branch instructions}
- G06F 9/30098: {Register arrangements}
- G06F 9/323: {for indirect branch instructions}
- G06F 9/4812: {by interrupt, e.g. masked}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Techniques for flexible return and event delivery are described. As an example, an exemplary apparatus includes decoder circuitry to decode a single instruction, the single instruction to include a field for an opcode; and execution circuitry to execute the decoded single instruction according to the opcode to cause a return from an event handler while staying in a most privileged level and establish a return context that was in effect before event delivery.

## Claims

### Claim 1

An apparatus comprising:
decoder circuitry to decode a single instruction, the single instruction to include a field for an opcode; and
execution circuitry to execute the decoded single instruction according to the opcode to cause a return from an event handler while staying in a most privileged level and establish a return context that was in effect before event delivery.

### Claim 2 (depends on 1)

The apparatus of claim 1, wherein the execution of the decoded instruction is to not modify segment registers.

### Claim 3 (depends on 1)

The apparatus of claim 1, wherein the opcode is F2 0F 01 CA.

### Claim 4 (depends on 1)

The apparatus of claim 1, wherein the most privileged level is ring 0.

### Claim 5 (depends on 1)

The apparatus of claim 1, wherein to execute the decode instruction the execution circuitry is to load and check the return context from a stack.

### Claim 6 (depends on 5)

The apparatus of claim 5, wherein the execution circuitry is to check a shadow stack to confirm validity of the return.

### Claim 7 (depends on 5)

The apparatus of claim 5, wherein the execution circuitry is to establish the return context by, at least in part, loading one or more registers.

### Claim 8

A method comprising:
decoding a single instruction, the single instruction to include a field for an opcode; and
executing the decoded instruction according to the opcode to cause a return from an event handler while staying in a most privileged level and establish a return context that was in effect before event delivery.

### Claim 9 (depends on 8)

The method of claim 8, wherein executing the decoded instruction further comprises not modifying segment registers.

### Claim 10 (depends on 8)

The method of claim 8, wherein the opcode is F2 0F 01 CA.

### Claim 11 (depends on 8)

The method of claim 8, wherein the most privileged level is ring 0.

### Claim 12 (depends on 8)

The method of claim 8, wherein the executing further comprises loading and checking the return context from a stack.

### Claim 13 (depends on 12)

The method of claim 12, wherein the executing is to check a shadow stack to confirm validity of the return.

### Claim 14 (depends on 12)

The method of claim 12, wherein the executing is to establish the return context by, at least in part, loading one or more registers.

### Claim 15

A method comprising:
translating a single instruction from a first instruction set architecture into one or more instructions of a second instruction set architecture, the single instruction having a field for an opcode, the opcode indicating that execution circuitry is to cause a return from an event handler while staying in a most privileged level and establish a return context that was in effect before event delivery;
decoding the one or more instructions of the second instruction set architecture; and
executing the decoded one or more instructions of the second instruction set architecture to cause a return from an event handler while staying in a most privileged level and establish a return context that was in effect before event delivery.

### Claim 16 (depends on 15)

The method of claim 15, wherein the opcode is F2 0F 01 CA.

### Claim 17 (depends on 15)

The method of claim 15, wherein the most privileged level is ring 0.

### Claim 18

A system comprising:
a processor core including:
decoder circuitry to decode a single instruction, the single instruction to include a field for an opcode, and
execution circuitry to execute the decoded single instruction according to the opcode to cause a return from an event handler while staying in a most privileged level and establish a return context that was in effect before event delivery; and
memory coupled to the processor core to store the single instruction.

### Claim 19 (depends on 18)

The system of claim 18, wherein the opcode is F2 0F 01 CA.

### Claim 20 (depends on 18)

The system of claim 18, wherein the execution circuitry is to establish the return context by, at least in part, loading one or more registers.

### Claim 21

An apparatus comprising:
decoder circuitry to decode a single instruction, the single instruction to include a field for an opcode; and
execution circuitry to execute the decoded instruction according to the opcode to cause a return from an event handler while transitioning to a least privileged ring and establishing the return context that was in effect before event delivery.

### Claim 22 (depends on 21)

The apparatus of claim 21, wherein the execution of the decoded instruction is to modify segment registers.

### Claim 23 (depends on 21)

The apparatus of claim 21, wherein the opcode is F3 0F 01 CA.

### Claim 24 (depends on 21)

The apparatus of claim 21, wherein the least privileged level is ring 3.

### Claim 25 (depends on 21)

The apparatus of claim 21, wherein to execute the decode instruction the execution circuitry is to load and check the return context from a stack.

### Claim 26 (depends on 25)

The apparatus of claim 25, wherein the execution circuitry is to check a shadow stack to confirm validity of the return.

### Claim 27 (depends on 25)

The apparatus of claim 25, wherein the execution circuitry is to establish the return context by, at least in part, loading one or more registers.

### Claim 28

A method comprising:
decoding a single instruction, the single instruction to include a field for an opcode; and
executing the decoded instruction according to the opcode to cause a return from an event handler while transitioning to a least privileged ring and establishing the return context that was in effect before event delivery.

### Claim 29 (depends on 28)

The method of claim 28, wherein executing the decoded instruction further comprises modifying segment registers.

### Claim 30 (depends on 28)

The method of claim 28, wherein the opcode is F3 0F 01 CA.

### Claim 31 (depends on 28)

The method of claim 28, wherein the least privileged level is ring 3.

### Claim 32 (depends on 28)

The method of claim 28, wherein the executing further comprises loading and checking the return context from a stack.

### Claim 33 (depends on 32)

The method of claim 32, wherein the executing is to check a shadow stack to confirm validity of the return.

### Claim 34 (depends on 32)

The method of claim 32, wherein the executing is to establish the return context by, at least in part, loading one or more registers.

### Claim 35

A method comprising:
translating a single instruction from a first instruction set architecture into one or more instructions of a second instruction set architecture, the single instruction having a field for an opcode, the opcode indicating that execution circuitry is to cause a return from an event handler while transitioning to a least privileged level and establish a return context that was in effect before event delivery;
decoding the one or more instructions of the second instruction set architecture; and
executing the decoded one or more instructions of the second instruction set architecture to cause a return from an event handler while transitioning to a least privileged level and establish a return context that was in effect before event delivery.

### Claim 36 (depends on 35)

The method of claim 35, wherein the opcode is F3 0F 01 CA.

### Claim 37 (depends on 35)

The method of claim 35, wherein the least privileged level is ring 3.

### Claim 38

A system comprising:
a processor core including:
decoder circuitry to decode a single instruction, the single instruction to include a field for an opcode, and
execution circuitry to execute the decoded instruction according to the opcode to cause a return from an event handler while transitioning to a least privileged ring and establishing the return context that was in effect before event delivery; and
memory coupled to the processor core to store the single instruction.

### Claim 39 (depends on 38)

The system of claim 38, wherein the opcode is F3 0F 01 CA.

### Claim 40 (depends on 38)

The system of claim 38, wherein the execution circuitry is to establish the return context by, at least in part, loading one or more registers.

### Claim 41

An apparatus comprising:
event delivery circuitry to perform one or more operations upon an event delivery of an exception or interrupt to an event handler, wherein the one or more operations include an establishment of a new context of an event handler in a first privilege level; and
one or more model specific registers (MSRs) to be utilized by the event delivery circuitry to perform the one or more operations including one or more of:
a configuration MSR wherein a first proper subset of bits of the configuration register identify a stack level to use for markable interrupts that are delivered while current privilege level has a first state, a second proper subset of bits of the configuration register indicate the current privilege level state, a third proper subset of bits of the configuration register identify an amount of cachelines by which event delivery decrements a stack pointer when not changing stacks, and a fourth proper subset of bits of the configuration register contain the upper bits of the linear address of a page in memory containing event handlers;
a plurality of regular stack pointer MSRs;
a stack levels (STKLVLS) MSR; and
a plurality of shadow stack pointer MSRs.

### Claim 42 (depends on 41)

The apparatus of claim 41, wherein the execution circuitry is to perform event delivery to:
determine a state of the new context;
save information about the event and an original context; and
load state of the new context.

### Claim 43 (depends on 41)

The apparatus of claim 41, wherein to determine a state of the new context comprises to determine a new instruction pointer, a new flags register value, and values for a stack level, stack pointer, and a shadow stack pointer.

### Claim 44 (depends on 41)

The apparatus of claim 41, wherein to save information about the event and an original context comprises to save information on a regular stack and to save information on a shadow stack.

### Claim 45 (depends on 41)

The apparatus of claim 41, wherein the execution circuitry is to further confirm that the event delivery is supported by performing event delivery by determining that a bit in a control register is set to indicate support for flexible return and event delivery.

### Claim 46 (depends on 41)

The apparatus of claim 41, further comprising:
memory to store the event handler.
