gem5  v21.2.0.0
vm.cc
Go to the documentation of this file.
1 /*
2  * Copyright 2014 Google, Inc.
3  * Copyright (c) 2012, 2015 ARM Limited
4  * All rights reserved
5  *
6  * The license below extends only to copyright in the software and shall
7  * not be construed as granting a license to any other intellectual
8  * property including but not limited to intellectual property relating
9  * to a hardware implementation of the functionality of the software
10  * licensed hereunder. You may use the software subject to the license
11  * terms below provided that you ensure that this notice is replicated
12  * unmodified and in its entirety in all distributions of the software,
13  * modified or unmodified, in source code or in binary form.
14  *
15  * Redistribution and use in source and binary forms, with or without
16  * modification, are permitted provided that the following conditions are
17  * met: redistributions of source code must retain the above copyright
18  * notice, this list of conditions and the following disclaimer;
19  * redistributions in binary form must reproduce the above copyright
20  * notice, this list of conditions and the following disclaimer in the
21  * documentation and/or other materials provided with the distribution;
22  * neither the name of the copyright holders nor the names of its
23  * contributors may be used to endorse or promote products derived from
24  * this software without specific prior written permission.
25  *
26  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37  */
38 
39 #include "cpu/kvm/vm.hh"
40 
41 #include <fcntl.h>
42 #include <linux/kvm.h>
43 #include <sys/ioctl.h>
44 #include <sys/stat.h>
45 #include <sys/types.h>
46 #include <unistd.h>
47 
48 #include <cerrno>
49 #include <memory>
50 
51 #include "cpu/kvm/base.hh"
52 #include "debug/Kvm.hh"
53 #include "mem/physical.hh"
54 #include "params/KvmVM.hh"
55 #include "sim/system.hh"
56 
57 namespace gem5
58 {
59 
60 namespace
61 {
62 
63 constexpr int ExpectedKvmApiVersion = 12;
64 static_assert(KVM_API_VERSION == ExpectedKvmApiVersion,
65  "Unsupported KVM version");
66 
67 } // anonymous namespace
68 
69 Kvm *Kvm::instance = NULL;
70 
72  : kvmFD(-1), apiVersion(-1), vcpuMMapSize(0)
73 {
74  static bool created = false;
75  if (created)
76  warn_once("Use of multiple KvmVMs is currently untested!");
77 
78  created = true;
79 
80  kvmFD = ::open("/dev/kvm", O_RDWR);
81  if (kvmFD == -1)
82  fatal("KVM: Failed to open /dev/kvm\n");
83 
84  apiVersion = ioctl(KVM_GET_API_VERSION);
85  if (apiVersion != ExpectedKvmApiVersion)
86  fatal("KVM: Incompatible API version\n");
87 
88  vcpuMMapSize = ioctl(KVM_GET_VCPU_MMAP_SIZE);
89  if (vcpuMMapSize == -1)
90  panic("KVM: Failed to get virtual CPU MMAP size\n");
91 }
92 
94 {
95  close(kvmFD);
96 }
97 
98 Kvm *
100 {
101  if (!instance)
102  instance = new Kvm();
103 
104  return instance;
105 }
106 
107 bool
109 {
110  return checkExtension(KVM_CAP_USER_MEMORY) != 0;
111 }
112 
113 bool
115 {
116  return checkExtension(KVM_CAP_SET_TSS_ADDR) != 0;
117 }
118 
119 bool
121 {
122  return checkExtension(KVM_CAP_EXT_CPUID) != 0;
123 }
124 
125 bool
127 {
128 #ifdef KVM_CAP_USER_NMI
129  return checkExtension(KVM_CAP_USER_NMI) != 0;
130 #else
131  return false;
132 #endif
133 }
134 
135 int
137 {
138  return checkExtension(KVM_CAP_COALESCED_MMIO);
139 }
140 
141 int
143 {
144 #ifdef KVM_CAP_NR_MEMSLOTS
145  return checkExtension(KVM_CAP_NR_MEMSLOTS);
146 #else
147  return 0;
148 #endif
149 }
150 
151 bool
153 {
154 #ifdef KVM_CAP_ONE_REG
155  return checkExtension(KVM_CAP_ONE_REG) != 0;
156 #else
157  return false;
158 #endif
159 }
160 
161 bool
163 {
164  return checkExtension(KVM_CAP_IRQCHIP) != 0;
165 }
166 
167 bool
169 {
170 #ifdef KVM_CAP_VCPU_EVENTS
171  return checkExtension(KVM_CAP_VCPU_EVENTS) != 0;
172 #else
173  return false;
174 #endif
175 }
176 
177 bool
179 {
180 #ifdef KVM_CAP_DEBUGREGS
181  return checkExtension(KVM_CAP_DEBUGREGS) != 0;
182 #else
183  return false;
184 #endif
185 }
186 
187 bool
189 {
190 #ifdef KVM_CAP_XCRS
191  return checkExtension(KVM_CAP_XCRS) != 0;
192 #else
193  return false;
194 #endif
195 }
196 
197 bool
199 {
200 #ifdef KVM_CAP_XSAVE
201  return checkExtension(KVM_CAP_XSAVE) != 0;
202 #else
203  return false;
204 #endif
205 }
206 
207 
208 #if defined(__i386__) || defined(__x86_64__)
209 bool
210 Kvm::getSupportedCPUID(struct kvm_cpuid2 &cpuid) const
211 {
212  if (ioctl(KVM_GET_SUPPORTED_CPUID, (void *)&cpuid) == -1) {
213  if (errno == E2BIG)
214  return false;
215  else
216  panic("KVM: Failed to get supported CPUID (errno: %i)\n", errno);
217  } else
218  return true;
219 }
220 
221 const Kvm::CPUIDVector &
222 Kvm::getSupportedCPUID() const
223 {
224  if (supportedCPUIDCache.empty()) {
225  std::unique_ptr<struct kvm_cpuid2, void(*)(void *p)>
226  cpuid(nullptr, [](void *p) { operator delete(p); });
227  int i(1);
228  do {
229  cpuid.reset((struct kvm_cpuid2 *)operator new(
230  sizeof(kvm_cpuid2) + i * sizeof(kvm_cpuid_entry2)));
231 
232  cpuid->nent = i;
233  ++i;
234  } while (!getSupportedCPUID(*cpuid));
235  supportedCPUIDCache.assign(cpuid->entries,
236  cpuid->entries + cpuid->nent);
237  }
238 
239  return supportedCPUIDCache;
240 }
241 
242 bool
243 Kvm::getSupportedMSRs(struct kvm_msr_list &msrs) const
244 {
245  if (ioctl(KVM_GET_MSR_INDEX_LIST, (void *)&msrs) == -1) {
246  if (errno == E2BIG)
247  return false;
248  else
249  panic("KVM: Failed to get supported CPUID (errno: %i)\n", errno);
250  } else
251  return true;
252 }
253 
254 const Kvm::MSRIndexVector &
255 Kvm::getSupportedMSRs() const
256 {
257  if (supportedMSRCache.empty()) {
258  std::unique_ptr<struct kvm_msr_list, void(*)(void *p)>
259  msrs(nullptr, [](void *p) { operator delete(p); });
260  int i(0);
261  do {
262  msrs.reset((struct kvm_msr_list *)operator new(
263  sizeof(kvm_msr_list) + i * sizeof(uint32_t)));
264 
265  msrs->nmsrs = i;
266  ++i;
267  } while (!getSupportedMSRs(*msrs));
268  supportedMSRCache.assign(msrs->indices, msrs->indices + msrs->nmsrs);
269  }
270 
271  return supportedMSRCache;
272 }
273 
274 #endif // x86-specific
275 
276 
277 int
278 Kvm::checkExtension(int extension) const
279 {
280  int ret = ioctl(KVM_CHECK_EXTENSION, extension);
281  if (ret == -1)
282  panic("KVM: ioctl failed when checking for extension\n");
283  return ret;
284 }
285 
286 int
287 Kvm::ioctl(int request, long p1) const
288 {
289  assert(kvmFD != -1);
290 
291  return ::ioctl(kvmFD, request, p1);
292 }
293 
294 int
296 {
297  int vmFD;
298 
299  vmFD = ioctl(KVM_CREATE_VM);
300  if (vmFD == -1)
301  panic("Failed to create KVM VM\n");
302 
303  return vmFD;
304 }
305 
306 
307 KvmVM::KvmVM(const KvmVMParams &params)
308  : SimObject(params),
309  kvm(new Kvm()), system(nullptr),
310  vmFD(kvm->createVM()),
311  started(false),
312  _hasKernelIRQChip(false),
313  nextVCPUID(0)
314 {
316  /* If we couldn't determine how memory slots there are, guess 32. */
317  if (!maxMemorySlot)
318  maxMemorySlot = 32;
319  /* Setup the coalesced MMIO regions */
320  for (int i = 0; i < params.coalescedMMIO.size(); ++i)
321  coalesceMMIO(params.coalescedMMIO[i]);
322 }
323 
325 {
326  if (vmFD != -1)
327  close(vmFD);
328 
329  if (kvm)
330  delete kvm;
331 }
332 
333 void
335 {
336  if (vmFD != -1) {
337  if (close(vmFD) == -1)
338  warn("kvm VM: notifyFork failed to close vmFD\n");
339 
340  vmFD = -1;
341 
342  delete kvm;
343  kvm = NULL;
344  }
345 }
346 
347 void
349 {
350  if (started)
351  return;
352  started = true;
353 
354  delayedStartup();
355 }
356 
357 void
359 {
360  assert(system); // set by the system during its construction
363 
364  DPRINTF(Kvm, "Mapping %i memory region(s)\n", memories.size());
365  for (int slot(0); slot < memories.size(); ++slot) {
366  if (!memories[slot].kvmMap) {
367  DPRINTF(Kvm, "Skipping region marked as not usable by KVM\n");
368  continue;
369  }
370 
371  const AddrRange &range(memories[slot].range);
372  void *pmem(memories[slot].pmem);
373 
374  if (pmem) {
375  DPRINTF(Kvm, "Mapping region: 0x%p -> 0x%llx [size: 0x%llx]\n",
376  pmem, range.start(), range.size());
377 
378  if (range.interleaved()) {
379  panic("Tried to map an interleaved memory range into "
380  "a KVM VM.\n");
381  }
382 
383  const MemSlot slot = allocMemSlot(range.size());
384  setupMemSlot(slot, pmem, range.start(), 0/* flags */);
385  } else {
386  DPRINTF(Kvm, "Zero-region not mapped: [0x%llx]\n", range.start());
387  hack("KVM: Zero memory handled as IO\n");
388  }
389  }
390 }
391 
392 const KvmVM::MemSlot
393 KvmVM::allocMemSlot(uint64_t size)
394 {
395  if (!size)
396  panic("Memory slots must have non-zero size.\n");
397 
399  for (pos = memorySlots.begin(); pos != memorySlots.end(); pos++) {
400  if (!pos->size) {
401  pos->size = size;
402  pos->active = false;
403  return pos->slot;
404  }
405  }
406 
407  uint32_t nextSlot = memorySlots.size();
408  if (nextSlot > maxMemorySlot)
409  panic("Out of memory slots.\n");
410 
411  MemorySlot slot;
412  slot.size = size;
413  slot.slot = nextSlot;
414  slot.active = false;
415 
416  memorySlots.push_back(slot);
417  return MemSlot(slot.slot);
418 }
419 
420 void
421 KvmVM::setupMemSlot(const KvmVM::MemSlot num, void *host_addr, Addr guest,
422  uint32_t flags)
423 {
424  MemorySlot &slot = memorySlots.at(num.num);
425  slot.active = true;
426  setUserMemoryRegion(num.num, host_addr, guest, slot.size, flags);
427 }
428 
429 void
431 {
432  MemorySlot &slot = memorySlots.at(num.num);
433  if (slot.active)
434  setUserMemoryRegion(num.num, NULL, 0, 0, 0);
435  slot.active = false;
436 }
437 
438 void
440 {
441  disableMemSlot(num.num);
442  MemorySlot &slot = memorySlots.at(num.num);
443  slot.size = 0;
444 }
445 
446 void
448  void *host_addr, Addr guest_addr,
449  uint64_t len, uint32_t flags)
450 {
451  struct kvm_userspace_memory_region m;
452 
453  memset(&m, 0, sizeof(m));
454  m.slot = slot;
455  m.flags = flags;
456  m.guest_phys_addr = (uint64_t)guest_addr;
457  m.memory_size = len;
458  m.userspace_addr = (__u64)host_addr;
459 
460  if (ioctl(KVM_SET_USER_MEMORY_REGION, (void *)&m) == -1) {
461  panic("Failed to setup KVM memory region:\n"
462  "\tHost Address: 0x%p\n"
463  "\tGuest Address: 0x%llx\n",
464  "\tSize: %ll\n",
465  "\tFlags: 0x%x\n",
466  m.userspace_addr, m.guest_phys_addr,
467  m.memory_size, m.flags);
468  }
469 }
470 
471 void
473 {
474  coalesceMMIO(range.start(), range.size());
475 }
476 
477 void
478 KvmVM::coalesceMMIO(Addr start, int size)
479 {
480  struct kvm_coalesced_mmio_zone zone;
481 
482  zone.addr = start;
483  zone.size = size;
484  zone.pad = 0;
485 
486  DPRINTF(Kvm, "KVM: Registering coalesced MMIO region [0x%x, 0x%x]\n",
487  zone.addr, zone.addr + zone.size - 1);
488  if (ioctl(KVM_REGISTER_COALESCED_MMIO, (void *)&zone) == -1)
489  panic("KVM: Failed to register coalesced MMIO region (%i)\n",
490  errno);
491 }
492 
493 void
495 {
496  if (ioctl(KVM_SET_TSS_ADDR, (unsigned long)tss_address) == -1)
497  panic("KVM: Failed to set VM TSS address\n");
498 }
499 
500 void
502 {
503  if (_hasKernelIRQChip)
504  panic("KvmVM::createIRQChip called twice.\n");
505 
506  if (ioctl(KVM_CREATE_IRQCHIP) != -1) {
507  _hasKernelIRQChip = true;
508  } else {
509  warn("KVM: Failed to create in-kernel IRQ chip (errno: %i)\n",
510  errno);
511  _hasKernelIRQChip = false;
512  }
513 }
514 
515 void
516 KvmVM::setIRQLine(uint32_t irq, bool high)
517 {
518  struct kvm_irq_level kvm_level;
519 
520  kvm_level.irq = irq;
521  kvm_level.level = high ? 1 : 0;
522 
523  if (ioctl(KVM_IRQ_LINE, &kvm_level) == -1)
524  panic("KVM: Failed to set IRQ line level (errno: %i)\n",
525  errno);
526 }
527 
528 int
529 KvmVM::createDevice(uint32_t type, uint32_t flags)
530 {
531 #if defined(KVM_CREATE_DEVICE)
532  struct kvm_create_device dev = { type, 0, flags };
533 
534  if (ioctl(KVM_CREATE_DEVICE, &dev) == -1) {
535  panic("KVM: Failed to create device (errno: %i)\n",
536  errno);
537  }
538 
539  return dev.fd;
540 #else
541  panic("Kernel headers don't support KVM_CREATE_DEVICE\n");
542 #endif
543 }
544 
545 void
547 {
548  panic_if(system != nullptr, "setSystem() can only be called once");
549  panic_if(s == nullptr, "setSystem() called with null System*");
550  system = s;
551 }
552 
553 long
555 {
556  assert(system != nullptr);
557  return dynamic_cast<BaseKvmCPU*>
558  (system->threads[ctx]->getCpuPtr())->getVCpuID();
559 }
560 
561 int
562 KvmVM::createVCPU(long vcpuID)
563 {
564  int fd;
565 
566  fd = ioctl(KVM_CREATE_VCPU, vcpuID);
567  if (fd == -1)
568  panic("KVM: Failed to create virtual CPU");
569 
570  return fd;
571 }
572 
573 long
575 {
576  return nextVCPUID++;
577 }
578 
579 #if defined(__aarch64__)
580 void
581 KvmVM::kvmArmPreferredTarget(struct kvm_vcpu_init &target) const
582 {
583  if (ioctl(KVM_ARM_PREFERRED_TARGET, &target) == -1) {
584  panic("KVM: Failed to get ARM preferred CPU target (errno: %i)\n",
585  errno);
586  }
587 }
588 #endif
589 
590 int
591 KvmVM::ioctl(int request, long p1) const
592 {
593  assert(vmFD != -1);
594 
595  return ::ioctl(vmFD, request, p1);
596 }
597 
598 } // namespace gem5
fatal
#define fatal(...)
This implements a cprintf based fatal() function.
Definition: logging.hh:190
gem5::KvmVM::vmFD
int vmFD
KVM VM file descriptor.
Definition: vm.hh:535
gem5::KvmVM::MemorySlot::slot
uint32_t slot
Definition: vm.hh:553
gem5::KvmVM::createVCPU
int createVCPU(long vcpuID)
Create a new vCPU within a VM.
Definition: vm.cc:562
gem5::Kvm::capSetTSSAddress
bool capSetTSSAddress() const
Support for KvmVM::setTSSAddress()
Definition: vm.cc:114
gem5::KvmVM::freeMemSlot
void freeMemSlot(const MemSlot slot)
Free a previously allocated memory slot.
Definition: vm.cc:439
gem5::Kvm::capUserNMI
bool capUserNMI() const
Support for BaseKvmCPU::kvmNonMaskableInterrupt().
Definition: vm.cc:126
gem5::ArmISA::len
Bitfield< 18, 16 > len
Definition: misc_types.hh:445
gem5::memory::PhysicalMemory::getBackingStore
std::vector< BackingStoreEntry > getBackingStore() const
Get the pointers to the backing store for external host access.
Definition: physical.hh:227
gem5::KvmVM::setUserMemoryRegion
void setUserMemoryRegion(uint32_t slot, void *host_addr, Addr guest_addr, uint64_t len, uint32_t flags)
Setup a region of physical memory in the guest.
Definition: vm.cc:447
gem5::Kvm::instance
static Kvm * instance
Singleton instance.
Definition: vm.hh:268
gem5::AddrRange::start
Addr start() const
Get the start address of the range.
Definition: addr_range.hh:343
gem5::Kvm::capCoalescedMMIO
int capCoalescedMMIO() const
Check if coalesced MMIO is supported and which page in the MMAP'ed structure it stores requests in.
Definition: vm.cc:136
warn
#define warn(...)
Definition: logging.hh:246
system.hh
gem5::KvmVM::createIRQChip
void createIRQChip()
Create an in-kernel interrupt controller.
Definition: vm.cc:501
gem5::MipsISA::cpuid
Bitfield< 28, 21 > cpuid
Definition: dt_constants.hh:95
gem5::KvmVM::setTSSAddress
void setTSSAddress(Addr tss_address)
Setup a shared three-page memory region used by the internals of KVM.
Definition: vm.cc:494
gem5::ArmISA::fd
Bitfield< 14, 12 > fd
Definition: types.hh:150
warn_once
#define warn_once(...)
Definition: logging.hh:250
gem5::Kvm::create
Kvm * create()
Definition: vm.cc:99
gem5::KvmVM::allocVCPUID
long allocVCPUID()
Allocate a new vCPU ID within the VM.
Definition: vm.cc:574
gem5::KvmVM::disableMemSlot
void disableMemSlot(const MemSlot slot)
Disable a memory slot.
Definition: vm.cc:430
gem5::KvmVM::setSystem
void setSystem(System *s)
Initialize system pointer.
Definition: vm.cc:546
gem5::KvmVM::maxMemorySlot
uint32_t maxMemorySlot
Definition: vm.hh:557
gem5::X86ISA::system
Bitfield< 15 > system
Definition: misc.hh:1003
gem5::Kvm::capExtendedCPUID
bool capExtendedCPUID() const
Support for BaseKvmCPU::setCPUID2 and getSupportedCPUID().
Definition: vm.cc:120
std::vector
STL vector class.
Definition: stl.hh:37
gem5::KvmVM::ioctl
int ioctl(int request, long p1) const
KVM VM ioctl interface.
Definition: vm.cc:591
gem5::KvmVM::coalesceMMIO
void coalesceMMIO(Addr start, int size)
Request coalescing MMIO for a memory range.
Definition: vm.cc:478
gem5::Kvm::capUserMemory
bool capUserMemory() const
Support for KvmVM::setUserMemoryRegion()
Definition: vm.cc:108
gem5::KvmVM::KvmVM
KvmVM(const KvmVMParams &params)
Definition: vm.cc:307
gem5::ArmISA::i
Bitfield< 7 > i
Definition: misc_types.hh:67
gem5::Kvm::capXCRs
bool capXCRs() const
Support for getting and setting the x86 XCRs.
Definition: vm.cc:188
gem5::Kvm::capXSave
bool capXSave() const
Support for getting and setting the kvm_xsave structure.
Definition: vm.cc:198
hack
#define hack(...)
Definition: logging.hh:248
gem5::Kvm::capIRQChip
bool capIRQChip() const
Support for creating an in-kernel IRQ chip model.
Definition: vm.cc:162
gem5::ArmISA::irq
Bitfield< 1 > irq
Definition: misc_types.hh:331
gem5::Kvm::checkExtension
int checkExtension(int extension) const
Check for the presence of an extension to the KVM API.
Definition: vm.cc:278
gem5::high
high
Definition: intmath.hh:176
gem5::System
Definition: system.hh:75
gem5::Kvm::capVCPUEvents
bool capVCPUEvents() const
Support for getting and setting the kvm_vcpu_events structure.
Definition: vm.cc:168
gem5::AddrRange::interleaved
bool interleaved() const
Determine if the range is interleaved or not.
Definition: addr_range.hh:284
gem5::SimObject::params
const Params & params() const
Definition: sim_object.hh:176
DPRINTF
#define DPRINTF(x,...)
Definition: trace.hh:186
gem5::BaseKvmCPU
Base class for KVM based CPU models.
Definition: base.hh:87
gem5::Kvm::vcpuMMapSize
int vcpuMMapSize
Size of the MMAPed vCPU parameter area.
Definition: vm.hh:265
gem5::MipsISA::p
Bitfield< 0 > p
Definition: pra_constants.hh:326
gem5::KvmVM::system
System * system
Definition: vm.hh:532
gem5::Kvm::Kvm
Kvm()
Definition: vm.cc:71
gem5::KvmVM::_hasKernelIRQChip
bool _hasKernelIRQChip
Do we have in-kernel IRQ-chip emulation enabled?
Definition: vm.hh:541
gem5::X86ISA::type
type
Definition: misc.hh:733
gem5::ArmISA::s
Bitfield< 4 > s
Definition: misc_types.hh:562
gem5::Kvm::kvmFD
int kvmFD
KVM VM file descriptor.
Definition: vm.hh:261
gem5::KvmVM::started
bool started
Has delayedStartup() already been called?
Definition: vm.hh:538
gem5::KvmVM::setIRQLine
void setIRQLine(uint32_t irq, bool high)
Set the status of an IRQ line using KVM_IRQ_LINE.
Definition: vm.cc:516
gem5::AddrRange::size
Addr size() const
Get the size of the address range.
Definition: addr_range.hh:326
gem5::KvmVM::delayedStartup
void delayedStartup()
Delayed initialization, executed once before the first CPU starts.
Definition: vm.cc:358
gem5::Kvm::ioctl
int ioctl(int request, long p1) const
Main VM ioctl interface.
Definition: vm.cc:287
gem5::SimObject
Abstract superclass for simulation objects.
Definition: sim_object.hh:146
gem5::KvmVM::MemSlot
Definition: vm.hh:371
gem5::KvmVM::contextIdToVCpuId
long contextIdToVCpuId(ContextID ctx) const
Get the VCPUID for a given context.
Definition: vm.cc:554
gem5::Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147
base.hh
vm.hh
gem5::KvmVM::kvm
Kvm * kvm
Global KVM interface.
Definition: vm.hh:417
gem5::KvmVM::cpuStartup
void cpuStartup()
VM CPU initialization code.
Definition: vm.cc:348
gem5::KvmVM::MemorySlot
Structures tracking memory slots.
Definition: vm.hh:549
panic_if
#define panic_if(cond,...)
Conditional panic macro that checks the supplied condition and only panics if the condition is true a...
Definition: logging.hh:204
gem5::ArmISA::m
Bitfield< 0 > m
Definition: misc_types.hh:395
gem5::KvmVM::allocMemSlot
const MemSlot allocMemSlot(uint64_t size)
Allocate a memory slot within the VM.
Definition: vm.cc:393
gem5::Kvm::capDebugRegs
bool capDebugRegs() const
Support for getting and setting the kvm_debugregs structure.
Definition: vm.cc:178
gem5::System::threads
Threads threads
Definition: system.hh:314
gem5::KvmVM::nextVCPUID
long nextVCPUID
Next unallocated vCPU ID.
Definition: vm.hh:544
physical.hh
gem5::ContextID
int ContextID
Globally unique thread context ID.
Definition: types.hh:246
gem5::Kvm
KVM parent interface.
Definition: vm.hh:80
gem5::KvmVM::MemorySlot::active
bool active
Definition: vm.hh:554
gem5::KvmVM::MemorySlot::size
uint64_t size
Definition: vm.hh:552
gem5::Kvm::capNumMemSlots
int capNumMemSlots() const
Attempt to determine how many memory slots are available.
Definition: vm.cc:142
gem5::System::getPhysMem
memory::PhysicalMemory & getPhysMem()
Get a pointer to access the physical memory of the system.
Definition: system.hh:343
gem5::Kvm::~Kvm
virtual ~Kvm()
Definition: vm.cc:93
gem5::AddrRange
The AddrRange class encapsulates an address range, and supports a number of tests to check if two ran...
Definition: addr_range.hh:81
gem5::Kvm::apiVersion
int apiVersion
KVM API version.
Definition: vm.hh:263
gem5::KvmVM::MemSlot::num
int32_t num
Definition: vm.hh:378
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: tlb.cc:60
gem5::KvmVM::notifyFork
void notifyFork()
Notify a child process of a fork.
Definition: vm.cc:334
gem5::KvmVM::memorySlots
std::vector< MemorySlot > memorySlots
Definition: vm.hh:556
gem5::KvmVM::~KvmVM
virtual ~KvmVM()
Definition: vm.cc:324
gem5::Kvm::capOneReg
bool capOneReg() const
Support for reading and writing single registers.
Definition: vm.cc:152
panic
#define panic(...)
This implements a cprintf based panic() function.
Definition: logging.hh:178
gem5::Kvm::createVM
int createVM()
Create a KVM Virtual Machine.
Definition: vm.cc:295
gem5::KvmVM::setupMemSlot
void setupMemSlot(const MemSlot slot, void *host_addr, Addr guest_addr, uint32_t flags)
Setup a region of physical memory in the guest.
Definition: vm.cc:421
gem5::KvmVM::createDevice
int createDevice(uint32_t type, uint32_t flags=0)
Create an in-kernel device model.
Definition: vm.cc:529

Generated on Tue Dec 21 2021 11:34:25 for gem5 by doxygen 1.8.17