lib/crypto/x86/ghash-pclmul.S

Source file repositories/reference/linux-study-clean/lib/crypto/x86/ghash-pclmul.S

File Facts

System
Linux kernel
Corpus path
lib/crypto/x86/ghash-pclmul.S
Extension
.S
Size
2620 bytes
Lines
128
Domain
Kernel Services
Bucket
lib
Inferred role
Kernel Services: lib
Status
atlas-only

Why This File Exists

Shared kernel service surface used by multiple subsystems, including helpers, cryptography, virtualization support, and async I/O infrastructure.

Dependency Surface

Detected Declarations

Annotated Snippet

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

.section	.rodata.cst16.bswap_mask, "aM", @progbits, 16
.align 16
.Lbswap_mask:
	.octa 0x000102030405060708090a0b0c0d0e0f

#define ACC	%xmm0
#define KEY	%xmm1
#define T1	%xmm2
#define T2	%xmm3
#define T3	%xmm4
#define BSWAP	%xmm5
#define IN1	%xmm6

.text

/*
 * __clmul_gf128mul_ble:	internal ABI
 * input:
 *	ACC:			operand1
 *	KEY:			operand2, hash_key << 1 mod poly
 * output:
 *	ACC:			operand1 * operand2 mod poly
 * changed:
 *	T1
 *	T2
 *	T3
 */
SYM_FUNC_START_LOCAL(__clmul_gf128mul_ble)
	movaps ACC, T1
	pshufd $0b01001110, ACC, T2
	pshufd $0b01001110, KEY, T3
	pxor ACC, T2
	pxor KEY, T3

	pclmulqdq $0x00, KEY, ACC	# ACC = a0 * b0
	pclmulqdq $0x11, KEY, T1	# T1 = a1 * b1
	pclmulqdq $0x00, T3, T2		# T2 = (a1 + a0) * (b1 + b0)
	pxor ACC, T2
	pxor T1, T2			# T2 = a0 * b1 + a1 * b0

	movaps T2, T3
	pslldq $8, T3
	psrldq $8, T2
	pxor T3, ACC
	pxor T2, T1			# <T1:ACC> is result of
					# carry-less multiplication

	# first phase of the reduction
	movaps ACC, T3
	psllq $1, T3
	pxor ACC, T3
	psllq $5, T3
	pxor ACC, T3
	psllq $57, T3
	movaps T3, T2
	pslldq $8, T2
	psrldq $8, T3
	pxor T2, ACC
	pxor T3, T1

	# second phase of the reduction
	movaps ACC, T2
	psrlq $5, T2
	pxor ACC, T2
	psrlq $1, T2
	pxor ACC, T2
	psrlq $1, T2

Annotation

Implementation Notes