Page tag-based memory trap-and-emulate operations
A hypervisor comprising a plurality of emulation routines is launched at a host. Individual emulation routines are used to perform respective tasks by a hypervisor on behalf of guest virtual machines of the host. A guest virtual machine initiates an operation which requires access to a virtual address. Subsequent to a determination by a memory management unit of the host that a virtual-to-physical address translation mapping for the virtual address which permits the operation initiated by the guest virtual machine is not available, a task is performed using a particular emulation routine, without initiating an analysis using the virtual address at the hypervisor to select the particular emulation routine from the plurality of emulation routines.
1 . A computer-implemented method, comprising:
launching, at a virtualization host, a hypervisor comprising a plurality of emulation routines, wherein individual ones of the emulation routines are used to perform respective tasks triggered by operations initiated at one or more guest virtual machines launched at the virtualization host, wherein the respective tasks require a privilege level which is granted to the hypervisor and not granted to the one or more guest virtual machines, and wherein at least some of the respective tasks are associated with a corresponding hardware subcomponent of the virtualization host;
initiating, by a particular guest virtual machine which was launched at the virtualization host, an operation which requires access to a particular virtual address;
determining, by a memory management unit (MMU) of the virtualization host, that a valid virtual-to-physical address translation mapping for the particular virtual address which grants permission for the operation initiated by the particular guest virtual machine is not present in a set of address translation entries associated with the particular guest virtual machine; and
based on (a) the determining by the MMU that the valid virtual-to-physical address translation mapping for the particular virtual address is not present and (b) a page tag associated with the particular virtual address, performing, at the virtualization host, a task using a particular emulation routine of the plurality of emulation routines, wherein the page tag is stored in a particular address translation entry of the set of address translation entries, and wherein the particular emulation routine is executed without the hypervisor utilizing the particular virtual address to select the particular emulation routine from the plurality of emulation routines.
2 . The computer-implemented method as recited in claim 1 , further comprising:
storing the page tag by the hypervisor in the particular address translation entry.
3 . The computer-implemented method as recited in claim 1 , further comprising:
reading the page tag by the MMU from the particular address translation entry in response to determining that the valid virtual-to-physical address translation mapping is not present;
storing the page tag by the MMU in a system register of the virtualization host;
reading the page tag from the system register by the hypervisor; and
selecting, by the hypervisor, the particular emulation routine from the plurality of emulation routines using the page tag.
4 . The computer-implemented method as recited in claim 1 , further comprising:
populating, by the hypervisor, a vector table in a memory of the virtualization host, wherein the vector table comprises a plurality of vector table entries indexed by respective page tags, wherein individual ones of the vector table entries comprise executable instructions for initiating execution of respective emulation routines of the plurality of emulation routines, wherein the plurality of vector table entries includes a particular vector table entry corresponding to the particular emulation routine, and wherein the particular vector table entry is indexed by the page tag; and
storing, by the hypervisor in a system register, a base address of the vector table.
5 . The computer-implemented method as recited in claim 4 , further comprising:
reading the page tag by the MMU from the particular address translation entry in response to determining that the valid virtual-to-physical address translation mapping is not present;
accessing, by a control unit of a processor of the virtualization host, the particular vector table entry using (a) the base address of the vector table, obtained from the system register, and (b) the page tag; and
causing, at the processor, the task to be performed using one or more executable instructions stored in the particular vector table entry.
6 . A system, comprising:
a processor of a host, wherein the processor includes a memory management unit (MMU);
a memory of the host, wherein the memory stores instructions that when executed on the processor:
launch a hypervisor, wherein the hypervisor comprises a plurality of emulation routines, wherein individual ones of the emulation routines are used to perform respective tasks on behalf of one or more guest virtual machines running at the host, and wherein the respective tasks require a privilege level granted to the hypervisor and not granted to the one or more guest virtual machines;
initiate, by a particular guest virtual machine which was launched at the host, an operation which requires access to a particular virtual address; and
subsequent to a determination by the MMU that a virtual-to-physical address translation mapping for the particular virtual address which permits the operation initiated by the guest virtual machine is not available, perform a task using a particular emulation routine of the plurality of emulation routines, wherein the particular emulation routine is identified using a page tag associated within the particular virtual address, and wherein the task is performed without using, by the hypervisor, the particular virtual address to select the particular emulation routine from the plurality of emulation routines.
7 . The system as recited in claim 6 , wherein the memory stores further instructions that when executed on the processor:
store the page tag in a particular address translation entry of a set of address translation entries associated with the particular guest virtual machine.
8 . The system as recited in claim 7 , wherein the memory stores further instructions that when executed on the processor:
obtain the page tag, at the hypervisor, from a location into which the page tag is stored subsequent to the determination that the virtual-to-physical address translation mapping for the particular virtual address which permits the operation initiated by the particular guest virtual machine is not available; and
select, by the hypervisor based at least in part on the page tag, the particular emulation routine from the plurality of emulation routines.
9 . The system as recited in claim 8 , wherein the MMU is configured to:
read the page tag from the particular address translation entry in response to determining that a virtual-to-physical address translation mapping for the particular virtual address which permits the operation initiated by the guest virtual machine is not available; and
store the page tag in the location.
10 . The system as recited in claim 8 , wherein the location comprises a system register of the host.
11 . The system as recited in claim 7 , wherein the particular address translation entry comprises an entry of a hypervisor-managed page table, and wherein the page tag is stored using one or more reserved bits of the entry of the hypervisor-managed page table.
12 . The system as recited in claim 7 , wherein the memory stores further instructions that when executed on the processor:
populate, by the hypervisor, a vector table in a memory of the host, wherein the vector table comprises a plurality of vector table entries indexed by respective page tags, wherein individual ones of the vector table entries comprise executable instructions for initiating execution of respective emulation routines of the plurality of emulation routines, wherein the plurality of vector table entries includes a particular vector table entry corresponding to the particular emulation routine, and wherein the particular vector table entry is indexed by the page tag; and
store, by the hypervisor in a system register of the host, a base address of the vector table.
13 . The system as recited in claim 12 , wherein the MMU is configured to:
read the page tag from the particular address translation entry in response to a determination by the MMU that a virtual-to-physical address translation mapping for the particular virtual address which permits the operation initiated by the particular guest virtual machine is not available; and
cause the processor to access the particular vector table entry using (a) the base address of the vector table, obtained from the system register, and (b) the page tag, wherein the task is performed at the processor using one or more executable instructions stored in the particular vector table entry.
14 . The system as recited in claim 12 , wherein the memory stores further instructions that when executed on the processor:
set, by the hypervisor, a particular bit in the system register to indicate that the vector table is to be used to execute emulation routines at the host.
15 . The system as recited in claim 6 , wherein the operation which requires access to the particular virtual address comprises one or more of: (a) a read or write operation directed to a Universal Asynchronous Receiver-Transmitter (UART) device, (b) a read or write operation directed to a Peripheral Component Interconnect (PCI) device, or (c) a read or write operation directed to a portion of virtual memory which has not been mapped to physical memory of the host by the hypervisor.
16 . One or more non-transitory computer-accessible storage media storing program instructions that when executed on or across one or more processors:
launch a hypervisor at a virtualization host, wherein the hypervisor comprises a plurality of emulation routines, wherein individual ones of the emulation routines are used to perform respective tasks on behalf of one or more guest virtual machines launched at the virtualization host by the hypervisor, and wherein the respective tasks require a privilege level granted to the hypervisor and not granted to the one or more guest virtual machines;
initiate, by a particular guest virtual machine which was launched at the virtualization host, an operation which requires access to a particular virtual address; and
subsequent to a determination by a memory management unit (MMU) of a processor of the one or more processors that a virtual-to-physical address translation mapping for the particular virtual address which permits the operation initiated by the particular guest virtual machine is not available, select, using a page tag associated within the particular virtual address, a particular emulation routine of the plurality of emulation routines; and
perform a task using the particular emulation routine of the plurality of emulation routines, wherein the task is performed without initiating an analysis using the particular virtual address to select the particular emulation routine from among the plurality of emulation routines.
17 . The one or more non-transitory computer-accessible storage media as recited in claim 16 , storing further program instructions that when executed on or across the one or more processors:
store, by the hypervisor, a particular page tag corresponding to the particular virtual address in a particular address translation entry of a set of address translation entries associated with the particular guest virtual machine, wherein the particular page tag is the page tag utilized to select the particular emulation routine from among the plurality of emulation routines.
18 . The one or more non-transitory computer-accessible storage media as recited in claim 17 , storing further program instructions that when executed on or across the one or more processors:
obtain the particular page tag, at the hypervisor, from a location into which the particular page tag is stored by the MMU subsequent to the determination by the MMU that a virtual-to-physical address translation mapping for the particular virtual address which permits the operation initiated by the particular guest virtual machine is not available; and
select, by the hypervisor based at least in part on the particular page tag, the particular emulation routine from the plurality of emulation routines.
19 . The one or more non-transitory computer-accessible storage media as recited in claim 17 , storing further program instructions that when executed on or across the one or more processors:
populate, by the hypervisor, a vector table in a memory of the virtualization host, wherein the vector table comprises a plurality of vector table entries indexed by respective page tags, wherein individual ones of the vector table entries comprise executable instructions for initiating execution of respective emulation routines of the plurality of emulation routines, wherein the plurality of vector table entries includes a particular vector table entry corresponding to the particular emulation routine, and wherein the particular vector table entry is indexed by the particular page tag; and
store, by the hypervisor in a system register of the host, a base address of the vector table, wherein contents of the system register and the particular vector table entry are utilized to perform the task using the particular emulation routine.
20 . The one or more non-transitory computer-accessible storage media as recited in claim 19 , wherein the particular vector table entry includes one of: (a) a jump instruction to a portion of executable code of the particular emulation routine or (b) at least a portion of executable code of the particular emulation routine.