Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp394351ybx; Tue, 29 Oct 2019 21:08:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7EEEyApLldcQ5RZiTPo7h34A4wsGEaSiaECigfJz2gH+qQVmhqprYYVVJGrKM2w98NnhS X-Received: by 2002:a17:906:4d4f:: with SMTP id b15mr6738560ejv.81.1572408507978; Tue, 29 Oct 2019 21:08:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572408507; cv=none; d=google.com; s=arc-20160816; b=kXzqtrdlO8z8Z9jJ0vwC7Gg1sI4rNDiK3qdxkWcIC34xtxVKUPdwcfh4/2m7Ysz+7C 2NpFtUbmmQhFE1kegxfTf4MHqA3fOgyhUfTF/2b9LKKeIUOGUfqfQ0BIQ5iddl2p1/iw /t2NXnxy7QQ9UgiYLZAOLdQYNAh1pAJNjtOel5qaK13qPabF549vUOzjYcP7/ki8g5Nk 0ly90tHxr/Gvql4To4Og2/xOSyGA7o9JaRIeBZ98off0/tJW/ZJvNgmcsjE/BEiXHVu8 c5FNsaBvMK/1DMnO89SZyYtssGsPmYHOwaB+f+zLkBKUme+h6qMxboRW8YQpNM1rCsoy ZK2g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :dlp-reaction:dlp-version:dlp-product:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=lPJJvCnv44jpCGL24wYQKytzD1mqYDumocX0DxfyoBE=; b=hhOl8vkz6lqygSsTT9lKgfbRIDnU5rpbSpj4lNqMtgCc8I883cP9w21YypNPhFYaxD xtN9G2FfQqnSQBxKr7wCfkTid521Urq5amkWf6x0+Y41RrsKerDSg4jKSLhJ2tndGEnD tHtAO6ghjVBGqR8vTFPMFvAp2LLPJ/KUoQ+q2HbmMhZsu4nVGk/6IxT9sav4Qq2Cx8rs /LjsufH2dKdwsbop/YgSYzorrbXS+c5AWfRlq4HNm5J5P+fPd5WEIKVFnW0t001Cstn8 GE3jYtok890MB+GN7V/B0gxLwcfC4Nlt2xIpmZJCqmacsiMLLjC54Brq8pzSaZBG6yz0 Pzew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n10si632426edb.175.2019.10.29.21.08.04; Tue, 29 Oct 2019 21:08:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727006AbfJ3EGx convert rfc822-to-8bit (ORCPT + 99 others); Wed, 30 Oct 2019 00:06:53 -0400 Received: from mga06.intel.com ([134.134.136.31]:36903 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725308AbfJ3EGw (ORCPT ); Wed, 30 Oct 2019 00:06:52 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Oct 2019 21:06:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.68,246,1569308400"; d="scan'208";a="205679958" Received: from fmsmsx104.amr.corp.intel.com ([10.18.124.202]) by FMSMGA003.fm.intel.com with ESMTP; 29 Oct 2019 21:06:51 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx104.amr.corp.intel.com (10.18.124.202) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 29 Oct 2019 21:06:51 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 29 Oct 2019 21:06:50 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.127]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.149]) with mapi id 14.03.0439.000; Wed, 30 Oct 2019 12:06:50 +0800 From: "Kang, Luwei" To: Peter Zijlstra CC: "kvm@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "pbonzini@redhat.com" , "rkrcmar@redhat.com" , "Christopherson, Sean J" , "vkuznets@redhat.com" , "wanpengli@tencent.com" , "jmattson@google.com" , "joro@8bytes.org" , "tglx@linutronix.de" , "mingo@redhat.com" , "bp@alien8.de" , "hpa@zytor.com" , "x86@kernel.org" , "ak@linux.intel.com" , "thomas.lendacky@amd.com" , "acme@kernel.org" , "mark.rutland@arm.com" , "alexander.shishkin@linux.intel.com" , "jolsa@redhat.com" , "namhyung@kernel.org" Subject: RE: [PATCH v1 2/8] KVM: x86: PEBS output to Intel PT MSRs emulation Thread-Topic: [PATCH v1 2/8] KVM: x86: PEBS output to Intel PT MSRs emulation Thread-Index: AQHVjLdyhOcLoCoSDkKqY/nWjYpZ1qdxNEmAgAE5RbA= Date: Wed, 30 Oct 2019 04:06:49 +0000 Message-ID: <82D7661F83C1A047AF7DC287873BF1E173835B2F@SHSMSX104.ccr.corp.intel.com> References: <1572217877-26484-1-git-send-email-luwei.kang@intel.com> <1572217877-26484-3-git-send-email-luwei.kang@intel.com> <20191029150243.GM4097@hirez.programming.kicks-ass.net> In-Reply-To: <20191029150243.GM4097@hirez.programming.kicks-ass.net> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjE2ZTE1MmEtZDQ2Mi00ZTM2LThmNzctN2ZjM2Q1MjgwOTdkIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoicXZxMFdINjhNNVM1UWlrUjNyNmt3WnZvaGxPR1MxS0dVWWpWWnFwK0tuQ1RKenFSbkl0VE8zUVVKNG9YWWJGSSJ9 dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > > Intel new hardware introduces a mechanism to direct PEBS records > > output into the Intel PT buffer that can be used for enabling PEBS in > > KVM guest. This patch implements the registers read and write > > emulation when PEBS is supported in KVM guest. > > > > KMM needs to reprogram the counters when the value of these MSRs be > > changed that to make sure it can take effect in hardware. > > > > Signed-off-by: Luwei Kang > > --- > > arch/x86/include/asm/kvm_host.h | 4 +++ > > arch/x86/include/asm/msr-index.h | 6 ++++ > > arch/x86/kvm/vmx/capabilities.h | 15 ++++++++++ > > arch/x86/kvm/vmx/pmu_intel.c | 63 ++++++++++++++++++++++++++++++++++++++-- > > 4 files changed, 86 insertions(+), 2 deletions(-) > > > > diff --git a/arch/x86/include/asm/msr-index.h > > b/arch/x86/include/asm/msr-index.h > > index 20ce682..d22f8d9 100644 > > --- a/arch/x86/include/asm/msr-index.h > > +++ b/arch/x86/include/asm/msr-index.h > > @@ -131,9 +131,13 @@ > > #define LBR_INFO_ABORT BIT_ULL(61) > > #define LBR_INFO_CYCLES 0xffff > > > > +#define MSR_IA32_PEBS_PMI_AFTER_REC BIT_ULL(60) > > +#define MSR_IA32_PEBS_OUTPUT_PT BIT_ULL(61) > > +#define MSR_IA32_PEBS_OUTPUT_MASK (3ULL << 61) > > #define MSR_IA32_PEBS_ENABLE 0x000003f1 > > #define MSR_PEBS_DATA_CFG 0x000003f2 > > #define MSR_IA32_DS_AREA 0x00000600 > > +#define MSR_IA32_PERF_CAP_PEBS_OUTPUT_PT BIT_ULL(16) > > #define MSR_IA32_PERF_CAPABILITIES 0x00000345 > > #define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6 > > > > @@ -665,6 +669,8 @@ > > #define MSR_IA32_MISC_ENABLE_FERR (1ULL << MSR_IA32_MISC_ENABLE_FERR_BIT) > > #define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX_BIT 10 > > #define MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX (1ULL << MSR_IA32_MISC_ENABLE_FERR_MULTIPLEX_BIT) > > +#define MSR_IA32_MISC_ENABLE_PEBS_BIT 12 > > +#define MSR_IA32_MISC_ENABLE_PEBS (1ULL << MSR_IA32_MISC_ENABLE_PEBS_BIT) > > #define MSR_IA32_MISC_ENABLE_TM2_BIT 13 > > #define MSR_IA32_MISC_ENABLE_TM2 (1ULL << MSR_IA32_MISC_ENABLE_TM2_BIT) > > #define MSR_IA32_MISC_ENABLE_ADJ_PREF_DISABLE_BIT 19 > > Some of these already exist but are local to perf. Don't blindly introduce more without unifying. Got it. Will reuse the exist definition in perf. Thanks, Luwei Kang