gem5.git
9 years agoarm: Fixes based on UBSan and static analysis
Andreas Hansson [Fri, 14 Nov 2014 08:53:51 +0000 (03:53 -0500)]
arm: Fixes based on UBSan and static analysis

Another churn to clean up undefined behaviour, mostly ARM, but some
parts also touching the generic part of the code base.

Most of the fixes are simply ensuring that proper intialisation. One
of the more subtle changes is the return type of the sign-extension,
which is changed to uint64_t. This is to avoid shifting negative
values (undefined behaviour) in the ISA code.

9 years agomem: Clarify unit of DRAM controller buffer size
Andreas Hansson [Fri, 14 Nov 2014 08:53:48 +0000 (03:53 -0500)]
mem: Clarify unit of DRAM controller buffer size

9 years agostats: Bump regressions to match latest changes
Andreas Hansson [Wed, 12 Nov 2014 14:05:25 +0000 (09:05 -0500)]
stats: Bump regressions to match latest changes

Updates after timezone hick-up and sorting of dictionary items in the
SimObject.

9 years agomem: Delete unused variable in Garnet NetworkLink
Mitch Hayenga [Wed, 12 Nov 2014 14:05:23 +0000 (09:05 -0500)]
mem: Delete unused variable in Garnet NetworkLink

With recent changes OSX clang compilation fails due to an unused variable.

9 years agoarm: Fix timing wakeup with LLSC
Ali Saidi [Wed, 12 Nov 2014 14:05:22 +0000 (09:05 -0500)]
arm: Fix timing wakeup with LLSC

9 years agosim: Sort SimObject descendants and ports
Andreas Hansson [Wed, 12 Nov 2014 14:05:21 +0000 (09:05 -0500)]
sim: Sort SimObject descendants and ports

This patch fixes a number of occurences where the sorting order of the
objects was implementation defined.

9 years agobase: Revert 9277177eccff and use getenv/setenv for UTC time
Andreas Hansson [Wed, 12 Nov 2014 14:05:20 +0000 (09:05 -0500)]
base: Revert 9277177eccff and use getenv/setenv for UTC time

This patch reverts changeset 9277177eccff which does not do what it
was intended to do. In essence, we go back to implementing mkutctime
much like the non-standard timegm extension.

9 years agostats: changes to x86 o3 fs and sparc fs regression tests.
Nilay Vaish [Tue, 11 Nov 2014 20:17:10 +0000 (14:17 -0600)]
stats: changes to x86 o3 fs and sparc fs regression tests.

9 years agox86 isa: This patch attempts an implementation at mwait.
Marc Orr [Thu, 6 Nov 2014 11:42:22 +0000 (05:42 -0600)]
x86 isa: This patch attempts an implementation at mwait.

Mwait works as follows:
1. A cpu monitors an address of interest (monitor instruction)
2. A cpu calls mwait - this loads the cache line into that cpu's cache.
3. The cpu goes to sleep.
4. When another processor requests write permission for the line, it is
   evicted from the sleeping cpu's cache. This eviction is forwarded to the
   sleeping cpu, which then wakes up.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agotests: A test program for the new mwait implementation.
Marc Orr [Thu, 6 Nov 2014 11:42:21 +0000 (05:42 -0600)]
tests: A test program for the new mwait implementation.

This is a simple test program for the new mwait implemenation. It is uses
m5threads to create to threads of execution in syscall emulation mode that
interact using the mwait instruction.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agocpu: Minor Draining Bug
Andrew Lukefahr [Thu, 6 Nov 2014 11:42:21 +0000 (05:42 -0600)]
cpu: Minor Draining Bug

Fixes a bug where Minor drains in the midst of committing a
conditional store.

While committing a conditional store, lastCommitWasEndOfMacroop is true
(from the previous instruction) as we still haven't finished the conditional
store. If a drain occurs before the cache response, Minor would check just
lastCommitWasEndOfMacroop, which was true, and set drainState=DrainHaltFetch,
which increases the streamSeqNum.  This caused the conditional store to be
squashed when the memory responded and it completed.  However, to the memory
the store succeeded, while to the instruction sequence it never occurred.

In the case of an LLSC, the instruction sequence will replay the squashed
STREX, which will fail as the cache is no longer in LLSC.  Then the
instruction sequence will loop back to a LDREX, which receives the updated
(incorrect) value.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agostats: updates due to changes to ruby
Nilay Vaish [Thu, 6 Nov 2014 11:42:21 +0000 (05:42 -0600)]
stats: updates due to changes to ruby

9 years agoruby: provide a backing store
Nilay Vaish [Thu, 6 Nov 2014 11:42:21 +0000 (05:42 -0600)]
ruby: provide a backing store
Ruby's functional accesses are not guaranteed to succeed as of now.  While
this is not a problem for the protocols that are currently in the mainline
repo, it seems that coherence protocols for gpus rely on a backing store to
supply the correct data.  The aim of this patch is to make this backing store
configurable i.e. it comes into play only when a particular option:
--access-backing-store is invoked.

The backing store has been there since M5 and GEMS were integrated.  The only
difference is that earlier the system used to maintain the backing store and
ruby's copy was write-only.  Sometime last year, we moved to data being
supplied supplied by ruby in SE mode simulations.  And now we have patches on
the reviewboard, which remove ruby's copy of memory altogether and rely
completely on the system's memory to supply data.  This patch adds back a
SimpleMemory member to RubySystem.  This member is used only if the option:
access-backing-store is set to true.  By default, the memory would not be
accessed.

9 years agoruby: interface with classic memory controller
Nilay Vaish [Thu, 6 Nov 2014 11:42:21 +0000 (05:42 -0600)]
ruby: interface with classic memory controller
This patch is the final in the series.  The whole series and this patch in
particular were written with the aim of interfacing ruby's directory controller
with the memory controller in the classic memory system.  This is being done
since ruby's memory controller has not being kept up to date with the changes
going on in DRAMs.  Classic's memory controller is more up to date and
supports multiple different types of DRAM.  This also brings classic and
ruby ever more close.  The patch also changes ruby's memory controller to
expose the same interface.

9 years agoruby: remove the function functionalReadBuffers()
Nilay Vaish [Thu, 6 Nov 2014 11:42:20 +0000 (05:42 -0600)]
ruby: remove the function functionalReadBuffers()
This function was added when I had incorrectly arrived at the conclusion
that such a function can improve the chances of a functional read succeeding.
As was later realized, this is not possible in the current setup.  While the
code using this function was dropped long back, this function was not.  Hence
the patch.

9 years agoruby: coherence protocols: remove data block from dirctory entry
Nilay Vaish [Thu, 6 Nov 2014 11:42:20 +0000 (05:42 -0600)]
ruby: coherence protocols: remove data block from dirctory entry
This patch removes the data block present in the directory entry structure
of each protocol in gem5's mainline.  Firstly, this is required for moving
towards common set of memory controllers for classic and ruby memory systems.
Secondly, the data block was being misused in several places.  It was being
used for having free access to the physical memory instead of calling on the
memory controller.

From now on, the directory controller will not have a direct visibility into
the physical memory.  The Memory Vector object now resides in the
Memory Controller class.  This also means that some significant changes are
being made to the functional accesses in ruby.

9 years agoruby: slicc: allow adding a bool to an int, like C++.
Nilay Vaish [Thu, 6 Nov 2014 11:42:20 +0000 (05:42 -0600)]
ruby: slicc: allow adding a bool to an int, like C++.

9 years agoruby: remove sparse memory.
Nilay Vaish [Thu, 6 Nov 2014 11:42:20 +0000 (05:42 -0600)]
ruby: remove sparse memory.
In my opinion, it creates needless complications in rest of the code.
Also, this structure hinders the move towards common set of code for
physical memory controllers.

9 years agoruby: single physical memory in fs mode
Nilay Vaish [Thu, 6 Nov 2014 11:41:44 +0000 (05:41 -0600)]
ruby: single physical memory in fs mode
Both ruby and the system used to maintain memory copies.  With the changes
carried for programmed io accesses, only one single memory is required for
fs simulations.  This patch sets the copy of memory that used to reside
with the system to null, so that no space is allocated, but address checks
can still be carried out.  All the memory accesses now source and sink values
to the memory maintained by ruby.

9 years agoruby: dma sequencer: remove RubyPort as parent class
Nilay Vaish [Thu, 6 Nov 2014 06:55:09 +0000 (00:55 -0600)]
ruby: dma sequencer: remove RubyPort as parent class
As of now DMASequencer inherits from the RubyPort class.  But the code in
RubyPort class is heavily tailored for the CPU Sequencer.  There are parts of
the code that are not required at all for the DMA sequencer.  Moreover, the
next patch uses the dma sequencer for carrying out memory accesses for all the
io devices.  Hence, it is better to have a leaner dma sequencer.

9 years agotests: Update stats no match.
Ali Saidi [Mon, 3 Nov 2014 16:14:42 +0000 (10:14 -0600)]
tests: Update stats no match.

Bootloader I had on my sytem was an older version with a couple of
instruction differences.

9 years agoarm, tests: Forgot the system.terminal files for the new regressions.
Ali Saidi [Thu, 30 Oct 2014 05:04:12 +0000 (00:04 -0500)]
arm, tests: Forgot the system.terminal files for the new regressions.

9 years agoarm, tests: Add 64-bit ARM regression tests
Ali Saidi [Thu, 30 Oct 2014 04:50:15 +0000 (23:50 -0500)]
arm, tests: Add 64-bit ARM regression tests

9 years agoautomated merge
Ali Saidi [Thu, 30 Oct 2014 04:22:26 +0000 (23:22 -0500)]
automated merge

9 years agotests: Update regressions for the new kernels and various preceeding fixes.
Ali Saidi [Thu, 30 Oct 2014 04:18:29 +0000 (23:18 -0500)]
tests: Update regressions for the new kernels and various preceeding fixes.

9 years agoarm, tests: Update config files to more recent kernels and create 64-bit regressions.
Ali Saidi [Thu, 30 Oct 2014 04:18:27 +0000 (23:18 -0500)]
arm, tests: Update config files to more recent kernels and create 64-bit regressions.

This changes the default ARM system to a Versatile Express-like system that supports
2GB of memory and PCI devices and updates the default kernels/file-systems for
AArch64 ARM systems (64-bit) to support up to 32GB of memory and PCI devices. Some
platforms that are no longer supported have been pruned from the configuration files.

In addition a set of 64-bit ARM regressions have been added to the regression system.

9 years agocpu: Add writeback modeling for drain functionality
Mitch Hayenga [Thu, 30 Oct 2014 04:18:27 +0000 (23:18 -0500)]
cpu: Add writeback modeling for drain functionality

It is possible for the O3 CPU to consider itself drained and
later have a squashed instruction perform a writeback.  This
patch re-adds tracking of in-flight instructions to prevent
falsely signaling a drained event.

9 years agocpu: Add drain check functionality to IEW
Mitch Hayenga [Thu, 30 Oct 2014 04:18:26 +0000 (23:18 -0500)]
cpu: Add drain check functionality to IEW

IEW did not check the instQueue and memDepUnit to ensure
they were drained.  This caused issues when drainSanityCheck()
did check those structures after asserting IEW was drained.

9 years agoarm, mem: Fix drain bug and provide drain prints for more components.
Ali Saidi [Thu, 30 Oct 2014 04:18:26 +0000 (23:18 -0500)]
arm, mem: Fix drain bug and provide drain prints for more components.

9 years agoarm: Fix multi-system AArch64 boot w/caches.
Ali Saidi [Thu, 30 Oct 2014 04:18:26 +0000 (23:18 -0500)]
arm: Fix multi-system AArch64 boot w/caches.

Automatically extract cpu release address from DTB file.
Check SCTLR_EL1 to verify all caches are enabled.

9 years agoarm: fix bare-metal memory setup.
Ali Saidi [Thu, 30 Oct 2014 04:18:26 +0000 (23:18 -0500)]
arm: fix bare-metal memory setup.

The bare-metal configuration option still configured memory with the old scheme
that no-longer works. This change unifies the code so there aren't any differences.

9 years agoarm: Mark some miscregs (timer counter) registers at unverifiable.
Ali Saidi [Thu, 30 Oct 2014 04:18:24 +0000 (23:18 -0500)]
arm: Mark some miscregs (timer counter) registers at unverifiable.

The checker can't verify timer registers, so it should just grab the version
from the executing CPU, otherwise it could get a larger value and diverge
execution.

9 years agocpu: Add support to checker for CACHE_BLOCK_ZERO commands.
Ali Saidi [Thu, 30 Oct 2014 04:18:24 +0000 (23:18 -0500)]
cpu: Add support to checker for CACHE_BLOCK_ZERO commands.

The checker didn't know how to properly validate these new commands.

9 years agocpu: Fix barrier push to store buffer when full bug in Minor
Andrew Bardsley [Thu, 30 Oct 2014 04:18:24 +0000 (23:18 -0500)]
cpu: Fix barrier push to store buffer when full bug in Minor

This patch fixes a bug where a completing load or store which is also a
barrier can push a barrier into the store buffer without first checking
that there is a free slot.

The bug was not fatal but would print a warning that the store buffer
was full when inserting.

9 years agomem: don't inhibit WriteInv's or defer snoops on their MSHRs
Curtis Dunham [Tue, 21 Oct 2014 22:04:41 +0000 (17:04 -0500)]
mem: don't inhibit WriteInv's or defer snoops on their MSHRs

WriteInvalidate semantics depend on the unconditional writeback
or they won't complete.  Also, there's no point in deferring snoops
on their MSHRs, as they don't get new data at the end of their life
cycle the way other transactions do.

Add comment in the cache about a minor inefficiency re: WriteInvalidate.

9 years agomem: have WriteInvalidate obsolete MSHRs
Curtis Dunham [Thu, 30 Oct 2014 04:18:24 +0000 (23:18 -0500)]
mem: have WriteInvalidate obsolete MSHRs

Since WriteInvalidate directly writes into the cache, it can
create tricky timing interleavings with reads and writes to the
same cache line that haven't yet completed.  This patch ensures
that these requests, when completed, don't overwrite the newer
data from the WriteInvalidate.

9 years agosyscall_emul: add retry flag to SyscallReturn
Steve Reinhardt [Tue, 2 Sep 2014 21:07:50 +0000 (16:07 -0500)]
syscall_emul: add retry flag to SyscallReturn

This hook allows blocking emulated system calls to indicate
that they would block, but return control to the simulator
so that the simulation does not hang.  The actual retry
functionality requires additional support, to be provided
in a future changeset.

9 years agosyscall_emul: minor style fix to LiveProcess constructor
Steve Reinhardt [Wed, 22 Oct 2014 22:53:34 +0000 (15:53 -0700)]
syscall_emul: minor style fix to LiveProcess constructor

9 years agosyscall_emul: devirtualize BaseBufferArg methods
Steve Reinhardt [Wed, 22 Oct 2014 22:53:34 +0000 (15:53 -0700)]
syscall_emul: devirtualize BaseBufferArg methods

Not clear why they were marked virtual to begin with,
but that doesn't appear to be necessary.

9 years agosyscall_emul: Put BufferArg classes in a separate header.
Steve Reinhardt [Wed, 22 Oct 2014 22:53:34 +0000 (15:53 -0700)]
syscall_emul: Put BufferArg classes in a separate header.

Move the BufferArg classes that support syscall buffer args
(i.e., pointers into simulated user space) out of syscall_emul.hh
and into a new header syscall_emul_buf.hh so they are accessible
to emulated driver implementations.

Take the opportunity to add some comments as well.

9 years agosyscall_emul: add EmulatedDriver object
Steve Reinhardt [Wed, 22 Oct 2014 22:53:34 +0000 (15:53 -0700)]
syscall_emul: add EmulatedDriver object

Fake SE-mode device drivers can now be added by
deriving from this abstract object.

9 years agosim: revert 6709bbcf564d
Nilay Vaish [Wed, 22 Oct 2014 20:59:57 +0000 (15:59 -0500)]
sim: revert 6709bbcf564d
The identifier SYS_getdents is not available on Mac OS X.  Therefore, its use
results in compilation failure.  It seems there is no straight forward way to
implement the system call getdents using readdir() or similar C functions.
Hence the commit 6709bbcf564d is being rolled back.

9 years agox86: Fixes to avoid LTO warnings
Andreas Hansson [Mon, 20 Oct 2014 22:03:56 +0000 (18:03 -0400)]
x86: Fixes to avoid LTO warnings

This patch fixes a few minor issues that caused link-time warnings
when using LTO, mainly for x86. The most important change is how the
syscall array is created. Previously gcc and clang would complain that
the declaration and definition types did not match. The organisation
is now changed to match how it is done for ARM, moving the code that
was previously in syscalls.cc into process.cc, and having a class
variable pointing to the static array.

With these changes, there are no longer any warnings using gcc 4.6.3
with LTO.

9 years agomisc: Use gmtime for conversion to UTC to avoid getenv/setenv
Andreas Hansson [Mon, 20 Oct 2014 22:03:55 +0000 (18:03 -0400)]
misc: Use gmtime for conversion to UTC to avoid getenv/setenv

This patch changes how we turn time into UTC. Previously we
manipulated the TZ environment variable, but this has issues as the
strings that are manipulated could be tainted (see e.g. CERT
ENV34-C). Now we simply rely on the built-in gmtime function and avoid
touching getenv/setenv all together.

9 years agomem: Fix DRAM activationlLimit bug
Omar Naji [Mon, 20 Oct 2014 22:03:55 +0000 (18:03 -0400)]
mem: Fix DRAM activationlLimit bug

Ensure that we do the proper event scheduling also when the activation
limit is disabled.

9 years agobase: Fix for stats node on gcc < 4.6.3
Andreas Hansson [Mon, 20 Oct 2014 22:03:54 +0000 (18:03 -0400)]
base: Fix for stats node on gcc < 4.6.3

This patch adds an explicit function to get the underlying node as gcc
4.6.1 and 4.6.2 have issues otherwise.

9 years agoext: Bump DRAMPower to avoid compilation issues
Andreas Hansson [Mon, 20 Oct 2014 22:03:53 +0000 (18:03 -0400)]
ext: Bump DRAMPower to avoid compilation issues

This patch bumps DRAMPower to commit
19433a6897ede4bbb19b06694faa8589b5a6569a which contains a small fix
for clang, and a work-around for LTO with gcc 4.6.

9 years agomem: Add DRAM device size and check against config
Omar Naji [Mon, 20 Oct 2014 22:03:52 +0000 (18:03 -0400)]
mem: Add DRAM device size and check against config

This patch adds the size of the DRAM device to the DRAM config. It
also compares the actual DRAM size (calculated using information from
the config) to the size defined in the system. If these two values do
not match gem5 will print a warning. In order to do correct DRAM
research the size of the memory defined in the system should match the
size of the DRAM in the config. The timing and current parameters
found in the DRAM configs are defined for a DRAM device with a
specific size and would differ for another device with a different
size.

9 years agostats: updates due to previous mmap and exit_group patches.
Nilay Vaish [Mon, 20 Oct 2014 21:48:19 +0000 (16:48 -0500)]
stats: updates due to previous mmap and exit_group patches.

9 years agocpu: o3: corrects base FP and CC register index in removeThread()
Nilay Vaish [Mon, 20 Oct 2014 21:47:55 +0000 (16:47 -0500)]
cpu: o3: corrects base FP and CC register index in removeThread()

9 years agosim: invalid alignment checks in mmap and mremap
Tom Jablin [Mon, 20 Oct 2014 21:45:25 +0000 (16:45 -0500)]
sim: invalid alignment checks in mmap and mremap
Presently, the alignment checks in the mmap and mremap implementations
in syscall_emul.hh are wrong. The checks are implemented as:

if ((start % TheISA::PageBytes) != 0 ||
        (length % TheISA::PageBytes) != 0) {
    warn("mmap failing: arguments not page-aligned: "
            "start 0x%x length 0x%x",
            start, length);
    return -EINVAL;
}

This checks that both the start and the length arguments of the mmap
syscall are checked for page-alignment. However, the POSIX specification says:

The off argument is constrained to be aligned and sized according to the value
returned by sysconf() when passed _SC_PAGESIZE or _SC_PAGE_SIZE. When MAP_FIXED
is specified, the application shall ensure that the argument addr also meets
these constraints. The implementation performs mapping operations over whole
pages. Thus, while the argument len need not meet a size or alignment
constraint, the implementation shall include, in any mapping operation, any
partial page specified by the range [pa,pa+len).

So the length parameter should not be checked for page-alignment. By contrast,
the current implementation fails to check the offset argument, which must be
page aligned.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agosim: mmap: correct behavior for fixed address
Michael Adler [Mon, 20 Oct 2014 21:45:08 +0000 (16:45 -0500)]
sim: mmap: correct behavior for fixed address
Change mmap fixed address request to return an error if the mapping is
impossible due to conflict instead of what I believe used to be silent
corruption.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agosim: implement getdents/getdents64 in user mode
Michael Adler [Mon, 20 Oct 2014 21:44:53 +0000 (16:44 -0500)]
sim: implement getdents/getdents64 in user mode

Has been tested only for alpha.
Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agox86: syscall: implementation of exit_group
Severin Wischmann ext:(%2C%20Ioannis%20Ilkos%20%3Cioannis.ilkos09%40imperial.ac.uk%3E) [Mon, 20 Oct 2014 21:43:48 +0000 (16:43 -0500)]
x86: syscall: implementation of exit_group
On exit_group syscall, we used to exit the simulator.  But now we will only
halt the execution of threads that belong to the group.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agomem: Modernise PhysicalMemory with C++11 features
Andreas Hansson [Thu, 16 Oct 2014 09:50:01 +0000 (05:50 -0400)]
mem: Modernise PhysicalMemory with C++11 features

Bring the PhysicalMemory up-to-date by making use of range-based for
loops and vector intialisation where possible.

9 years agomisc: Move AddrRangeList from port.hh to addr_range.hh
Andreas Hansson [Thu, 16 Oct 2014 09:49:59 +0000 (05:49 -0400)]
misc: Move AddrRangeList from port.hh to addr_range.hh

The new location seems like a better fit. The iterator typedefs are
removed in favour of using C++11 auto.

9 years agoext: Update fputils to rev 6a47fd8358
Andreas Sandberg [Thu, 16 Oct 2014 09:49:58 +0000 (05:49 -0400)]
ext: Update fputils to rev 6a47fd8358

This patch updates fputils to the latest revision (6a47fd8358) from
the upstream repository (github.com/andysan/fputils). Most notably,
this includes changes that export a limited set of 64-bit float
manipulation and avoids a warning about unused 64-bit floats in clang.

9 years agodev: refactor pci config space for sysfs scanning
Geoffrey Blake [Thu, 16 Oct 2014 09:49:57 +0000 (05:49 -0400)]
dev: refactor pci config space for sysfs scanning

Sysfs on ubuntu scrapes the entire PCI config space
when it discovers a device using 4 byte accesses.
This was not supported by our devices, in particular the NIC
that implemented the extended PCI config space.  This change
allows the extended PCI config space to be accessed by
sysfs properly.

9 years agomem: Add ExternalMaster and ExternalSlave ports
Andrew Bardsley [Thu, 16 Oct 2014 09:49:56 +0000 (05:49 -0400)]
mem: Add ExternalMaster and ExternalSlave ports

This patch adds two MemoryObject's: ExternalMaster and ExternalSlave.
Each object has a single port which can be bound to an externally-
provided bridge to a port of another simulation system at
initialisation.

9 years agosim: SystemC hosting
Andrew Bardsley [Thu, 16 Oct 2014 09:49:54 +0000 (05:49 -0400)]
sim: SystemC hosting

This patch hosts gem5 onto SystemC scheduler. There's already an upstream
review board patch that does something similar but this patch ...:

 1) is less obtrusive to the existing gem5 code organisation. It's divided
 into the 'generic' preparatory patches (already submitted) and this patch
 which affects no existing files

 2) does not try to exactly track the gem5 event queue with notifys into
 SystemC and so doesn't requive the event queue to be modified for
 anything other than 'out of event queue' scheduling events

 3) supports debug logging with SC_REPORT

The patch consists of the files:
    util/systemc/
        sc_gem5_control.{cc,hh} -- top level objects to use to
                                   instantiate gem5 Systems within
                                   larger SystemC test harnesses as
                                   sc_module objects
        sc_logger.{cc,hh}       -- logging support
        sc_module.{cc,hh}       -- a separated event loop specific to
                                   SystemC
        stats.{cc,hh}           -- example Stats handling for the sample
                                   top level
        main.{cc,hh}            -- a sample top level

On the downside this patch is only currently functional with C++
configuration at the top level.

The above sc_... files are indended to be compiled alongside gem5 (as a
library, see main.cc for a command line and util/systemc/README for
more details.)

The top-level system instantiation in sc_gem5_control.{cc,hh} provides
two classes: Gem5Control and Gem5System

Gem5Control is a simulation control class (from which a singleton
object should be created) derived from Gem5SystemC::Module which
carries the top level simulation control interface for gem5.  This
includes hosting a system-building configuration file and
instantiating the Root object from that file.

Gem5System is a base class for instantiating renamed gem5 Systems
from the config file hosted by the Gem5Control object.  In use, a
SystemC module class should be made which represents the desired,
instantiable gem5 System.  That class's instances should create
a Gem5System during their construction, set the parameters of that
system and then call instantiate to build that system.  If this
is all carried out in the sc_core::sc_module-derived classes
constructor, the System's external ports will become children of
that module and can then be recovered by name using sc_core::
sc_find_object.

It is intended that this interface is used with dlopen.  To that
end, the header file sc_gem5_control.hh includes no other header
files from gem5 (and so can be easily copied into another project).
The classes Gem5System and Gem5Control have all their member
functions declared `virtual' so that those functions can be called
through the vtable acquired by building the top level Gem5Control
using dlsym(..., "makeGem5Control") and `makeSystem' on the
Gem5Control.

9 years agosim: EventQueue wakeup on events scheduled outside the event loop
Andreas Hansson [Thu, 16 Oct 2014 09:49:53 +0000 (05:49 -0400)]
sim: EventQueue wakeup on events scheduled outside the event loop

This patch adds a 'wakeup' member function to EventQueue which should be
called on an event queue whenever an event is scheduled on the event queue
from outside code within the call tree of the gem5 event loop.

This clearly isn't necessary for normal gem5 EventQueue operation but
becomes the minimum necessary interface to allow hosting gem5's event loop
onto other schedulers where there may be calls into gem5 from external
code which schedules events onto an EventQueue between the current time and
the time of the next scheduled event.

The use case I have in mind is a SystemC hosting where the event loop is:

    while (more events) {
        wait(time_to_next_event or wakeup)
        setCurTick
        service events at this time
    }

where the 'wait' needs to be woken up if time_to_next_event becomes shorter
due to a scheduled event from SystemC arriving in a gem5 object.

Requiring 'wakeup' to be called is a more efficient interface than
requiring all gem5 event scheduling actions to affect the host scheduler.

This interface could be located elsewhere, say on another global object,
or by being passed by the host scheduler to objects which will schedule
such events, but it seems cleanest to put it on EventQueue as it is
actually a signal to the queue.

EventQueue::wakeup is called for async_event events on event queue 0 as
it's only important that *some* queue be triggered for such events.

9 years agobase: Reimplement the DPRINTF mechanism in a Logger class
Andrew Bardsley [Thu, 16 Oct 2014 09:49:53 +0000 (05:49 -0400)]
base: Reimplement the DPRINTF mechanism in a Logger class

This patch adds a Logger class encapsulating dprintf.  This allows
variants of DPRINTF logging to be constructed and substituted in
place of the default behaviour.

The Logger provides a logMessage(when, name, format, ...) member
function like Trace::dprintf and a getOstream member function to
use a raw ostream for logging.

A class OstreamLogger is provided which generates the customary
debugging output with Trace::OstreamLogger::logMessage being the
old Trace::dprintf.

9 years agoarch: Use shared_ptr for all Faults
Andreas Hansson [Thu, 16 Oct 2014 09:49:51 +0000 (05:49 -0400)]
arch: Use shared_ptr for all Faults

This patch takes quite a large step in transitioning from the ad-hoc
RefCountingPtr to the c++11 shared_ptr by adopting its use for all
Faults. There are no changes in behaviour, and the code modifications
are mostly just replacing "new" with "make_shared".

9 years agoo3: Use shared_ptr for MemDepEntry
Andreas Hansson [Thu, 16 Oct 2014 09:49:49 +0000 (05:49 -0400)]
o3: Use shared_ptr for MemDepEntry

This patch transitions the o3 MemDepEntry from the ad-hoc
RefCountingPtr to the c++11 shared_ptr. There are no changes in
behaviour, and the code modifications are mainly replacing "new" with
"make_shared".

9 years agomem: Use shared_ptr for Ruby Message classes
Andreas Hansson [Thu, 16 Oct 2014 09:49:49 +0000 (05:49 -0400)]
mem: Use shared_ptr for Ruby Message classes

This patch transitions the Ruby Message and its derived classes from
the ad-hoc RefCountingPtr to the c++11 shared_ptr. There are no
changes in behaviour, and the code modifications are mainly replacing
"new" with "make_shared".

The cloning of derived messages is slightly changed as they previously
relied on overriding the base-class through covariant return types.

9 years agobase: Use shared_ptr for stat Node
Andreas Hansson [Thu, 16 Oct 2014 09:49:48 +0000 (05:49 -0400)]
base: Use shared_ptr for stat Node

This patch transitions the stat Node and its derived classes from
the ad-hoc RefCountingPtr to the c++11 shared_ptr. There are no
changes in behaviour, and the code modifications are mainly replacing
"new" with "make_shared".

9 years agobase: Transition CP annotate to use shared_ptr
Andreas Hansson [Thu, 16 Oct 2014 09:49:47 +0000 (05:49 -0400)]
base: Transition CP annotate to use shared_ptr

9 years agodev: Use shared_ptr for EthPacketData
Andreas Hansson [Thu, 16 Oct 2014 09:49:46 +0000 (05:49 -0400)]
dev: Use shared_ptr for EthPacketData

This patch transitions the EthPacketData from the ad-hoc
RefCountingPtr to the c++11 shared_ptr. There are no changes in
behaviour, and the code modifications are mainly replacing "new" with
"make_shared".

The bool casting operator for the shared_ptr is explicit, and we must
therefore either cast it, compare it to NULL (p != nullptr), double
negate it (!!p) or do a (p ? true : false).

9 years agodev: Use shared_ptr for Arguments::Data
Andreas Hansson [Thu, 16 Oct 2014 09:49:45 +0000 (05:49 -0400)]
dev: Use shared_ptr for Arguments::Data

This patch takes a first few steps in transitioning from the ad-hoc
RefCountingPtr to the c++11 shared_ptr. There are no changes in
behaviour, and the code modifications are mainly introducing the
use of make_shared.

Note that the class could use unique_ptr rather than shared_ptr, was
it not for the postfix increment and decrement operators.

9 years agoarch,x86,mem: Dynamically determine the ISA for Ruby store check
Andreas Hansson [Thu, 16 Oct 2014 09:49:44 +0000 (05:49 -0400)]
arch,x86,mem: Dynamically determine the ISA for Ruby store check

This patch makes the memory system ISA-agnostic by enabling the Ruby
Sequencer to dynamically determine if it has to do a store check. To
enable this check, the ISA is encoded as an enum, and the system
is able to provide the ISA to the Sequencer at run time.

--HG--
rename : src/arch/x86/insts/microldstop.hh => src/arch/x86/ldstflags.hh

9 years agomem: Dynamically determine page bytes in memory components
Andreas Hansson [Thu, 16 Oct 2014 09:49:43 +0000 (05:49 -0400)]
mem: Dynamically determine page bytes in memory components

This patch takes a step towards an ISA-agnostic memory
system by enabling the components to establish the page size after
instantiation. The swap operation in the memory is now also allowing
any granularity to avoid depending on the IntReg of the ISA.

9 years agoarm: Add helper methods to setup architected PMU events
Andreas Sandberg [Thu, 16 Oct 2014 09:49:42 +0000 (05:49 -0400)]
arm: Add helper methods to setup architected PMU events

9 years agocpu: Probe points for basic PMU stats
Andreas Sandberg [Thu, 16 Oct 2014 09:49:41 +0000 (05:49 -0400)]
cpu: Probe points for basic PMU stats

This changeset adds probe points that can be used to implement PMU
counters for CPU stats. The following probes are supported:

  * BaseCPU::ppCycles / Cycles
  * BaseCPU::ppRetiredInsts / RetiredInsts
  * BaseCPU::ppRetiredLoads / RetiredLoads
  * BaseCPU::ppRetiredStores / RetiredStores
  * BaseCPU::ppRetiredBranches RetiredBranches

9 years agoarm: Add TLB PMU probes
Andreas Sandberg [Thu, 16 Oct 2014 09:49:41 +0000 (05:49 -0400)]
arm: Add TLB PMU probes

This changeset adds probe points that can be used to implement PMU
counters for TLB stats. The following probes are supported:

* ArmISA::TLB::ppRefills / TLB Refills (TLB insertions)

9 years agocpu: Add branch predictor PMU probe points
Andreas Sandberg [Thu, 16 Oct 2014 09:49:40 +0000 (05:49 -0400)]
cpu: Add branch predictor PMU probe points

This changeset adds probe points that can be used to implement PMU
counters for branch predictor stats. The following probes are
supported:

 * BPRedUnit::ppBranches / Branches
 * BPRedUnit::ppMisses / Misses

9 years agoarm: Add a model of an ARM PMUv3
Andreas Sandberg [Thu, 16 Oct 2014 09:49:39 +0000 (05:49 -0400)]
arm: Add a model of an ARM PMUv3

This class implements a subset of the ARM PMU v3 specification as
described in the ARMv8 reference manual. It supports most of the
features of the PMU, however the following features are known to be
missing:

 * Event filtering (e.g., from different privilege levels).
 * Access controls (the PMU currently ignores the execution level).
 * The chain counter (event no. 0x1E) is unimplemented.

The PMU itself does not implement any events, it merely provides an
interface for the configuration scripts to hook up probes that drive
events. Configuration scripts should call addEventProbe() to configure
custom events or high-level methods to configure architected
events. The Python implementation of addEventProbe() automatically
delays event type registration until after instantiation.

In order to support CPU switching and some combined counters (e.g.,
memory references synthesized from loads and stores), the PMU allows
multiple probes per event type. When creating a system that switches
between CPU models that share the same PMU, PMU events for all of the
CPU models can be registered with the PMU.

Kudos to Matt Horsnell for the initial gem5 implementation of the PMU.

9 years agosim: Add typedefs for PMU probe points
Andreas Sandberg [Thu, 16 Oct 2014 09:49:38 +0000 (05:49 -0400)]
sim: Add typedefs for PMU probe points

In order to show make PMU probe points usable across different PMU
implementations, we want a common probe interface. This patch the
namespace ProbePoins that contains typedefs for probe points that are
shared between multiple SimObjects. It also adds typedefs for the PMU
probe interface.

9 years agosim: Add support for serializing BitUnionXX
Andreas Sandberg [Thu, 16 Oct 2014 09:49:37 +0000 (05:49 -0400)]
sim: Add support for serializing BitUnionXX

BitUnion instances can normally not be used with the SERIALIZE_SCALAR
and UNSERIALIZE_SCALAR macros due to the way they are converted
between their storage type and their actual type. This changeset adds
a set of parm(In|Out) functions specifically for gem5 bit unions to
work around the issue.

9 years agoconfig: Add the ability to read a config file using C++ and Python
Andreas Hansson [Thu, 16 Oct 2014 09:49:37 +0000 (05:49 -0400)]
config: Add the ability to read a config file using C++ and Python

This patch adds the ability to load in config.ini files generated from
gem5 into another instance of gem5 built without Python configuration
support. The intended use case is for configuring gem5 when it is a
library embedded in another simulation system.

A parallel config file reader is also provided purely in Python to
demonstrate the approach taken and to provided similar functionality
for as-yet-unknown use models. The Python configuration file reader
can read both .ini and .json files.

C++ configuration file reading:

A command line option has been added for scons to enable C++ configuration
file reading: --with-cxx-config

There is an example in util/cxx_config that shows C++ configuration in action.
util/cxx_config/README explains how to build the example.

Configuration is achieved by the object CxxConfigManager. It handles
reading object descriptions from a CxxConfigFileBase object which
wraps a config file reader. The wrapper class CxxIniFile is provided
which wraps an IniFile for reading .ini files. Reading .json files
from C++ would be possible with a similar wrapper and a JSON parser.

After reading object descriptions, CxxConfigManager creates
SimObjectParam-derived objects from the classes in the (generated with this
patch) directory build/ARCH/cxx_config

CxxConfigManager can then build SimObjects from those SimObjectParams (in an
order dictated by the SimObject-value parameters on other objects) and bind
ports of the produced SimObjects.

A minimal set of instantiate-replacing member functions are provided by
CxxConfigManager and few of the member functions of SimObject (such as drain)
are extended onto CxxConfigManager.

Python configuration file reading (configs/example/read_config.py):

A Python version of the reader is also supplied with a similar interface to
CxxConfigFileBase (In Python: ConfigFile) to config file readers.

The Python config file reading will handle both .ini and .json files.

The object construction strategy is slightly different in Python from the C++
reader as you need to avoid objects prematurely becoming the children of other
objects when setting parameters.

Port binding also needs to be strictly in the same port-index order as the
original instantiation.

9 years agoscons: Add Undefined Behavior Sanitizer (UBSan) option
Andreas Hansson [Thu, 16 Oct 2014 09:49:36 +0000 (05:49 -0400)]
scons: Add Undefined Behavior Sanitizer (UBSan) option

This patch adds the Undefined Behavior Sanitizer (UBSan) for clang and
gcc >= 4.9. Due to the performance impact, the usage is guarded by a
command-line option.

9 years agoscons: Add --without-tcmalloc build option
Curtis Dunham [Mon, 22 Sep 2014 19:37:23 +0000 (14:37 -0500)]
scons: Add --without-tcmalloc build option

Disabling tcmalloc is required for valgrind's memcheck to work properly;
this option makes it easier to create such a build.

9 years agoarm: Don't speculatively access most miscregisters.
Akash Bagdia [Tue, 2 Sep 2014 10:26:32 +0000 (11:26 +0100)]
arm: Don't speculatively access most miscregisters.

Speculative exeuction can cause panics in detailed execution mode that
shouldn't happen.

9 years agoscons: Generate a single debug flag C++ file
Curtis Dunham [Tue, 12 Aug 2014 22:35:28 +0000 (17:35 -0500)]
scons: Generate a single debug flag C++ file

Reduces target count/compiler invocations by ~180.

9 years agoscons: create dummy target to have SWIG generate C++ classes
Curtis Dunham [Thu, 16 Oct 2014 09:49:33 +0000 (05:49 -0400)]
scons: create dummy target to have SWIG generate C++ classes

scons build/<arch>/swig

9 years agoconfig: Add a --without-python option to build process
Andrew Bardsley [Thu, 16 Oct 2014 09:49:32 +0000 (05:49 -0400)]
config: Add a --without-python option to build process

Add the ability to build libgem5 without embedded Python or the
ability to configure with Python.

This is a prelude to a patch to allow config.ini files to be loaded
into libgem5 using only C++ which would make embedding gem5 within
other simulation systems easier.

This adds a few registration interfaces to things which cross
between Python and C++.  Namely: stats dumping and SimObject resolving

9 years agostats: Small bump of trailing stats
Andreas Hansson [Thu, 16 Oct 2014 09:49:31 +0000 (05:49 -0400)]
stats: Small bump of trailing stats

Somehow these seem to have been missed.

9 years agostats: updates due to changes to x86, stale configs.
Nilay Vaish [Sat, 11 Oct 2014 21:18:51 +0000 (16:18 -0500)]
stats: updates due to changes to x86, stale configs.

9 years agocpu: Fix o3 SMT IQCount bug
Andrew Lukefahr [Sat, 11 Oct 2014 21:16:02 +0000 (16:16 -0500)]
cpu: Fix o3 SMT IQCount bug

Commmitted by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agoutil: adds a script for using DSENT
Nilay Vaish [Sat, 11 Oct 2014 21:16:00 +0000 (16:16 -0500)]
util: adds a script for using DSENT
This patch adds a python script that processes the configuration and the
statistics file from a simulation run.  Configuration and activity of network
routers and links obtained from this processing is fed to DSENT via its Python
interface.  DSENT then computes the area and the power consumption of these
network components.  The script outputs these quantities to the console.

9 years agoext: dsent: adds a Python interface, drops C++ one
Nilay Vaish [Sat, 11 Oct 2014 21:16:00 +0000 (16:16 -0500)]
ext: dsent: adds a Python interface, drops C++ one
This patch extensively modifies DSENT so that it can be accessed using Python.
To access the Python interface, DSENT needs to compiled as a shared library.
For this purpose a CMakeLists.txt file has been added.  Some of the code that
is not required is being removed.

9 years agoext: add the source code for DSENT
Nilay Vaish [Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)]
ext: add the source code for DSENT
This patch adds a tool called DSENT to the ext/ directory.  DSENT
is a tool that models power and area for on-chip networks.  The next
patch adds a script for using the tool.

9 years agoruby: network: garnet: add statistics for different activities
Nilay Vaish [Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)]
ruby: network: garnet: add statistics for different activities
This patch adds some statistics to garnet that record the activity
of certain structures in the on-chip network.  These statistics, in a later
patch, will be used for computing the energy consumed by the on-chip network.

9 years agoruby: network: garnet: remove functions for computing power
Nilay Vaish [Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)]
ruby: network: garnet: remove functions for computing power

9 years agoruby: drop Orion network power model
Nilay Vaish [Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)]
ruby: drop Orion network power model

Orion is being dropped from ruby.  It would be replaced with DSENT
which has better models.  Note that the power / energy numbers reported
after this patch has been applied are not for use.

9 years agoruby: mesi: slight renaming
Nilay Vaish [Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)]
ruby: mesi: slight renaming

9 years agoconfig: separate function for instantiating a memory controller
Nilay Vaish [Sat, 11 Oct 2014 20:02:23 +0000 (15:02 -0500)]
config: separate function for instantiating a memory controller
This patch moves code for instantiating a single memory controller from
the function config_mem() to a separate function.  This is being done
so that memory controllers can be instantiated without assuming that
they will be attached to the system in a particular fashion.

9 years agoruby: structures: coorect #ifndef macros in header files
Nilay Vaish [Sat, 11 Oct 2014 20:02:22 +0000 (15:02 -0500)]
ruby: structures: coorect #ifndef macros in header files

9 years agoruby: moesi hammer: correct typo in master-slave assignment
Nilay Vaish [Sat, 11 Oct 2014 20:02:22 +0000 (15:02 -0500)]
ruby: moesi hammer: correct typo in master-slave assignment

10 years agox86: add LongModeAddressSize function to cpuid
Jiuyue Ma [Fri, 13 Jun 2014 08:48:47 +0000 (16:48 +0800)]
x86: add LongModeAddressSize function to cpuid

LongModeAddressSize was used by kernel 2.6.28.4 for physical address
validation, if not properly implemented, PCI resource allocation may
failed because of ioremap failed:

- linux-2.6.28.4/arch/x86/mm/ioremap.c:27-30
  27 static inline int phys_addr_valid(unsigned long addr)
  28 {
  29     return addr < (1UL << boot_cpu_data.x86_phys_bits);
  30 }

- linux-2.6.28.4/arch/x86/kernel/cpu/common.c:475-482
 475 #ifdef CONFIG_X86_64
 476         if (c->extended_cpuid_level >= 0x80000008) {
 477                 u32 eax = cpuid_eax(0x80000008);
 478
 479                 c->x86_virt_bits = (eax >> 8) & 0xff;
 480                 c->x86_phys_bits = eax & 0xff;
 481         }
 482 #endif

- linux-2.6.28.4/arch/x86/mm/ioremap.c:209-214
 209 if (!phys_addr_valid(phys_addr)) {
 210     printk(KERN_WARNING "ioremap: invalid physical address %llx\n",
 211            (unsigned long long)phys_addr);
 212     WARN_ON_ONCE(1);
 213     return NULL;
 214 }

This patch return 0x0000ffff for LongModeAddressSize, which guarantee phys_addr_valid never failed.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>

9 years agoconfig, x86: Ensure that PCI devs get bridged to the memory bus
Jiuyue Ma [Thu, 17 Jul 2014 04:05:41 +0000 (12:05 +0800)]
config, x86: Ensure that PCI devs get bridged to the memory bus

This patch force IO device to be mapped to 0xC0000000-0xFFFF0000 by
reserve anything between the end of memory and 3GB if memory is less
than 3GB. It also statically bridge these address range to the IO bus,
which guaranty access to pci address space will pass though bridge to
iobus.

Committed by: Nilay Vaish <nilay@cs.wisc.edu>