diff options
author | Andreas Sandberg <andreas@sandberg.pp.se> | 2013-06-03 13:39:11 +0200 |
---|---|---|
committer | Andreas Sandberg <andreas@sandberg.pp.se> | 2013-06-03 13:39:11 +0200 |
commit | c2ec232920354ac1c8e07e0d2fbb8b8b314343b5 (patch) | |
tree | 8bdcd552af72fbc86f8987b71205f86e7f996cde /src/cpu/kvm/base.hh | |
parent | 15f81b6ed9a2bc9821c90a4058b7b528e001a10f (diff) | |
download | gem5-c2ec232920354ac1c8e07e0d2fbb8b8b314343b5.tar.xz |
kvm: Allow architectures to override the cycle accounting mechanism
Some architectures have special registers in the guest that can be
used to do cycle accounting. This is generally preferrable since the
prevents the guest from seeing a non-monotonic clock. This changeset
adds a virtual method, getHostCycles(), that the architecture-specific
code can override to implement this functionallity. The default
implementation uses the hwCycles counter.
Diffstat (limited to 'src/cpu/kvm/base.hh')
-rw-r--r-- | src/cpu/kvm/base.hh | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/cpu/kvm/base.hh b/src/cpu/kvm/base.hh index 4546b1071..c53f715e3 100644 --- a/src/cpu/kvm/base.hh +++ b/src/cpu/kvm/base.hh @@ -154,6 +154,21 @@ class BaseKvmCPU : public BaseCPU virtual void tick(); /** + * Get the value of the hardware cycle counter in the guest. + * + * This method is supposed to return the total number of cycles + * executed in hardware mode relative to some arbitrary point in + * the past. It's mainly used when estimating the number of cycles + * actually executed by the CPU in kvmRun(). The default behavior + * of this method is to use the cycles performance counter, but + * some architectures may want to use internal registers instead. + * + * @return Number of host cycles executed relative to an undefined + * point in the past. + */ + virtual uint64_t getHostCycles() const; + + /** * Request KVM to run the guest for a given number of ticks. The * method returns the approximate number of ticks executed. * |