summaryrefslogtreecommitdiff
path: root/src/cpu/kvm/vm.hh
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2014-12-09 21:53:44 -0800
committerGabe Black <gabeblack@google.com>2014-12-09 21:53:44 -0800
commit70eb68beae90c6f27ca3c45cfd3f53531e548cb4 (patch)
treea77790060fb50d8b7d3b39d1fa6c12d67f3e7a62 /src/cpu/kvm/vm.hh
parent9b7578d8c7f82e255776a354657d1f19f1ca64f4 (diff)
downloadgem5-70eb68beae90c6f27ca3c45cfd3f53531e548cb4.tar.xz
Let other objects set up memory like regions in a KVM VM.
Diffstat (limited to 'src/cpu/kvm/vm.hh')
-rw-r--r--src/cpu/kvm/vm.hh60
1 files changed, 56 insertions, 4 deletions
diff --git a/src/cpu/kvm/vm.hh b/src/cpu/kvm/vm.hh
index 660805ed7..84d526705 100644
--- a/src/cpu/kvm/vm.hh
+++ b/src/cpu/kvm/vm.hh
@@ -1,4 +1,5 @@
/*
+ * Copyright 2014 Google, Inc.
* Copyright (c) 2012 ARM Limited
* All rights reserved
*
@@ -110,6 +111,12 @@ class Kvm
int capCoalescedMMIO() const;
/**
+ * Attempt to determine how many memory slots are available. If it can't
+ * be determined, this function returns 0.
+ */
+ int capNumMemSlots() const;
+
+ /**
* Support for reading and writing single registers.
*
* @see BaseKvmCPU::getOneReg(), and BaseKvmCPU::setOneReg()
@@ -331,6 +338,42 @@ class KvmVM : public SimObject
bool hasKernelIRQChip() const { return _hasKernelIRQChip; }
/** @} */
+ struct MemSlot
+ {
+ MemSlot(uint32_t _num) : num(_num)
+ {}
+ MemSlot() : num(-1)
+ {}
+
+ int32_t num;
+ };
+
+ /**
+ * Allocate a memory slot within the VM.
+ */
+ const MemSlot allocMemSlot(uint64_t size);
+
+ /**
+ * Setup a region of physical memory in the guest
+ *
+ * @param slot KVM memory slot ID returned by allocMemSlot
+ * @param host_addr Memory allocation backing the memory
+ * @param guest_addr Address in the guest
+ * @param flags Flags (see the KVM API documentation)
+ */
+ void setupMemSlot(const MemSlot slot, void *host_addr, Addr guest_addr,
+ uint32_t flags);
+
+ /**
+ * Disable a memory slot.
+ */
+ void disableMemSlot(const MemSlot slot);
+
+ /**
+ * Free a previously allocated memory slot.
+ */
+ void freeMemSlot(const MemSlot slot);
+
/** Global KVM interface */
Kvm kvm;
@@ -366,16 +409,12 @@ class KvmVM : public SimObject
* @param slot KVM memory slot ID (must be unique)
* @param host_addr Memory allocation backing the memory
* @param guest_addr Address in the guest
- * @param guest_range Address range used by guest.
* @param len Size of the allocation in bytes
* @param flags Flags (see the KVM API documentation)
*/
void setUserMemoryRegion(uint32_t slot,
void *host_addr, Addr guest_addr,
uint64_t len, uint32_t flags);
- void setUserMemoryRegion(uint32_t slot,
- void *host_addr, AddrRange guest_range,
- uint32_t flags);
/** @} */
/**
@@ -437,6 +476,19 @@ class KvmVM : public SimObject
/** Next unallocated vCPU ID */
long nextVCPUID;
+
+ /**
+ * Structures tracking memory slots.
+ */
+ class MemorySlot
+ {
+ public:
+ uint64_t size;
+ uint32_t slot;
+ bool active;
+ };
+ std::vector<MemorySlot> memorySlots;
+ uint32_t maxMemorySlot;
};
#endif