• Chris Wilson's avatar
    drm/i915/gem: Typecheck page lookups · f47e6306
    Chris Wilson authored
    We need to check that we avoid integer overflows when looking up a page,
    and so fix all the instances where we have mistakenly used a plain
    integer instead of a more suitable long. Be pedantic and add integer
    typechecking to the lookup so that we can be sure that we are safe.
    And it also uses pgoff_t as our page lookups must remain compatible with
    the page cache, pgoff_t is currently exactly unsigned long.
    
    v2: Move added i915_utils's macro into drm_util header (Jani N)
    v3: Make not use the same macro name on a function. (Mauro)
        For kernel-doc, macros and functions are handled in the same namespace,
        the same macro name on a function prevents ever adding documentation
        for it.
    v4: Add kernel-doc markups to the kAPI functions and macros (Mauoro)
    v5: Fix an alignment to match open parenthesis
    v6: Rebase
    v10: Use assert_typable instead of exactly_pgoff_t() macro. (Kees)
    v11: Change the use of assert_typable to assert_same_typable (G.G)
    v12: Change to use static_assert(__castable_to_type(n ,T)) style since
         the assert_same_typable() macro has been dropped. (G.G)
    v13: Change the use of __castable_to_type() to castable_to_type()
         Remove an unnecessary header include line. (G.G)
    v16: Fix "ERROR:SPACING" Checkpatch report (G.G)
    
    Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
    Cc: Matthew Auld <matthew.auld@intel.com>
    Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
    Cc: Kees Cook <keescook@chromium.org>
    Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
    Co-developed-by: default avatarGwan-gyeong Mun <gwan-gyeong.mun@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)
    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-2-gwan-gyeong.mun@intel.com
    f47e6306
i915_gem_context.c 40.5 KB