crypto: sparc - move opcodes.h into asm directory
authorEric Biggers <ebiggers@google.com>
Mon, 28 Apr 2025 17:00:34 +0000 (10:00 -0700)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 5 May 2025 10:20:43 +0000 (18:20 +0800)
Since arch/sparc/crypto/opcodes.h is now needed outside the
arch/sparc/crypto/ directory, move it into arch/sparc/include/asm/ so
that it can be included as <asm/opcodes.h>.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
17 files changed:
arch/sparc/crypto/aes_asm.S
arch/sparc/crypto/aes_glue.c
arch/sparc/crypto/camellia_asm.S
arch/sparc/crypto/camellia_glue.c
arch/sparc/crypto/des_asm.S
arch/sparc/crypto/des_glue.c
arch/sparc/crypto/md5_asm.S
arch/sparc/crypto/md5_glue.c
arch/sparc/crypto/opcodes.h [deleted file]
arch/sparc/crypto/sha1_asm.S
arch/sparc/crypto/sha1_glue.c
arch/sparc/crypto/sha256_asm.S
arch/sparc/crypto/sha256_glue.c
arch/sparc/crypto/sha512_asm.S
arch/sparc/crypto/sha512_glue.c
arch/sparc/include/asm/opcodes.h [new file with mode: 0644]
arch/sparc/lib/crc32c_asm.S

index 155cefb98520e9a7e3b2c9f86ac20b180ba8ff5b..f291174a72a1d0aa0839ebb72c91f2603ab384c5 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 
-#include "opcodes.h"
-
 #define ENCRYPT_TWO_ROUNDS(KEY_BASE, I0, I1, T0, T1) \
        AES_EROUND01(KEY_BASE +  0, I0, I1, T0) \
        AES_EROUND23(KEY_BASE +  2, I0, I1, T1) \
index 6831508303562ecca79ad60375572ae1b7357a54..359f22643b0518987eec73e655578f884a576543 100644 (file)
 #include <crypto/internal/skcipher.h>
 
 #include <asm/fpumacro.h>
+#include <asm/opcodes.h>
 #include <asm/pstate.h>
 #include <asm/elf.h>
 
-#include "opcodes.h"
-
 struct aes_ops {
        void (*encrypt)(const u64 *key, const u32 *input, u32 *output);
        void (*decrypt)(const u64 *key, const u32 *input, u32 *output);
index dcdc9193fcd721cc298b33d89e524d0c86399b65..8471b346ef5481ecc449273537ec7c200f189eca 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 
-#include "opcodes.h"
-
 #define CAMELLIA_6ROUNDS(KEY_BASE, I0, I1) \
        CAMELLIA_F(KEY_BASE +  0, I1, I0, I1) \
        CAMELLIA_F(KEY_BASE +  2, I0, I1, I0) \
index aaa9714378e665a7913a0fbe8ab7dc9df00e99ce..e7a1e1c42b996129246ea140b8898a30b98a93e1 100644 (file)
 #include <crypto/internal/skcipher.h>
 
 #include <asm/fpumacro.h>
+#include <asm/opcodes.h>
 #include <asm/pstate.h>
 #include <asm/elf.h>
 
-#include "opcodes.h"
-
 #define CAMELLIA_MIN_KEY_SIZE        16
 #define CAMELLIA_MAX_KEY_SIZE        32
 #define CAMELLIA_BLOCK_SIZE          16
index 7157468a679dfd81158c132d637a37498e685a91..d534446cbef9ae6c1c650f8866c77598b8d226c7 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 
-#include "opcodes.h"
-
        .align  32
 ENTRY(des_sparc64_key_expand)
        /* %o0=input_key, %o1=output_key */
index a499102bf70656cd9db3e78aac9379108ed5b234..e50ec4cd57cde932495071f7c7b11b13e2e72381 100644 (file)
 #include <crypto/internal/skcipher.h>
 
 #include <asm/fpumacro.h>
+#include <asm/opcodes.h>
 #include <asm/pstate.h>
 #include <asm/elf.h>
 
-#include "opcodes.h"
-
 struct des_sparc64_ctx {
        u64 encrypt_expkey[DES_EXPKEY_WORDS / 2];
        u64 decrypt_expkey[DES_EXPKEY_WORDS / 2];
index 7a6637455f37adb9a476affab560feb91bcd5356..60b544e4d205b1b7361e16c870c617ed7549fc4a 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 
-#include "opcodes.h"
-
 ENTRY(md5_sparc64_transform)
        /* %o0 = digest, %o1 = data, %o2 = rounds */
        VISEntryHalf
index 5b018c6a376c4809ba458fe4c04b341eb572c68c..b3615f0cdf626266a180d5e1b90c8f24efa3473f 100644 (file)
@@ -15,6 +15,7 @@
 #define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
 
 #include <asm/elf.h>
+#include <asm/opcodes.h>
 #include <asm/pstate.h>
 #include <crypto/internal/hash.h>
 #include <crypto/md5.h>
@@ -24,8 +25,6 @@
 #include <linux/string.h>
 #include <linux/unaligned.h>
 
-#include "opcodes.h"
-
 struct sparc_md5_state {
        __le32 hash[MD5_HASH_WORDS];
        u64 byte_count;
diff --git a/arch/sparc/crypto/opcodes.h b/arch/sparc/crypto/opcodes.h
deleted file mode 100644 (file)
index 417b6a1..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef _OPCODES_H
-#define _OPCODES_H
-
-#define SPARC_CR_OPCODE_PRIORITY       300
-
-#define F3F(x,y,z)     (((x)<<30)|((y)<<19)|((z)<<5))
-
-#define FPD_ENCODE(x)  (((x) >> 5) | ((x) & ~(0x20)))
-
-#define RS1(x)         (FPD_ENCODE(x) << 14)
-#define RS2(x)         (FPD_ENCODE(x) <<  0)
-#define RS3(x)         (FPD_ENCODE(x) <<  9)
-#define RD(x)          (FPD_ENCODE(x) << 25)
-#define IMM5_0(x)      ((x)           <<  0)
-#define IMM5_9(x)      ((x)           <<  9)
-
-#define CRC32C(a,b,c)  \
-       .word           (F3F(2,0x36,0x147)|RS1(a)|RS2(b)|RD(c));
-
-#define MD5            \
-       .word   0x81b02800;
-#define SHA1           \
-       .word   0x81b02820;
-#define SHA256         \
-       .word   0x81b02840;
-#define SHA512         \
-       .word   0x81b02860;
-
-#define AES_EROUND01(a,b,c,d)  \
-       .word   (F3F(2, 0x19, 0)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_EROUND23(a,b,c,d)  \
-       .word   (F3F(2, 0x19, 1)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_DROUND01(a,b,c,d)  \
-       .word   (F3F(2, 0x19, 2)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_DROUND23(a,b,c,d)  \
-       .word   (F3F(2, 0x19, 3)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_EROUND01_L(a,b,c,d)        \
-       .word   (F3F(2, 0x19, 4)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_EROUND23_L(a,b,c,d)        \
-       .word   (F3F(2, 0x19, 5)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_DROUND01_L(a,b,c,d)        \
-       .word   (F3F(2, 0x19, 6)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_DROUND23_L(a,b,c,d)        \
-       .word   (F3F(2, 0x19, 7)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define AES_KEXPAND1(a,b,c,d)  \
-       .word   (F3F(2, 0x19, 8)|RS1(a)|RS2(b)|IMM5_9(c)|RD(d));
-#define AES_KEXPAND0(a,b,c)    \
-       .word   (F3F(2, 0x36, 0x130)|RS1(a)|RS2(b)|RD(c));
-#define AES_KEXPAND2(a,b,c)    \
-       .word   (F3F(2, 0x36, 0x131)|RS1(a)|RS2(b)|RD(c));
-
-#define DES_IP(a,b)            \
-       .word           (F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
-#define DES_IIP(a,b)           \
-       .word           (F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
-#define DES_KEXPAND(a,b,c)     \
-       .word           (F3F(2, 0x36, 0x136)|RS1(a)|IMM5_0(b)|RD(c));
-#define DES_ROUND(a,b,c,d)     \
-       .word           (F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-
-#define CAMELLIA_F(a,b,c,d)            \
-       .word           (F3F(2, 0x19, 0x00c)|RS1(a)|RS2(b)|RS3(c)|RD(d));
-#define CAMELLIA_FL(a,b,c)             \
-       .word           (F3F(2, 0x36, 0x13c)|RS1(a)|RS2(b)|RD(c));
-#define CAMELLIA_FLI(a,b,c)            \
-       .word           (F3F(2, 0x36, 0x13d)|RS1(a)|RS2(b)|RD(c));
-
-#define MOVDTOX_F0_O4          \
-       .word   0x99b02200
-#define MOVDTOX_F2_O5          \
-       .word   0x9bb02202
-#define MOVXTOD_G1_F60                 \
-       .word   0xbbb02301
-#define MOVXTOD_G1_F62                 \
-       .word   0xbfb02301
-#define MOVXTOD_G3_F4          \
-       .word   0x89b02303;
-#define MOVXTOD_G7_F6          \
-       .word   0x8db02307;
-#define MOVXTOD_G3_F0          \
-       .word   0x81b02303;
-#define MOVXTOD_G7_F2          \
-       .word   0x85b02307;
-#define MOVXTOD_O0_F0          \
-       .word   0x81b02308;
-#define MOVXTOD_O5_F0          \
-       .word   0x81b0230d;
-#define MOVXTOD_O5_F2          \
-       .word   0x85b0230d;
-#define MOVXTOD_O5_F4          \
-       .word   0x89b0230d;
-#define MOVXTOD_O5_F6          \
-       .word   0x8db0230d;
-#define MOVXTOD_G3_F60         \
-       .word   0xbbb02303;
-#define MOVXTOD_G7_F62         \
-       .word   0xbfb02307;
-
-#endif /* _OPCODES_H */
index 7d8bf354f0e795413d18e7228b7932048d2afb76..00b46bac1b08f6db8dcc37e454de6cae0496af99 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 
-#include "opcodes.h"
-
 ENTRY(sha1_sparc64_transform)
        /* %o0 = digest, %o1 = data, %o2 = rounds */
        VISEntryHalf
index ec5a06948e0d44f12414be7be18ea5e1948dc2cd..ef19d5023b1bc30738a9d9c0fe9709253f28c569 100644 (file)
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
 
 #include <asm/elf.h>
+#include <asm/opcodes.h>
 #include <asm/pstate.h>
 #include <crypto/internal/hash.h>
 #include <crypto/sha1.h>
@@ -19,8 +20,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 
-#include "opcodes.h"
-
 asmlinkage void sha1_sparc64_transform(struct sha1_state *digest,
                                       const u8 *data, int rounds);
 
index 0b39ec7d7ca2983f47f3a0092913407a9b7878ae..8ce88611e98ad6c9b2b029b8a626e9936a2db6f8 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 
-#include "opcodes.h"
-
 ENTRY(sha256_sparc64_transform)
        /* %o0 = digest, %o1 = data, %o2 = rounds */
        VISEntryHalf
index ddb250242faf4c8316bc662ef4bae55bc966beea..25008603a98689f2f226094417cadaeac2bd430a 100644 (file)
@@ -12,6 +12,7 @@
 #define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
 
 #include <asm/elf.h>
+#include <asm/opcodes.h>
 #include <asm/pstate.h>
 #include <crypto/internal/hash.h>
 #include <crypto/sha2.h>
@@ -19,8 +20,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 
-#include "opcodes.h"
-
 asmlinkage void sha256_sparc64_transform(u32 *digest, const char *data,
                                         unsigned int rounds);
 
index b2f6e6728802366af17596f6c35dc827f98f1e8c..9932b4fe1b599c5268ff2658b5607fe0da22d8a0 100644 (file)
@@ -1,9 +1,8 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 
-#include "opcodes.h"
-
 ENTRY(sha512_sparc64_transform)
        /* %o0 = digest, %o1 = data, %o2 = rounds */
        VISEntry
index 1d0e1f98ca461655731186c3ef6e3393c196b1e9..47b9277b6877a8e5657c1fa7a1eb280ce9bd9cf3 100644 (file)
@@ -11,6 +11,7 @@
 #define pr_fmt(fmt)    KBUILD_MODNAME ": " fmt
 
 #include <asm/elf.h>
+#include <asm/opcodes.h>
 #include <asm/pstate.h>
 #include <crypto/internal/hash.h>
 #include <crypto/sha2.h>
@@ -18,8 +19,6 @@
 #include <linux/kernel.h>
 #include <linux/module.h>
 
-#include "opcodes.h"
-
 asmlinkage void sha512_sparc64_transform(u64 *digest, const char *data,
                                         unsigned int rounds);
 
diff --git a/arch/sparc/include/asm/opcodes.h b/arch/sparc/include/asm/opcodes.h
new file mode 100644 (file)
index 0000000..ebfda6e
--- /dev/null
@@ -0,0 +1,100 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _SPARC_ASM_OPCODES_H
+#define _SPARC_ASM_OPCODES_H
+
+#define SPARC_CR_OPCODE_PRIORITY       300
+
+#define F3F(x,y,z)     (((x)<<30)|((y)<<19)|((z)<<5))
+
+#define FPD_ENCODE(x)  (((x) >> 5) | ((x) & ~(0x20)))
+
+#define RS1(x)         (FPD_ENCODE(x) << 14)
+#define RS2(x)         (FPD_ENCODE(x) <<  0)
+#define RS3(x)         (FPD_ENCODE(x) <<  9)
+#define RD(x)          (FPD_ENCODE(x) << 25)
+#define IMM5_0(x)      ((x)           <<  0)
+#define IMM5_9(x)      ((x)           <<  9)
+
+#define CRC32C(a,b,c)  \
+       .word           (F3F(2,0x36,0x147)|RS1(a)|RS2(b)|RD(c));
+
+#define MD5            \
+       .word   0x81b02800;
+#define SHA1           \
+       .word   0x81b02820;
+#define SHA256         \
+       .word   0x81b02840;
+#define SHA512         \
+       .word   0x81b02860;
+
+#define AES_EROUND01(a,b,c,d)  \
+       .word   (F3F(2, 0x19, 0)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_EROUND23(a,b,c,d)  \
+       .word   (F3F(2, 0x19, 1)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_DROUND01(a,b,c,d)  \
+       .word   (F3F(2, 0x19, 2)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_DROUND23(a,b,c,d)  \
+       .word   (F3F(2, 0x19, 3)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_EROUND01_L(a,b,c,d)        \
+       .word   (F3F(2, 0x19, 4)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_EROUND23_L(a,b,c,d)        \
+       .word   (F3F(2, 0x19, 5)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_DROUND01_L(a,b,c,d)        \
+       .word   (F3F(2, 0x19, 6)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_DROUND23_L(a,b,c,d)        \
+       .word   (F3F(2, 0x19, 7)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define AES_KEXPAND1(a,b,c,d)  \
+       .word   (F3F(2, 0x19, 8)|RS1(a)|RS2(b)|IMM5_9(c)|RD(d));
+#define AES_KEXPAND0(a,b,c)    \
+       .word   (F3F(2, 0x36, 0x130)|RS1(a)|RS2(b)|RD(c));
+#define AES_KEXPAND2(a,b,c)    \
+       .word   (F3F(2, 0x36, 0x131)|RS1(a)|RS2(b)|RD(c));
+
+#define DES_IP(a,b)            \
+       .word           (F3F(2, 0x36, 0x134)|RS1(a)|RD(b));
+#define DES_IIP(a,b)           \
+       .word           (F3F(2, 0x36, 0x135)|RS1(a)|RD(b));
+#define DES_KEXPAND(a,b,c)     \
+       .word           (F3F(2, 0x36, 0x136)|RS1(a)|IMM5_0(b)|RD(c));
+#define DES_ROUND(a,b,c,d)     \
+       .word           (F3F(2, 0x19, 0x009)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+
+#define CAMELLIA_F(a,b,c,d)            \
+       .word           (F3F(2, 0x19, 0x00c)|RS1(a)|RS2(b)|RS3(c)|RD(d));
+#define CAMELLIA_FL(a,b,c)             \
+       .word           (F3F(2, 0x36, 0x13c)|RS1(a)|RS2(b)|RD(c));
+#define CAMELLIA_FLI(a,b,c)            \
+       .word           (F3F(2, 0x36, 0x13d)|RS1(a)|RS2(b)|RD(c));
+
+#define MOVDTOX_F0_O4          \
+       .word   0x99b02200
+#define MOVDTOX_F2_O5          \
+       .word   0x9bb02202
+#define MOVXTOD_G1_F60                 \
+       .word   0xbbb02301
+#define MOVXTOD_G1_F62                 \
+       .word   0xbfb02301
+#define MOVXTOD_G3_F4          \
+       .word   0x89b02303;
+#define MOVXTOD_G7_F6          \
+       .word   0x8db02307;
+#define MOVXTOD_G3_F0          \
+       .word   0x81b02303;
+#define MOVXTOD_G7_F2          \
+       .word   0x85b02307;
+#define MOVXTOD_O0_F0          \
+       .word   0x81b02308;
+#define MOVXTOD_O5_F0          \
+       .word   0x81b0230d;
+#define MOVXTOD_O5_F2          \
+       .word   0x85b0230d;
+#define MOVXTOD_O5_F4          \
+       .word   0x89b0230d;
+#define MOVXTOD_O5_F6          \
+       .word   0x8db0230d;
+#define MOVXTOD_G3_F60         \
+       .word   0xbbb02303;
+#define MOVXTOD_G7_F62         \
+       .word   0xbfb02307;
+
+#endif /* _SPARC_ASM_OPCODES_H */
index ee454fa6aed685b4cef8c00c33424d2db97fbe92..4db873850f44c9cc154756d9dd2b91123a097dac 100644 (file)
@@ -1,10 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #include <linux/linkage.h>
+#include <asm/opcodes.h>
 #include <asm/visasm.h>
 #include <asm/asi.h>
 
-#include "../crypto/opcodes.h"
-
 ENTRY(crc32c_sparc64)
        /* %o0=crc32p, %o1=data_ptr, %o2=len */
        VISEntryHalf