diff options
author | John Högberg <[email protected]> | 2018-11-20 15:55:47 +0100 |
---|---|---|
committer | John Högberg <[email protected]> | 2018-11-20 15:55:47 +0100 |
commit | da9268d342e3f0f21b43fb55788f6e60aac55e71 (patch) | |
tree | d2f0adfb44aad2b5d103ac29a8be011b376788b9 /erts | |
parent | f2c1d537dc28ffbde5d42aedec70bf4c6574c3ea (diff) | |
parent | 3a812a499f9a40951f1ba6b7315473c5e149fd8b (diff) | |
download | otp-da9268d342e3f0f21b43fb55788f6e60aac55e71.tar.gz otp-da9268d342e3f0f21b43fb55788f6e60aac55e71.tar.bz2 otp-da9268d342e3f0f21b43fb55788f6e60aac55e71.zip |
Merge branch 'john/erts/spectre-configure-flag/OTP-15430/ERIERL-237' into john/erts/spectre-configure-flag-otp_20/OTP-15430/ERIERL-237
* john/erts/spectre-configure-flag/OTP-15430/ERIERL-237:
Allow disabling retpoline in interpreter loop
Add a ./configure flag for spectre mitigation
Diffstat (limited to 'erts')
-rw-r--r-- | erts/configure.in | 50 | ||||
-rw-r--r-- | erts/emulator/beam/beam_emu.c | 1 |
2 files changed, 51 insertions, 0 deletions
diff --git a/erts/configure.in b/erts/configure.in index cbebca97a3..1ae91f293f 100644 --- a/erts/configure.in +++ b/erts/configure.in @@ -422,6 +422,56 @@ if test X"$with_ets_write_concurrency_locks" != X""; then [Define to override the default number of write_concurrency locks]) fi +AC_ARG_WITH(spectre-mitigation, + AS_HELP_STRING([--with-spectre-mitigation={yes|incomplete}], + [enable spectre mitigation, either fully or with mitigations + disabled in a handful places like the interpreter]) + AS_HELP_STRING([--without-spectre-mitigation], + [build without spectre mitigation]), + [],[with_spectre_mitigation=no]) + +case "$with_spectre_mitigation" in + no) ;; + yes) ;; + incomplete) ;; + *) AC_MSG_ERROR([Invalid spectre mitigation setting]) ;; +esac + +i_noretpoline_attr="" + +if test X"$with_spectre_mitigation" != X"no"; then + CFLAGS="$CFLAGS -mindirect-branch=thunk" + + AC_MSG_CHECKING([for spectre mitigation]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([],[return 0;])], + [AC_MSG_RESULT([yes])], + [AC_MSG_ERROR([no])]) + + if test X"$with_spectre_mitigation" = X"incomplete"; then + # gcc and clang support this attribute if they're recent enough. Note + # that we must compile with -Werror to check for actual support as they + # warn rather than error out on unsupported attributes. + + i_noretpoline_attr='__attribute__((__indirect_branch__("keep")))' + i_preserve_cflags="$CFLAGS" + CFLAGS="$CFLAGS -Werror" + + AC_MSG_CHECKING([whether spectre mitigation can be disabled on a per-function basis]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([$i_noretpoline_attr],[return 0;])], + [AC_MSG_RESULT([yes])], + [AC_MSG_ERROR([no])]) + + CFLAGS="$i_preserve_cflags" + fi +fi + +AC_DEFINE_UNQUOTED(ERTS_NO_RETPOLINE, $i_noretpoline_attr, + [Per-function attribute for disabling retpoline. This is + *only* defined when --with-spectre-mitigation=incomplete + and has no effects otherwise]) + dnl ---------------------------------------------------------------------- dnl Checks for programs. dnl ---------------------------------------------------------------------- diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index b4e6c35579..7db0938b39 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -1237,6 +1237,7 @@ init_emulator(void) * the instructions' C labels to the loader. * The second call starts execution of BEAM code. This call never returns. */ +ERTS_NO_RETPOLINE void process_main(Eterm * x_reg_array, FloatDef* f_reg_array) { static int init_done = 0; |