target-arm: add SHA-3, SM3 and SHA512 instruction support
v3 cover target-arm: add SHA-3, SM3 and SHA512 instruction support
This v3 is a follow-up to the single patch 'target/arm: implement SHA-512 instructions' sent out on the 9th of January.
Changes since v2:
- fix thinko in big-endian aware handling of 64-bit quantities: this is not needed given that the NEON registers are represented as arrays of uint64_t so they always appear in the correct order.
- add support for SM3 instructions (Chinese SHA derivative)
Changes since v1:
- update SHA512 patch to adhere more closely to the existing style, and to the way the instruction encodings are classified in the ARM ARM (#1)
- add patch implementing the new SHA3 instructions EOR3/RAX1/XAR/BCAX (#2)
- enable support for these instructions in user mode emulation (#3)
Ard Biesheuvel (4):
target/arm: implement SHA-512 instructions target/arm: implement SHA-3 instructions
target/arm: implement SM3 instructions
target/arm: enable user-mode SHA-3, SM3 and SHA-512 instruction
support
linux-user/elfload.c | 18 ++ target/arm/cpu.h | 3 + target/arm/cpu64.c | 3 + target/arm/crypto_helper.c | 311 +++++++++++++++++++- target/arm/helper.h | 15 + target/arm/translate-a64.c | 255 ++++++++++++++++ 6 files changed, 604 insertions(+), 1 deletion(-)
Signature · 1 line
2.11.0
PATCH v3 1/4 target/arm: implement SHA-512 instructions
This implements emulation of the new SHA-512 instructions that have been added as an optional extensions to the ARMv8 Crypto Extensions in ARM v8.2.
--- target/arm/cpu.h | 1 + target/arm/crypto_helper.c | 99 +++++++++++++++++++- target/arm/helper.h | 5 + target/arm/translate-a64.c | 99 ++++++++++++++++++++ 4 files changed, 203 insertions(+), 1 deletion(-)
target/arm/cpu.h +1 -0
@@ -1340,6 +1340,7 @@ enum arm_features {ARM_FEATURE_VBAR ,/* has cp15 VBAR */ ARM_FEATURE_M_SECURITY ,/* M profile Security Extension */ ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ + ARM_FEATURE_V8_SHA512, /* implements SHA512 part of v8 Crypto Extensions */ };static inline int arm_feature (CPUARMState *env,int feature)
target/arm/crypto_helper.c +98 -1
108 lines not on this page · raw message
target/arm/helper.h +5 -0
@@ -534,6 +534,11 @@ DEF_HELPER_4(crypto_sha256h2, void, env, i32, i32, i32) DEF_HELPER_3(crypto_sha256su0, void, env, i32, i32) DEF_HELPER_4(crypto_sha256su1, void, env, i32, i32, i32) +DEF_HELPER_4(crypto_sha512h, void, env, i32, i32, i32) +DEF_HELPER_4(crypto_sha512h2, void, env, i32, i32, i32) +DEF_HELPER_3(crypto_sha512su0, void, env, i32, i32) +DEF_HELPER_4(crypto_sha512su1, void, env, i32, i32, i32) + DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32)DEF_HELPER_2 (dc_zva, void, env, i64)
target/arm/translate-a64.c +99 -0
111 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 2/4 target/arm: implement SHA-3 instructions
In reply to Ard BiesheuvelThis implements emulation of the new SHA-3 instructions that have been added as an optional extensions to the ARMv8 Crypto Extensions in ARM v8.2.
--- target/arm/cpu.h | 1 + target/arm/crypto_helper.c | 69 +++++++++++++ target/arm/helper.h | 5 + target/arm/translate-a64.c | 108 +++++++++++++++++++- 4 files changed, 179 insertions(+), 4 deletions(-)
target/arm/cpu.h +1 -0
@@ -1341,6 +1341,7 @@ enum arm_features {ARM_FEATURE_M_SECURITY ,/* M profile Security Extension */ ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ ARM_FEATURE_V8_SHA512 ,/* implements SHA512 part of v8 Crypto Extensions */ + ARM_FEATURE_V8_SHA3, /* implements SHA3 part of v8 Crypto Extensions */ };static inline int arm_feature (CPUARMState *env,int feature)
target/arm/crypto_helper.c +69 -0
72 lines not on this page · raw message
target/arm/helper.h +5 -0
@@ -539,6 +539,11 @@ DEF_HELPER_4(crypto_sha512h2, void, env, i32, i32, i32) DEF_HELPER_3(crypto_sha512su0, void, env, i32, i32) DEF_HELPER_4(crypto_sha512su1, void, env, i32, i32, i32) +DEF_HELPER_4(crypto_rax1, void, env, i32, i32, i32) +DEF_HELPER_5(crypto_eor3, void, env, i32, i32, i32, i32) +DEF_HELPER_5(crypto_bcax, void, env, i32, i32, i32, i32) +DEF_HELPER_5(crypto_xar, void, env, i32, i32, i32, i32) + DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32)DEF_HELPER_2 (dc_zva, void, env, i64)
target/arm/translate-a64.c +104 -4
148 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 3/4 target/arm: implement SM3 instructions
In reply to Ard BiesheuvelThis implements emulation of the new SM3 instructions that have been added as an optional extension to the ARMv8 Crypto Extensions in ARM v8.2.
--- target/arm/cpu.h | 1 + target/arm/crypto_helper.c | 143 ++++++++++++++++++++ target/arm/helper.h | 5 + target/arm/translate-a64.c | 100 +++++++++++--- 4 files changed, 227 insertions(+), 22 deletions(-)
target/arm/cpu.h +1 -0
@@ -1342,6 +1342,7 @@ enum arm_features {ARM_FEATURE_JAZELLE ,/* has (trivial) Jazelle implementation */ ARM_FEATURE_V8_SHA512 ,/* implements SHA512 part of v8 Crypto Extensions */ ARM_FEATURE_V8_SHA3 ,/* implements SHA3 part of v8 Crypto Extensions */ + ARM_FEATURE_V8_SM3, /* implements SM3 part of v8 Crypto Extensions */ };static inline int arm_feature (CPUARMState *env,int feature)
target/arm/crypto_helper.c +143 -0
146 lines not on this page · raw message
target/arm/helper.h +5 -0
@@ -544,6 +544,11 @@ DEF_HELPER_5(crypto_eor3, void, env, i32, i32, i32, i32) DEF_HELPER_5(crypto_bcax, void, env, i32, i32, i32, i32) DEF_HELPER_5(crypto_xar, void, env, i32, i32, i32, i32) +DEF_HELPER_5(crypto_sm3ss1, void, env, i32, i32, i32, i32) +DEF_HELPER_6(crypto_sm3tt, void, env, i32, i32, i32, i32, i32) +DEF_HELPER_4(crypto_sm3partw1, void, env, i32, i32, i32) +DEF_HELPER_4(crypto_sm3partw2, void, env, i32, i32, i32) + DEF_HELPER_FLAGS_3(crc32, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32) DEF_HELPER_FLAGS_3(crc32c, TCG_CALL_NO_RWG_SE, i32, i32, i32, i32)DEF_HELPER_2 (dc_zva, void, env, i64)
target/arm/translate-a64.c +78 -22
124 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v3 4/4 target/arm: enable user-mode SHA-3, SM3 and SHA-512 instruction support
In reply to Ard BiesheuvelAdd support for the new ARMv8.2 SHA-3, SM3 and SHA-512 instructions to AArch64 user mode emulation.
--- linux-user/elfload.c | 18 ++++++++++++++++++ target/arm/cpu64.c | 3 +++ 2 files changed, 21 insertions(+)
linux-user/elfload.c +18 -0
@@ -512,6 +512,21 @@ enum {ARM_HWCAP_A64_SHA1 =1 <<5 ,ARM_HWCAP_A64_SHA2 =1 <<6 ,ARM_HWCAP_A64_CRC32 =1 <<7 , +ARM_HWCAP_A64_ATOMICS =1 <<8 , +ARM_HWCAP_A64_FPHP =1 <<9 , +ARM_HWCAP_A64_ASIMDHP =1 <<10 , +ARM_HWCAP_A64_CPUID =1 <<11 , +ARM_HWCAP_A64_ASIMDRDM =1 <<12 , +ARM_HWCAP_A64_JSCVT =1 <<13 , +ARM_HWCAP_A64_FCMA =1 <<14 , +ARM_HWCAP_A64_LRCPC =1 <<15 , +ARM_HWCAP_A64_DCPOP =1 <<16 , +ARM_HWCAP_A64_SHA3 =1 <<17 , +ARM_HWCAP_A64_SM3 =1 <<18 , +ARM_HWCAP_A64_SM4 =1 <<19 , +ARM_HWCAP_A64_ASIMDDP =1 <<20 , +ARM_HWCAP_A64_SHA512 =1 <<21 , + ARM_HWCAP_A64_SVE = 1 << 22, };#define ELF_HWCAP get_elf_hwcap()
@@ -532,6 +547,9 @@ static uint32_t get_elf_hwcap(void)GET_FEATURE (ARM_FEATURE_V8_SHA1 ,ARM_HWCAP_A64_SHA1 );GET_FEATURE (ARM_FEATURE_V8_SHA256 ,ARM_HWCAP_A64_SHA2 );GET_FEATURE (ARM_FEATURE_CRC ,ARM_HWCAP_A64_CRC32 ); +GET_FEATURE (ARM_FEATURE_V8_SHA3 ,ARM_HWCAP_A64_SHA3 ); +GET_FEATURE (ARM_FEATURE_V8_SM3 ,ARM_HWCAP_A64_SM3 ); +GET_FEATURE (ARM_FEATURE_V8_SHA512 ,ARM_HWCAP_A64_SHA512 );#undef GET_FEATUREreturn hwcaps;
target/arm/cpu64.c +3 -0
@@ -224,6 +224,9 @@ static void aarch64_any_initfn(Object *obj)set_feature (&cpu->env,ARM_FEATURE_V8_AES );set_feature (&cpu->env,ARM_FEATURE_V8_SHA1 );set_feature (&cpu->env,ARM_FEATURE_V8_SHA256 ); +set_feature (&cpu->env,ARM_FEATURE_V8_SHA3 ); +set_feature (&cpu->env,ARM_FEATURE_V8_SM3 ); +set_feature (&cpu->env,ARM_FEATURE_V8_SHA512 );set_feature (&cpu->env,ARM_FEATURE_V8_PMULL );set_feature (&cpu->env,ARM_FEATURE_CRC ); cpu->ctr =0x80038003 ;/* 32 byte I and D cacheline size, VIPT icache */
Signature · 1 line
2.11.0