1d2912cb1SThomas Gleixner/* SPDX-License-Identifier: GPL-2.0-only */ 2019cd469SArd Biesheuvel/* 3019cd469SArd Biesheuvel * Copyright (C) 2013 - 2017 Linaro Ltd <ard.biesheuvel@linaro.org> 4019cd469SArd Biesheuvel */ 5019cd469SArd Biesheuvel 6019cd469SArd Biesheuvel#include <linux/linkage.h> 7019cd469SArd Biesheuvel#include <asm/assembler.h> 8019cd469SArd Biesheuvel 9019cd469SArd Biesheuvel .arch armv8-a+crypto 10019cd469SArd Biesheuvel 11*0e89640bSMark BrownSYM_FUNC_START(__aes_ce_encrypt) 12019cd469SArd Biesheuvel sub w3, w3, #2 13019cd469SArd Biesheuvel ld1 {v0.16b}, [x2] 14019cd469SArd Biesheuvel ld1 {v1.4s}, [x0], #16 15019cd469SArd Biesheuvel cmp w3, #10 16019cd469SArd Biesheuvel bmi 0f 17019cd469SArd Biesheuvel bne 3f 18019cd469SArd Biesheuvel mov v3.16b, v1.16b 19019cd469SArd Biesheuvel b 2f 20019cd469SArd Biesheuvel0: mov v2.16b, v1.16b 21019cd469SArd Biesheuvel ld1 {v3.4s}, [x0], #16 22019cd469SArd Biesheuvel1: aese v0.16b, v2.16b 23019cd469SArd Biesheuvel aesmc v0.16b, v0.16b 24019cd469SArd Biesheuvel2: ld1 {v1.4s}, [x0], #16 25019cd469SArd Biesheuvel aese v0.16b, v3.16b 26019cd469SArd Biesheuvel aesmc v0.16b, v0.16b 27019cd469SArd Biesheuvel3: ld1 {v2.4s}, [x0], #16 28019cd469SArd Biesheuvel subs w3, w3, #3 29019cd469SArd Biesheuvel aese v0.16b, v1.16b 30019cd469SArd Biesheuvel aesmc v0.16b, v0.16b 31019cd469SArd Biesheuvel ld1 {v3.4s}, [x0], #16 32019cd469SArd Biesheuvel bpl 1b 33019cd469SArd Biesheuvel aese v0.16b, v2.16b 34019cd469SArd Biesheuvel eor v0.16b, v0.16b, v3.16b 35019cd469SArd Biesheuvel st1 {v0.16b}, [x1] 36019cd469SArd Biesheuvel ret 37*0e89640bSMark BrownSYM_FUNC_END(__aes_ce_encrypt) 38019cd469SArd Biesheuvel 39*0e89640bSMark BrownSYM_FUNC_START(__aes_ce_decrypt) 40019cd469SArd Biesheuvel sub w3, w3, #2 41019cd469SArd Biesheuvel ld1 {v0.16b}, [x2] 42019cd469SArd Biesheuvel ld1 {v1.4s}, [x0], #16 43019cd469SArd Biesheuvel cmp w3, #10 44019cd469SArd Biesheuvel bmi 0f 45019cd469SArd Biesheuvel bne 3f 46019cd469SArd Biesheuvel mov v3.16b, v1.16b 47019cd469SArd Biesheuvel b 2f 48019cd469SArd Biesheuvel0: mov v2.16b, v1.16b 49019cd469SArd Biesheuvel ld1 {v3.4s}, [x0], #16 50019cd469SArd Biesheuvel1: aesd v0.16b, v2.16b 51019cd469SArd Biesheuvel aesimc v0.16b, v0.16b 52019cd469SArd Biesheuvel2: ld1 {v1.4s}, [x0], #16 53019cd469SArd Biesheuvel aesd v0.16b, v3.16b 54019cd469SArd Biesheuvel aesimc v0.16b, v0.16b 55019cd469SArd Biesheuvel3: ld1 {v2.4s}, [x0], #16 56019cd469SArd Biesheuvel subs w3, w3, #3 57019cd469SArd Biesheuvel aesd v0.16b, v1.16b 58019cd469SArd Biesheuvel aesimc v0.16b, v0.16b 59019cd469SArd Biesheuvel ld1 {v3.4s}, [x0], #16 60019cd469SArd Biesheuvel bpl 1b 61019cd469SArd Biesheuvel aesd v0.16b, v2.16b 62019cd469SArd Biesheuvel eor v0.16b, v0.16b, v3.16b 63019cd469SArd Biesheuvel st1 {v0.16b}, [x1] 64019cd469SArd Biesheuvel ret 65*0e89640bSMark BrownSYM_FUNC_END(__aes_ce_decrypt) 66019cd469SArd Biesheuvel 67019cd469SArd Biesheuvel/* 68019cd469SArd Biesheuvel * __aes_ce_sub() - use the aese instruction to perform the AES sbox 69019cd469SArd Biesheuvel * substitution on each byte in 'input' 70019cd469SArd Biesheuvel */ 71*0e89640bSMark BrownSYM_FUNC_START(__aes_ce_sub) 72019cd469SArd Biesheuvel dup v1.4s, w0 73019cd469SArd Biesheuvel movi v0.16b, #0 74019cd469SArd Biesheuvel aese v0.16b, v1.16b 75019cd469SArd Biesheuvel umov w0, v0.s[0] 76019cd469SArd Biesheuvel ret 77*0e89640bSMark BrownSYM_FUNC_END(__aes_ce_sub) 78019cd469SArd Biesheuvel 79*0e89640bSMark BrownSYM_FUNC_START(__aes_ce_invert) 80019cd469SArd Biesheuvel ld1 {v0.4s}, [x1] 81019cd469SArd Biesheuvel aesimc v1.16b, v0.16b 82019cd469SArd Biesheuvel st1 {v1.4s}, [x0] 83019cd469SArd Biesheuvel ret 84*0e89640bSMark BrownSYM_FUNC_END(__aes_ce_invert) 85