Message ID | 5d52b37e391a4165dc3775f77a621d34a33d22c2.1593974333.git.michal.leszczynski@cert.pl (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Implement support for external IPT monitoring | expand |
----- 5 lip 2020 o 20:54, Michał Leszczyński michal.leszczynski@cert.pl napisał(a): > From: Michal Leszczynski <michal.leszczynski@cert.pl> > > Add vmtrace_pt_size domain parameter in live domain and > vmtrace_pt_order parameter in xen_domctl_createdomain. > > Signed-off-by: Michal Leszczynski <michal.leszczynski@cert.pl> > --- > xen/common/domain.c | 12 ++++++++++++ > xen/include/public/domctl.h | 1 + > xen/include/xen/sched.h | 4 ++++ > 3 files changed, 17 insertions(+) > > diff --git a/xen/common/domain.c b/xen/common/domain.c > index a45cf023f7..25d3359c5b 100644 > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -338,6 +338,12 @@ static int sanitise_domain_config(struct > xen_domctl_createdomain *config) > return -EINVAL; > } > > + if ( config->vmtrace_pt_order && !vmtrace_supported ) > + { > + dprintk(XENLOG_INFO, "Processor tracing is not supported\n"); > + return -EINVAL; > + } > + > return arch_sanitise_domain_config(config); > } > > @@ -443,6 +449,12 @@ struct domain *domain_create(domid_t domid, > d->nr_pirqs = min(d->nr_pirqs, nr_irqs); > > radix_tree_init(&d->pirq_tree); > + > + if ( config->vmtrace_pt_order ) > + { > + uint32_t shift_val = config->vmtrace_pt_order + PAGE_SHIFT; > + d->vmtrace_pt_size = (1ULL << shift_val); > + } > } > > if ( (err = arch_domain_create(d, config)) != 0 ) > diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h > index 59bdc28c89..7b8289d436 100644 > --- a/xen/include/public/domctl.h > +++ b/xen/include/public/domctl.h > @@ -92,6 +92,7 @@ struct xen_domctl_createdomain { > uint32_t max_evtchn_port; > int32_t max_grant_frames; > int32_t max_maptrack_frames; > + uint8_t vmtrace_pt_order; > > struct xen_arch_domainconfig arch; > }; > diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h > index ac53519d7f..48f0a61bbd 100644 > --- a/xen/include/xen/sched.h > +++ b/xen/include/xen/sched.h > @@ -457,6 +457,10 @@ struct domain > unsigned pbuf_idx; > spinlock_t pbuf_lock; > > + /* Used by vmtrace features */ > + spinlock_t vmtrace_lock; > + uint64_t vmtrace_pt_size; > + > /* OProfile support. */ > struct xenoprof *xenoprof; > > -- > 2.17.1 Just a note to myself: in v4 it was suggested by Jan that we should go with "number of kB" instead of "number of bytes" and the type could be uint32_t. I will modify it in such way within the next version. Best regards, Michał Leszczyński CERT Polska
Hi, On 05/07/2020 19:54, Michał Leszczyński wrote: > From: Michal Leszczynski <michal.leszczynski@cert.pl> > > Add vmtrace_pt_size domain parameter in live domain and > vmtrace_pt_order parameter in xen_domctl_createdomain. > > Signed-off-by: Michal Leszczynski <michal.leszczynski@cert.pl> > --- > xen/common/domain.c | 12 ++++++++++++ > xen/include/public/domctl.h | 1 + > xen/include/xen/sched.h | 4 ++++ > 3 files changed, 17 insertions(+) > > diff --git a/xen/common/domain.c b/xen/common/domain.c > index a45cf023f7..25d3359c5b 100644 > --- a/xen/common/domain.c > +++ b/xen/common/domain.c > @@ -338,6 +338,12 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) > return -EINVAL; > } > > + if ( config->vmtrace_pt_order && !vmtrace_supported ) Looking at the rest of the series, vmtrace will only be supported for x86 HVM guest. So don't you want to return -EINVAL for PV guests here? This could be done in a new helper arch_vmtrace_supported() or possibly in the existing arch_sanitise_domain_config(). Cheers,
diff --git a/xen/common/domain.c b/xen/common/domain.c index a45cf023f7..25d3359c5b 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -338,6 +338,12 @@ static int sanitise_domain_config(struct xen_domctl_createdomain *config) return -EINVAL; } + if ( config->vmtrace_pt_order && !vmtrace_supported ) + { + dprintk(XENLOG_INFO, "Processor tracing is not supported\n"); + return -EINVAL; + } + return arch_sanitise_domain_config(config); } @@ -443,6 +449,12 @@ struct domain *domain_create(domid_t domid, d->nr_pirqs = min(d->nr_pirqs, nr_irqs); radix_tree_init(&d->pirq_tree); + + if ( config->vmtrace_pt_order ) + { + uint32_t shift_val = config->vmtrace_pt_order + PAGE_SHIFT; + d->vmtrace_pt_size = (1ULL << shift_val); + } } if ( (err = arch_domain_create(d, config)) != 0 ) diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h index 59bdc28c89..7b8289d436 100644 --- a/xen/include/public/domctl.h +++ b/xen/include/public/domctl.h @@ -92,6 +92,7 @@ struct xen_domctl_createdomain { uint32_t max_evtchn_port; int32_t max_grant_frames; int32_t max_maptrack_frames; + uint8_t vmtrace_pt_order; struct xen_arch_domainconfig arch; }; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index ac53519d7f..48f0a61bbd 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -457,6 +457,10 @@ struct domain unsigned pbuf_idx; spinlock_t pbuf_lock; + /* Used by vmtrace features */ + spinlock_t vmtrace_lock; + uint64_t vmtrace_pt_size; + /* OProfile support. */ struct xenoprof *xenoprof;