Re: [PATCH] compiler-gcc: disable -ftracer for __noclone functions

From: Nadav Amit
Date: Sat May 05 2018 - 13:22:22 EST


Paolo Bonzini <pbonzini@xxxxxxxxxx> wrote:

> -ftracer can duplicate asm blocks causing compilation to fail in
> noclone functions. For example, KVM declares a global variable
> in an asm like
>
> asm("2: ... \n
> .pushsection data \n
> .global vmx_return \n
> vmx_return: .long 2b");
>
> and -ftracer causes a double declaration.
>
> Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
> Cc: Michal Marek <mmarek@xxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx
> Cc: kvm@xxxxxxxxxxxxxxx
> Reported-by: Linda Walsh <lkml@xxxxxxxxx>
> Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> ---
> include/linux/compiler-gcc.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/compiler-gcc.h b/include/linux/compiler-gcc.h
> index 22ab246feed3..eeae401a2412 100644
> --- a/include/linux/compiler-gcc.h
> +++ b/include/linux/compiler-gcc.h
> @@ -199,7 +199,7 @@
> #define unreachable() __builtin_unreachable()
>
> /* Mark a function definition as prohibited from being cloned. */
> -#define __noclone __attribute__((__noclone__))
> +#define __noclone __attribute__((__noclone__, __optimize__("no-tracer")))

[ Bringing the thread back from the dead for context ]

Setting different optimization attributes to certain functions apparently
prevents gcc from inlining functions with different âoptimizationsâ. This
results in poor compilation - most notably of vmx_vcpu_run() - and causes
short functions such as to_vmx() not to be inlined.

Regards,
Nadav