Deleted Added
sdiff udiff text old ( 9752:a152d7f114b8 ) new ( 9753:b9a742cdd75a )
full compact
1/*
2 * Copyright (c) 2012 ARM Limited
3 * All rights reserved
4 *
5 * The license below extends only to copyright in the software and shall
6 * not be construed as granting a license to any other intellectual
7 * property including but not limited to intellectual property relating
8 * to a hardware implementation of the functionality of the software

--- 27 unchanged lines hidden (view full) ---

36 *
37 * Authors: Andreas Sandberg
38 */
39
40#ifndef __CPU_KVM_BASE_HH__
41#define __CPU_KVM_BASE_HH__
42
43#include <memory>
44
45#include "base/statistics.hh"
46#include "cpu/kvm/perfevent.hh"
47#include "cpu/kvm/timer.hh"
48#include "cpu/kvm/vm.hh"
49#include "cpu/base.hh"
50#include "cpu/simple_thread.hh"
51

--- 76 unchanged lines hidden (view full) ---

128 /** ThreadContext object, provides an interface for external
129 * objects to modify this thread's state.
130 */
131 ThreadContext *tc;
132
133 KvmVM &vm;
134
135 protected:
136 enum Status {
137 /** Context not scheduled in KVM */
138 Idle,
139 /** Running normally */
140 Running,
141 };
142
143 /** CPU run state */
144 Status _status;
145
146 /**
147 * Execute the CPU until the next event in the main event queue or
148 * until the guest needs service from gem5.
149 *
150 * @note This method is virtual in order to allow implementations
151 * to check for architecture specific events (e.g., interrupts)
152 * before entering the VM.
153 */
154 virtual void tick();
155
156 /**
157 * Get the value of the hardware cycle counter in the guest.
158 *
159 * This method is supposed to return the total number of cycles
160 * executed in hardware mode relative to some arbitrary point in
161 * the past. It's mainly used when estimating the number of cycles
162 * actually executed by the CPU in kvmRun(). The default behavior

--- 9 unchanged lines hidden (view full) ---

172 * Request KVM to run the guest for a given number of ticks. The
173 * method returns the approximate number of ticks executed.
174 *
175 * @note The returned number of ticks can be both larger or
176 * smaller than the requested number of ticks. A smaller number
177 * can, for example, occur when the guest executes MMIO. A larger
178 * number is typically due to performance counter inaccuracies.
179 *
180 * @param ticks Number of ticks to execute
181 * @return Number of ticks executed (see note)
182 */
183 Tick kvmRun(Tick ticks);
184
185 /**
186 * Get a pointer to the kvm_run structure containing all the input
187 * and output parameters from kvmRun().
188 */
189 struct kvm_run *getKvmRunState() { return _kvmRun; };
190
191 /**
192 * Retrieve a pointer to guest data stored at the end of the
193 * kvm_run structure. This is mainly used for PIO operations

--- 186 unchanged lines hidden (view full) ---

380 * code.
381 *
382 * @return Number of ticks delay the next CPU tick
383 */
384 virtual Tick handleKvmExitFailEntry();
385 /** @} */
386
387 /**
388 * Inject a memory mapped IO request into gem5
389 *
390 * @param paddr Physical address
391 * @param data Pointer to the source/destination buffer
392 * @param size Memory access size
393 * @param write True if write, False if read
394 * @return Number of ticks spent servicing the memory access
395 */
396 Tick doMMIOAccess(Addr paddr, void *data, int size, bool write);
397
398
399 /**
400 * @addtogroup KvmIoctl
401 * @{
402 */
403 /**
404 * vCPU ioctl interface.
405 *

--- 88 unchanged lines hidden (view full) ---

494 Tick flushCoalescedMMIO();
495
496 /**
497 * Setup a signal handler to catch the timer signal used to
498 * switch back to the monitor.
499 */
500 void setupSignalHandler();
501
502 /** Setup hardware performance counters */
503 void setupCounters();
504
505 /** KVM vCPU file descriptor */
506 int vcpuFD;
507 /** Size of MMAPed kvm_run area */
508 int vcpuMMapSize;
509 /**
510 * Pointer to the kvm_run structure used to communicate parameters
511 * with KVM.
512 *

--- 32 unchanged lines hidden (view full) ---

545 * specified number of simulation tick equivalents have executed
546 * in the guest. This counter generates the signal specified by
547 * KVM_TIMER_SIGNAL.
548 */
549 std::unique_ptr<BaseKvmTimer> runTimer;
550
551 float hostFactor;
552
553 public:
554 /* @{ */
555 Stats::Scalar numInsts;
556 Stats::Scalar numVMExits;
557 Stats::Scalar numMMIO;
558 Stats::Scalar numCoalescedMMIO;
559 Stats::Scalar numIO;
560 Stats::Scalar numHalt;
561 Stats::Scalar numInterrupts;
562 Stats::Scalar numHypercalls;
563 /* @} */
564
565 /** Number of instructions executed by the CPU */
566 Counter ctrInsts;
567};
568
569#endif