2015-09-11 01:27:13 +03:00
/ *
* Intel S H A E x t e n s i o n s o p t i m i z e d i m p l e m e n t a t i o n o f a S H A - 2 5 6 u p d a t e f u n c t i o n
*
* This f i l e i s p r o v i d e d u n d e r a d u a l B S D / G P L v2 l i c e n s e . W h e n u s i n g o r
* redistributing t h i s f i l e , y o u m a y d o s o u n d e r e i t h e r l i c e n s e .
*
* GPL L I C E N S E S U M M A R Y
*
* Copyright( c ) 2 0 1 5 I n t e l C o r p o r a t i o n .
*
* This p r o g r a m i s f r e e s o f t w a r e ; you can redistribute it and/or modify
* it u n d e r t h e t e r m s o f v e r s i o n 2 o f t h e G N U G e n e r a l P u b l i c L i c e n s e a s
* published b y t h e F r e e S o f t w a r e F o u n d a t i o n .
*
* This p r o g r a m i s d i s t r i b u t e d i n t h e h o p e t h a t i t w i l l b e u s e f u l , b u t
* WITHOUT A N Y W A R R A N T Y ; without even the implied warranty of
* MERCHANTABILITY o r F I T N E S S F O R A P A R T I C U L A R P U R P O S E . S e e t h e G N U
* General P u b l i c L i c e n s e f o r m o r e d e t a i l s .
*
* Contact I n f o r m a t i o n :
* Sean G u l l e y < s e a n . m . g u l l e y @intel.com>
* Tim C h e n < t i m . c . c h e n @linux.intel.com>
*
* BSD L I C E N S E
*
* Copyright( c ) 2 0 1 5 I n t e l C o r p o r a t i o n .
*
* Redistribution a n d u s e i n s o u r c e a n d b i n a r y f o r m s , w i t h o r w i t h o u t
* modification, a r e p e r m i t t e d p r o v i d e d t h a t t h e f o l l o w i n g c o n d i t i o n s
* are m e t :
*
* * Redistributions o f s o u r c e c o d e m u s t r e t a i n t h e a b o v e c o p y r i g h t
* notice, t h i s l i s t o f c o n d i t i o n s a n d t h e f o l l o w i n g d i s c l a i m e r .
* * Redistributions i n b i n a r y f o r m m u s t r e p r o d u c e t h e a b o v e c o p y r i g h t
* notice, t h i s l i s t o f c o n d i t i o n s a n d t h e f o l l o w i n g d i s c l a i m e r i n
* the d o c u m e n t a t i o n a n d / o r o t h e r m a t e r i a l s p r o v i d e d w i t h t h e
* distribution.
* * Neither t h e n a m e o f I n t e l C o r p o r a t i o n n o r t h e n a m e s o f i t s
* contributors m a y b e u s e d t o e n d o r s e o r p r o m o t e p r o d u c t s d e r i v e d
* from t h i s s o f t w a r e w i t h o u t s p e c i f i c p r i o r w r i t t e n p e r m i s s i o n .
*
* THIS S O F T W A R E I S P R O V I D E D B Y T H E C O P Y R I G H T H O L D E R S A N D C O N T R I B U T O R S
* " AS I S " A N D A N Y E X P R E S S O R I M P L I E D W A R R A N T I E S , I N C L U D I N G , B U T N O T
* LIMITED T O , T H E I M P L I E D W A R R A N T I E S O F M E R C H A N T A B I L I T Y A N D F I T N E S S F O R
* A P A R T I C U L A R P U R P O S E A R E D I S C L A I M E D . I N N O E V E N T S H A L L T H E C O P Y R I G H T
* OWNER O R C O N T R I B U T O R S B E L I A B L E F O R A N Y D I R E C T , I N D I R E C T , I N C I D E N T A L ,
* SPECIAL, E X E M P L A R Y , O R C O N S E Q U E N T I A L D A M A G E S ( I N C L U D I N G , B U T N O T
* LIMITED T O , P R O C U R E M E N T O F S U B S T I T U T E G O O D S O R S E R V I C E S ; LOSS OF USE,
* DATA, O R P R O F I T S ; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY O F L I A B I L I T Y , W H E T H E R I N C O N T R A C T , S T R I C T L I A B I L I T Y , O R T O R T
* ( INCLUDING N E G L I G E N C E O R O T H E R W I S E ) A R I S I N G I N A N Y W A Y O U T O F T H E U S E
* OF T H I S S O F T W A R E , E V E N I F A D V I S E D O F T H E P O S S I B I L I T Y O F S U C H D A M A G E .
*
* /
# include < l i n u x / l i n k a g e . h >
2022-11-18 22:44:14 +03:00
# include < l i n u x / c f i _ t y p e s . h >
2015-09-11 01:27:13 +03:00
# define D I G E S T _ P T R % r d i / * 1 s t a r g * /
# define D A T A _ P T R % r s i / * 2 n d a r g * /
# define N U M _ B L K S % r d x / * 3 r d a r g * /
# define S H A 2 5 6 C O N S T A N T S % r a x
# define M S G % x m m 0
# define S T A T E 0 % x m m 1
# define S T A T E 1 % x m m 2
# define M S G T M P 0 % x m m 3
# define M S G T M P 1 % x m m 4
# define M S G T M P 2 % x m m 5
# define M S G T M P 3 % x m m 6
# define M S G T M P 4 % x m m 7
# define S H U F _ M A S K % x m m 8
# define A B E F _ S A V E % x m m 9
# define C D G H _ S A V E % x m m 1 0
/ *
* Intel S H A E x t e n s i o n s o p t i m i z e d i m p l e m e n t a t i o n o f a S H A - 2 5 6 u p d a t e f u n c t i o n
*
* The f u n c t i o n t a k e s a p o i n t e r t o t h e c u r r e n t h a s h v a l u e s , a p o i n t e r t o t h e
* input d a t a , a n d a n u m b e r o f 6 4 b y t e b l o c k s t o p r o c e s s . O n c e a l l b l o c k s h a v e
* been p r o c e s s e d , t h e d i g e s t p o i n t e r i s u p d a t e d w i t h t h e r e s u l t i n g h a s h v a l u e .
* The f u n c t i o n o n l y p r o c e s s e s c o m p l e t e b l o c k s , t h e r e i s n o f u n c t i o n a l i t y t o
* store p a r t i a l b l o c k s . A l l m e s s a g e p a d d i n g a n d h a s h v a l u e i n i t i a l i z a t i o n m u s t
* be d o n e o u t s i d e t h e u p d a t e f u n c t i o n .
*
* The i n d e n t e d l i n e s i n t h e l o o p a r e i n s t r u c t i o n s r e l a t e d t o r o u n d s p r o c e s s i n g .
* The n o n - i n d e n t e d l i n e s a r e i n s t r u c t i o n s r e l a t e d t o t h e m e s s a g e s c h e d u l e .
*
* void s h a25 6 _ n i _ t r a n s f o r m ( u i n t 3 2 _ t * d i g e s t , c o n s t v o i d * d a t a ,
uint3 2 _ t n u m B l o c k s ) ;
* digest : p o i n t e r t o d i g e s t
* data : pointer t o i n p u t d a t a
* numBlocks : Number o f b l o c k s t o p r o c e s s
* /
.text
2022-11-18 22:44:14 +03:00
SYM_ T Y P E D _ F U N C _ S T A R T ( s h a25 6 _ n i _ t r a n s f o r m )
2015-09-11 01:27:13 +03:00
shl $ 6 , N U M _ B L K S / * c o n v e r t t o b y t e s * /
jz . L d o n e _ h a s h
add D A T A _ P T R , N U M _ B L K S / * p o i n t e r t o e n d o f d a t a * /
/ *
* load i n i t i a l h a s h v a l u e s
* Need t o r e o r d e r t h e s e a p p r o p r i a t e l y
* DCBA, H G F E - > A B E F , C D G H
* /
movdqu 0 * 1 6 ( D I G E S T _ P T R ) , S T A T E 0
movdqu 1 * 1 6 ( D I G E S T _ P T R ) , S T A T E 1
pshufd $ 0 x B 1 , S T A T E 0 , S T A T E 0 / * C D A B * /
pshufd $ 0 x1 B , S T A T E 1 , S T A T E 1 / * E F G H * /
movdqa S T A T E 0 , M S G T M P 4
palignr $ 8 , S T A T E 1 , S T A T E 0 / * A B E F * /
pblendw $ 0 x F 0 , M S G T M P 4 , S T A T E 1 / * C D G H * /
movdqa P S H U F F L E _ B Y T E _ F L I P _ M A S K ( % r i p ) , S H U F _ M A S K
lea K 2 5 6 ( % r i p ) , S H A 2 5 6 C O N S T A N T S
.Lloop0 :
/* Save hash values for addition after rounds */
movdqa S T A T E 0 , A B E F _ S A V E
movdqa S T A T E 1 , C D G H _ S A V E
/* Rounds 0-3 */
movdqu 0 * 1 6 ( D A T A _ P T R ) , M S G
pshufb S H U F _ M A S K , M S G
movdqa M S G , M S G T M P 0
paddd 0 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
/* Rounds 4-7 */
movdqu 1 * 1 6 ( D A T A _ P T R ) , M S G
pshufb S H U F _ M A S K , M S G
movdqa M S G , M S G T M P 1
paddd 1 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 1 , M S G T M P 0
/* Rounds 8-11 */
movdqu 2 * 1 6 ( D A T A _ P T R ) , M S G
pshufb S H U F _ M A S K , M S G
movdqa M S G , M S G T M P 2
paddd 2 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 2 , M S G T M P 1
/* Rounds 12-15 */
movdqu 3 * 1 6 ( D A T A _ P T R ) , M S G
pshufb S H U F _ M A S K , M S G
movdqa M S G , M S G T M P 3
paddd 3 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 3 , M S G T M P 4
palignr $ 4 , M S G T M P 2 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 0
sha2 5 6 m s g 2 M S G T M P 3 , M S G T M P 0
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 3 , M S G T M P 2
/* Rounds 16-19 */
movdqa M S G T M P 0 , M S G
paddd 4 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 0 , M S G T M P 4
palignr $ 4 , M S G T M P 3 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 1
sha2 5 6 m s g 2 M S G T M P 0 , M S G T M P 1
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 0 , M S G T M P 3
/* Rounds 20-23 */
movdqa M S G T M P 1 , M S G
paddd 5 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 1 , M S G T M P 4
palignr $ 4 , M S G T M P 0 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 2
sha2 5 6 m s g 2 M S G T M P 1 , M S G T M P 2
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 1 , M S G T M P 0
/* Rounds 24-27 */
movdqa M S G T M P 2 , M S G
paddd 6 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 2 , M S G T M P 4
palignr $ 4 , M S G T M P 1 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 3
sha2 5 6 m s g 2 M S G T M P 2 , M S G T M P 3
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 2 , M S G T M P 1
/* Rounds 28-31 */
movdqa M S G T M P 3 , M S G
paddd 7 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 3 , M S G T M P 4
palignr $ 4 , M S G T M P 2 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 0
sha2 5 6 m s g 2 M S G T M P 3 , M S G T M P 0
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 3 , M S G T M P 2
/* Rounds 32-35 */
movdqa M S G T M P 0 , M S G
paddd 8 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 0 , M S G T M P 4
palignr $ 4 , M S G T M P 3 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 1
sha2 5 6 m s g 2 M S G T M P 0 , M S G T M P 1
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 0 , M S G T M P 3
/* Rounds 36-39 */
movdqa M S G T M P 1 , M S G
paddd 9 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 1 , M S G T M P 4
palignr $ 4 , M S G T M P 0 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 2
sha2 5 6 m s g 2 M S G T M P 1 , M S G T M P 2
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 1 , M S G T M P 0
/* Rounds 40-43 */
movdqa M S G T M P 2 , M S G
paddd 1 0 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 2 , M S G T M P 4
palignr $ 4 , M S G T M P 1 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 3
sha2 5 6 m s g 2 M S G T M P 2 , M S G T M P 3
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 2 , M S G T M P 1
/* Rounds 44-47 */
movdqa M S G T M P 3 , M S G
paddd 1 1 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 3 , M S G T M P 4
palignr $ 4 , M S G T M P 2 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 0
sha2 5 6 m s g 2 M S G T M P 3 , M S G T M P 0
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 3 , M S G T M P 2
/* Rounds 48-51 */
movdqa M S G T M P 0 , M S G
paddd 1 2 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 0 , M S G T M P 4
palignr $ 4 , M S G T M P 3 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 1
sha2 5 6 m s g 2 M S G T M P 0 , M S G T M P 1
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
sha2 5 6 m s g 1 M S G T M P 0 , M S G T M P 3
/* Rounds 52-55 */
movdqa M S G T M P 1 , M S G
paddd 1 3 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 1 , M S G T M P 4
palignr $ 4 , M S G T M P 0 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 2
sha2 5 6 m s g 2 M S G T M P 1 , M S G T M P 2
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
/* Rounds 56-59 */
movdqa M S G T M P 2 , M S G
paddd 1 4 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
movdqa M S G T M P 2 , M S G T M P 4
palignr $ 4 , M S G T M P 1 , M S G T M P 4
paddd M S G T M P 4 , M S G T M P 3
sha2 5 6 m s g 2 M S G T M P 2 , M S G T M P 3
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
/* Rounds 60-63 */
movdqa M S G T M P 3 , M S G
paddd 1 5 * 1 6 ( S H A 2 5 6 C O N S T A N T S ) , M S G
sha2 5 6 r n d s2 S T A T E 0 , S T A T E 1
pshufd $ 0 x0 E , M S G , M S G
sha2 5 6 r n d s2 S T A T E 1 , S T A T E 0
/* Add current hash values with previously saved */
paddd A B E F _ S A V E , S T A T E 0
paddd C D G H _ S A V E , S T A T E 1
/* Increment data pointer and loop if more to process */
add $ 6 4 , D A T A _ P T R
cmp N U M _ B L K S , D A T A _ P T R
jne . L l o o p0
/* Write hash values back in the correct order */
pshufd $ 0 x1 B , S T A T E 0 , S T A T E 0 / * F E B A * /
pshufd $ 0 x B 1 , S T A T E 1 , S T A T E 1 / * D C H G * /
movdqa S T A T E 0 , M S G T M P 4
pblendw $ 0 x F 0 , S T A T E 1 , S T A T E 0 / * D C B A * /
palignr $ 8 , M S G T M P 4 , S T A T E 1 / * H G F E * /
movdqu S T A T E 0 , 0 * 1 6 ( D I G E S T _ P T R )
movdqu S T A T E 1 , 1 * 1 6 ( D I G E S T _ P T R )
.Ldone_hash :
2021-12-04 16:43:40 +03:00
RET
2019-10-11 14:51:04 +03:00
SYM_ F U N C _ E N D ( s h a25 6 _ n i _ t r a n s f o r m )
2015-09-11 01:27:13 +03:00
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-20 00:33:04 +03:00
.section .rodata .cst256 .K256 , " aM" , @progbits, 256
2015-09-11 01:27:13 +03:00
.align 64
K256 :
.long 0 x4 2 8 a2 f98 ,0 x71 3 7 4 4 9 1 ,0 x b5 c0 f b c f ,0 x e 9 b5 d b a5
.long 0 x3 9 5 6 c25 b ,0 x59 f11 1 f1 ,0 x92 3 f82 a4 ,0 x a b1 c5 e d5
.long 0 xd8 0 7 a a98 ,0 x12 8 3 5 b01 ,0 x24 3 1 8 5 b e ,0 x55 0 c7 d c3
.long 0 x7 2 b e 5 d74 ,0 x80 d e b1 f e ,0 x9 b d c06 a7 ,0 x c19 b f17 4
.long 0 xe4 9 b69 c1 ,0 x e f b e 4 7 8 6 ,0 x0 f c19 d c6 ,0 x24 0 c a1 c c
.long 0 x2 d e 9 2 c6 f ,0 x4 a74 8 4 a a ,0 x5 c b0 a9 d c ,0 x76 f98 8 d a
.long 0 x9 8 3 e 5 1 5 2 ,0 x a83 1 c66 d ,0 x b00 3 2 7 c8 ,0 x b f59 7 f c7
.long 0 xc6 e 0 0 b f3 ,0 x d5 a79 1 4 7 ,0 x06 c a63 5 1 ,0 x14 2 9 2 9 6 7
.long 0 x2 7 b70 a85 ,0 x2 e 1 b21 3 8 ,0 x4 d2 c6 d f c ,0 x53 3 8 0 d13
.long 0 x6 5 0 a73 5 4 ,0 x76 6 a0 a b b ,0 x81 c2 c92 e ,0 x92 7 2 2 c85
.long 0 xa2 b f e 8 a1 ,0 x a81 a66 4 b ,0 x c24 b8 b70 ,0 x c76 c51 a3
.long 0 xd1 9 2 e 8 1 9 ,0 x d69 9 0 6 2 4 ,0 x f40 e 3 5 8 5 ,0 x10 6 a a07 0
.long 0 x1 9 a4 c11 6 ,0 x1 e 3 7 6 c08 ,0 x27 4 8 7 7 4 c ,0 x34 b0 b c b5
.long 0 x3 9 1 c0 c b3 ,0 x4 e d8 a a4 a ,0 x5 b9 c c a4 f ,0 x68 2 e 6 f f3
.long 0 x7 4 8 f82 e e ,0 x78 a56 3 6 f ,0 x84 c87 8 1 4 ,0 x8 c c70 2 0 8
.long 0 x9 0 b e f f f a ,0 x a45 0 6 c e b ,0 x b e f9 a3 f7 ,0 x c67 1 7 8 f2
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-20 00:33:04 +03:00
.section .rodata .cst16 .PSHUFFLE_BYTE_FLIP_MASK , " aM" , @progbits, 16
.align 16
2015-09-11 01:27:13 +03:00
PSHUFFLE_BYTE_FLIP_MASK :
.octa 0x0c0d0e0f08090a0b0405060700010203