Skip to content
  • Paulo Zanoni's avatar
    iris: check memory with INTEL_DEBUG=mem · b2360f15
    Paulo Zanoni authored
    
    
    After this commit, INTEL_DEBUG=mem will make iris over-allocate a page
    for every GEM buffer requested, write a pattern to the unused end area
    - which we refer to as the red zone - and check for integrity of the
    pattern when the buffer is not used anymore. Once a problem is found,
    we dump the buffer and assert(false). Notice that the red zone is not
    only the extra page we over-allocate, but it also includes the padding
    caused by iris' allocation buckets and page rounding: even if our tool
    didn't over-allocate anything (i.e., if we define
    RED_ZONE_BUFFER_EXTENSION to zero), the tool would still be doing
    helpful work.
    
    While I was able to find an issue in the Kernel with this patch
    series, it turns our the Mesa problems I suspected to have found were
    issues with this patch. So as of v5 the memory checker still has yet
    to find a Mesa memory problem.
    
    I also plan to extend the subsystem to also check for use-after-free
    issues in later patches, but first I want to work on the bugs that red
    zoning was already able to catch.
    
    v2:
     - Rebase
    v3:
     - Missing commas in error message (Marcin Ślusarz).
     - Rely on memcmp() in check_red_zone() instead of implementing our
       own uint64_t check (Marcin Ślusarz).
    v4:
     - Rebase.
     - Tweak the dump_mem_range() output after having used it for a while.
     - Make the code a little easier to read.
    v5:
     - Use RAW_MODE so we don't get false positives in RBC and HIZ
       auxiliary buffers.
    
    Signed-off-by: default avatarPaulo Zanoni <paulo.r.zanoni@intel.com>
    b2360f15