sim: add validation to make sure there is memory where we're loading the kernel
authorKrishnendra Nathella <Krishnendra.Nathella@arm.com>
Fri, 7 Sep 2012 19:20:53 +0000 (14:20 -0500)
committerKrishnendra Nathella <Krishnendra.Nathella@arm.com>
Fri, 7 Sep 2012 19:20:53 +0000 (14:20 -0500)
src/sim/system.cc

index 2dd4d41bd14db1fb72711dd99a298c419293df81..4871ac824916059325c63945b72d95c2cb71c2de 100644 (file)
@@ -266,6 +266,13 @@ System::initState()
          * Load the kernel code into memory
          */
         if (params()->kernel != "")  {
+            // Validate kernel mapping before loading binary
+            if (!(isMemAddr(kernelStart & loadAddrMask) &&
+                            isMemAddr(kernelEnd & loadAddrMask))) {
+                fatal("Kernel is mapped to invalid location (not memory). "
+                      "kernelStart 0x(%x) - kernelEnd 0x(%x)\n", kernelStart,
+                      kernelEnd);
+            }
             // Load program sections into memory
             kernel->loadSections(physProxy, loadAddrMask);