# US 2023/0418767 A1 · PC-Based Memory Permissions

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

- Number: US 2023/0418767 A1
- Document ID: US20230418767A1
- Status: Published application
- Kind: A1
- Application number: 18/343,125
- Filed: 2023-06-28
- Published: 2023-12-28
- Earliest claimed: 2022-06-28
- Assignees: Apple Inc.
- Applicants: Apple Inc.
- Inventors: Jeffry E. Gonion; Bernard J. Semeria
- Web page: https://patentgrep.com/patent/US20230418767A1

## CPC

- G06F 12/1483: {using an access-table, e.g. matrix or list}
- G06F 9/30076: {to perform miscellaneous control operations, e.g. NOP}
- G06F 9/30189: {according to execution mode, e.g. mode flag}
- G06F 12/1027: using associative or pseudo-associative address translation means, e.g. translation look-aside buffer [TLB]
- G06F 12/145: {the protection being virtual, e.g. for virtual blocks or segments before a translation mechanism}
- G06F 12/1475: {in a virtual system, e.g. with translation means}
- G06F 12/1491: {in a hierarchical protection system, e.g. privilege levels, memory rings}
- G06F 21/52: during program execution, e.g. stack integrity {; Preventing unwanted data erasure; Buffer overflow}
- G06F 2221/034: Test or assess a computer or a system
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A memory permissions model for a processor that is based on the memory address accessed by an instruction as well as the program counter of the instruction. These permissions may be stored in permissions tables and indexed using the memory addresses of the instruction and the address of the memory locations that it accesses. Those indexes may be obtained from a page table in some cases. These memory permissions may be used in conjunction with other permissions, such as execute permissions and secondary execution privileges that are based on whether the instruction belongs to a particular instruction group.

## Claims

### Claim 1

An apparatus, comprising:
a processor that includes:
a permission table circuit configured to store a plurality of permissions for accesses to memory, wherein the permission table circuit is indexed by a particular permission table index corresponding to a particular instruction to provide a particular permission for a particular memory access by the particular instruction; and
a control circuit coupled to the permission table circuit and configured to generate the particular permission table index based on:
a first value corresponding to a first memory address indicated by the particular instruction; and
a second value corresponding to a second memory address at which the particular instruction is stored.

### Claim 2 (depends on 1)

The apparatus of claim 1, further comprising a translation lookaside buffer circuit (TLB) coupled to the control circuit, wherein the TLB is configured to store one or more of the first value and the second value.

### Claim 3 (depends on 1)

The apparatus of claim 1, wherein the first value is stored in a page table in association with a first physical page number to which the first memory address translates, and wherein the second value is stored in the page table in association with a second physical page number to which the second memory address translates.

### Claim 4 (depends on 1)

The apparatus of claim 1, wherein the control circuit is configured to generate the particular permission table index by concatenating the first value and the second value.

### Claim 5 (depends on 4)

The apparatus of claim 4, wherein the particular permission table index is a secondary index, and wherein the control circuit is configured to access a particular set of permissions from the permission table circuit using the secondary index, wherein the particular set of permissions is a permission mask;
wherein the control circuit is configured to generate a primary index for the particular instruction based on a third value corresponding to the first memory address; and
wherein the control circuit is configured to use the primary index to retrieve a base set of memory permissions from the permission table circuit and to use the secondary index to retrieve the permission mask from the permission table circuit; and
wherein the control circuit is configured to combine the base set of memory permissions and the permission mask to obtain a final set of memory permissions for the particular instruction.

### Claim 6 (depends on 1)

The apparatus of claim 1, wherein the particular instruction is a control flow instruction, wherein the first memory address is a target of the control flow instruction.

### Claim 7 (depends on 6)

The apparatus of claim 6, wherein the control circuit, in response to the target of the control flow instruction being a load-store instruction, is configured to generate a different permission table index for the target of the control flow instruction based on:
a third value corresponding to a third memory address accessed by the target of the control flow instruction; and
a fourth value corresponding to a fourth memory address at which the target of the control flow instruction is stored.

### Claim 8 (depends on 1)

The apparatus of claim 1, further comprising:
a secondary execution privileges table circuit configured to store a plurality of secondary execution privilege values, wherein:
the secondary execution privileges table circuit is indexed by a particular secondary execution privileges index corresponding to the particular instruction to provide a particular secondary execution privileges value for the particular instruction;
the particular secondary execution privileges value defines a permissible set of a plurality of instruction groups that are executable from the second memory address; and
the control circuit is configured to selectively permit the processor to execute the particular instruction when the particular instruction is in the permissible set of the plurality of instruction groups defined by the particular secondary execution privileges value.

### Claim 9 (depends on 8)

The apparatus of claim 8, wherein the particular secondary execution privileges index is associated with a particular page table entry to which the second memory address is mapped; and
wherein the control circuit is further configured to selectively permit the processor to execute the particular instruction based on a primary execution privilege associated with the particular page table entry.

### Claim 10 (depends on 1)

The apparatus of claim 1, wherein the permission table circuit is configured to store a plurality of permission tables that specify different permissions for the particular instruction;
wherein the control circuit is configured to obtain permissions for the particular instruction by:
selecting, based on an execution mode of the processor, one of the plurality of permission tables; and
retrieving permissions for the particular instruction from the selected permission table using the particular permission table index.

### Claim 11

A method, comprising:
receiving, in a processor of a computer system, a particular instruction to be executed by an execution pipeline circuit of the processor, the particular instruction including a reference to a first memory address and being located at a second memory address;
storing, by the processor in a permission table, a plurality of permissions for accesses to memory of the computer system, wherein the permission table is indexed by a permission table index; and
generating, by the processor, a particular permission table index for the particular instruction based on:
a first value corresponding to the first memory address; and
a second value corresponding to the second memory address;
retrieving, by the processor from the permission table using the particular permission table index, a particular permission of the plurality of permissions for the particular instruction; and
enforcing, by the processor during execution of the particular instruction, a final memory permission that is based on the particular permission.

### Claim 12 (depends on 11)

The method of claim 11, wherein the particular permission is a permission mask, the method further comprising:
determining a base memory permission from a permission table lookup that is based on a third value corresponding to the first memory address; and
generating the final memory permission from the base memory permission and the particular permission.

### Claim 13 (depends on 11)

The method of claim 11, further comprising:
determining an execute permission for the particular instruction from a permission table lookup that is based on a fourth value corresponding to the second memory address.

### Claim 14 (depends on 11)

The method of claim 11, further comprising:
determining secondary execution privileges for the particular instruction from a permission table lookup that is based on a fifth value corresponding to the second memory address, the secondary execution privileges defining which of a plurality of permission groups are permitted to execute from the second memory address.

### Claim 15 (depends on 11)

The method of claim 11, further comprising:
selecting the permission table from a set of permission tables based on a current execution mode of the processor.

### Claim 16 (depends on 11)

The method for claim 11, wherein the permission table defines two or more different memory permissions for accessing a particular memory location from different code locations.

### Claim 17

An apparatus, comprising:
a processor configured to execute computer program instructions, the processor including:
a permission table circuit configured to store, in a set of permission tables, a plurality of permissions for accesses to a memory, wherein the set of permission tables are indexed by a permission table index;
an execution pipeline circuit configured to receive a particular instruction for execution, the particular instruction specifying a first memory address to be accessed by the particular instruction and the particular instruction being located at a second memory address, wherein a control circuit of the execution pipeline circuit is configured to:
generate a particular permission table index for the particular instruction based on the first memory address and the second memory address;
retrieve, from the permission table circuit using the particular permission table index, a particular permission of the plurality of permissions for the particular instruction, the particular permission being specific to code executing at the second memory address and accessing a memory location at the first memory address; and
enforce, during execution of the particular instruction, a final memory permission that is based on the particular permission.

### Claim 18 (depends on 17)

The apparatus of claim 17, wherein the execution pipeline circuit is configured to retrieve the particular permission by:
selecting one of a plurality of permission tables from the permission table circuit based on an execution mode of the processor; and
accessing the selected permission table using the particular permission table index to retrieve the particular permission.

### Claim 19 (depends on 18)

The apparatus of claim 18, wherein the execution mode and particular permission table index are from a previous clock cycle of the processor.

### Claim 20 (depends on 18)

The apparatus of claim 18, wherein the control circuit includes a mode checking circuit configured to determine whether a mode change specified by instruction is permitted before disseminating a new mode value throughout the execution pipeline circuit.
