linux/arch/x86/crypto
Denys Vlasenko e183914af0 crypto: x86 - make constants readonly, allow linker to merge them
A lot of asm-optimized routines in arch/x86/crypto/ keep its
constants in .data. This is wrong, they should be on .rodata.

Mnay of these constants are the same in different modules.
For example, 128-bit shuffle mask 0x000102030405060708090A0B0C0D0E0F
exists in at least half a dozen places.

There is a way to let linker merge them and use just one copy.
The rules are as follows: mergeable objects of different sizes
should not share sections. You can't put them all in one .rodata
section, they will lose "mergeability".

GCC puts its mergeable constants in ".rodata.cstSIZE" sections,
or ".rodata.cstSIZE.<object_name>" if -fdata-sections is used.
This patch does the same:

	.section .rodata.cst16.SHUF_MASK, "aM", @progbits, 16

It is important that all data in such section consists of
16-byte elements, not larger ones, and there are no implicit
use of one element from another.

When this is not the case, use non-mergeable section:

	.section .rodata[.VAR_NAME], "a", @progbits

This reduces .data by ~15 kbytes:

    text    data     bss     dec      hex filename
11097415 2705840 2630712 16433967  fac32f vmlinux-prev.o
11112095 2690672 2630712 16433479  fac147 vmlinux.o

Merged objects are visible in System.map:

ffffffff81a28810 r POLY
ffffffff81a28810 r POLY
ffffffff81a28820 r TWOONE
ffffffff81a28820 r TWOONE
ffffffff81a28830 r PSHUFFLE_BYTE_FLIP_MASK <- merged regardless of
ffffffff81a28830 r SHUF_MASK   <------------- the name difference
ffffffff81a28830 r SHUF_MASK
ffffffff81a28830 r SHUF_MASK
..
ffffffff81a28d00 r K512 <- merged three identical 640-byte tables
ffffffff81a28d00 r K512
ffffffff81a28d00 r K512

Use of object names in section name suffixes is not strictly necessary,
but might help if someday link stage will use garbage collection
to eliminate unused sections (ld --gc-sections).

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
CC: Herbert Xu <herbert@gondor.apana.org.au>
CC: Josh Poimboeuf <jpoimboe@redhat.com>
CC: Xiaodong Liu <xiaodong.liu@intel.com>
CC: Megha Dey <megha.dey@intel.com>
CC: linux-crypto@vger.kernel.org
CC: x86@kernel.org
CC: linux-kernel@vger.kernel.org
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
2017-01-23 22:50:29 +08:00
..
sha1-mb crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha256-mb crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha512-mb crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
aes-i586-asm_32.S crypto: x86/aes - assembler clean-ups: use ENTRY/ENDPROC, localize jump targets 2013-01-20 10:16:47 +11:00
aes-x86_64-asm_64.S crypto: x86/aes - assembler clean-ups: use ENTRY/ENDPROC, localize jump targets 2013-01-20 10:16:47 +11:00
aes_ctrby8_avx-x86_64.S crypto: aesni - fix "by8" variant for 128 bit keys 2015-01-05 21:35:02 +11:00
aes_glue.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
aesni-intel_asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
aesni-intel_avx-x86_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
aesni-intel_glue.c crypto: aesni-intel - RFC4106 can zero copy when !PageHighMem 2016-12-27 17:48:48 +08:00
blowfish-x86_64-asm_64.S crypto: blowfish-x86_64: use ENTRY()/ENDPROC() for assembler functions and localize jump targets 2013-01-20 10:16:48 +11:00
blowfish_glue.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
camellia-aesni-avx-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
camellia-aesni-avx2-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
camellia-x86_64-asm_64.S crypto: camellia-x86_64/aes-ni: use ENTRY()/ENDPROC() for assembler functions and localize jump targets 2013-01-20 10:16:48 +11:00
camellia_aesni_avx2_glue.c x86/cpufeature: Replace cpu_has_avx with boot_cpu_has() usage 2016-04-13 11:37:40 +02:00
camellia_aesni_avx_glue.c x86/cpufeature: Replace cpu_has_avx with boot_cpu_has() usage 2016-04-13 11:37:40 +02:00
camellia_glue.c crypto: xts - consolidate sanity check for keys 2016-02-17 04:07:51 +08:00
cast5-avx-x86_64-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
cast5_avx_glue.c x86/fpu: Rename XSAVE macros 2015-09-14 12:21:46 +02:00
cast6-avx-x86_64-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
cast6_avx_glue.c crypto: xts - consolidate sanity check for keys 2016-02-17 04:07:51 +08:00
chacha20-avx2-x86_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
chacha20-ssse3-x86_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
chacha20_glue.c crypto: x86/chacha20 - Manually align stack buffer 2017-01-13 00:26:46 +08:00
crc32-pclmul_asm.S x86, crc32-pclmul: Fix build with older binutils 2013-05-30 16:36:23 -07:00
crc32-pclmul_glue.c x86/cpufeature: Carve out X86_FEATURE_* 2016-01-30 11:22:17 +01:00
crc32c-intel_glue.c x86/fpu: Remove use_eager_fpu() 2016-10-07 11:14:36 +02:00
crc32c-pcl-intel-asm_64.S crypto: x86/crc32c - fix %progbits -> @progbits 2017-01-23 22:50:26 +08:00
crct10dif-pcl-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
crct10dif-pclmul_glue.c x86/cpufeature: Carve out X86_FEATURE_* 2016-01-30 11:22:17 +01:00
des3_ede-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
des3_ede_glue.c crypto: x86/des3_ede - drop bogus module aliases 2015-01-13 22:30:52 +11:00
fpu.c crypto: aesni - Convert to skcipher 2016-11-28 21:23:20 +08:00
ghash-clmulni-intel_asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
ghash-clmulni-intel_glue.c crypto: ghash-clmulni - Fix cryptd reordering 2016-06-23 18:29:53 +08:00
glue_helper-asm-avx.S crypto: x86 - add more optimized XTS-mode for serpent-avx 2013-04-25 21:01:51 +08:00
glue_helper-asm-avx2.S crypto: twofish - add AVX2/x86_64 assembler implementation of twofish cipher 2013-04-25 21:09:05 +08:00
glue_helper.c crypto: glue_helper - Add skcipher xts helpers 2016-11-28 21:23:20 +08:00
Makefile crypto: sha512-mb - SHA512 multibuffer job manager and glue code 2016-06-28 16:06:35 +08:00
poly1305-avx2-x86_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
poly1305-sse2-x86_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
poly1305_glue.c x86/cpufeature: Replace cpu_has_avx with boot_cpu_has() usage 2016-04-13 11:37:40 +02:00
salsa20-i586-asm_32.S crypto: x86/salsa20 - assembler cleanup, use ENTRY/ENDPROC for assember functions and rename ECRYPT_* to salsa20_* 2013-01-20 10:16:50 +11:00
salsa20-x86_64-asm_64.S crypto: x86/salsa20 - assembler cleanup, use ENTRY/ENDPROC for assember functions and rename ECRYPT_* to salsa20_* 2013-01-20 10:16:50 +11:00
salsa20_glue.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
serpent-avx-x86_64-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
serpent-avx2-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
serpent-sse2-i586-asm_32.S crypto: x86/serpent - use ENTRY/ENDPROC for assember functions and localize jump targets 2013-01-20 10:16:50 +11:00
serpent-sse2-x86_64-asm_64.S crypto: x86/serpent - use ENTRY/ENDPROC for assember functions and localize jump targets 2013-01-20 10:16:50 +11:00
serpent_avx2_glue.c x86/cpufeature: Replace cpu_has_avx2 with boot_cpu_has() usage 2016-04-13 11:37:39 +02:00
serpent_avx_glue.c crypto: xts - consolidate sanity check for keys 2016-02-17 04:07:51 +08:00
serpent_sse2_glue.c x86/cpufeature: Remove cpu_has_xmm2 2016-03-31 13:35:09 +02:00
sha1_avx2_x86_64_asm.S crypto: x86/sha1 - reduce size of the AVX2 asm implementation 2014-03-25 20:25:43 +08:00
sha1_ni_asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha1_ssse3_asm.S crypto: x86/sha1 - assembler clean-ups: use ENTRY/ENDPROC 2013-01-20 10:16:51 +11:00
sha1_ssse3_glue.c crypto: sha-ssse3 - add MODULE_ALIAS 2016-05-31 16:41:46 +08:00
sha256-avx-asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha256-avx2-asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha256-ssse3-asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha256_ni_asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha256_ssse3_glue.c crypto: sha-ssse3 - add MODULE_ALIAS 2016-05-31 16:41:46 +08:00
sha512-avx-asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha512-avx2-asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha512-ssse3-asm.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
sha512_ssse3_glue.c crypto: sha-ssse3 - add MODULE_ALIAS 2016-05-31 16:41:46 +08:00
twofish-avx-x86_64-asm_64.S crypto: x86 - make constants readonly, allow linker to merge them 2017-01-23 22:50:29 +08:00
twofish-i586-asm_32.S crypto: x86/twofish - assembler clean-ups: use ENTRY/ENDPROC, localize jump labels 2013-01-20 10:16:51 +11:00
twofish-x86_64-asm_64-3way.S crypto: x86/twofish - assembler clean-ups: use ENTRY/ENDPROC, localize jump labels 2013-01-20 10:16:51 +11:00
twofish-x86_64-asm_64.S x86/asm: Replace "MOVQ $imm, %reg" with MOVL 2015-04-01 13:17:39 +02:00
twofish_avx_glue.c x86/fpu: Fixup uninitialized feature_name warning 2015-09-24 09:21:20 +02:00
twofish_glue.c crypto: prefix module autoloading with "crypto-" 2014-11-24 22:43:57 +08:00
twofish_glue_3way.c crypto: xts - consolidate sanity check for keys 2016-02-17 04:07:51 +08:00