Providing a copy of the I / O memory management unit registers to the guest operating system

By maintaining separate IOMMU MMIO registers for each guest operating system in a backing store, the system addresses latency and processor load issues in existing virtualization systems, improving performance and reducing memory bus traffic.

JP7564830B2Active Publication Date: 2024-10-09ADVANCED MICRO DEVICES INC
View PDF 10 Cites 0 Cited by

Patent Information

Application Number
JP2021570831
Authority / Receiving Office
JP · JP
Patent Type
Patents
Current Assignee / Owner
Priority Date
2019-05-27
Filing Date
2020-05-25
Publication Date
2024-10-09
Estimated Expiration
2040-05-25

AI Technical Summary

Technical Problem

The existing systems for virtualization of electronic device hardware, particularly in managing communications between guest operating systems and IOMMUs, suffer from high latency and processor load due to hypervisor intervention, leading to inefficient memory bus traffic.

Method used

Implementing a system where the IOMMU maintains separate copies of MMIO registers for each guest operating system in a backing store, allowing direct access and reducing the need for hypervisor involvement, thus optimizing communication pathways.

Benefits of technology

This approach reduces latency, decreases processor load, and minimizes memory bus traffic, enhancing overall performance and user satisfaction by streamlining operations between guest operating systems and IOMMUs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 0007564830000001
    Figure 0007564830000001
  • Figure 0007564830000002
    Figure 0007564830000002
  • Figure 0007564830000003
    Figure 0007564830000003
Patent Text Reader

Abstract

The electronic device includes a processor that executes guest operating systems, an input / output management unit (IOMMU), and a main memory that stores an IOMMU backing store. The IOMMU backing store includes a separate copy of a set of IOMMU memory-mapped input / output (MMIO) registers for each guest operating system in a set of supported guest operating systems. The IOMMU receives communications from the guest operating systems to access data in the specified IOMMU MMIO registers. The IOMMU performs corresponding accesses to data in the copy of the specified IOMMU MMIO register in the IOMMU backing store associated with the guest operating system.
Need to check novelty before this filing date? Find Prior Art

Description

[Background technology]

[0001] (Related Technology) Some electronic devices (e.g., servers, desktop computers, etc.) support "virtualization" of electronic device hardware, such as input / output (IO) devices. Virtualization involves an intermediate entity on or within the electronic device providing the illusion to an instance of software (e.g., an application program, etc.) running on the electronic device that the instance of software has direct access to the electronic device hardware, when in fact the intermediate entity intercepts / redirects or otherwise assists the instance of software in accessing it. For example, one common intermediate entity is a "virtual machine." A virtual machine is a software entity that abstracts the electronic device hardware and emulates or presents a known interface to the electronic device hardware, thereby allowing an instance of the software to run on electronic devices of various types and configurations. The configuration of electronic device hardware may include electronic device hardware with which the instance of the software is not compatible. In some electronic devices, the virtual machine supports the execution of one or more instances of an operating system, called a "guest" operating system. The guest operating system provides an environment for running other instances of software, such as productivity applications, databases, etc.

[0002] In some electronic devices, virtual machines are managed and controlled by a software entity known as a hypervisor. The hypervisor may start or initialize the virtual machines, control, monitor and assist the virtual machines in accessing the electronic device hardware, terminate or close the virtual machines, etc. FIG. 1 is a block diagram illustrating virtual machines and a hypervisor. As seen in FIG. 1, there are three virtual machines (VMs) 100, each of which runs a guest operating system (guest OS) 102, one or more programs (PRGRMS) 104, such as databases, software applications, etc. The virtual machines 100 communicate with a hypervisor 106, which interfaces between a host operating system (host OS) 108 and the virtual machines 100. The host operating system 108 provides an interface between the electronic device hardware 110 and the hypervisor 106. Additionally, the hypervisor 106 provides an interface between the virtual machines 100 and an input / output management unit (IOMMU) 112, which acts as a memory management unit and controller for the IO device hardware 114.

[0003] Operations performed by the hypervisor include handling communications between the electronic device hardware and guest operating systems (or, more broadly, virtual machines). For example, the hypervisor may translate, redirect, or otherwise assist communications between the guest operating systems and an input / output management unit (IOMMU). Communications handled by the hypervisor include communications such as peripheral page request (PPR) log and event log writing by the IOMMU, and command buffer writing by the guest operating systems. PPR log, event log, and command buffer writing are described in detail in the AMD I / O Virtualization Technology (IOMMU) Specification, rev. 3.00, December 2016, which is incorporated by reference in its entirety.

[0004] FIG. 2 is a block diagram illustrating communication between guest operating systems and IOMMUs as handled by the hypervisor. In FIG. 2, several elements are shown as dotted / dotted, which are logs, buffers, etc. stored in memory (e.g., main memory of an electronic device) and thus accessed via typical memory access techniques. The elements of FIG. 2 include guest operating system 102, hypervisor 106, and IOMMU 112, as well as guest peripheral page request (PPR) log 200, guest command buffer (CMD BUF) 202, and guest event log 204, which are structures in memory (e.g., lists, tables, etc.) used to store communications from and to guest operating system 102. Additionally, the elements include guest pointer (PTRS) / status register (REGS) 206, which is a set of pointers to guest operating system structures and locations in memory for storing status information related to the guest operating system. Additionally, elements include IOMMU peripheral page request log 208, IOMMU command buffer 210, and IOMMU event log 212, which are structures in memory (e.g., lists, tables, etc.) used to store communications from and to the IOMMU 112. Elements also include IOMMU memory mapped input / output (MMIO) pointers / status registers (REGS) 214 in the IOMMU 112, which are a set of registers in the IOMMU 112 for storing pointers to various IOMMU 112 structures and status information related to the IOMMU 112.

[0005] During operation, using commands as an example, guest operating system 102 writes commands destined for IOMMU 112 to guest command buffer 202 (i.e., to the next available location in the buffer in memory where commands from guest operating system 102 are stored). As indicated by the dotted line in Figure 2, hypervisor 106 detects the guest operating system's write to guest command buffer 202, retrieves and processes the command (e.g., by replacing the guest domain ID and / or guest device ID in the command with the corresponding host domain ID and / or device ID), and stores the processed command in IOMMU command buffer 210. Hypervisor 106 also updates the tail pointer in IOMMU MMIO pointer / status register 214 of IOMMU command buffer 210 to indicate the newly written command (e.g., increments the tail pointer to the next location in IOMMU command buffer 210). The IOMMU 112 then uses the command buffer head pointer to retrieve the command from the IOMMU command buffer 210 and execute the command, which causes the IOMMU 112 to perform the corresponding action. The hypervisor 106 performs similar operations (e.g., replacing the host device ID with the guest device ID) for the IOMMU 112 to write to the IOMMU peripheral page request log 208 and the IOMMU event log 212. Because of the long latency of memory reads and writes, pointer updates, and other operations performed by the hypervisor 106, using the hypervisor 106 to intervene between the guest operating system 102 and the IOMMU 112 not only slows down communication processing, but also keeps the processor busy and adds traffic to the memory bus of the electronic device. [Brief description of the drawings]

[0006] [Figure 1] FIG. 2 is a block diagram illustrating a virtual machine and a hypervisor. [Diagram 2]FIG. 2 is a block diagram illustrating communication between guest operating systems and an IOMMU that is handled by a hypervisor. [Diagram 3] FIG. 2 is a block diagram illustrating a virtual machine and a hypervisor, according to some embodiments. [Figure 4] FIG. 1 is a block diagram illustrating an electronic device according to some embodiments. [Diagram 5] 1 is a block diagram illustrating a portion of memory accessed by an IOMMU, in accordance with some embodiments. [Figure 6] FIG. 2 is a block diagram illustrating values ​​stored in a guest copy of an IOMMU MMIO register in accordance with some embodiments. [Figure 7] 1 is a block diagram illustrating communication between a guest operating system and an IOMMU that is handled by the IOMMU, according to some embodiments. [Figure 8] 1 is a flowchart illustrating a process by which an IOMMU accesses a copy of an IOMMU MMIO register in an IOMMU backing store on behalf of a guest operating system, according to some embodiments. [Figure 9] 1 is a flowchart illustrating the process by which a guest operating system writes to and the IOMMU reads from copies of IOMMU MMIO registers in the IOMMU backing store, according to some embodiments. [Figure 10] 1 is a flowchart illustrating the process by which an IOMMU writes to and a guest operating system reads from copies of IOMMU MMIO registers in an IOMMU backing store, according to some embodiments. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS

[0007] Throughout the drawings and the description, like numbers refer to like drawing elements.

[0008] The following description is presented to enable any person skilled in the art to make and use the described embodiments and is provided in the context of a particular application and its requirements. Various modifications to the described embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be applied to other embodiments and applications. Thus, the described embodiments are not limited to the embodiments shown but are to be accorded the widest scope consistent with the principles and features disclosed herein.

[0009] (term) In the following description, various terms are used to describe the embodiments. The following are simplified general descriptions of these terms. Please note that the terms may have important additional features that are not described herein for clarity and conciseness, and therefore this description is not intended to limit the terms.

[0010] Functional Block: A functional block refers to a group, collection, and / or set of one or more interrelated circuit elements, such as integrated circuit elements, discrete circuit elements, etc. The circuit elements are "interrelated" in that they share at least one characteristic. For example, circuit elements that are interrelated may be contained in, fabricated on, or otherwise coupled to a particular integrated circuit chip or portion thereof, may participate in the performance of a given function (e.g., a computational or processing function, a memory function, etc.), may be controlled by a common control element and / or a common clock, etc. A functional block may include any number of circuit elements, ranging from a single circuit element (e.g., a single integrated circuit logic gate) to millions or billions of circuit elements (e.g., integrated circuit memories).

[0011] (Virtualization, Virtual Machines and Hypervisors) The described embodiments support "virtualization" of electronic device hardware, such as memory, input / output (IO) devices, etc. Virtualization generally involves an intermediate entity on or within an electronic device providing an illusion to an instance of software running on the electronic device that the instance of software has direct access to the electronic device hardware, when in fact the intermediate entity intercepts / redirects or otherwise assists the accesses made by the instance of software. For example, an instance of software may be presented by the intermediate entity with a set of electronic device registers, memory locations, electronic device settings, and other functional blocks that appear to the instance of software as actual device registers, memory locations, etc. of the electronic device, but are merely copies presented by the intermediate entity. In this case, the intermediate entity receives, intercepts, or otherwise obtains access of a copy of the electronic device hardware and performs corresponding interactions with the actual electronic device hardware on behalf of the instance of software. Virtualization of electronic device hardware has many advantages, such as allowing different electronic devices to use different configurations of electronic device hardware, different addresses, locations, or identifiers of electronic device hardware, etc., and the instances of software are presented through the intermediate entity with the same interface to the electronic device hardware. Additionally, the intermediate entity can decide whether to allow or block access of the electronic device hardware by a given instance of the software, thus allowing protection of the electronic device hardware (or portions thereof) and / or instances of software running on the electronic device through virtualization of the electronic device hardware. By controlling access as described above, the intermediate entity can share the electronic device hardware among several instances of the software and / or provide individual instances of the software with exclusive access to portions of the electronic device hardware.

[0012] In the described embodiment, the intermediate entity includes a "virtual machine." A virtual machine is a software entity that abstracts the electronic device hardware and presents a known interface to actual or emulated electronic device hardware to an instance of software. The hardware abstraction allows an instance of software to run on various types and configurations of electronic device hardware, including potentially incompatible electronic device hardware. In the described embodiment, the virtual machine supports the execution of one or more instances of operating systems, referred to as "guest" operating systems. The guest operating systems provide an environment for running other software programs, such as applications, databases, and the like.

[0013] In the described embodiment, the virtual machines are managed and controlled by a software entity known as a hypervisor. The hypervisor may start or initialize the virtual machines, control, monitor and assist the virtual machines in accessing the electronic device hardware, terminate or close the virtual machines, etc. FIG. 3 is a block diagram illustrating virtual machines and a hypervisor according to some embodiments. As seen in FIG. 3, there are three virtual machines (VMs) 300, under each of which runs a guest operating system (guest OS) 302 and one or more programs (PRGRMS) 304, such as databases, software applications, etc. The virtual machines 300 communicate with a hypervisor 306, which interfaces between a host operating system (host OS) 308 and the virtual machines 300. The host operating system 308 provides an interface between the electronic device hardware 310 and the hypervisor 306. Unlike that shown in FIG. 1 for existing electronic devices, in FIG. 3 the IOMMU 312 directly interfaces between the guest operating system 302 and the IO device hardware 314 (as indicated by the thick line between the IOMMU 312 and the guest operating system 302) without the hypervisor 306 being involved. Thus, unlike existing electronic devices, in the described embodiments the hypervisor 306 is not involved in performing at least some of the operations for handling communications between the guest operating system 302 and the IOMMU 312 as described herein. However, it should be noted that certain communications do occur between the IOMMU 312 and the hypervisor 306, as indicated by the line between the hypervisor 306 and the IOMMU 312. Additionally, it should be noted that in some embodiments, the host operating system 308 is not present and the hypervisor 306 communicates more directly with the electronic device hardware 310.

[0014] (overview) In a described embodiment, an electronic device includes a processor, a memory (e.g., main memory), a number of input / output (IO) devices (e.g., network interface devices, disk controllers, etc.), and an input / output memory management unit (IOMMU) that interfaces between the processor and the IO devices. The processor executes a hypervisor, one or more virtual machines, and guest operating systems on the virtual machines. Each guest operating system is assigned a guest portion of memory (e.g., a contiguous or non-contiguous region or block of memory) reserved for storing data and information accessed by that guest operating system. In a described embodiment, the IOMMU performs operations to handle communication between the guest operating systems and the IOMMU.

[0015] As part of handling communication between guest operating systems and the IOMMU, instead of using a single IOMMU copy of a particular buffer and log as in existing systems, the IOMMU directly accesses each guest operating system's buffers and logs in the corresponding guest portion of memory. That is, the IOMMU accesses separate copies of the buffers and logs used by each guest operating system instead of the copies of the buffers and logs maintained by the IOMMU (and hypervisor) in existing systems. For example, in some embodiments, each guest operating system maintains buffers and logs, including a command buffer, an event log, and / or a peripheral page request (PPR) log, in the corresponding guest portion of memory. The IOMMU also reads information from and writes information to each guest operating system's buffers and logs in the guest operating system's portion of memory. For example, the IOMMU can read commands from a particular guest operating system's command buffer in the particular guest operating system's guest portion of memory.

[0016] In existing systems where an IOMMU uses a single copy of buffers and logs, the IOMMU maintains a set of IOMMU memory-mapped input / output (MMIO) registers that are used to store information about the buffers and logs. For example, the IOMMU MMIO registers include information such as a set of pointers (e.g., head and / or tail pointers for each log or buffer) and control values ​​for the buffers and logs (e.g., size indicators and / or configuration values ​​for each log or buffer). In described embodiments, the IOMMU accesses buffers and logs separately in different guest portions of memory (i.e., at different memory addresses and possibly with different control values), so a single set of IOMMU MMIO registers is insufficient. Thus, in described embodiments, the IOMMU provides a separate copy of the set of IOMMU MMIO registers for each guest operating system that is used to access the buffers and logs in the corresponding guest portions of memory. In other words, in some embodiments, if N guest operating systems are supported by the system, the IOMMU provides N copies of the IOMMU MMIO registers (i.e., sets of pointers and control values ​​for the buffers and logs), one for each guest operating system.

[0017] Due to the large number of registers required to keep track of buffers and logs for all possible guest operating systems (which can be very large), a separate copy of the IOMMU MMIO registers does not physically exist in the IOMMU. Instead, a separate copy of the set of IOMMU MMIO registers for the guest operating systems is stored in the IOMMU backing store, which is a portion of main memory reserved for storing IOMMU data and information. In the described embodiment, the IOMMU "virtualizes" the IOMMU MMIO registers, or indicates to the guest operating systems (and possibly other entities such as a hypervisor) that the guest operating systems can access the IOMMU MMIO registers through a specified IOMMU MMIO address, although the IOMMU MMIO address does not have any registers. Instead, the IOMMU intercepts accesses by the guest operating systems to the IOMMU MMIO registers of the IOMMU MMIO address and redirects the IOMMU MMIO register accesses to the corresponding locations in the IOMMU backing store. For example, in some embodiments, the IOMMU MMIO address comprises an address from a particular range of addresses provided by the IOMMU within the IOMMU interface / aperture that is used to map communications to copies of IOMMU registers in the IOMMU backing store.

[0018] In some embodiments, during operation, the IOMMU receives communications from a guest operating system to access data in a given IOMMU MMIO register. For example, after writing a command to the guest operating system's command buffer in the corresponding guest portion of memory, the guest operating system may send a memory write to update the command buffer tail pointer received by the IOMMU. The IOMMU performs a corresponding access to data in a copy of the given IOMMU MMIO register in an IOMMU backing store associated with the guest operating system. Continuing the example, the IOMMU may write the updated data (e.g., a new address of the command buffer tail pointer) to the guest operating system's copy of the command buffer tail pointer register in the IOMMU backing store. In some embodiments, in addition to the guest operating system accessing its copy of the IOMMU MMIO register, the IOMMU itself updates the copy of the IOMMU MMIO register in the backing store. For example, in some embodiments, the IOMMU may update the guest operating system's command buffer head pointer (and / or other command buffer values) after processing commands from the guest command buffer in a first-in-first-out order.

[0019] In some embodiments, virtualization of addresses associated with copies of IOMMU MMIO registers in an IOMMU backing store causes various entities to perform operations to calculate, translate, or otherwise determine the physical address at which the copy of the IOMMU MMIO register is located in the IOMMU backing store. In some of these embodiments, a given guest operating system accesses an IOMMU MMIO register using a corresponding guest virtual address, which is the local address of the IOMMU MMIO register generated or provided by the given guest operating system. The guest virtual address is translated by the processor's memory management unit (MMU) (e.g., using one or more page tables) to an IOMMU MMIO address, i.e., to a system physical address that is within the IOMMU's MMIO aperture / interface in the range used to map the guest copy of the IOMMU MMIO register. Because the IOMMU MMIO address is virtualized for use by multiple guest operating systems, the IOMMU then determines the address of a given copy of an IOMMU MMIO register for a given guest operating system. In this process, the IOMMU first calculates an IOMMU virtual address for a copy of the IOMMU MMIO registers for a given guest operating system based on an identifier for the given guest operating system and the system physical address provided by the MMU, using an algorithm, table, etc. The IOMMU then translates the IOMMU virtual address to a system physical address using one or more page tables, where the copy of the IOMMU MMIO registers for the given guest operating system is stored in the IOMMU backing store.

[0020] In some embodiments, upon detecting an update of data in an IOMMU MMIO register by a guest operating system, the IOMMU performs one or more corresponding processing operations. For example, in some embodiments, in response to detecting that a guest operating system has updated its command buffer tail pointer (i.e., its copy in the backing store) in a corresponding IOMMU MMIO register, the IOMMU retrieves a command from the guest operating system's command buffer and processes the command.

[0021] In some embodiments, the hypervisor emulates certain IOMMU MMIO registers that are not included in the separate copy of the set of IOMMU MMIO registers for the guest operating system stored in the IOMMU backing store. For example, in some embodiments, the hypervisor emulates the IOMMU's IOMMU control MMIO registers, translation table base address MMIO registers, etc. In these embodiments, the hypervisor intercepts guest operating system accesses of the emulated IOMMU MMIO registers and performs the corresponding accesses through the IOMMU.

[0022] In some embodiments, the IOMMU stores copies of information from copies of IOMMU MMIO registers from several separate sets of IOMMU MMIO registers in the IOMMU's local cache memory. For example, the IOMMU may store copies of recently used or frequently used values ​​from each guest operating system's individual IOMMU MMIO registers.

[0023] The IOMMU provides direct access to the buffers and logs in the guest portion of memory by providing a separate copy of the set of IOMMU MMIO registers used to access the buffers and logs in the guest portion of memory. This means that the IOMMU does not need to rely on the hypervisor to handle the buffer and log accesses, as in existing systems. Moving these operations from the hypervisor (implemented in software) to the IOMMU (implemented in hardware) results in faster operations, less memory system bandwidth is required, and less stress is placed on the processor's compute functional blocks, improving the overall performance of the electronic device. Better performance for electronic devices translates into happier users.

[0024] (Electronic Devices) 4 is a block diagram illustrating an electronic device 400 according to some embodiments. As seen in FIG. 4, the electronic device 400 includes a processor 402, a memory 404, a mass storage device 406, input / output (IO) devices 408-412, an input / output (IO) hub 414, and a memory controller 416.

[0025] The processor 402 is a functional block that executes computational operations in the electronic device 400. The processor 402 includes two cores 418-420, each of which includes one or more computational mechanisms, such as a central processing unit (CPU) core, a graphics processing unit (GPU) core, an embedded processor, an application specific integrated circuit (ASIC), and / or other computational mechanisms. The processor 402 also includes a memory management unit (MMU) 422, which is a functional block that executes operations related to address translation (e.g., page table walk, translation lookaside buffer lookup, etc.), memory access protection for memory accesses by the cores 418-420, etc.

[0026] Memory 404 is a functional block that performs memory (e.g., "main" memory) operations within electronic device 400. Memory 404 includes one or more dynamic random access memory (DRAM), double data rate synchronous DRAM (DDR SDRAM), and / or other types of memory circuits that store data and instructions used by other functional blocks within electronic device 400, and control circuitry that handles accessing (e.g., reading, writing, checking, deleting, invalidating, etc.) the data and instructions stored in the memory circuits.

[0027] The mass storage device 406 is a functional block and / or device that performs the operations of a large capacity non-volatile storage element for storing data and instructions used by other functional blocks of the electronic device 400. The mass storage device 406 may be or include a large capacity semiconductor memory (e.g., flash memory, etc.), a disk drive (e.g., hard drive, etc.), an optical drive, etc. Copies of the data and instructions stored in the mass storage device 406 are retrieved and stored in the memory 404 for use by other functional blocks in the electronic device 400. For example, in some embodiments, data and / or instructions are retrieved from the mass storage device 406 in blocks or "pages" of a predetermined size (e.g., 4kB, 2MB, etc.), and the pages are stored in the memory 404 for access by the other functional blocks. Additionally, pages may be newly created in available locations in the memory 404 (e.g., to store computation results).

[0028] The IO devices 408-412 are functional blocks and / or devices that perform corresponding IO operations. The particular nature of the IO operations performed by each of the IO devices 408-412 depends on the nature of the IO device. For example, the IO devices 408-412 can include human interface devices, network interface devices, audio / visual processing or presentation devices, GPUs, sensor devices, disk controllers, peripheral component interface (PCI) devices, universal serial bus (USB) devices, etc., with each IO device performing related operations such as receiving input from a human (e.g., keyboard, mouse, etc.), receiving or transmitting data over a network, etc. The IO devices 408-412 provide data and / or instructions to or consume data and / or instructions from other functional blocks of the electronic device 400. For example, in some embodiments, the IO devices 408-412 access (i.e., read, write, invalidate, etc.) data in memory pages in the guest memory 428 (i.e., portions of memory reserved for a given guest operating system).

[0029] The IO hub 414 is a functional block that performs the operations of an input / output hub that interfaces between the IO devices 408-412 and other functional blocks (e.g., the processor 402, the memory 404, etc.) of the electronic device 400. The operations performed by the IO hub 414 include operations to ensure that communications destined for the IO devices 408-412 reach the intended IO devices, that communications from the IO devices 408-412 reach the other functional blocks properly, that the other functional blocks are secured from unauthorized access by the IO devices 408-412, and vice versa. In some embodiments, the IO hub 414 interfaces and converts or translates related communications between buses that use different communication standards (e.g., between a Peripheral Component Interface Express (PCIe) bus and a HyperTransport link (registered trademark)).

[0030] IO hub 414 includes IOMMU 424, which is a functional block that performs operations to enable IO devices 408-412 to access data and / or instructions in memory 404, communicates with processor 402 (and guest operating systems executed thereby), etc. In these embodiments, when data and instructions are accessed in memory 404 by an IO device (e.g., IO device 408), the IO device sends a memory access request (e.g., a direct memory access request or DMA) to IOMMU 424. IOMMU 424 then sends a corresponding request to memory 404 to fulfill the memory access request. For example, in some embodiments, when data is to be retrieved based on a memory access request, IOMMU 424 retrieves the data from memory 404 (or mass storage device 406 if the data is not present in memory 404) and transfers the data to the requesting IO device. In some embodiments, IOMMU 424 includes page tables, translation lookaside buffers, and / or other functional blocks used to translate the “virtual” or local memory addresses used by IO devices 408-412 into physical addresses in memory 404 where the data is actually located.

[0031] In the described embodiments, IOMMU 424 communicates with guest operating systems executed by cores 418-420 within the virtual machines, and vice versa. For example, in some embodiments, IOMMU 424 (or IO devices 408-412 via IOMMU 424) communicate events and peripheral page requests (PPRs) to the guest operating systems. In these embodiments, IOMMU 424 reports events such as IO page faults (for page table walks on behalf of IO devices 408-412), IOMMU 424 hardware errors, etc. to the guest operating systems via a shared guest event log in memory 404. Additionally, in these embodiments, IOMMU 424 forwards PPRs from peripherals (IO devices) using the well-known Address Translation Services or ATS standard to guest operating systems for memory page provisioning operations (i.e., to perform operations on pages in memory 404 accessible by the guest operating systems) via a shared guest PPR log in memory 404. As another example, in some embodiments, the guest operating system communicates commands to IOMMU 424. In these embodiments, the guest operating system issues commands to IOMMU 424 via a shared guest command buffer in memory 404 to control IOMMU 424 and / or IO devices 408-412, such as wait for completion (which acts as a command barrier to allow previous commands to complete before IOMMU 424 continues), invalidate device table entries, invalidate IOMMU 424 translation lookaside buffer entries, etc.

[0032] In some embodiments, IOMMU 424 provides an interface to guest operating systems, which interface includes memory mapped locations, registers, etc. used to communicate with IOMMU 424. For example, in some embodiments, IOMMU 424 provides a set of memory mapped input / output (MMIO) memory locations to which guest operating systems can write values, which are received by IOMMU 424. In some embodiments, the interface is virtualized; that is, the memory locations, registers, etc. are not used to store the values ​​as expected by the guest operating systems, but instead are simply presented by IOMMU 424. In these embodiments, IOMMU 424 may receive values ​​from guest operating systems over the interface, but uses IOMMU backing store 426 and / or other locations in memory 404 to store separate copies of the values ​​for each guest operating system (e.g., addressed to an IOMMU MMIO address, etc.). Memory accessed by IOMMU 424 to communicate with guest operating systems and other entities (e.g., processor 402, etc.) is described in more detail below.

[0033] 4, IOMMU 424 includes a local cache memory that is used to store copies of data or information for IOMMU 424. For example, in some embodiments, the cache memory is used to store copies of recently or frequently used data from IOMMU backing store 426, such as the set of values ​​and / or individual values ​​therefrom of a given guest operating system's IOMMU MMIO registers. Because the cache memory is smaller than IOMMU backing store 426, it may only have the capacity (i.e., memory locations) to store a portion (and perhaps only a small portion) of the data and information stored in IOMMU backing store 426.

[0034] Guest memory 428 is a portion of memory 404 (e.g., one or more contiguous or non-contiguous pages or blocks of memory) used by a corresponding guest operating system to store data and information used by the guest operating system. In general, guest memory 428 may be used by a guest operating system and / or other entities to store any type of data and information used by the guest operating system and / or other entities. In some embodiments, guest memory 428 is protected and only certain entities are permitted to access guest memory 428. For example, the corresponding guest operating system, a hypervisor, a security processor, and / or an operating system within electronic device 400 may "protect" guest memory 428 by restricting access of guest memory 428 to the corresponding guest operating system and other designated devices and / or functional blocks. In some embodiments, guest memory 428 is encrypted or otherwise rendered inaccessible by undesirable entities. In some embodiments, guest memory 428 is used to store a guest event log, a guest peripheral page request (PPR) log, and a guest command buffer, which are data structures (e.g., tables, lists, etc.) used to communicate between the guest operating system and the IOMMU. The guest event log, guest peripheral page request (PPR) log, and guest command buffer are described in more detail below.

[0035] In some embodiments, communication paths are coupled between various functional blocks of electronic device 400 (e.g., processor 402, memory controller 416, memory 404, etc.), as indicated by arrowed lines between the elements. The communication paths include one or more buses, wires, guides, and / or other connections, possibly along with controllers, fabric elements (e.g., switches, routers, etc.), circuit elements, etc. The communication paths are used to route commands, data, control signals, and / or other information between the functional blocks. For example, in some embodiments, a coherent bus fabric or interconnect is coupled between IO hub 414, processor 402 (e.g., MMU 422), and memory 404. Note that some communication paths within electronic device 400 are not shown in FIG. 4 for clarity.

[0036] In some embodiments, electronic device hardware 310 of Figure 3 includes functional blocks and devices such as processor 402 and memory 404, and IO device hardware 314 includes functional blocks and devices such as IO devices 408-412. In these embodiments, IOMMU 312 of Figure 3 and IOMMU 424 of Figure 4 perform at least some of the same operations.

[0037] Electronic device 400 is shown with a particular number and configuration of elements (e.g., functional blocks and devices, such as processor 402, memory 404, etc.) and communication paths. However, electronic device 400 is simplified for illustrative purposes, and in some embodiments, electronic device 400 has a different number or configuration of elements and / or communication paths. For example, electronic device 400 may include a power subsystem, a display, etc. In general, electronic device 400 includes sufficient elements and communication paths to perform the operations described herein.

[0038] Electronic device 400 can be or can be included in any electronic device that performs computational operations. For example, electronic device 400 can be or can be included in electronic devices such as a desktop computer, a laptop computer, a wearable electronic device, a tablet computer, a smartphone, a server, an artificial intelligence device, a virtual or augmented reality device, a network device, a toy, an audiovisual device, a home appliance, a controller, a vehicle, and / or combinations thereof.

[0039] (Part of memory accessed by IOMMU) In some embodiments, the IOMMU accesses data and information in different portions of memory (e.g., memory 404) to perform the operations described herein. In some of these embodiments, the portions of memory include an IOMMU backing store (e.g., IOMMU backing store 426), guest memory (e.g., guest memory 428), and / or hypervisor memory. FIG. 5 is a block diagram illustrating portions of memory accessed by an IOMMU, according to some embodiments. While FIG. 5 is shown as an example, in some embodiments, the memory and / or different portions of the memory store different types and / or configurations of information. In general, the memory contains sufficient information to enable the operations described herein.

[0040] 5, the IOMMU backing store 500 includes an ID translation table 502. In general, the ID translation table 502 includes information used by the IOMMU to translate or convert guest domain IDs and / or device IDs to host domain IDs and / or device IDs in guest operating system to IOMMU communications, or vice versa. Domain IDs and device IDs are described in more detail in the AMD I / O Virtualization Technology (IOMMU) Specification, rev. 3.00, December 2016, which is incorporated herein by reference as noted above.

[0041] In some embodiments, ID translation table 502 includes separate tables for domain IDs, denoted as domain ID mapping table 504, and for device IDs, denoted as device ID mapping table 506, although separate tables are not required (so that all translations can be included in a single table). Domain ID mapping table 504 includes a set of entries, each of which is used to store an identification or index of a guest domain ID associated or related to a specified host domain ID. Device ID mapping table 506 includes a set of entries, each of which is used to store an identification or index of a guest device ID associated or related to a specified host device ID. During operation, when a guest or host domain ID and / or device ID is translated or translated in a communication, the IOMMU performs a lookup in ID translation table 502 (i.e., domain ID mapping table 504 and / or device ID mapping table 506) to obtain the corresponding translation or translation.

[0042] IOMMU backing store 500 also includes guest control 508. Generally, guest control 508 includes copies of values ​​stored in or from interface and control registers for guest operating systems in the electronic device. For each supported guest operating system, guest control 508 includes a copy of the guest interface registers and / or guest operating system control registers (or at least the values ​​therein) that control the interaction between the IOMMU and that guest operating system. For example, guest control 508 may include, for each guest operating system, a map control register that is used to communicate domain ID and / or device ID mapping for the guest operating system to the IOMMU.

[0043] IOMMU backing store 500 further includes guest memory mapped input / output (MMIO) 510. Generally, guest MMIO 510 includes pointers and control information used to access buffers and logs (e.g., guest command buffers, guest event logs, and guest PPR logs) for guest operating systems in the guest portion of memory 404 (e.g., guest memory 428). More specifically, guest MMIO 510 includes, for each supported guest operating system, a copy of values ​​used to control access of buffers and logs in the guest portion of memory 404. For example, in some embodiments, the IOMMU may include two N Supports guest operating systems (capable of interacting with, communicating with, etc.), where N=10, 16, or another value, and Guest MMIO 510 is up to 2 N, one for each supported guest operating system. In the described embodiment, the values ​​used to control access are similar to the values ​​stored in the IOMMU MMIO registers of the existing device, but a separate set of values ​​is kept for each supported guest operating system and points to that guest operating system's guest portion of memory 404 (rather than a single copy in the IOMMU on the existing device).

[0044] FIG. 6 is a block diagram illustrating values ​​stored in guest MMIO 510, according to some embodiments. In the example of FIG. 6, values ​​for a single complete set of IOMMU MMIO registers for a given guest operating system are shown along with partial values ​​for two adjacent sets of IOMMU MMIO registers above and below the single complete set of values. FIG. 6 is shown in this manner to illustrate that, as discussed above, in some embodiments, IOMMU backing store 426 includes multiple separate sets of values, each set of values ​​associated with a given guest operating system. FIG. 6 is shown by way of example, and in some embodiments, guest MMIO 510 stores different values ​​or different configurations of values. In general, guest MMIO 510 and / or another entity stores sufficient information to access buffers and logs in the guest portion of memory, as described herein.

[0045] The values ​​in each set of guest MMIO 510 values ​​can be grouped into values ​​generally associated with a guest command (CMD) buffer, a guest event log, and a guest PPR log for the guest operating system. For a guest command buffer, the values ​​include a command tail pointer 600, which is a pointer or other reference that indicates the end, tail, or most recently written entry of the guest command buffer in the corresponding guest portion of memory 404. In other words, the command tail pointer 600 holds a pointer or reference, such as a memory address (e.g., some or all of the bits of the physical address of the guest portion of memory 404), that indicates where the tail or most recently written entry of the command buffer is. The guest command buffer values ​​also include a command head pointer 602, which is a pointer or other reference that indicates the head or base of the command buffer, i.e., where the command buffer starts and / or where the buffered commands start in the corresponding guest portion of memory 404. The guest command buffer values ​​further include a command length 604, which is a value that indicates the current or maximum size of the command buffer, such as in number of entries, number of bytes, etc. The guest command buffer value further includes command controls 606, which is a set or sequence of bits that includes several bits (or combinations thereof) that indicate the configuration of the command buffer of the guest operating system and / or the corresponding guest portion of memory 404. For example, in some embodiments, command controls 606 includes bits that indicate whether a particular command buffer-related interrupt is enabled, whether command buffering or processing is enabled (or disabled / stopped), and what types of commands are or can be present.For example, in some embodiments, command controls 606 include command buffer control values ​​similar to those described in the AMD I / O Virtualization Technology (IOMMU) Specification, rev. 3.00, which is incorporated herein by reference, such as CmdWaitInt, CmdBufRun, CmdWaitInteEn, CmdBufEn, and / or other values, as described above.

[0046] In some embodiments, the command buffer is implemented as a ring buffer by using a command head pointer 602 to point to the command buffer being read and / or a command tail pointer 600 that points to the end / last added entry / location of the command buffer (which can be the same entry / location if only one command is stored in the command buffer). In these embodiments, as a command is read from an entry and processed, the command head pointer 602 is advanced by one entry until the command head pointer 602 and command tail pointer 600 point to the same entry or an adjacent entry. In some of these embodiments, the command length 604 stores the maximum length of the command buffer. Implementing ring buffers using pointers is commonly known in the art and therefore will not be described in detail herein.

[0047] For the event log, the guest MMIO 510 values, i.e., event tail pointer 608, event head pointer 610, event length 612, and event control 614, are similar in function to those described above for the command buffer, although the values ​​are used to access the event log in the corresponding guest portion of memory 404. The same applies to the PPR log, where the guest MMIO 510 values, i.e., PPR tail pointer 616, PPR head pointer 618, PPR length 620, and PPR control 622, are similar in function to those described above for the command buffer, although the values ​​are used to access the PPR log in the corresponding guest portion of memory 404.

[0048] In some embodiments, fewer than the supported number of guest operating systems (and possibly much fewer) may be running on electronic device 400 at any one time, and thus in these embodiments, IOMMU backing store 500 is dynamically adjusted to include sufficient space to store guest MMIO 510, etc. That is, as guest operating systems are initialized, the hypervisor and / or another entity may allocate, add, or activate space in IOMMU backing store 500 (i.e., guest MMIO 510) to store values ​​of IOMMU MMIO registers for the guest operating systems.

[0049] In some embodiments, the hypervisor performs at least some initialization operations on the IOMMU backing store 500. For example, in some embodiments, the hypervisor allocates memory, e.g., contiguous or distributed pages of memory, in memory 404 to store the IOMMU backing store. As described above, memory 404 is general-purpose memory in electronic device 400 used by various functional blocks (e.g., cores 418-420, etc.) to store data and information, and is not merely local memory in the IOMMU. Thus, this operation includes the hypervisor allocating space in the "main" memory of electronic device 400 to store the IOMMU backing store. As another example, in some embodiments, the hypervisor writes initial values, via the IOMMU, to copies of IOMMU MMIO registers in the backing store of each active guest operating system. Thus, the hypervisor writes the initial values ​​of pointers and control values ​​of each active guest operating system to their respective copies of IOMMU MMIO registers in the IOMMU backing store, such as at the start of the guest operating system.

[0050] In some embodiments, only a subset of the available IOMMU MMIO registers are included in the copy of the IOMMU MMIO registers in the IOMMU backing store. In these embodiments, other registers may be provided by the IOMMU itself. For example, in some embodiments, registers in the IOMMU that store IOMMU control values ​​(e.g., enable / disable the IOMMU, etc.), base addresses of page tables, etc. are provided by the IOMMU. In general, IOMMU MMIO registers that are not used to access some buffers and logs of memory in the guest operating system are not shown as copies, but instead a single copy of each register is provided by the IOMMU. In some of these embodiments, the hypervisor emulates these IOMMU registers for the guest operating system, but accesses are received and processed by the IOMMU for registers in the IOMMU.

[0051] Returning to FIG. 5 , guest memory 512 includes a guest event log 514, a guest peripheral page request (PPR) log 516, and a guest command buffer 518 for the guest operating system. In general, guest event log 514, guest PPR log 516, and guest command buffer 518 are memory structures (e.g., lists, tables, buffers, etc.) used to store corresponding events, PPR requests, and commands for access by the IOMMU and / or the guest operating system. During operation, the IOMMU communicates events and PPRs to the guest operating system via corresponding logs in guest event log 514 and guest PPR log 516 in guest memory 512. Additionally, the guest operating system communicates commands to the IOMMU via corresponding command buffers in guest command buffer 518 in guest memory 512.

[0052] In some embodiments, each guest operating system active on electronic device 400 is associated with a corresponding separate guest portion of memory (i.e., some number of pages in memory 404) that includes a guest event log, a peripheral page request log, and a guest command buffer used by that guest operating system and accessible by the IOMMU. This is illustrated in FIG. 5 as additional guest memories 520-522 behind guest memory 512.

[0053] The hypervisor memory 524 includes a device table 526. In general, the device table 526 is a table in which device-related information is stored about devices (which may be real / physical devices or virtual devices) associated with and / or coupled to an electronic device. The device table 526 includes a set of entries, each of which can be used to store information about the corresponding device, such as pointers to page tables and interrupt tables, control and configuration values, function indicators, mode indicators, domain IDs, security information and settings, etc. Additionally, in the described embodiment, unlike existing device tables, each entry in the device table 526 includes a device ID and a guest identifier for a guest operating system that communicates with, participates in, or is otherwise associated with the device. During operation, in addition to using the device table to determine information about the device, the IOMMU uses the device ID and / or the guest identifier to translate or convert the guest device ID to a host device ID.

[0054] In some embodiments, some / all of IOMMU backing store 500, guest memory 512, and hypervisor memory 524 are not contiguous, but instead are stored in different regions or locations of memory. For example, the base address of guest event log 514 (and thus the guest event log itself) may be located in memory separate from guest PPR log 516. Thus, guest event log 514 may not be adjacent to guest PPR log 516 as shown in FIG. 5.

[0055] In some embodiments, the IOMMU includes a private address map that contains pointers, references, and / or other indicia to the locations in memory of various data and information in memory that are accessed by the IOMMU. For example, the IOMMU private address map may include pointers to base addresses in memory for guest event log 514, guest PPR log 516, etc. In these embodiments, before accessing data and information in memory, the IOMMU may perform a lookup in the private address map for the location of the data and information and may also perform a translation using page tables or the like of these addresses before use.

[0056] In some embodiments, IOMMU backing store 500 and / or portions thereof (such as control bits) may be accessed by other entities of electronic device 400 via the IOMMU (e.g., by sending requests to the IOMMU) or may not be accessible by other entities. For example, at least some of the data and information in IOMMU backing store 500 may be accessed by other entities via writes to and reads from corresponding IOMMU MMIO registers.

[0057] (IOMMU and guest operating system communication) In the described embodiment, the IOMMU (e.g., IOMMU 424) handles communication between the IOMMU (or IO devices served by it) and the guest operating system. FIG. 7 is a block diagram illustrating communication between guest operating system 700 and IOMMU 702, as handled by IOMMU 702, according to some embodiments. While some elements are shown in a particular configuration in FIG. 7, other embodiments use a different number or configuration of elements. In general, in the described embodiments, IOMMU 702 includes or has access to sufficient elements to enable the operations described herein. In FIG. 7, some elements are shown as dotted / dotted. These elements are logs, buffers, etc. that are stored in memory (e.g., in IOMMU backing store 500, in guest memory 512, etc.) and accessed by IOMMU 702, guest operating system 700, and / or other entities using typical memory access techniques. In some embodiments, guest operating system 700, IOMMU 702, and hypervisor 704 are configured similarly to guest operating system 302, IOMMU 312, and hypervisor 306 of FIG. 3, although this is not a requirement.

[0058] As seen in FIG. 7, unlike that shown in FIG. 2 for the existing system, in the described embodiment, the IOMMU 702 and guest operating system 700 communicate with each other more directly. In other words, the IOMMU 702 and guest operating system 700 communicate with each other via the guest event log 514, guest PPR log 516, and guest command buffer (BUFF) 518 in memory (i.e., in the guest portion of memory for the guest operating system 700 (e.g., guest memory 428)). Additionally, the guest operating system 700 and the IOMMU 702 use guest control 508 and guest MMIO 510 to direct how the communication is to be performed. For example, in some embodiments, the IOMMU 702 uses pointers in the guest MMIO 510 to determine the location in memory of the guest event log 514, guest command buffer 518, and guest PPR log 516 for the guest operating system 700. The hypervisor 704 does not intervene or is otherwise not involved in some or all of the operations to complete these communications. For example, hypervisor 704 does not perform operations such as translating domain IDs and device IDs for these communications, accessing pointers in guest MMIO 510, and / or accessing buffers and logs in the guest portion of memory. Instead, IOMMU 702 performs these operations. Because IOMMU 702 translates domain IDs and device IDs and obtains information from guest MMIO 510, etc., the described embodiments avoid using hypervisor 704 to handle at least some of the communications between guest operating system 700 and IOMMU 702. This means that communications are completed more quickly, reducing the load on processor 402, memory 404, etc.

[0059] In operation, using the command as an example, guest operating system 700 writes an invalidate_IOMMU_pages command to guest command buffer 518, which causes IOMMU 702 to invalidate a range of entries in the IOMMU translation cache as specified by the domain ID of the command. In other words, the guest operating system performs a memory write to the corresponding guest portion of memory to update the next open / available entry in guest command buffer 518 to include data for the invalidate_IOMMU_pages command (i.e., bits representing the command). Guest operating system 700 then sends a write command to the IOMMU to update (e.g., advance, increment, etc.) the command buffer tail pointer (e.g., command tail pointer 600) of the corresponding IOMMU MMIO register to indicate that guest operating system 700 has written the command to the command buffer. IOMMU 702 detects guest operating system 700 writes of the command buffer tail pointer, e.g., via monitoring writes to addresses in the corresponding guest command buffer, detecting changes in the value of the buffer tail pointer, receiving write commands from guest operating system 700, etc. Upon detecting a command buffer tail pointer write, IOMMU 702 uses the value of the command buffer head pointer (e.g., command head pointer 602) to retrieve the next command from the command buffer in the guest portion of memory and prepares to process the command (e.g., by substituting the host domain ID associated with the guest domain ID in the command). IOMMU 702 then processes the command, which causes IOMMU 702 to invalidate the range of entries in IOMMU 702's translation cache that are indicated by the host domain ID.IOMMU 702 performs at least some similar operations for IOMMU 702 writes to guest PPR log 516 and guest event log 514, but in the reverse order: IOMMU 702 writes these logs and guest operating system 700 reads them.

[0060] Although hypervisor 704 is not involved in certain portions of the communication between guest operating system 700 and IOMMU 702, such as translating guest domain IDs to host domain IDs, hypervisor 704 and guest operating system 700 and / or IOMMU 702 may separately exchange communications related to communication between guest operating system 700 and IOMMU 702, or hypervisor 704 may be otherwise involved in ensuring that communications are properly handled by guest operating system 700 and / or IOMMU 702. For example, hypervisor 704 may directly (e.g., via communications) or indirectly (e.g., via snooping memory accesses) determine that IOMMU 702 or guest operating system 700 has performed a specified operation (e.g., writing to a buffer or log) and perform the operation, such as signaling an interrupt to guest operating system 700 and / or IOMMU 702, updating a shared memory location that serves as a flag, etc. As noted above, hypervisor 704 may also initialize IOMMU backing stores, etc.

[0061] (Process for using IOMMU MMIO register values) In the described embodiment, an IOMMU (e.g., IOMMU 702) performs operations to provide a virtual copy of the IOMMU MMIO registers to a guest operating system (e.g., guest operating system 700). As described above, the operations include accessing, on behalf of the guest operating system, corresponding copies of the IOMMU MMIO registers stored in an IOMMU backing store. FIG. 8 is a flow chart illustrating a process by which the IOMMU accesses copies of the IOMMU MMIO registers in the IOMMU backing store on behalf of a guest operating system, according to some embodiments. It should be noted that the operations illustrated in FIG. 8 are provided as general examples of operations performed by some embodiments. Operations performed by other embodiments include different operations, operations performed in a different order, and / or operations performed by different entities or functional blocks.

[0062] The operations shown in FIG. 8 for accessing a copy of an IOMMU MMIO register are general in scope and relate to various types of accesses, e.g., read, write, invalidate, etc. Specific examples shown in FIGS. 9-10 include a guest operating system writing a copy of an IOMMU MMIO register in FIG. 9 and a guest operating system reading a copy of an IOMMU MMIO register in FIG. 10.

[0063] 8 begins when the IOMMU receives a communication from a guest operating system to access data in a given IOMMU MMIO register (step 800). The access may be a read of the data in the IOMMU MMIO register, and thus the communication is a read request, a write of the data in the IOMMU MMIO register, and thus the communication is a write request, and / or other accesses, such as an invalidation. For example, the IOMMU may receive a communication from a guest operating system requesting that certain data be written to a command buffer tail pointer (such as command tail pointer 600) to initialize or update the command buffer tail pointer.

[0064] The IOMMU performs a corresponding access to data in the copy of the given IOMMU MMIO register associated with the guest operating system in the IOMMU backing store (step 802). Recall that the IOMMU virtualizes the IOMMU MMIO registers; that is, it presents the guest operating systems (and other entities) with the illusion that they are accessing actual MMIO registers in the IOMMU, but the IOMMU actually uses separate copies of the IOMMU MMIO registers stored in the IOMMU backing store for each supported guest operating system. Thus, this operation involves determining which copy of the IOMMU MMIO register the IOMMU has access to in the backing store and performing the access.

[0065] 9 is a flow chart illustrating the process by which a guest operating system writes to and the IOMMU reads copies of IOMMU MMIO registers in an IOMMU backing store, according to some embodiments. Note that the operations illustrated in FIG. 9 are provided as general examples of operations that may be performed by some embodiments. Operations performed by other embodiments include different operations, operations performed in a different order, and / or operations performed by different entities or functional blocks.

[0066] 9 begins when a guest operating system (e.g., guest operating system 700) writes a command to a command buffer (e.g., guest command buffer 518) in a guest portion of memory (e.g., guest memory 428) (step 900). For example, in some embodiments, the guest command buffer is a circular buffer in the guest portion of memory that contains several entries, and this operation includes the guest operating system writing the command (i.e., a sequence of bits that represent the command) to the next available entry in the guest command buffer.

[0067] As the guest operating system adds commands to the guest command buffer that require processing by an IOMMU (e.g., IOMMU 702), the guest operating system notifies the IOMMU of the command. More specifically, the guest operating system sends a write request to update the command buffer tail pointer, and the write request is directed to the guest virtual address of the IOMMU MMIO register where the command buffer tail pointer is stored (step 902). In the described embodiment, the guest operating system uses local or "virtual" addresses (it may not know the actual IOMMU addresses) to access the IOMMU MMIO registers. The guest virtual addresses are translated by a memory management unit (MMU) of the processor running the guest operating system (e.g., by performing a page table of page table walk of the guest operating system, etc.) to the system physical address of the IOMMU where the MMIO registers are located (i.e., the IOMMU MMIO address). As described above, because the IOMMU virtualizes the IOMMU MMIO registers, the system physical address used by the MMU is not the address where the guest operating system's copy of the IOMMU MMIO register is located, but rather the address of the IOMMU's interface / aperture as seen by the IOMMU as an access of the MMIO register. Thus, following translation at the MMU, the MMU forwards the write request to the IOMMU at the IOMMU MMIO address (i.e., the system physical address) associated with the guest virtual address (step 904).

[0068] Because the IOMMU MMIO address is simply an address provided by the IOMMU to receive access requests from the guest operating system, the IOMMU also performs a translation based on the write request to determine a physical address in memory where a copy of the guest operating system's command buffer tail pointer is stored (step 906). During this operation, the IOMMU uses the guest operating system's identity to determine the physical address in memory where the copy of the IOMMU MMIO registers is accessed in the IOMMU backing store. In this process, the IOMMU first calculates, using an algorithm, table, etc., an IOMMU virtual address of the copy of the IOMMU MMIO registers for the guest operating system based on the guest operating system's identifier and the system physical address provided by the MMU. The IOMMU then uses one or more page tables to translate the IOMMU virtual address to the system physical address where the copy of the guest operating system's IOMMU MMIO registers is stored in the IOMMU backing store.

[0069] The IOMMU then stores the data from the write request at a physical address in memory, thereby updating the guest operating system's copy of the command buffer tail pointer (step 908). In other words, the IOMMU stores data, such as one or more bits of the updated address of the command buffer tail pointer, an entry identifier, an execution count, etc., in the memory location where the guest operating system's associated copy of the command buffer tail pointer is saved in the IOMMU backing store. This update causes the command buffer tail pointer to directly or indirectly indicate that a command has been written to the guest command buffer, and is therefore awaiting processing by the IOMMU. In some embodiments, the IOMMU, the guest operating system, and / or another entity sets other pointers or indicators to indicate that a command is awaiting processing in the guest command buffer, or that the guest operating system has provided a command. For example, in some embodiments, the IOMMU includes a set of command waiting bits, one for each supported guest operating system, and the command waiting bits are set (or cleared) for the guest operating system to indicate that a command is awaiting processing in the guest command buffer.

[0070] Upon detecting a write request (or otherwise determining that a command is waiting to be processed), the IOMMU performs one or more subsequent operations to process the command in the guest command buffer using data from its copy of the command buffer head pointer (e.g., command head pointer 602) (step 910). For example, in some embodiments, the value of the copy of the command buffer head pointer stores the address of the location in the guest portion of memory where the next entry in the guest command buffer will be located and the IOMMU uses the address directly or indirectly to retrieve the command from the guest command buffer before processing the command.

[0071] 10 is a flow chart illustrating the process by which an IOMMU writes to and a guest operating system reads from copies of IOMMU MMIO registers in an IOMMU backing store, according to some embodiments. Note that the operations illustrated in FIG. 10 are provided as general examples of operations performed by some embodiments. Operations performed by other embodiments include different operations, operations performed in a different order, and / or operations performed by different entities or functional blocks.

[0072] 10 begins when an IOMMU (e.g., IOMMU 702) writes an event to a guest event log (e.g., guest event log 514) in a guest portion of memory for a guest operating system (e.g., guest memory 428) (step 1000). For example, in some embodiments, the guest event log is a circular buffer in the guest portion of memory that contains several entries, and this operation involves the IOMMU writing the event (i.e., a sequence of bits that represent the event) to the next available entry in the guest event log.

[0073] In some embodiments, not shown in FIG. 10 for brevity, the IOMMU first obtains information about the guest event log from a copy of the event log tail pointer and / or other copy of the IOMMU MMIO pointer associated with the guest operating system in the IOMMU backing store. The IOMMU then uses this information to perform step 1000. For example, in some embodiments, the IOMMU uses a direct or indirect indication (e.g., a physical address, etc.) of the location of the guest event log (or an available entry therein) obtained from the guest operating system's copy of the event log tail pointer in the IOMMU backing store to write an event to the guest event log. To obtain information about the guest event log, in some embodiments, the IOMMU determines the physical address of the copy of the event log tail pointer and / or other copy of the IOMMU MMIO pointer in a manner similar to step 1002, and then uses the physical address to obtain the information.

[0074] The IOMMU notifies the guest operating system of the event because it has added an event to the guest event log that requires processing by the guest operating system. In some embodiments, notifying the guest operating system includes both updating the guest operating system's copy of the event log tail pointer in the IOMMU backing store and sending an interrupt to the guest operating system to notify the guest operating system. Thus, the IOMMU determines the physical address of the guest operating system's copy of the event log tail pointer in the IOMMU backing store (step 1002). During this operation, the IOMMU determines the address in physical memory using the guest operating system's ID indicating which copy of the IOMMU MMIO register is accessed in the IOMMU backing store and one or more IOMMU private address tables and / or page tables. The IOMMU then stores the data to update the guest operating system's copy of the event log tail pointer at the physical address (step 1004). In other words, the IOMMU stores data, such as one or more bits of the updated address of the event log tail pointer, an entry identifier, an execution count, etc., in the memory location where a copy of the event log tail pointer associated with the guest operating system is saved in the IOMMU backing store. This update causes the event log tail pointer to directly or indirectly indicate that an event has been written to the event log and is therefore awaiting processing by the guest operating system.

[0075] The IOMMU also sends an interrupt to the guest operating system, the interrupt indicating that an event is waiting in the guest event log, step 1006. In this operation, the IOMMU may use an interrupt mechanism whereby the interrupt is passed between the IOMMU and the guest operating system, such as through a virtual advanced programmable interrupt controller (vAPIC) associated with the guest operating system.

[0076] In response to receiving the interrupt, the guest operating system sends a read request to the IOMMU to read data from the event log head pointer (e.g., event head pointer 610), the read request being sent to the guest virtual address of the IOMMU MMIO register where the event log head pointer is stored (step 1008). In the described embodiment, the guest operating system uses a local or "virtual" address to access the IOMMU MMIO register (it may not be aware of the actual and / or virtual IOMMU address). The guest virtual address is translated by a memory management unit (MMU) of the processor executing the guest operating system to the system physical address of the IOMMU where the MMIO register is located (i.e., the IOMMU MMIO address) (e.g., by performing a page table of page table walk of the guest operating system, etc.). As noted above, because the IOMMU virtualizes the IOMMU MMIO registers, the system physical address used by the MMU is the address of the IOMMU's interface / aperture as seen by the IOMMU as accessing the MMIO register, not the address where the guest operating system's copy of the IOMMU MMIO register is located. Thus, following the translation in the MMU, the MMU forwards the read request to the IOMMU at the IOMMU MMIO address (ie, the system physical address) associated with the guest virtual address (step 1010).

[0077] Because the IOMMU MMIO address is simply an address provided by the IOMMU to receive access requests from the guest operating system, the IOMMU also performs a translation based on the read request to determine a physical address in memory where the guest operating system's copy of the event log head pointer is stored (step 1012). During this operation, the IOMMU determines the physical address in memory using the guest operating system's ID, which indicates which copy of the IOMMU MMIO register is accessed in the IOMMU backing store. In this process, the IOMMU first calculates an IOMMU virtual address of the guest operating system's copy of the IOMMU MMIO register using an algorithm, table, etc., based on the guest operating system's ID and the system physical address provided by the MMU. The IOMMU then uses one or more page tables to translate the IOMMU virtual address to the system physical address where the guest operating system's copy of the IOMMU MMIO register is stored in the IOMMU backing store.

[0078] The IOMMU then reads the data for the read request from the memory location of the physical address in memory (step 1014). In other words, the IOMMU reads data such as one or more bits of the address of the event log head pointer, an entry identifier, an execution count, etc., at the memory location where a copy of the event log head pointer associated with the guest operating system is saved in the IOMMU backing store. The event log head pointer directly or indirectly indicates the next event to be written to the guest event log that is waiting for processing by the guest operating system. In some embodiments, the IOMMU, the guest operating system, and / or another entity sets other pointers or indicators to indicate that an event is waiting for processing in the guest event log or that the IOMMU has provided an event. For example, in some embodiments, the guest operating system and / or hypervisor includes a set of event waiting bits, one for each supported guest operating system, and the event waiting bit is set (or cleared) for the guest operating system to indicate that an event is waiting for processing in the guest event log.

[0079] After reading the data from the event log head pointer, the IOMMU transmits the data back to the guest operating system (step 1016). The guest operating system then uses the data to perform one or more subsequent actions to process the events in the guest event log (step 1018). For example, in some embodiments, the guest operating system's copy of the event log head pointer stores the address of the location in the guest portion of memory where the event log entries are located, and the guest operating system uses that address directly or indirectly to retrieve the events from the guest event log before processing the events.

[0080] In some embodiments, the electronic device (e.g., electronic device 400 and / or portions thereof) uses code and / or data stored in a non-transitory computer-readable storage medium to perform some or all of the operations described herein. More specifically, the electronic device reads the code and / or data from the computer-readable storage medium and executes the code and / or uses the data in performing the described operations. The computer-readable storage medium may be any device, medium, or combination thereof that stores code and / or data used by the electronic device. For example, the computer-readable storage medium may include, but is not limited to, volatile and / or non-volatile memory, including flash memory, random access memory (e.g., eDRAM, RAM, SRAM, DRAM, DDR4 SDRAM, etc.), read-only memory (ROM), and / or magnetic or optical storage media (e.g., disk drives, magnetic tapes, CDs, DVDs, etc.).

[0081] In some embodiments, one or more hardware modules perform the operations described herein. For example, the hardware modules may include, but are not limited to, one or more processors / cores / central processing units (CPUs), application specific integrated circuits (ASICs) chips, neural network processors or accelerators, field programmable gate arrays (FPGAs), computational units, embedded processors, graphics processors (GPUs) / graphics cores, pipelines, accelerated processing units (APUs), sparsity monitors, functional blocks, and / or other programmable logic devices. When such hardware modules are activated, the hardware modules perform some or all of the operations. In some embodiments, the hardware modules include one or more general purpose circuits configured to perform the operations by executing instructions (program code, firmware, etc.).

[0082] In some embodiments, data structures representing some or all of the structures and mechanisms described herein (e.g., electronic device 400, IOMMU 424, and / or portions thereof) are stored in a non-transitory computer-readable storage medium, including a database or other data structure, that can be read by the electronic device and used directly or indirectly to manufacture hardware including the structures and mechanisms. For example, the data structure may be a behavioral or register transfer level (RTL) description of the hardware functionality in a high-level design language (HDL) such as Verilog or VHDL. The description may be read by a synthesis tool, which can synthesize the description to generate a netlist from a synthesis library that includes a list of gates / circuit elements that represent the functionality of the hardware including the structures and mechanisms described above. The netlist may then be placed and routed, and a data set may be generated that describes the geometry to be applied to a mask. The mask may then be used in various semiconductor manufacturing steps to manufacture one or more semiconductor circuits (e.g., integrated circuits) corresponding to the structures and mechanisms described above. Alternatively, the database on the computer accessible storage medium may be a netlist (with or without a synthesis library) or a data set or Graphical Data System (GDS) II data, as appropriate.

[0083] In this specification, variables or unspecified values ​​(i.e., general descriptions of values ​​without specific instances of the values) are represented by letters such as N. Similar letters may be used elsewhere in this description, but as used herein, the variables and unspecified values ​​in each instance are not necessarily the same, i.e., there may be different variable quantities and values ​​for some or all of the general variables and unspecified values. In other words, N and other letters used to represent variables and unspecified values ​​in this description are not necessarily related to each other.

[0084] As used herein, the phrase "et cetra" or "etc." is intended to present the equivalent of "and / or," i.e., "at least one" of the elements in the list to which "etc." pertains. For example, in the sentence "the electronic device performs a first operation, a second operation, etc.", the electronic device performs at least one of the first operation, the second operation, and other operations. Moreover, the elements in the list to which "etc." pertains are merely examples in a set of examples, and at least some of the examples may not appear in some embodiments.

[0085] The foregoing descriptions of the embodiments have been presented for purposes of illustration and description only. They are not intended to be exhaustive or to limit the embodiments to the precise forms disclosed. Accordingly, many modifications and variations will be apparent to those skilled in the art. Moreover, the above disclosure is not intended to limit the embodiments. The scope of the embodiments is defined by the appended claims.

Claims

1. 1. An electronic device comprising: a processor running a guest operating system; an input / output memory management unit (IOMMU); a main memory that stores an IOMMU backing store, the IOMMU backing store including a separate copy of a set of IOMMU memory-mapped input / output (MMIO) registers for each guest operating system in a set of supported guest operating systems; The IOMMU includes: receiving a communication from the guest operating system to access data in a predetermined IOMMU MMIO register; performing a corresponding access to data in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system; 4. The method of claim 3, Electronic devices.

2. Receiving a communication from the guest operating system to access data in a predetermined IOMMU MMIO register, receiving the communication from a memory management unit (MMU) of the processor, the MMU receiving the communication from the guest operating system and forwarding the communication to the IOMMU at an IOMMU MMIO address associated with the given IOMMU MMIO register; The electronic device of claim 1 .

3. accessing the data includes storing the data in the predetermined IOMMU MMIO register; The IOMMU includes: determining a physical address within the IOMMU backing store where a copy of the given IOMMU MMIO register is located based on the IOMMU MMIO address using a domain identifier associated with the guest operating system and one or more translation tables; storing data in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system at the physical address; 4. The method of claim 3, The electronic device of claim 2.

4. The IOMMU includes: Detecting a communication that causes data to be stored in a copy of the given IOMMU MMIO register in the IOMMU backing store; responsive to detecting said communication, performing one or more subsequent processing operations using data from a copy of said given IOMMU MMIO register in said IOMMU backing store; [0023] The electronic device of claim 3.

5. accessing the data includes reading data from the predetermined IOMMU MMIO register; The IOMMU includes: determining a physical address within the IOMMU backing store where a copy of the given IOMMU MMIO register is located based on the IOMMU MMIO address using a domain identifier associated with the guest operating system and one or more translation tables; reading data from the physical address in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system; returning the data to the guest operating system; and [0023] The electronic device of claim 2.

6. The IOMMU stores information in the predetermined IOMMU MMIO register in the IOMMU backing store as: determining a physical address within the IOMMU backing store at which a copy of the given IOMMU MMIO register is located using a domain identifier associated with the guest operating system and one or more translation tables; storing data in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system at the physical address; configured to update by The electronic device of claim 1.

7. Each copy of the set of IOMMU MMIO registers in the IOMMU backing store includes: For each guest operating system, Guest operating system buffer and log pointers; control fields associated with said buffers and logs of a guest operating system; a memory location for storing The electronic device of claim 1 .

8. The processor executes a hypervisor; The hypervisor is During an initialization operation of the IOMMU backing store, allocating contiguous or distributed memory pages within the main memory for use in storing the IOMMU backing store. The electronic device of claim 1 .

9. The hypervisor is emulating, for the guest operating system, at least some IOMMU MMIO registers that are not included in a set of corresponding IOMMU MMIO registers for the guest operating system in the IOMMU backing store; accessing information in an emulated IOMMU MMIO register via said IOMMU; The electronic device of claim 8.

10. The IOMMU MMIO registers emulated by the hypervisor include a translation table base address and an IOMMU control register.

10. The electronic device of claim 9.

11. A cache memory in the IOMMU is provided, the IOMMU caches copies of information in the IOMMU MMIO registers from a portion of each copy of the set of IOMMU MMIO registers; The electronic device of claim 1 .

12. 1. A method of providing a copy of an IOMMU memory mapped input / output (MMIO) register to a guest operating system of an electronic device having a processor that executes the guest operating system, an input / output memory management unit (IOMMU), and a main memory that stores an IOMMU backing store, the method comprising: the IOMMU backing store includes a separate copy of the set of IOMMUMMIO registers for each guest operating system in a set of supported guest operating systems; The method comprises: the IOMMU receiving a communication from the guest operating system accessing data in a predetermined IOMMU MMIO register; and performing a corresponding access to data in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system. method.

13. Receiving a communication from the guest operating system to access data in the predetermined IOMMU MMIO register, receiving the communication from a memory management unit (MMU) of the processor, the MMU receiving the communication from the guest operating system and forwarding the communication to the IOMMU at an IOMMU MMIO address associated with the given IOMMU MMIO register; 13. The method of claim 12.

14. accessing the data includes storing the data in the predetermined IOMMU MMIO register; The method comprises: the IOMMU using a domain identifier associated with the guest operating system and one or more translation tables to determine a physical address within the IOMMU backing store where a copy of the given IOMMU MMIO register is located based on the IOMMU MMIO address; the IOMMU storing data in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system at the physical address.

14. The method of claim 13.

15. detecting a communication that causes the IOMMU to store data in a copy of the given IOMMU MMIO register in the IOMMU backing store; and in response to detecting the communication, performing one or more subsequent processing operations using data from a copy of the predetermined IOMMU MMIO register in the IOMMU backing store.

15. The method of claim 14.

16. accessing the data includes reading data from the predetermined IOMMU MMIO register; The method comprises: the IOMMU using a domain identifier associated with the guest operating system and one or more translation tables to determine a physical address within the IOMMU backing store where a copy of the given IOMMU MMIO register is located based on the IOMMU MMIO address; the IOMMU reading data from the physical address in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system; the IOMMU returning the data to the guest operating system.

14. The method of claim 13.

17. The IOMMU reads information in the predetermined IOMMU MMIO register in the IOMMU backing store, determining a physical address within the IOMMU backing store at which a copy of the given IOMMU MMIO register is located using a domain identifier associated with the guest operating system and one or more translation tables; storing data in a copy of the given IOMMU MMIO register in the IOMMU backing store associated with the guest operating system at the physical address; including updating by 13. The method of claim 12.

18. Each copy of the set of IOMMU MMIO registers in the IOMMU backing store includes: For each guest operating system, Guest operating system buffer and log pointers; control fields associated with said buffers and logs of a guest operating system; a memory location for storing 13. The method of claim 12.

19. The processor executes a hypervisor; The method comprises: the hypervisor, during an initialization operation of the IOMMU backing store, allocating contiguous or distributed memory pages within the main memory for use in storing the IOMMU backing store; 13. The method of claim 12.

20. the hypervisor emulating, for the guest operating system, at least some IOMMU MMIO registers that are not included in the guest operating system's set of corresponding IOMMU MMIO registers in the IOMMU backing store; and the hypervisor accessing emulated IOMMU MMIO register information via the IOMMU.

20. The method of claim 19.

21. The IOMMU MMIO registers emulated by the hypervisor include a translation table base address and an IOMMU control register.

21. The method of claim 20.

22. the IOMMU comprises a cache memory; The method comprises: the IOMMU caching copies of information in the IOMMU MMIO registers from a portion of each copy of the set of IOMMU MMIO registers; 13. The method of claim 12.

Citation Information

Patent Citations

  • DMA window for lpar environment for enabling a plurality of IOA for one terminal bridge by using device arbitration level

    JP2002318701A

  • Information processor, process control method and computer program

    JP2006350531A

  • IOMMU with two-level address translation for I / O and computation load reduction devices in peripheral interconnects

    JP2013500524A

  • A mechanism for handling page faults in peripheral devices.

    JP2013531328A

  • Direct sharing of smart devices through virtualization

    JP2013546111A