Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1827564ybl; Wed, 28 Aug 2019 22:41:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7h26dSF5KYhzbq8kOIVeKxr9oSrB0Myf9ovmO+g7bkeYGPezRyyt2tKJF45cLv8qJkXpm X-Received: by 2002:a63:9245:: with SMTP id s5mr6808866pgn.123.1567057261182; Wed, 28 Aug 2019 22:41:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567057261; cv=none; d=google.com; s=arc-20160816; b=fQFrAkqVv+GjL9hkKZDwf4wtrjO6CmQmgTOvue9W31OMZe5QIpl2CshxAm7jEfj+ig dHqXKFSt/UoNK2dbptjjGuTrUW2T6ThVFfPka7/LWr0NUxl/UqDDgU3pixcr6pHUAIrD 88pXNP6XRyPcgVevVMSuE/W6vGTw7rZEflfxWwCfEPhWD6RMl9H8CZOvlbuoTwLnB1jd EuDY6YTUXdZauy9NfMguwCeKO/iiOC728gsHfno8tzMSmX+8X1eSbUnZywG/aipPEJs0 vSrZ/xERWH9TwnqGKGrbFPkZd7JjXDiXJ4WJHOL1tm+D/KvUvJqgOBTmwnhUaxIOFbVc i+NA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=gonXKCzW2q7VvyweJpdSq2mBrz3lxTPlPwjmVbANGuQ=; b=ypr7P2sbr5JpEbh++5lcRCBk16PCPZSWek1HnuY1sVht8zhXSo4hDXN/w99pufAqgL B+BSCbrsEVwMRcqCc4IYmxYo6Eb0gPQLGL7HMmf4spf3jUzVwGkBHUV5s2ZFohUwODaY uxIJdPI0kD2xOCh4wquzwZWMNI9f5syucZnxw5S44mB8gugkHLZO5MElSecBxDXu1xkt pckad8mLLwza8Ig83lDvidwRqZzf5WLvDHPjBzsrEJc8y99RzOTxbMxorFXv7eoXttR+ nzhFQ7QiKoaPiUN85JbRRNg2HONmzrkLLRj7Iwp6vFT95U8evsvln2wQiaSr1u6OTXRo /OWA== 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 80si1069815pgf.5.2019.08.28.22.40.46; Wed, 28 Aug 2019 22:41:01 -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 S1727763AbfH2Fj3 (ORCPT + 99 others); Thu, 29 Aug 2019 01:39:29 -0400 Received: from mga17.intel.com ([192.55.52.151]:42165 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727736AbfH2Fj1 (ORCPT ); Thu, 29 Aug 2019 01:39:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Aug 2019 22:39:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,442,1559545200"; d="scan'208";a="210416346" Received: from icl-2s.bj.intel.com ([10.240.193.48]) by fmsmga002.fm.intel.com with ESMTP; 28 Aug 2019 22:39:24 -0700 From: Luwei Kang To: pbonzini@redhat.com, rkrcmar@redhat.com Cc: sean.j.christopherson@intel.com, 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, kvm@vger.kernel.org, linux-kernel@vger.kernel.org, Luwei Kang Subject: [RFC v1 8/9] KVM: X86: MSR_IA32_PERF_CAPABILITIES MSR emulation Date: Thu, 29 Aug 2019 13:34:08 +0800 Message-Id: <1567056849-14608-9-git-send-email-luwei.kang@intel.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1567056849-14608-1-git-send-email-luwei.kang@intel.com> References: <1567056849-14608-1-git-send-email-luwei.kang@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Expose some bits of definition which relate with enable PEBS to KVM guest especially PEBS via PT feature. Signed-off-by: Luwei Kang --- arch/x86/include/asm/kvm_host.h | 1 + arch/x86/include/asm/msr-index.h | 3 +++ arch/x86/kvm/vmx/vmx.c | 14 ++++++++++++++ 3 files changed, 18 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 2d9b0f9..94af338 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -576,6 +576,7 @@ struct kvm_vcpu_arch { u64 ia32_xss; u64 microcode_version; u64 arch_capabilities; + u64 ia32_perf_capabilities; /* * Paging state of the vcpu diff --git a/arch/x86/include/asm/msr-index.h b/arch/x86/include/asm/msr-index.h index 6321acb..4932dec 100644 --- a/arch/x86/include/asm/msr-index.h +++ b/arch/x86/include/asm/msr-index.h @@ -137,6 +137,9 @@ #define MSR_IA32_PEBS_ENABLE 0x000003f1 #define MSR_PEBS_DATA_CFG 0x000003f2 #define MSR_IA32_DS_AREA 0x00000600 +#define MSR_IA32_PERF_CAP_PEBS_TRAP (1UL << 6) +#define MSR_IA32_PERF_CAP_PEBS_ARCH_REG (1UL << 7) +#define MSR_IA32_PERF_CAP_PEBS_REC_FMT (0xfUL << 8) #define MSR_IA32_PERF_CAP_PEBS_OUTPUT_PT (1UL << 16) #define MSR_IA32_PERF_CAPABILITIES 0x00000345 #define MSR_PEBS_LD_LAT_THRESHOLD 0x000003f6 diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c index dbff8f0..71e3d42 100644 --- a/arch/x86/kvm/vmx/vmx.c +++ b/arch/x86/kvm/vmx/vmx.c @@ -1737,6 +1737,16 @@ static int vmx_get_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) return 1; msr_info->data = vcpu->arch.ia32_xss; break; + case MSR_IA32_PERF_CAPABILITIES: + if (!vmx_pdcm_supported() || !vmx_pebs_supported()) + return 1; + rdmsrl(MSR_IA32_PERF_CAPABILITIES, msr_info->data); + msr_info->data = msr_info->data & + (MSR_IA32_PERF_CAP_PEBS_TRAP | + MSR_IA32_PERF_CAP_PEBS_ARCH_REG | + MSR_IA32_PERF_CAP_PEBS_REC_FMT | + MSR_IA32_PERF_CAP_PEBS_OUTPUT_PT); + break; case MSR_IA32_RTIT_CTL: if (pt_mode != PT_MODE_HOST_GUEST) return 1; @@ -1981,6 +1991,10 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) else clear_atomic_switch_msr(vmx, MSR_IA32_XSS); break; + case MSR_IA32_PERF_CAPABILITIES: + if (!vmx_pdcm_supported() || !vmx_pebs_supported()) + return 1; + break; case MSR_IA32_RTIT_CTL: if ((pt_mode != PT_MODE_HOST_GUEST) || vmx_rtit_ctl_check(vcpu, data) || -- 1.8.3.1