CONCURRENT KERNEL AND USER SPACE DEBUGGING OF GUEST SOFTWARE ON A VIRTUAL MACHINE IN THE PRESENCE OF PAGE TABLE ISOLATION
20220100549 · 2022-03-31
Assignee
Inventors
Cpc classification
International classification
G06F9/455
PHYSICS
G06F11/36
PHYSICS
Abstract
A method for use in a computing device, the method comprising: transmitting, to a context manager, a context request associated with a process that is executed in a virtual machine; receiving, from the context manager, a context identifier in response to the context request; transmitting, to an introspection Application Programming Interface (API), a memory access request that is based, at least in part, on the context identifier.
Claims
1. A method for use in a computing device, the method comprising: transmitting, to a context manager, a context request associated with a process that is executed in a virtual machine; receiving, from the context manager, a context identifier in response to the context request; transmitting, to an introspection Application Programming Interface (API), a memory access request that is based, at least in part, on the context identifier.
2. The method of claim 1, wherein the memory access request includes a memory read request, the method further comprising receiving, from the introspection API, data that is retrieved from a memory that is allocated to the process, the data being retrieved from the introspection API based on the context identifier in response to the memory read request.
3. The method of claim 1, wherein the context manager is configured to monitor one or more system events that are generated in the virtual machine, and update a context database based on the one or more system events, the context database including a plurality of entries, each entry identifying a respective page table of a corresponding process.
4. The method of claim 1, wherein the context identifier includes a pointer to a page table that is associated with the process, such that requests may be constructed to access memory across contexts.
5. The method of claim 1, wherein the context identifier includes a context object.
6. The method of claim 1, wherein the context request and the memory access request are transmitted by software that is configured to debug, run, or analyze the virtual machine, the software and the virtual machine being executed inside a virtual machine manager.
7. The method of claim 1, wherein the introspection API is configured to use, at least a portion of the context identifier in lieu of information stored in one or more context registers of the computing device.
8. A system, comprising: a memory; and at least one processor that is operatively coupled to the memory, the at least one processor being configured to perform the operations of: transmitting, to a context manager, a context request associated with a process that is executed in a virtual machine; receiving, from the context manager, a context identifier in response to the context request; transmitting, to an introspection Application Programming Interface (API), a memory access request that is based, at least in part, on the context identifier.
9. The system of claim 8, wherein the memory access request includes a memory read request, the method further comprising receiving, from the introspection API, data that is retrieved from a memory that is allocated to the process, the data being retrieved from the introspection API based on the context identifier in response to the memory read request.
10. The system of claim 8, wherein the context manager is configured to monitor one or more system events that are generated in the virtual machine, and update a context database based on the one or more system events, the context database including a plurality of entries, each entry identifying a respective page table of a corresponding process.
11. The system of claim 8, wherein the context identifier includes a pointer to a page table that is associated with the process, such that requests may be constructed to access memory across contexts.
12. The system of claim 8, wherein the context identifier includes a context object.
13. The system of claim 8, wherein the context request and the access request are transmitted by software that is configured to debug, run, or analyze the virtual machine, the software and the virtual machine being executed inside a virtual machine manager.
14. The system of claim 8, wherein the introspection API is configured to use, at least a portion of the context identifier in lieu of information stored in one or more context registers of the computing device.
15. A non-transitory computer-readable medium storing one or more processor executable instructions, which, when executed by at least one processor, cause the at least one processor to perform the operations of: transmitting, to a context manager, a context request associated with a process that is executed in a virtual machine; receiving, from the context manager, a context identifier in response to the context request; transmitting, to an introspection Application Programming Interface (API), a memory access request that is based, at least in part, on the context identifier.
16. The non-transitory computer-readable medium of claim 15, wherein the memory access request includes a memory read request, the method further comprising receiving, from the introspection API, data that is retrieved from a memory that is allocated to the process, the data being retrieved from the introspection API based on the context identifier in response to the memory read request.
17. The non-transitory computer-readable medium of claim 15, wherein the context manager is configured to monitor one or more system events that are generated in the virtual machine, and update a context database based on the one or more system events, the context database including a plurality of entries, each entry identifying a respective page table of a corresponding process.
18. The non-transitory computer-readable medium of claim 15, wherein the context identifier includes a pointer to a page table that is associated with the process, such that requests may be constructed to access memory across contexts.
19. The non-transitory computer-readable medium of claim 15, wherein the context identifier includes a context object.
20. The non-transitory computer-readable medium of claim 15, wherein the context request and the access request are transmitted by software that is configured to debug, run, or analyze the virtual machine, the software and the virtual machine being executed inside a virtual machine manager.
Description
BRIEF DESCRIPTION OF THE DRAWING FIGURES
[0007] Other aspects, features, and advantages of the claimed invention will become more fully apparent from the following detailed description, the appended claims, and the accompanying drawings in which like reference numerals identify similar or identical elements. Reference numerals that are introduced in the specification in association with a drawing figure may be repeated in one or more subsequent figures without additional description in the specification in order to provide context for other features.
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
DETAILED DESCRIPTION
[0016] In one aspect of the disclosure, techniques are provided for accessing memory across memory contexts of a virtual machine. The technique may be used to allow a debugger to resolve memory access requests into the memory context of a virtual machine, irrespective of whether that machine is executing in a particular memory context.
[0017]
[0018] According to the present example, the processor 110 includes a single core. However, alternative implementations are possible in which the processor 110 includes more than one core. As illustrated, the processor 110 may include one or more context registers 138. The context registers 138 may include any register that identifies the current context of the processor 110. For example, the context registers 138 may include a register that identifies what process is currently running on the processor 110, a register that identifies the memory space (e.g., a page table) corresponding to the process, etc. An example of a context register in the x86 architecture is the CR3 register, which enables the processor to translate linear addresses into physical addresses by locating the page directory or page tables for the current context of the processor. In some implementations, the process 110 may be configured to execute methods 500, 600A, 600B, and 700, which are discussed further below with respect to
[0019] The processor 110 may be configured to execute a virtual machine manager (VMM) 120. The VMM 120 may include any suitable type of hypervisor. The VMM 120 may be configured to execute a debugger 122, a context manager 132, an introspection API 136, and a context database 134. The VM 124 may be configured to execute a guest software 126 and an event generator 128. The guest software, according to the present example, is an operating system. The guest software 126 may be configured to execute a process 126A and a process 126B. The debugger 122 may include any suitable type of debugger that is configured to debug the execution of VM 124 and/or any software that is executing within VM 124, such as the guest software 126, the process 126A, the process 126B, etc.
[0020] The event generator 128 may include any suitable type of API that is configured to generate system events when a new process is instantiated within VM 124 and/or the guest software 126 or when an already-instantiated process changes states. As is discussed further below, the system events may be utilized by the context manager 132 to detect when a new process (e.g., a task, a thread, an operating system process, etc.) is instantiated by VM 124 and/or obtain context data relating to the context of the new process. Additionally or alternatively, the system events may be utilized by the context manager 132 to detect when new memory contexts are instantiated by the VM 124 and/or obtain context data relating to the new memory contexts. According to the example of
[0021] The context manager 132 may be configured to monitor system events that are generated by event generator 128 and update the context database 134. Furthermore, the context manager 132 may be configured to provide a particular memory context of the VM 124 (e.g., the context of one of processes 126A or 126B, etc.) According to the example of
[0022] The context database 134 may include one or more data structures that are arranged to store context information for memory contexts of the VM 124. Although in the example of
[0023] The introspection API 136 may include an application programming interface (API) for reading data from or writing memory to the memory 140. Although in the example of
[0024] The context manager 132 may be configured to monitor system events generated by the event generator 128 and update the context database 134 based on the events. An example of the context database 134 is shown in
[0025]
[0026] According to the example of
[0027] As used throughout the disclosure, the term context identifier corresponding to a process may refer to any suitable type of object, number, or alphanumerical string or set of objects, numbers, or alphanumerical strings that identifies context information associated with the process. For example, the context identifier of a process may include a pointer to a user page table of the process. As another example, the context identifier of a process may include one or more of a pointer to a user page table of the process, a pointer to a kernel page table of the process, a current privilege level (CPL) of the process, a name of the process, an identifier corresponding to the process, and/or any other information that is defined by VM 124 and/or guest software 126 that defines the unique system state of the process. As yet another example, the context identifier may include a context object that includes one or more of a pointer to a user page table of the process, a pointer to a kernel page table of the process, a current privilege level (CPL) of the process, a name of the process, an identifier corresponding to the process, and/or any other information that is defined by VM 124 and/or guest software 126 that defines the unique system state of the process. Although
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034] At step 704, the introspection API determines if the memory access request includes a context identifier. Determining whether the memory access request includes a context identifier may include one or more of: (i) examining the contents of the memory access request to detect whether it includes a content identifier, (ii) detecting whether the memory access request is of a type that is expected to include (or otherwise be associated with) a context identifier, and/or any other action that helps the introspection API whether other data should be used to complete the memory access request instead of the contents of one or more context registers. If the memory access request includes a context identifier, the method 700 proceeds to step 708. If the memory access request does not include a context identifier, the method 700 proceeds to step 706.
[0035] At step 706, the memory access request executes the memory access request based on information that is stored one or more context registers. An example of a context register is the CR3 register in the x86 architecture. However, the present disclosure is not limited to any specific type of context register, as the processor architectures on which any of the methods 500, 600A, 600B, and 700 is executed may vary. As noted above, the memory access request may include a read request or a write request. Executing the memory access request based on information that is stored one or more context registers may include: (1) retrieving a base pointer to a page table from a register (e.g., CR3), (2) adding an offset provided in the memory access request to the base pointer to obtain a memory address where the requested data is stored, (3) retrieving data from or writing data to the memory address. When the memory access request is a read request, any retrieved data may be provided to a sender of the memory read request. At step 708, the introspection API executes the memory access request based on the context identifier (e.g., based on a base pointer to a page table that is contained in the context identifier, etc.). Executing the memory access request based on the context identifier may include: (1) obtaining, based on the context identifier, a base pointer to a page table, (2) adding an offset provided in the memory access request to the base pointer to obtain a memory address where the relevant data is stored, (3) retrieving data from or writing data to the memory address. When the memory access request is a read request, any retrieved data may be provided to a sender of the memory read request. As noted above, the context identifier may include a base pointer of a user or kernel page table that is outside of the context of the sender of the memory access request (e.g., the debugger 122). In some respects, at step 708, the introspection API 136 effectively overrides the contents of the context registers of the processor 110 with information that is contained in the context identifier to reach outside of the current context of the processor 110. The processor 110, in this example, is a single processing core, and as such, it cannot be, at the same time, in both of: (i) the context of the sender of the memory access request, and (ii) the context to which the memory access request is directed. Debugging the VM 124 (including software executing in the VM) may require the debugger 122 to perform memory accesses outside of the VM's 124 present context, and the introspection API 136 facilitates the performance of such memory accesses.
[0036]
[0037] Additionally, the term “or” is intended to mean an inclusive “or” rather than an exclusive “or”. That is, unless specified otherwise, or clear from context, “X employs A or B” is intended to mean any of the natural inclusive permutations. That is, if X employs A; X employs B; or X employs both A and B, then “X employs A or B” is satisfied under any of the foregoing instances. In addition, the articles “a” and “an” as used in this application and the appended claims should generally be construed to mean “one or more” unless specified otherwise or clear from context to be directed to a singular form.
[0038] To the extent directional terms are used in the specification and claims (e.g., upper, lower, parallel, perpendicular, etc.), these terms are merely intended to assist in describing and claiming the invention and are not intended to limit the claims in any way. Such terms do not require exactness (e.g., exact perpendicularity or exact parallelism, etc.), but instead it is intended that normal tolerances and ranges apply. Similarly, unless explicitly stated otherwise, each numerical value and range should be interpreted as being approximate as if the word “about”, “substantially” or “approximately” preceded the value of the value or range.
[0039] Moreover, the terms “system,” “component,” “module,” “interface,”, “model” or the like are generally intended to refer to a computer-related entity, either hardware, a combination of hardware and software, software, or software in execution. For example, a component may be, but is not limited to being, a process running on a processor, a processor, an object, an executable, a thread of execution, a program, and/or a computer. By way of illustration, both an application running on a controller and the controller can be a component. One or more components may reside within a process and/or thread of execution and a component may be localized on one computer and/or distributed between two or more computers.
[0040] Although the subject matter described herein may be described in the context of illustrative implementations to process one or more computing application features/operations for a computing application having user-interactive components the subject matter is not limited to these particular embodiments. Rather, the techniques described herein can be applied to any suitable type of user-interactive component execution management methods, systems, platforms, and/or apparatus.
[0041] While the exemplary embodiments have been described with respect to processes of circuits, including possible implementation as a single integrated circuit, a multi-chip module, a single card, or a multi-card circuit pack, the described embodiments are not so limited. As would be apparent to one skilled in the art, various functions of circuit elements may also be implemented as processing blocks in a software program. Such software may be employed in, for example, a digital signal processor, micro-controller, or general-purpose computer.
[0042] Some embodiments might be implemented in the form of methods and apparatuses for practicing those methods. Described embodiments might also be implemented in the form of program code embodied in tangible media, such as magnetic recording media, optical recording media, solid state memory, floppy diskettes, CD-ROMs, hard drives, or any other machine-readable storage medium, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the claimed invention. Described embodiments might also be implemented in the form of program code, for example, whether stored in a storage medium, loaded into and/or executed by a machine, or transmitted over some transmission medium or carrier, such as over electrical wiring or cabling, through fiber optics, or via electromagnetic radiation, wherein, when the program code is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the claimed invention. When implemented on a general-purpose processor, the program code segments combine with the processor to provide a unique device that operates analogously to specific logic circuits. Described embodiments might also be implemented in the form of a bitstream or other sequence of signal values electrically or optically transmitted through a medium, stored magnetic-field variations in a magnetic recording medium, etc., generated using a method and/or an apparatus of the claimed invention.
[0043] It should be understood that the steps of the exemplary methods set forth herein are not necessarily required to be performed in the order described, and the order of the steps of such methods should be understood to be merely exemplary. Likewise, additional steps may be included in such methods, and certain steps may be omitted or combined, in methods consistent with various embodiments.
[0044] Also, for purposes of this description, the terms “couple,” “coupling,” “coupled,” “connect,” “connecting,” or “connected” refer to any manner known in the art or later developed in which energy is allowed to be transferred between two or more elements, and the interposition of one or more additional elements is contemplated, although not required. Conversely, the terms “directly coupled,” “directly connected,” etc., imply the absence of such additional elements.
[0045] As used herein in reference to an element and a standard, the term “compatible” means that the element communicates with other elements in a manner wholly or partially specified by the standard, and would be recognized by other elements as sufficiently capable of communicating with the other elements in the manner specified by the standard. The compatible element does not need to operate internally in a manner specified by the standard.
[0046] It will be further understood that various changes in the details, materials, and arrangements of the parts which have been described and illustrated in order to explain the nature of the claimed invention might be made by those skilled in the art without departing from the scope of the following claims.