Index: share/man/man4/ossl.4 =================================================================== --- share/man/man4/ossl.4 +++ share/man/man4/ossl.4 @@ -26,12 +26,12 @@ .\" .\" $FreeBSD$ .\" -.Dd October 19, 2020 +.Dd November 26, 2020 .Dt OSSL 4 .Os .Sh NAME .Nm ossl -.Nd "driver using OpenSSL assembly routines on x86 CPUs" +.Nd "driver using OpenSSL assembly routines" .Sh SYNOPSIS To compile this driver into the kernel, place the following lines in your @@ -61,6 +61,8 @@ .Pp .Bl -bullet -compact .It +arm64 +.It amd64 .It i386 Index: sys/conf/files.arm64 =================================================================== --- sys/conf/files.arm64 +++ sys/conf/files.arm64 @@ -246,6 +246,13 @@ no-implicit-rule \ clean "armv8_crypto_wrap.o" crypto/des/des_enc.c optional netsmb +crypto/openssl/ossl_aarch64.c optional ossl +crypto/openssl/aarch64/sha1-armv8.S optional ossl \ + compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}" +crypto/openssl/aarch64/sha256-armv8.S optional ossl \ + compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}" +crypto/openssl/aarch64/sha512-armv8.S optional ossl \ + compile-with "${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}" dev/acpica/acpi_bus_if.m optional acpi dev/acpica/acpi_if.m optional acpi dev/acpica/acpi_pci_link.c optional acpi pci Index: sys/crypto/openssl/ossl_aarch64.c =================================================================== --- /dev/null +++ sys/crypto/openssl/ossl_aarch64.c @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause-FreeBSD + * + * Copyright (c) 2020 The FreeBSD Foundation + * + * This software was developed by Mitchell Horne + * under sponsorship from the FreeBSD Foundation. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + +#include +#include + +#include + +/* + * Feature bits defined in OpenSSL's arm_arch.h + */ +#define ARMV8_AES (1 << 2) +#define ARMV8_SHA1 (1 << 3) +#define ARMV8_SHA256 (1 << 4) +#define ARMV8_PMULL (1 << 5) +#define ARMV8_SHA512 (1 << 6) + +unsigned int OPENSSL_armcap_P; + +void +ossl_cpuid(void) +{ + /* SHA features */ + if ((elf_hwcap & HWCAP_SHA1) != 0) + OPENSSL_armcap_P |= ARMV8_AES; + if ((elf_hwcap & HWCAP_SHA2) != 0) + OPENSSL_armcap_P |= ARMV8_SHA256; + if ((elf_hwcap & HWCAP_SHA512) != 0) + OPENSSL_armcap_P |= ARMV8_SHA512; + + /* AES features */ + if ((elf_hwcap & HWCAP_AES) != 0) + OPENSSL_armcap_P |= ARMV8_AES; + if ((elf_hwcap & HWCAP_PMULL) != 0) + OPENSSL_armcap_P |= ARMV8_PMULL; +} Index: sys/modules/Makefile =================================================================== --- sys/modules/Makefile +++ sys/modules/Makefile @@ -518,6 +518,7 @@ _mlx4ib= mlx4ib _mlx5ib= mlx5ib .endif +_ossl= ossl _vmware= vmware .endif @@ -634,7 +635,6 @@ _ndis= ndis _ntb= ntb _ocs_fc= ocs_fc -_ossl= ossl _pccard= pccard _qat= qat _qatfw= qatfw Index: sys/modules/ossl/Makefile =================================================================== --- sys/modules/ossl/Makefile +++ sys/modules/ossl/Makefile @@ -13,6 +13,12 @@ ossl_sha512.c \ ${SRCS.${MACHINE_CPUARCH}} +SRCS.aarch64= \ + sha1-armv8.S \ + sha256-armv8.S \ + sha512-armv8.S \ + ossl_aarch64.c + SRCS.amd64= \ sha1-x86_64.S \ sha256-x86_64.S \ @@ -25,4 +31,10 @@ sha512-586.S \ ossl_x86.c +# For arm64, we are forced to rewrite the compiler invocation to remove +# -mgeneral-regs-only. +${SRCS.aarch64:S/S/o/}: ${.TARGET:R}.S + ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC} + ${CTFCONVERT_CMD} + .include Index: tests/sys/opencrypto/runtests.sh =================================================================== --- tests/sys/opencrypto/runtests.sh +++ tests/sys/opencrypto/runtests.sh @@ -65,7 +65,7 @@ case ${cpu_type} in aarch64) - cpu_module=nexus/armv8crypto + cpu_module="nexus/armv8crypto nexus/ossl" ;; amd64|i386) cpu_module="nexus/aesni nexus/ossl"