39#ifndef __CPU_KVM_KVMVM_HH__
40#define __CPU_KVM_KVMVM_HH__
47struct kvm_cpuid_entry2;
154#if defined(__i386__) || defined(__x86_64__)
171 bool getSupportedCPUID(
struct kvm_cpuid2 &
cpuid)
const;
183 const CPUIDVector &getSupportedCPUID()
const;
190 bool getSupportedMSRs(
struct kvm_msr_list &msrs)
const;
200 const MSRIndexVector &getSupportedMSRs()
const;
204 mutable CPUIDVector supportedCPUIDCache;
207 mutable MSRIndexVector supportedMSRCache;
239 int ioctl(
int request,
long p1)
const;
240 int ioctl(
int request,
void *p1)
const {
241 return ioctl(request, (
long)p1);
244 return ioctl(request, 0
L);
431#if defined(__aarch64__)
444 void kvmArmPreferredTarget(
struct kvm_vcpu_init &target)
const;
484 void *host_addr,
Addr guest_addr,
519 int ioctl(
int request,
long p1)
const;
520 int ioctl(
int request,
void *p1)
const {
521 return ioctl(request, (
long)p1);
524 return ioctl(request, 0
L);
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Base class for KVM based CPU models.
Structures tracking memory slots.
long contextIdToVCpuId(ContextID ctx) const
Get the VCPUID for a given context.
const MemSlot allocMemSlot(uint64_t size)
Allocate a memory slot within the VM.
long nextVCPUID
Next unallocated vCPU ID.
void notifyFork()
Notify a child process of a fork.
bool validEnvironment() const
Verify gem5 configuration will support KVM emulation.
int createVCPU(long vcpuID)
Create a new vCPU within a VM.
KvmVM(const KvmVMParams ¶ms)
bool started
Has delayedStartup() already been called?
std::vector< MemorySlot > memorySlots
Kvm * kvm
Global KVM interface.
int vmFD
KVM VM file descriptor.
void freeMemSlot(const MemSlot slot)
Free a previously allocated memory slot.
long allocVCPUID()
Allocate a new vCPU ID within the VM.
void cpuStartup()
VM CPU initialization code.
void setTSSAddress(Addr tss_address)
Setup a shared three-page memory region used by the internals of KVM.
void disableMemSlot(const MemSlot slot)
Disable a memory slot.
void setupMemSlot(const MemSlot slot, void *host_addr, Addr guest_addr, uint32_t flags)
Setup a region of physical memory in the guest.
bool _hasKernelIRQChip
Do we have in-kernel IRQ-chip emulation enabled?
void delayedStartup()
Delayed initialization, executed once before the first CPU starts.
int createDevice(uint32_t type, uint32_t flags=0)
Create an in-kernel device model.
void setUserMemoryRegion(uint32_t slot, void *host_addr, Addr guest_addr, uint64_t len, uint32_t flags)
Setup a region of physical memory in the guest.
KvmVM & operator=(const KvmVM &vm)
void coalesceMMIO(Addr start, int size)
Request coalescing MMIO for a memory range.
int apiVersion
KVM API version.
int checkExtension(int extension) const
Check for the presence of an extension to the KVM API.
int capNumMemSlots() const
Attempt to determine how many memory slots are available.
bool capIRQLineLayout2() const
Support for ARM IRQ line layout 2.
bool capXCRs() const
Support for getting and setting the x86 XCRs.
bool capIRQChip() const
Support for creating an in-kernel IRQ chip model.
bool capExtendedCPUID() const
Support for BaseKvmCPU::setCPUID2 and getSupportedCPUID().
bool capSetTSSAddress() const
Support for KvmVM::setTSSAddress()
int createVM()
Create a KVM Virtual Machine.
bool capUserNMI() const
Support for BaseKvmCPU::kvmNonMaskableInterrupt().
bool capDebugRegs() const
Support for getting and setting the kvm_debugregs structure.
int getVCPUMMapSize() const
Get the size of the MMAPed parameter area used to communicate vCPU parameters between the kernel and ...
Kvm & operator=(const Kvm &kvm)
int getAPIVersion() const
Get the version of the KVM API implemented by the kernel.
int vcpuMMapSize
Size of the MMAPed vCPU parameter area.
int capCoalescedMMIO() const
Check if coalesced MMIO is supported and which page in the MMAP'ed structure it stores requests in.
bool capXSave() const
Support for getting and setting the kvm_xsave structure.
bool capUserMemory() const
Support for KvmVM::setUserMemoryRegion()
bool capVCPUEvents() const
Support for getting and setting the kvm_vcpu_events structure.
bool capOneReg() const
Support for reading and writing single registers.
static Kvm * instance
Singleton instance.
int kvmFD
KVM VM file descriptor.
Abstract superclass for simulation objects.
bool hasKernelIRQChip() const
Is in-kernel IRQ chip emulation enabled?
void setIRQLine(uint32_t irq, bool high)
Set the status of an IRQ line using KVM_IRQ_LINE.
void enableKernelIRQChip()
Tell the VM and VCPUs to use an in-kernel IRQ chip for interrupt delivery.
void createIRQChip()
Create an in-kernel interrupt controller.
int ioctl(int request, void *p1) const
int ioctl(int request, long p1) const
Main VM ioctl interface.
int ioctl(int request, void *p1) const
int ioctl(int request, long p1) const
KVM VM ioctl interface.
int ioctl(int request) const
int ioctl(int request) const
const Params & params() const
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved.
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
int ContextID
Globally unique thread context ID.