From: "Jan Beulich" Subject: Re: [PATCH v6 15/19] x86/VPMU: Add privileged PMU mode Date: Tue, 27 May 2014 10:10:39 +0100 Message-ID: <538472AF0200007800015EA9@mail.emea.novell.com> References: <1399996413-1998-1-git-send-email-boris.ostrovsky@oracle.com> <1399996413-1998-16-git-send-email-boris.ostrovsky@oracle.com> <538346350200007800015C3B@mail.emea.novell.com> <5383F380.6070002@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5383F380.6070002@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, keir@xen.org, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, donald.d.dugger@intel.com, xen-devel@lists.xen.org, dietmar.hahn@ts.fujitsu.com, jun.nakajima@intel.com List-Id: xen-devel@lists.xenproject.org >>> On 27.05.14 at 04:08, wrote: > On 05/26/2014 07:48 AM, Jan Beulich wrote: >> >>> + gregs = guest_cpu_user_regs(); >>> + memcpy(&v->arch.vpmu.xenpmu_data->pmu.r.regs, >>> + gregs, sizeof(struct cpu_user_regs)); >>> + } >>> + else >>> + memcpy(&v->arch.vpmu.xenpmu_data->pmu.r.regs, >>> + regs, sizeof(struct cpu_user_regs)); >>> >>> - cmp = (void *)&v->arch.vpmu.xenpmu_data->pmu.r.regs; >>> - XLAT_cpu_user_regs(cmp, gregs); >>> - memcpy(&v->arch.vpmu.xenpmu_data->pmu.r.regs, >>> - &cmp, sizeof(struct compat_cpu_user_regs)); >>> + gregs = &v->arch.vpmu.xenpmu_data->pmu.r.regs; >>> + gregs->cs = (current->arch.flags & TF_kernel_mode) ? 0 : 0x3; >> Ah, no - you want to modify the structure here. But you could do this >> directly on the ->pmu.r.regs field rather than first latching the pointer. >> >> And as said before, it doesn't really look correct to simply set ->cs to >> just the RPL, especially without any comment explaining why this is >> (a) being done and (b) correct. > > The reason for only passing up the RPL is that's the only field that the > guest is interested in (whether the interrupt happened in kernel or user > space). I added a comment in the code to this effect. > > Do you think that all fields need to be passed? How do you know what a guest is interested in? Namely 32-bit OSes may have uses for more than a single flat code segment, and hence may have an interest in knowing the full selector. Jan