From ef83daf4dadf9380a3b94618fb7aee75fcd9a6b1 Mon Sep 17 00:00:00 2001 From: Richard Levitte Date: Wed, 11 Mar 2020 17:38:46 +0100 Subject: Refactor CPUID code We were using CPUID coded in several modules, but it was unclear how it actually got there, and could fail randomly. To remedy that, this change separates the CPUID C code from the rest of cryptlib.c, and ensures the right modules get both that and the assembler sources explicitly. Fixes #11281 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/14755) --- crypto/build.info | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'crypto/build.info') diff --git a/crypto/build.info b/crypto/build.info index dc180d0252..e6dce8ebc2 100644 --- a/crypto/build.info +++ b/crypto/build.info @@ -59,6 +59,31 @@ IF[{- !$disabled{asm} && $config{processor} ne '386' -}] ENDIF ENDIF +# CPUID support. We need to add that explicitly in every shared library and +# provider module that uses it. ctype.c is included here because the CPUID +# uses functions from there to parse magic environment variables. +$CPUID_COMMON=$CPUIDASM cpuid.c ctype.c +INCLUDE[cpuid.o]=.. + +SOURCE[../libcrypto]=$CPUID_COMMON +DEFINE[../libcrypto]=$CPUIDDEF +SOURCE[../providers/fips]=$CPUID_COMMON +DEFINE[../providers/fips]=$CPUIDDEF +# We only need to include the CPUID stuff in the legacy provider when it's a +# separate module and it's dynamically linked with libcrypto. Otherwise, it +# already gets everything that the static libcrypto.a has, and doesn't need it +# added again. +IF[{- !$disabled{module} && !$disabled{shared} -}] + SOURCE[../providers/liblegacy.a]=$CPUID_COMMON + DEFINE[../providers/liblegacy.a]=$CPUIDDEF +ENDIF + +# Implementations are now spread across several libraries, so the CPUID define +# need to be applied to all affected libraries and modules. +DEFINE[../providers/libfips.a]=$CPUIDDEF +DEFINE[../providers/libimplementations.a]=$CPUIDDEF +DEFINE[../providers/libcommon.a]=$CPUIDDEF + # The Core $CORE_COMMON=provider_core.c provider_predefined.c \ core_fetch.c core_algorithm.c core_namemap.c self_test_core.c @@ -69,28 +94,19 @@ SOURCE[../providers/libfips.a]=$CORE_COMMON # Central utilities $UTIL_COMMON=\ cryptlib.c params.c params_from_text.c bsearch.c ex_data.c o_str.c \ - ctype.c threads_pthread.c threads_win.c threads_none.c initthread.c \ - context.c sparse_array.c asn1_dsa.c packet.c param_build.c $CPUIDASM \ + threads_pthread.c threads_win.c threads_none.c initthread.c \ + context.c sparse_array.c asn1_dsa.c packet.c param_build.c \ param_build_set.c der_writer.c passphrase.c threads_lib.c -$UTIL_DEFINE=$CPUIDDEF SOURCE[../libcrypto]=$UTIL_COMMON \ mem.c mem_sec.c \ cversion.c info.c cpt_err.c ebcdic.c uid.c o_time.c o_dir.c \ o_fopen.c getenv.c o_init.c init.c trace.c provider.c \ - punycode.c \ - $UPLINKSRC + punycode.c SOURCE[../providers/libfips.a]=$UTIL_COMMON -SOURCE[../providers/liblegacy.a]=cryptlib.c $CPUIDASM ctype.c -# Implementations are now spread across several libraries, so the defines -# need to be applied to all affected libraries and modules. -DEFINE[../libcrypto]=$UTIL_DEFINE $UPLINKDEF -DEFINE[../providers/libfips.a]=$UTIL_DEFINE -DEFINE[../providers/fips]=$UTIL_DEFINE -DEFINE[../providers/libimplementations.a]=$UTIL_DEFINE -DEFINE[../providers/liblegacy.a]=$UTIL_DEFINE -DEFINE[../providers/libcommon.a]=$UTIL_DEFINE +SOURCE[../libcrypto]=$UPLINKSRC +DEFINE[../libcrypto]=$UPLINKDEF DEPEND[info.o]=buildinf.h DEPEND[cversion.o]=buildinf.h -- cgit v1.2.1