IP Library Granted Patent US 8,307,360
Granted Patent B2
US 8,307,360 · App. 12/272,954 · Granted Nov 6, 2012

Caching binary translations for virtual machine guest

Assignee: Advanced Micro Devices, Inc.
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 8,307,360
App. No.
12/272,954
Granted
Nov 6, 2012
Kind
B2
Abstract

In one embodiment, a method comprises in response to an intercept of a first instruction in a guest that is controlled by a virtual machine monitor (VMM), updating first tracking data corresponding to the first instruction in an intercept tracking table; determining, from the first tracking data, that a translation of the first instruction into a first routine is to be performed; and caching the first routine to be executed in response to a subsequent intercept of the first instruction, wherein the first routine is formed from instructions defined in a same instruction set architecture as the first instruction. In some embodiments, a routine for an intercepted instruction that is within a merge window of the first instruction in a guest may be merged into the same routine with the first instruction.

Claims (59)

1. A method comprising:

intercepting a first instruction in a guest that is controlled by a virtual machine monitor (VMM), wherein the intercepting causes a processor executing the guest to exit execution of the guest and to begin executing code corresponding to the VMM;

in response to the intercepting of the first instruction, updating first tracking data corresponding to the first instruction in an intercept tracking table responsive to executing the code corresponding to the VMM;

determining, from the first tracking data, that a translation of the first instruction into a first routine is to be performed responsive to executing the code corresponding to the VMM; and

caching the first routine to be executed in response to a subsequent intercept of the first instruction, wherein the first routine is formed from instructions defined in a same instruction set architecture as the first instruction.

2. The method as recited in claim 1 further comprising:

in response to an intercept of a second instruction in the guest, updating second tracking data corresponding to the second instruction in the intercept tracking table;

determining, from the second tracking data, that the second instruction is to be emulated; and

emulating the second instruction.

3. The method as recited in claim 1 further comprising:

in response to the subsequent intercept of the first instruction, detecting the cached first routine; and

executing the first routine in the VMM.

4. The method as recited in claim 3 wherein the detecting the cached first routine is responsive to a virtual instruction pointer from the guest that corresponds to the first instruction.

5. The method as recited in claim 4 wherein the detecting is still further responsive to additional data related to the first instruction and stored in the intercept tracking table.

6. The method as recited in claim 5 wherein the additional data comprises a physical address translated from the virtual instruction pointer.

7. The method as recited in claim 5 wherein the additional data comprises data describing the first instruction.

8. The method as recited in claim 7 wherein the data describing the first instruction comprises at least a subset of instruction bytes that form the first instruction.

9. The method as recited in claim 1 wherein the first tracking data comprises a count of a number of intercepts of the first instruction, and wherein the determining comprises determining that the count exceeds a threshold number of intercepts.

10. The method as recited in claim 1 further comprising:

in response to a second intercept of a second instruction in the guest, detecting that the second instruction is within a merge window of the first instruction in the guest; and

adding additional instructions to the first routine to handle the second instruction as well as the first instruction, whereby the subsequent intercept and execution of the first routine handles both the first instruction and the second instruction in response to the subsequent intercept.

11. The method as recited in claim 10 further comprising:

detecting one or more intervening instructions in the guest between the first instruction and the second instruction;

reading the one or more intervening instructions from the guest;

validating the one or more intervening instructions for execution in the first routine; and

writing the one or more intervening instructions into the first routine.

12. The method as recited in claim 10 further comprising:

detecting insufficient space to add the additional instructions at an end of the first routine;

allocating additional space disjoint from the first routine;

storing the additional instructions in the additional space; and

adding a branch at an end of the first routine to the additional space.

13. A non-transitory computer accessible storage medium storing a plurality of instructions comprising code corresponding to a virtual machine manager (VMM), wherein the code, when executed:

updates first tracking data corresponding to a first instruction in an intercept tracking table in response to an intercept of the first instruction in a guest that is controlled by the VMM, wherein the intercept of the first instruction causes a processor executing the guest to exit the guest and to begin executing the code, wherein executing the code corresponding to the VMM causes the update to be performed;

determines, from the first tracking data, that a translation of the first instruction into a first routine is to be performed, wherein executing the code corresponding to the VMM causes the determination to be performed; and

caches the first routine to be executed in response to a subsequent intercept of the first instruction, wherein the first routine is formed from instructions defined in a same instruction set architecture as the first instruction.

14. The computer accessible storage medium as recited in claim 13 wherein the plurality of instructions, when executed in response to an intercept of a second instruction in the guest:

update second tracking data corresponding to the second instruction in the intercept tracking table;

determine, from the second tracking data, that the second instruction is to be emulated; and

emulate the second instruction.

15. The computer accessible storage medium as recited in claim 13 wherein the plurality of instructions, when executed in response to the subsequent intercept of the first instruction:

detect the cached first routine; and

execute the first routine.

16. The computer accessible storage medium as recited in claim 13 wherein the first tracking data comprises a count of a number of intercepts of the first instruction, and wherein the plurality of instructions which, when executed determine, from the first tracking data, that a translation of the first instruction into a first routine is to be performed include instructions which, when executed, determine that the count exceeds a threshold number of intercepts.

17. The computer accessible storage medium as recited in claim 13 wherein the plurality of instructions, when executed in response to a second intercept of a second instruction in the guest:

detect that the second instruction is within a merge window of the first instruction in the guest; and

add additional instructions to the first routine to handle the second instruction as well as the first instruction, whereby the subsequent intercept and execution of the first routine handles both the first instruction and the second instruction in response to the subsequent intercept.

18. The computer accessible storage medium as recited in claim 17 wherein the plurality of instructions, when executed:

detect one or more intervening instructions in the guest between the first instruction and the second instruction;

read the one or more intervening instructions from the guest;

validate the one or more intervening instructions for execution in the first routine; and

write the one or more intervening instructions into the first routine.

19. A method comprising:

in response to an intercept of a first instruction in a guest that is controlled by a virtual machine monitor (VMM), detecting that the first instruction is within a merge window of a second instruction in the guest, wherein the VMM has cached a first routine corresponding to the second instruction to be executed in response to an intercept of the second instruction;

translating the first instruction into a plurality of additional instructions;

adding the plurality of additional instructions to the first routine;

detecting one or more intervening instructions in the guest between the first instruction and the second instruction;

reading the one or more intervening instructions from the guest;

validating the one or more intervening instructions for execution in the first routine; and

writing the one or more intervening instructions into the first routine.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Nov 18, 2008
From: SEREBRIN, BENJAMIN C.
To: ADVANCED MICRO DEVICES, INC.
Reel/Frame 021850/0654 →
Continuity (2)
Provisional Application 61022700 · Jan 22, 2008
Related Publication 20090187902A1 · Jul 23, 2009