System and method for controlling switching between VMM and VM using enabling value of VMM timer indicator and VMM timer value having a specified time

Information

  • Patent Grant
  • 7840962
  • Patent Number
    7,840,962
  • Date Filed
    Thursday, September 30, 2004
    19 years ago
  • Date Issued
    Tuesday, November 23, 2010
    13 years ago
Abstract
In one embodiment, a method includes transitioning control to a virtual machine (VM) from a virtual machine monitor (VMM), determining that a VMM timer indicator is set to an enabling value, and identifying a VMM timer value configured by the VMM. The method further includes periodically comparing a current value of a timing source with the VMM timer value, generating an internal event if the current value of the timing source has reached the VMM timer value, and transitioning control to the VMM in response to the internal event without incurring an event handling procedure in any one of the VMM and the VM.
Description
FIELD

Embodiments of the invention relate generally to virtual machines, and more specifically to providing support for a timer associated with a virtual machine monitor.


BACKGROUND

Timers and time reference sources are typically used by operating systems and application software to schedule and optimize activities. For example, an operating system kernel may use a timer to allow a plurality of user-level applications to time-share the resources of the system (e.g., the central processing unit (CPU)). An example of a timer used on a personal computer (PC) platform is the 8254 Programmable Interval Timer. This timer may be configured to issue interrupts after a specified interval or periodically.


An example of a time reference source is the timestamp counter (TSC) used in the instruction set architecture (ISA) of the Intel® Pentium® 4 (referred to herein as the IA-32 ISA). The TSC is a 64-bit counter that is set to 0 following the hardware reset of the processor, and then incremented every processor clock cycle, even when the processor is halted by the HLT instruction. The TSC cannot be used to generate interrupts. It is a time reference only, useful to measure time intervals. The IA-32 ISA provides an instruction (RDTSC) to read the value of the TSC and an instruction (WRMSR) to write the TSC. When WRMSR is used to write the timestamp counter, only the 32 low-order bits may be written; the 32 high-order bits are cleared to 0.


In a virtual machine system, a virtual-machine monitor (VMM) may need to utilize platform-based timers in a manner similar to that of a conventional operating system. For example, a VMM may use timers to schedule resources, assure security, provide quality of service, etc.





BRIEF DESCRIPTION OF THE DRAWINGS

The present invention is illustrated by way of example, and not by way of limitation, in the figures of the accompanying drawings and in which like reference numerals refer to similar elements and in which:



FIG. 1 illustrates one embodiment of a virtual-machine environment, in which the present invention may operate;



FIG. 2 is a flow diagram of one embodiment of a process for providing support for a timer associated with a VMM;



FIGS. 3 and 4 are flow diagrams of two embodiment of a process for utilizing a VMM timer to decide whether to return control to a VMM; and



FIG. 5 is a flow diagram of one embodiment of a process for configuring a timer associated with a VMM.





DESCRIPTION OF EMBODIMENTS

A method and apparatus for providing support for a timer associated with a virtual machine monitor is described. In the following description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the present invention. It will be apparent, however, to one skilled in the art that the present invention can be practiced without these specific details.


Some portions of the detailed descriptions that follow are presented in terms of algorithms and symbolic representations of operations on data bits within a computer system's registers or memory. These algorithmic descriptions and representations are the means used by those skilled in the data processing arts to most effectively convey the substance of their work to others skilled in the art. An algorithm is here, and generally, conceived to be a self-consistent sequence of operations leading to a desired result. The operations are those requiring physical manipulations of physical quantities. Usually, though not necessarily, these quantities take the form of electrical or magnetic signals capable of being stored, transferred, combined, compared, and otherwise manipulated. It has proven convenient at times, principally for reasons of common usage, to refer to these signals as bits, values, elements, symbols, characters, terms, numbers, or the like.


It should be borne in mind, however, that all of these and similar terms are to be associated with the appropriate physical quantities and are merely convenient labels applied to these quantities. Unless specifically stated otherwise as apparent from the following discussions, it is appreciated that throughout the present invention, discussions utilizing terms such as “processing” or “computing” or “calculating” or “determining” or the like, may refer to the action and processes of a computer system, or similar electronic computing device, that manipulates and transforms data represented as physical (electronic) quantities within the computer system's registers and memories into other data similarly represented as physical quantities within the computer-system memories or registers or other such information storage, transmission or display devices.


In the following detailed description of the embodiments, reference is made to the accompanying drawings that show, by way of illustration, specific embodiments in which the invention may be practiced. In the drawings, like numerals describe substantially similar components throughout the several views. These embodiments are described in sufficient detail to enable those skilled in the art to practice the invention. Other embodiments may be utilized and structural, logical, and electrical changes may be made without departing from the scope of the present invention. Moreover, it is to be understood that the various embodiments of the invention, although different, are not necessarily mutually exclusive. For example, a particular feature, structure, or characteristic described in one embodiment may be included within other embodiments. The following detailed description is, therefore, not to be taken in a limiting sense, and the scope of the present invention is defined only by the appended claims, along with the full scope of equivalents to which such claims are entitled.


Although the below examples may describe providing support to a timer associated with a virtual machine monitor (VMM) in the context of execution units and logic circuits, other embodiments of the present invention can be accomplished by way of software. For example, in some embodiments, the present invention may be provided as a computer program product or software which may include a machine or computer-readable medium having stored thereon instructions which may be used to program a computer (or other electronic devices) to perform a process according to the present invention. In other embodiments, processes of the present invention might be performed by specific hardware components that contain hardwired logic for performing the processes, or by any combination of programmed computer components and custom hardware components.


Thus, a machine-readable medium may include any mechanism for storing or transmitting information in a form readable by a machine (e.g., a computer), but is not limited to, floppy diskettes, optical disks, Compact Disc, Read-Only Memory (CD-ROMs), and magneto-optical disks, Read-Only Memory (ROMs), Random Access Memory (RAM), Erasable Programmable Read-Only Memory (EPROM), Electrically Erasable Programmable Read-Only Memory (EEPROM), magnetic or optical cards, flash memory, a transmission over the Internet, electrical, optical, acoustical or other forms of propagated signals (e.g., carrier waves, infrared signals, digital signals, etc.) or the like.


Further, a design may go through various stages, from creation to simulation to fabrication. Data representing a design may represent the design in a number of manners. First, as is useful in simulations, the hardware may be represented using a hardware description language or another functional description language. Additionally, a circuit level model with logic and/or transistor gates may be produced at some stages of the design process. Furthermore, most designs, at some stage, reach a level of data representing the physical placement of various devices in the hardware model. In the case where conventional semiconductor fabrication techniques are used, data representing a hardware model may be the data specifying the presence or absence of various features on different mask layers for masks used to produce the integrated circuit. In any representation of the design, the data may be stored in any form of a machine-readable medium. An optical or electrical wave modulated or otherwise generated to transmit such information, a memory, or a magnetic or optical storage such as a disc may be the machine readable medium. Any of these mediums may “carry” or “indicate” the design or software information. When an electrical carrier wave indicating or carrying the code or design is transmitted, to the extent that copying, buffering, or re-transmission of the electrical signal is performed, a new copy is made. Thus, a communication provider or a network provider may make copies of an article (a carrier wave) embodying techniques of the present invention.



FIG. 1 illustrates one embodiment of a virtual-machine environment 100, in which the present invention may operate. In this embodiment, bare platform hardware 116 comprises a computing platform, which may be capable, for example, of executing a standard operating system (OS) or a virtual-machine monitor (VMM), such as a VMM 112.


The VMM 112, though typically implemented in software, may emulate and export a bare machine interface to higher level software. Such higher level software may comprise a standard or real-time OS, may be a highly stripped down operating environment with limited operating system functionality, may not include traditional OS facilities, etc. Alternatively, for example, the VMM 112 may be run within, or on top of, another VMM. VMMs may be implemented, for example, in hardware, software, firmware or by a combination of various techniques.


The platform hardware 116 can be of a personal computer (PC), mainframe, handheld device, portable computer, set-top box, or any other computing system. The platform hardware 116 includes a processor 118 and memory 120.


Processor 118 can be any type of processor capable of executing software, such as a microprocessor, digital signal processor, microcontroller, or the like. The processor 118 may include microcode, programmable logic or hardcoded logic for performing the execution of method embodiments of the present invention. Although FIG. 1 shows only one such processor 118, there may be one or more processors in the system.


Memory 120 can be a hard disk, a floppy disk, random access memory (RAM), read only memory (ROM), flash memory, any combination of the above devices, or any other type of machine medium readable by processor 118. Memory 120 may store instructions and/or data for performing the execution of method embodiments of the present invention.


The VMM 112 presents to other software (i.e., “guest” software) the abstraction of one or more virtual machines (VMs), which may provide the same or different abstractions to the various guests. FIG. 1 shows two VMs, 102 and 114. The guest software running on each VM may include a guest OS such as a guest OS 104 or 106 and various guest software applications 108 and 110. Each of the guest OSs 104 and 106 expects to access physical resources (e.g., processor registers, memory and I/O devices) within the VMs 102 and 114 on which the guest OS 104 or 106 is running and to perform other functions. For example, the guest OS 104 or 106 expects to have access to all registers, caches, structures, I/O devices, memory and the like, according to the architecture of the processor and platform presented in the VM 102 and 114. The resources that can be accessed by the guest software may either be classified as “privileged” or “non-privileged.” For privileged resources, the VMM 112 facilitates functionality desired by guest software while retaining ultimate control over these privileged resources. Non-privileged resources do not need to be controlled by the VMM 112 and can be accessed by guest software.


Further, each guest OS expects to handle various fault events such as exceptions (e.g., page faults, general protection faults, etc.), interrupts (e.g., hardware interrupts, software interrupts), and platform events (e.g., initialization (NIT) and system management interrupts (SMIs)). Some of these fault events are “privileged” because they must be handled by the VMM 112 to ensure proper operation of VMs 102 and 114 and for protection from and among guest software.


When a privileged fault event occurs or guest software attempts to access a privileged resource, control may be transferred to the VMM 112. The transfer of control from guest software to the VMM 112 is referred to herein as a VM exit. After facilitating the resource access or handling the event appropriately, the VMM 112 may return control to guest software. The transfer of control from the VMM 112 to guest software is referred to as a VM entry.


In one embodiment, the processor 118 controls the operation of the VMs 102 and 114 in accordance with data stored in a virtual machine control structure (VMCS) 124. The VMCS 124 is a structure that may contain the state of guest software, the state of the VMM 112, execution control information indicating how the VMM 112 wishes to control operation of guest software, information controlling transitions between the VMM 112 and a VM, etc. The processor 118 reads information from the VMCS 124 to determine the execution environment of the VM and to constrain its behavior. In one embodiment, the VMCS is stored in memory 120. In some embodiments, multiple VMCS structures are used to support multiple VMs.


In one embodiment, when a VM exit occurs, components of the processor state used by guest software are saved, components of the processor state required by the VMM 112 are loaded, and the execution resumes in the VMM 112. In one embodiment, the components of the processor state used by guest software are stored in a guest-state area of VMCS 124 and the components of the processor state required by the VMM 112 are stored in a monitor-state area of VMCS 124. In one embodiment, when a transition from the VMM 112 to guest software occurs, the processor state that was saved at the VM exit (and may have been modified by the VMM 112 while processing the VM exit) is restored and control is returned to the VM 102 or 114.


An event causing a VM exit may or may not require the execution of an “event handling” procedure. The event handling procedure refers to event reporting that changes control flow of the code executing on the processor even though no branches requiring such a change exist in the code. Event reporting is typically performed when an event is an exception or an interrupt and may require saving the state of the running code (e.g., on a stack), locating an interrupt vector by traversing a redirection structure (e.g., the interrupt descriptor table (IDT) in the instruction set architecture (ISA) of the Intel® Pentium® 4 (referred to herein as the IA-32 ISA)), loading the state of the event handler, and starting execution in the new code. When an exception or interrupt occurs during the operation of the VM 102 or 114, and this exception or interrupt should be handled by the VMM 112 (e.g., an I/O completion interrupt for an I/O operation that was not initiated by or on behalf of the running VM 102 or 114), the event handling procedure is executed after exiting the running VM 102 or 114 (i.e., transitioning control to the VMM 112).


Some events do not require the above-referenced event handling procedure to be executed in either the VMM 112 or the VM 102 or 114. Such events are referred to herein as internal events. For example, the VM 102 or 114 may incur a page fault on a page, which the VMM 112 has paged out but the VM 102 or 114 expects to be resident. Such a page fault cannot cause the event handling procedure, in order to prevent a violation of virtualization. Instead, this page fault is handled using a VM exit, which causes the VM state to be saved in the VMCS 124, with the execution resuming in the VMM 112, which handles the page fault and transitions control back to the VM 102 or 114.


The VMM 112 may need to gain control during the operation of the VM 102 or 114 to schedule resources, provide quality of service, assure security, and perform other functions. Hence, the VMM 112 needs to have a timer mechanism allowing the VMM 112 to indicate the desired time for gaining control. In one embodiment, the VMM 112 includes a timer configuration module 126 that provides values for fields associated with the VMM timer prior to requesting a transition of control to the VM 102 or 114. These fields may include, for example, a VMM timer indicator specifying whether a VMM timer should be enabled, and a VMM timer value field indicating a desired time for regaining control.


In one embodiment, the VMM timer indicator and the VMM timer value are stored in the VMCS 124. Alternatively, the VMM timer indicator and the VMM timer value may reside in the processor 118, a combination of the memory 120 and the processor 118, or in any other storage location or locations. In one embodiment, a separate pair of the VMM timer indicator and VMM timer value is maintained for each of the VMs 102 and 114. Alternatively, the same VMM timer indicator and VMM timer value are maintained for both VMs 102 and 144 and are updated by the VMM 112 before each VM entry.


In one embodiment, in which the system 100 includes multiple processors or multi-threaded processors, each of the logical processors is associated with a separate pair of the VMM timer indicator and VMM timer value, and the VMM 112 configures the VMM timer indicator and VMM timer value for each of the logical processors.


In one embodiment, the processor 118 includes VMM timer support logic 122 that is responsible for determining whether the VMM timer is enabled based on the VMM timer indicator. If the VMM timer is enabled, the VMM timer support logic 122 decides when to transition control to the VMM 112 using the VMM timer value specified by the VMM 112.


In one embodiment, the VMM timer value specifies the time at which control should be returned to the VMM 112. During the operation of the VM 102 or 114, the VMM timer support logic 122 periodically (e.g., after each cycle executed by the currently operating VM 102 or 114) compares the current value of the timing source with the VMM timer value specified by the VMM 112. The timing source may be any clock used by the system 100 to measure time intervals. For example, in the IA-32 ISA, the timing source used for measuring time intervals may be the timestamp counter (TSC).


When the current time provided by the timing source “reaches” the VMM timer value specified by the VMM 112, the VMM timer support logic 122 transitions control to the VMM 112, indicating that the cause of the transition is the VMM timer. The current time “reaches” the VMM timer value if the current time matches the VMM timer value or exceeds the timer value (when an exact match between the current time and the VMM timer value is not possible).


In another embodiment, the VMM timer value specifies the time interval at the end of which the VMM 112 should gain control. During the operation of the VM 102 or 114, the VMM timer support logic 122 uses this time interval as a countdown value, periodically decrementing it (e.g., every N ticks of the clock). When the countdown value reaches zero, the VMM timer support logic 122 transitions control to the VMM 112. In one embodiment, if a VM exit occurs prior to the expiration of the countdown value (e.g. due to a fault detected during the operation of the VM), the VMM timer support logic 122 stores a current countdown value to the VMCS 124. The stored countdown value may replace the VMM timer value previously specified by the VMM 112 or be maintained in a designated countdown value field.



FIG. 2 is a flow diagram of one embodiment of a process 200 for providing support for a timer associated with a VMM. The process may be performed by processing logic that may comprise hardware (e.g., circuitry, dedicated logic, programmable logic, microcode, etc.), software (such as that run on a general purpose computer system or a dedicated machine), or a combination of both. In one embodiment, process 200 is performed by VMM timer support logic 122 of FIG. 1.


Referring to FIG. 2, process 200 begins with processing logic receiving a request to transition control to a VM from a VMM (i.e., the request for VM entry) (processing block 202). In one embodiment, the VM entry request is received via a VM entry instruction executed by the VMM.


Next, processing logic determines whether a VMM timer indicator is set to an enabling value (processing box 204). The VMM timer indicator is configured by the VMM and may be set to the enabling value to indicate that the VMM timer mechanism is enabled. As discussed above, the VMM timer mechanism (also referred to herein as the VMM timer) allows the VMM to gain control at a specific point of time during the operation of the VM.


If the determination made at processing box 204 is negative (the VMM timer indicator is set to a disabling value), processing logic proceeds to processing box 210.


If the determination made at processing box 204 is positive, processing logic identifies a VMM timer value configured by the VMM (processing block 206). In one embodiment, processing logic identifies the VMM timer value by retrieving it from the VMCS. The VMM stores the VMM timer value to the VMCS prior to issuing a VM entry request. At processing block 208, processing logic configures and enables the VMM timer using the VMM timer value.


In one embodiment, the VMM timer value specifies the time at which control should be returned to the VMM. The VMM may calculate this timer value by adding an offset value (i.e., a time interval specifying how long the VM is allowed to execute) to the value of the timing source read by the VMM at the time of calculation. In another embodiment, the VMM timer value is an offset time interval specifying how long the VM is allowed to execute.


Next, processing logic transitions control to the VM (processing block 210) and allows the VM to execute until an event associated with a VM exit occurs (processing block 212). In one embodiment, an event is associated with a VM exit if an execution control indicator associated with this event is set to a VM exit value to cause a VM exit for this event.


At processing block 214, the VMM timer is disabled. Note that if the VMM timer was not enabled in processing box 208, this processing step is not required. Next, if the event is a non-VMM timer event (e.g., a fault) associated with a VM exit (processing block 216), processing logic returns control to the VMM, indicating the cause of the VM exit (processing block 218).


Alternatively, if the event is caused by the VMM timer (processing block 216), processing logic transitions control to the VMM, indicating that the VM exist was caused by the VMM timer (processing block 220).


The VMM timer will generate events to trigger a VM exit based on the VMM timer value specified by the VMM. In one embodiment, in which the VMM timer value specifies the time at which the VMM desires to gain control, processing logic makes the above decision by periodically comparing the current time of the clock (e.g., the TSC, or some other timing reference) with the VMM timer value until detecting that the clock reaches the VMM timer value. In another embodiment, in which the VMM timer value is an offset time value specifying how long the VM is allowed to execute, processing logic makes the above decision by periodically decrementing the offset time value until detecting that the offset time value reaches 0.


It should be noted that FIG. 2 illustrates an embodiment in which VM exits caused by non-VMM timer events may have higher priority than VM exits caused by the VMM timer. However, this prioritization may be different depending on a prioritization scheme being used, and, therefore, a decision pertaining to a VM exit caused by a non-VMM timer event can be made after a decision pertaining to a VM exit caused by the VMM timer (processing block 214). Additionally, some non-VMM timer events may have higher priority while other non-VMM timer events may have lower priority than the VMM timer event.



FIGS. 3 and 4 are flow diagrams of two embodiment of a process for utilizing a VMM timer to decide whether to return control to a VMM. The process may be performed by processing logic that may comprise hardware (e.g., circuitry, dedicated logic, programmable logic, microcode, etc.), software (such as that run on a general purpose computer system or a dedicated machine), or a combination of both. In one embodiment, the process is performed by VMM timer support logic 122 of FIG. 1.


Referring to FIG. 3, process 300 uses a VMM timer value that specifies the time at which control should be returned to the VMM. As discussed above, the VMM may calculate this timer value by adding an offset value (i.e., a time interval specifying how long the VM is allowed to execute) to the value of the timing source read by the VMM at the time of calculation.


Process 300 begins subsequent to determining that the VMM timer is enabled, identifying a VMM timer value configured by the VMM, and transitioning control to the VM, as illustrated in FIG. 2.


Initially, processing logic determines, during the operation of the VM, whether the current time provided by the timing source has reached the VMM timer value (processing box 302). As discussed above, the timing source may be any clock used by the system 100 to measure time intervals. For example, a processor supporting the IA-32 ISA may use the TSC to measure time intervals.


In an embodiment, not all of the bits in the timing source may be compared to the VMM timer value. Instead, only the high-order bits may be compared. The number of the bits compared is referred to as the VMM-timer-comparator length. In an embodiment, the VMM may determine the VMM-timer-comparator length by reading a capability model specific register (MSR) using the RDMSR instruction. In one embodiment, in which the TSC is used as the timing source, the determination of processing block 302 is made by comparing the high-order bits of the TSC with the same high-order bits of the VMM timer value, and if the TSC value is greater than or equal to the VMM timer value, then the comparison in processing block 302 is satisfied.


If the current time of the timing source reaches the VMM timer value, processing logic creates an internal event and generates a VM exit, indicating that the cause of the VM exit is due to the VMM timer (processing block 304). As discussed above, because the VM exit is caused by an internal event, the execution will resume in the VMM without performing the event handling procedure that is typically performed for interrupts or exceptions after exiting the VM.


If the current time of the timing source has not yet reached the VMM timer value, processing logic checks for a non-VMM timer event associated with a VM exit (processing box 306). If such event occurs, processing logic generates a VM exit and indicates the source of the VM exit (processing block 308). Otherwise, processing logic returns to processing block 302. Depending on the nature of the non-VMM timer event (e.g., whether the non-VMM timer event is an external interrupt or an internal event), exiting the VM may or may not be followed by the event handling procedure.


In one embodiment, the comparison between the current time and the VMM timer value (illustrated in processing box 302) is performed after each cycle executed by the VM, until the current time meets or exceeds the VMM timer value.


In an embodiment, the comparison is performed in a hardware component, which is configured to generate a signal if the current time matches the VMM timer value. The signal indicates that a VM exit should be generated due to the VMM timer. In one embodiment, the signal is recognized (e.g., by microcode or another hardware component) at the end of the currently executing instruction. The recognized signal indicates that a VM exit due to the VMM timer may be required. This requirement is then prioritized (e.g., by microcode or another hardware component) with other VM exit sources, and the appropriate VM exit to the VMM is generated. That is, if the VMM timer source is of higher priority than other VM exit sources, a VM exit due to the VMM timer is generated. If a VM exit source other than the VMM timer is of higher priority than the VMM timer, a VM exit due to this other source is generated.


Referring to FIG. 4, process 400 uses a VMM timer value that specifies an offset value indicating how long the VM is allowed to execute. Process 400 begins subsequent to determining that the VMM timer is enabled and identifying a VMM timer value configured by the VMM, as illustrated in FIG. 2.


Initially, processing logic stores the offset value configured by the VMM (e.g., as stored in a preemption timer field in the VMCS) as a countdown value in a register (processing block 402). Next, processing logic transitions control to the VM (processing block 403). After transitioning control to the VM, processing logic begins decrementing the countdown value at the rate proportional to the increments of the clock (e.g., every N ticks of the clock) (processing block 404). After each decrement, processing logic checks whether the countdown value has reached 0 (processing box 406). Note that the decrementing of the countdown value may result in the value becoming negative. In this case, in an embodiment, the value is not allowed to be made lower than 0 (i.e., the decrementing stops at 0). Alternatively, the value may be allowed to be made lower than 0, in which case the determination at processing block 406 would be made determined by the value reaching or crossing 0. If the countdown value has reached (has matched or crossed) 0, processing logic issues an internal event and generates a VM exit, indicating that the source of the VM exit is the VMM timer (processing block 412). In one embodiment, once the determination in processing block 406 is positive, a signal is generated that is recognized (e.g., by microcode or a hardware component) at the end of the currently executing instruction. The recognition of this signal indicates that a VM exit due to the VMM timer may be required. This requirement is then prioritized (e.g., by microcode) with other VM exit sources, and the appropriate VM exit to the VMM is generated as discussed above.


If the countdown value has not yet reached 0, processing logic checks for a non-VMM timer event associated with a VM exit (processing box 408). If such event occurs, processing logic stores the current countdown value to the VMCS (processing block 410) and generates a VM exit, indicating the source of this VM exit (processing block 414). Otherwise, processing logic returns to processing block 404.


In an embodiment, the storing of the countdown timer value in processing block 410 may be controlled by a store VMM timer control value stored in the VMCS. If the store VMM timer control is set to an enabled value, then the value of the countdown timer is stored (e.g., to the VMCS) as part of VM exit processing. In an embodiment, if the store VMM timer control is not set to an enabled value, a value of 0 is stored to the offset value configured by the VMM (e.g., to a field in the VMCS). In another embodiment, if the store VMM timer control is not set to an enabled value the offset value configured by the VMM is not modified.



FIG. 5 is a flow diagram of one embodiment of a process 500 for configuring a timer associated with a VMM. The process may be performed by processing logic that may comprise hardware (e.g., circuitry, dedicated logic, programmable logic, microcode, etc.), software (such as that run on a general purpose computer system or a dedicated machine), or a combination of both. In one embodiment, process 500 is performed by a timer configuration module 126 of FIG. 1.


Referring to FIG. 5, process 500 begins with processing logic determining a VMM timer value (processing block 502) and storing it in the VMCS (processing block 504). In one embodiment, the VMM timer value specifies the time at which control should be returned to the VMM. Examples of calculating the VMM timer value are provided below.


Next, processing logic sets a VMM timer indicator to an enabling value (processing block 506) and issues a request to transition control to the VM (a VM entry request) (processing logic 508).


Subsequently, when a VM exit from the VM is generated, processing logic receives control back (processing block 510) and determines whether control was returned due to the VMM timer (processing block 512). If so, processing logic may perform a desired operation and then generate a VM entry to the same VM or a different VM.


Prior to generating the VM entry, processing logic may need to update the VM timer indicator and/or the VMM timer value (processing block 514). In one embodiment, the remaining time was saved to the VMCS prior to the VM exit (as discussed above with respect to FIG. 4). In another embodiment, the remaining time is calculated by processing logic upon receiving control from the VM.


In an embodiment, the VMM timer is used to determine a scheduling quantum for a VM. When a VM is scheduled to execute, it is assigned a quantum value by the VMM. This value is initially used for the VMM timer value. Upon transition to the VM, processing logic will utilize the countdown VMM timer value as described with respect to FIG. 4. Before control is transitioned to the VMM, processing logic determines how much time was left in the time quantum allocated to the VM. In one embodiment, processing logic calculates the remaining time by reading the time value of the timing source prior to transitioning control to the VM and when receiving control from the VM. The difference of these two values indicates how long the VM was executing. This value is then subtracted from the time allocated to the VM. When the remaining time value reaches 0, the VMs scheduling quantum is consumed, and the VMM may then schedule a different VM to execute.


In one embodiment, the VMM timer value is used to limit the maximum time that may be spent in the VM. An offset value (i.e., a time interval specifying how long the VM is allowed to execute) is added to the value of the timing source read by the VMM at the time of calculation. This value is used as the VMM timer value. Upon transition to the VM, processing logic will utilize this value as described with respect to FIG. 3. This same value is used each time control is transitioned to the VM. In this embodiment, the VMM timer acts as a watchdog timer, limiting the longest execution time in the VM, in the absence of other VM exit sources. Note that in an embodiment, a countdown timer (as described with respect to FIG. 4) may also be utilized to realize a watchdog timer mechanism.


Thus, a method and apparatus for providing support for a timer associated with a VMM have been described. It is to be understood that the above description is intended to be illustrative, and not restrictive. Many other embodiments will be apparent to those of skill in the art upon reading and understanding the above description. The scope of the invention should, therefore, be determined with reference to the appended claims, along with the full scope of equivalents to which such claims are entitled.

Claims
  • 1. A computer-implemented method comprising: receiving a request for a virtual machine (VM) entry, the VM entry request including a request for transitioning control from a virtual machine monitor (VMM) to a VM, the VMM having a timer configuration module including a VMM timer indicator;determining whether the VMM timer indicator is set to an enabling value indicating the timer configuration module is enabled to, if necessary, gain control back from the VM during an operation at the VM;if the VMM timer indicator is set to an enabling value, identifying a VMM timer value configured by the VMM prior to receiving the VM entry request, the VMM timer value representing a specific time at which the VMM is to receive the control back from the VM, andenabling the VMM timer using the VMM timer value, andtransitioning control to the VM;if the VMM timer indicator is not set to an enabling value, transitioning control to the VM;executing a VM exit by returning the control back to the VMM from the VM in response to an event relating to the VM exit occurring at the VM.
  • 2. The computer-implemented method of claim 1, further comprising storing the VMM timer value at a virtual machine control structure (VMCS).
  • 3. The computer-implemented method of claim 1, further comprising: periodically comparing a current value of the timing source with the VMM timer value after each cycle executed by the VM; andreturning the control back to the VMM from the VM when the current value reaches the VMM timer value.
  • 4. The method of claim 1, further comprising: disabling the VMM timer upon the occurrence of a VM exit event.
  • 5. The method of claim 1, further comprising: indicating the VM exit was caused by the VMM timer when the VM exit event is a VMM timer event.
  • 6. A machine-readable non-transitory storage medium comprising instructions which, when executed, cause a machine to: receive a request for a virtual machine (VM) entry, the VM entry request including a request for transitioning control from a virtual machine monitor (VMM) to a VM, the VMM having a timer configuration module including a VMM timer indicator;determine whether the VMM timer indicator is set to an enabling value indicating the timer configuration module is enabled to, if necessary, gain control back from the VM during an operation at the VM;if the VMM timer indicator is set to an enabling value, identify a VMM timer value configured by the VMM prior to receiving the VM entry request, the VMM timer value representing a specific time at which the VMM is to receive the control back from the VM, andenable the VMM timer using the VMM timer value, andtransitioning control to the VM;if the VMM timer indicator is not set to an enabling value, transition control to the VM;execute a VM exit by returning the control back to the VMM from the VM in response to an event relating to the VM exit occurring at the VM.
  • 7. The machine-readable storage medium of claim 6, wherein the instructions that when executed, further cause the machine to store the VMM timer value at a virtual machine control structure (VMCS).
  • 8. The machine-readable storage medium of claim 6, wherein the instructions that when executed, further cause the machine to: periodically compare a current value of the timing source with the VMM timer value after each cycle executed by the VM; andreturn the control back to the VMM from the VM when the current value reaches the VMM timer value.
  • 9. The machine-readable storage medium of claim 6, wherein the instructions further comprise instructions which, when executed cause a machine to: disable the VMM timer upon the occurrence of a VM exit event.
  • 10. The machine-readable storage medium of claim 6, wherein the instructions further comprise instructions which, when executed cause a machine to: indicate the VM exit was caused by the VMM timer when the VM exit event is a VMM timer event.
  • 11. A computer system comprising: a non-transitory storage medium having a virtual machine control structure (VMCS); anda processor coupled to the storage medium, the processor having a virtual machine memory (VMM) timer support logic and in communication with a VMM having a timer configuration module, the processor further in communication with a virtual machine (VM) and, during operation of the VM and the VMM, the processor to: receive a request for a virtual machine (VM) entry, the VM entry request including a request for transitioning control from a virtual machine monitor (VMM) to a VM, the VMM having a timer configuration module including a VMM timer indicator;determine whether the VMM timer indicator is set to an enabling value indicating the timer configuration module is enabled to, if necessary, gain control back from the VM during an operation at the VM;if the VMM timer indicator is set to an enabling value, identify a VMM timer value configured by the VMM prior to receiving the VM entry request, the VMM timer value representing a specific time at which the VMM is to receive the control back from the VM, andenable the VMM timer using the VMM timer value, andtransitioning control to the VM;if the VMM timer indicator is not set to an enabling value, transition control to the VM;execute a VM exit by returning the control back to the VMM from the VM in response to an event relating to the VM exit occurring at the VM.
  • 12. The computer system of claim 11, wherein the processor is further to store the VMM timer value at the virtual machine control structure (VMCS).
  • 13. The computer system of claim 11, wherein the processor is further to: periodically compare a current value of the timing source with the VMM timer value after each cycle executed by the VM; andreturn the control back to the VMM from the VM when the current value reaches the VMM timer value.
  • 14. The computer system of claim 11, wherein the processor further to: disable the VMM timer upon the occurrence of a VM exit event.
  • 15. The computer system of claim 11, wherein the processor further to: indicate the VM exit was caused by the VMM timer when the VM exit event is a VMM timer event.
  • 16. An apparatus comprising: a processor, during operation of a virtual machine (VM) and a virtual machine monitor (VMM), to: receive a request for a virtual machine (VM) entry, the VM entry request including a request for transitioning control from a virtual machine monitor (VMM) to a VM, the VMM having a timer configuration module including a VMM timer indicator;determine whether the VMM timer indicator is set to an enabling value indicating the timer configuration module is enabled to, if necessary, gain control back from the VM during an operation at the VM;if the VMM timer indicator is set to an enabling value, identify a VMM timer value configured by the VMM prior to receiving the VM entry request, the VMM timer value representing a specific time at which the VMM is to receive the control back from the VM, andenable the VMM timer using the VMM timer value, and transitioning control to the VM;if the VMM timer indicator is not set to an enabling value, transition control to the VM;execute a VM exit by returning the control back to the VMM from the VM in response to an event relating to the VM exit occurring at the VM.
  • 17. The apparatus of claim 16, wherein the processor is further to store the VMM timer value at a virtual machine control structure (VMCS).
  • 18. The apparatus of claim 16, wherein the processor is further to: periodically compare a current value of the timing source with the VMM timer value after each cycle executed by the VM; andreturn the control back to the VMM from the VM when the current value reaches the VMM timer value.
US Referenced Citations (230)
Number Name Date Kind
3699532 Schaffer et al. Oct 1972 A
3996449 Attanasio et al. Dec 1976 A
4037214 Birney et al. Jul 1977 A
4162536 Morley Jul 1979 A
4207609 Luiz et al. Jun 1980 A
4247905 Yoshida et al. Jan 1981 A
4276594 Morley Jun 1981 A
4278837 Best Jul 1981 A
4307447 Provanzano et al. Dec 1981 A
4319233 Matsuoka et al. Mar 1982 A
4319323 Ermolovich et al. Mar 1982 A
4347565 Kaneda et al. Aug 1982 A
4366537 Heller et al. Dec 1982 A
4400769 Kaneda et al. Aug 1983 A
4403283 Myntti et al. Sep 1983 A
4419724 Branigin et al. Dec 1983 A
4430709 Schleupen et al. Feb 1984 A
4521852 Guttag Jun 1985 A
4571672 Hatada et al. Feb 1986 A
4621318 Maeda Nov 1986 A
4759064 Chaum Jul 1988 A
4795893 Ugon Jan 1989 A
4802084 Ikegaya et al. Jan 1989 A
4811276 Suga Mar 1989 A
4825052 Chemin et al. Apr 1989 A
4907270 Hazard Mar 1990 A
4907272 Hazard Mar 1990 A
4910774 Barakat Mar 1990 A
4974159 Hargrove et al. Nov 1990 A
4975836 Hirosawa et al. Dec 1990 A
5007082 Cummins Apr 1991 A
5022077 Bealkowski et al. Jun 1991 A
5023771 Kishi Jun 1991 A
5075842 Lai Dec 1991 A
5079737 Hackbarth Jan 1992 A
5187802 Inoue et al. Feb 1993 A
5230069 Brelsford et al. Jul 1993 A
5237616 Abraham et al. Aug 1993 A
5237669 Spear et al. Aug 1993 A
5255379 Melo Oct 1993 A
5287363 Wolf et al. Feb 1994 A
5293424 Holtey et al. Mar 1994 A
5295251 Wakui et al. Mar 1994 A
5317705 Gannon et al. May 1994 A
5319760 Mason et al. Jun 1994 A
5361375 Ogi Nov 1994 A
5386552 Garney Jan 1995 A
5421006 Jablon et al. May 1995 A
5434999 Goire et al. Jul 1995 A
5437033 Inoue et al. Jul 1995 A
5442645 Ugon et al. Aug 1995 A
5455909 Blomgren et al. Oct 1995 A
5459867 Adams et al. Oct 1995 A
5459869 Spilo Oct 1995 A
5469557 Salt et al. Nov 1995 A
5473692 Davis Dec 1995 A
5479509 Ugon Dec 1995 A
5504922 Seki et al. Apr 1996 A
5506975 Onodera Apr 1996 A
5511217 Nakajima et al. Apr 1996 A
5522075 Robinson et al. May 1996 A
5528231 Patarin Jun 1996 A
5533126 Hazard et al. Jul 1996 A
5555385 Osisek Sep 1996 A
5555414 Hough et al. Sep 1996 A
5560013 Scalzi et al. Sep 1996 A
5564040 Kubala Oct 1996 A
5566323 Ugon Oct 1996 A
5568552 Davis Oct 1996 A
5574936 Ryba et al. Nov 1996 A
5582717 Di Santo Dec 1996 A
5604805 Brands Feb 1997 A
5606617 Brands Feb 1997 A
5615263 Takahashi Mar 1997 A
5628022 Ueno et al. May 1997 A
5633929 Kaliski, Jr. May 1997 A
5657445 Pearce Aug 1997 A
5668971 Neufeld Sep 1997 A
5684948 Johnson et al. Nov 1997 A
5706469 Kobayashi Jan 1998 A
5717903 Bonola Feb 1998 A
5720609 Pfefferle Feb 1998 A
5721222 Bernstein et al. Feb 1998 A
5729760 Poisner Mar 1998 A
5737604 Miller et al. Apr 1998 A
5737760 Grimmer, Jr. et al. Apr 1998 A
5740178 Jacks et al. Apr 1998 A
5752046 Oprescu et al. May 1998 A
5757919 Herbert et al. May 1998 A
5764969 Kahle Jun 1998 A
5796835 Saada Aug 1998 A
5796845 Serikawa et al. Aug 1998 A
5805712 Davis Sep 1998 A
5809546 Greenstein et al. Sep 1998 A
5825875 Ugon Oct 1998 A
5825880 Sudia et al. Oct 1998 A
5835594 Albrecht et al. Nov 1998 A
5844986 Davis Dec 1998 A
5852717 Bhide et al. Dec 1998 A
5854913 Goetz et al. Dec 1998 A
5867577 Patarin Feb 1999 A
5872994 Akiyama et al. Feb 1999 A
5890189 Nozue et al. Mar 1999 A
5900606 Rigal May 1999 A
5901225 Ireton et al. May 1999 A
5903752 Dingwall et al. May 1999 A
5919257 Trostle Jul 1999 A
5935242 Madany et al. Aug 1999 A
5935247 Pai et al. Aug 1999 A
5937063 Davis Aug 1999 A
5944821 Angelo Aug 1999 A
5953502 Helbig, Sr. Sep 1999 A
5956408 Arnold Sep 1999 A
5970147 Davis et al. Oct 1999 A
5978475 Schneier et al. Nov 1999 A
5978481 Ganesan et al. Nov 1999 A
5987557 Ebrahim Nov 1999 A
6014745 Ashe Jan 2000 A
6035374 Panwar et al. Mar 2000 A
6044478 Green Mar 2000 A
6055637 Hudson et al. Apr 2000 A
6058478 Davis May 2000 A
6061794 Angelo May 2000 A
6075938 Bugnion et al. Jun 2000 A
6085296 Karkhanis et al. Jul 2000 A
6088262 Nasu Jul 2000 A
6092095 Maytal Jul 2000 A
6093213 Favor et al. Jul 2000 A
6101584 Satou et al. Aug 2000 A
6108644 Goldschlag et al. Aug 2000 A
6115816 Davis Sep 2000 A
6125430 Noel et al. Sep 2000 A
6128318 Sato Oct 2000 A
6131166 Wong-Isley Oct 2000 A
6148379 Schimmel Nov 2000 A
6158546 Hanson et al. Dec 2000 A
6173417 Merrill Jan 2001 B1
6175924 Arnold Jan 2001 B1
6175925 Nardone et al. Jan 2001 B1
6178509 Nardone Jan 2001 B1
6182089 Ganapathy et al. Jan 2001 B1
6188257 Buer Feb 2001 B1
6192455 Bogin et al. Feb 2001 B1
6199152 Kelly et al. Mar 2001 B1
6205550 Nardone et al. Mar 2001 B1
6212635 Reardon Apr 2001 B1
6222923 Schwenk Apr 2001 B1
6230118 Bader et al. May 2001 B1
6249872 Wildgrube et al. Jun 2001 B1
6252650 Nakaumra Jun 2001 B1
6269392 Cotichini et al. Jul 2001 B1
6272533 Browne et al. Aug 2001 B1
6272637 Little et al. Aug 2001 B1
6275933 Fine et al. Aug 2001 B1
6282650 Davis Aug 2001 B1
6282651 Ashe Aug 2001 B1
6282657 Kaplan et al. Aug 2001 B1
6292874 Barnett Sep 2001 B1
6301646 Hostetter Oct 2001 B1
6308270 Guthery et al. Oct 2001 B1
6314409 Schneck et al. Nov 2001 B2
6321314 Van Dyke Nov 2001 B1
6327652 England et al. Dec 2001 B1
6330670 England et al. Dec 2001 B1
6339815 Feng Jan 2002 B1
6339816 Bausch Jan 2002 B1
6357004 Davis Mar 2002 B1
6363485 Adams Mar 2002 B1
6374286 Gee et al. Apr 2002 B1
6374317 Ajanovic et al. Apr 2002 B1
6378068 Foster Apr 2002 B1
6378072 Collins et al. Apr 2002 B1
6389537 Davis et al. May 2002 B1
6397242 Devine et al. May 2002 B1
6397379 Yates, Jr. et al. May 2002 B1
6401156 Mergard et al. Jun 2002 B1
6412035 Webber Jun 2002 B1
6421702 Gulick Jul 2002 B1
6435416 Slassi Aug 2002 B1
6445797 McGough et al. Sep 2002 B1
6463535 Drews et al. Oct 2002 B1
6463537 Tello Oct 2002 B1
6496847 Bugnion et al. Dec 2002 B1
6499123 McFarland et al. Dec 2002 B1
6505279 Phillips et al. Jan 2003 B1
6507904 Ellison et al. Jan 2003 B1
6529909 Bowman-Amuah Mar 2003 B1
6535988 Poisner Mar 2003 B1
6557104 Vu et al. Apr 2003 B2
6560627 McDonald et al. May 2003 B1
6609199 DeTreville Aug 2003 B1
6615278 Curtis Sep 2003 B1
6633963 Ellison et al. Oct 2003 B1
6633981 Davis Oct 2003 B1
6651171 England et al. Nov 2003 B1
6678825 Ellison et al. Jan 2004 B1
6684326 Cromer et al. Jan 2004 B1
6795966 Lim et al. Sep 2004 B1
7177967 Jeyasingh et al. Feb 2007 B2
7356817 Cota-Robles et al. Apr 2008 B1
7370324 Goud et al. May 2008 B2
7421533 Zimmer et al. Sep 2008 B2
7475002 Mann Jan 2009 B1
20010021969 Burger et al. Sep 2001 A1
20010027511 Wakabayashi et al. Oct 2001 A1
20010027527 Khidekel et al. Oct 2001 A1
20010037450 Metlitski et al. Nov 2001 A1
20020007456 Peinado et al. Jan 2002 A1
20020023032 Pearson et al. Feb 2002 A1
20020147916 Strongin et al. Oct 2002 A1
20020166061 Falik et al. Nov 2002 A1
20020169717 Challener Nov 2002 A1
20030018892 Tello Jan 2003 A1
20030037089 Cota-Robles et al. Feb 2003 A1
20030074548 Cromer et al. Apr 2003 A1
20030115453 Grawrock Jun 2003 A1
20030126442 Glew et al. Jul 2003 A1
20030126453 Glew et al. Jul 2003 A1
20030159056 Cromer et al. Aug 2003 A1
20030188179 Challener et al. Oct 2003 A1
20030196085 Lampson et al. Oct 2003 A1
20040003323 Bennett et al. Jan 2004 A1
20040003324 Uhlig et al. Jan 2004 A1
20040117532 Bennett et al. Jun 2004 A1
20040117539 Bennett et al. Jun 2004 A1
20050132362 Knauerhase et al. Jun 2005 A1
20050149933 Saito et al. Jul 2005 A1
20050251806 Auslander et al. Nov 2005 A1
20060130059 Bennett et al. Jun 2006 A1
20090025006 Waldspurger Jan 2009 A1
Foreign Referenced Citations (42)
Number Date Country
4217444 Dec 1992 DE
0473913 Mar 1992 EP
0600112 Jun 1994 EP
0602867 Jun 1994 EP
0892521 Jan 1999 EP
0930567 Jul 1999 EP
0961193 Dec 1999 EP
0965902 Dec 1999 EP
1030237 Aug 2000 EP
1055989 Nov 2000 EP
1056014 Nov 2000 EP
1085396 Mar 2001 EP
1146715 Oct 2001 EP
1209563 May 2002 EP
1271277 Jan 2003 EP
2000076139 Mar 2000 JP
2001282558 Oct 2001 JP
2159467 Nov 2000 RU
2159953 Nov 2000 RU
WO9524696 Sep 1995 WO
WO9729567 Aug 1997 WO
WO9812620 Mar 1998 WO
WO9834365 Aug 1998 WO
WO9844402 Oct 1998 WO
WO9905600 Feb 1999 WO
WO9909482 Feb 1999 WO
WO9918511 Apr 1999 WO
WO9957863 Nov 1999 WO
WO9965579 Dec 1999 WO
WO0021238 Apr 2000 WO
WO0062232 Oct 2000 WO
WO0127723 Apr 2001 WO
WO0127821 Apr 2001 WO
WO0163994 Aug 2001 WO
WO0175564 Oct 2001 WO
WO0175565 Oct 2001 WO
WO0175595 Oct 2001 WO
WO0201794 Jan 2002 WO
WO0217555 Feb 2002 WO
WO02060121 Aug 2002 WO
WO02086684 Oct 2002 WO
WO03058412 Jul 2003 WO
Related Publications (1)
Number Date Country
20060075402 A1 Apr 2006 US