qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] configure: add option to disable -fstack-protector flags
@ 2014-01-13 20:36 Steven Noonan
  2014-02-05 17:52 ` Paolo Bonzini
  2014-03-28 15:31 ` Laurent Desnogues
  0 siblings, 2 replies; 3+ messages in thread
From: Steven Noonan @ 2014-01-13 20:36 UTC (permalink / raw)
  To: qemu-devel; +Cc: Steven Noonan, Anthony Liguori

The -fstack-protector flag family is useful for ensuring safety and for
debugging, but has a performance impact. Here are some boot time comparisons of
the various versions of -fstack-protector using qemu-system-arm on an x86_64
host:

    # -fstack-protector-all
    Startup finished in 1.810s (kernel) + 12.331s (initrd) + 49.016s (userspace) = 1min 3.159s
    Startup finished in 1.801s (kernel) + 12.287s (initrd) + 47.925s (userspace) = 1min 2.013s
    Startup finished in 1.812s (kernel) + 12.302s (initrd) + 47.995s (userspace) = 1min 2.111s

    # -fstack-protector-strong
    Startup finished in 1.744s (kernel) + 11.223s (initrd) + 44.688s (userspace) = 57.657s
    Startup finished in 1.721s (kernel) + 11.222s (initrd) + 44.194s (userspace) = 57.138s
    Startup finished in 1.693s (kernel) + 11.250s (initrd) + 44.426s (userspace) = 57.370s

    # -fstack-protector
    Startup finished in 1.705s (kernel) + 11.409s (initrd) + 43.563s (userspace) = 56.677s
    Startup finished in 1.877s (kernel) + 11.137s (initrd) + 43.719s (userspace) = 56.734s
    Startup finished in 1.708s (kernel) + 11.141s (initrd) + 43.628s (userspace) = 56.478s

    # no stack protector
    Startup finished in 1.743s (kernel) + 11.190s (initrd) + 43.709s (userspace) = 56.643s
    Startup finished in 1.763s (kernel) + 11.216s (initrd) + 43.767s (userspace) = 56.747s
    Startup finished in 1.711s (kernel) + 11.283s (initrd) + 43.878s (userspace) = 56.873s

This patch introduces a configure option to disable the stack protector
entirely, and conditional stack protector flag selection (in order, based on
availability): -fstack-protector-strong, -fstack-protector, no stack protector.

Signed-off-by: Steven Noonan <snoonan@amazon.com>
Cc: Anthony Liguori <aliguori@amazon.com>
Reviewed-by: Stefan Weil <sw@weilnetz.de>
---
 configure | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 07b6be3..09f83a7 100755
--- a/configure
+++ b/configure
@@ -147,6 +147,7 @@ audio_win_int=""
 cc_i386=i386-pc-linux-gnu-gcc
 libs_qga=""
 debug_info="yes"
+stack_protector=""
 
 # Don't accept a target_list environment variable.
 unset target_list
@@ -879,6 +880,10 @@ for opt do
   ;;
   --disable-werror) werror="no"
   ;;
+  --enable-stack-protector) stack_protector="yes"
+  ;;
+  --disable-stack-protector) stack_protector="no"
+  ;;
   --disable-curses) curses="no"
   ;;
   --enable-curses) curses="yes"
@@ -1117,6 +1122,7 @@ echo "  --enable-sparse          enable sparse checker"
 echo "  --disable-sparse         disable sparse checker (default)"
 echo "  --disable-strip          disable stripping binaries"
 echo "  --disable-werror         disable compilation abort on warning"
+echo "  --disable-stack-protector disable compiler-provided stack protection"
 echo "  --disable-sdl            disable SDL"
 echo "  --enable-sdl             enable SDL"
 echo "  --disable-gtk            disable gtk UI"
@@ -1298,9 +1304,15 @@ for flag in $gcc_flags; do
     fi
 done
 
-if compile_prog "-Werror -fstack-protector-all" "" ; then
-    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
-    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
+if test "$stack_protector" != "no" ; then
+  gcc_flags="-fstack-protector-strong -fstack-protector"
+  for flag in $gcc_flags; do
+    if compile_prog "-Werror $flag" "" ; then
+      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
+      LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
+      break
+    fi
+  done
 fi
 
 # Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v3] configure: add option to disable -fstack-protector flags
  2014-01-13 20:36 [Qemu-devel] [PATCH v3] configure: add option to disable -fstack-protector flags Steven Noonan
@ 2014-02-05 17:52 ` Paolo Bonzini
  2014-03-28 15:31 ` Laurent Desnogues
  1 sibling, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2014-02-05 17:52 UTC (permalink / raw)
  To: Steven Noonan, qemu-devel; +Cc: Steven Noonan, Anthony Liguori

Il 13/01/2014 21:36, Steven Noonan ha scritto:
> The -fstack-protector flag family is useful for ensuring safety and for
> debugging, but has a performance impact. Here are some boot time comparisons of
> the various versions of -fstack-protector using qemu-system-arm on an x86_64
> host:
>
>     # -fstack-protector-all
>     Startup finished in 1.810s (kernel) + 12.331s (initrd) + 49.016s (userspace) = 1min 3.159s
>     Startup finished in 1.801s (kernel) + 12.287s (initrd) + 47.925s (userspace) = 1min 2.013s
>     Startup finished in 1.812s (kernel) + 12.302s (initrd) + 47.995s (userspace) = 1min 2.111s
>
>     # -fstack-protector-strong
>     Startup finished in 1.744s (kernel) + 11.223s (initrd) + 44.688s (userspace) = 57.657s
>     Startup finished in 1.721s (kernel) + 11.222s (initrd) + 44.194s (userspace) = 57.138s
>     Startup finished in 1.693s (kernel) + 11.250s (initrd) + 44.426s (userspace) = 57.370s
>
>     # -fstack-protector
>     Startup finished in 1.705s (kernel) + 11.409s (initrd) + 43.563s (userspace) = 56.677s
>     Startup finished in 1.877s (kernel) + 11.137s (initrd) + 43.719s (userspace) = 56.734s
>     Startup finished in 1.708s (kernel) + 11.141s (initrd) + 43.628s (userspace) = 56.478s
>
>     # no stack protector
>     Startup finished in 1.743s (kernel) + 11.190s (initrd) + 43.709s (userspace) = 56.643s
>     Startup finished in 1.763s (kernel) + 11.216s (initrd) + 43.767s (userspace) = 56.747s
>     Startup finished in 1.711s (kernel) + 11.283s (initrd) + 43.878s (userspace) = 56.873s
>
> This patch introduces a configure option to disable the stack protector
> entirely, and conditional stack protector flag selection (in order, based on
> availability): -fstack-protector-strong, -fstack-protector, no stack protector.
>
> Signed-off-by: Steven Noonan <snoonan@amazon.com>
> Cc: Anthony Liguori <aliguori@amazon.com>
> Reviewed-by: Stefan Weil <sw@weilnetz.de>
> ---
>  configure | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 07b6be3..09f83a7 100755
> --- a/configure
> +++ b/configure
> @@ -147,6 +147,7 @@ audio_win_int=""
>  cc_i386=i386-pc-linux-gnu-gcc
>  libs_qga=""
>  debug_info="yes"
> +stack_protector=""
>
>  # Don't accept a target_list environment variable.
>  unset target_list
> @@ -879,6 +880,10 @@ for opt do
>    ;;
>    --disable-werror) werror="no"
>    ;;
> +  --enable-stack-protector) stack_protector="yes"
> +  ;;
> +  --disable-stack-protector) stack_protector="no"
> +  ;;
>    --disable-curses) curses="no"
>    ;;
>    --enable-curses) curses="yes"
> @@ -1117,6 +1122,7 @@ echo "  --enable-sparse          enable sparse checker"
>  echo "  --disable-sparse         disable sparse checker (default)"
>  echo "  --disable-strip          disable stripping binaries"
>  echo "  --disable-werror         disable compilation abort on warning"
> +echo "  --disable-stack-protector disable compiler-provided stack protection"
>  echo "  --disable-sdl            disable SDL"
>  echo "  --enable-sdl             enable SDL"
>  echo "  --disable-gtk            disable gtk UI"
> @@ -1298,9 +1304,15 @@ for flag in $gcc_flags; do
>      fi
>  done
>
> -if compile_prog "-Werror -fstack-protector-all" "" ; then
> -    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
> -    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
> +if test "$stack_protector" != "no" ; then
> +  gcc_flags="-fstack-protector-strong -fstack-protector"
> +  for flag in $gcc_flags; do
> +    if compile_prog "-Werror $flag" "" ; then
> +      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
> +      LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
> +      break
> +    fi
> +  done
>  fi
>
>  # Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
>

I'll apply this to my configure branch as soon as I can test it, which 
will likely be tomorrow or friday.

Paolo

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH v3] configure: add option to disable -fstack-protector flags
  2014-01-13 20:36 [Qemu-devel] [PATCH v3] configure: add option to disable -fstack-protector flags Steven Noonan
  2014-02-05 17:52 ` Paolo Bonzini
@ 2014-03-28 15:31 ` Laurent Desnogues
  1 sibling, 0 replies; 3+ messages in thread
From: Laurent Desnogues @ 2014-03-28 15:31 UTC (permalink / raw)
  To: Steven Noonan; +Cc: Steven Noonan, qemu-devel@nongnu.org, Anthony Liguori

Hello,

On Mon, Jan 13, 2014 at 9:36 PM, Steven Noonan <steven@uplinklabs.net> wrote:
> The -fstack-protector flag family is useful for ensuring safety and for
> debugging, but has a performance impact. Here are some boot time comparisons of
> the various versions of -fstack-protector using qemu-system-arm on an x86_64
> host:
>
>     # -fstack-protector-all
>     Startup finished in 1.810s (kernel) + 12.331s (initrd) + 49.016s (userspace) = 1min 3.159s
>     Startup finished in 1.801s (kernel) + 12.287s (initrd) + 47.925s (userspace) = 1min 2.013s
>     Startup finished in 1.812s (kernel) + 12.302s (initrd) + 47.995s (userspace) = 1min 2.111s
>
>     # -fstack-protector-strong
>     Startup finished in 1.744s (kernel) + 11.223s (initrd) + 44.688s (userspace) = 57.657s
>     Startup finished in 1.721s (kernel) + 11.222s (initrd) + 44.194s (userspace) = 57.138s
>     Startup finished in 1.693s (kernel) + 11.250s (initrd) + 44.426s (userspace) = 57.370s
>
>     # -fstack-protector
>     Startup finished in 1.705s (kernel) + 11.409s (initrd) + 43.563s (userspace) = 56.677s
>     Startup finished in 1.877s (kernel) + 11.137s (initrd) + 43.719s (userspace) = 56.734s
>     Startup finished in 1.708s (kernel) + 11.141s (initrd) + 43.628s (userspace) = 56.478s
>
>     # no stack protector
>     Startup finished in 1.743s (kernel) + 11.190s (initrd) + 43.709s (userspace) = 56.643s
>     Startup finished in 1.763s (kernel) + 11.216s (initrd) + 43.767s (userspace) = 56.747s
>     Startup finished in 1.711s (kernel) + 11.283s (initrd) + 43.878s (userspace) = 56.873s
>
> This patch introduces a configure option to disable the stack protector
> entirely, and conditional stack protector flag selection (in order, based on
> availability): -fstack-protector-strong, -fstack-protector, no stack protector.

Why did you remove -fstack-protector-all which is the current default?

That being said, I manually applied your patch (it doesn't apply any
more) and ran it on qemu-system-arm.

Env: Fedora 19 x86_64, gcc 4.8.2, Intel 4770K (no OC, HT disabled)
Soft: ARM image booting kernel and running Sunspider with Google v8

main                   17.8s
prot_off               16.5s
prot_off+patch+disable 15.5s

prot_off is with --disable-stack-protector
patch is with Paolo patch to ENV_GET_CPU
disable is with --disable-qom-cast-debug

Definitely a good speed up.  I think a respin of that patch is needed
and would be a good thing :)

Thanks,

Laurent

> Signed-off-by: Steven Noonan <snoonan@amazon.com>
> Cc: Anthony Liguori <aliguori@amazon.com>
> Reviewed-by: Stefan Weil <sw@weilnetz.de>
> ---
>  configure | 18 +++++++++++++++---
>  1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 07b6be3..09f83a7 100755
> --- a/configure
> +++ b/configure
> @@ -147,6 +147,7 @@ audio_win_int=""
>  cc_i386=i386-pc-linux-gnu-gcc
>  libs_qga=""
>  debug_info="yes"
> +stack_protector=""
>
>  # Don't accept a target_list environment variable.
>  unset target_list
> @@ -879,6 +880,10 @@ for opt do
>    ;;
>    --disable-werror) werror="no"
>    ;;
> +  --enable-stack-protector) stack_protector="yes"
> +  ;;
> +  --disable-stack-protector) stack_protector="no"
> +  ;;
>    --disable-curses) curses="no"
>    ;;
>    --enable-curses) curses="yes"
> @@ -1117,6 +1122,7 @@ echo "  --enable-sparse          enable sparse checker"
>  echo "  --disable-sparse         disable sparse checker (default)"
>  echo "  --disable-strip          disable stripping binaries"
>  echo "  --disable-werror         disable compilation abort on warning"
> +echo "  --disable-stack-protector disable compiler-provided stack protection"
>  echo "  --disable-sdl            disable SDL"
>  echo "  --enable-sdl             enable SDL"
>  echo "  --disable-gtk            disable gtk UI"
> @@ -1298,9 +1304,15 @@ for flag in $gcc_flags; do
>      fi
>  done
>
> -if compile_prog "-Werror -fstack-protector-all" "" ; then
> -    QEMU_CFLAGS="$QEMU_CFLAGS -fstack-protector-all"
> -    LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,-fstack-protector-all"
> +if test "$stack_protector" != "no" ; then
> +  gcc_flags="-fstack-protector-strong -fstack-protector"
> +  for flag in $gcc_flags; do
> +    if compile_prog "-Werror $flag" "" ; then
> +      QEMU_CFLAGS="$QEMU_CFLAGS $flag"
> +      LIBTOOLFLAGS="$LIBTOOLFLAGS -Wc,$flag"
> +      break
> +    fi
> +  done
>  fi
>
>  # Workaround for http://gcc.gnu.org/PR55489.  Happens with -fPIE/-fPIC and
> --
> 1.8.5.2
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-28 15:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-13 20:36 [Qemu-devel] [PATCH v3] configure: add option to disable -fstack-protector flags Steven Noonan
2014-02-05 17:52 ` Paolo Bonzini
2014-03-28 15:31 ` Laurent Desnogues

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).