]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
[S390x] Replace inline assembly and fix fat filenames
authorMamone Tarsha <maamoun.tk@googlemail.com>
Wed, 21 Jul 2021 06:03:13 +0000 (09:03 +0300)
committerMamone Tarsha <maamoun.tk@googlemail.com>
Wed, 21 Jul 2021 06:03:13 +0000 (09:03 +0300)
15 files changed:
configure.ac
fat-s390x.c
s390x/fat/aes128-decrypt-2.asm [moved from s390x/fat/aes128-decrypt.asm with 100% similarity]
s390x/fat/aes128-encrypt-2.asm [moved from s390x/fat/aes128-encrypt.asm with 100% similarity]
s390x/fat/aes128-set-decrypt-key-2.asm [moved from s390x/fat/aes128-set-decrypt-key.asm with 100% similarity]
s390x/fat/aes128-set-encrypt-key-2.asm [moved from s390x/fat/aes128-set-encrypt-key.asm with 100% similarity]
s390x/fat/aes192-decrypt-2.asm [moved from s390x/fat/aes192-decrypt.asm with 100% similarity]
s390x/fat/aes192-encrypt-2.asm [moved from s390x/fat/aes192-encrypt.asm with 100% similarity]
s390x/fat/aes192-set-decrypt-key-2.asm [moved from s390x/fat/aes192-set-decrypt-key.asm with 100% similarity]
s390x/fat/aes192-set-encrypt-key-2.asm [moved from s390x/fat/aes192-set-encrypt-key.asm with 100% similarity]
s390x/fat/aes256-decrypt-2.asm [moved from s390x/fat/aes256-decrypt.asm with 100% similarity]
s390x/fat/aes256-encrypt-2.asm [moved from s390x/fat/aes256-encrypt.asm with 100% similarity]
s390x/fat/aes256-set-decrypt-key-2.asm [moved from s390x/fat/aes256-set-decrypt-key.asm with 100% similarity]
s390x/fat/aes256-set-encrypt-key-2.asm [moved from s390x/fat/aes256-set-encrypt-key.asm with 100% similarity]
s390x/fat/cpu-facility.asm [new file with mode: 0644]

index be061aa894af0ab70b4cb21f372feb0f08be14da..e4b22ee73088f6778e514f12b50ef7e475c31675 100644 (file)
@@ -565,8 +565,14 @@ asm_replace_list="aes-encrypt-internal.asm aes-decrypt-internal.asm \
                sha3-permute.asm umac-nh.asm umac-nh-n.asm machine.m4"
 
 # Assembler files which generate additional object files if they are used.
-asm_nettle_optional_list="gcm-hash.asm gcm-hash8.asm cpuid.asm \
+asm_nettle_optional_list="gcm-hash.asm gcm-hash8.asm cpuid.asm cpu-facility.asm \
   aes-encrypt-internal-2.asm aes-decrypt-internal-2.asm memxor-2.asm \
+  aes128-set-encrypt-key-2.asm aes128-set-decrypt-key-2.asm \
+  aes128-encrypt-2.asm aes128-decrypt-2.asm \
+  aes192-set-encrypt-key-2.asm aes192-set-decrypt-key-2.asm \
+  aes192-encrypt-2.asm aes192-decrypt-2.asm \
+  aes256-set-encrypt-key-2.asm aes256-set-decrypt-key-2.asm \
+  aes256-encrypt-2.asm aes256-decrypt-2.asm \
   chacha-2core.asm chacha-3core.asm chacha-4core.asm chacha-core-internal-2.asm \
   salsa20-2core.asm salsa20-core-internal-2.asm \
   sha1-compress-2.asm sha256-compress-2.asm \
@@ -675,6 +681,21 @@ AH_VERBATIM([HAVE_NATIVE],
     implementation of the corresponding routine exists.  */
 #undef HAVE_NATIVE_aes_decrypt
 #undef HAVE_NATIVE_aes_encrypt
+#undef HAVE_NATIVE_aes128_decrypt
+#undef HAVE_NATIVE_aes128_encrypt
+#undef HAVE_NATIVE_aes128_invert_key
+#undef HAVE_NATIVE_aes128_set_decrypt_key
+#undef HAVE_NATIVE_aes128_set_encrypt_key
+#undef HAVE_NATIVE_aes192_decrypt
+#undef HAVE_NATIVE_aes192_encrypt
+#undef HAVE_NATIVE_aes192_invert_key
+#undef HAVE_NATIVE_aes192_set_decrypt_key
+#undef HAVE_NATIVE_aes192_set_encrypt_key
+#undef HAVE_NATIVE_aes256_decrypt
+#undef HAVE_NATIVE_aes256_encrypt
+#undef HAVE_NATIVE_aes256_invert_key
+#undef HAVE_NATIVE_aes256_set_decrypt_key
+#undef HAVE_NATIVE_aes256_set_encrypt_key
 #undef HAVE_NATIVE_chacha_core
 #undef HAVE_NATIVE_chacha_2core
 #undef HAVE_NATIVE_chacha_3core
index 690b60134cc8f8fa8e7b49165b554229d0faeef9..927cf83776d512c186c34b4ddc30d76ef1ae3084 100644 (file)
@@ -84,6 +84,10 @@ struct s390x_features
   int have_kmid_ghash;
 };
 
+void _nettle_stfle(uint64_t *facility, uint64_t facility_size);
+void _nettle_km_status(uint64_t *status);
+void _nettle_kimd_status(uint64_t *status);
+
 #define MATCH(s, slen, literal, llen) \
   ((slen) == (llen) && memcmp ((s), (literal), llen) == 0)
 
@@ -126,24 +130,12 @@ get_s390x_features (struct s390x_features *features)
     if (hwcap & HWCAP_S390_STFLE)
     {
       uint64_t facilities[FACILITY_DOUBLEWORDS_MAX] = {0};
-
-      register uint64_t gr0 asm("0") = FACILITY_DOUBLEWORDS_MAX - 1;
-      asm volatile(
-        ".insn s,0xb2b00000,%1" /* stfle */
-        : "+d"(gr0), "=Q"(facilities)
-        :
-        : "cc");
+      _nettle_stfle(facilities, FACILITY_DOUBLEWORDS_MAX);
 
       if (facilities[FACILITY_INDEX(FAC_MSA)] & FACILITY_BIT(FAC_MSA))
       {
         uint64_t query_status[2] = {0};
-        register uint64_t *query_status_addr asm("1") = query_status;
-        asm volatile(
-          "lghi 0,0\n\t"
-          ".long 0xb92e0022" /* km %r2,%r2. Operands are ignored */
-          :
-          : "a"(query_status_addr)
-          : "memory", "cc", "r0");
+        _nettle_km_status(query_status);
         if (query_status[FACILITY_INDEX(AES_128_CODE)] & FACILITY_BIT(AES_128_CODE))
           features->have_km_aes128 = 1;
         if (query_status[FACILITY_INDEX(AES_192_CODE)] & FACILITY_BIT(AES_192_CODE))
@@ -155,13 +147,7 @@ get_s390x_features (struct s390x_features *features)
       if (facilities[FACILITY_INDEX(FAC_MSA_X4)] & FACILITY_BIT(FAC_MSA_X4))
       {
         uint64_t query_status[2] = {0};
-        register uint64_t *query_status_addr asm("1") = query_status;
-        asm volatile(
-          "lghi 0,0\n\t"
-          ".long 0xb93e0002" /* kimd %r0,%r2. Operands are ignored */
-          :
-          : "a"(query_status_addr)
-          : "memory", "cc", "r0");
+        _nettle_kimd_status(query_status);
         if (query_status[FACILITY_INDEX(GHASH_CODE)] & FACILITY_BIT(GHASH_CODE))
           features->have_kmid_ghash = 1;
       }
diff --git a/s390x/fat/cpu-facility.asm b/s390x/fat/cpu-facility.asm
new file mode 100644 (file)
index 0000000..59235d8
--- /dev/null
@@ -0,0 +1,62 @@
+C s390x/fat/cpu-facility.asm
+
+ifelse(`
+   Copyright (C) 2021 Mamone Tarsha
+
+   This file is part of GNU Nettle.
+
+   GNU Nettle is free software: you can redistribute it and/or
+   modify it under the terms of either:
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at your
+       option) any later version.
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at your
+       option) any later version.
+
+   or both in parallel, as here.
+
+   GNU Nettle is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see http://www.gnu.org/licenses/.
+')
+
+.file "cpu-facility.asm"
+
+.text
+
+C void _nettle_stfle(uint64_t *facility, uint64_t facility_size)
+
+PROLOGUE(_nettle_stfle)
+    lgr            %r0,%r3                       C facility_size
+    aghi           %r0,-1                        C facility_size - 1
+    .long          0xb2b02000                    C stfle 0(%r2)
+    br             RA
+EPILOGUE(_nettle_stfle)
+
+C void _nettle_km_status(uint64_t *status)
+
+PROLOGUE(_nettle_km_status)
+    lghi           %r0,0                         C query code
+    lgr            %r1,%r2                       C status
+    .long          0xb92e0022                    C km %r2,%r2. Operands are ignored
+    br             RA
+EPILOGUE(_nettle_km_status)
+
+C void _nettle_kimd_status(uint64_t *status)
+
+PROLOGUE(_nettle_kimd_status)
+    lghi           %r0,0                         C query code
+    lgr            %r1,%r2                       C status
+    .long          0xb93e0002                    C kimd %r0,%r2. Operands are ignored
+    br             RA
+EPILOGUE(_nettle_kimd_status)