Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752779AbdLAGkZ (ORCPT ); Fri, 1 Dec 2017 01:40:25 -0500 Received: from mga09.intel.com ([134.134.136.24]:13917 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752296AbdLAGkX (ORCPT ); Fri, 1 Dec 2017 01:40:23 -0500 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,344,1508828400"; d="scan'208";a="182306392" 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+LAGtNNKBqMsVLeAgAG1NoA= Date: Fri, 1 Dec 2017 06:40:19 +0000 Message-ID: <82D7661F83C1A047AF7DC287873BF1E167E4F3E1@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> In-Reply-To: <3cfad210-6633-66cf-0276-95d4ca1af273@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_IC x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZDZlODgzOGQtMjY5ZS00NWJkLWFlZDAtZGFjYmNiYWVjM2UxIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX0lDIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiJLKzJEZko4cHJGd2pkUTFONE9vNnlQcnMrNmg5Z0k0aDJEN29tUEVIc1AzWXZCaG1PSXZYZ3JcL1g1eUx0azkwRCJ9 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 vB16eU4D004729 Content-Length: 1409 Lines: 40 > > + 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; Thanks, Luwei Kang > > Thanks, > > Paolo > > > + if (!kvm_x86_ops->pt_supported() || msrs_to_save[i] - > > + MSR_IA32_RTIT_ADDR0_A >= (eax & 0x7)) > > + continue; > > + break;