Changes between Initial Version and Version 1 of Tools/Memory Checker


Ignore:
Timestamp:
Jan 29, 2009, 6:04:50 PM (15 years ago)
Author:
becoulet
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Tools/Memory Checker

    v1 v1  
     1= Memory access checker for Soclib =
     2
     3The Memory checker tool is a software memory access debugger for !SoClib.
     4
     5== Overview ==
     6
     7The Memory checker is able to perform several analysis on memory accesses performed by the running software to track software bugs. Access to uninitialized or freed data and stack overflow are examples of reported behaviors. It acts as the [http://valgrind.org/ valgrind] memory checker tool found on some unix.
     8
     9== Implementation ==
     10
     11Like the GdbServer, the Memory checker contains no processor specific code and can be used to manage any Soclib processor model using the generic Iss interface. It is implemented as an Iss wrapper class. When the Memory checker is in use, it intercepts all events between the processor Iss model and the Soclib platform. The running operating system must be instrumented slightly to let the Memory checker be aware of valid stack ranges and allocation ranges. The Mutekh operating system is working with the Memory checker.
     12
     13=== What is being checked ===
     14
     15All memory access are monitored and checked for read access to non previously initialized (written) words.
     16
     17Context and stacks related checks:
     18 * The stack pointer register must stay in range given by the operating system for each software context in use.
     19 * The frame pointer register (if any) must stay in range given by the operating system for each software context in use.
     20 * Context stack range can not overlap (checked on context creation)
     21 * Stack range must be in allocated memory at context creation (when allocation checks are enabled).
     22 * The stack memory is marked as non-initialized when a new execution context is created.
     23 * The stack memory is marked as non-initialized below the stack pointer.
     24 * Memory r/w accesses can not occur below the stack pointer.
     25
     26Memory allocation and region checks:
     27 * Write accesses can not occur in readonly preloaded sections.
     28 * Preloaded sections are marked as uninitialize when appropriate.
     29 * Memory is marked as uninitialized on `malloc()`.
     30 * Memory is marked as uninitialized on `free()`.
     31 * Memory r/w accesses can not occur in freed memory.
     32 * Allocation are only allowed in free memory.
     33
     34=== Suspicious memory access reporting ===
     35
     36Suspicious memory access produce a message on running platform stdout stream.
     37
     38An exception can be reported if working with the GdbServer module to stop the processors execution. This enables further analisys of buggy software when a suspicious memory access happend. When using the Memory checker with the GdbServer, the Memory checker must be close to the processor.
     39
     40== Usage ==
     41
     42=== Adding Memory checker support to your platform ===
     43
     44Adding the !GdbServer to your topcell is easy. First include the header:
     45
     46{{{
     47#include "iss_memchecker.h"
     48}}}
     49
     50Then call the init function with mapping table and loader and replace processor instantiation:
     51
     52{{{
     53   // Without Memory checker
     54// soclib::caba::VciXcacheWrapper<soclib::common::Mips32ElIss> cpu0("cpu0", 0, maptab, IntTab(0), 1,8,4, 1,8,4);
     55
     56   // With Memory checker
     57   soclib::common::Memchecker<soclib::common::Mips32ElIss>::init(maptab, loader);
     58   soclib::caba::VciXcacheWrapper<soclib::common::Memchecker<soclib::common::Mips32ElIss> > cpu0("cpu0", 0, maptab, IntTab(0), 1,8,4, 1,8,4);
     59}}}
     60
     61Finally do not forget to update the platform description file:
     62
     63{{{
     64Uses('iss_wrapper', iss_t = 'common:memchecker_iss', memchecker_iss_t = 'common:mips32el'),
     65}}}
     66
     67=== Using an instrumented operating system ===
     68
     69The running operating system must communicate with the Memory checker to report information about context creation, stack range and allocator operations. This is done through read/write access to specifc memory locations which are intercepted by the Memory checker and not forwarded to the rest of the platform.
     70
     71Currently the only known supported operating system is Mutekh with mips processor. Other processors are partially supported, only memory allocation checks are performed. To use the memory checker with Mutekh, simply add the `CONFIG_SOCLIB_MEMCHECK` configuration token to your configuration file.
     72
     73Note:
     74 * An instrumented operating system can not be used without the ISS Memory checker module as memory access won't be intercepted and may cause bus error or side effects.
     75 * The default base address for the register bank of the memory checker is 0x00004200. This address can be changed but must stay small to fit on some processor instruction immediate field.
     76 * The register bank is protected by a magic value and as almost no chance being modified by an other running software.