From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: Re: [PATCH v25 04/15] x86/VPMU: Interface for setting PMU mode and flags Date: Mon, 22 Jun 2015 16:10:12 +0100 Message-ID: <558841740200007800087A8F@mail.emea.novell.com> References: <1434739486-1611-1-git-send-email-boris.ostrovsky@oracle.com> <1434739486-1611-5-git-send-email-boris.ostrovsky@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1434739486-1611-5-git-send-email-boris.ostrovsky@oracle.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Boris Ostrovsky Cc: kevin.tian@intel.com, andrew.cooper3@citrix.com, dietmar.hahn@ts.fujitsu.com, xen-devel@lists.xen.org, Aravind.Gopalakrishnan@amd.com, suravee.suthikulpanit@amd.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org >>> On 19.06.15 at 20:44, wrote: > Add runtime interface for setting PMU mode and flags. Three main modes are > provided: > * XENPMU_MODE_OFF: PMU is not virtualized > * XENPMU_MODE_SELF: Guests can access PMU MSRs and receive PMU interrupts. > * XENPMU_MODE_HV: Same as XENPMU_MODE_SELF for non-proviledged guests, dom0 > can profile itself and the hypervisor. > > Note that PMU modes are different from what can be provided at Xen's boot > line > with 'vpmu' argument. An 'off' (or '0') value is equivalent to > XENPMU_MODE_OFF. > Any other value, on the other hand, will cause VPMU mode to be set to > XENPMU_MODE_SELF during boot. > > For feature flags only Intel's BTS is currently supported. > > Mode and flags are set via HYPERVISOR_xenpmu_op hypercall. > > Signed-off-by: Boris Ostrovsky > Acked-by: Daniel De Graaf Acked-by: Jan Beulich with one minor comment > + switch ( op ) > + { > + case XENPMU_mode_set: > + { > + if ( (pmu_params.val & ~(XENPMU_MODE_SELF | XENPMU_MODE_HV)) || > + (hweight64(pmu_params.val) > 1) ) > + return -EINVAL; > + > + /* 32-bit dom0 can only sample itself. */ > + if ( is_pv_32bit_vcpu(current) && (pmu_params.val & XENPMU_MODE_HV) ) > + return -EINVAL; > + > + spin_lock(&vpmu_lock); > + > + /* > + * We can always safely switch between XENPMU_MODE_SELF and > + * XENPMU_MODE_HV while other VPMUs are active. > + */ > + if ( (vpmu_count == 0) || (vpmu_mode == pmu_params.val) || > + ((vpmu_mode ^ pmu_params.val) == > + (XENPMU_MODE_SELF | XENPMU_MODE_HV)) ) > + vpmu_mode = pmu_params.val; > + else > + { I think this would better be if ( (vpmu_count == 0) || ((vpmu_mode ^ pmu_params.val) == (XENPMU_MODE_SELF | XENPMU_MODE_HV)) ) vpmu_mode = pmu_params.val; else if ( vpmu_mode != pmu_params.val ) { But there's no need to re-submit just because of this (it could be changed upon commit if you agree). Or wait - I just checked again, and while I thought this was long addressed I still don't seen struct xen_pmu_params "pad" field being checked to be zero as input, and being stored as zero when only an output. Did this get lost? Did I forget about a reason why this isn't being done? Unless the latter is the case, the ack above is dependent upon this getting fixed. Jan