Skip to content
Snippets Groups Projects
  • Pavel Tatashin's avatar
    101376ba
    sparc64: NG4 memset 32 bits overflow · 101376ba
    Pavel Tatashin authored
    Early in boot Linux patches memset and memcpy to branch to platform
    optimized versions of these routines.  The NG4 (Niagra 4) versions are
    currently used on all platforms starting from T4.  Recently, there were M7
    optimized routines added into UEK4 but not into mainline yet.  So, even
    with M7 optimized routines NG4 are still going to be used on T4, T5, M5,
    and M6 processors.
    
    While investigating how to improve initialization time of dentry_hashtable
    which is 8G long on M6 ldom with 7T of main memory, I noticed that
    memset() does not reset all the memory in this array, after studying the
    code, I realized that NG4memset() branches use %icc register instead of
    %xcc to check compare, so if value of length is over 32-bit long, which is
    true for 8G array, these routines fail to work properly.
    
    The fix is to replace all %icc with %xcc in these routines.  (Alternative
    is to use %ncc, but this is misleading, as the code already has sparcv9
    only instructions, and cannot be compiled on 32-bit).
    
    This is important to fix this bug, because even older T4-4 can have 2T of
    memory, and there are large memory proportional data structures in kernel
    which can be larger than 4G in size.  The failing of memset() is silent
    and corruption is hard to detect.
    
    Link: http://lkml.kernel.org/r/1488432825-92126-2-git-send-email-pasha.tatashin@oracle.com
    
    
    Signed-off-by: default avatarPavel Tatashin <pasha.tatashin@oracle.com>
    Reviewed-by: default avatarBabu Moger <babu.moger@oracle.com>
    Cc: Babu Moger <babu.moger@amd.com>
    Cc: David Miller <davem@davemloft.net>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>
    101376ba
    History
    sparc64: NG4 memset 32 bits overflow
    Pavel Tatashin authored
    Early in boot Linux patches memset and memcpy to branch to platform
    optimized versions of these routines.  The NG4 (Niagra 4) versions are
    currently used on all platforms starting from T4.  Recently, there were M7
    optimized routines added into UEK4 but not into mainline yet.  So, even
    with M7 optimized routines NG4 are still going to be used on T4, T5, M5,
    and M6 processors.
    
    While investigating how to improve initialization time of dentry_hashtable
    which is 8G long on M6 ldom with 7T of main memory, I noticed that
    memset() does not reset all the memory in this array, after studying the
    code, I realized that NG4memset() branches use %icc register instead of
    %xcc to check compare, so if value of length is over 32-bit long, which is
    true for 8G array, these routines fail to work properly.
    
    The fix is to replace all %icc with %xcc in these routines.  (Alternative
    is to use %ncc, but this is misleading, as the code already has sparcv9
    only instructions, and cannot be compiled on 32-bit).
    
    This is important to fix this bug, because even older T4-4 can have 2T of
    memory, and there are large memory proportional data structures in kernel
    which can be larger than 4G in size.  The failing of memset() is silent
    and corruption is hard to detect.
    
    Link: http://lkml.kernel.org/r/1488432825-92126-2-git-send-email-pasha.tatashin@oracle.com
    
    
    Signed-off-by: default avatarPavel Tatashin <pasha.tatashin@oracle.com>
    Reviewed-by: default avatarBabu Moger <babu.moger@oracle.com>
    Cc: Babu Moger <babu.moger@amd.com>
    Cc: David Miller <davem@davemloft.net>
    Cc: Al Viro <viro@zeniv.linux.org.uk>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    Signed-off-by: default avatarStephen Rothwell <sfr@canb.auug.org.au>