From: "Jan Beulich" Subject: Re: [PATCH v13 for-xen-4.5 17/21] x86/VPMU: Handle PMU interrupts for PV guests Date: Tue, 14 Oct 2014 11:10:31 +0100 Message-ID: <543D12B7020000780003EA68@mail.emea.novell.com> References: <1412372423-1182-1-git-send-email-boris.ostrovsky@oracle.com> <1412372423-1182-18-git-send-email-boris.ostrovsky@oracle.com> <543C0C07020000780003E61D@mail.emea.novell.com> <543C23AE.6000305@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <543C23AE.6000305@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, 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 13.10.14 at 21:10, wrote: > On 10/13/2014 11:29 AM, Jan Beulich wrote: >>>>> On 03.10.14 at 23:40, wrote: >>> int vpmu_do_wrmsr(unsigned int msr, uint64_t msr_content, uint64_t > supported) >>> { >>> - struct vpmu_struct *vpmu = vcpu_vpmu(current); >>> + struct vcpu *curr = current; >>> + struct vpmu_struct *vpmu = vcpu_vpmu(curr); >>> >>> if ( !(vpmu_mode & (XENPMU_MODE_SELF | XENPMU_MODE_HV)) ) >>> return 0; >>> >>> if ( vpmu->arch_vpmu_ops && vpmu->arch_vpmu_ops->do_wrmsr ) >>> - return vpmu->arch_vpmu_ops->do_wrmsr(msr, msr_content, supported); >>> + { >>> + int ret = vpmu->arch_vpmu_ops->do_wrmsr(msr, msr_content, supported); >>> + >>> + /* >>> + * We may have received a PMU interrupt during WRMSR handling >>> + * and since do_wrmsr may load VPMU context we should save >>> + * (and unload) it again. >>> + */ >> Is this btw true also when do_wrmsr() failed? Or could you not rather >> handle ret != 0 before the following if() (or check ret == 0 together >> with the other conditions)? > > There is indeed no need to save/unload if do_wrmsr() failed but one of > conditions in the if() that you refer to (PMU_CACHED bit test) can only > happen if do_wrmsr() succeeded because the context could not have been > loaded in case of failure. Ah, okay, that's fine then. I hope I'll remember when looking over v14+. Jan