diff mbox series

[03/11] Revert "compiler-gcc: disable -ftracer for __noclone functions"

Message ID 20181220202518.21442-4-sean.j.christopherson@intel.com (mailing list archive)
State New, archived
Headers show
Series KVM: VMX: Clean up VM-Enter/VM-Exit asm code | expand

Commit Message

Sean Christopherson Dec. 20, 2018, 8:25 p.m. UTC
The -ftracer optimization was disabled in __noclone as a workaround to
GCC duplicating a blob of inline assembly that happened to define a
global variable.  It has been pointed out that no amount of workarounds
can guarantee the compiler won't duplicate inline assembly[1], and that
disabling the -ftracer optimization has several unintended and nasty
side effects[2][3].

Now that the offending KVM code which required the workaround has
been properly fixed and no longer uses __noclone, remove the -ftracer
optimization tweak from __noclone.

[1] https://lore.kernel.org/lkml/ri6y38lo23g.fsf@suse.cz/T/#u
[2] https://lore.kernel.org/lkml/20181218140105.ajuiglkpvstt3qxs@treble/T/#u
[3] https://patchwork.kernel.org/patch/8707981/#21817015

This reverts commit 95272c29378ee7dc15f43fa2758cb28a5913a06d.

Suggested-by: Andi Kleen <ak@linux.intel.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Nadav Amit <namit@vmware.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Martin Jambor <mjambor@suse.cz>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Miroslav Benes <mbenes@suse.cz>
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
---
 include/linux/compiler_attributes.h | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Miguel Ojeda Dec. 21, 2018, 11:34 a.m. UTC | #1
Hi Sean,

On Thu, Dec 20, 2018 at 9:25 PM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> The -ftracer optimization was disabled in __noclone as a workaround to
> GCC duplicating a blob of inline assembly that happened to define a
> global variable.  It has been pointed out that no amount of workarounds
> can guarantee the compiler won't duplicate inline assembly[1], and that
> disabling the -ftracer optimization has several unintended and nasty
> side effects[2][3].
>
> Now that the offending KVM code which required the workaround has
> been properly fixed and no longer uses __noclone, remove the -ftracer
> optimization tweak from __noclone.
>
> [1] https://lore.kernel.org/lkml/ri6y38lo23g.fsf@suse.cz/T/#u
> [2] https://lore.kernel.org/lkml/20181218140105.ajuiglkpvstt3qxs@treble/T/#u
> [3] https://patchwork.kernel.org/patch/8707981/#21817015
>
> This reverts commit 95272c29378ee7dc15f43fa2758cb28a5913a06d.
>
> Suggested-by: Andi Kleen <ak@linux.intel.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Nadav Amit <namit@vmware.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: Martin Jambor <mjambor@suse.cz>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Miroslav Benes <mbenes@suse.cz>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
>  include/linux/compiler_attributes.h | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
>
> diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
> index f8c400ba1929..f3e16fc9a5df 100644
> --- a/include/linux/compiler_attributes.h
> +++ b/include/linux/compiler_attributes.h
> @@ -163,17 +163,11 @@
>
>  /*
>   * Optional: not supported by clang
> - * Note: icc does not recognize gcc's no-tracer
>   *
>   *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noclone-function-attribute
> - *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-optimize-function-attribute
>   */
>  #if __has_attribute(__noclone__)
> -# if __has_attribute(__optimize__)
> -#  define __noclone                     __attribute__((__noclone__, __optimize__("no-tracer")))
> -# else
> -#  define __noclone                     __attribute__((__noclone__))
> -# endif
> +# define __noclone                      __attribute__((__noclone__))
>  #else
>  # define __noclone
>  #endif

Please also remove the line:

    # define __GCC4_has_attribute___optimize__            1

in the top of the file. :-)

With that change:

Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

Cheers,
Miguel
Paolo Bonzini Dec. 21, 2018, 11:44 a.m. UTC | #2
On 21/12/18 12:34, Miguel Ojeda wrote:
> Please also remove the line:
> 
>     # define __GCC4_has_attribute___optimize__            1
> 
> in the top of the file. :-)
> 
> With that change:
> 
> Reviewed-by: Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>

Done, thanks.

Paolo
Miroslav Benes Dec. 21, 2018, 11:54 a.m. UTC | #3
On Thu, 20 Dec 2018, Sean Christopherson wrote:

> The -ftracer optimization was disabled in __noclone as a workaround to
> GCC duplicating a blob of inline assembly that happened to define a
> global variable.  It has been pointed out that no amount of workarounds
> can guarantee the compiler won't duplicate inline assembly[1], and that
> disabling the -ftracer optimization has several unintended and nasty
> side effects[2][3].
> 
> Now that the offending KVM code which required the workaround has
> been properly fixed and no longer uses __noclone, remove the -ftracer
> optimization tweak from __noclone.
> 
> [1] https://lore.kernel.org/lkml/ri6y38lo23g.fsf@suse.cz/T/#u
> [2] https://lore.kernel.org/lkml/20181218140105.ajuiglkpvstt3qxs@treble/T/#u
> [3] https://patchwork.kernel.org/patch/8707981/#21817015
> 
> This reverts commit 95272c29378ee7dc15f43fa2758cb28a5913a06d.
> 
> Suggested-by: Andi Kleen <ak@linux.intel.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Nadav Amit <namit@vmware.com>
> Cc: Andi Kleen <ak@linux.intel.com>
> Cc: Josh Poimboeuf <jpoimboe@redhat.com>
> Cc: Martin Jambor <mjambor@suse.cz>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Miroslav Benes <mbenes@suse.cz>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>

with Miguel's change

Reviewed-by: Miroslav Benes <mbenes@suse.cz>

Miroslav
diff mbox series

Patch

diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
index f8c400ba1929..f3e16fc9a5df 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -163,17 +163,11 @@ 
 
 /*
  * Optional: not supported by clang
- * Note: icc does not recognize gcc's no-tracer
  *
  *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-noclone-function-attribute
- *  gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-optimize-function-attribute
  */
 #if __has_attribute(__noclone__)
-# if __has_attribute(__optimize__)
-#  define __noclone                     __attribute__((__noclone__, __optimize__("no-tracer")))
-# else
-#  define __noclone                     __attribute__((__noclone__))
-# endif
+# define __noclone                      __attribute__((__noclone__))
 #else
 # define __noclone
 #endif