Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752641AbdLDBV0 (ORCPT ); Sun, 3 Dec 2017 20:21:26 -0500 Received: from mga04.intel.com ([192.55.52.120]:6202 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751322AbdLDBVY (ORCPT ); Sun, 3 Dec 2017 20:21:24 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,356,1508828400"; d="scan'208";a="155707197" From: "Kang, Luwei" To: Paolo Bonzini , "kvm@vger.kernel.org" CC: "tglx@linutronix.de" , "mingo@redhat.com" , "hpa@zytor.com" , "x86@kernel.org" , "rkrcmar@redhat.com" , "linux-kernel@vger.kernel.org" , "joro@8bytes.org" , Chao Peng Subject: RE: [PATCH v3 7/9] KVM: x86: Implement Intel Processor Trace MSRs read/write Thread-Topic: [PATCH v3 7/9] KVM: x86: Implement Intel Processor Trace MSRs read/write Thread-Index: AQHTaDECPc+6e0u140Ku+LAGtNNKBqMsVLeAgAG1NoD//521gIAEw8gA Date: Mon, 4 Dec 2017 01:21:20 +0000 Message-ID: <82D7661F83C1A047AF7DC287873BF1E167E504FC@SHSMSX101.ccr.corp.intel.com> References: <1511814242-12949-1-git-send-email-luwei.kang@intel.com> <1511814242-12949-8-git-send-email-luwei.kang@intel.com> <3cfad210-6633-66cf-0276-95d4ca1af273@redhat.com> <82D7661F83C1A047AF7DC287873BF1E167E4F3E1@SHSMSX101.ccr.corp.intel.com> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMGM3MmFmNmUtZjBmYS00MDlhLWE3MGUtN2IxYmIzOGFjYmY4IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJOWVNOeVR4U3lnNlwvM2d2cysxdGg0RXZpbzYwVXZoXC81QXlXOTI3UWsrTThcL0VkSW94bzZmUUQ4eFE5aDB0ZzBDIn0= dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vB41Le8m020774 Content-Length: 1621 Lines: 42 > >>> + case MSR_IA32_RTIT_ADDR0_A ... MSR_IA32_RTIT_ADDR3_B: { > >>> + u32 eax, ebx, ecx, edx; > >>> + > >>> + cpuid_count(0x14, 1, &eax, &ebx, &ecx, &edx); > >> > >> Please cache the cpuid_count result, or do the cpuid_count after testing > >> vmx_pt_supported() (which you can use instead of going through kvm_x86_ops). > > > > Hi Paolo, > > Thanks for your reply. I have cache EAX in "struct pt_desc" and will initialize in vmx_vcpu_setup(). > > +struct pt_desc { > > + unsigned int addr_num; > > + struct pt_ctx host; > > + struct pt_ctx guest; > > +}; > > But kvm_init_msr_list() is invoked too early, I have to read from hardware. So, what about change like this. > > > > - cpuid_count(0x14, 1, &eax, &ebx, &ecx, &edx); > > - if (!kvm_x86_ops->pt_supported() || msrs_to_save[i] - > > - MSR_IA32_RTIT_ADDR0_A >= (eax & 0x7)) > > + if (!kvm_x86_ops->pt_supported()) > > continue; > > + cpuid_count(0x14, 1, &eax, &ebx, &ecx, &edx); > > + if (msrs_to_save[i] - > > + MSR_IA32_RTIT_ADDR0_A >= (eax & 0x7)) > > + continue; > > For kvm_init_msr_list it's okay. But can you please add a > pt_msr_count() function? > Of course, I will fix in next version. Thanks! Luwei Kang > >> > >>> + if (!kvm_x86_ops->pt_supported() || msrs_to_save[i] - > >>> + MSR_IA32_RTIT_ADDR0_A >= (eax & 0x7)) > >>> + continue; > >>> + break; > >