Page MenuHomeFreeBSD

D27390.id80042.diff
No OneTemporary

D27390.id80042.diff

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/aarch64/ossl_cpuid.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/aarch64/ossl_cpuid.c
===================================================================
--- /dev/null
+++ sys/crypto/openssl/aarch64/ossl_cpuid.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 <mhorne@FreeBSD.org>
+ * 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 <sys/types.h>
+
+#include <machine/elf.h>
+#include <machine/md_var.h>
+
+#include <crypto/openssl/ossl.h>
+
+/*
+ * 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
@@ -515,6 +515,7 @@
_mlx4ib= mlx4ib
_mlx5ib= mlx5ib
.endif
+_ossl= ossl
_vmware= vmware
.endif
@@ -630,7 +631,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
@@ -19,6 +19,15 @@
ossl_sha512.c \
${SRCS.${MACHINE_CPUARCH}}
+# For arm64, we are required to rewrite the compiler invocation to remove
+# -mgeneral-regs-only.
+OBJS+= sha1-armv8.o \
+ sha256-armv8.o \
+ sha512-armv8.o
+${OBJS:Msha*-armv8.o}: ${.TARGET:R}.S
+ ${CC} -c ${CFLAGS:N-mgeneral-regs-only} ${WERROR} ${PROF} ${.IMPSRC}
+ ${CTFCONVERT_CMD}
+
SRCS.amd64= \
sha1-x86_64.S \
sha256-x86_64.S \
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"

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 18, 10:14 PM (3 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15898760
Default Alt Text
D27390.id80042.diff (5 KB)

Event Timeline