cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-configure-add-option-to-disable-fstack-protect.patch

0a122b
From d43267efbe5634bfe9c8ca9cccd3d3d0a36759ae Mon Sep 17 00:00:00 2001
0a122b
From: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
Date: Wed, 5 Feb 2014 15:02:19 +0100
0a122b
Subject: [PATCH 09/28] configure: add option to disable -fstack-protect
0a122b
0a122b
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
Message-id: <fbd17542d86a4fd4beb4d9c672df14f237b51a62.1391612088.git.mrezanin@redhat.com>
0a122b
Patchwork-id: 57118
0a122b
O-Subject: [RHEL7 qemu-kvm PATCH 1/2] configure: add option to disable -fstack-protect
0a122b
Bugzilla: 1044182
0a122b
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
0a122b
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
0a122b
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
0a122b
0a122b
From: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
0a122b
upstream: submitted
0a122b
(Do not wait for apply to get to RHEL 7.0 before Snapshot 8)
0a122b
0a122b
The -fstack-protector flag family is useful for ensuring safety and for
0a122b
debugging, but has a performance impact. Here are some boot time comparisons
0a122b
of the various versions of -fstack-protector using qemu-system-arm on an
0a122b
x86_64 host:
0a122b
    # -fstack-protector-all
0a122b
    Startup finished in 1.810s (kernel) + 12.331s (initrd) + 49.016s
0a122b
(userspace) = 1min 3.159s
0a122b
    Startup finished in 1.801s (kernel) + 12.287s (initrd) + 47.925s
0a122b
(userspace) = 1min 2.013s
0a122b
    Startup finished in 1.812s (kernel) + 12.302s (initrd) + 47.995s
0a122b
(userspace) = 1min 2.111s
0a122b
0a122b
    # -fstack-protector-strong
0a122b
    Startup finished in 1.744s (kernel) + 11.223s (initrd) + 44.688s
0a122b
(userspace) = 57.657s
0a122b
    Startup finished in 1.721s (kernel) + 11.222s (initrd) + 44.194s
0a122b
(userspace) = 57.138s
0a122b
    Startup finished in 1.693s (kernel) + 11.250s (initrd) + 44.426s
0a122b
(userspace) = 57.370s
0a122b
0a122b
    # -fstack-protector
0a122b
    Startup finished in 1.705s (kernel) + 11.409s (initrd) + 43.563s
0a122b
(userspace) = 56.677s
0a122b
    Startup finished in 1.877s (kernel) + 11.137s (initrd) + 43.719s
0a122b
(userspace) = 56.734s
0a122b
    Startup finished in 1.708s (kernel) + 11.141s (initrd) + 43.628s
0a122b
(userspace) = 56.478s
0a122b
0a122b
    # no stack protector
0a122b
    Startup finished in 1.743s (kernel) + 11.190s (initrd) + 43.709s
0a122b
(userspace) = 56.643s
0a122b
    Startup finished in 1.763s (kernel) + 11.216s (initrd) + 43.767s
0a122b
(userspace) = 56.747s
0a122b
    Startup finished in 1.711s (kernel) + 11.283s (initrd) + 43.878s
0a122b
(userspace) = 56.873s
0a122b
0a122b
This patch introduces a configure option to disable the stack protector
0a122b
entirely, and conditional stack protector flag selection (in order, based on
0a122b
availability): -fstack-protector-strong, -fstack-protector, no stack protector.
0a122b
0a122b
Signed-off-by: Steven Noonan <address@hidden>
0a122b
Cc: Anthony Liguori <address@hidden>
0a122b
Reviewed-by: Stefan Weil <address@hidden>
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 configure | 18 +++++++++++++++---
0a122b
 1 file changed, 15 insertions(+), 3 deletions(-)
0a122b
0a122b
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
0a122b
---
0a122b
 configure |   18 +++++++++++++++---
0a122b
 1 files changed, 15 insertions(+), 3 deletions(-)
0a122b
0a122b
diff --git a/configure b/configure
0a122b
index b892b88..3f68220 100755
0a122b
--- a/configure
0a122b
+++ b/configure
0a122b
@@ -134,6 +134,7 @@ audio_win_int=""
0a122b
 cc_i386=i386-pc-linux-gnu-gcc
0a122b
 libs_qga=""
0a122b
 debug_info="yes"
0a122b
+stack_protector=""
0a122b
 
0a122b
 # Don't accept a target_list environment variable.
0a122b
 unset target_list
0a122b
@@ -839,6 +840,10 @@ for opt do
0a122b
   ;;
0a122b
   --disable-werror) werror="no"
0a122b
   ;;
0a122b
+  --enable-stack-protector) stack_protector="yes"
0a122b
+  ;;
0a122b
+  --disable-stack-protector) stack_protector="no"
0a122b
+  ;;
0a122b
   --disable-curses) curses="no"
0a122b
   ;;
0a122b
   --enable-curses) curses="yes"
0a122b
@@ -1115,6 +1120,7 @@ echo "  --enable-sparse          enable sparse checker"
0a122b
 echo "  --disable-sparse         disable sparse checker (default)"
0a122b
 echo "  --disable-strip          disable stripping binaries"
0a122b
 echo "  --disable-werror         disable compilation abort on warning"
0a122b
+echo "  --disable-stack-protector disable compiler-provided stack protection"
0a122b
 echo "  --disable-sdl            disable SDL"
0a122b
 echo "  --enable-sdl             enable SDL"
0a122b
 echo "  --disable-gtk            disable gtk UI"
0a122b
@@ -1296,9 +1302,15 @@ for flag in $gcc_flags; do
0a122b
     fi
0a122b
 done
0a122b
 
0a122b
-if compile_prog "-Werror -fstack-protector-all" "" ; then
0a122b
-    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
0a122b
-    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
0a122b
+if test "$stack_protector" != "no" ; then
0a122b
+  gcc_flags="-fstack-protector-strong -fstack-protector"
0a122b
+  for flag in $gcc_flags; do
0a122b
+    if compile_prog "-Werror $flag" "" ; then
0a122b
+      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
0a122b
+      LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
0a122b
+      break
0a122b
+    fi
0a122b
+  done
0a122b
 fi
0a122b
 
0a122b
 # Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
0a122b
-- 
0a122b
1.7.1
0a122b