lib/crypto/powerpc/chacha-p10le-8x.S

Source file repositories/reference/linux-study-clean/lib/crypto/powerpc/chacha-p10le-8x.S

File Facts

System
Linux kernel
Corpus path
lib/crypto/powerpc/chacha-p10le-8x.S
Extension
.S
Size
16252 bytes
Lines
841
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

#
# Accelerated chacha20 implementation for ppc64le.
#
# Copyright 2023- IBM Corp. All rights reserved
#
#===================================================================================
# Written by Danny Tsen <dtsen@us.ibm.com>
#
# do rounds,  8 quarter rounds
# 1.  a += b; d ^= a; d <<<= 16;
# 2.  c += d; b ^= c; b <<<= 12;
# 3.  a += b; d ^= a; d <<<= 8;
# 4.  c += d; b ^= c; b <<<= 7
#
# row1 = (row1 + row2),  row4 = row1 xor row4,  row4 rotate each word by 16
# row3 = (row3 + row4),  row2 = row3 xor row2,  row2 rotate each word by 12
# row1 = (row1 + row2), row4 = row1 xor row4,  row4 rotate each word by 8
# row3 = (row3 + row4), row2 = row3 xor row2,  row2 rotate each word by 7
#
# 4 blocks (a b c d)
#
# a0 b0 c0 d0
# a1 b1 c1 d1
# ...
# a4 b4 c4 d4
# ...
# a8 b8 c8 d8
# ...
# a12 b12 c12 d12
# a13 ...
# a14 ...
# a15 b15 c15 d15
#
# Column round (v0, v4,  v8, v12, v1, v5,  v9, v13, v2, v6, v10, v14, v3, v7, v11, v15)
# Diagnal round (v0, v5, v10, v15, v1, v6, v11, v12, v2, v7,  v8, v13, v3, v4,  v9, v14)
#

#include <asm/ppc_asm.h>
#include <asm/asm-offsets.h>
#include <asm/asm-compat.h>
#include <linux/linkage.h>

.machine	"any"
.text

.macro	SAVE_GPR GPR OFFSET FRAME
	std	\GPR,\OFFSET(\FRAME)
.endm

.macro	SAVE_VRS VRS OFFSET FRAME
	li	16, \OFFSET
	stvx	\VRS, 16, \FRAME
.endm

.macro	SAVE_VSX VSX OFFSET FRAME
	li	16, \OFFSET
	stxvx	\VSX, 16, \FRAME
.endm

.macro	RESTORE_GPR GPR OFFSET FRAME
	ld	\GPR,\OFFSET(\FRAME)
.endm

.macro	RESTORE_VRS VRS OFFSET FRAME
	li	16, \OFFSET
	lvx	\VRS, 16, \FRAME
.endm

.macro	RESTORE_VSX VSX OFFSET FRAME
	li	16, \OFFSET

Annotation

Implementation Notes