Hello Curtis Dunham,

I'd like you to do a code review. Please visit

    https://gem5-review.googlesource.com/2323

to review the following change.


Change subject: sim: Implement load_addr_mask auto-calculation
......................................................................

sim: Implement load_addr_mask auto-calculation

Recent Linux kernels for AArch64 have changed their start addresses
but we still want to relocate the kernel to 0x80080000 which
required hacking the load_addr_mask in Realview.py to be 0x7ffffff
from 0xfffffff to mask off the proper number of MSBs to load the
kernel in the desired location.  To avoid having to make this change
in the future again, we auto-calculate  the load_addr_mask if it is
specified as 0x0 in the System sim-object to find the most restrictive
address mask instead of having the configuration specify it.  If the
configuration does specify the address mask, we use it instead of
auto-calculating.

Change-Id: I18aabb5d09945c6e3e3819c9c8036ea24b6c35cf
Signed-off-by: Geoffrey Blake <geoffrey.bl...@arm.com>
Reviewed-by: Curtis Dunham <curtis.dun...@arm.com>
Signed-off-by: Andreas Sandberg <andreas.sandb...@arm.com>
---
M src/arch/arm/ArmSystem.py
M src/dev/arm/RealView.py
M src/sim/System.py
M src/sim/system.cc
4 files changed, 30 insertions(+), 10 deletions(-)



diff --git a/src/arch/arm/ArmSystem.py b/src/arch/arm/ArmSystem.py
index 9100db0..4020046 100644
--- a/src/arch/arm/ArmSystem.py
+++ b/src/arch/arm/ArmSystem.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2012-2013, 2015 ARM Limited
+# Copyright (c) 2009, 2012-2013, 2015-2017 ARM Limited
 # All rights reserved.
 #
 # The license below extends only to copyright in the software and shall
@@ -51,7 +51,6 @@
 class ArmSystem(System):
     type = 'ArmSystem'
     cxx_header = "arch/arm/system.hh"
-    load_addr_mask = 0xffffffff
     multi_proc = Param.Bool(True, "Multiprocessor system?")
     boot_loader = VectorParam.String([],
"File that contains the boot loader code. Zero or more files may be "
@@ -78,7 +77,6 @@
 class GenericArmSystem(ArmSystem):
     type = 'GenericArmSystem'
     cxx_header = "arch/arm/system.hh"
-    load_addr_mask = 0x0fffffff
     machine_type = Param.ArmMachineType('VExpress_EMM',
         "Machine id from http://www.arm.linux.org.uk/developer/machines/";)
atags_addr = Param.Addr("Address where default atags structure should " \
@@ -98,6 +96,10 @@
     type = 'LinuxArmSystem'
     cxx_header = "arch/arm/linux/system.hh"

+    # Have Linux systems for ARM auto-calc their load_addr_mask for proper
+    # kernel relocation.
+    load_addr_mask = 0x0
+
     @classmethod
     def export_methods(cls, code):
         code('''void dumpDmesg();''')
diff --git a/src/dev/arm/RealView.py b/src/dev/arm/RealView.py
index 20112d4..b44cffc 100644
--- a/src/dev/arm/RealView.py
+++ b/src/dev/arm/RealView.py
@@ -360,7 +360,6 @@
         self.nvmem.port = mem_bus.master
         cur_sys.boot_loader = loc('boot.arm')
         cur_sys.atags_addr = 0x100
-        cur_sys.load_addr_mask = 0xfffffff
         cur_sys.load_offset = 0


@@ -673,7 +672,6 @@
         self.nvmem.port = mem_bus.master
         cur_sys.boot_loader = loc('boot_emm.arm')
         cur_sys.atags_addr = 0x8000000
-        cur_sys.load_addr_mask = 0xfffffff
         cur_sys.load_offset = 0x80000000

     # Attach I/O devices that are on chip and also set the appropriate
@@ -784,7 +782,6 @@
         self.nvmem.port = mem_bus.master
         cur_sys.boot_loader = loc('boot_emm.arm64')
         cur_sys.atags_addr = 0x8000000
-        cur_sys.load_addr_mask = 0xfffffff
         cur_sys.load_offset = 0x80000000


@@ -954,5 +951,4 @@
         self.nvmem.port = mem_bus.master
cur_sys.boot_loader = [ loc('boot_emm.arm64'), loc('boot_emm.arm') ]
         cur_sys.atags_addr = 0x8000000
-        cur_sys.load_addr_mask = 0xfffffff
         cur_sys.load_offset = 0x80000000
diff --git a/src/sim/System.py b/src/sim/System.py
index e3e42d8..d6c6556 100644
--- a/src/sim/System.py
+++ b/src/sim/System.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2017 ARM Limited
+# All rights reserved.
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder.  You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
 # Copyright (c) 2005-2007 The Regents of The University of Michigan
 # Copyright (c) 2011 Regents of the University of California
 # All rights reserved.
@@ -97,8 +109,10 @@
         "whether to address check on kernel (disable for baremetal)")
     readfile = Param.String("", "file to read startup script from")
     symbolfile = Param.String("", "file to get the symbols from")
-    load_addr_mask = Param.UInt64(0xffffffffff,
-            "Address to mask loading binaries with")
+    load_addr_mask = Param.UInt64(0xffffffffffffffff,
+            "Address to mask loading binaries with, if 0, system "
+            "auto-calculates the mask to be the most restrictive, "
+            "otherwise it obeys a custom mask.")
load_offset = Param.UInt64(0, "Address to offset loading binaries with")

     multi_thread = Param.Bool(False,
diff --git a/src/sim/system.cc b/src/sim/system.cc
index 9315882..38f1744 100644
--- a/src/sim/system.cc
+++ b/src/sim/system.cc
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011-2014 ARM Limited
+ * Copyright (c) 2011-2014,2017 ARM Limited
  * All rights reserved
  *
  * The license below extends only to copyright in the software and shall
@@ -156,6 +156,14 @@
             kernelEnd = kernel->bssBase() + kernel->bssSize();
             kernelEntry = kernel->entryPoint();

+            // If load_addr_mask is set to 0x0, then auto-calculate
+            // the smallest mask to cover all kernel addresses so gem5
+            // can re-locate the kernel to a new offset.
+            if (loadAddrMask == 0) {
+                Addr shift_amt = findMsbSet(kernelEnd - kernelStart) + 1;
+                loadAddrMask = ((Addr)1 << shift_amt) - 1;
+            }
+
             // load symbols
             if (!kernel->loadGlobalSymbols(kernelSymtab))
                 fatal("could not load kernel symbols\n");

--
To view, visit https://gem5-review.googlesource.com/2323
To unsubscribe, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I18aabb5d09945c6e3e3819c9c8036ea24b6c35cf
Gerrit-Change-Number: 2323
Gerrit-PatchSet: 1
Gerrit-Owner: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Curtis Dunham <curtis.dun...@arm.com>
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to