summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2021-07-21 15:09:40 +0000
committerNiels Möller <nisse@lysator.liu.se>2021-07-21 15:09:40 +0000
commit83ed852508593c71d4ebe79e9598c212f143f216 (patch)
tree90dea4069bae0abcdb00f2d16eb86b6747e44ad4
parentc7b445a0a4a4f2d5385bd66219979c48010870f2 (diff)
parent4fc00c4dda061c52a7a0501d71fb26308990b4b1 (diff)
downloadnettle-83ed852508593c71d4ebe79e9598c212f143f216.tar.gz
Merge branch 's390x-fat' into 's390x'
[S390x] Replace inline assembly, fix fat filenames and add FAT_TEST_LIST See merge request nettle/nettle!32
-rw-r--r--configure.ac24
-rw-r--r--fat-s390x.c28
-rw-r--r--s390x/fat/aes128-decrypt-2.asm (renamed from s390x/fat/aes128-decrypt.asm)0
-rw-r--r--s390x/fat/aes128-encrypt-2.asm (renamed from s390x/fat/aes128-encrypt.asm)0
-rw-r--r--s390x/fat/aes128-set-decrypt-key-2.asm (renamed from s390x/fat/aes128-set-decrypt-key.asm)0
-rw-r--r--s390x/fat/aes128-set-encrypt-key-2.asm (renamed from s390x/fat/aes128-set-encrypt-key.asm)0
-rw-r--r--s390x/fat/aes192-decrypt-2.asm (renamed from s390x/fat/aes192-decrypt.asm)0
-rw-r--r--s390x/fat/aes192-encrypt-2.asm (renamed from s390x/fat/aes192-encrypt.asm)0
-rw-r--r--s390x/fat/aes192-set-decrypt-key-2.asm (renamed from s390x/fat/aes192-set-decrypt-key.asm)0
-rw-r--r--s390x/fat/aes192-set-encrypt-key-2.asm (renamed from s390x/fat/aes192-set-encrypt-key.asm)0
-rw-r--r--s390x/fat/aes256-decrypt-2.asm (renamed from s390x/fat/aes256-decrypt.asm)0
-rw-r--r--s390x/fat/aes256-encrypt-2.asm (renamed from s390x/fat/aes256-encrypt.asm)0
-rw-r--r--s390x/fat/aes256-set-decrypt-key-2.asm (renamed from s390x/fat/aes256-set-decrypt-key.asm)0
-rw-r--r--s390x/fat/aes256-set-encrypt-key-2.asm (renamed from s390x/fat/aes256-set-encrypt-key.asm)0
-rw-r--r--s390x/fat/cpu-facility.asm62
15 files changed, 92 insertions, 22 deletions
diff --git a/configure.ac b/configure.ac
index be061aa8..74cbc7ac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -533,6 +533,7 @@ if test "x$enable_assembler" = xyes ; then
if test "x$enable_fat" = xyes ; then
asm_path="s390x/fat $asm_path"
OPT_NETTLE_SOURCES="fat-s390x.c $OPT_NETTLE_SOURCES"
+ FAT_TEST_LIST="none msa_x1 msa_x2 msa_x4"
else
if test "$enable_s390x_msa" = yes ; then
asm_path="s390x/msa_x1 s390x/msa_x2 s390x/msa_x4 $asm_path"
@@ -565,8 +566,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 +682,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
diff --git a/fat-s390x.c b/fat-s390x.c
index 690b6013..927cf837 100644
--- a/fat-s390x.c
+++ b/fat-s390x.c
@@ -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/aes128-decrypt.asm b/s390x/fat/aes128-decrypt-2.asm
index f49c9849..f49c9849 100644
--- a/s390x/fat/aes128-decrypt.asm
+++ b/s390x/fat/aes128-decrypt-2.asm
diff --git a/s390x/fat/aes128-encrypt.asm b/s390x/fat/aes128-encrypt-2.asm
index 3d60c5a4..3d60c5a4 100644
--- a/s390x/fat/aes128-encrypt.asm
+++ b/s390x/fat/aes128-encrypt-2.asm
diff --git a/s390x/fat/aes128-set-decrypt-key.asm b/s390x/fat/aes128-set-decrypt-key-2.asm
index 9861e091..9861e091 100644
--- a/s390x/fat/aes128-set-decrypt-key.asm
+++ b/s390x/fat/aes128-set-decrypt-key-2.asm
diff --git a/s390x/fat/aes128-set-encrypt-key.asm b/s390x/fat/aes128-set-encrypt-key-2.asm
index ec799ffa..ec799ffa 100644
--- a/s390x/fat/aes128-set-encrypt-key.asm
+++ b/s390x/fat/aes128-set-encrypt-key-2.asm
diff --git a/s390x/fat/aes192-decrypt.asm b/s390x/fat/aes192-decrypt-2.asm
index 2889021d..2889021d 100644
--- a/s390x/fat/aes192-decrypt.asm
+++ b/s390x/fat/aes192-decrypt-2.asm
diff --git a/s390x/fat/aes192-encrypt.asm b/s390x/fat/aes192-encrypt-2.asm
index 6a532358..6a532358 100644
--- a/s390x/fat/aes192-encrypt.asm
+++ b/s390x/fat/aes192-encrypt-2.asm
diff --git a/s390x/fat/aes192-set-decrypt-key.asm b/s390x/fat/aes192-set-decrypt-key-2.asm
index cabb51d1..cabb51d1 100644
--- a/s390x/fat/aes192-set-decrypt-key.asm
+++ b/s390x/fat/aes192-set-decrypt-key-2.asm
diff --git a/s390x/fat/aes192-set-encrypt-key.asm b/s390x/fat/aes192-set-encrypt-key-2.asm
index 8416cc18..8416cc18 100644
--- a/s390x/fat/aes192-set-encrypt-key.asm
+++ b/s390x/fat/aes192-set-encrypt-key-2.asm
diff --git a/s390x/fat/aes256-decrypt.asm b/s390x/fat/aes256-decrypt-2.asm
index a3e68363..a3e68363 100644
--- a/s390x/fat/aes256-decrypt.asm
+++ b/s390x/fat/aes256-decrypt-2.asm
diff --git a/s390x/fat/aes256-encrypt.asm b/s390x/fat/aes256-encrypt-2.asm
index cfb23646..cfb23646 100644
--- a/s390x/fat/aes256-encrypt.asm
+++ b/s390x/fat/aes256-encrypt-2.asm
diff --git a/s390x/fat/aes256-set-decrypt-key.asm b/s390x/fat/aes256-set-decrypt-key-2.asm
index ad25d3b0..ad25d3b0 100644
--- a/s390x/fat/aes256-set-decrypt-key.asm
+++ b/s390x/fat/aes256-set-decrypt-key-2.asm
diff --git a/s390x/fat/aes256-set-encrypt-key.asm b/s390x/fat/aes256-set-encrypt-key-2.asm
index aeacf503..aeacf503 100644
--- a/s390x/fat/aes256-set-encrypt-key.asm
+++ b/s390x/fat/aes256-set-encrypt-key-2.asm
diff --git a/s390x/fat/cpu-facility.asm b/s390x/fat/cpu-facility.asm
new file mode 100644
index 00000000..59235d84
--- /dev/null
+++ b/s390x/fat/cpu-facility.asm
@@ -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)