From: "Jan Beulich" Subject: Re: [PATCH v16 19/23] x86/VPMU: Handle PMU interrupts for PV guests Date: Thu, 18 Dec 2014 14:57:44 +0000 Message-ID: <5492F9780200007800050B69@mail.emea.novell.com> References: <1418830734-1558-1-git-send-email-boris.ostrovsky@oracle.com> <1418830734-1558-20-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: <1418830734-1558-20-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, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, tim@xen.org, dietmar.hahn@ts.fujitsu.com, xen-devel@lists.xen.org, Aravind.Gopalakrishnan@amd.com, jun.nakajima@intel.com, dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org >>> On 17.12.14 at 16:38, wrote: > Add support for handling PMU interrupts for PV guests. > > VPMU for the interrupted VCPU is unloaded until the guest issues > XENPMU_flush > hypercall. This allows the guest to access PMU MSR values that are stored in > VPMU context which is shared between hypervisor and domain, thus avoiding > traps to hypervisor. > > Since the interrupt handler may now force VPMU context save (i.e. set > VPMU_CONTEXT_SAVE flag) we need to make changes to amd_vpmu_save() which > until now expected this flag to be set only when the counters were stopped. > > Signed-off-by: Boris Ostrovsky > Acked-by: Daniel De Graaf > Reviewed-by: Dietmar Hahn > Tested-by: Dietmar Hahn Acked-by: Jan Beulich with one minor comment: > + /* Store appropriate registers in xenpmu_data */ > + /* FIXME: 32-bit PVH should go here as well */ > + if ( is_pv_32bit_vcpu(sampling) ) > + { > + /* > + * 32-bit dom0 cannot process Xen's addresses (which are 64 bit) > + * and therefore we treat it the same way as a non-privileged > + * PV 32-bit domain. > + */ > + struct compat_pmu_regs *cmp; > + > + cur_regs = guest_cpu_user_regs(); > + > + cmp = (void *)&vpmu->xenpmu_data->pmu.r.regs; > + cmp->ip = cur_regs->rip; > + cmp->sp = cur_regs->rsp; > + cmp->flags = cur_regs->eflags; > + cmp->ss = cur_regs->ss; > + cmp->cs = cur_regs->cs; > + if ( (cmp->cs & 3) != 1 ) > + *flags |= PMU_SAMPLE_USER; Perhaps better > 1, to be on the safe side? Jan