diff options
author | Christian Weisgerber <naddy@cvs.openbsd.org> | 2015-11-07 01:37:27 +0000 |
---|---|---|
committer | Christian Weisgerber <naddy@cvs.openbsd.org> | 2015-11-07 01:37:27 +0000 |
commit | 966a9b7591f8b4daf8ce119a6690e0575ffec433 (patch) | |
tree | a110966e36d9687ebd13f730a77bb3257e543099 /sys/arch | |
parent | acfe0a6f79f135c701e5b2ce57db63a0703470e7 (diff) |
Allow overriding ghash_update() with an optimized MD function. Use
this on amd64 to provide a version that uses the PCLMUL instruction
on CPUs that support it but don't have AESNI. ok mikeb@
Diffstat (limited to 'sys/arch')
-rw-r--r-- | sys/arch/amd64/amd64/aesni.c | 19 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/autoconf.c | 8 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/identcpu.c | 6 |
3 files changed, 30 insertions, 3 deletions
diff --git a/sys/arch/amd64/amd64/aesni.c b/sys/arch/amd64/amd64/aesni.c index adf4c3948ae..5693f28ee1f 100644 --- a/sys/arch/amd64/amd64/aesni.c +++ b/sys/arch/amd64/amd64/aesni.c @@ -1,4 +1,4 @@ -/* $OpenBSD: aesni.c,v 1.35 2015/08/28 19:59:36 tedu Exp $ */ +/* $OpenBSD: aesni.c,v 1.36 2015/11/07 01:37:26 naddy Exp $ */ /*- * Copyright (c) 2003 Jason Wright * Copyright (c) 2003, 2004 Theo de Raadt @@ -120,6 +120,9 @@ int aesni_swauth(struct cryptop *, struct cryptodesc *, struct swcr_data *, int aesni_encdec(struct cryptop *, struct cryptodesc *, struct cryptodesc *, struct aesni_session *); +void pclmul_setup(void); +void ghash_update_pclmul(GHASH_CTX *, uint8_t *, size_t); + void aesni_setup(void) { @@ -663,3 +666,17 @@ out: crypto_done(crp); return (err); } + +void +pclmul_setup(void) +{ + ghash_update = ghash_update_pclmul; +} + +void +ghash_update_pclmul(GHASH_CTX *ghash, uint8_t *src, size_t len) +{ + fpu_kernel_enter(); + aesni_gmac_update(ghash, src, len); + fpu_kernel_exit(); +} diff --git a/sys/arch/amd64/amd64/autoconf.c b/sys/arch/amd64/amd64/autoconf.c index 26cb2f3770c..0cb241770c1 100644 --- a/sys/arch/amd64/amd64/autoconf.c +++ b/sys/arch/amd64/amd64/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.43 2015/07/17 21:53:56 mlarkin Exp $ */ +/* $OpenBSD: autoconf.c,v 1.44 2015/11/07 01:37:26 naddy Exp $ */ /* $NetBSD: autoconf.c,v 1.1 2003/04/26 18:39:26 fvdl Exp $ */ /*- @@ -97,6 +97,9 @@ void rdrand(void *); void viac3_crypto_setup(void); extern int amd64_has_xcrypt; +void pclmul_setup(void); +extern int amd64_has_pclmul; + void aesni_setup(void); extern int amd64_has_aesni; #endif @@ -146,6 +149,9 @@ cpu_configure(void) if (amd64_has_xcrypt) viac3_crypto_setup(); + if (amd64_has_pclmul) + pclmul_setup(); + if (amd64_has_aesni) aesni_setup(); #endif diff --git a/sys/arch/amd64/amd64/identcpu.c b/sys/arch/amd64/amd64/identcpu.c index c0aa9409028..352c3f39beb 100644 --- a/sys/arch/amd64/amd64/identcpu.c +++ b/sys/arch/amd64/amd64/identcpu.c @@ -1,4 +1,4 @@ -/* $OpenBSD: identcpu.c,v 1.64 2015/08/12 05:31:41 mlarkin Exp $ */ +/* $OpenBSD: identcpu.c,v 1.65 2015/11/07 01:37:26 naddy Exp $ */ /* $NetBSD: identcpu.c,v 1.1 2003/04/26 18:39:28 fvdl Exp $ */ /* @@ -52,6 +52,7 @@ int cpuspeed; int amd64_has_xcrypt; #ifdef CRYPTO +int amd64_has_pclmul; int amd64_has_aesni; #endif int has_rdrand; @@ -560,6 +561,9 @@ identifycpu(struct cpu_info *ci) setperf_setup = est_init; #ifdef CRYPTO + if (cpu_ecxfeature & CPUIDECX_PCLMUL) + amd64_has_pclmul = 1; + if (cpu_ecxfeature & CPUIDECX_AES) amd64_has_aesni = 1; #endif |