From: Jan Beulich Date: Mon, 4 May 2020 09:48:13 +0000 (+0200) Subject: xenoprof: adjust ordering of page sharing vs domain type setting X-Git-Tag: archive/raspbian/4.14.0+80-gd101b417b7-1+rpi1^2~63^2~317 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=7f6a6e8c0a400d1a073b083fe0b7d25ef74b14e0;p=xen.git xenoprof: adjust ordering of page sharing vs domain type setting Buffer pages should be shared with "ignored" or "active" guests only (besides, obviously, the primary profiling domain). Hence domain type should be set to "ignored" before unsharing from the primary domain (which implies even a previously "passive" domain may then access its buffers, albeit that's not very useful unless it gets promoted to "active" subsequently), i.e. such that no further writes of records to the buffer would occur, and (at least for consistency) also before sharing it (with the calling domain) from the XENOPROF_get_buffer path. Signed-off-by: Jan Beulich Reviewed-by: Wei Liu --- diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index b04726cb49..3dad5dfb38 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -372,8 +372,8 @@ static void reset_passive(struct domain *d) if ( x == NULL ) return; - unshare_xenoprof_page_with_guest(x); x->domain_type = XENOPROF_DOMAIN_IGNORED; + unshare_xenoprof_page_with_guest(x); } static void reset_active_list(void) @@ -654,6 +654,13 @@ static int xenoprof_op_get_buffer(XEN_GUEST_HANDLE_PARAM(void) arg) if ( ret < 0 ) return ret; } + else + { + d->xenoprof->domain_ready = 0; + d->xenoprof->domain_type = XENOPROF_DOMAIN_IGNORED; + } + + d->xenoprof->is_primary = (xenoprof_primary_profiler == d); ret = share_xenoprof_page_with_guest( d, virt_to_mfn(d->xenoprof->rawbuf), d->xenoprof->npages); @@ -662,10 +669,6 @@ static int xenoprof_op_get_buffer(XEN_GUEST_HANDLE_PARAM(void) arg) xenoprof_reset_buf(d); - d->xenoprof->domain_type = XENOPROF_DOMAIN_IGNORED; - d->xenoprof->domain_ready = 0; - d->xenoprof->is_primary = (xenoprof_primary_profiler == current->domain); - xenoprof_get_buffer.nbuf = d->xenoprof->nbuf; xenoprof_get_buffer.bufsize = d->xenoprof->bufsize; if ( !paging_mode_translate(d) )