[PATCH 07/11] camellia-aarch64-ce: clear volatile vectors registers

Jussi Kivilinna jussi.kivilinna at iki.fi
Sun Nov 3 20:56:51 CET 2024


* cipher/camellia-simd128.h [__powerpc__] (clear_vec_regs): New.
[__ARM_NEON]: Include 'simd-common-aarch64.h'.
[__ARM_NEON] (memory_barrier_with_vec): Remove.
[__x86_64__] (clear_vec_regs): New.
(FUNC_ENC_BLK16, FUNC_DEC_BLK16, FUNC_KEY_SETUP): Add clear_vec_regs.
--

Signed-off-by: Jussi Kivilinna <jussi.kivilinna at iki.fi>
---
 cipher/camellia-simd128.h | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/cipher/camellia-simd128.h b/cipher/camellia-simd128.h
index ed26afb7..120fbe5a 100644
--- a/cipher/camellia-simd128.h
+++ b/cipher/camellia-simd128.h
@@ -152,6 +152,7 @@ static const uint8x16_t shift_row =
 #define if_not_aes_subbytes(...) /*_*/
 
 #define memory_barrier_with_vec(a) __asm__("" : "+wa"(a) :: "memory")
+#define clear_vec_regs() ((void)0)
 
 #endif /* __powerpc__ */
 
@@ -160,6 +161,7 @@ static const uint8x16_t shift_row =
 /**********************************************************************
   AT&T x86 asm to intrinsics conversion macros (ARMv8-CE)
  **********************************************************************/
+#include "simd-common-aarch64.h"
 #include <arm_neon.h>
 
 #define __m128i uint64x2_t
@@ -232,8 +234,6 @@ static const uint8x16_t shift_row =
 #define if_aes_subbytes(...) /*_*/
 #define if_not_aes_subbytes(...) __VA_ARGS__
 
-#define memory_barrier_with_vec(a) __asm__("" : "+w"(a) :: "memory")
-
 #endif /* __ARM_NEON */
 
 #if defined(__x86_64__) || defined(__i386__)
@@ -307,6 +307,7 @@ static const uint8x16_t shift_row =
 #define if_not_aes_subbytes(...) __VA_ARGS__
 
 #define memory_barrier_with_vec(a) __asm__("" : "+x"(a) :: "memory")
+#define clear_vec_regs() ((void)0)
 
 #endif /* defined(__x86_64__) || defined(__i386__) */
 
@@ -1123,6 +1124,8 @@ FUNC_ENC_BLK16(const void *key_table, void *vout, const void *vin,
 
   write_output(x7, x6, x5, x4, x3, x2, x1, x0, x15, x14, x13, x12, x11, x10, x9,
 	       x8, out);
+
+  clear_vec_regs();
 }
 
 /* Decrypts 16 input block from IN and writes result to OUT. IN and OUT may
@@ -1193,6 +1196,8 @@ FUNC_DEC_BLK16(const void *key_table, void *vout, const void *vin,
 
   write_output(x7, x6, x5, x4, x3, x2, x1, x0, x15, x14, x13, x12, x11, x10, x9,
 	       x8, out);
+
+  clear_vec_regs();
 }
 
 /********* Key setup **********************************************************/
@@ -2232,4 +2237,6 @@ FUNC_KEY_SETUP(void *key_table, const void *vkey, unsigned int keylen)
     }
 
   camellia_setup256(key_table, x0, x1);
+
+  clear_vec_regs();
 }
-- 
2.45.2




More information about the Gcrypt-devel mailing list