• Yishai Hadas's avatar
    mlx4_core: Fix integer overflow issues around MTT table · 3de819e6
    Yishai Hadas authored
    Fix some issues around int variables used in data structures related
    to memory registration.
    
    Handle int overflow in mlx4_init_icm_table by using a u64 intermediate
    variable and changing struct mlx4_icm_table num_obj field to be u32.
    
    Change some more fields/variables to use u32 instead of int to prevent
    a case where the variable becomes negative when bit 31 is set.
    
    Also subtract log_mtts_per_seg from the exponent when computing
    num_mtt, since its added later on in that very same code area.
    
    This and the previous commit fixes some issues which actually prevent
    commit db5a7a65 ("mlx4_core: Scale size of MTT table with system
    RAM") from working.  Now, when the number of MTTs is scaled with the
    size of the RAM we can map up to 8TB.
    Signed-off-by: default avatarYishai Hadas <yishaih@mellanox.com>
    Signed-off-by: default avatarJack Morgenstein <jackm@mellanox.com>
    Signed-off-by: default avatarOr Gerlitz <ogerlitz@mellanox.com>
    Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
    3de819e6
icm.h 4.02 KB