sim: Initialize stackSize and stackMin in MemState
authorMatthew Poremba <matthew.poremba@amd.com>
Wed, 17 Jun 2020 23:06:23 +0000 (18:06 -0500)
committerMatthew Poremba <matthew.poremba@amd.com>
Fri, 19 Jun 2020 14:19:36 +0000 (14:19 +0000)
Initialize _stackSize and _stackMin to the maximum stack size values.
The are setup in each arch's Process::initState and may be uninitialized
until then. If a stack fixup occurs before these are setup, addresses
which are not in the stack might be allocated on the stack. This
prevents that until they are initialized in Process::initState. If an
access occurs before that with these initial values, the stack fixup
will simply allocate a page of memory in the stack space. However, it
will not print the typical info messages about growing the stack during
this time.

Change-Id: I9f9316734f4bf1f773fc538922e83b867731c684
JIRA: https://gem5.atlassian.net/browse/GEM5-629
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/30394
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Tested-by: kokoro <noreply+kokoro@google.com>
src/sim/mem_state.cc

index bfee9dab53fd82799ddde680c65b69ea7b66184c..bcfab78597d6bdf9f97446e449efe2a29aa67dc7 100644 (file)
@@ -43,7 +43,8 @@ MemState::MemState(Process *owner, Addr brk_point, Addr stack_base,
                    Addr mmap_end)
     : _ownerProcess(owner),
       _pageBytes(owner->system->getPageBytes()), _brkPoint(brk_point),
-      _stackBase(stack_base), _maxStackSize(max_stack_size),
+      _stackBase(stack_base), _stackSize(max_stack_size),
+      _maxStackSize(max_stack_size), _stackMin(stack_base - max_stack_size),
       _nextThreadStackBase(next_thread_stack_base),
       _mmapEnd(mmap_end), _endBrkPoint(brk_point)
 {