summaryrefslogtreecommitdiff
path: root/src/mem/physical.cc
diff options
context:
space:
mode:
authorDavid Hashe <david.j.hashe@gmail.com>2016-08-22 11:41:05 -0400
committerDavid Hashe <david.j.hashe@gmail.com>2016-08-22 11:41:05 -0400
commitf3ccaab1e982f4482177aefa95575f7d7dae21f7 (patch)
tree8797cdd232c0ccafa53d0601bc9da14a16f6db00 /src/mem/physical.cc
parentd80a613990935dd144a5665a875f91725ee81f78 (diff)
downloadgem5-f3ccaab1e982f4482177aefa95575f7d7dae21f7.tar.xz
cpu, mem, sim: Change how KVM maps memory
Only map memories into the KVM guest address space that are marked as usable by KVM. Create BackingStoreEntry class containing flags for is_conf_reported, in_addr_map, and kvm_map.
Diffstat (limited to 'src/mem/physical.cc')
-rw-r--r--src/mem/physical.cc51
1 files changed, 41 insertions, 10 deletions
diff --git a/src/mem/physical.cc b/src/mem/physical.cc
index 82e331fe1..05881b224 100644
--- a/src/mem/physical.cc
+++ b/src/mem/physical.cc
@@ -111,7 +111,9 @@ PhysicalMemory::PhysicalMemory(const string& _name,
// memories are allowed to overlap in the logic address
// map
vector<AbstractMemory*> unmapped_mems{m};
- createBackingStore(m->getAddrRange(), unmapped_mems);
+ createBackingStore(m->getAddrRange(), unmapped_mems,
+ m->isConfReported(), m->isInAddrMap(),
+ m->isKvmMap());
}
}
@@ -132,7 +134,19 @@ PhysicalMemory::PhysicalMemory(const string& _name,
if (!intlv_ranges.empty() &&
!intlv_ranges.back().mergesWith(r.first)) {
AddrRange merged_range(intlv_ranges);
- createBackingStore(merged_range, curr_memories);
+
+ AbstractMemory *f = curr_memories.front();
+ for (const auto& c : curr_memories)
+ if (f->isConfReported() != c->isConfReported() ||
+ f->isInAddrMap() != c->isInAddrMap() ||
+ f->isKvmMap() != c->isKvmMap())
+ fatal("Inconsistent flags in an interleaved "
+ "range\n");
+
+ createBackingStore(merged_range, curr_memories,
+ f->isConfReported(), f->isInAddrMap(),
+ f->isKvmMap());
+
intlv_ranges.clear();
curr_memories.clear();
}
@@ -140,7 +154,10 @@ PhysicalMemory::PhysicalMemory(const string& _name,
curr_memories.push_back(r.second);
} else {
vector<AbstractMemory*> single_memory{r.second};
- createBackingStore(r.first, single_memory);
+ createBackingStore(r.first, single_memory,
+ r.second->isConfReported(),
+ r.second->isInAddrMap(),
+ r.second->isKvmMap());
}
}
}
@@ -149,13 +166,26 @@ PhysicalMemory::PhysicalMemory(const string& _name,
// ahead and do it
if (!intlv_ranges.empty()) {
AddrRange merged_range(intlv_ranges);
- createBackingStore(merged_range, curr_memories);
+
+ AbstractMemory *f = curr_memories.front();
+ for (const auto& c : curr_memories)
+ if (f->isConfReported() != c->isConfReported() ||
+ f->isInAddrMap() != c->isInAddrMap() ||
+ f->isKvmMap() != c->isKvmMap())
+ fatal("Inconsistent flags in an interleaved "
+ "range\n");
+
+ createBackingStore(merged_range, curr_memories,
+ f->isConfReported(), f->isInAddrMap(),
+ f->isKvmMap());
}
}
void
PhysicalMemory::createBackingStore(AddrRange range,
- const vector<AbstractMemory*>& _memories)
+ const vector<AbstractMemory*>& _memories,
+ bool conf_table_reported,
+ bool in_addr_map, bool kvm_map)
{
panic_if(range.interleaved(),
"Cannot create backing store for interleaved range %s\n",
@@ -184,7 +214,8 @@ PhysicalMemory::createBackingStore(AddrRange range,
// remember this backing store so we can checkpoint it and unmap
// it appropriately
- backingStore.push_back(make_pair(range, pmem));
+ backingStore.emplace_back(range, pmem,
+ conf_table_reported, in_addr_map, kvm_map);
// point the memories to their backing store
for (const auto& m : _memories) {
@@ -198,7 +229,7 @@ PhysicalMemory::~PhysicalMemory()
{
// unmap the backing store
for (auto& s : backingStore)
- munmap((char*)s.second, s.first.size());
+ munmap((char*)s.pmem, s.range.size());
}
bool
@@ -314,7 +345,7 @@ PhysicalMemory::serialize(CheckpointOut &cp) const
// store each backing store memory segment in a file
for (auto& s : backingStore) {
ScopedCheckpointSection sec(cp, csprintf("store%d", store_id));
- serializeStore(cp, store_id++, s.first, s.second);
+ serializeStore(cp, store_id++, s.range, s.pmem);
}
}
@@ -407,8 +438,8 @@ PhysicalMemory::unserializeStore(CheckpointIn &cp)
fatal("Can't open physical memory checkpoint file '%s'", filename);
// we've already got the actual backing store mapped
- uint8_t* pmem = backingStore[store_id].second;
- AddrRange range = backingStore[store_id].first;
+ uint8_t* pmem = backingStore[store_id].pmem;
+ AddrRange range = backingStore[store_id].range;
long range_size;
UNSERIALIZE_SCALAR(range_size);