2 * Accelerated GHASH implementation with ARMv8 PMULL instructions.
4 * Copyright (C) 2014 Linaro Ltd. <ard.biesheuvel@linaro.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 as published
8 * by the Free Software Foundation.
11 #include <linux/linkage.h>
12 #include <asm/assembler.h>
28 * void pmull_ghash_update(int blocks, u64 dg[], const char *src,
29 * struct ghash_key const *k, const char *head)
31 ENTRY(pmull_ghash_update)
35 ext SHASH2.16b, SHASH.16b, SHASH.16b, #8
36 shl MASK.2d, MASK.2d, #57
37 eor SHASH2.16b, SHASH2.16b, SHASH.16b
39 /* do the head block first, if supplied */
44 0: ld1 {T1.2d}, [x2], #16
47 1: /* multiply XL by SHASH in GF(2^128) */
48 CPU_LE( rev64 T1.16b, T1.16b )
50 ext T2.16b, XL.16b, XL.16b, #8
51 ext IN1.16b, T1.16b, T1.16b, #8
52 eor T1.16b, T1.16b, T2.16b
53 eor XL.16b, XL.16b, IN1.16b
55 pmull2 XH.1q, SHASH.2d, XL.2d // a1 * b1
56 eor T1.16b, T1.16b, XL.16b
57 pmull XL.1q, SHASH.1d, XL.1d // a0 * b0
58 pmull XM.1q, SHASH2.1d, T1.1d // (a1 + a0)(b1 + b0)
60 ext T1.16b, XL.16b, XH.16b, #8
61 eor T2.16b, XL.16b, XH.16b
62 eor XM.16b, XM.16b, T1.16b
63 eor XM.16b, XM.16b, T2.16b
64 pmull T2.1q, XL.1d, MASK.1d
69 eor XL.16b, XM.16b, T2.16b
70 ext T2.16b, XL.16b, XL.16b, #8
71 pmull XL.1q, XL.1d, MASK.1d
72 eor T2.16b, T2.16b, XH.16b
73 eor XL.16b, XL.16b, T2.16b
79 ENDPROC(pmull_ghash_update)