From 3595d72f8696cd6d27581868201f971f164d2df1 Mon Sep 17 00:00:00 2001 From: Allan Jude Date: Thu, 6 Oct 2016 03:32:30 +0000 Subject: [PATCH] Disable loop unrolling in skein for sys/boot When tsoome@ added skein support to the ZFS boot code and zfsloader, it resulted in an explosion in code size, running close to a number of limits. The default for the C version of skein is to unroll all loops for skein-256 and 512 Disabling the loop unrolling saves 20-28kb from each binary boot1.efi gptzfsboot loader.efi userboot.so zfsloader Reviewed by: emaste, tsoome Sponsored by: ScaleEngine Inc. Differential Revision: https://reviews.freebsd.org/D7826 --- sys/boot/efi/boot1/Makefile | 2 ++ sys/boot/efi/loader/Makefile | 2 ++ sys/boot/i386/gptzfsboot/Makefile | 3 +++ sys/boot/i386/zfsboot/Makefile | 2 ++ sys/boot/userboot/zfs/Makefile | 3 +++ sys/boot/zfs/Makefile | 2 ++ 6 files changed, 14 insertions(+) diff --git a/sys/boot/efi/boot1/Makefile b/sys/boot/efi/boot1/Makefile index 5355c3141ec0..110a8577491b 100644 --- a/sys/boot/efi/boot1/Makefile +++ b/sys/boot/efi/boot1/Makefile @@ -28,6 +28,8 @@ SRCS= boot1.c self_reloc.c start.S ufs_module.c .if ${MK_ZFS} != "no" SRCS+= zfs_module.c SRCS+= skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 .PATH: ${.CURDIR}/../../../crypto/skein .endif diff --git a/sys/boot/efi/loader/Makefile b/sys/boot/efi/loader/Makefile index 7503cc2667c8..597c53ca9048 100644 --- a/sys/boot/efi/loader/Makefile +++ b/sys/boot/efi/loader/Makefile @@ -25,6 +25,8 @@ SRCS= autoload.c \ SRCS+= zfs.c .PATH: ${.CURDIR}/../../zfs SRCS+= skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 .PATH: ${.CURDIR}/../../../crypto/skein # Disable warnings that are currently incompatible with the zfs boot code diff --git a/sys/boot/i386/gptzfsboot/Makefile b/sys/boot/i386/gptzfsboot/Makefile index e8d7d5187269..793eeff30e70 100644 --- a/sys/boot/i386/gptzfsboot/Makefile +++ b/sys/boot/i386/gptzfsboot/Makefile @@ -36,6 +36,9 @@ CFLAGS= -DBOOTPROG=\"gptzfsboot\" \ -Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \ -Winline -Wno-tentative-definition-incomplete-type -Wno-pointer-sign +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 + .if !defined(LOADER_NO_GELI_SUPPORT) CFLAGS+= -DLOADER_GELI_SUPPORT CFLAGS+= -I${.CURDIR}/../../geli diff --git a/sys/boot/i386/zfsboot/Makefile b/sys/boot/i386/zfsboot/Makefile index e12a481387db..07bb7b7815d7 100644 --- a/sys/boot/i386/zfsboot/Makefile +++ b/sys/boot/i386/zfsboot/Makefile @@ -35,6 +35,8 @@ CFLAGS= -DBOOTPROG=\"zfsboot\" \ -Winline CFLAGS.gcc+= --param max-inline-insns-single=100 +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 LD_FLAGS=${LD_FLAGS_BIN} diff --git a/sys/boot/userboot/zfs/Makefile b/sys/boot/userboot/zfs/Makefile index cc320a483d99..3180b94788b7 100644 --- a/sys/boot/userboot/zfs/Makefile +++ b/sys/boot/userboot/zfs/Makefile @@ -8,6 +8,9 @@ INTERNALLIB= SRCS+= zfs.c skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 + CFLAGS+= -I${.CURDIR}/../../common -I${.CURDIR}/../../.. -I. CFLAGS+= -I${.CURDIR}/../../../../lib/libstand CFLAGS+= -I${.CURDIR}/../../../cddl/boot/zfs diff --git a/sys/boot/zfs/Makefile b/sys/boot/zfs/Makefile index db0f44a1d6a2..9180049becb1 100644 --- a/sys/boot/zfs/Makefile +++ b/sys/boot/zfs/Makefile @@ -6,6 +6,8 @@ INTERNALLIB= SRCS+= zfs.c SRCS+= skein.c skein_block.c +# Do not unroll skein loops, reduce code size +CFLAGS+= -DSKEIN_LOOP=111 .PATH: ${.CURDIR}/../../crypto/skein CFLAGS+= -DBOOTPROG=\"zfsloader\"