• Gwan-gyeong Mun's avatar
    drm/i915: Check for integer truncation on the configuration of ttm place · 6949aa0e
    Gwan-gyeong Mun authored
    There is an impedance mismatch between the first/last valid page
    frame number of ttm place in unsigned and our memory/page accounting in
    unsigned long.
    As the object size is under the control of userspace, we have to be prudent
    and catch the conversion errors.
    To catch the implicit truncation as we switch from unsigned long to
    unsigned, we use overflows_type check and report E2BIG or overflow_type
    prior to the operation.
    
    v3: Not to change execution inside a macro. (Mauro)
        Add safe_conversion_gem_bug_on() macro and remove temporal
        SAFE_CONVERSION() macro.
    v4: Fix unhandled GEM_BUG_ON() macro call from safe_conversion_gem_bug_on()
    v6: Fix to follow general use case for GEM_BUG_ON(). (Jani)
    v7: Fix to use WARN_ON() macro where GEM_BUG_ON() macro was used. (Jani)
    v8: Replace safe_conversion() with check_assign() (Kees)
    v14: Split one macro of assignment with checking of overflow to two steps,
         first overflow check, and second assignment.
    
    Cc: Chris Wilson <chris@chris-wilson.co.uk>
    Cc: Matthew Auld <matthew.auld@intel.com>
    Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Cc: Jani Nikula <jani.nikula@intel.com>
    Signed-off-by: default avatarGwan-gyeong Mun <gwan-gyeong.mun@intel.com>
    Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> (v2)
    Reviewed-by: Mauro Carvalho Chehab <mchehab@kernel.org> (v3)
    Reported-by: default avatarkernel test robot <lkp@intel.com>
    Reviewed-by: Andrzej Hajda <andrzej.hajda@intel.com> (v5)
    Signed-off-by: default avatarRodrigo Vivi <rodrigo.vivi@intel.com>
    Link: https://patchwork.freedesktop.org/patch/msgid/20221228192252.917299-4-gwan-gyeong.mun@intel.com
    6949aa0e
intel_region_ttm.c 7.44 KB