Re: [PATCH v3 3/3] xen: Expose the PMU to the guests
On Fri, 8 Oct 2021, Michal Orzel wrote: > Add parameter vpmu to xl domain configuration syntax > to enable the access to PMU registers by disabling > the PMU traps(currently only for ARM). > > The current status is that the PMU registers are not > virtualized and the physical registers are directly > accessible when this parameter is enabled. There is no > interrupt support and Xen will not save/restore the > register values on context switches. > > Please note that this feature is experimental. > > Signed-off-by: Michal Orzel > Signed-off-by: Julien Grall The patch needs rebasing > --- > Changes since v2: > -remove redundant check from x86 code > -do not define bit position and mask separately > Changes since v1: > -modify vpmu parameter to be common rather than arch specific > --- > docs/man/xl.cfg.5.pod.in | 17 + > tools/golang/xenlight/helpers.gen.go | 6 ++ > tools/golang/xenlight/types.gen.go | 1 + > tools/include/libxl.h| 6 ++ > tools/libs/light/libxl_create.c | 4 > tools/libs/light/libxl_types.idl | 2 ++ > tools/ocaml/libs/xc/xenctrl.ml | 1 + > tools/ocaml/libs/xc/xenctrl.mli | 1 + > tools/xl/xl_parse.c | 2 ++ > xen/arch/arm/domain.c| 10 -- > xen/arch/arm/setup.c | 1 + > xen/common/domain.c | 9 - > xen/include/asm-arm/domain.h | 1 + > xen/include/public/domctl.h | 4 +++- > 14 files changed, 61 insertions(+), 4 deletions(-) > > diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in > index 4b1e3028d2..55c4881205 100644 > --- a/docs/man/xl.cfg.5.pod.in > +++ b/docs/man/xl.cfg.5.pod.in > @@ -690,6 +690,23 @@ default. > B: Acceptable values are platform specific. For Intel Processor > Trace, this value must be a power of 2 between 4k and 16M. > > +=item B > + > +Currently ARM only. > + > +Specifies whether to enable the access to PMU registers by disabling > +the PMU traps. > + > +The PMU registers are not virtualized and the physical registers are directly > +accessible when this parameter is enabled. There is no interrupt support and > +Xen will not save/restore the register values on context switches. > + > +vPMU, by design and purpose, exposes system level performance > +information to the guest. Only to be used by sufficiently privileged > +domains. This feature is currently in experimental state. > + > +If this option is not specified then it will default to B. > + > =back > > =head2 Devices > diff --git a/tools/golang/xenlight/helpers.gen.go > b/tools/golang/xenlight/helpers.gen.go > index c8669837d8..2449580bad 100644 > --- a/tools/golang/xenlight/helpers.gen.go > +++ b/tools/golang/xenlight/helpers.gen.go > @@ -1119,6 +1119,9 @@ return fmt.Errorf("converting field ArchX86.MsrRelaxed: > %v", err) > } > x.Altp2M = Altp2MMode(xc.altp2m) > x.VmtraceBufKb = int(xc.vmtrace_buf_kb) > +if err := x.Vpmu.fromC();err != nil { > +return fmt.Errorf("converting field Vpmu: %v", err) > +} > > return nil} > > @@ -1600,6 +1603,9 @@ return fmt.Errorf("converting field ArchX86.MsrRelaxed: > %v", err) > } > xc.altp2m = C.libxl_altp2m_mode(x.Altp2M) > xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb) > +if err := x.Vpmu.toC(); err != nil { > +return fmt.Errorf("converting field Vpmu: %v", err) > +} > > return nil > } > diff --git a/tools/golang/xenlight/types.gen.go > b/tools/golang/xenlight/types.gen.go > index 45f2cba3d2..b2e8bd1a85 100644 > --- a/tools/golang/xenlight/types.gen.go > +++ b/tools/golang/xenlight/types.gen.go > @@ -521,6 +521,7 @@ MsrRelaxed Defbool > } > Altp2M Altp2MMode > VmtraceBufKb int > +Vpmu Defbool > } > > type DomainBuildInfoTypeUnion interface { > diff --git a/tools/include/libxl.h b/tools/include/libxl.h > index ec5e3badae..ee73eb06f1 100644 > --- a/tools/include/libxl.h > +++ b/tools/include/libxl.h > @@ -508,6 +508,12 @@ > */ > #define LIBXL_HAVE_PHYSINFO_CAP_VPMU 1 > > +/* > + * LIBXL_HAVE_VPMU indicates that libxl_domain_build_info has a vpmu > parameter, > + * which allows to enable the access to PMU registers. > + */ > +#define LIBXL_HAVE_VPMU 1 > + > /* > * libxl ABI compatibility > * > diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c > index e356b2106d..d123c2f703 100644 > --- a/tools/libs/light/libxl_create.c > +++ b/tools/libs/light/libxl_create.c > @@ -91,6 +91,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, > } > > libxl_defbool_setdefault(_info->device_model_stubdomain, false); > +libxl_defbool_setdefault(_info->vpmu, false); > > if (libxl_defbool_val(b_info->device_model_stubdomain) && > !b_info->device_model_ssidref) > @@ -622,6 +623,9 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config > *d_config, > create.flags |= XEN_DOMCTL_CDF_nested_virt; > } > > +if ( libxl_defbool_val(b_info->vpmu) ) >
Re: [PATCH v3 3/3] xen: Expose the PMU to the guests
On Fri, Oct 08, 2021 at 10:19:33AM +0200, Michal Orzel wrote: > Add parameter vpmu to xl domain configuration syntax > to enable the access to PMU registers by disabling > the PMU traps(currently only for ARM). > > The current status is that the PMU registers are not > virtualized and the physical registers are directly > accessible when this parameter is enabled. There is no > interrupt support and Xen will not save/restore the > register values on context switches. > > Please note that this feature is experimental. > > Signed-off-by: Michal Orzel > Signed-off-by: Julien Grall > --- > Changes since v2: > -remove redundant check from x86 code > -do not define bit position and mask separately > Changes since v1: > -modify vpmu parameter to be common rather than arch specific > --- > docs/man/xl.cfg.5.pod.in | 17 + > tools/golang/xenlight/helpers.gen.go | 6 ++ > tools/golang/xenlight/types.gen.go | 1 + > tools/include/libxl.h| 6 ++ > tools/libs/light/libxl_create.c | 4 > tools/libs/light/libxl_types.idl | 2 ++ > tools/ocaml/libs/xc/xenctrl.ml | 1 + > tools/ocaml/libs/xc/xenctrl.mli | 1 + > tools/xl/xl_parse.c | 2 ++ > xen/arch/arm/domain.c| 10 -- > xen/arch/arm/setup.c | 1 + > xen/common/domain.c | 9 - > xen/include/asm-arm/domain.h | 1 + > xen/include/public/domctl.h | 4 +++- > 14 files changed, 61 insertions(+), 4 deletions(-) > > diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in > index 4b1e3028d2..55c4881205 100644 > --- a/docs/man/xl.cfg.5.pod.in > +++ b/docs/man/xl.cfg.5.pod.in > @@ -690,6 +690,23 @@ default. > B: Acceptable values are platform specific. For Intel Processor > Trace, this value must be a power of 2 between 4k and 16M. > > +=item B > + > +Currently ARM only. > + > +Specifies whether to enable the access to PMU registers by disabling > +the PMU traps. > + > +The PMU registers are not virtualized and the physical registers are directly > +accessible when this parameter is enabled. There is no interrupt support and > +Xen will not save/restore the register values on context switches. > + > +vPMU, by design and purpose, exposes system level performance > +information to the guest. Only to be used by sufficiently privileged > +domains. This feature is currently in experimental state. > + > +If this option is not specified then it will default to B. > + > =back > > =head2 Devices > diff --git a/tools/golang/xenlight/helpers.gen.go > b/tools/golang/xenlight/helpers.gen.go > index c8669837d8..2449580bad 100644 > --- a/tools/golang/xenlight/helpers.gen.go > +++ b/tools/golang/xenlight/helpers.gen.go > @@ -1119,6 +1119,9 @@ return fmt.Errorf("converting field ArchX86.MsrRelaxed: > %v", err) > } > x.Altp2M = Altp2MMode(xc.altp2m) > x.VmtraceBufKb = int(xc.vmtrace_buf_kb) > +if err := x.Vpmu.fromC();err != nil { > +return fmt.Errorf("converting field Vpmu: %v", err) > +} > > return nil} > > @@ -1600,6 +1603,9 @@ return fmt.Errorf("converting field ArchX86.MsrRelaxed: > %v", err) > } > xc.altp2m = C.libxl_altp2m_mode(x.Altp2M) > xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb) > +if err := x.Vpmu.toC(); err != nil { > +return fmt.Errorf("converting field Vpmu: %v", err) > +} > > return nil > } > diff --git a/tools/golang/xenlight/types.gen.go > b/tools/golang/xenlight/types.gen.go > index 45f2cba3d2..b2e8bd1a85 100644 > --- a/tools/golang/xenlight/types.gen.go > +++ b/tools/golang/xenlight/types.gen.go > @@ -521,6 +521,7 @@ MsrRelaxed Defbool > } > Altp2M Altp2MMode > VmtraceBufKb int > +Vpmu Defbool > } > > type DomainBuildInfoTypeUnion interface { For the golang re-gen, Acked-by: Nick Rosbrook Thanks, NR
Re: [PATCH v3 3/3] xen: Expose the PMU to the guests
Hi Michal, > On 8 Oct 2021, at 09:19, Michal Orzel wrote: > > Add parameter vpmu to xl domain configuration syntax > to enable the access to PMU registers by disabling > the PMU traps(currently only for ARM). > > The current status is that the PMU registers are not > virtualized and the physical registers are directly > accessible when this parameter is enabled. There is no > interrupt support and Xen will not save/restore the > register values on context switches. > > Please note that this feature is experimental. > > Signed-off-by: Michal Orzel > Signed-off-by: Julien Grall Reviewed-by: Bertrand Marquis Cheers Bertrand > --- > Changes since v2: > -remove redundant check from x86 code > -do not define bit position and mask separately > Changes since v1: > -modify vpmu parameter to be common rather than arch specific > --- > docs/man/xl.cfg.5.pod.in | 17 + > tools/golang/xenlight/helpers.gen.go | 6 ++ > tools/golang/xenlight/types.gen.go | 1 + > tools/include/libxl.h| 6 ++ > tools/libs/light/libxl_create.c | 4 > tools/libs/light/libxl_types.idl | 2 ++ > tools/ocaml/libs/xc/xenctrl.ml | 1 + > tools/ocaml/libs/xc/xenctrl.mli | 1 + > tools/xl/xl_parse.c | 2 ++ > xen/arch/arm/domain.c| 10 -- > xen/arch/arm/setup.c | 1 + > xen/common/domain.c | 9 - > xen/include/asm-arm/domain.h | 1 + > xen/include/public/domctl.h | 4 +++- > 14 files changed, 61 insertions(+), 4 deletions(-) > > diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in > index 4b1e3028d2..55c4881205 100644 > --- a/docs/man/xl.cfg.5.pod.in > +++ b/docs/man/xl.cfg.5.pod.in > @@ -690,6 +690,23 @@ default. > B: Acceptable values are platform specific. For Intel Processor > Trace, this value must be a power of 2 between 4k and 16M. > > +=item B > + > +Currently ARM only. > + > +Specifies whether to enable the access to PMU registers by disabling > +the PMU traps. > + > +The PMU registers are not virtualized and the physical registers are directly > +accessible when this parameter is enabled. There is no interrupt support and > +Xen will not save/restore the register values on context switches. > + > +vPMU, by design and purpose, exposes system level performance > +information to the guest. Only to be used by sufficiently privileged > +domains. This feature is currently in experimental state. > + > +If this option is not specified then it will default to B. > + > =back > > =head2 Devices > diff --git a/tools/golang/xenlight/helpers.gen.go > b/tools/golang/xenlight/helpers.gen.go > index c8669837d8..2449580bad 100644 > --- a/tools/golang/xenlight/helpers.gen.go > +++ b/tools/golang/xenlight/helpers.gen.go > @@ -1119,6 +1119,9 @@ return fmt.Errorf("converting field ArchX86.MsrRelaxed: > %v", err) > } > x.Altp2M = Altp2MMode(xc.altp2m) > x.VmtraceBufKb = int(xc.vmtrace_buf_kb) > +if err := x.Vpmu.fromC();err != nil { > +return fmt.Errorf("converting field Vpmu: %v", err) > +} > > return nil} > > @@ -1600,6 +1603,9 @@ return fmt.Errorf("converting field ArchX86.MsrRelaxed: > %v", err) > } > xc.altp2m = C.libxl_altp2m_mode(x.Altp2M) > xc.vmtrace_buf_kb = C.int(x.VmtraceBufKb) > +if err := x.Vpmu.toC(); err != nil { > +return fmt.Errorf("converting field Vpmu: %v", err) > +} > > return nil > } > diff --git a/tools/golang/xenlight/types.gen.go > b/tools/golang/xenlight/types.gen.go > index 45f2cba3d2..b2e8bd1a85 100644 > --- a/tools/golang/xenlight/types.gen.go > +++ b/tools/golang/xenlight/types.gen.go > @@ -521,6 +521,7 @@ MsrRelaxed Defbool > } > Altp2M Altp2MMode > VmtraceBufKb int > +Vpmu Defbool > } > > type DomainBuildInfoTypeUnion interface { > diff --git a/tools/include/libxl.h b/tools/include/libxl.h > index ec5e3badae..ee73eb06f1 100644 > --- a/tools/include/libxl.h > +++ b/tools/include/libxl.h > @@ -508,6 +508,12 @@ > */ > #define LIBXL_HAVE_PHYSINFO_CAP_VPMU 1 > > +/* > + * LIBXL_HAVE_VPMU indicates that libxl_domain_build_info has a vpmu > parameter, > + * which allows to enable the access to PMU registers. > + */ > +#define LIBXL_HAVE_VPMU 1 > + > /* > * libxl ABI compatibility > * > diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c > index e356b2106d..d123c2f703 100644 > --- a/tools/libs/light/libxl_create.c > +++ b/tools/libs/light/libxl_create.c > @@ -91,6 +91,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc, > } > > libxl_defbool_setdefault(_info->device_model_stubdomain, false); > +libxl_defbool_setdefault(_info->vpmu, false); > > if (libxl_defbool_val(b_info->device_model_stubdomain) && > !b_info->device_model_ssidref) > @@ -622,6 +623,9 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config > *d_config, > create.flags |= XEN_DOMCTL_CDF_nested_virt; > } > > +if ( libxl_defbool_val(b_info->vpmu) ) > +