From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752931AbdLER43 (ORCPT ); Tue, 5 Dec 2017 12:56:29 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47334 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752151AbdLER4Z (ORCPT ); Tue, 5 Dec 2017 12:56:25 -0500 Date: Tue, 5 Dec 2017 18:56:05 +0100 From: Radim Krcmar To: "Natarajan, Janakarajan" Cc: Borislav Petkov , Paolo Bonzini , kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , "H . Peter Anvin" , Len Brown , Kyle Huey , Kan Liang , Grzegorz Andrejczuk , Tom Lendacky , Tony Luck Subject: Re: [PATCH v2 3/4] Add support for AMD Core Perf Extension in guest Message-ID: <20171205175604.GA20099@flask> 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> <2c785f9f-faac-58d5-2efd-3fce80d24c18@amd.com> <20171117114445.iv2s7sm2mjqusztx@pd.tnic> <8ff957e3-67b7-3986-05ef-3e42bd7143f6@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8ff957e3-67b7-3986-05ef-3e42bd7143f6@amd.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 05 Dec 2017 17:56:25 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2017-12-01 13:30-0600, Natarajan, Janakarajan: > On 11/17/2017 5:44 AM, Borislav Petkov wrote: > > On Thu, Nov 16, 2017 at 12:00:11PM -0600, Natarajan, Janakarajan wrote: > > > Ah my apologies. So when the pmu is initialized the cpuid entries > > > aren't available then. > > So let's see: > > > > ... kvm_arch_vcpu_create() -> > > svm_create_vcpu() -> > > kvm_vcpu_init() -> > > kvm_arch_vcpu_init() -> > > > > <--- HERE > > > > kvm_pmu_init() > > > > But at HERE in kvm_arch_vcpu_init() right before kvm_pmu_init() we do already query > > cpuid: > > > > vcpu->arch.maxphyaddr = cpuid_query_maxphyaddr(vcpu); > > > > so it's not like we don't know about cpuid leafs at that point. Which > > would mean that the code can be made to set the CPU family earlier, > > before kvm_pmu_init() runs so that you have the proper CPU family and > > thus have this thing properly designed. > > > > Maybe Paolo and Radim have a better suggestion here... > > Paolo, Radim any suggestions about this. I feel that the number of counters > initialized can be 6 This is the best solution with the current framework. > and the subsequent code (kvm_pmu_refresh()) takes care of the number of > counters to be used (4 or 6) > based on the vcpu family. Can't we look only at X86_FEATURE_PERFCTR_CORE and completely ignore the AMD family? Using the family would bring problems with compatiblity. Thanks.