types: Introduce [us]128
authorPeter Zijlstra <peterz@infradead.org>
Wed, 31 May 2023 13:08:35 +0000 (15:08 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 5 Jun 2023 07:36:35 +0000 (09:36 +0200)
Introduce [us]128 (when available). Unlike [us]64, ensure they are
always naturally aligned.

This also enables 128bit wide atomics (which require natural
alignment) such as cmpxchg128().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Herbert Xu <herbert@gondor.apana.org.au>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20230531132323.385005581@infradead.org
include/linux/types.h
include/uapi/linux/types.h
lib/crypto/curve25519-hacl64.c
lib/crypto/poly1305-donna64.c

index 688fb943556a1665554f94e1018add3befc76fff..becb8cd5916fc8da79edd50f8b4e402426191770 100644 (file)
 #define DECLARE_BITMAP(name,bits) \
        unsigned long name[BITS_TO_LONGS(bits)]
 
+#ifdef __SIZEOF_INT128__
+typedef __s128 s128;
+typedef __u128 u128;
+#endif
+
 typedef u32 __kernel_dev_t;
 
 typedef __kernel_fd_set                fd_set;
index 308433be33c2613c8b7dcb5a7e94d1346df5af13..6375a06840520da2d161a2873bb782200365ec64 100644 (file)
 
 #include <linux/posix_types.h>
 
+#ifdef __SIZEOF_INT128__
+typedef __signed__ __int128 __s128 __attribute__((aligned(16)));
+typedef unsigned __int128 __u128 __attribute__((aligned(16)));
+#endif
 
 /*
  * Below are truly Linux-specific types that should never collide with
index 771d82dc5f14e4f0d54a288c9dc6c522ee8e2c60..c40e5d9132343f524b1cee137c5c706e3baaba4b 100644 (file)
@@ -14,8 +14,6 @@
 #include <crypto/curve25519.h>
 #include <linux/string.h>
 
-typedef __uint128_t u128;
-
 static __always_inline u64 u64_eq_mask(u64 a, u64 b)
 {
        u64 x = a ^ b;
index d34cf4053668958ee48e176092d92d90c7d3c0f8..988702c9b3b2167210b4f18b20e0228f677eacd4 100644 (file)
@@ -10,8 +10,6 @@
 #include <asm/unaligned.h>
 #include <crypto/internal/poly1305.h>
 
-typedef __uint128_t u128;
-
 void poly1305_core_setkey(struct poly1305_core_key *key,
                          const u8 raw_key[POLY1305_BLOCK_SIZE])
 {