Re: [Xen-devel] [PATCH v4 1/2] gcov: add new interface and new formats support

2016-10-13 Thread Konrad Rzeszutek Wilk
> diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
> index 93f107c..2f64bb5 100644
> --- a/xen/common/sysctl.c
> +++ b/xen/common/sysctl.c
> @@ -28,6 +28,7 @@
>  #include 
>  #include 
>  #include 
> +#include 
>  
>  long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
>  {
> @@ -395,6 +396,13 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
> u_sysctl)
>  }
>  break;
>  
> +#ifdef CONFIG_GCOV
> +case XEN_SYSCTL_gcov_op:
> +ret = sysctl_gcov_op(>u.gcov_op);
> +copyback = 1;
> +break;
> +#endif

Should there be an XSM entry in flask_sysctl for this?
And also in flask/policy/access_vectors

And in tools/flask/policy/policy.conf

Maybe that should be a seperate patch?

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


Re: [Xen-devel] [PATCH v4 1/2] gcov: add new interface and new formats support

2016-10-13 Thread Wei Liu
On Thu, Oct 13, 2016 at 09:38:45AM -0400, Konrad Rzeszutek Wilk wrote:
> > diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
> > index 93f107c..2f64bb5 100644
> > --- a/xen/common/sysctl.c
> > +++ b/xen/common/sysctl.c
> > @@ -28,6 +28,7 @@
> >  #include 
> >  #include 
> >  #include 
> > +#include 
> >  
> >  long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
> >  {
> > @@ -395,6 +396,13 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) 
> > u_sysctl)
> >  }
> >  break;
> >  
> > +#ifdef CONFIG_GCOV
> > +case XEN_SYSCTL_gcov_op:
> > +ret = sysctl_gcov_op(>u.gcov_op);
> > +copyback = 1;
> > +break;
> > +#endif
> 
> Should there be an XSM entry in flask_sysctl for this?
> And also in flask/policy/access_vectors
> 
> And in tools/flask/policy/policy.conf
> 
> Maybe that should be a seperate patch?

Yes. That's planned. Didn't want to cram in too much stuff in one single
patch.

Wei.

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


Re: [Xen-devel] [PATCH v4 1/2] gcov: add new interface and new formats support

2016-10-13 Thread Wei Liu
On Thu, Oct 13, 2016 at 07:05:21AM -0600, Jan Beulich wrote:
> >>> On 13.10.16 at 14:04,  wrote:
> > A new sysctl interface for passing gcov data back to userspace. The new
> > interface uses a customised record file format. The new sysctl reuses
> > original sysctl number but renames the op to gcov_op.
> > 
> > Formats starting from gcc version 3.4 are supported. The code is
> > rewritten so that a new format can be easily added in the future.
> > Version specific code is grouped into different files. The format one
> > needs to use can be picked via Kconfig. The default format is the newest
> > one.
> > 
> > Userspace programs to handle extracted data will come in a later patch.
> > 
> > Signed-off-by: Wei Liu 
> 
> Acked-by: Jan Beulich 
> with one suggestion and one further adjustment:
> 
> > --- /dev/null
> > +++ b/xen/common/gcov/gcc_4_9.c
> > @@ -0,0 +1,35 @@
> > +/*
> > + *  This code provides functions to handle gcc's profiling data format
> > + *  introduced with gcc 4.7.
> > + *
> > + *  This file is based heavily on gcc_3_4.c file.
> 
> I think this is not really applicable here and in gcc_5.c.

OK. I will delete this.

> 
> > + *
> > + *  For a better understanding, refer to gcc source:
> > + *  gcc/gcov-io.h
> > + *  libgcc/libgcov.c
> > + *
> > + *  Uses gcc-internal data definitions.
> > + *
> > + *  Imported from Linux and modified for Xen by
> > + *Wei Liu 
> > + */
> > +
> > +#include "gcov.h"
> > +
> > +#if !(GCC_VERSION >= 40900 && GCC_VERSION < 50100)
> 
> This wants to be 5 now on the right side, afaict.
> 

Right. I missed this one place. I will fix it.

Thanks for your careful review.

Wei.

> Jan
> 

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


Re: [Xen-devel] [PATCH v4 1/2] gcov: add new interface and new formats support

2016-10-13 Thread Jan Beulich
>>> On 13.10.16 at 14:04,  wrote:
> A new sysctl interface for passing gcov data back to userspace. The new
> interface uses a customised record file format. The new sysctl reuses
> original sysctl number but renames the op to gcov_op.
> 
> Formats starting from gcc version 3.4 are supported. The code is
> rewritten so that a new format can be easily added in the future.
> Version specific code is grouped into different files. The format one
> needs to use can be picked via Kconfig. The default format is the newest
> one.
> 
> Userspace programs to handle extracted data will come in a later patch.
> 
> Signed-off-by: Wei Liu 

Acked-by: Jan Beulich 
with one suggestion and one further adjustment:

> --- /dev/null
> +++ b/xen/common/gcov/gcc_4_9.c
> @@ -0,0 +1,35 @@
> +/*
> + *  This code provides functions to handle gcc's profiling data format
> + *  introduced with gcc 4.7.
> + *
> + *  This file is based heavily on gcc_3_4.c file.

I think this is not really applicable here and in gcc_5.c.

> + *
> + *  For a better understanding, refer to gcc source:
> + *  gcc/gcov-io.h
> + *  libgcc/libgcov.c
> + *
> + *  Uses gcc-internal data definitions.
> + *
> + *  Imported from Linux and modified for Xen by
> + *Wei Liu 
> + */
> +
> +#include "gcov.h"
> +
> +#if !(GCC_VERSION >= 40900 && GCC_VERSION < 50100)

This wants to be 5 now on the right side, afaict.

Jan

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


[Xen-devel] [PATCH v4 1/2] gcov: add new interface and new formats support

2016-10-13 Thread Wei Liu
A new sysctl interface for passing gcov data back to userspace. The new
interface uses a customised record file format. The new sysctl reuses
original sysctl number but renames the op to gcov_op.

Formats starting from gcc version 3.4 are supported. The code is
rewritten so that a new format can be easily added in the future.
Version specific code is grouped into different files. The format one
needs to use can be picked via Kconfig. The default format is the newest
one.

Userspace programs to handle extracted data will come in a later patch.

Signed-off-by: Wei Liu 
---
v4:
1. gcov conflicts with livepatch in Kconfig.
2. Finer grain formats

v3:
1. Check gcc version in gcc_*.c files.
2. Eliminate u32 / u64.
3. Mark __gcov_init as __init.
4. Fix a rebase error in v2.
5. Some other cosmetic fixes.

v2:
1. Use tab in Kconfig and indent help text properly.
2. Bump XEN_SYSCTL_INTERFACE_VERSION.
3. Fix cosmetic issues.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
---
 xen/Kconfig.debug   |  39 -
 xen/common/gcov/Makefile|   5 +
 xen/common/gcov/gcc_3_4.c   | 367 
 xen/common/gcov/gcc_4_7.c   | 204 
 xen/common/gcov/gcc_4_9.c   |  35 +
 xen/common/gcov/gcc_5.c |  35 +
 xen/common/gcov/gcov.c  | 257 +++
 xen/common/gcov/gcov.h  |  40 +
 xen/common/gcov/gcov_base.c |  60 
 xen/common/sysctl.c |   8 +
 xen/include/public/sysctl.h |  39 -
 xen/include/xen/gcov.h  |   9 ++
 12 files changed, 1091 insertions(+), 7 deletions(-)
 create mode 100644 xen/common/gcov/gcc_3_4.c
 create mode 100644 xen/common/gcov/gcc_4_7.c
 create mode 100644 xen/common/gcov/gcc_4_9.c
 create mode 100644 xen/common/gcov/gcc_5.c
 create mode 100644 xen/common/gcov/gcov.c
 create mode 100644 xen/common/gcov/gcov.h
 create mode 100644 xen/common/gcov/gcov_base.c
 create mode 100644 xen/include/xen/gcov.h

diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug
index ef863dc..b19b357 100644
--- a/xen/Kconfig.debug
+++ b/xen/Kconfig.debug
@@ -30,16 +30,45 @@ config FRAME_POINTER
 
 config GCOV
bool "Gcov Support"
-   depends on BROKEN
+   depends on !LIVEPATCH
---help---
  Enable gcov (a test coverage program in GCC) support.
 
- Currently the data structure and hypercall interface are tied
- to GCC 3.4 gcov format. You need to have a version of GCC
- that is compatible with that format to make gcov work.
-
  If unsure, say N here.
 
+choice
+   prompt "Specify Gcov format"
+   depends on GCOV
+   default GCOV_FORMAT_5
+   ---help---
+ The gcov format is determined by gcc version.
+
+config GCOV_FORMAT_5
+   bool "GCC 5 format"
+   ---help---
+ Select this option to use the format specified in GCC 5.
+ Works in gcc version range [5, ...).
+
+config GCOV_FORMAT_4_9
+   bool "GCC 4.9 format"
+   ---help---
+ Select this option to use the format specified in GCC 4.9.
+ Works in gcc version range [4.9, 5).
+
+config GCOV_FORMAT_4_7
+   bool "GCC 4.7 format"
+   ---help---
+ Select this option to use the format specified in GCC 4.7.
+ Works in gcc version range [4.7, 4.9).
+
+config GCOV_FORMAT_3_4
+   bool "GCC 3.4 format"
+   ---help---
+ Select this option to use the format specified in GCC 3.4.
+ Works in gcc version range [3.4, 4.7).
+
+endchoice
+
 config LOCK_PROFILE
bool "Lock Profiling"
---help---
diff --git a/xen/common/gcov/Makefile b/xen/common/gcov/Makefile
index e69de29..6a304ab 100644
--- a/xen/common/gcov/Makefile
+++ b/xen/common/gcov/Makefile
@@ -0,0 +1,5 @@
+obj-y += gcov_base.o gcov.o
+obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o
+obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o
+obj-$(CONFIG_GCOV_FORMAT_4_9) += gcc_4_9.o
+obj-$(CONFIG_GCOV_FORMAT_5)   += gcc_5.o
diff --git a/xen/common/gcov/gcc_3_4.c b/xen/common/gcov/gcc_3_4.c
new file mode 100644
index 000..3631f4b
--- /dev/null
+++ b/xen/common/gcov/gcc_3_4.c
@@ -0,0 +1,367 @@
+/*
+ *  This code provides functions to handle gcc's profiling data format
+ *  introduced with gcc 3.4. Future versions of gcc may change the gcov
+ *  format (as happened before), so all format-specific information needs
+ *  to be kept modular and easily exchangeable.
+ *
+ *  This file is based on gcc-internal definitions. Functions and data
+ *  structures are defined to be compatible with gcc counterparts.
+ *  For a better understanding, refer to gcc source: gcc/gcov-io.h.
+ *
+ *Copyright IBM Corp. 2009
+ *Author(s): Peter