Deleted Added
sdiff udiff text old ( 9986:7cab06691984 ) new ( 10073:2360411a16be )
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

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

58#include "sim/process.hh"
59#include "sim/system.hh"
60
61#include <signal.h>
62
63/* Used by some KVM macros */
64#define PAGE_SIZE pageSize
65
66volatile bool timerOverflowed = false;
67
68BaseKvmCPU::BaseKvmCPU(BaseKvmCPUParams *params)
69 : BaseCPU(params),
70 vm(*params->kvmVM),
71 _status(Idle),
72 dataPort(name() + ".dcache_port", this),
73 instPort(name() + ".icache_port", this),
74 threadContextDirty(true),

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

87 panic("KVM: Failed to determine host page size (%i)\n",
88 errno);
89
90 thread = new SimpleThread(this, 0, params->system,
91 params->itb, params->dtb, params->isa[0]);
92 thread->setStatus(ThreadContext::Halted);
93 tc = thread->getTC();
94 threadContexts.push_back(tc);
95
96 setupCounters();
97
98 if (params->usePerfOverflow)
99 runTimer.reset(new PerfKvmTimer(hwCycles,
100 KVM_TIMER_SIGNAL,
101 params->hostFactor,
102 params->hostFreq));
103 else
104 runTimer.reset(new PosixKvmTimer(KVM_TIMER_SIGNAL, CLOCK_MONOTONIC,
105 params->hostFactor,
106 params->hostFreq));
107}
108
109BaseKvmCPU::~BaseKvmCPU()
110{
111 if (_kvmRun)
112 munmap(_kvmRun, vcpuMMapSize);
113 close(vcpuFD);
114}

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

172 inform("KVM: Coalesced IO available\n");
173 mmioRing = (struct kvm_coalesced_mmio_ring *)(
174 (char *)_kvmRun + (mmioOffset * pageSize));
175 } else {
176 inform("KVM: Coalesced not supported by host OS\n");
177 }
178
179 thread->startup();
180}
181
182void
183BaseKvmCPU::regStats()
184{
185 using namespace Stats;
186
187 BaseCPU::regStats();
188
189 numInsts
190 .name(name() + ".committedInsts")

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

1039 }
1040
1041 return ticks;
1042}
1043
1044/**
1045 * Cycle timer overflow when running in KVM. Forces the KVM syscall to
1046 * exit with EINTR and allows us to run the event queue.
1047 */
1048static void
1049onTimerOverflow(int signo, siginfo_t *si, void *data)
1050{
1051 timerOverflowed = true;
1052}
1053
1054/**

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

1074
1075 memset(&sa, 0, sizeof(sa));
1076 sa.sa_sigaction = onInstEvent;
1077 sa.sa_flags = SA_SIGINFO | SA_RESTART;
1078 if (sigaction(KVM_INST_SIGNAL, &sa, NULL) == -1)
1079 panic("KVM: Failed to setup vCPU instruction signal handler\n");
1080
1081 sigset_t sigset;
1082 if (sigprocmask(SIG_BLOCK, NULL, &sigset) == -1)
1083 panic("KVM: Failed get signal mask\n");
1084
1085 // Request KVM to setup the same signal mask as we're currently
1086 // running with. We'll sometimes need to mask the KVM_TIMER_SIGNAL
1087 // to cause immediate exits from KVM after servicing IO
1088 // requests. See kvmRun().
1089 setSignalMask(&sigset);
1090
1091 // Mask our control signals so they aren't delivered unless we're
1092 // actually executing inside KVM.
1093 sigaddset(&sigset, KVM_TIMER_SIGNAL);
1094 sigaddset(&sigset, KVM_INST_SIGNAL);
1095 if (sigprocmask(SIG_SETMASK, &sigset, NULL) == -1)
1096 panic("KVM: Failed mask the KVM control signals\n");
1097}
1098
1099bool
1100BaseKvmCPU::discardPendingSignal(int signum) const
1101{
1102 int discardedSignal;
1103

--- 137 unchanged lines hidden ---