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