vm.cc (11793:ef606668d247) vm.cc (11839:dd6df2e47c14)
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

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

287 panic("Failed to create KVM VM\n");
288
289 return vmFD;
290}
291
292
293KvmVM::KvmVM(KvmVMParams *params)
294 : SimObject(params),
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

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

287 panic("Failed to create KVM VM\n");
288
289 return vmFD;
290}
291
292
293KvmVM::KvmVM(KvmVMParams *params)
294 : SimObject(params),
295 kvm(new Kvm()), system(params->system),
295 kvm(new Kvm()), system(nullptr),
296 vmFD(kvm->createVM()),
297 started(false),
298 nextVCPUID(0)
299{
300 maxMemorySlot = kvm->capNumMemSlots();
301 /* If we couldn't determine how memory slots there are, guess 32. */
302 if (!maxMemorySlot)
303 maxMemorySlot = 32;

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

337 started = true;
338
339 delayedStartup();
340}
341
342void
343KvmVM::delayedStartup()
344{
296 vmFD(kvm->createVM()),
297 started(false),
298 nextVCPUID(0)
299{
300 maxMemorySlot = kvm->capNumMemSlots();
301 /* If we couldn't determine how memory slots there are, guess 32. */
302 if (!maxMemorySlot)
303 maxMemorySlot = 32;

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

337 started = true;
338
339 delayedStartup();
340}
341
342void
343KvmVM::delayedStartup()
344{
345 assert(system); // set by the system during its construction
345 const std::vector<BackingStoreEntry> &memories(
346 system->getPhysMem().getBackingStore());
347
348 DPRINTF(Kvm, "Mapping %i memory region(s)\n", memories.size());
349 for (int slot(0); slot < memories.size(); ++slot) {
350 if (!memories[slot].kvmMap) {
351 DPRINTF(Kvm, "Skipping region marked as not usable by KVM\n");
352 continue;

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

521 }
522
523 return dev.fd;
524#else
525 panic("Kernel headers don't support KVM_CREATE_DEVICE\n");
526#endif
527}
528
346 const std::vector<BackingStoreEntry> &memories(
347 system->getPhysMem().getBackingStore());
348
349 DPRINTF(Kvm, "Mapping %i memory region(s)\n", memories.size());
350 for (int slot(0); slot < memories.size(); ++slot) {
351 if (!memories[slot].kvmMap) {
352 DPRINTF(Kvm, "Skipping region marked as not usable by KVM\n");
353 continue;

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

522 }
523
524 return dev.fd;
525#else
526 panic("Kernel headers don't support KVM_CREATE_DEVICE\n");
527#endif
528}
529
530void
531KvmVM::setSystem(System *s) {
532 panic_if(system != nullptr, "setSystem() can only be called once");
533 panic_if(s == nullptr, "setSystem() called with null System*");
534 system = s;
535}
536
529int
530KvmVM::createVCPU(long vcpuID)
531{
532 int fd;
533
534 fd = ioctl(KVM_CREATE_VCPU, vcpuID);
535 if (fd == -1)
536 panic("KVM: Failed to create virtual CPU");

--- 41 unchanged lines hidden ---
537int
538KvmVM::createVCPU(long vcpuID)
539{
540 int fd;
541
542 fd = ioctl(KVM_CREATE_VCPU, vcpuID);
543 if (fd == -1)
544 panic("KVM: Failed to create virtual CPU");

--- 41 unchanged lines hidden ---