gem5  v20.1.0.0
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
Kvm Class Reference

KVM parent interface. More...

#include <vm.hh>

Public Member Functions

virtual ~Kvm ()
 
Kvmcreate ()
 
int getAPIVersion () const
 Get the version of the KVM API implemented by the kernel. More...
 
int getVCPUMMapSize () const
 Get the size of the MMAPed parameter area used to communicate vCPU parameters between the kernel and userspace. More...
 
bool capUserMemory () const
 Support for KvmVM::setUserMemoryRegion() More...
 
bool capSetTSSAddress () const
 Support for KvmVM::setTSSAddress() More...
 
bool capExtendedCPUID () const
 Support for BaseKvmCPU::setCPUID2 and getSupportedCPUID(). More...
 
bool capUserNMI () const
 Support for BaseKvmCPU::kvmNonMaskableInterrupt(). More...
 
int capCoalescedMMIO () const
 Check if coalesced MMIO is supported and which page in the MMAP'ed structure it stores requests in. More...
 
int capNumMemSlots () const
 Attempt to determine how many memory slots are available. More...
 
bool capOneReg () const
 Support for reading and writing single registers. More...
 
bool capIRQChip () const
 Support for creating an in-kernel IRQ chip model. More...
 
bool capVCPUEvents () const
 Support for getting and setting the kvm_vcpu_events structure. More...
 
bool capDebugRegs () const
 Support for getting and setting the kvm_debugregs structure. More...
 
bool capXCRs () const
 Support for getting and setting the x86 XCRs. More...
 
bool capXSave () const
 Support for getting and setting the kvm_xsave structure. More...
 

Protected Member Functions

int checkExtension (int extension) const
 Check for the presence of an extension to the KVM API. More...
 
int ioctl (int request, long p1) const
 Main VM ioctl interface. More...
 
int ioctl (int request, void *p1) const
 
int ioctl (int request) const
 

Private Member Functions

 Kvm ()
 
 Kvm (const Kvm &kvm)
 
Kvmoperator= (const Kvm &kvm)
 
int createVM ()
 Create a KVM Virtual Machine. More...
 

Private Attributes

int kvmFD
 KVM VM file descriptor. More...
 
int apiVersion
 KVM API version. More...
 
int vcpuMMapSize
 Size of the MMAPed vCPU parameter area. More...
 

Static Private Attributes

static Kvminstance = NULL
 Singleton instance. More...
 

Friends

class KvmVM
 

Detailed Description

KVM parent interface.

The main Kvm object is used to provide functionality that is not specific to a VM or CPU. For example, it allows checking of the optional features and creation of VM containers.

Definition at line 72 of file vm.hh.

Constructor & Destructor Documentation

◆ ~Kvm()

Kvm::~Kvm ( )
virtual

Definition at line 80 of file vm.cc.

References kvmFD.

◆ Kvm() [1/2]

Kvm::Kvm ( )
private

Definition at line 64 of file vm.cc.

References apiVersion, EXPECTED_KVM_API_VERSION, fatal, ioctl(), kvmFD, panic, and vcpuMMapSize.

Referenced by create().

◆ Kvm() [2/2]

Kvm::Kvm ( const Kvm kvm)
private

Member Function Documentation

◆ capCoalescedMMIO()

int Kvm::capCoalescedMMIO ( ) const

Check if coalesced MMIO is supported and which page in the MMAP'ed structure it stores requests in.

Returns
Offset (in pages) into the mmap'ed vCPU area where the MMIO buffer is stored. 0 if unsupported.

Definition at line 123 of file vm.cc.

References checkExtension().

Referenced by BaseKvmCPU::startup().

◆ capDebugRegs()

bool Kvm::capDebugRegs ( ) const

Support for getting and setting the kvm_debugregs structure.

Definition at line 165 of file vm.cc.

References checkExtension().

Referenced by X86KvmCPU::X86KvmCPU().

◆ capExtendedCPUID()

bool Kvm::capExtendedCPUID ( ) const

Support for BaseKvmCPU::setCPUID2 and getSupportedCPUID().

Definition at line 107 of file vm.cc.

References checkExtension().

Referenced by X86KvmCPU::X86KvmCPU().

◆ capIRQChip()

bool Kvm::capIRQChip ( ) const

Support for creating an in-kernel IRQ chip model.

See also
KvmVM::createIRQChip()

Definition at line 149 of file vm.cc.

References checkExtension().

◆ capNumMemSlots()

int Kvm::capNumMemSlots ( ) const

Attempt to determine how many memory slots are available.

If it can't be determined, this function returns 0.

Definition at line 129 of file vm.cc.

References checkExtension().

Referenced by KvmVM::KvmVM().

◆ capOneReg()

bool Kvm::capOneReg ( ) const

Support for reading and writing single registers.

See also
BaseKvmCPU::getOneReg(), and BaseKvmCPU::setOneReg()

Definition at line 139 of file vm.cc.

References checkExtension().

◆ capSetTSSAddress()

bool Kvm::capSetTSSAddress ( ) const

Support for KvmVM::setTSSAddress()

Definition at line 101 of file vm.cc.

References checkExtension().

Referenced by X86KvmCPU::X86KvmCPU().

◆ capUserMemory()

bool Kvm::capUserMemory ( ) const

Support for KvmVM::setUserMemoryRegion()

Definition at line 95 of file vm.cc.

References checkExtension().

◆ capUserNMI()

bool Kvm::capUserNMI ( ) const

Support for BaseKvmCPU::kvmNonMaskableInterrupt().

Definition at line 113 of file vm.cc.

References checkExtension().

Referenced by X86KvmCPU::X86KvmCPU().

◆ capVCPUEvents()

bool Kvm::capVCPUEvents ( ) const

Support for getting and setting the kvm_vcpu_events structure.

Definition at line 155 of file vm.cc.

References checkExtension().

Referenced by X86KvmCPU::X86KvmCPU().

◆ capXCRs()

bool Kvm::capXCRs ( ) const

Support for getting and setting the x86 XCRs.

Definition at line 175 of file vm.cc.

References checkExtension().

Referenced by X86KvmCPU::X86KvmCPU().

◆ capXSave()

bool Kvm::capXSave ( ) const

Support for getting and setting the kvm_xsave structure.

Definition at line 185 of file vm.cc.

References checkExtension().

Referenced by X86KvmCPU::X86KvmCPU().

◆ checkExtension()

int Kvm::checkExtension ( int  extension) const
protected

Check for the presence of an extension to the KVM API.

The return value depends on the extension, but is always zero if it is unsupported or positive otherwise. Some extensions use the return value provide additional data about the extension.

Returns
0 if the extension is unsupported, positive integer otherwise.

Definition at line 263 of file vm.cc.

References ioctl(), and panic.

Referenced by capCoalescedMMIO(), capDebugRegs(), capExtendedCPUID(), capIRQChip(), capNumMemSlots(), capOneReg(), capSetTSSAddress(), capUserMemory(), capUserNMI(), capVCPUEvents(), capXCRs(), and capXSave().

◆ create()

Kvm * Kvm::create ( )

Definition at line 86 of file vm.cc.

References instance, and Kvm().

◆ createVM()

int Kvm::createVM ( )
private

Create a KVM Virtual Machine.

Returns
File descriptor pointing to the VM

Definition at line 280 of file vm.cc.

References ioctl(), and panic.

◆ getAPIVersion()

int Kvm::getAPIVersion ( ) const
inline

Get the version of the KVM API implemented by the kernel.

Definition at line 82 of file vm.hh.

References apiVersion.

◆ getVCPUMMapSize()

int Kvm::getVCPUMMapSize ( ) const
inline

Get the size of the MMAPed parameter area used to communicate vCPU parameters between the kernel and userspace.

This area, amongst other things, contains the kvm_run data structure.

Definition at line 88 of file vm.hh.

References vcpuMMapSize.

Referenced by BaseKvmCPU::startup().

◆ operator=()

Kvm& Kvm::operator= ( const Kvm kvm)
private

Friends And Related Function Documentation

◆ KvmVM

friend class KvmVM
friend

Definition at line 74 of file vm.hh.

Member Data Documentation

◆ apiVersion

int Kvm::apiVersion
private

KVM API version.

Definition at line 255 of file vm.hh.

Referenced by getAPIVersion(), and Kvm().

◆ instance

Kvm * Kvm::instance = NULL
staticprivate

Singleton instance.

Definition at line 260 of file vm.hh.

Referenced by create().

◆ kvmFD

int Kvm::kvmFD
private

KVM VM file descriptor.

Definition at line 253 of file vm.hh.

Referenced by ioctl(), Kvm(), and ~Kvm().

◆ vcpuMMapSize

int Kvm::vcpuMMapSize
private

Size of the MMAPed vCPU parameter area.

Definition at line 257 of file vm.hh.

Referenced by getVCPUMMapSize(), and Kvm().


The documentation for this class was generated from the following files:

Generated on Wed Sep 30 2020 14:02:26 for gem5 by doxygen 1.8.17