Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b0d6596 authored by Herbert Xu's avatar Herbert Xu
Browse files

crypto: ghash-intel - Add PSHUFB macros



Add PSHUFB macros instead of repeating byte sequences, suggested
by Ingo.

Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Acked-by: default avatarIngo Molnar <mingo@elte.hu>
parent 2d06ef7f
Loading
Loading
Loading
Loading
+6 −5
Original line number Original line Diff line number Diff line
@@ -17,6 +17,7 @@
 */
 */


#include <linux/linkage.h>
#include <linux/linkage.h>
#include <asm/i387.h>


.align 16
.align 16
.Lbswap_mask:
.Lbswap_mask:
@@ -101,7 +102,7 @@ ENTRY(clmul_ghash_mul)
	movups (%rsi), SHASH
	movups (%rsi), SHASH
	movaps .Lbswap_mask, BSWAP
	movaps .Lbswap_mask, BSWAP
	# pshufb BSWAP, DATA
	# pshufb BSWAP, DATA
	.byte 0x66, 0x0f, 0x38, 0x00, 0xc5
	PSHUFB_XMM5_XMM0
	call __clmul_gf128mul_ble
	call __clmul_gf128mul_ble
	# pshufb BSWAP, DATA
	# pshufb BSWAP, DATA
	.byte 0x66, 0x0f, 0x38, 0x00, 0xc5
	.byte 0x66, 0x0f, 0x38, 0x00, 0xc5
@@ -119,12 +120,12 @@ ENTRY(clmul_ghash_update)
	movups (%rdi), DATA
	movups (%rdi), DATA
	movups (%rcx), SHASH
	movups (%rcx), SHASH
	# pshufb BSWAP, DATA
	# pshufb BSWAP, DATA
	.byte 0x66, 0x0f, 0x38, 0x00, 0xc5
	PSHUFB_XMM5_XMM0
.align 4
.align 4
.Lupdate_loop:
.Lupdate_loop:
	movups (%rsi), IN1
	movups (%rsi), IN1
	# pshufb BSWAP, IN1
	# pshufb BSWAP, IN1
	.byte 0x66, 0x0f, 0x38, 0x00, 0xf5
	PSHUFB_XMM5_XMM6
	pxor IN1, DATA
	pxor IN1, DATA
	call __clmul_gf128mul_ble
	call __clmul_gf128mul_ble
	sub $16, %rdx
	sub $16, %rdx
@@ -132,7 +133,7 @@ ENTRY(clmul_ghash_update)
	cmp $16, %rdx
	cmp $16, %rdx
	jge .Lupdate_loop
	jge .Lupdate_loop
	# pshufb BSWAP, DATA
	# pshufb BSWAP, DATA
	.byte 0x66, 0x0f, 0x38, 0x00, 0xc5
	PSHUFB_XMM5_XMM0
	movups DATA, (%rdi)
	movups DATA, (%rdi)
.Lupdate_just_ret:
.Lupdate_just_ret:
	ret
	ret
@@ -146,7 +147,7 @@ ENTRY(clmul_ghash_setkey)
	movaps .Lbswap_mask, BSWAP
	movaps .Lbswap_mask, BSWAP
	movups (%rsi), %xmm0
	movups (%rsi), %xmm0
	# pshufb BSWAP, %xmm0
	# pshufb BSWAP, %xmm0
	.byte 0x66, 0x0f, 0x38, 0x00, 0xc5
	PSHUFB_XMM5_XMM0
	movaps %xmm0, %xmm1
	movaps %xmm0, %xmm1
	psllq $1, %xmm0
	psllq $1, %xmm0
	psrlq $63, %xmm1
	psrlq $63, %xmm1
+7 −0
Original line number Original line Diff line number Diff line
@@ -10,6 +10,8 @@
#ifndef _ASM_X86_I387_H
#ifndef _ASM_X86_I387_H
#define _ASM_X86_I387_H
#define _ASM_X86_I387_H


#ifndef __ASSEMBLY__

#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/kernel_stat.h>
#include <linux/kernel_stat.h>
#include <linux/regset.h>
#include <linux/regset.h>
@@ -411,4 +413,9 @@ static inline unsigned short get_fpu_mxcsr(struct task_struct *tsk)
	}
	}
}
}


#endif /* __ASSEMBLY__ */

#define PSHUFB_XMM5_XMM0 .byte 0x66, 0x0f, 0x38, 0x00, 0xc5
#define PSHUFB_XMM5_XMM6 .byte 0x66, 0x0f, 0x38, 0x00, 0xf5

#endif /* _ASM_X86_I387_H */
#endif /* _ASM_X86_I387_H */