From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Natarajan, Janakarajan" Subject: Re: [PATCH v2 3/4] Add support for AMD Core Perf Extension in guest Date: Thu, 16 Nov 2017 12:00:11 -0600 Message-ID: <2c785f9f-faac-58d5-2efd-3fce80d24c18@amd.com> References: <5113a9d6e76d2c6050c1fba4007068340321521c.1509985085.git.Janakarajan.Natarajan@amd.com> <20171109183425.rhqc5wrltznt5tcf@pd.tnic> <07f23e5e-2747-b0bc-1b93-f83f3982649a@amd.com> <20171115190755.5n2zskcr2d4bmewp@pd.tnic> <20171116172520.4lgdvpcdxuxenxc7@pd.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Paolo Bonzini , Radim Krcmar , Len Brown , Kyle Huey , Kan Liang , Grzegorz Andrejczuk , Tom Lendacky , Tony Luck To: Borislav Petkov Return-path: Received: from mail-dm3nam03on0046.outbound.protection.outlook.com ([104.47.41.46]:10443 "EHLO NAM03-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S966208AbdKPSAh (ORCPT ); Thu, 16 Nov 2017 13:00:37 -0500 In-Reply-To: <20171116172520.4lgdvpcdxuxenxc7@pd.tnic> Content-Language: en-US Sender: kvm-owner@vger.kernel.org List-ID: On 11/16/2017 11:25 AM, Borislav Petkov wrote: > On Thu, Nov 16, 2017 at 11:13:47AM -0600, Natarajan, Janakarajan wrote: >> On 11/15/2017 1:07 PM, Borislav Petkov wrote: >>> On Wed, Nov 15, 2017 at 01:04:03PM -0600, Natarajan, Janakarajan wrote: >>>> So, when the amd_pmu_init is called, a query to guest_cpuid_family() gives a >>>> value of -1. >>> And that is because...? And it can be fixed to give the proper guest family I >>> presume ...? >> Qemu initially creates a vcpu with KVM_CREATE_VCPU which in kvm initializes >> the pmu. Later on >> the cpuid is set using KVM_SET_CPUID2 which sets all the cpuid entries in >> kvm and the pmu refresh is called. > That doesn't answer my questions above. Ah my apologies. So when the pmu is initialized the cpuid entries aren't available then. We'll have to wait until the pmu refresh is called to get the family value. So there is no place to fix it. The setting of the nr_counters based on the family will have to be done in the amd_pmu_refresh() and not in the amd_pmu_init(). >