config: Add --memchecker option
authorMarco Elver <Marco.Elver@ARM.com>
Tue, 23 Dec 2014 14:31:18 +0000 (09:31 -0500)
committerMarco Elver <Marco.Elver@ARM.com>
Tue, 23 Dec 2014 14:31:18 +0000 (09:31 -0500)
This patch adds the --memchecker option, to denote that a MemChecker
should be instantiated for the system. The exact usage of the MemChecker
depends on the system configuration.

For now CacheConfig.py makes use of the option, adding MemCheckerMonitor
instances between CPUs and D-Caches.

Note, however, that currently this only provides limited checking on a
running system; other parts of the system, such as I/O devices are not
monitored, and may cause warnings to be issued by the monitor.

configs/common/CacheConfig.py
configs/common/Options.py

index c7a724b3438a85fddda5c6c3d36d5a5a6d20747f..f31b3d566ab4a31daa99b2ec0585fe519c0ff723 100644 (file)
@@ -76,6 +76,9 @@ def config_cache(options, system):
         system.l2.cpu_side = system.tol2bus.master
         system.l2.mem_side = system.membus.slave
 
+    if options.memchecker:
+        system.memchecker = MemChecker()
+
     for i in xrange(options.num_cpus):
         if options.caches:
             icache = icache_class(size=options.l1i_size,
@@ -83,6 +86,21 @@ def config_cache(options, system):
             dcache = dcache_class(size=options.l1d_size,
                                   assoc=options.l1d_assoc)
 
+            if options.memchecker:
+                dcache_mon = MemCheckerMonitor(warn_only=True)
+                dcache_real = dcache
+
+                # Do not pass the memchecker into the constructor of
+                # MemCheckerMonitor, as it would create a copy; we require
+                # exactly one MemChecker instance.
+                dcache_mon.memchecker = system.memchecker
+
+                # Connect monitor
+                dcache_mon.mem_side = dcache.cpu_side
+
+                # Let CPU connect to monitors
+                dcache = dcache_mon
+
             # When connecting the caches, the clock is also inherited
             # from the CPU in question
             if buildEnv['TARGET_ISA'] == 'x86':
@@ -91,6 +109,13 @@ def config_cache(options, system):
                                                       PageTableWalkerCache())
             else:
                 system.cpu[i].addPrivateSplitL1Caches(icache, dcache)
+
+            if options.memchecker:
+                # The mem_side ports of the caches haven't been connected yet.
+                # Make sure connectAllPorts connects the right objects.
+                system.cpu[i].dcache = dcache_real
+                system.cpu[i].dcache_mon = dcache_mon
+
         system.cpu[i].createInterruptController()
         if options.l2cache:
             system.cpu[i].connectAllPorts(system.tol2bus, system.membus)
index cb5ffad2ec645107b04d784f5573bd10dec59be9..f81e69a61aa6a1769df3df443bbba9cbbe2e17b1 100644 (file)
@@ -97,6 +97,8 @@ def addCommonOptions(parser):
     parser.add_option("-l", "--lpae", action="store_true")
     parser.add_option("-V", "--virtualisation", action="store_true")
 
+    parser.add_option("--memchecker", action="store_true")
+
     # Cache Options
     parser.add_option("--caches", action="store_true")
     parser.add_option("--l2cache", action="store_true")