# US 10,956,157 B1 · Taint protection during speculative execution

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

- Number: US 10,956,157 B1
- Document ID: US10956157B1
- Status: Granted
- Kind: B1
- Application number: 16/293,154
- Filed: 2019-03-05
- Granted: 2021-03-23
- Earliest claimed: 2018-03-06
- Assignees: Advanced Micro Devices, Inc.
- Applicants: Advanced Micro Devices, Inc.
- Inventors: David Kaplan; Marius Evers
- Web page: https://patentgrep.com/patent/US10956157B1

## CPC

- G06F 9/30105: {Register structure}
- G06F 9/3838: {Dependency mechanisms, e.g. register scoreboarding}
- G06F 9/30043: {LOAD or STORE instructions; Clear instruction}
- G06F 9/30076: {to perform miscellaneous control operations, e.g. NOP}
- G06F 9/30098: {Register arrangements}
- G06F 9/3834: {Maintaining memory consistency}
- G06F 9/3842: {Speculative instruction execution}
- G06F 9/3861: {Recovery, e.g. branch miss-prediction, exception handling (error detection or correction G06F11/00)}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A subset of a set of architectural registers in a processing system is marked (or “tainted”) to indicate that speculative use of data in the subset of the architectural registers is constrained based on a taint handling policy. One or more speculation features supported by the processing system are disabled for the instruction so that the one or more speculation features cannot be used on data in the subset. In some cases, values of bits associated with the subset of architectural registers are modified to indicate that the subset is tainted. The taint handling policy can be indicated by values stored in a policy register. Taint markings are tracked in response to values stored in the tainted architectural registers being written to a memory or read from the memory.

## Claims

### Claim 1

A method comprising:
marking a subset of a set of architectural registers in a processing system to indicate that speculative use of data in the subset of the set of architectural registers is constrained based on a taint handling policy; and
preventing use of at least one speculation feature on data in the subset.

### Claim 2 (depends on 1)

The method of claim 1, wherein marking the subset comprises modifying values of bits associated with the subset to indicate that the subset is tainted.

### Claim 3 (depends on 2)

The method of claim 2, wherein:
each architectural register of the set of architectural registers is associated with a corresponding bit of a plurality of bits; and
modifying the values of the bits associated with the subset comprises modifying values of the plurality of bits for each architectural register in the subset.

### Claim 4 (depends on 2)

The method of claim 2, wherein marking the subset comprises executing an instruction that explicitly marks the subset as tainted or untainted by instructing a processor to modify the values of the bits associated with the subset.

### Claim 5 (depends on 2)

The method of claim 2, wherein marking the subset comprises modifying the values of the bits associated with the subset in response to data in the subset crossing a hardware privilege boundary.

### Claim 6 (depends on 2)

The method of claim 2, wherein marking the subset comprises modifying the values of the bits associated with architectural registers controlled by a user in response to a control flow crossing a hardware privilege boundary.

### Claim 7 (depends on 2)

The method of claim 2, further comprising:
reading the values of the bits to determine which of the set of the architectural registers are tainted.

### Claim 8 (depends on 2)

The method of claim 2, further comprising:
writing at least one of the values of the bits to a location in a memory using a write instruction that indicates the location in the memory.

### Claim 9 (depends on 1)

The method of claim 1, wherein preventing use of the at least one speculation feature comprises disabling the at least one speculation feature to prevent a pipeline in the processing system from utilizing data loaded from the subset until a load instruction used to load the data from the subset has retired.

### Claim 10 (depends on 1)

The method of claim 1, further comprising:
accessing a policy register that stores values that indicate policies applied to tainted architectural registers; and
wherein preventing use of the at least one speculation feature comprises disabling the at least one speculation feature based on a policy indicated by a value stored in the policy register.

### Claim 11 (depends on 10)

The method of claim 10, wherein the policy register is subdivided into default policies that are implemented unless specifically disabled and optional policies that are not implemented unless specifically enabled.

### Claim 12 (depends on 1)

The method of claim 1, wherein the subset comprises at least one source register for an instruction; and the method further comprising:
propagating tainting from the at least one source register to a destination register of the instruction.

### Claim 13 (depends on 12)

The method of claim 12, wherein propagating the tainting from the at least one source register to the destination register comprises modifying at least one value of at least one bit associated with the destination register to indicate that the destination register is tainted.

### Claim 14 (depends on 1)

The method of claim 1, further comprising:
tracking taint markings of the subset in response to storing data from the subset in a memory.

### Claim 15 (depends on 14)

The method of claim 14, wherein tracking the taint markings of the subset comprises storing a portion of the data in the memory and storing at least one bit in the memory, the at least one bit having a value that indicates that the portion is tainted.

### Claim 16 (depends on 14)

The method of claim 14, wherein tracking the taint markings of the subset comprises storing the data in a predetermined region of the memory that is allocated for storing tainted data.

### Claim 17 (depends on 14)

The method of claim 14, wherein tracking the taint markings comprises obfuscating the data prior to storing the obfuscated data in the memory.

### Claim 18 (depends on 17)

The method of claim 17, further comprising:
configuring read instructions or write instructions that involve the subset to specify that the data in the subset is tainted;
obfuscating, at the processing system, the data prior to storing the data in the memory in response to a write instruction; and
de-obfuscating the data at the processing system after reading the data from the memory and prior to storing the data in the subset.

### Claim 19

An apparatus comprising:
processing circuitry configured to:
mark a subset of a set of architectural registers to indicate that speculative use of data in the subset is constrained based on a taint handling policy; and
prevent use of at least one speculation feature on data in the subset.

### Claim 20 (depends on 19)

The apparatus of claim 19, further comprising:
a physical register file including physical registers that are associated with architectural registers; and
a data structure including bits associated with the architectural registers, wherein the processing circuitry is configured to modify values of the bits associated with the subset to indicate that the subset is tainted.

### Claim 21 (depends on 20)

The apparatus of claim 20, wherein:
the data structure comprises a plurality of bits associated with each of the architectural registers;
each architectural register of the set is associated with a corresponding bit of a plurality of bits; and
the processing circuitry is configured to modify values of the plurality of bits for each architectural register in the subset.

### Claim 22 (depends on 20)

The apparatus of claim 20, wherein the processing circuitry is configured to modify the values of the bits associated with the subset by executing an instruction that explicitly marks the subset as tainted.

### Claim 23 (depends on 20)

The apparatus of claim 20, wherein the processing circuitry is configured to taint or untaint the subset by modifying the values of the bits associated with the subset in response to data in the subset crossing a hardware privilege boundary.

### Claim 24 (depends on 20)

The apparatus of claim 20, wherein the processing circuitry is configured to taint the subset by modifying the values of the bits associated with architectural registers controlled by a user in response to a control flow crossing a hardware privilege boundary.

### Claim 25 (depends on 20)

The apparatus of claim 20, wherein the processing circuitry is configured to read the values of the bits to determine which of the architectural registers are tainted.

### Claim 26 (depends on 20)

The apparatus of claim 20, wherein the processing circuitry is configured to write at least one of the values of the bits to a location in a memory using a write instruction that indicates the location in the memory.

### Claim 27 (depends on 19)

The apparatus of claim 19, wherein:
the processing circuitry implements a pipeline for executing instructions; and
the processing circuitry is configured to prevent the pipeline from utilizing data loaded from the subset until a load instruction used to load the data from the subset has retired.

### Claim 28 (depends on 19)

The apparatus of claim 19, further comprising:
a policy register configured to store values that indicate policies applied to marked architectural registers, and wherein the processing circuitry is configured to prevent use of the at least one speculation feature by disabling the at least one speculation feature based on a policy indicated by a value stored in the policy register.

### Claim 29 (depends on 28)

The apparatus of claim 28, wherein the policy register is subdivided into default policies that are implemented unless specifically disabled by the processing circuitry and optional policies that are not implemented unless specifically enabled by the processing circuitry.

### Claim 30 (depends on 19)

The apparatus of claim 19, wherein:
the subset comprises a source register for an instruction; and
the processing circuitry is configured to propagate marking from the source register to a destination register of the instruction.

### Claim 31 (depends on 30)

The apparatus of claim 30, wherein the processing circuitry is configured to propagate the marking by modifying at least one value of at least one bit associated with the destination register to indicate that the destination register is tainted.

### Claim 32 (depends on 19)

The apparatus of claim 19, wherein the processing circuitry is configured to track taint markings of the subset of the architectural registers in response to storing data from the subset in a memory.

### Claim 33 (depends on 32)

The apparatus of claim 32, wherein the processing circuitry is configured to:
store a portion of the data in the memory; and
store at least one bit in the memory, the at least one bit having a value that indicates that the portion is tainted.

### Claim 34 (depends on 32)

The apparatus of claim 32, wherein the processing circuitry is configured to store the data in a predetermined region of the memory that is allocated for storing tainted data.

### Claim 35 (depends on 32)

The apparatus of claim 32, wherein the processing circuitry is configured to obfuscate the data prior to storing the obfuscated data in the memory.

### Claim 36 (depends on 35)

The apparatus of claim 35, wherein:
read instructions or write instructions that involve the subset of the architectural registers specify that the data in the subset is tainted;
the processing circuitry obfuscates the data prior to storing the data in the memory in response to a write instruction; and
the processing circuitry is configured to de-obfuscate the data after reading the data from the memory and prior to storing the data in the subset of the architectural registers.

### Claim 37

An apparatus comprising:
processing circuitry configured to:
speculatively execute an instruction that operates on values stored in architectural registers; and
disable at least one speculation feature for the instruction in response to at least one of the architectural registers being tainted to indicate that speculative use of data in the at least one of the architectural registers is constrained based on a taint handling policy.

### Claim 38 (depends on 37)

The apparatus of claim 37, further comprising:
a physical register file including physical registers that are associated with corresponding architectural registers; and
a data structure including bits associated with the architectural registers, wherein the processing circuitry is configured to modify values of a subset of the bits to indicate that a corresponding subset of the architectural registers as tainted.

### Claim 39 (depends on 37)

The apparatus of claim 37, further comprising:
a policy register configured to store values that indicate policies applied to the at least one of the architectural registers that is constrained based on the taint handling policy, and wherein the processing circuitry is configured to disable the at least one speculation feature based on the taint handling policy indicated by a value stored in the policy register.

### Claim 40 (depends on 37)

The apparatus of claim 37, wherein the processing circuitry is configured to track taint markings of the at least one of the architectural registers that is constrained based on the taint handling policy in response to storing data from the at least one of the architectural registers in a memory.
