[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH] Enable compiling with gcc tracing



On Wed, Mar 29, 2017 at 08:16:02PM +0200, Felix Schmoll wrote:
> Make minimal adjustments in order to enable the compilation of the
> xen source-code with gcc-6's -fsanitize-coverage=trace-pc option.
> 
> Due to a bug in Xen's build-system the flag for the compiler has
> to be handed in via the command line, i.e. for compiling one would
> use:
> 
>       make CC=<path to gcc-6>
> 
> This is an experimental patch as in a final version you would not
> want all files to be compiled with this option by default.
> 
> Signed-off-by: Felix Schmoll <eggi.innovations@xxxxxxxxx>

Have you tried booting Xen with this patch applied and trace-pc enabled?

> ---
>  xen/Rules.mk                | 1 +
>  xen/common/kernel.c         | 2 ++
>  xen/include/xen/hypercall.h | 2 ++
>  3 files changed, 5 insertions(+)
> 
> diff --git a/xen/Rules.mk b/xen/Rules.mk
> index 77bcd44922..254cc4381e 100644
> --- a/xen/Rules.mk
> +++ b/xen/Rules.mk
> @@ -46,6 +46,7 @@ else
>  CFLAGS += -O2 -fomit-frame-pointer
>  endif
>  
> +CFLAGS += -fsanitize-coverage=trace-pc
>  CFLAGS += -nostdinc -fno-builtin -fno-common
>  CFLAGS += -Werror -Wredundant-decls -Wno-pointer-arith
>  CFLAGS += -pipe -g -D__XEN__ -include $(BASEDIR)/include/xen/config.h
> diff --git a/xen/common/kernel.c b/xen/common/kernel.c
> index 84618715dc..77b22effb3 100644
> --- a/xen/common/kernel.c
> +++ b/xen/common/kernel.c
> @@ -238,6 +238,8 @@ void __init do_initcalls(void)
>  
>  # define DO(fn) long do_##fn
>  
> +void __sanitizer_cov_trace_pc(void) { return; }
> +

IIRC this is going to recurse until stack overflows, right?

What I actually want you to do is to add a new file and hook it up in
the build system.

And maybe if you feel like it, start looking at actually putting
something inside the trace_pc function.

Hint, you can get hold of PC with  __builtin_return_address(0).

>  #endif
>  
>  /*
> diff --git a/xen/include/xen/hypercall.h b/xen/include/xen/hypercall.h
> index cc99aea57d..12517b5e90 100644
> --- a/xen/include/xen/hypercall.h
> +++ b/xen/include/xen/hypercall.h
> @@ -19,6 +19,8 @@
>  #include <asm/hypercall.h>
>  #include <xsm/xsm.h>
>  
> +extern void __sanitizer_cov_trace_pc(void);
> +
>  extern long
>  do_sched_op(
>      int cmd,
> -- 
> 2.11.0
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.