From mboxrd@z Thu Jan 1 00:00:00 1970 From: Boris Ostrovsky Subject: Re: [PATCH v4 13/17] x86/VPMU: Add privileged PMU mode Date: Tue, 04 Feb 2014 11:13:40 -0500 Message-ID: <52F111B4.8030805@oracle.com> References: <1390331342-3967-1-git-send-email-boris.ostrovsky@oracle.com> <1390331342-3967-14-git-send-email-boris.ostrovsky@oracle.com> <52F0DDBE0200007800118F62@nat28.tlf.novell.com> <52F10D0D.2050908@oracle.com> <52F11CDF02000078001191EB@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <52F11CDF02000078001191EB@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: keir@xen.org, jun.nakajima@intel.com, andrew.cooper3@citrix.com, eddie.dong@intel.com, dietmar.hahn@ts.fujitsu.com, xen-devel@lists.xen.org, suravee.suthikulpanit@amd.com List-Id: xen-devel@lists.xenproject.org On 02/04/2014 11:01 AM, Jan Beulich wrote: >>>> On 04.02.14 at 16:53, Boris Ostrovsky wrote: >> On 02/04/2014 06:31 AM, Jan Beulich wrote: >>>>>> On 21.01.14 at 20:08, Boris Ostrovsky wrote: >>>> + gregs = &v->arch.vpmu.xenpmu_data->pmu.r.regs; >>>> + gregs->cs = cs; >>> And now you store a NUL selector (i.e. just the RPL bits) into the >>> output field? >>>> } >>>> - else if ( !is_control_domain(current->domain) && >>>> - !is_idle_vcpu(current) ) >>>> + else >>>> { >>>> - /* PV guest */ >>>> + /* HVM guest */ >>>> + struct segment_register cs; >>>> + >>>> gregs = guest_cpu_user_regs(); >>>> memcpy(&v->arch.vpmu.xenpmu_data->pmu.r.regs, >>>> gregs, sizeof(struct cpu_user_regs)); >>>> + >>>> + hvm_get_segment_register(current, x86_seg_cs, &cs); >>>> + gregs = &v->arch.vpmu.xenpmu_data->pmu.r.regs; >>>> + gregs->cs = cs.attr.fields.dpl; >>> And here too? If that's intended, a code comment is a must. >> This is HVM-only path, PVH or PV don't go here so cs should be valid. > Isn't the reply of mine a few lines up in PV code? And why would > the selector being wrong for HVM be okay? This clause is for privileged profiling: we are in PV clause even though the interrupt is taken by an HVM guest. The diff is somewhat difficult to follow so here is the flow: // in privileged mode 'v' is dom0's CPU. if ( !is_hvm_domain(v->domain) || (vpmu_mode & XENPMU_MODE_PRIV) ) { if ( !is_hvm_domain(current->domain) ) { // either PV (including dom0) or Xen is interrupted } else { // This is the clause we are discussing. 'current' is HVM hvm_get_segment_register(current, x86_seg_cs, &cs); } send_guest_vcpu_virq(v, VIRQ_XENPMU); return 1; } So I think CS should be correct for the guest, no? -boris