Go to the documentation of this file.
38 #ifndef __CPU_KVM_BASE_HH__
39 #define __CPU_KVM_BASE_HH__
56 #define KVM_KICK_SIGNAL SIGRTMIN
60 struct BaseKvmCPUParams;
120 virtual void dump()
const;
332 void kvmInterrupt(
const struct kvm_interrupt &interrupt);
563 int ioctl(
int request,
long p1)
const;
564 int ioctl(
int request,
void *p1)
const {
565 return ioctl(request, (
long)p1);
568 return ioctl(request, 0
L);
EventFunctionWrapper tickEvent
An instance of a performance counter.
void setOneReg(uint64_t id, const void *addr)
Get/Set single register using the KVM_(SET|GET)_ONE_REG API.
void kvmNonMaskableInterrupt()
Send a non-maskable interrupt to the guest.
Port & getInstPort() override
Purely virtual method that returns a reference to the instruction port.
int ioctl(int request) const
const bool alwaysSyncTC
Be conservative and always synchronize the thread context on KVM entry/exit.
@ Running
Running normally.
const long pageSize
Cached page size of the host.
void setupSignalHandler()
Setup a signal handler to catch the timer signal used to switch back to the monitor.
void setupInstStop()
Setup an instruction break if there is one pending.
pthread_t vcpuThread
ID of the vCPU thread.
bool kvmStateDirty
Is the KVM state dirty? Set to true to force an update of the KVM vCPU state upon the next call to kv...
void ioctlRun()
Execute the KVM_RUN ioctl.
KVMCpuPort dataPort
Port for data requests.
void setOneReg(uint64_t id, uint64_t value)
#define KVM_KICK_SIGNAL
Signal to use to trigger exits from KVM.
ThreadContext * getContext(int tn) override
Given a thread num get tho thread context for it.
void takeOverFrom(BaseCPU *cpu) override
Load the state of a CPU from the previous CPU object, invoked on all new CPUs that are about to be sw...
int16_t ThreadID
Thread index/ID type.
std::string getAndFormatOneReg(uint64_t id) const
Get and format one register for printout.
Stats::Scalar numVMHalfEntries
bool discardPendingSignal(int signum) const
Discard a (potentially) pending signal.
Status _status
CPU run state.
BaseKvmCPU(BaseKvmCPUParams *params)
uint8_t * getGuestData(uint64_t offset) const
Retrieve a pointer to guest data stored at the end of the kvm_run structure.
uint64_t Tick
Tick count type.
void setFPUState(const struct kvm_fpu &state)
void setupInstCounter(uint64_t period=0)
Setup the guest instruction counter.
void setRegisters(const struct kvm_regs ®s)
virtual Tick handleKvmExitException()
An unhandled virtualization exception occured.
void recvReqRetry() override
Called by the peer if sendTimingReq was called on this peer (causing recvTimingReq to be called on th...
void switchOut() override
Prepare for another CPU to take over execution.
virtual Tick handleKvmExit()
Main kvmRun exit handler, calls the relevant handleKvmExit* depending on exit type.
void getOneReg(uint64_t id, void *addr) const
BaseKvmCPU * cpu
KVM cpu pointer for finishMMIOPending() callback.
virtual uint64_t getHostCycles() const
Get the value of the hardware cycle counter in the guest.
Port & getDataPort() override
Purely virtual method that returns a reference to the data port.
uint64_t getOneRegU64(uint64_t id) const
Tick submitIO(PacketPtr pkt)
Interface to send Atomic or Timing IO request.
Stats::Scalar numCoalescedMMIO
virtual Tick handleKvmExitUnknown()
An unknown architecture dependent error occurred when starting the vCPU.
The SimpleThread object provides a combination of the ThreadState object and the ThreadContext interf...
BaseKvmCPU::StatGroup stats
DrainState
Object drain/handover states.
This is a simple scalar statistic, like a counter.
void kvmInterrupt(const struct kvm_interrupt &interrupt)
Send a normal interrupt to the guest.
int64_t Counter
Statistics counter type.
int vcpuFD
KVM vCPU file descriptor.
Counter totalOps() const override
void syncThreadContext()
Update a thread context if the KVM state is dirty with respect to the cached thread context.
Base class for KVM based CPU models.
@ RunningServiceCompletion
Service completion in progress.
SimpleThread * thread
A cached copy of a thread's state in the form of a SimpleThread object.
ThreadContext is the external interface to all thread state for anything outside of the CPU.
void suspendContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now suspended.
virtual Tick handleKvmExitHypercall()
The guest requested a monitor service using a hypercall.
void unserializeThread(CheckpointIn &cp, ThreadID tid) override
Unserialize one thread.
virtual Tick handleKvmExitIO()
The guest performed a legacy IO request (out/inp on x86)
Stats::Scalar numInterrupts
bool perfControlledByTimer
Does the runTimer control the performance counters?
Ports are used to interface objects to each other.
void setupCounters()
Setup hardware performance counters.
void haltContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now halted.
virtual Tick kvmRun(Tick ticks)
Request KVM to run the guest for a given number of ticks.
struct kvm_run * getKvmRunState()
Get a pointer to the kvm_run structure containing all the input and output parameters from kvmRun().
StatGroup(Stats::Group *parent)
Stats::Scalar numExitSignal
@ RunningMMIOPending
Timing MMIO request in flight or stalled.
Tick doMMIOAccess(Addr paddr, void *data, int size, bool write)
Inject a memory mapped IO request into gem5.
EventQueue * deviceEventQueue()
Get a pointer to the event queue owning devices.
A RequestPort is a specialisation of a Port, which implements the default protocol for the three diff...
virtual void dump() const
Dump the internal state to the terminal.
void startupThread()
Thread-specific initialization.
void getFPUState(struct kvm_fpu &state) const
Get/Set the guest FPU/vector state.
void kick() const
Force an exit from KVM.
void notifyFork() override
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
virtual Tick kvmRunDrain()
Request the CPU to run until draining completes.
const Params * params() const
EventQueue * eventQueue() const
DrainState drain() override
void tick()
Execute the CPU until the next event in the main event queue or until the guest needs service from ge...
int ioctl(int request, long p1) const
vCPU ioctl interface.
bool threadContextDirty
Is the gem5 context dirty? Set to true to force an update of the KVM vCPU state upon the next call to...
KVMCpuPort instPort
Unused dummy port for the instruction interface.
void verifyMemoryMode() const override
Verify that the system is in a memory mode supported by the CPU.
const long vcpuID
KVM internal ID of the vCPU.
KVMCpuPort(const std::string &_name, BaseKvmCPU *_cpu)
Counter ctrInsts
Number of instructions executed by the CPU.
void finishMMIOPending()
Callback from KvmCPUPort to transition the CPU out of RunningMMIOPending when all timing requests hav...
@ RunningService
Requiring service at the beginning of the next cycle.
Counter totalInsts() const override
uint64_t activeInstPeriod
Currently active instruction count breakpoint.
virtual void updateThreadContext()=0
Update the current thread context with the KVM state.
@ Idle
Context not scheduled in KVM.
std::unique_ptr< BaseKvmTimer > runTimer
Timer used to force execution into the monitor after a specified number of simulation tick equivalent...
ThreadContext * tc
ThreadContext object, provides an interface for external objects to modify this thread's state.
virtual Tick handleKvmExitIRQWindowOpen()
The guest exited because an interrupt window was requested.
A Packet is used to encapsulate a transfer between two objects in the memory system (e....
void getSpecialRegisters(struct kvm_sregs ®s) const
int vcpuMMapSize
Size of MMAPed kvm_run area.
Stats::Scalar committedInsts
unsigned int activeMMIOReqs
Number of MMIO requests in flight.
void drainResume() override
struct kvm_run * _kvmRun
Pointer to the kvm_run structure used to communicate parameters with KVM.
void syncKvmState()
Update the KVM if the thread context is dirty.
virtual void updateKvmState()=0
Update the KVM state from the current thread context.
void setOneReg(uint64_t id, uint32_t value)
Tick flushCoalescedMMIO()
Service MMIO requests in the mmioRing.
virtual bool archIsDrained() const
Is the architecture specific code in a state that prevents draining?
std::ostream CheckpointOut
Stats::Scalar numHypercalls
struct kvm_coalesced_mmio_ring * mmioRing
Coalesced MMIO ring buffer.
bool recvTimingResp(PacketPtr pkt) override
Receive a timing response from the peer.
void setSpecialRegisters(const struct kvm_sregs ®s)
void wakeup(ThreadID tid=0) override
Queue of events sorted in time order.
void getRegisters(struct kvm_regs ®s) const
Get/Set the register state of the guest vCPU.
std::queue< PacketPtr > pendingMMIOPkts
Pending MMIO packets.
int ioctl(int request, void *p1) const
float hostFactor
Host factor as specified in the configuration.
bool tryDrain()
Try to drain the CPU if a drain is pending.
PerfKvmCounter hwInstructions
Guest instruction counter.
PerfKvmCounter hwCycles
Guest cycle counter.
void activateContext(ThreadID thread_num) override
Notify the CPU that the indicated context is now active.
uint32_t getOneRegU32(uint64_t id) const
void deallocateContext(ThreadID thread_num)
void setSignalMask(const sigset_t *mask)
Set the signal mask used in kvmRun()
void serializeThread(CheckpointOut &cp, ThreadID tid) const override
Serialize a single thread.
virtual Tick handleKvmExitFailEntry()
KVM failed to start the virtualized CPU.
Status nextIOState() const
Returns next valid state after one or more IO accesses.
Generated on Wed Sep 30 2020 14:02:07 for gem5 by doxygen 1.8.17