# US 2021/0286622 A1 · Optimized branching using safe static keys

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

- Number: US 2021/0286622 A1
- Document ID: US20210286622A1
- Status: Published application
- Kind: A1
- Application number: 17/332,428
- Filed: 2021-05-27
- Published: 2021-09-16
- Earliest claimed: 2020-02-26
- Assignees: Red Hat, Inc.
- Applicants: Red Hat, Inc.
- Inventors: Michael Tsirkin
- Web page: https://patentgrep.com/patent/US20210286622A1

## CPC

- G06F 9/30181: {Instruction operation extension or modification}
- G06F 9/45558: {Hypervisor-specific management and integration aspects}
- G06F 9/30054: {Unconditional branch instructions}
- G06F 9/30058: {Conditional branch instructions}
- G06F 9/30061: {Multi-way branch instructions, e.g. CASE}
- G06F 9/3836: {Instruction issuing, e.g. dynamic instruction scheduling or out of order instruction execution}
- G06F 9/45533: {Hypervisors; Virtual machine monitors}
- G06F 9/4401: Bootstrapping (security arrangements therefor G06F21/57)
- G06F 2009/45575: {Starting, stopping, suspending or resuming virtual machine instances}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Systems and methods for managing optimized branching in executable instructions are disclosed. In one implementation, a processing device may identify, in a sequence of executable instructions, a branching instruction associated with a safe static key, the branching instruction specifying a first target location. The processing device may determine whether a value of the safe static key is initialized. Responsive to determining that the value of the safe static key is initialized, the processing device may further replace the branching instruction with an unconditional branching instruction specifying the first target location. Responsive to determining that the value of the safe static key is uninitialized, the processing device may replace the branching instruction with a conditional branching instruction specifying the first target location.

## Claims

### Claim 1

A method comprising:
identifying, in a sequence of executable instructions, a branching instruction associated with a safe static key, the branching instruction specifying a first target location;
determining whether a value of the safe static key is initialized;
responsive to determining that the value of the safe static key is initialized, replacing the branching instruction with an unconditional branching instruction specifying the first target location; and
responsive to determining that the value of the safe static key is uninitialized, replacing the branching instruction with a conditional branching instruction specifying the first target location.

### Claim 2 (depends on 1)

The method of claim 1, wherein the safe static key is a part of a conditional expression associated with the branching instruction.

### Claim 3 (depends on 1)

The method of claim 1, wherein the sequence of executable instructions is executed by a process running on a virtual machine.

### Claim 4 (depends on 1)

The method of claim 1, wherein the branching instruction is a jump instruction.

### Claim 5 (depends on 1)

The method of claim 1 further comprises:
responsive to determining that a condition is satisfied, replacing the branching instruction with the conditional branching instruction, wherein the condition comprises detecting a boot sequence of a virtual machine executing the sequence of instructions.

### Claim 6 (depends on 1)

The method of claim 1 further comprising:
responsive to determining that a rate of modification of the safe static key exceeds a threshold rate, replacing the unconditional branching instruction with the conditional branching instruction specifying the first target location.

### Claim 7 (depends on 6)

The method of claim 6, wherein determining that the rate of modification of the safe static key exceeds the threshold rate further comprises:
detecting that the unconditional branching instruction is modified;
adding a timestamp of a current time to a list of code modification timestamps; and
determining the rate of modification of the unconditional branching instruction as a number of entries in the list of code modification timestamps that fall within a predetermined window.

### Claim 8 (depends on 7)

The method of claim 7 further comprising:
responsive to adding the timestamp of the current time to the list of code modification timestamps, deleting an earliest timestamp from the list of code modification timestamps.

### Claim 9

A system comprising:
a memory; and
a processing device operatively coupled to the memory, wherein the processing device is further to:
identify, in a sequence of executable instructions, a branching instruction associated with a safe static key, the branching instruction specifying a first target location;
determine whether a value of the safe static key is initialized;
responsive to determining that the value of the safe static key is initialized, replace the branching instruction with an unconditional branching instruction specifying the first target location; and
responsive to determining that the value of the safe static key is uninitialized, replace the branching instruction with a conditional branching instruction specifying the first target location.

### Claim 10 (depends on 9)

The system of claim 9, wherein the safe static key is a part of a conditional expression associated with the branching instruction.

### Claim 11 (depends on 9)

The system of claim 9, wherein the processing device is further to:
responsive to determining that a rate of modification of the safe static key exceeds a threshold rate, replace the unconditional branching instruction with the conditional branching instruction specifying the first target location.

### Claim 12 (depends on 11)

The system of claim 11, wherein to determine that the rate of modification of the safe static key exceeds the threshold rate, the processing device is further to:
detect that the unconditional branching instruction is modified;
add a timestamp of a current time to a list of code modification timestamps; and
determine the rate of modification of the unconditional branching instruction as a number of entries in the list of code modification timestamps that fall within a predetermined window.

### Claim 13 (depends on 11)

The system of claim 11, wherein the sequence of executable instructions comprise a compiled program running on the virtual machine.

### Claim 14

A non-transitory computer-readable storage medium comprising executable instructions that, when executed by a processing device, cause the processing device to:
identify, in a sequence of executable instructions, a branching instruction associated with a safe static key, the branching instruction specifying a first target location;
determine whether a value of the safe static key is initialized;
responsive to determining that the value of the safe static key is initialized, replace the branching instruction with an unconditional branching instruction specifying the first target location; and
responsive to determining that the value of the safe static key is uninitialized, replace the branching instruction with a conditional branching instruction specifying the first target location.

### Claim 15 (depends on 14)

The non-transitory computer-readable storage medium of claim 14, wherein the processing device is further to:
responsive to determining that a rate of modification of the safe static key exceeds a threshold rate, replace the unconditional branching instruction with the conditional branching instruction specifying the first target location.

### Claim 16 (depends on 15)

The non-transitory computer-readable storage medium of claim 15, wherein to determine that the rate of modification of the safe static key exceeds the threshold rate, the processing device is further to:
detect that the unconditional branching instruction is modified;
add a timestamp of a current time to a list of code modification timestamps; and
determine the rate of modification of the unconditional branching instruction as a number of entries in the list of code modification timestamps that fall within a predetermined window.

### Claim 17 (depends on 16)

The non-transitory computer-readable storage medium of claim 16, wherein the processing device is further to:
responsive to adding the timestamp of the current time to the list of code modification timestamps, delete an earliest timestamp from the list of code modification timestamps.

### Claim 18 (depends on 14)

The non-transitory computer-readable storage medium of claim 14, wherein the sequence of executable instructions comprise a compiled program running on the virtual machine.

### Claim 19 (depends on 14)

The non-transitory computer-readable storage medium of claim 14, wherein the processing device is further to:
responsive to determining that a condition is satisfied, replace the branching instruction with the conditional branching instruction, wherein the condition comprises detecting a boot sequence of a virtual machine executing the sequence of instructions.

### Claim 20 (depends on 14)

The non-transitory computer-readable storage medium of claim 14, wherein the branching instruction is a jump instruction.
