]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
crypto: x86/aes-xts - make the register aliases per-function
authorEric Biggers <ebiggers@google.com>
Thu, 12 Dec 2024 21:28:41 +0000 (13:28 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 21 Dec 2024 14:46:24 +0000 (22:46 +0800)
Since aes-xts-avx-x86_64.S contains multiple functions, move the
register aliases for the parameters and local variables of the XTS
update function into the macro that generates that function.  Then add
register aliases to aes_xts_encrypt_iv() to improve readability there.
This makes aes-xts-avx-x86_64.S consistent with the GCM assembly files.

No change in the generated code.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/aes-xts-avx-x86_64.S

index 580e733960522c5549e871f17e1b794766b31587..ca69e6480cb68746d43a91738d049ac968bf2a35 100644 (file)
        .byte   0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80
 .text
 
-// Function parameters
-.set   KEY,            %rdi    // Initially points to crypto_aes_ctx, then is
-                               // advanced to point to 7th-from-last round key
-.set   SRC,            %rsi    // Pointer to next source data
-.set   DST,            %rdx    // Pointer to next destination data
-.set   LEN,            %ecx    // Remaining length in bytes
-.set   LEN8,           %cl
-.set   LEN64,          %rcx
-.set   TWEAK,          %r8     // Pointer to next tweak
-
-// %rax holds the AES key length in bytes.
-.set   KEYLEN,         %eax
-.set   KEYLEN64,       %rax
-
-// %r9-r11 are available as temporaries.
-
 .macro _define_Vi      i
 .if VL == 16
        .set    V\i,            %xmm\i
 .endr
 .endif
 
+       // Function parameters
+       .set    KEY,            %rdi    // Initially points to crypto_aes_ctx, then is
+                                       // advanced to point to 7th-from-last round key
+       .set    SRC,            %rsi    // Pointer to next source data
+       .set    DST,            %rdx    // Pointer to next destination data
+       .set    LEN,            %ecx    // Remaining length in bytes
+       .set    LEN8,           %cl
+       .set    LEN64,          %rcx
+       .set    TWEAK,          %r8     // Pointer to next tweak
+
+       // %rax holds the AES key length in bytes.
+       .set    KEYLEN,         %eax
+       .set    KEYLEN64,       %rax
+
+       // %r9-r11 are available as temporaries.
+
        // V0-V3 hold the data blocks during the main loop, or temporary values
        // otherwise.  V4-V5 hold temporary values.
 
 // void aes_xts_encrypt_iv(const struct crypto_aes_ctx *tweak_key,
 //                        u8 iv[AES_BLOCK_SIZE]);
 SYM_TYPED_FUNC_START(aes_xts_encrypt_iv)
-       vmovdqu         (%rsi), %xmm0
-       vpxor           (%rdi), %xmm0, %xmm0
-       movl            480(%rdi), %eax         // AES key length
-       lea             -16(%rdi, %rax, 4), %rdi
-       cmp             $24, %eax
+       .set    TWEAK_KEY,      %rdi
+       .set    IV,             %rsi
+       .set    KEYLEN,         %eax
+       .set    KEYLEN64,       %rax
+
+       vmovdqu         (IV), %xmm0
+       vpxor           (TWEAK_KEY), %xmm0, %xmm0
+       movl            480(TWEAK_KEY), KEYLEN
+       lea             -16(TWEAK_KEY, KEYLEN64, 4), TWEAK_KEY
+       cmp             $24, KEYLEN
        jl              .Lencrypt_iv_aes128
        je              .Lencrypt_iv_aes192
-       vaesenc         -6*16(%rdi), %xmm0, %xmm0
-       vaesenc         -5*16(%rdi), %xmm0, %xmm0
+       vaesenc         -6*16(TWEAK_KEY), %xmm0, %xmm0
+       vaesenc         -5*16(TWEAK_KEY), %xmm0, %xmm0
 .Lencrypt_iv_aes192:
-       vaesenc         -4*16(%rdi), %xmm0, %xmm0
-       vaesenc         -3*16(%rdi), %xmm0, %xmm0
+       vaesenc         -4*16(TWEAK_KEY), %xmm0, %xmm0
+       vaesenc         -3*16(TWEAK_KEY), %xmm0, %xmm0
 .Lencrypt_iv_aes128:
 .irp i, -2,-1,0,1,2,3,4,5,6
-       vaesenc         \i*16(%rdi), %xmm0, %xmm0
+       vaesenc         \i*16(TWEAK_KEY), %xmm0, %xmm0
 .endr
-       vaesenclast     7*16(%rdi), %xmm0, %xmm0
-       vmovdqu         %xmm0, (%rsi)
+       vaesenclast     7*16(TWEAK_KEY), %xmm0, %xmm0
+       vmovdqu         %xmm0, (IV)
        RET
 SYM_FUNC_END(aes_xts_encrypt_iv)